Skip to content

Commit

Permalink
Add optional credentialIssuerIdentifier and configurationIdentifier p…
Browse files Browse the repository at this point in the history
…roperties to DocClaimsDecodable and related models
  • Loading branch information
phisakel committed Jan 15, 2025
1 parent a9c97d0 commit af53063
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public protocol DocClaimsDecodable: Sendable, AgeAttesting {
var display: [DisplayMetadata]? { get }
/// The display properties of the issuer
var issuerDisplay: [DisplayMetadata]? { get }
/// The credential issuer identifier
var credentialIssuerIdentifier: String? { get }
/// The issuer configuration identifier
var configurationIdentifier: String? { get }
// The document type. For CBOR (mso_mdoc) documents is native, for SD-JWT (vc+sd-jwt) documents is the type of the document.
var docType: String? { get }
// document claims in a format agnostic way
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Foundation

/// A protocol to create a ``DocClaimsDecodable`` from a cbor encoded ``IssuerSigned`` struct
public protocol DocClaimsDecodableFactory: Sendable {
func makeClaimsDecodableFromCbor(id: String, createdAt: Date, issuerSigned: IssuerSigned, displayName: String?, display: [DisplayMetadata]?, issuerDisplay: [DisplayMetadata]?, credentialIssuerIdentifier: String, configurationIdentifier: String, claimDisplayNames: [NameSpace: [String: String]]?, mandatoryClaims: [NameSpace: [String: Bool]]?, claimValueTypes: [NameSpace: [String: String]]?) -> (
func makeClaimsDecodableFromCbor(id: String, createdAt: Date, issuerSigned: IssuerSigned, displayName: String?, display: [DisplayMetadata]?, issuerDisplay: [DisplayMetadata]?, credentialIssuerIdentifier: String?, configurationIdentifier: String?, claimDisplayNames: [NameSpace: [String: String]]?, mandatoryClaims: [NameSpace: [String: Bool]]?, claimValueTypes: [NameSpace: [String: String]]?) -> (
any DocClaimsDecodable
)?
}
6 changes: 3 additions & 3 deletions Sources/MdocDataModel18013/MdocKnownDocTypes/EuPidModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public struct EuPidModel: Decodable, DocClaimsDecodable, Sendable {
public var displayName: String? = String("eu_pid_doctype_name")
public var modifiedAt: Date?
public var docDataFormat: DocDataFormat = .cbor
public var credentialIssuerIdentifier: String
public var configurationIdentifier: String
public var credentialIssuerIdentifier: String?
public var configurationIdentifier: String?
public let family_name: String?
public let given_name: String?
public let birth_date: String?
Expand Down Expand Up @@ -100,7 +100,7 @@ public struct EuPidModel: Decodable, DocClaimsDecodable, Sendable {
}

extension EuPidModel {
public init?(id: String, createdAt: Date, issuerSigned: IssuerSigned, displayName: String?, display: [DisplayMetadata]?, issuerDisplay: [DisplayMetadata]?, credentialIssuerIdentifier: String, configurationIdentifier: String, claimDisplayNames: [NameSpace: [String: String]]?, mandatoryClaims: [NameSpace: [String: Bool]]?, claimValueTypes: [NameSpace: [String: String]]?) {
public init?(id: String, createdAt: Date, issuerSigned: IssuerSigned, displayName: String?, display: [DisplayMetadata]?, issuerDisplay: [DisplayMetadata]?, credentialIssuerIdentifier: String?, configurationIdentifier: String?, claimDisplayNames: [NameSpace: [String: String]]?, mandatoryClaims: [NameSpace: [String: Bool]]?, claimValueTypes: [NameSpace: [String: String]]?) {
self.id = id
self.createdAt = createdAt; self.displayName = displayName; self.display = display; self.issuerDisplay = issuerDisplay
self.credentialIssuerIdentifier = credentialIssuerIdentifier; self.configurationIdentifier = configurationIdentifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import Foundation
public struct GenericMdocModel: DocClaimsDecodable, Sendable {
public var display: [DisplayMetadata]?
public var issuerDisplay: [DisplayMetadata]?
public var credentialIssuerIdentifier: String
public var configurationIdentifier: String
public var credentialIssuerIdentifier: String?
public var configurationIdentifier: String?
public var id: String = UUID().uuidString
public var createdAt: Date = Date()
public var docType: String?
Expand All @@ -18,7 +18,7 @@ public struct GenericMdocModel: DocClaimsDecodable, Sendable {
public var docDataFormat: DocDataFormat
public var hashingAlg: String?

public init(id: String = UUID().uuidString, createdAt: Date = Date(), docType: String?, displayName: String?, display: [DisplayMetadata]?, issuerDisplay: [DisplayMetadata]? = nil, credentialIssuerIdentifier: String, configurationIdentifier: String, modifiedAt: Date?, ageOverXX: [Int : Bool] = [Int: Bool](), docClaims: [DocClaim] = [DocClaim](), docDataFormat: DocDataFormat, hashingAlg: String?) {
public init(id: String = UUID().uuidString, createdAt: Date = Date(), docType: String?, displayName: String?, display: [DisplayMetadata]?, issuerDisplay: [DisplayMetadata]? = nil, credentialIssuerIdentifier: String?, configurationIdentifier: String?, modifiedAt: Date?, ageOverXX: [Int : Bool] = [Int: Bool](), docClaims: [DocClaim] = [DocClaim](), docDataFormat: DocDataFormat, hashingAlg: String?) {
self.id = id
self.createdAt = createdAt
self.docType = docType
Expand All @@ -35,7 +35,7 @@ public struct GenericMdocModel: DocClaimsDecodable, Sendable {

extension GenericMdocModel {

public init?(id: String, createdAt: Date, issuerSigned: IssuerSigned, docType: String, displayName: String?, display: [DisplayMetadata]?, issuerDisplay: [DisplayMetadata]?, credentialIssuerIdentifier: String, configurationIdentifier: String, claimDisplayNames: [NameSpace: [String: String]]?, mandatoryClaims: [NameSpace: [String: Bool]]?, claimValueTypes: [NameSpace: [String: String]]?) {
public init?(id: String, createdAt: Date, issuerSigned: IssuerSigned, docType: String, displayName: String?, display: [DisplayMetadata]?, issuerDisplay: [DisplayMetadata]?, credentialIssuerIdentifier: String?, configurationIdentifier: String?, claimDisplayNames: [NameSpace: [String: String]]?, mandatoryClaims: [NameSpace: [String: Bool]]?, claimValueTypes: [NameSpace: [String: String]]?) {
self.id = id; self.createdAt = createdAt; self.displayName = displayName
self.display = display; self.issuerDisplay = issuerDisplay
self.credentialIssuerIdentifier = credentialIssuerIdentifier; self.configurationIdentifier = configurationIdentifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import Foundation
public struct IsoMdlModel: Decodable, DocClaimsDecodable, Sendable {
public var display: [DisplayMetadata]?
public var issuerDisplay: [DisplayMetadata]?
public var credentialIssuerIdentifier: String
public var configurationIdentifier: String
public var credentialIssuerIdentifier: String?
public var configurationIdentifier: String?
public var id: String = UUID().uuidString
public var createdAt: Date = Date()
public var docType: String? = Self.isoDocType
Expand Down Expand Up @@ -125,7 +125,7 @@ public struct IsoMdlModel: Decodable, DocClaimsDecodable, Sendable {


extension IsoMdlModel {
public init?(id: String, createdAt: Date, issuerSigned: IssuerSigned, displayName: String?, display: [DisplayMetadata]?, issuerDisplay: [DisplayMetadata]?, credentialIssuerIdentifier: String, configurationIdentifier: String, claimDisplayNames: [NameSpace: [String: String]]?, mandatoryClaims: [NameSpace: [String: Bool]]?, claimValueTypes: [NameSpace: [String: String]]?) {
public init?(id: String, createdAt: Date, issuerSigned: IssuerSigned, displayName: String?, display: [DisplayMetadata]?, issuerDisplay: [DisplayMetadata]?, credentialIssuerIdentifier: String?, configurationIdentifier: String?, claimDisplayNames: [NameSpace: [String: String]]?, mandatoryClaims: [NameSpace: [String: Bool]]?, claimValueTypes: [NameSpace: [String: String]]?) {
self.id = id; self.createdAt = createdAt; self.displayName = displayName; self.display = display; self.issuerDisplay = issuerDisplay
self.credentialIssuerIdentifier = credentialIssuerIdentifier; self.configurationIdentifier = configurationIdentifier
guard let nameSpaceItems = Self.getCborSignedItems(issuerSigned, nameSpaces) else { return nil }
Expand Down

0 comments on commit af53063

Please sign in to comment.