Skip to content

Commit

Permalink
feat: Update credential request for draft 13 - jwt_vc_json and ldp_vc #…
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Jul 18, 2024
1 parent b520c1e commit a8bf76f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/oidc4vc/get_credential.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Future<
authorizationDetails: authorizationDetails,
openIdConfiguration: openIdConfiguration,
dio: Dio(),
vcFormatType: customOidc4vcProfile.vcFormatType,
);

return (
Expand Down
13 changes: 13 additions & 0 deletions packages/oidc4vc/lib/src/oidc4vc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import 'package:jose_plus/jose.dart';
import 'package:json_path/json_path.dart';
import 'package:oidc4vc/oidc4vc.dart';
import 'package:oidc4vc/src/helper_function.dart';
import 'package:oidc4vc/src/vc_format_type.dart';
import 'package:secp256k1/secp256k1.dart';
import 'package:secure_storage/secure_storage.dart';
import 'package:uuid/uuid.dart';
Expand Down Expand Up @@ -438,6 +439,7 @@ class OIDC4VC {
required String accessToken,
required String? cnonce,
required Dio dio,
required VCFormatType vcFormatType,
List<dynamic>? authorizationDetails,
}) async {
var nonce = cnonce;
Expand Down Expand Up @@ -511,6 +513,7 @@ class OIDC4VC {
accessToken: accessToken,
nonce: nonce,
dio: dio,
vcFormatType: vcFormatType,
);

/// update nonce value
Expand Down Expand Up @@ -544,6 +547,7 @@ class OIDC4VC {
accessToken: accessToken,
nonce: cnonce,
dio: dio,
vcFormatType: vcFormatType,
);

credentialResponseData.add(credentialResponseDataValue);
Expand Down Expand Up @@ -641,6 +645,7 @@ class OIDC4VC {
required String accessToken,
required String? nonce,
required Dio dio,
required VCFormatType vcFormatType,
}) async {
try {
final credentialData = await buildCredentialData(
Expand All @@ -661,6 +666,7 @@ class OIDC4VC {
issuer: issuer,
kid: kid,
privateKey: privateKey,
vcFormatType: vcFormatType,
);

/// sign proof
Expand Down Expand Up @@ -715,6 +721,7 @@ class OIDC4VC {
accessToken: accessToken,
nonce: nonce,
dio: dio,
vcFormatType: vcFormatType,
);
count = 0;
return credentialResponseDataValue;
Expand Down Expand Up @@ -1055,6 +1062,7 @@ class OIDC4VC {
required String issuer,
required String kid,
required String privateKey,
required VCFormatType vcFormatType,
}) async {
final credentialData = <String, dynamic>{};

Expand Down Expand Up @@ -1133,6 +1141,11 @@ class OIDC4VC {
credentialData['format'] = format;

if (credentialDefinition != null) {
if (vcFormatType == VCFormatType.jwtVcJson ||
vcFormatType == VCFormatType.ldpVc) {
credentialDefinition.removeWhere((key, _) => key != 'type');
}

credentialData['credential_definition'] = credentialDefinition;
}

Expand Down
2 changes: 2 additions & 0 deletions packages/oidc4vc/test/src/oidc4vc_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ void main() {
accessToken: accessToken,
cnonce: nonce,
dio: client,
vcFormatType: VCFormatType.jwtVcJson,
);

expect(credentialResponseData, [expecedCredentialResponse]);
Expand Down Expand Up @@ -602,6 +603,7 @@ void main() {
accessToken: '',
cnonce: null,
dio: client,
vcFormatType: VCFormatType.jwtVcJson,
);
},
throwsA(isA<FormatException>()),
Expand Down

0 comments on commit a8bf76f

Please sign in to comment.