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/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..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 { @@ -798,44 +799,48 @@ class ScanCubit extends Cubit { credentialList: [credentialsToBePresented[i]], ); - final pathNested = {'id': inputDescriptor.id, 'format': vcFormat}; + Map? pathNested; + + if (vcFormatType != VCFormatType.vcSdJWT) { + 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 (vcFormatType != VCFormatType.vcSdJWT && 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, - }); + descriptor['path_nested'] = pathNested; } + + inputDescriptors.add(descriptor); } } } 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: 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"