From fdfea95e16e8823e6bed96d9fed7fac9a28573a7 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Wed, 22 May 2024 17:16:09 +0545 Subject: [PATCH 1/4] Bypas clientmetadata check when clientype is jwkthumprint and when vcformat is null then ignore nested_data --- .../cubit/qr_code_scan_cubit.dart | 35 ++++++---- lib/scan/cubit/scan_cubit.dart | 69 ++++++++++--------- 2 files changed, 58 insertions(+), 46 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 ee2a864c7..ee81113eb 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 @@ -627,21 +627,26 @@ class QRCodeScanCubit extends Cubit { } } } - - final clientMetadata = state.uri!.queryParameters['client_metadata']; - if (clientMetadata != null) { - final clientMetadataMap = - jsonDecode(clientMetadata) as Map; - final data = - clientMetadataMap['subject_syntax_types_supported'] as List; - if (!data.contains('did:key')) { - if (isSecurityHigh) { - throw ResponseMessage( - data: { - 'error': 'unsupported_response_type', - 'error_description': 'The subject syntax type is not supported.', - }, - ); + final clientType = profileCubit.state.model.profileSetting + .selfSovereignIdentityOptions.customOidc4vcProfile.clientType; + + if (clientType != ClientType.p256JWKThumprint) { + final clientMetadata = state.uri!.queryParameters['client_metadata']; + if (clientMetadata != null) { + final clientMetadataMap = + jsonDecode(clientMetadata) as Map; + final data = clientMetadataMap['subject_syntax_types_supported'] + as List; + if (!data.contains('did:key')) { + if (isSecurityHigh) { + throw ResponseMessage( + data: { + 'error': 'unsupported_response_type', + 'error_description': + 'The subject syntax type is not supported.', + }, + ); + } } } } diff --git a/lib/scan/cubit/scan_cubit.dart b/lib/scan/cubit/scan_cubit.dart index 4a93e0f7e..ed099301a 100644 --- a/lib/scan/cubit/scan_cubit.dart +++ b/lib/scan/cubit/scan_cubit.dart @@ -798,44 +798,51 @@ class ScanCubit extends Cubit { credentialList: [credentialsToBePresented[i]], ); - final pathNested = {'id': inputDescriptor.id, 'format': vcFormat}; + Map? pathNested; + + if (!(inputDescriptor.id == null || vcFormat == null)) { + pathNested = { + 'id': inputDescriptor.id, + 'format': vcFormat, + }; + } if (credential.isNotEmpty) { - if (credentialsToBePresented.length == 1) { - if (vpFormat == 'ldp_vp') { - pathNested['path'] = r'$.verifiableCredential'; - } else if (vpFormat == 'vc+sd-jwt') { - pathNested['path'] = r'$'; - } else { - pathNested['path'] = r'$.vp.verifiableCredential[0]'; - } + final Map descriptor = { + 'id': inputDescriptor.id, + 'format': vpFormat, + 'path': r'$', + }; - inputDescriptors.add({ - 'id': inputDescriptor.id, - 'format': vpFormat, - 'path': r'$', - 'path_nested': pathNested, - }); - } else { - if (vpFormat == 'ldp_vp') { - pathNested['path'] = - // ignore: prefer_interpolation_to_compose_strings - r'$.verifiableCredential[' + i.toString() + ']'; - } else if (vpFormat == 'vc+sd-jwt') { - pathNested['path'] = r'$'; + if (pathNested != null) { + if (credentialsToBePresented.length == 1) { + if (vpFormat == 'ldp_vp') { + pathNested['path'] = r'$.verifiableCredential'; + } else if (vpFormat == 'vc+sd-jwt') { + pathNested['path'] = r'$'; + } else { + pathNested['path'] = r'$.vp.verifiableCredential[0]'; + } } else { - pathNested['path'] = - // ignore: prefer_interpolation_to_compose_strings - r'$.vp.verifiableCredential[' + i.toString() + ']'; + if (vpFormat == 'ldp_vp') { + pathNested['path'] = + // ignore: prefer_interpolation_to_compose_strings + r'$.verifiableCredential[' + i.toString() + ']'; + } else if (vpFormat == 'vc+sd-jwt') { + pathNested['path'] = r'$'; + } else { + pathNested['path'] = + // ignore: prefer_interpolation_to_compose_strings + r'$.vp.verifiableCredential[' + i.toString() + ']'; + } } + } - inputDescriptors.add({ - 'id': inputDescriptor.id, - 'format': vpFormat, - 'path': r'$', - 'path_nested': pathNested, - }); + if (pathNested != null) { + descriptor['path_nested'] = pathNested; } + + inputDescriptors.add(descriptor); } } } From c81661006de8e4a88a929503a33dc2f558f56585 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Thu, 23 May 2024 13:35:15 +0545 Subject: [PATCH 2/4] Update for vc-sd-jwt - pathNested ignored --- .../cubit/missing_credentials_cubit.dart | 14 ++++++++++++-- lib/scan/cubit/scan_cubit.dart | 12 +++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/dashboard/missing_creentials/cubit/missing_credentials_cubit.dart b/lib/dashboard/missing_creentials/cubit/missing_credentials_cubit.dart index 9ebe4a082..e9f632611 100644 --- a/lib/dashboard/missing_creentials/cubit/missing_credentials_cubit.dart +++ b/lib/dashboard/missing_creentials/cubit/missing_credentials_cubit.dart @@ -58,8 +58,18 @@ class MissingCredentialsCubit extends Cubit { credentialField['filter'] as Map, ); - final credentialName = - filter.pattern ?? filter.contains!.containsConst; + final credentialName = filter.pattern ?? + filter.contains?.containsConst ?? + filter.containsConst; + + if (credentialName == null) { + throw ResponseMessage( + data: { + 'error': 'invalid_request', + 'error_description': 'Invalid presentatoin Definition.', + }, + ); + } final CredentialSubjectType? credentialSubjectType = getCredTypeFromName(credentialName); diff --git a/lib/scan/cubit/scan_cubit.dart b/lib/scan/cubit/scan_cubit.dart index ed099301a..6efdb7551 100644 --- a/lib/scan/cubit/scan_cubit.dart +++ b/lib/scan/cubit/scan_cubit.dart @@ -727,6 +727,9 @@ class ScanCubit extends Cubit { 'definition_id': presentationDefinition.id, }; + final vcFormatType = profileSetting + .selfSovereignIdentityOptions.customOidc4vcProfile.vcFormatType; + final inputDescriptors = >[]; String? vcFormat; @@ -761,8 +764,6 @@ class ScanCubit extends Cubit { } } else { if (clientMetaData == null) { - final vcFormatType = profileSetting - .selfSovereignIdentityOptions.customOidc4vcProfile.vcFormatType; vcFormat = vcFormatType.vcValue; vpFormat = vcFormatType.vpValue; } else { @@ -800,7 +801,7 @@ class ScanCubit extends Cubit { Map? pathNested; - if (!(inputDescriptor.id == null || vcFormat == null)) { + if (vcFormatType != VCFormatType.vcSdJWT) { pathNested = { 'id': inputDescriptor.id, 'format': vcFormat, @@ -814,7 +815,7 @@ class ScanCubit extends Cubit { 'path': r'$', }; - if (pathNested != null) { + if (vcFormatType != VCFormatType.vcSdJWT && pathNested != null) { if (credentialsToBePresented.length == 1) { if (vpFormat == 'ldp_vp') { pathNested['path'] = r'$.verifiableCredential'; @@ -836,9 +837,6 @@ class ScanCubit extends Cubit { r'$.vp.verifiableCredential[' + i.toString() + ']'; } } - } - - if (pathNested != null) { descriptor['path_nested'] = pathNested; } From bbe5dd40a14c3a231b9b6030508ddba072c931f9 Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Thu, 23 May 2024 16:46:27 +0545 Subject: [PATCH 3/4] Add typ in header for key binding type --- packages/oidc4vc/lib/src/oidc4vc.dart | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/oidc4vc/lib/src/oidc4vc.dart b/packages/oidc4vc/lib/src/oidc4vc.dart index 3163f4ba4..9c59bd5d5 100644 --- a/packages/oidc4vc/lib/src/oidc4vc.dart +++ b/packages/oidc4vc/lib/src/oidc4vc.dart @@ -1480,12 +1480,11 @@ class OIDC4VC { ..setProtectedHeader('alg', tokenParameters.alg) // add a key to sign, can only add one for JWT - ..addRecipient(key, algorithm: tokenParameters.alg); + ..addRecipient(key, algorithm: tokenParameters.alg) + ..setProtectedHeader('typ', tokenParameters.mediaType.typ); if (!ignoreProofHeaderType) { - /// Proof Header Type is ignored for clientSecretJwt - // also ignored for KB jwt - vpBuilder.setProtectedHeader('typ', tokenParameters.mediaType.typ); + /// Proof Header Type is ignored for KB jwt switch (tokenParameters.proofHeaderType) { case ProofHeaderType.kid: From c48ea53e7e9b1cb7b94369b046cb89564900556e Mon Sep 17 00:00:00 2001 From: Bibash Shrestha Date: Fri, 24 May 2024 14:11:07 +0545 Subject: [PATCH 4/4] version update to 2.5.7+457 --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 1b9b6fdd5..9d4d2821d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: altme description: AltMe Flutter App -version: 2.5.6+456 +version: 2.5.7+457 environment: sdk: ">=3.1.0 <4.0.0"