Skip to content

Commit a57fb71

Browse files
committed
PackagingSigning: make some of the private API more public
This extends the visibility of some of the private implementation to the package level to allow use for testing without `@testable` imports.
1 parent 1a0ba32 commit a57fb71

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

Sources/PackageSigning/SignatureProvider.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public struct VerifierConfiguration {
8787
public var certificateRevocation: CertificateRevocation
8888

8989
// for testing
90-
init(
90+
package init(
9191
trustedRoots: [[UInt8]],
9292
includeDefaultTrustStore: Bool,
9393
certificateExpiration: CertificateExpiration,
@@ -160,7 +160,7 @@ public enum SigningKeyType {
160160
// RSA support is internal/testing only, thus not included
161161
}
162162

163-
enum SignatureAlgorithm {
163+
package enum SignatureAlgorithm {
164164
case ecdsaP256
165165
case rsa
166166

@@ -198,19 +198,19 @@ protocol SignatureProviderProtocol {
198198

199199
// MARK: - CMS signature provider
200200

201-
struct CMSSignatureProvider: SignatureProviderProtocol {
201+
package struct CMSSignatureProvider: SignatureProviderProtocol {
202202
let signatureAlgorithm: SignatureAlgorithm
203203
let httpClient: HTTPClient
204204

205-
init(
205+
package init(
206206
signatureAlgorithm: SignatureAlgorithm,
207207
customHTTPClient: HTTPClient? = .none
208208
) {
209209
self.signatureAlgorithm = signatureAlgorithm
210210
self.httpClient = customHTTPClient ?? HTTPClient()
211211
}
212212

213-
func sign(
213+
package func sign(
214214
content: [UInt8],
215215
identity: SigningIdentity,
216216
intermediateCertificates: [[UInt8]],
@@ -264,7 +264,7 @@ struct CMSSignatureProvider: SignatureProviderProtocol {
264264
}
265265
}
266266

267-
func status(
267+
package func status(
268268
signature: [UInt8],
269269
content: [UInt8],
270270
verifierConfiguration: VerifierConfiguration,

Sources/PackageSigning/SigningEntity/FilePackageSigningEntityStorage.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import struct TSCUtility.Version
2020

2121
public struct FilePackageSigningEntityStorage: PackageSigningEntityStorage {
2222
let fileSystem: FileSystem
23-
let directoryPath: Basics.AbsolutePath
23+
package let directoryPath: Basics.AbsolutePath
2424

2525
private let encoder: JSONEncoder
2626
private let decoder: JSONDecoder
@@ -231,7 +231,7 @@ private enum StorageModel {
231231
}
232232

233233
extension PackageIdentity {
234-
var signedVersionsFilename: String {
234+
package var signedVersionsFilename: String {
235235
"\(self.description).json"
236236
}
237237
}

Sources/PackageSigning/SigningEntity/SigningEntity.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public enum SigningEntity: Hashable, Codable, CustomStringConvertible, Sendable
2424
case recognized(type: SigningEntityType, name: String, organizationalUnit: String, organization: String)
2525
case unrecognized(name: String?, organizationalUnit: String?, organization: String?)
2626

27-
static func from(certificate: Certificate) -> SigningEntity {
27+
package static func from(certificate: Certificate) -> SigningEntity {
2828
let name = certificate.subject.commonName
2929
let organizationalUnit = certificate.subject.organizationalUnitName
3030
let organization = certificate.subject.organizationName

Sources/PackageSigning/SigningIdentity.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ extension SecIdentity: SigningIdentity {}
4040
// MARK: - SwiftSigningIdentity is created using raw private key and certificate bytes
4141

4242
public struct SwiftSigningIdentity: SigningIdentity {
43-
let certificate: Certificate
43+
package let certificate: Certificate
4444
let privateKey: Certificate.PrivateKey
4545

4646
// for testing
47-
init(certificate: Certificate, privateKey: Certificate.PrivateKey) {
47+
package init(certificate: Certificate, privateKey: Certificate.PrivateKey) {
4848
self.certificate = certificate
4949
self.privateKey = privateKey
5050
}

Sources/PackageSigning/X509Extensions.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ extension Certificate {
3838
self = try Certificate(Array(data))
3939
}
4040

41-
init(secIdentity: SecIdentity) throws {
41+
package init(secIdentity: SecIdentity) throws {
4242
var secCertificate: SecCertificate?
4343
let status = SecIdentityCopyCertificate(secIdentity, &secCertificate)
4444
guard status == errSecSuccess, let secCertificate else {
@@ -56,15 +56,15 @@ extension Certificate {
5656
}
5757

5858
extension DistinguishedName {
59-
var commonName: String? {
59+
package var commonName: String? {
6060
self.stringAttribute(oid: ASN1ObjectIdentifier.NameAttributes.commonName)
6161
}
6262

63-
var organizationalUnitName: String? {
63+
package var organizationalUnitName: String? {
6464
self.stringAttribute(oid: ASN1ObjectIdentifier.NameAttributes.organizationalUnitName)
6565
}
6666

67-
var organizationName: String? {
67+
package var organizationName: String? {
6868
self.stringAttribute(oid: ASN1ObjectIdentifier.NameAttributes.organizationName)
6969
}
7070

@@ -83,7 +83,7 @@ extension DistinguishedName {
8383
extension Certificate {
8484
private static let cache = ThreadSafeKeyValueStore<[UInt8], Certificate>()
8585

86-
init(_ bytes: [UInt8]) throws {
86+
package init(_ bytes: [UInt8]) throws {
8787
if let cached = Self.cache[bytes] {
8888
self = cached
8989
} else {

0 commit comments

Comments
 (0)