diff --git a/demo/app/lib/models/store_credential_data.dart b/demo/app/lib/models/store_credential_data.dart index 740a2925..30ef9a0d 100644 --- a/demo/app/lib/models/store_credential_data.dart +++ b/demo/app/lib/models/store_credential_data.dart @@ -16,7 +16,7 @@ class UserLoginDetails { Future getUser() async { SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences p = prefs; - String? userLoggedIn = p.getString("userLoggedIn"); + String? userLoggedIn = p.getString("userLoggedIn"); print("userLoginDetails -> $userLoggedIn"); return UserLoginDetails(userLoggedIn); } diff --git a/demo/app/lib/scenarios/handle_openid_vp_flow.dart b/demo/app/lib/scenarios/handle_openid_vp_flow.dart index df10b1cf..b0015778 100644 --- a/demo/app/lib/scenarios/handle_openid_vp_flow.dart +++ b/demo/app/lib/scenarios/handle_openid_vp_flow.dart @@ -26,16 +26,15 @@ void handleOpenIDVpFlow(BuildContext context, String qrCodeURL) async { // Check if the flow is for the verifiable presentation or for issuance. UserLoginDetails userLoginDetails = await getUser(); - var username = userLoginDetails.username!; + var username = userLoginDetails.username; storedCredentials = await storageService.retrieveCredentials(username!); - log("stored credentials -> $storedCredentials"); - - credentials = storedCredentials.map((e) => e.value.rawCredential).toList(); + credentials = storedCredentials.map((e) => e.value.rawCredential).toList(); try { - await walletSDKPlugin.processAuthorizationRequest( - authorizationRequest: qrCodeURL, storedCredentials: credentials); + await walletSDKPlugin.processAuthorizationRequest( + authorizationRequest: qrCodeURL); } on PlatformException catch (error) { + if (!context.mounted) return; Navigator.push( context, MaterialPageRoute( diff --git a/demo/app/lib/views/credential_preview.dart b/demo/app/lib/views/credential_preview.dart index cdf05406..a0969b84 100644 --- a/demo/app/lib/views/credential_preview.dart +++ b/demo/app/lib/views/credential_preview.dart @@ -33,7 +33,7 @@ class CredentialPreviewState extends State { @override void initState() { super.initState(); - WalletSDKPlugin.parseCredentialDisplayData(widget.credentialData.credentialDisplayData!).then( + WalletSDKPlugin.parseCredentialDisplayData(widget.credentialData.credentialDisplayData).then( (response) { setState(() { issuerDisplayData = response.first.issuerName; @@ -54,7 +54,7 @@ class CredentialPreviewState extends State { } )) ); - WidgetsBinding.instance?.addPostFrameCallback((timeStamp) async { + WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { UserLoginDetails userLoginDetails = await getUser(); userLoggedIn = userLoginDetails.username!; }); @@ -109,7 +109,7 @@ class CredentialPreviewState extends State { ], ), ), - subtitle: Text(serviceURL!, textAlign: TextAlign.center, style: const TextStyle(fontSize: 12,fontWeight: FontWeight.normal)), + subtitle: Text(serviceURL, textAlign: TextAlign.center, style: const TextStyle(fontSize: 12,fontWeight: FontWeight.normal)), ), const SizedBox(height: 20), @@ -142,7 +142,7 @@ class CredentialPreviewState extends State { ), PrimaryButton( onPressed: () async { - _storageService.addCredential(CredentialDataObject("$userLoggedIn-${uuid.v1()}", widget.credentialData!)); + _storageService.addCredential(CredentialDataObject("$userLoggedIn-${uuid.v1()}", widget.credentialData)); _navigateToCredentialAdded(); }, width: double.infinity, diff --git a/demo/app/lib/views/presentation_preview.dart b/demo/app/lib/views/presentation_preview.dart index acac0b53..053d927e 100644 --- a/demo/app/lib/views/presentation_preview.dart +++ b/demo/app/lib/views/presentation_preview.dart @@ -40,7 +40,7 @@ class PresentationPreviewState extends State { @override void initState() { super.initState(); - WidgetsBinding.instance?.addPostFrameCallback((timeStamp) async { + WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { final verifiedDisplayData = await WalletSDKPlugin.getVerifierDisplayData(); log("verifiedDisplayData ${verifiedDisplayData.logoURI}"); var resp = await WalletSDKPlugin.wellKnownDidConfig(verifiedDisplayData.did); diff --git a/demo/app/lib/wallet_sdk/wallet_sdk_js.dart b/demo/app/lib/wallet_sdk/wallet_sdk_js.dart index 5014283e..7dd1afce 100644 --- a/demo/app/lib/wallet_sdk/wallet_sdk_js.dart +++ b/demo/app/lib/wallet_sdk/wallet_sdk_js.dart @@ -47,6 +47,28 @@ extension JSResolvedDisplayDataExt on JSResolvedDisplayData { external List get credentialDisplays; } +@JS() +@staticInterop + +class JSVerifierDisplayData {} + +extension JSVerifierDisplayDataExt on JSVerifierDisplayData { + external String get name; + external String get did; + external String get logoURI; + external String get purpose; +} + +@JS() +@staticInterop + +class JSWellKnownDIDConfig {} + +extension JSWellKnownDIDConfigExt on JSWellKnownDIDConfig { + external bool get isValid; + external String get serviceURL; +} + @JS() @staticInterop class JSCredentialDisplayData {} @@ -100,6 +122,18 @@ extension JSSubmissionRequirementExt on JSSubmissionRequirement { external List nested; } +@JS() +@staticInterop +class JSInputDescriptor {} + +extension JSInputDescriptorExt on JSInputDescriptor { + external String get id; + external String get name; + external String get purpose; + external List get matchedVCsID; + external List get matchedVCs; +} + @JS() @staticInterop class JSSupportedCredentials {} @@ -304,11 +338,9 @@ class WalletSDK extends WalletPlatform { .toList(); } - Future> processAuthorizationRequest( - {required String authorizationRequest, List? storedCredentials}) async { + Future processAuthorizationRequest({required String authorizationRequest}) async { await promiseToFuture(jsCreateOpenID4VPInteraction(authorizationRequest)); - - return []; + return; } Future> getSubmissionRequirements({required List storedCredentials}) async { @@ -317,18 +349,19 @@ class WalletSDK extends WalletPlatform { return Future.wait(reqs.map((s) => mapSubmissionRequirement(s))); } - Future mapInputDescriptor(dynamic d) async { - final List jsMatchedVCs = d.matchedVCs; + Future mapInputDescriptor(JSInputDescriptor d) async { + final List jsMatchedVCs = d.matchedVCs.map((e) => e).toList(); final matchedVCs = jsMatchedVCs.map((vc) => vc).toList(); final matchedVCsIds = await Future.wait(jsMatchedVCs.map((vc) => promiseToFuture(jsGetCredentialID(vc)))); return InputDescriptor( - name: d.name, purpose: d.purpose, id: d.id, matchedVCs: matchedVCs, matchedVCsID: matchedVCsIds); + name: d.name, purpose: d.purpose, id: d.id, matchedVCs: matchedVCs, matchedVCsID: matchedVCsIds + ); } Future mapSubmissionRequirement(JSSubmissionRequirement jsReq) async { - final descriptors = await Future.wait(jsReq.descriptors.map(mapInputDescriptor)); + final descriptors = await Future.wait(jsReq.descriptors.map((e) => mapInputDescriptor(e))); final nested = await Future.wait(jsReq.nested.map((n) => mapSubmissionRequirement(n))); return SubmissionRequirement( @@ -349,7 +382,7 @@ class WalletSDK extends WalletPlatform { } Future wellKnownDidConfig(String issuerID) async { - final jsConfig = await promiseToFuture(jsWellKnownDidConfig(issuerID)); + final JSWellKnownDIDConfig jsConfig = await promiseToFuture(jsWellKnownDidConfig(issuerID)); return WellKnownDidConfig(isValid: jsConfig.isValid, serviceURL: jsConfig.serviceURL); } @@ -398,7 +431,7 @@ class WalletSDK extends WalletPlatform { } Future getVerifierDisplayData() async { - final data = await promiseToFuture(jsVerifierDisplayData()); + final JSVerifierDisplayData data = await promiseToFuture(jsVerifierDisplayData()); return VerifierDisplayData(name: data.name, did: data.did, logoURI: data.logoURI, purpose: data.purpose); }