From bfaad87b02baba2dc76c9ab0c2d7c1e10ea58b2b Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Wed, 6 Nov 2024 18:50:37 +0545 Subject: [PATCH] feat: Show par data to be sent #3054 --- .../cubit/qr_code_scan_cubit.dart | 8 +++++- .../get_authorization_uri_for_issuer.dart | 27 ++++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) 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 74304021e..86783e26b 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 @@ -1316,7 +1316,7 @@ class QRCodeScanCubit extends Cubit { emit(state.loading()); final scope = customOidc4vcProfile.scope; - await getAuthorizationUriForIssuer( + final authorizationUri = await getAuthorizationUriForIssuer( scannedResponse: state.uri.toString(), oidc4vc: oidc4vc, isEBSI: isEBSI, @@ -1338,7 +1338,13 @@ class QRCodeScanCubit extends Cubit { walletIssuer: Parameters.walletIssuer, useOAuthAuthorizationServerLink: useOauthServerAuthEndPoint(profileCubit.state.model), + profileCubit: profileCubit, + qrCodeScanCubit: qrCodeScanCubit, ); + + if (authorizationUri == null) return; + + await LaunchUrl.launchUri(authorizationUri); goBack(); } } catch (e) { diff --git a/lib/oidc4vc/get_authorization_uri_for_issuer.dart b/lib/oidc4vc/get_authorization_uri_for_issuer.dart index 40a493a87..2f829e9bb 100644 --- a/lib/oidc4vc/get_authorization_uri_for_issuer.dart +++ b/lib/oidc4vc/get_authorization_uri_for_issuer.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:altme/app/app.dart'; import 'package:altme/app/shared/shared.dart'; +import 'package:altme/dashboard/dashboard.dart'; import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart'; import 'package:did_kit/did_kit.dart'; @@ -9,7 +10,7 @@ import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:oidc4vc/oidc4vc.dart'; import 'package:uuid/uuid.dart'; -Future getAuthorizationUriForIssuer({ +Future getAuthorizationUriForIssuer({ required String scannedResponse, required OIDC4VC oidc4vc, required bool isEBSI, @@ -23,13 +24,15 @@ Future getAuthorizationUriForIssuer({ required ClientAuthentication clientAuthentication, required OIDC4VCIDraftType oidc4vciDraftType, required VCFormatType vcFormatType, - String? oAuthClientAttestation, - String? oAuthClientAttestationPop, required bool secureAuthorizedFlow, required DioClient client, required ProfileType profileType, required String walletIssuer, required bool useOAuthAuthorizationServerLink, + required ProfileCubit profileCubit, + required QRCodeScanCubit qrCodeScanCubit, + String? oAuthClientAttestation, + String? oAuthClientAttestationPop, }) async { /// this is first phase flow for authorization_code @@ -129,6 +132,22 @@ Future getAuthorizationUriForIssuer({ final parUrl = openIdConfiguration.pushedAuthorizationRequestEndpoint ?? '$authorizationEndpoint/par'; + if (profileCubit.state.model.isDeveloperMode) { + final value = await qrCodeScanCubit.showDataBeforeSending( + title: 'Pushed Authorization Request Data', + data: authorizationRequestParemeters, + ); + + if (value) { + qrCodeScanCubit.completer = null; + } else { + qrCodeScanCubit.completer = null; + qrCodeScanCubit.resetNonceAndAccessTokenAndAuthorizationDetails(); + qrCodeScanCubit.goBack(); + return null; + } + } + /// error we shuld get it from final response = await client.post( parUrl, @@ -157,5 +176,5 @@ Future getAuthorizationUriForIssuer({ Uri.https(url.authority, url.path, authorizationRequestParemeters); } - await LaunchUrl.launchUri(authorizationUri); + return authorizationUri; }