diff --git a/Package.resolved b/Package.resolved index 263b71e..9705792 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,6 +1,24 @@ { - "originHash" : "d82261f801b2b01101e71638a69c962753ac4854dfd3bcc135b5147bd265209b", + "originHash" : "0334db293306eafc7f9541f6ae0a8f3f10c0b5d1d3f585b7f5dcbe3247ffa790", "pins" : [ + { + "identity" : "eudi-lib-ios-iso18013-data-model", + "kind" : "remoteSourceControl", + "location" : "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-iso18013-data-model.git", + "state" : { + "revision" : "ef353c447c7716c1fe5f5905ff98e089f5a29d43", + "version" : "0.5.1" + } + }, + { + "identity" : "eudi-lib-ios-iso18013-security", + "kind" : "remoteSourceControl", + "location" : "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-iso18013-security.git", + "state" : { + "revision" : "d3d9935b24b05902f840471bb70f651caa7f4cb5", + "version" : "0.4.0" + } + }, { "identity" : "swift-asn1", "kind" : "remoteSourceControl", diff --git a/Package.swift b/Package.swift index f28bb40..44643b7 100644 --- a/Package.swift +++ b/Package.swift @@ -13,12 +13,7 @@ let package = Package( targets: ["MdocDataTransfer18013"]), ], dependencies: [ - .package(path: "../eudi-lib-ios-iso18013-security"), - //.package(path: "../eudi-lib-ios-wallet-storage"), - //.package(path: "../eudi-lib-sdjwt-swift"), - //.package(url: "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-wallet-storage.git", exact: "0.4.1"), - //.package(url: "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-iso18013-security.git", exact: "0.3.1"), - // .package(url: "https://github.com/eu-digital-identity-wallet/eudi-lib-sdjwt-swift.git", exact: "0.3.2"), + .package(url: "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-iso18013-security.git", exact: "0.4.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. @@ -26,8 +21,6 @@ let package = Package( .target( name: "MdocDataTransfer18013", dependencies: [ .product(name: "MdocSecurity18013", package: "eudi-lib-ios-iso18013-security")]), - //.product(name: "WalletStorage", package: "eudi-lib-ios-wallet-storage"), - //.product(name: "eudi-lib-sdjwt-swift", package: "eudi-lib-sdjwt-swift")]), .testTarget( name: "MdocDataTransfer18013Tests", dependencies: ["MdocDataTransfer18013"]), diff --git a/Sources/MdocDataTransfer18013/InitializeTransferInfo.swift b/Sources/MdocDataTransfer18013/InitializeTransferInfo.swift index 05ca9db..463182e 100644 --- a/Sources/MdocDataTransfer18013/InitializeTransferInfo.swift +++ b/Sources/MdocDataTransfer18013/InitializeTransferInfo.swift @@ -4,12 +4,13 @@ import MdocSecurity18013 public struct InitializeTransferData: Sendable { - public init(dataFormats: [String : String], documentData: [String : Data], privateKeyData: [String : String], trustedCertificates: [Data], deviceAuthMethod: String) { + public init(dataFormats: [String : String], documentData: [String : Data], privateKeyData: [String : String], trustedCertificates: [Data], deviceAuthMethod: String, docTypesToΙds: [String : String]) { self.dataFormats = dataFormats self.documentData = documentData self.privateKeyData = privateKeyData self.trustedCertificates = trustedCertificates self.deviceAuthMethod = deviceAuthMethod + self.docTypesToΙds = docTypesToΙds } public let dataFormats: [String: String] @@ -21,20 +22,23 @@ public struct InitializeTransferData: Sendable { public let trustedCertificates: [Data] /// device auth method public let deviceAuthMethod: String + // document id to document type map + public let docTypesToΙds: [String: String] public func toInitializeTransferInfo() -> InitializeTransferInfo { // filter data and private keys by format let documentObjects = documentData + let dataFormats = Dictionary.init(uniqueKeysWithValues: dataFormats.map { k,v in (k, DocDataFormat(rawValue: v)) }).compactMapValues { $0 } let privateKeyObjects = Dictionary.init(uniqueKeysWithValues: privateKeyData.map { k,v in (k, CoseKeyPrivate(privateKeyId: k, secureArea: SecureAreaRegistry.shared.get(name: v))) }) let iaca = trustedCertificates.map { SecCertificateCreateWithData(nil, $0 as CFData)! } let deviceAuthMethod = DeviceAuthMethod(rawValue: deviceAuthMethod) ?? .deviceMac - return InitializeTransferInfo(dataFormats: dataFormats, documentObjects: documentObjects, privateKeyObjects: privateKeyObjects, iaca: iaca, deviceAuthMethod: deviceAuthMethod) + return InitializeTransferInfo(dataFormats: dataFormats, documentObjects: documentObjects, privateKeyObjects: privateKeyObjects, iaca: iaca, deviceAuthMethod: deviceAuthMethod, docTypesToΙds: docTypesToΙds) } } public struct InitializeTransferInfo { /// doc-id to data format - public let dataFormats: [String: String] + public let dataFormats: [String: DocDataFormat] /// doc-id to document objects public let documentObjects: [String: Data] /// doc-id to private key objects @@ -43,4 +47,6 @@ public struct InitializeTransferInfo { public let iaca: [SecCertificate] /// device auth method public let deviceAuthMethod: DeviceAuthMethod + // document id to document type map + public let docTypesToΙds: [String: String] } \ No newline at end of file diff --git a/Sources/MdocDataTransfer18013/MdocHelpers.swift b/Sources/MdocDataTransfer18013/MdocHelpers.swift index 6385916..b7a16f1 100644 --- a/Sources/MdocDataTransfer18013/MdocHelpers.swift +++ b/Sources/MdocDataTransfer18013/MdocHelpers.swift @@ -103,7 +103,7 @@ public class MdocHelpers { /// - sessionTranscript: Session Transcript object /// - dauthMethod: Mdoc Authentication method /// - Returns: (Device response object, valid requested items, error request items) tuple - public static func getDeviceResponseToSend(deviceRequest: DeviceRequest?, issuerSigned: [String: IssuerSigned], selectedItems: RequestItems? = nil, sessionEncryption: SessionEncryption? = nil, eReaderKey: CoseKey? = nil, devicePrivateKeys: [String: CoseKeyPrivate], sessionTranscript: SessionTranscript? = nil, dauthMethod: DeviceAuthMethod, unlockData: [String: Data]) async throws -> (response: DeviceResponse, validRequestItems: RequestItems, errorRequestItems: RequestItems)? { + public static func getDeviceResponseToSend(deviceRequest: DeviceRequest?, issuerSigned: [String: IssuerSigned], selectedItems: RequestItems? = nil, sessionEncryption: SessionEncryption? = nil, eReaderKey: CoseKey? = nil, devicePrivateKeys: [String: CoseKeyPrivate], sessionTranscript: SessionTranscript? = nil, dauthMethod: DeviceAuthMethod, unlockData: [String: Data]) async throws -> (deviceResponse: DeviceResponse, validRequestItems: RequestItems, errorRequestItems: RequestItems)? { var docFiltered = [Document](); var docErrors = [[DocType: UInt64]]() var validReqItemsDocDict = RequestItems(); var errorReqItemsDocDict = RequestItems() guard deviceRequest != nil || selectedItems != nil else { fatalError("Invalid call") }