@pagopa/io-react-native-wallet 2.0.0-next.2 → 2.0.0-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js +38 -24
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +75 -57
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/05-authorize-access.js +6 -10
- package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +43 -11
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +51 -48
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/README.md +77 -45
- package/lib/commonjs/credential/issuance/const.js +1 -1
- package/lib/commonjs/credential/issuance/types.js +17 -10
- package/lib/commonjs/credential/issuance/types.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +6 -13
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +10 -11
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/commonjs/credential/presentation/types.js +1 -1
- package/lib/commonjs/credential/presentation/types.js.map +1 -1
- package/lib/commonjs/credential/status/README.md +0 -1
- package/lib/commonjs/sd-jwt/__test__/index.test.js +11 -15
- package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/types.test.js +5 -2
- package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/utils.test.js +37 -0
- package/lib/commonjs/sd-jwt/__test__/utils.test.js.map +1 -0
- package/lib/commonjs/sd-jwt/index.js +26 -1
- package/lib/commonjs/sd-jwt/index.js.map +1 -1
- package/lib/commonjs/sd-jwt/types.js +71 -8
- package/lib/commonjs/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/sd-jwt/utils.js +64 -0
- package/lib/commonjs/sd-jwt/utils.js.map +1 -0
- package/lib/commonjs/trust/types.js +18 -13
- package/lib/commonjs/trust/types.js.map +1 -1
- package/lib/commonjs/utils/par.js +32 -22
- package/lib/commonjs/utils/par.js.map +1 -1
- package/lib/commonjs/utils/pop.js +1 -1
- package/lib/commonjs/utils/pop.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/types.js +4 -1
- package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
- package/lib/module/credential/issuance/03-start-user-authorization.js +38 -24
- package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js +76 -58
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/05-authorize-access.js +6 -10
- package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +44 -12
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +51 -48
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/credential/issuance/README.md +77 -45
- package/lib/module/credential/issuance/const.js +1 -1
- package/lib/module/credential/issuance/types.js +13 -8
- package/lib/module/credential/issuance/types.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js +6 -13
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +10 -11
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/module/credential/presentation/types.js +1 -1
- package/lib/module/credential/presentation/types.js.map +1 -1
- package/lib/module/credential/status/README.md +0 -1
- package/lib/module/sd-jwt/__test__/index.test.js +11 -16
- package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/module/sd-jwt/__test__/types.test.js +5 -2
- package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/module/sd-jwt/__test__/utils.test.js +35 -0
- package/lib/module/sd-jwt/__test__/utils.test.js.map +1 -0
- package/lib/module/sd-jwt/index.js +7 -1
- package/lib/module/sd-jwt/index.js.map +1 -1
- package/lib/module/sd-jwt/types.js +70 -7
- package/lib/module/sd-jwt/types.js.map +1 -1
- package/lib/module/sd-jwt/utils.js +57 -0
- package/lib/module/sd-jwt/utils.js.map +1 -0
- package/lib/module/trust/types.js +18 -13
- package/lib/module/trust/types.js.map +1 -1
- package/lib/module/utils/par.js +29 -20
- package/lib/module/utils/par.js.map +1 -1
- package/lib/module/utils/pop.js +1 -1
- package/lib/module/utils/pop.js.map +1 -1
- package/lib/module/wallet-instance-attestation/types.js +4 -1
- package/lib/module/wallet-instance-attestation/types.js.map +1 -1
- package/lib/typescript/client/generated/wallet-provider.d.ts +12 -12
- package/lib/typescript/credential/issuance/01-start-flow.d.ts +2 -2
- package/lib/typescript/credential/issuance/01-start-flow.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +7 -6
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts +7 -14
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +10 -5
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts +3 -2
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/const.d.ts +1 -1
- package/lib/typescript/credential/issuance/types.d.ts +49 -26
- package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/01-start-flow.d.ts +2 -2
- package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts +4 -3
- package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +9 -5
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/types.d.ts +3 -4
- package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
- package/lib/typescript/credential/status/types.d.ts +4 -4
- package/lib/typescript/pid/sd-jwt/types.d.ts +7 -7
- package/lib/typescript/sd-jwt/__test__/utils.test.d.ts +2 -0
- package/lib/typescript/sd-jwt/__test__/utils.test.d.ts.map +1 -0
- package/lib/typescript/sd-jwt/index.d.ts +69 -28
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/types.d.ts +264 -31
- package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/utils.d.ts +18 -0
- package/lib/typescript/sd-jwt/utils.d.ts.map +1 -0
- package/lib/typescript/trust/build-chain.d.ts +30 -14
- package/lib/typescript/trust/build-chain.d.ts.map +1 -1
- package/lib/typescript/trust/types.d.ts +322 -158
- package/lib/typescript/trust/types.d.ts.map +1 -1
- package/lib/typescript/utils/par.d.ts +29 -13
- package/lib/typescript/utils/par.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/types.d.ts +9 -9
- package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/credential/issuance/01-start-flow.ts +2 -2
- package/src/credential/issuance/03-start-user-authorization.ts +57 -38
- package/src/credential/issuance/04-complete-user-authorization.ts +79 -85
- package/src/credential/issuance/05-authorize-access.ts +5 -11
- package/src/credential/issuance/06-obtain-credential.ts +56 -23
- package/src/credential/issuance/07-verify-and-parse-credential.ts +54 -62
- package/src/credential/issuance/README.md +77 -45
- package/src/credential/issuance/const.ts +1 -1
- package/src/credential/issuance/types.ts +19 -8
- package/src/credential/presentation/07-evaluate-dcql-query.ts +16 -17
- package/src/credential/presentation/07-evaluate-input-descriptor.ts +19 -16
- package/src/credential/presentation/types.ts +1 -2
- package/src/credential/status/README.md +0 -1
- package/src/sd-jwt/__test__/index.test.ts +8 -29
- package/src/sd-jwt/__test__/types.test.ts +6 -2
- package/src/sd-jwt/__test__/utils.test.ts +37 -0
- package/src/sd-jwt/index.ts +7 -1
- package/src/sd-jwt/types.ts +68 -7
- package/src/sd-jwt/utils.ts +73 -0
- package/src/trust/types.ts +23 -17
- package/src/utils/par.ts +37 -21
- package/src/utils/pop.ts +1 -1
- package/src/wallet-instance-attestation/types.ts +3 -1
@@ -13,45 +13,39 @@ var _logging = require("../../utils/logging");
|
|
13
13
|
|
14
14
|
// handy alias
|
15
15
|
|
16
|
-
const parseCredentialSdJwt = function (
|
16
|
+
const parseCredentialSdJwt = function (credentialConfig, _ref) {
|
17
17
|
let {
|
18
18
|
sdJwt,
|
19
19
|
disclosures
|
20
20
|
} = _ref;
|
21
21
|
let ignoreMissingAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
22
22
|
let includeUndefinedAttributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
23
|
-
|
24
|
-
|
25
|
-
_logging.Logger.log(_logging.LogLevel.ERROR,
|
26
|
-
throw new _errors.IoWalletError(
|
27
|
-
}
|
28
|
-
if (credentialSubject.format !== sdJwt.header.typ) {
|
29
|
-
_logging.Logger.log(_logging.LogLevel.ERROR, `Received credential is of an unknwown type. Expected one of [${credentialSubject.format}], received '${sdJwt.header.typ}'`);
|
30
|
-
throw new _errors.IoWalletError(`Received credential is of an unknwown type. Expected one of [${credentialSubject.format}], received '${sdJwt.header.typ}', `);
|
23
|
+
if (credentialConfig.format !== sdJwt.header.typ) {
|
24
|
+
const message = `Received credential is of an unknwown type. Expected one of [${credentialConfig.format}], received '${sdJwt.header.typ}'`;
|
25
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, message);
|
26
|
+
throw new _errors.IoWalletError(message);
|
31
27
|
}
|
32
|
-
|
33
|
-
// transfrom a record { key: value } in an iterable of pairs [key, value]
|
34
|
-
if (!credentialSubject.claims) {
|
28
|
+
if (!credentialConfig.claims) {
|
35
29
|
_logging.Logger.log(_logging.LogLevel.ERROR, "Missing claims in the credential subject");
|
36
30
|
throw new _errors.IoWalletError("Missing claims in the credential subject"); // TODO [SIW-1268]: should not be optional
|
37
31
|
}
|
38
32
|
|
39
|
-
const attrDefinitions =
|
33
|
+
const attrDefinitions = credentialConfig.claims;
|
40
34
|
|
41
35
|
// the key of the attribute defintion must match the disclosure's name
|
42
|
-
const attrsNotInDisclosures = attrDefinitions.filter(_ref2 => {
|
43
|
-
let [
|
44
|
-
return
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
});
|
36
|
+
const attrsNotInDisclosures = attrDefinitions.filter(definition => !disclosures.some(_ref2 => {
|
37
|
+
let [, name] = _ref2;
|
38
|
+
return name === definition.path[0];
|
39
|
+
}) // Ignore nested paths for now, see https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0-15.html#name-claims-path-pointer
|
40
|
+
);
|
41
|
+
|
49
42
|
if (attrsNotInDisclosures.length > 0) {
|
50
|
-
const missing = attrsNotInDisclosures.map(_ => _[0
|
43
|
+
const missing = attrsNotInDisclosures.map(_ => _.path[0]).join(", ");
|
51
44
|
const received = disclosures.map(_ => _[1 /* name */]).join(", ");
|
52
45
|
if (!ignoreMissingAttributes) {
|
53
|
-
|
54
|
-
|
46
|
+
const message = `Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`;
|
47
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, message);
|
48
|
+
throw new _errors.IoWalletError(message);
|
55
49
|
}
|
56
50
|
}
|
57
51
|
|
@@ -59,28 +53,31 @@ const parseCredentialSdJwt = function (credentials_supported, _ref) {
|
|
59
53
|
// and are present in the disclosure set
|
60
54
|
const definedValues = Object.fromEntries(attrDefinitions
|
61
55
|
// retrieve the value from the disclosure set
|
62
|
-
.map(
|
56
|
+
.map(_ref3 => {
|
63
57
|
var _disclosures$find;
|
64
|
-
let
|
65
|
-
|
58
|
+
let {
|
59
|
+
path,
|
60
|
+
...definition
|
61
|
+
} = _ref3;
|
62
|
+
return [path[0], {
|
66
63
|
...definition,
|
67
|
-
value: (_disclosures$find = disclosures.find(_ => _[1 /* name */] ===
|
64
|
+
value: (_disclosures$find = disclosures.find(_ => _[1 /* name */] === path[0])) === null || _disclosures$find === void 0 ? void 0 : _disclosures$find[2 /* value */]
|
68
65
|
}];
|
69
66
|
})
|
70
67
|
// add a human readable attribute name, with i18n, in the form { locale: name }
|
71
68
|
// example: { "it-IT": "Nome", "en-EN": "Name", "es-ES": "Nombre" }
|
72
|
-
.map(
|
69
|
+
.map(_ref4 => {
|
73
70
|
let [attrKey, {
|
74
71
|
display,
|
75
72
|
...definition
|
76
|
-
}] =
|
73
|
+
}] = _ref4;
|
77
74
|
return [attrKey, {
|
78
75
|
...definition,
|
79
|
-
name: display.reduce((names,
|
76
|
+
name: display.reduce((names, _ref5) => {
|
80
77
|
let {
|
81
78
|
locale,
|
82
79
|
name
|
83
|
-
} =
|
80
|
+
} = _ref5;
|
84
81
|
return {
|
85
82
|
...names,
|
86
83
|
[locale]: name
|
@@ -91,8 +88,8 @@ const parseCredentialSdJwt = function (credentials_supported, _ref) {
|
|
91
88
|
if (includeUndefinedAttributes) {
|
92
89
|
// attributes that are in the disclosure set
|
93
90
|
// but are not defined in the issuer configuration
|
94
|
-
const undefinedValues = Object.fromEntries(disclosures.filter(_ => !Object.keys(definedValues).includes(_[1])).map(
|
95
|
-
let [, key, value] =
|
91
|
+
const undefinedValues = Object.fromEntries(disclosures.filter(_ => !Object.keys(definedValues).includes(_[1])).map(_ref6 => {
|
92
|
+
let [, key, value] = _ref6;
|
96
93
|
return [key, {
|
97
94
|
value,
|
98
95
|
name: key
|
@@ -129,23 +126,26 @@ async function verifyCredentialSdJwt(rawCredential, issuerKeys, holderBindingCon
|
|
129
126
|
cnf
|
130
127
|
} = decodedCredential.sdJwt.payload;
|
131
128
|
if (!cnf.jwk.kid || cnf.jwk.kid !== holderBindingKey.kid) {
|
132
|
-
|
133
|
-
|
129
|
+
const message = `Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`;
|
130
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, message);
|
131
|
+
throw new _errors.IoWalletError(message);
|
134
132
|
}
|
135
133
|
return decodedCredential;
|
136
134
|
}
|
137
|
-
|
138
|
-
// utility type that specialize VerifyAndParseCredential for given format
|
139
|
-
|
140
|
-
const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref8) => {
|
135
|
+
const verifyAndParseCredentialSdJwt = async (issuerConf, credential, credentialConfigurationId, _ref7) => {
|
141
136
|
let {
|
142
137
|
credentialCryptoContext,
|
143
138
|
ignoreMissingAttributes,
|
144
139
|
includeUndefinedAttributes
|
145
|
-
} =
|
140
|
+
} = _ref7;
|
146
141
|
const decoded = await verifyCredentialSdJwt(credential, issuerConf.openid_credential_issuer.jwks.keys, credentialCryptoContext);
|
147
142
|
_logging.Logger.log(_logging.LogLevel.DEBUG, `Decoded credential: ${JSON.stringify(decoded)}`);
|
148
|
-
const
|
143
|
+
const credentialConfig = issuerConf.openid_credential_issuer.credential_configurations_supported[credentialConfigurationId];
|
144
|
+
if (!credentialConfig) {
|
145
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, `Credential type not supported by the issuer: ${credentialConfigurationId}`);
|
146
|
+
throw new _errors.IoWalletError("Credential type not supported by the issuer");
|
147
|
+
}
|
148
|
+
const parsedCredential = parseCredentialSdJwt(credentialConfig, decoded, ignoreMissingAttributes, includeUndefinedAttributes);
|
149
149
|
const maybeIssuedAt = (0, _converters.getValueFromDisclosures)(decoded.disclosures, "iat");
|
150
150
|
_logging.Logger.log(_logging.LogLevel.DEBUG, `Parsed credential: ${JSON.stringify(parsedCredential)}\nIssued at: ${maybeIssuedAt}`);
|
151
151
|
return {
|
@@ -159,7 +159,7 @@ const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref8) =
|
|
159
159
|
* Verify and parse an encoded credential.
|
160
160
|
* @param issuerConf The Issuer configuration returned by {@link evaluateIssuerTrust}
|
161
161
|
* @param credential The encoded credential returned by {@link obtainCredential}
|
162
|
-
* @param
|
162
|
+
* @param credentialConfigurationId The credential configuration ID that defines the provided credential
|
163
163
|
* @param context.credentialCryptoContext The crypto context used to obtain the credential in {@link obtainCredential}
|
164
164
|
* @param context.ignoreMissingAttributes Skip error when attributes declared in the issuer configuration are not found within disclosures
|
165
165
|
* @param context.includeUndefinedAttributes Include attributes not explicitly declared in the issuer configuration
|
@@ -168,13 +168,16 @@ const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref8) =
|
|
168
168
|
* @throws {IoWalletError} If the credential is not bound to the provided user key
|
169
169
|
* @throws {IoWalletError} If the credential data fail to parse
|
170
170
|
*/
|
171
|
-
const verifyAndParseCredential = async (issuerConf, credential,
|
172
|
-
|
173
|
-
|
174
|
-
|
171
|
+
const verifyAndParseCredential = async (issuerConf, credential, credentialConfigurationId, context) => {
|
172
|
+
var _issuerConf$openid_cr;
|
173
|
+
const format = (_issuerConf$openid_cr = issuerConf.openid_credential_issuer.credential_configurations_supported[credentialConfigurationId]) === null || _issuerConf$openid_cr === void 0 ? void 0 : _issuerConf$openid_cr.format;
|
174
|
+
if (format === "dc+sd-jwt") {
|
175
|
+
_logging.Logger.log(_logging.LogLevel.DEBUG, "Parsing credential in dc+sd-jwt format");
|
176
|
+
return verifyAndParseCredentialSdJwt(issuerConf, credential, credentialConfigurationId, context);
|
175
177
|
}
|
176
|
-
|
177
|
-
|
178
|
+
const message = `Unsupported credential format: ${format}`;
|
179
|
+
_logging.Logger.log(_logging.LogLevel.ERROR, message);
|
180
|
+
throw new _errors.IoWalletError(message);
|
178
181
|
};
|
179
182
|
exports.verifyAndParseCredential = verifyAndParseCredential;
|
180
183
|
//# sourceMappingURL=07-verify-and-parse-credential.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_errors","require","_types","_sdJwt","_converters","_logging","parseCredentialSdJwt","
|
1
|
+
{"version":3,"names":["_errors","require","_types","_sdJwt","_converters","_logging","parseCredentialSdJwt","credentialConfig","_ref","sdJwt","disclosures","ignoreMissingAttributes","arguments","length","undefined","includeUndefinedAttributes","format","header","typ","message","Logger","log","LogLevel","ERROR","IoWalletError","claims","attrDefinitions","attrsNotInDisclosures","filter","definition","some","_ref2","name","path","missing","map","_","join","received","definedValues","Object","fromEntries","_ref3","_disclosures$find","value","find","_ref4","attrKey","display","reduce","names","_ref5","locale","undefinedValues","keys","includes","_ref6","key","verifyCredentialSdJwt","rawCredential","issuerKeys","holderBindingContext","decodedCredential","holderBindingKey","Promise","all","verifySdJwt","SdJwt4VC","getPublicKey","cnf","payload","jwk","kid","verifyAndParseCredentialSdJwt","issuerConf","credential","credentialConfigurationId","_ref7","credentialCryptoContext","decoded","openid_credential_issuer","jwks","DEBUG","JSON","stringify","credential_configurations_supported","parsedCredential","maybeIssuedAt","getValueFromDisclosures","expiration","Date","exp","issuedAt","verifyAndParseCredential","context","_issuerConf$openid_cr","exports"],"sourceRoot":"../../../../src","sources":["credential/issuance/07-verify-and-parse-credential.ts"],"mappings":";;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAGA,IAAAI,QAAA,GAAAJ,OAAA;AA2BA;;AAkBA;;AAKA,MAAMK,oBAAoB,GAAG,SAAAA,CAE3BC,gBAAgC,EAAAC,IAAA,EAIX;EAAA,IAHrB;IAAEC,KAAK;IAAEC;EAAoC,CAAC,G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,CAACqB,GAAG,GAAG,IAAI,CAAC;IACtDC,QAAQ,EACN,OAAOL,aAAa,KAAK,QAAQ,GAC7B,IAAIG,IAAI,CAACH,aAAa,GAAG,IAAI,CAAC,GAC9BzE;EACR,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM+E,wBAAkD,GAAG,MAAAA,CAChEnB,UAAU,EACVC,UAAU,EACVC,yBAAyB,EACzBkB,OAAO,KACJ;EAAA,IAAAC,qBAAA;EACH,MAAM/E,MAAM,IAAA+E,qBAAA,GACVrB,UAAU,CAACM,wBAAwB,CAACK,mCAAmC,CACrET,yBAAyB,CAC1B,cAAAmB,qBAAA,uBAFDA,qBAAA,CAEG/E,MAAM;EAEX,IAAIA,MAAM,KAAK,WAAW,EAAE;IAC1BI,eAAM,CAACC,GAAG,CAACC,iBAAQ,CAAC4D,KAAK,EAAE,wCAAwC,CAAC;IACpE,OAAOT,6BAA6B,CAClCC,UAAU,EACVC,UAAU,EACVC,yBAAyB,EACzBkB,OACF,CAAC;EACH;EAEA,MAAM3E,OAAO,GAAI,kCAAiCH,MAAO,EAAC;EAC1DI,eAAM,CAACC,GAAG,CAACC,iBAAQ,CAACC,KAAK,EAAEJ,OAAO,CAAC;EACnC,MAAM,IAAIK,qBAAa,CAACL,OAAO,CAAC;AAClC,CAAC;AAAC6E,OAAA,CAAAH,wBAAA,GAAAA,wBAAA"}
|
@@ -6,7 +6,7 @@ There's a fork in the flow which is based on the type of the credential that is
|
|
6
6
|
This is due to the fact that eID credentials require a different authorization flow than other credentials, which is accomplished by a strong authentication method like SPID or CIE.
|
7
7
|
Credentials instead require a simpler authorization flow and they require other credentials to be presented in order to be issued.
|
8
8
|
|
9
|
-
The supported credentials are defined in the entity configuration of the issuer which is evaluted and parsed in the `evaluateIssuerTrust` step.
|
9
|
+
The supported credentials are defined in the entity configuration of the issuer which is evaluted and parsed in the `evaluateIssuerTrust` step. Available credentials are identified with a unique `credential_configuration_id`, that must be used when requesting authorization. The Authorization Server returns an array of **credential identifiers** that map to the `credential_configuration_id` provided: to obtain the credential, one of the credential identifiers (or all of them) must be requested to the credential endpoint.
|
10
10
|
|
11
11
|
## Sequence Diagram
|
12
12
|
|
@@ -96,17 +96,13 @@ const walletInstanceAttestation =
|
|
96
96
|
appFetch,
|
97
97
|
});
|
98
98
|
|
99
|
-
const
|
100
|
-
|
101
|
-
const eid = {
|
99
|
+
const pid = {
|
102
100
|
credential: "example",
|
103
101
|
parsedCredential: "example"
|
104
102
|
keyTag: "example";
|
105
|
-
credentialType: "
|
103
|
+
credentialType: "PersonIdentificationData";
|
106
104
|
};
|
107
105
|
|
108
|
-
const eidCryptoContext = createCryptoContextFor(eid.keyTag);
|
109
|
-
|
110
106
|
// Create credential crypto context
|
111
107
|
const credentialKeyTag = uuidv4().toString();
|
112
108
|
await generate(credentialKeyTag); // Let's assume this function generates a new hardware-backed key pair
|
@@ -115,22 +111,26 @@ const credentialCryptoContext = createCryptoContextFor(credentialKeyTag);
|
|
115
111
|
// Start the issuance flow
|
116
112
|
const startFlow: Credential.Issuance.StartFlow = () => ({
|
117
113
|
issuerUrl: WALLET_EAA_PROVIDER_BASE_URL,
|
118
|
-
|
114
|
+
credentialId: "someCredentialId",
|
119
115
|
});
|
120
116
|
|
121
|
-
const { issuerUrl } = startFlow();
|
117
|
+
const { issuerUrl, credentialId } = startFlow();
|
122
118
|
|
123
119
|
// Evaluate issuer trust
|
124
120
|
const { issuerConf } = await Credential.Issuance.evaluateIssuerTrust(issuerUrl);
|
125
121
|
|
126
122
|
// Start user authorization
|
127
|
-
const { issuerRequestUri, clientId, codeVerifier
|
128
|
-
await Credential.Issuance.startUserAuthorization(
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
123
|
+
const { issuerRequestUri, clientId, codeVerifier } =
|
124
|
+
await Credential.Issuance.startUserAuthorization(
|
125
|
+
issuerConf,
|
126
|
+
[credentialId],
|
127
|
+
{
|
128
|
+
walletInstanceAttestation,
|
129
|
+
redirectUri: REDIRECT_URI,
|
130
|
+
wiaCryptoContext,
|
131
|
+
appFetch,
|
132
|
+
}
|
133
|
+
);
|
134
134
|
|
135
135
|
const requestObject =
|
136
136
|
await Credential.Issuance.getRequestedCredentialToBePresented(
|
@@ -140,13 +140,12 @@ const requestObject =
|
|
140
140
|
appFetch
|
141
141
|
);
|
142
142
|
|
143
|
-
// The app here should ask the user to confirm the required data contained in the requestObject
|
144
|
-
|
145
143
|
// Complete the user authorization via form_post.jwt mode
|
146
144
|
const { code } =
|
147
145
|
await Credential.Issuance.completeUserAuthorizationWithFormPostJwtMode(
|
148
146
|
requestObject,
|
149
|
-
|
147
|
+
pid.credential,
|
148
|
+
{ wiaCryptoContext, pidCryptoContext: createCryptoContextFor(pid.keyTag) }
|
150
149
|
);
|
151
150
|
|
152
151
|
// Generate the DPoP context which will be used for the whole issuance flow
|
@@ -157,7 +156,7 @@ const { accessToken } = await Credential.Issuance.authorizeAccess(
|
|
157
156
|
issuerConf,
|
158
157
|
code,
|
159
158
|
clientId,
|
160
|
-
redirectUri,
|
159
|
+
redirectUri: REDIRECT_URI,
|
161
160
|
codeVerifier,
|
162
161
|
{
|
163
162
|
walletInstanceAttestation,
|
@@ -167,12 +166,19 @@ const { accessToken } = await Credential.Issuance.authorizeAccess(
|
|
167
166
|
}
|
168
167
|
);
|
169
168
|
|
170
|
-
//
|
171
|
-
const {
|
169
|
+
// For simplicity, in this example flow we work on a single credential.
|
170
|
+
const { credential_configuration_id, credential_identifiers } =
|
171
|
+
accessToken.authorization_details[0]!;
|
172
|
+
|
173
|
+
// Obtain the credential
|
174
|
+
const { credential } = await Credential.Issuance.obtainCredential(
|
172
175
|
issuerConf,
|
173
176
|
accessToken,
|
174
177
|
clientId,
|
175
|
-
|
178
|
+
{
|
179
|
+
credential_configuration_id,
|
180
|
+
credential_identifier: credential_identifiers[0],
|
181
|
+
},
|
176
182
|
{
|
177
183
|
credentialCryptoContext,
|
178
184
|
dPopCryptoContext,
|
@@ -184,22 +190,29 @@ const { credential, format } = await Credential.Issuance.obtainCredential(
|
|
184
190
|
* Parse and verify the credential. The ignoreMissingAttributes flag must be set to false or omitted in production.
|
185
191
|
* WARNING: includeUndefinedAttributes should not be set to true in production in order to get only claims explicitly declared by the issuer.
|
186
192
|
*/
|
187
|
-
const { parsedCredential } =
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
193
|
+
const { parsedCredential } =
|
194
|
+
await Credential.Issuance.verifyAndParseCredential(
|
195
|
+
issuerConf,
|
196
|
+
credential,
|
197
|
+
credential_configuration_id,
|
198
|
+
{
|
199
|
+
credentialCryptoContext,
|
200
|
+
ignoreMissingAttributes: true,
|
201
|
+
includeUndefinedAttributes: false
|
202
|
+
}
|
203
|
+
);
|
204
|
+
|
205
|
+
const credentialType =
|
206
|
+
issuerConf.openid_credential_issuer.credential_configurations_supported[
|
207
|
+
credential_configuration_id
|
208
|
+
].scope;
|
197
209
|
|
198
210
|
return {
|
199
211
|
parsedCredential,
|
200
212
|
credential,
|
201
213
|
keyTag: credentialKeyTag,
|
202
214
|
credentialType,
|
215
|
+
credentialConfigurationId: credential_configuration_id,
|
203
216
|
};
|
204
217
|
```
|
205
218
|
|
@@ -251,11 +264,10 @@ const credentialCryptoContext = createCryptoContextFor(credentialKeyTag);
|
|
251
264
|
// Start the issuance flow
|
252
265
|
const startFlow: Credential.Issuance.StartFlow = () => ({
|
253
266
|
issuerUrl: WALLET_EID_PROVIDER_BASE_URL,
|
254
|
-
|
255
|
-
appFetch,
|
267
|
+
credentialId: "dc_sd_jwt_PersonIdentificationData",
|
256
268
|
});
|
257
269
|
|
258
|
-
const { issuerUrl } = startFlow();
|
270
|
+
const { issuerUrl, credentialId } = startFlow();
|
259
271
|
|
260
272
|
// Evaluate issuer trust
|
261
273
|
const { issuerConf } = await Credential.Issuance.evaluateIssuerTrust(
|
@@ -265,12 +277,16 @@ const { issuerConf } = await Credential.Issuance.evaluateIssuerTrust(
|
|
265
277
|
|
266
278
|
// Start user authorization
|
267
279
|
const { issuerRequestUri, clientId, codeVerifier, credentialDefinition } =
|
268
|
-
await Credential.Issuance.startUserAuthorization(
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
280
|
+
await Credential.Issuance.startUserAuthorization(
|
281
|
+
issuerConf,
|
282
|
+
[credentialId], // Request authorization for one or more credentials
|
283
|
+
{
|
284
|
+
walletInstanceAttestation,
|
285
|
+
redirectUri,
|
286
|
+
wiaCryptoContext,
|
287
|
+
appFetch,
|
288
|
+
}
|
289
|
+
);
|
274
290
|
|
275
291
|
// Complete the authorization process with query mode with the authorizationContext which opens the browser
|
276
292
|
const { code } =
|
@@ -301,12 +317,27 @@ const { accessToken } = await Credential.Issuance.authorizeAccess(
|
|
301
317
|
}
|
302
318
|
);
|
303
319
|
|
320
|
+
|
321
|
+
const [pidCredentialDefinition] = credentialDefinition;
|
322
|
+
|
323
|
+
// Extract the credential_identifier(s) from the access token
|
324
|
+
// For each one of them, a credential can be obtained by calling `obtainCredential`
|
325
|
+
const { credential_configuration_id, credential_identifiers } =
|
326
|
+
accessToken.authorization_details.find(
|
327
|
+
(authDetails) =>
|
328
|
+
authDetails.credential_configuration_id ===
|
329
|
+
pidCredentialDefinition.credential_configuration_id
|
330
|
+
);
|
331
|
+
|
304
332
|
// Obtain che eID credential
|
305
333
|
const { credential, format } = await Credential.Issuance.obtainCredential(
|
306
334
|
issuerConf,
|
307
335
|
accessToken,
|
308
336
|
clientId,
|
309
|
-
|
337
|
+
{
|
338
|
+
credential_configuration_id,
|
339
|
+
credential_identifier: credential_identifiers.at(0),
|
340
|
+
},
|
310
341
|
{
|
311
342
|
credentialCryptoContext,
|
312
343
|
dPopCryptoContext,
|
@@ -318,15 +349,16 @@ const { credential, format } = await Credential.Issuance.obtainCredential(
|
|
318
349
|
const { parsedCredential, issuedAt, expiration } = await Credential.Issuance.verifyAndParseCredential(
|
319
350
|
issuerConf,
|
320
351
|
credential,
|
321
|
-
|
352
|
+
credential_configuration_id,
|
322
353
|
{ credentialCryptoContext }
|
323
354
|
);
|
324
355
|
|
325
356
|
return {
|
326
357
|
parsedCredential,
|
327
358
|
credential,
|
359
|
+
credentialConfigurationId: credential_configuration_id
|
360
|
+
credentialType: "PersonIdentificationData",
|
328
361
|
keyTag: credentialKeyTag,
|
329
|
-
credentialType,
|
330
362
|
issuedAt,
|
331
363
|
expiration
|
332
364
|
};
|
@@ -9,6 +9,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
9
9
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
10
10
|
const ASSERTION_TYPE = "urn:ietf:params:oauth:client-assertion-type:jwt-client-attestation";
|
11
11
|
exports.ASSERTION_TYPE = ASSERTION_TYPE;
|
12
|
-
const SupportedCredentialFormat = z.union([z.literal("
|
12
|
+
const SupportedCredentialFormat = z.union([z.literal("dc+sd-jwt"), z.literal("vc+mdoc-cbor")]);
|
13
13
|
exports.SupportedCredentialFormat = SupportedCredentialFormat;
|
14
14
|
//# sourceMappingURL=const.js.map
|
@@ -3,26 +3,29 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.TokenResponse = exports.ResponseUriResultShape = exports.CredentialResponse = void 0;
|
7
|
-
var _par = require("../../utils/par");
|
6
|
+
exports.TokenResponse = exports.ResponseUriResultShape = exports.NonceResponse = exports.CredentialResponse = exports.AuthorizationDetail = void 0;
|
8
7
|
var z = _interopRequireWildcard(require("zod"));
|
9
|
-
var _const = require("./const");
|
10
8
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
11
9
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
10
|
+
const AuthorizationDetail = z.object({
|
11
|
+
type: z.literal("openid_credential"),
|
12
|
+
credential_configuration_id: z.string(),
|
13
|
+
credential_identifiers: z.array(z.string())
|
14
|
+
});
|
15
|
+
exports.AuthorizationDetail = AuthorizationDetail;
|
12
16
|
const TokenResponse = z.object({
|
13
17
|
access_token: z.string(),
|
14
|
-
|
15
|
-
|
16
|
-
c_nonce_expires_in: z.number(),
|
18
|
+
refresh_token: z.string().optional(),
|
19
|
+
authorization_details: z.array(AuthorizationDetail),
|
17
20
|
expires_in: z.number(),
|
18
21
|
token_type: z.string()
|
19
22
|
});
|
20
23
|
exports.TokenResponse = TokenResponse;
|
21
24
|
const CredentialResponse = z.object({
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
credentials: z.array(z.object({
|
26
|
+
credential: z.string()
|
27
|
+
})),
|
28
|
+
notification_id: z.string().optional()
|
26
29
|
});
|
27
30
|
|
28
31
|
/**
|
@@ -33,4 +36,8 @@ const ResponseUriResultShape = z.object({
|
|
33
36
|
redirect_uri: z.string()
|
34
37
|
});
|
35
38
|
exports.ResponseUriResultShape = ResponseUriResultShape;
|
39
|
+
const NonceResponse = z.object({
|
40
|
+
c_nonce: z.string()
|
41
|
+
});
|
42
|
+
exports.NonceResponse = NonceResponse;
|
36
43
|
//# sourceMappingURL=types.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["z","_interopRequireWildcard","require","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","AuthorizationDetail","object","type","literal","credential_configuration_id","string","credential_identifiers","array","exports","TokenResponse","access_token","refresh_token","optional","authorization_details","expires_in","number","token_type","CredentialResponse","credentials","credential","notification_id","ResponseUriResultShape","redirect_uri","NonceResponse","c_nonce"],"sourceRoot":"../../../../src","sources":["credential/issuance/types.ts"],"mappings":";;;;;;AAAA,IAAAA,CAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAyB,SAAAC,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAH,wBAAAO,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,G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EpC,CAAC,CAAC8B,MAAM,CAAC,CAAC,CAACO,QAAQ,CAAC,CAAC;EACpCC,qBAAqB,EAAEtC,CAAC,CAACgC,KAAK,CAACP,mBAAmB,CAAC;EACnDc,UAAU,EAAEvC,CAAC,CAACwC,MAAM,CAAC,CAAC;EACtBC,UAAU,EAAEzC,CAAC,CAAC8B,MAAM,CAAC;AACvB,CAAC,CAAC;AAACG,OAAA,CAAAC,aAAA,GAAAA,aAAA;AAII,MAAMQ,kBAAkB,GAAG1C,CAAC,CAAC0B,MAAM,CAAC;EACzCiB,WAAW,EAAE3C,CAAC,CAACgC,KAAK,CAClBhC,CAAC,CAAC0B,MAAM,CAAC;IACPkB,UAAU,EAAE5C,CAAC,CAAC8B,MAAM,CAAC;EACvB,CAAC,CACH,CAAC;EACDe,eAAe,EAAE7C,CAAC,CAAC8B,MAAM,CAAC,CAAC,CAACO,QAAQ,CAAC;AACvC,CAAC,CAAC;;AAEF;AACA;AACA;AAFAJ,OAAA,CAAAS,kBAAA,GAAAA,kBAAA;AAGO,MAAMI,sBAAsB,GAAG9C,CAAC,CAAC0B,MAAM,CAAC;EAC7CqB,YAAY,EAAE/C,CAAC,CAAC8B,MAAM,CAAC;AACzB,CAAC,CAAC;AAACG,OAAA,CAAAa,sBAAA,GAAAA,sBAAA;AAKI,MAAME,aAAa,GAAGhD,CAAC,CAAC0B,MAAM,CAAC;EACpCuB,OAAO,EAAEjD,CAAC,CAAC8B,MAAM,CAAC;AACpB,CAAC,CAAC;AAACG,OAAA,CAAAe,aAAA,GAAAA,aAAA"}
|
@@ -7,7 +7,6 @@ exports.prepareRemotePresentations = exports.evaluateDcqlQuery = void 0;
|
|
7
7
|
var _dcql = require("dcql");
|
8
8
|
var _valibot = require("valibot");
|
9
9
|
var _sdJwt = require("../../sd-jwt");
|
10
|
-
var _crypto = require("../../utils/crypto");
|
11
10
|
var _errors = require("./errors");
|
12
11
|
/**
|
13
12
|
* The purpose for the credential request by the RP.
|
@@ -23,11 +22,6 @@ const mapCredentialToObject = jwt => {
|
|
23
22
|
disclosures
|
24
23
|
} = (0, _sdJwt.decode)(jwt);
|
25
24
|
const credentialFormat = sdJwt.header.typ;
|
26
|
-
|
27
|
-
// TODO [SIW-2082]: support MDOC credentials
|
28
|
-
if (credentialFormat !== "vc+sd-jwt") {
|
29
|
-
throw new Error(`Unsupported credential format: ${credentialFormat}`);
|
30
|
-
}
|
31
25
|
return {
|
32
26
|
vct: sdJwt.payload.vct,
|
33
27
|
credential_format: credentialFormat,
|
@@ -64,7 +58,7 @@ const extractMissingCredentials = (queryResult, originalQuery) => {
|
|
64
58
|
var _credential$meta;
|
65
59
|
let [id] = _ref3;
|
66
60
|
const credential = originalQuery.credentials.find(c => c.id === id);
|
67
|
-
if ((credential === null || credential === void 0 ? void 0 : credential.format) !== "vc+sd-jwt") {
|
61
|
+
if ((credential === null || credential === void 0 ? void 0 : credential.format) !== "dc+sd-jwt" && (credential === null || credential === void 0 ? void 0 : credential.format) !== "vc+sd-jwt") {
|
68
62
|
throw new Error("Unsupported format"); // TODO [SIW-2082]: support MDOC credentials
|
69
63
|
}
|
70
64
|
|
@@ -96,7 +90,7 @@ const evaluateDcqlQuery = (credentialsSdJwt, query) => {
|
|
96
90
|
return getDcqlQueryMatches(queryResult).map(_ref5 => {
|
97
91
|
var _queryResult$credenti;
|
98
92
|
let [id, match] = _ref5;
|
99
|
-
if (match.output.credential_format !== "vc+sd-jwt") {
|
93
|
+
if (match.output.credential_format !== "dc+sd-jwt" && match.output.credential_format !== "vc+sd-jwt") {
|
100
94
|
throw new Error("Unsupported format"); // TODO [SIW-2082]: support MDOC credentials
|
101
95
|
}
|
102
96
|
|
@@ -114,12 +108,12 @@ const evaluateDcqlQuery = (credentialsSdJwt, query) => {
|
|
114
108
|
required: Boolean(credentialSet.required)
|
115
109
|
};
|
116
110
|
});
|
117
|
-
const [
|
111
|
+
const [cryptoContext, credential] = credentialsSdJwtByVct[vct];
|
118
112
|
const requiredDisclosures = Object.values(claims);
|
119
113
|
return {
|
120
114
|
id,
|
121
115
|
vct,
|
122
|
-
|
116
|
+
cryptoContext,
|
123
117
|
credential,
|
124
118
|
requiredDisclosures,
|
125
119
|
// When it is a match but no credential_sets are found, the credential is required by default
|
@@ -148,12 +142,11 @@ const prepareRemotePresentations = async (credentials, nonce, clientId) => {
|
|
148
142
|
return Promise.all(credentials.map(async item => {
|
149
143
|
const {
|
150
144
|
vp_token
|
151
|
-
} = await (0, _sdJwt.prepareVpToken)(nonce, clientId, [item.credential, item.requestedClaims,
|
145
|
+
} = await (0, _sdJwt.prepareVpToken)(nonce, clientId, [item.credential, item.requestedClaims, item.cryptoContext]);
|
152
146
|
return {
|
153
147
|
credentialId: item.id,
|
154
148
|
requestedClaims: item.requestedClaims,
|
155
|
-
vpToken: vp_token
|
156
|
-
format: "vc+sd-jwt"
|
149
|
+
vpToken: vp_token
|
157
150
|
};
|
158
151
|
}));
|
159
152
|
};
|