From 87630273c40d25b537c93faa1c14ec6011096126 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Thu, 19 Oct 2023 12:34:48 +0545 Subject: [PATCH] refactor: OIDC4VP error management for presentation definition #2029 --- .../cubit/qr_code_scan_cubit.dart | 31 +++++++++++++++++++ pubspec.lock | 4 +-- 2 files changed, 33 insertions(+), 2 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 dff359281..70d4b98bb 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 @@ -875,6 +875,37 @@ class QRCodeScanCubit extends Cubit { ); } + if (presentationDefinition.inputDescriptors.isEmpty) { + throw ResponseMessage( + data: { + 'error': 'invalid_request', + 'error_description': + 'The input_descriptors is required in the presentation_definition' + ' object', + }, + ); + } + + if (presentationDefinition.format == null) { + throw ResponseMessage( + data: { + 'error': 'invalid_request', + 'error_description': 'Presentation definition is invalid', + }, + ); + } + + for (final descriptor in presentationDefinition.inputDescriptors) { + if (descriptor.constraints == null) { + throw ResponseMessage( + data: { + 'error': 'invalid_request', + 'error_description': 'Presentation definition is invalid', + }, + ); + } + } + final CredentialManifest credentialManifest = CredentialManifest( 'id', IssuedBy('', ''), diff --git a/pubspec.lock b/pubspec.lock index a0811e07f..eb17e2bd9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -779,10 +779,10 @@ packages: dependency: "direct main" description: name: file_saver - sha256: "591d25e750e3a4b654f7b0293abc2ed857242f82ca7334051b2a8ceeb369dac8" + sha256: "8ffd91ae9f543c5ebbfec71a814ee5aa9e21176d31335133308abf63f4c42e8a" url: "https://pub.dev" source: hosted - version: "0.2.8" + version: "0.2.9" file_selector_linux: dependency: transitive description: