Skip to content

Commit

Permalink
Bypas clientmetadata check when clientype is jwkthumprint and when vc…
Browse files Browse the repository at this point in the history
…format is null then ignore nested_data
  • Loading branch information
bibash28 committed May 22, 2024
1 parent a327469 commit 74baf8c
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 46 deletions.
35 changes: 20 additions & 15 deletions lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -627,21 +627,26 @@ class QRCodeScanCubit extends Cubit<QRCodeScanState> {
}
}
}

final clientMetadata = state.uri!.queryParameters['client_metadata'];
if (clientMetadata != null) {
final clientMetadataMap =
jsonDecode(clientMetadata) as Map<String, dynamic>;
final data =
clientMetadataMap['subject_syntax_types_supported'] as List<dynamic>;
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<String, dynamic>;
final data = clientMetadataMap['subject_syntax_types_supported']
as List<dynamic>;
if (!data.contains('did:key')) {
if (isSecurityHigh) {
throw ResponseMessage(
data: {
'error': 'unsupported_response_type',
'error_description':
'The subject syntax type is not supported.',
},
);
}
}
}
}
Expand Down
69 changes: 38 additions & 31 deletions lib/scan/cubit/scan_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -798,44 +798,51 @@ class ScanCubit extends Cubit<ScanState> {
credentialList: [credentialsToBePresented[i]],
);

final pathNested = {'id': inputDescriptor.id, 'format': vcFormat};
Map<String, dynamic>? 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<String, dynamic> 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);
}
}
}
Expand Down

0 comments on commit 74baf8c

Please sign in to comment.