Skip to content

Commit a0b0326

Browse files
authored
Expose SigningEntity via package metadata (#6444)
Prior changes have laid the groundwork for this, but we haven't actually exposed the signing entity here yet. rdar://107033737 (cherry picked from commit 7a8a9e1)
1 parent f63022a commit a0b0326

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Sources/PackageMetadata/PackageMetadata.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public struct Package {
3737
public let type: String
3838
public let checksum: String?
3939
public let signing: Signing?
40+
public let signingEntity: RegistryReleaseMetadata.SigningEntity?
4041
}
4142

4243
public struct Signing: Sendable {
@@ -421,13 +422,25 @@ extension Package.Signing {
421422
}
422423
}
423424

425+
extension RegistryReleaseMetadata.SigningEntity {
426+
fileprivate init(_ entity: SigningEntity) {
427+
switch entity {
428+
case .recognized(let type, let name, let organizationalUnit, let organization):
429+
self = .recognized(type: type.rawValue, commonName: name, organization: organization, identity: organizationalUnit)
430+
case .unrecognized(let name, _, let organization):
431+
self = .unrecognized(commonName: name, organization: organization)
432+
}
433+
}
434+
}
435+
424436
extension Package.Resource {
425437
fileprivate init(_ resource: RegistryClient.PackageVersionMetadata.Resource) {
426438
self.init(
427439
name: resource.name,
428440
type: resource.type,
429441
checksum: resource.checksum,
430-
signing: resource.signing.map { .init($0) }
442+
signing: resource.signing.map { .init($0) },
443+
signingEntity: resource.signingEntity.map { .init($0) }
431444
)
432445
}
433446
}

Sources/PackageModel/RegistryReleaseMetadata.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public struct RegistryReleaseMetadata {
105105
}
106106
}
107107

108-
public enum SigningEntity: Codable, Equatable {
108+
public enum SigningEntity: Codable, Equatable, Sendable {
109109
case recognized(type: String, commonName: String?, organization: String?, identity: String?)
110110
case unrecognized(commonName: String?, organization: String?)
111111
}

0 commit comments

Comments
 (0)