Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(app): fix flow without attestation VC #770

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions demo/app/ios/Runner/OpenID4CI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ public class OpenID4CI {
return credentials.atIndex(0)!;
}

func requestCredentials(didVerificationMethod: ApiVerificationMethod, otp: String, attestationVC: String?) throws -> Array<Dictionary<String, Any>> {
func requestCredentials(didVerificationMethod: ApiVerificationMethod, otp: String,
attestationVC: String?, attestationVM: ApiVerificationMethod?) throws -> Array<Dictionary<String, Any>> {
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)
Expand Down
6 changes: 3 additions & 3 deletions demo/app/ios/Runner/OpenID4VP.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Any>,
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")
// }
Expand All @@ -112,8 +112,8 @@ public class OpenID4VP {

let opts = Openid4vpNewPresentCredentialOpts()

if (attestationVC != nil && didVerificationMethod != nil) {
opts?.setAttestationVC(didVerificationMethod, vc: attestationVC)
if (attestationVC != nil && attestationVM != nil) {
opts?.setAttestationVC(attestationVM, vc: attestationVC)
}

for scope in customScopes {
Expand Down
16 changes: 12 additions & 4 deletions demo/app/ios/Runner/flutterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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 != nil && attestationDID == nil) {
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",
Expand Down
Loading