Skip to content

Commit

Permalink
Merge pull request #2676 from TalaoDAO/interop_edui_issue
Browse files Browse the repository at this point in the history
Interop edui issue fix
  • Loading branch information
hawkbee1 authored May 27, 2024
2 parents 53a1fd4 + c48ea53 commit 35f0832
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,18 @@ class MissingCredentialsCubit extends Cubit<MissingCredentialsState> {
credentialField['filter'] as Map<String, dynamic>,
);

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);
Expand Down
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
73 changes: 39 additions & 34 deletions lib/scan/cubit/scan_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,9 @@ class ScanCubit extends Cubit<ScanState> {
'definition_id': presentationDefinition.id,
};

final vcFormatType = profileSetting
.selfSovereignIdentityOptions.customOidc4vcProfile.vcFormatType;

final inputDescriptors = <Map<String, dynamic>>[];

String? vcFormat;
Expand Down Expand Up @@ -761,8 +764,6 @@ class ScanCubit extends Cubit<ScanState> {
}
} else {
if (clientMetaData == null) {
final vcFormatType = profileSetting
.selfSovereignIdentityOptions.customOidc4vcProfile.vcFormatType;
vcFormat = vcFormatType.vcValue;
vpFormat = vcFormatType.vpValue;
} else {
Expand Down Expand Up @@ -798,44 +799,48 @@ class ScanCubit extends Cubit<ScanState> {
credentialList: [credentialsToBePresented[i]],
);

final pathNested = {'id': inputDescriptor.id, 'format': vcFormat};
Map<String, dynamic>? 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<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 (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);
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions packages/oidc4vc/lib/src/oidc4vc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 35f0832

Please sign in to comment.