From e11d1c7ce9da88e24c02c9ebbb35cf0a5c635954 Mon Sep 17 00:00:00 2001 From: Volodymyr Kubiv Date: Tue, 16 Apr 2024 09:58:54 +0300 Subject: [PATCH 1/2] fix(app): fix flow without attestation VC Signed-off-by: Volodymyr Kubiv --- demo/app/ios/Runner/OpenID4CI.swift | 5 +++-- demo/app/ios/Runner/OpenID4VP.swift | 4 ++-- demo/app/ios/Runner/flutterPlugin.swift | 16 ++++++++++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/demo/app/ios/Runner/OpenID4CI.swift b/demo/app/ios/Runner/OpenID4CI.swift index a9f44eb2..7a99cb2d 100644 --- a/demo/app/ios/Runner/OpenID4CI.swift +++ b/demo/app/ios/Runner/OpenID4CI.swift @@ -94,11 +94,12 @@ public class OpenID4CI { return credentials.atIndex(0)!; } - func requestCredentials(didVerificationMethod: ApiVerificationMethod, otp: String, attestationVC: String?) throws -> Array> { + func requestCredentials(didVerificationMethod: ApiVerificationMethod, otp: String, + attestationVC: String?, attestationVM: ApiVerificationMethod?) throws -> Array> { let opts = Openid4ciRequestCredentialWithPreAuthOpts()!.setPIN(otp)! if(attestationVC != nil) { - opts.setAttestationVC(didVerificationMethod, vc: attestationVC) + opts.setAttestationVC(attestationVM!, vc: attestationVC) } let credentials = try initiatedInteraction.requestCredential(withPreAuth: didVerificationMethod, opts: opts) diff --git a/demo/app/ios/Runner/OpenID4VP.swift b/demo/app/ios/Runner/OpenID4VP.swift index a2914882..cd0a34c8 100644 --- a/demo/app/ios/Runner/OpenID4VP.swift +++ b/demo/app/ios/Runner/OpenID4VP.swift @@ -102,7 +102,7 @@ public class OpenID4VP { * initiatedInteraction has PresentCredential method which presents credentials to redirect uri from request object. */ func presentCredential(selectedCredentials: VerifiableCredentialsArray, customScopes: Dictionary, - didVerificationMethod: ApiVerificationMethod?, attestationVC: String?) throws { + didVerificationMethod: ApiVerificationMethod?, attestationVC: String?, attestationVM: ApiVerificationMethod?) throws { // guard let vpQueryContent = self.vpQueryContent else { // throw OpenID4VPError.runtimeError("OpenID4VP interaction not properly initialized, call processAuthorizationRequest first") // } @@ -112,7 +112,7 @@ public class OpenID4VP { let opts = Openid4vpNewPresentCredentialOpts() - if (attestationVC != nil && didVerificationMethod != nil) { + if (attestationVC != nil && attestationVM != nil) { opts?.setAttestationVC(didVerificationMethod, vc: attestationVC) } diff --git a/demo/app/ios/Runner/flutterPlugin.swift b/demo/app/ios/Runner/flutterPlugin.swift index 6f65ad60..caf7c84e 100644 --- a/demo/app/ios/Runner/flutterPlugin.swift +++ b/demo/app/ios/Runner/flutterPlugin.swift @@ -322,7 +322,8 @@ public class SwiftWalletSDKPlugin: NSObject, FlutterPlugin { try openID4VP.presentCredential( selectedCredentials: selectedCredentialsArray!, customScopes: customScopeList, - didVerificationMethod: attestationDID?.assertionMethod(), attestationVC:attestationVC) + didVerificationMethod: didDocResolution?.assertionMethod(), attestationVC:attestationVC, + attestationVM: attestationDID?.assertionMethod()) result(true); } catch let error as NSError{ @@ -830,17 +831,24 @@ public class SwiftWalletSDKPlugin: NSObject, FlutterPlugin { message: "error while process requestCredential credential", details: "openID4CI not initiated. Call authorize before this.")) } - - guard let attestationDID = self.attestationDID else{ + + guard let didDocResolution = self.didDocResolution else{ return result(FlutterError.init(code: "NATIVE_ERR", message: "error while process requestCredential credential", details: "Did document not initialized")) } let attestationVC = arguments["attestationVC"] as? String + + if (attestationVC != null && attestationDID == null) { + return result(FlutterError.init(code: "NATIVE_ERR", + message: "error while process requestCredential credential", + details: "attestation DID document not initialized")) + } do { - let credentialCreated = try openID4CI.requestCredentials(didVerificationMethod: attestationDID.assertionMethod(), otp: otp!, attestationVC: attestationVC) + let credentialCreated = try openID4CI.requestCredentials(didVerificationMethod: didDocResolution.assertionMethod(), otp: otp!, + attestationVC: attestationVC, attestationVM: attestationDID?.assertionMethod()) result(credentialCreated) } catch let error as NSError{ return result(FlutterError.init(code: "Exception", From d84c904b2c973dc8bd7c4e13060cf945b3722e40 Mon Sep 17 00:00:00 2001 From: Volodymyr Kubiv Date: Tue, 16 Apr 2024 12:49:50 +0300 Subject: [PATCH 2/2] fix(app): fix flow without attestation VC Signed-off-by: Volodymyr Kubiv --- demo/app/ios/Runner/OpenID4VP.swift | 2 +- demo/app/ios/Runner/flutterPlugin.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demo/app/ios/Runner/OpenID4VP.swift b/demo/app/ios/Runner/OpenID4VP.swift index cd0a34c8..6d4453c6 100644 --- a/demo/app/ios/Runner/OpenID4VP.swift +++ b/demo/app/ios/Runner/OpenID4VP.swift @@ -113,7 +113,7 @@ public class OpenID4VP { let opts = Openid4vpNewPresentCredentialOpts() if (attestationVC != nil && attestationVM != nil) { - opts?.setAttestationVC(didVerificationMethod, vc: attestationVC) + opts?.setAttestationVC(attestationVM, vc: attestationVC) } for scope in customScopes { diff --git a/demo/app/ios/Runner/flutterPlugin.swift b/demo/app/ios/Runner/flutterPlugin.swift index caf7c84e..905d337e 100644 --- a/demo/app/ios/Runner/flutterPlugin.swift +++ b/demo/app/ios/Runner/flutterPlugin.swift @@ -840,7 +840,7 @@ public class SwiftWalletSDKPlugin: NSObject, FlutterPlugin { let attestationVC = arguments["attestationVC"] as? String - if (attestationVC != null && attestationDID == null) { + if (attestationVC != nil && attestationDID == nil) { return result(FlutterError.init(code: "NATIVE_ERR", message: "error while process requestCredential credential", details: "attestation DID document not initialized"))