diff --git a/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart b/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart index 86783e26b..4b47a450a 100644 --- a/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart +++ b/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart @@ -1223,7 +1223,8 @@ class QRCodeScanCubit extends Cubit { final customOidc4vcProfile = profileCubit.state.model.profileSetting .selfSovereignIdentityOptions.customOidc4vcProfile; - final Response response = await oidc4vc.siopv2Flow( + final Map responseData = + await oidc4vc.getDataForSiopV2Flow( clientId: clientId, privateKey: privateKey, did: did, @@ -1232,8 +1233,28 @@ class QRCodeScanCubit extends Cubit { nonce: nonce, stateValue: stateValue, clientType: customOidc4vcProfile.clientType, - proofHeaderType: customOidc4vcProfile.proofHeader, + proofHeader: customOidc4vcProfile.proofHeader, + ); + + if (profileCubit.state.model.isDeveloperMode) { + final value = await showDataBeforeSending( + title: 'Response Data', + data: responseData, + ); + if (value) { + completer = null; + } else { + completer = null; + resetNonceAndAccessTokenAndAuthorizationDetails(); + goBack(); + return; + } + } + + final Response response = await oidc4vc.siopv2Flow( + redirectUri: redirectUri ?? responseUri!, dio: client.dio, + responseData: responseData, ); String? url; diff --git a/lib/scan/cubit/scan_cubit.dart b/lib/scan/cubit/scan_cubit.dart index d687820fc..385203526 100644 --- a/lib/scan/cubit/scan_cubit.dart +++ b/lib/scan/cubit/scan_cubit.dart @@ -618,6 +618,21 @@ class ScanCubit extends Cubit { body = responseData; } + if (profileCubit.state.model.isDeveloperMode) { + final value = await qrCodeScanCubit.showDataBeforeSending( + title: 'Response Data', + data: body, + ); + if (value) { + qrCodeScanCubit.completer = null; + } else { + qrCodeScanCubit.completer = null; + qrCodeScanCubit.resetNonceAndAccessTokenAndAuthorizationDetails(); + qrCodeScanCubit.goBack(); + return; + } + } + await Future.delayed(const Duration(seconds: 2)); final response = await client.dio.post( responseOrRedirectUri, diff --git a/packages/oidc4vc/lib/src/oidc4vc.dart b/packages/oidc4vc/lib/src/oidc4vc.dart index 24a17219c..72a7b1492 100644 --- a/packages/oidc4vc/lib/src/oidc4vc.dart +++ b/packages/oidc4vc/lib/src/oidc4vc.dart @@ -1398,7 +1398,7 @@ class OIDC4VC { } } - Future> siopv2Flow({ + Future> getDataForSiopV2Flow({ required String clientId, required String did, required String kid, @@ -1407,40 +1407,47 @@ class OIDC4VC { required String privateKey, required String? stateValue, required ClientType clientType, - required ProofHeaderType proofHeaderType, - required Dio dio, + required ProofHeaderType proofHeader, }) async { - try { - final private = jsonDecode(privateKey) as Map; + final private = jsonDecode(privateKey) as Map; + + final tokenParameters = VerifierTokenParameters( + privateKey: private, + did: did, + kid: kid, + audience: clientId, + credentials: [], + nonce: nonce, + mediaType: MediaType.basic, + clientType: clientType, + proofHeaderType: proofHeader, + clientId: clientId, + ); - final tokenParameters = VerifierTokenParameters( - privateKey: private, - did: did, - kid: kid, - audience: clientId, - credentials: [], - nonce: nonce, - mediaType: MediaType.basic, - clientType: clientType, - proofHeaderType: proofHeaderType, - clientId: clientId, - ); + // structures + final verifierIdToken = await getIdToken(tokenParameters); - // structures - final verifierIdToken = await getIdToken(tokenParameters); + final responseData = { + 'id_token': verifierIdToken, + }; - final responseHeaders = { - 'Content-Type': 'application/x-www-form-urlencoded', - }; + if (stateValue != null) { + responseData['state'] = stateValue; + } - final responseData = { - 'id_token': verifierIdToken, - }; + return responseData; + } - if (stateValue != null) { - responseData['state'] = stateValue; - } + Future> siopv2Flow({ + required String redirectUri, + required Dio dio, + required Map responseData, + }) async { + final responseHeaders = { + 'Content-Type': 'application/x-www-form-urlencoded', + }; + try { final response = await dio.post( redirectUri, options: Options(