Skip to content

Commit

Permalink
Update package dependencies and enhance InitializeTransferData struct…
Browse files Browse the repository at this point in the history
…ure to include document type mapping
  • Loading branch information
phisakel committed Dec 18, 2024
1 parent 7864a20 commit 02938f1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
20 changes: 19 additions & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
9 changes: 1 addition & 8 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,14 @@ 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.
// Targets can depend on other targets in this package and products from dependencies.
.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"]),
Expand Down
12 changes: 9 additions & 3 deletions Sources/MdocDataTransfer18013/InitializeTransferInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand All @@ -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]
}
2 changes: 1 addition & 1 deletion Sources/MdocDataTransfer18013/MdocHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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") }
Expand Down

0 comments on commit 02938f1

Please sign in to comment.