Skip to content

Commit

Permalink
Merge branch 'main' into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
phisakel committed Sep 27, 2024
2 parents 93f67bf + 00fcd4c commit 7d159c5
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 22 deletions.
14 changes: 7 additions & 7 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-openid4vci-swift.git",
"state" : {
"revision" : "134b1ef6878e1ca8afa8ab92d18af29f84baa862",
"version" : "0.4.4"
"revision" : "78fbd3f8599537649dcea3331d8b54ea00fe2551",
"version" : "0.5.0"
}
},
{
Expand All @@ -68,8 +68,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-siop-openid4vp-swift.git",
"state" : {
"revision" : "894b2de7ee21affbb065522f3d3ea6467b963797",
"version" : "0.3.4"
"revision" : "294e198eb9daf7fbed1b6f6cac27b2ca86a38f50",
"version" : "0.4.0"
}
},
{
Expand All @@ -93,10 +93,10 @@
{
"identity" : "joseswift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/niscy-eudiw/JOSESwift.git",
"location" : "https://github.com/airsidemobile/JOSESwift.git",
"state" : {
"revision" : "518cedba79ef18867191811b161471298b6cb7c8",
"version" : "2.4.1-gcm"
"revision" : "c2664a902e75c0426a1d43132bd4babc6fd173d3",
"version" : "3.0.0"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ let package = Package(
.package(url: "https://github.com/crspybits/swift-log-file", from: "0.1.0"),
.package(url: "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-iso18013-data-transfer.git", exact: "0.3.1"),
.package(url: "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-wallet-storage.git", exact: "0.2.8"),
.package(url: "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-siop-openid4vp-swift.git", exact: "0.3.4"),
.package(url: "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-openid4vci-swift.git", exact: "0.4.4"),
.package(url: "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-siop-openid4vp-swift.git", exact: "0.4.0"),
.package(url: "https://github.com/eu-digital-identity-wallet/eudi-lib-ios-openid4vci-swift.git", exact: "0.5.0"),
],
targets: [
// Targets are the basic building∫ blocks of a package, defining a module or a test suite.
Expand Down
2 changes: 1 addition & 1 deletion Sources/EudiWalletKit/Services/OpenId4VpService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public class OpenId4VpService: PresentationService {

fileprivate func SendVpToken(_ vpTokenStr: String?, _ pd: PresentationDefinition, _ resolved: ResolvedRequestData, _ onSuccess: ((URL?) -> Void)?) async throws {
let consent: ClientConsent = if let vpTokenStr {
.vpToken(vpToken: .msoMdoc(vpTokenStr, apu: mdocGeneratedNonce.base64urlEncode), presentationSubmission: .init(id: UUID().uuidString, definitionID: pd.id, descriptorMap: pd.inputDescriptors.filter { $0.formatContainer?.formats.contains(where: { $0["designation"].string?.lowercased() == "mso_mdoc" }) ?? false }.map { DescriptorMap(id: $0.id, format: "mso_mdoc", path: "$")} ))
.vpToken(vpToken: .init(verifiablePresentations: [.generic(vpTokenStr)]), presentationSubmission: .init(id: UUID().uuidString, definitionID: pd.id, descriptorMap: pd.inputDescriptors.filter { $0.formatContainer?.formats.contains(where: { $0["designation"].string?.lowercased() == "mso_mdoc" }) ?? false }.map { DescriptorMap(id: $0.id, format: "mso_mdoc", path: "$")} ))
} else { .negative(message: "Rejected") }
// Generate a direct post authorisation response
let response = try AuthorizationResponse(resolvedRequest: resolved, consent: consent, walletOpenId4VPConfig: getWalletConf(verifierApiUrl: openId4VpVerifierApiUri, verifierLegalName: openId4VpVerifierLegalName))
Expand Down
14 changes: 7 additions & 7 deletions Sources/EudiWalletKit/Services/PresentationSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import LocalAuthentication
/// This class wraps the ``PresentationService`` instance, providing bindable fields to a SwifUI view
public class PresentationSession: ObservableObject {
public var presentationService: any PresentationService
/// Reader certificate issuer (only for BLE flow wih verifier using reader authentication)
/// Reader certificate issuer (the Common Name (CN) from the verifier's certificate)
@Published public var readerCertIssuer: String?
/// Reader legal name (if provided)
@Published public var readerLegalName: String?
Expand All @@ -44,12 +44,12 @@ public class PresentationSession: ObservableObject {
var handleSelected: ((Bool, RequestItems?) -> Void)?
/// Device engagement data (QR data for the BLE flow)
@Published public var deviceEngagement: String?
// map of document id to doc types
public var docIdAndTypes: [String: String]
// map of document id to (doc type, display name) pairs
public var docIdAndTypes: [String: (String, String?)]
/// User authentication required
var userAuthenticationRequired: Bool

public init(presentationService: any PresentationService, docIdAndTypes: [String: String], userAuthenticationRequired: Bool) {
public init(presentationService: any PresentationService, docIdAndTypes: [String: (String, String?)], userAuthenticationRequired: Bool) {
self.presentationService = presentationService
self.docIdAndTypes = docIdAndTypes
self.userAuthenticationRequired = userAuthenticationRequired
Expand All @@ -65,10 +65,10 @@ public class PresentationSession: ObservableObject {
// show the items as checkboxes
guard let validRequestItems = request[UserRequestKeys.valid_items_requested.rawValue] as? RequestItems else { return }
disclosedDocuments = [DocElementsViewModel]()
for (docId, docType) in docIdAndTypes {
var tmp = validRequestItems.toDocElementViewModels(docId: docId, docType: docType, valid: true)
for (docId, (docType, displayName)) in docIdAndTypes {
var tmp = validRequestItems.toDocElementViewModels(docId: docId, docType: docType, displayName: displayName, valid: true)
if let errorRequestItems = request[UserRequestKeys.error_items_requested.rawValue] as? RequestItems, errorRequestItems.count > 0 {
tmp = tmp.merging(with: errorRequestItems.toDocElementViewModels(docId: docId, docType: docType, valid: false))
tmp = tmp.merging(with: errorRequestItems.toDocElementViewModels(docId: docId, docType: docType, displayName: displayName, valid: false))
}
disclosedDocuments.append(contentsOf: tmp)
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/EudiWalletKit/Services/StorageManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public class StorageManager: ObservableObject {
return retModel
}

public func getDocIdsToTypes() -> [String: String] {
Dictionary(uniqueKeysWithValues: mdocModels.map { m in (m.id, m.docType) })
public func getDocIdsToTypes() -> [String: (String, String?)] {
Dictionary(uniqueKeysWithValues: mdocModels.map { m in (m.id, (m.docType, m.displayName) ) })
}

/// Load documents from storage
Expand Down
7 changes: 4 additions & 3 deletions Sources/EudiWalletKit/ViewModels/DocElementsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public struct DocElementsViewModel: Identifiable {
public var id: String { docId }
public var docId: String
public let docType: String
public let displayName: String?
public var isEnabled: Bool
public var elements: [ElementViewModel]
}
Expand All @@ -47,10 +48,10 @@ extension DocElementsViewModel {
}

extension RequestItems {
func toDocElementViewModels(docId: String, docType: String, valid: Bool) -> [DocElementsViewModel] {
func toDocElementViewModels(docId: String, docType: String, displayName: String?, valid: Bool) -> [DocElementsViewModel] {
compactMap { dType,nsItems in
if dType != docType { nil }
else { DocElementsViewModel(docId: docId, docType: docType, isEnabled: valid, elements: DocElementsViewModel.fluttenItemViewModels(nsItems, valid: valid, mandatoryElementKeys: DocElementsViewModel.getMandatoryElementKeys(docType: docType))) }
else { DocElementsViewModel(docId: docId, docType: docType, displayName: displayName, isEnabled: valid, elements: DocElementsViewModel.fluttenItemViewModels(nsItems, valid: valid, mandatoryElementKeys: DocElementsViewModel.getMandatoryElementKeys(docType: docType))) }
}
}
}
Expand All @@ -63,7 +64,7 @@ extension Array where Element == DocElementsViewModel {
for otherDE in other {
if let exist = first(where: { $0.docId == otherDE.docId}) {
let newElements = (exist.elements + otherDE.elements).sorted(by: { $0.isEnabled && $1.isDisabled })
res.append(DocElementsViewModel(docId: exist.docId, docType: exist.docType, isEnabled: exist.isEnabled, elements: newElements))
res.append(DocElementsViewModel(docId: exist.docId, docType: exist.docType, displayName: exist.displayName, isEnabled: exist.isEnabled, elements: newElements))
}
else { res.append(otherDE) }
}
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v0.6.8
- Updated OpenID4VCI to version 0.5.0
- Updated OpenID4VP to version 0.4.0

## v0.6.7

### Added methods:
Expand Down

0 comments on commit 7d159c5

Please sign in to comment.