From 4914a27bd5d5cbc21f1e1245405234ca88f461ba Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Thu, 18 Apr 2024 17:19:57 +0545 Subject: [PATCH] some optional params fix --- .../qr_code_scan/cubit/qr_code_scan_cubit.dart | 11 ++++++++--- lib/oidc4vc/get_credential.dart | 2 +- packages/oidc4vc/lib/src/oidc4vc.dart | 4 ++-- 3 files changed, 11 insertions(+), 6 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 3db598acc..778af33fa 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 @@ -1360,8 +1360,13 @@ class QRCodeScanCubit extends Cubit { } } - if (savedAccessToken == null || savedNonce == null) { - throw Exception(); + if (savedAccessToken == null) { + throw ResponseMessage( + data: { + 'error': 'invalid_request', + 'error_description': 'Access token is not provided.', + }, + ); } /// get credentials @@ -1379,7 +1384,7 @@ class QRCodeScanCubit extends Cubit { clientId: clientId, profileCubit: profileCubit, accessToken: savedAccessToken!, - nonce: savedNonce!, + nonce: savedNonce, authorizationDetails: savedAuthorizationDetails, openIdConfiguration: openIdConfiguration, ); diff --git a/lib/oidc4vc/get_credential.dart b/lib/oidc4vc/get_credential.dart index 6481415da..d0b8bdd33 100644 --- a/lib/oidc4vc/get_credential.dart +++ b/lib/oidc4vc/get_credential.dart @@ -20,7 +20,7 @@ Future< required DidKeyType didKeyType, required String? clientId, required String accessToken, - required String nonce, + required String? nonce, required OpenIdConfiguration openIdConfiguration, required List? authorizationDetails, }) async { diff --git a/packages/oidc4vc/lib/src/oidc4vc.dart b/packages/oidc4vc/lib/src/oidc4vc.dart index 38441d29a..2d58d7ac3 100644 --- a/packages/oidc4vc/lib/src/oidc4vc.dart +++ b/packages/oidc4vc/lib/src/oidc4vc.dart @@ -426,7 +426,7 @@ class OIDC4VC { required ProofType proofType, required OpenIdConfiguration openIdConfiguration, required String accessToken, - required String cnonce, + required String? cnonce, List? authorizationDetails, }) async { var nonce = cnonce; @@ -617,7 +617,7 @@ class OIDC4VC { required String kid, required String privateKey, required String accessToken, - required String nonce, + required String? nonce, }) async { final credentialData = await buildCredentialData( nonce: nonce,