@pagopa/io-react-native-wallet 0.28.2 → 0.30.0
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/README.md +43 -0
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js +5 -0
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +12 -0
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/05-authorize-access.js +5 -0
- package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +13 -2
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +10 -0
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/credential/presentation/01-start-flow.js +9 -8
- package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/commonjs/credential/presentation/03-get-request-object.js +3 -2
- package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/05-verify-request-object.js +57 -22
- package/lib/commonjs/credential/presentation/05-verify-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +43 -16
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +16 -4
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js +85 -3
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/commonjs/credential/presentation/README.md +27 -9
- package/lib/commonjs/credential/presentation/errors.js +28 -23
- package/lib/commonjs/credential/presentation/errors.js.map +1 -1
- package/lib/commonjs/credential/presentation/index.js +6 -0
- package/lib/commonjs/credential/presentation/index.js.map +1 -1
- package/lib/commonjs/credential/presentation/types.js +14 -7
- package/lib/commonjs/credential/presentation/types.js.map +1 -1
- package/lib/commonjs/credential/status/02-status-attestation.js +2 -0
- package/lib/commonjs/credential/status/02-status-attestation.js.map +1 -1
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js +3 -0
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js.map +1 -1
- package/lib/commonjs/credential/trustmark/get-credential-trustmark.js +5 -0
- package/lib/commonjs/credential/trustmark/get-credential-trustmark.js.map +1 -1
- package/lib/commonjs/index.js +3 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/decoder.js +2 -0
- package/lib/commonjs/utils/decoder.js.map +1 -1
- package/lib/commonjs/utils/error-codes.js +9 -1
- package/lib/commonjs/utils/error-codes.js.map +1 -1
- package/lib/commonjs/utils/errors.js +31 -14
- package/lib/commonjs/utils/errors.js.map +1 -1
- package/lib/commonjs/utils/logging.js +68 -0
- package/lib/commonjs/utils/logging.js.map +1 -0
- package/lib/commonjs/utils/misc.js +2 -0
- package/lib/commonjs/utils/misc.js.map +1 -1
- package/lib/commonjs/utils/par.js +2 -0
- package/lib/commonjs/utils/par.js.map +1 -1
- package/lib/commonjs/wallet-instance/index.js +4 -0
- package/lib/commonjs/wallet-instance/index.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/issuing.js +5 -0
- package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/module/credential/issuance/03-start-user-authorization.js +5 -0
- package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js +12 -0
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/05-authorize-access.js +5 -0
- package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +13 -2
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +10 -0
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/credential/presentation/01-start-flow.js +9 -8
- package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/module/credential/presentation/03-get-request-object.js +3 -2
- package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/module/credential/presentation/05-verify-request-object.js +58 -23
- package/lib/module/credential/presentation/05-verify-request-object.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js +44 -17
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +17 -5
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -1
- package/lib/module/credential/presentation/08-send-authorization-response.js +82 -1
- package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/module/credential/presentation/README.md +27 -9
- package/lib/module/credential/presentation/errors.js +17 -19
- package/lib/module/credential/presentation/errors.js.map +1 -1
- package/lib/module/credential/presentation/index.js +2 -2
- package/lib/module/credential/presentation/index.js.map +1 -1
- package/lib/module/credential/presentation/types.js +12 -6
- package/lib/module/credential/presentation/types.js.map +1 -1
- package/lib/module/credential/status/02-status-attestation.js +2 -0
- package/lib/module/credential/status/02-status-attestation.js.map +1 -1
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js +3 -0
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js.map +1 -1
- package/lib/module/credential/trustmark/get-credential-trustmark.js +5 -0
- package/lib/module/credential/trustmark/get-credential-trustmark.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/decoder.js +2 -0
- package/lib/module/utils/decoder.js.map +1 -1
- package/lib/module/utils/error-codes.js +7 -0
- package/lib/module/utils/error-codes.js.map +1 -1
- package/lib/module/utils/errors.js +23 -14
- package/lib/module/utils/errors.js.map +1 -1
- package/lib/module/utils/logging.js +62 -0
- package/lib/module/utils/logging.js.map +1 -0
- package/lib/module/utils/misc.js +2 -0
- package/lib/module/utils/misc.js.map +1 -1
- package/lib/module/utils/par.js +2 -0
- package/lib/module/utils/par.js.map +1 -1
- package/lib/module/wallet-instance/index.js +4 -0
- package/lib/module/wallet-instance/index.js.map +1 -1
- package/lib/module/wallet-instance-attestation/issuing.js +5 -0
- package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
- 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.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 +1 -1
- 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.map +1 -1
- package/lib/typescript/credential/presentation/01-start-flow.d.ts +17 -14
- package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts +1 -3
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/05-verify-request-object.d.ts +2 -1
- package/lib/typescript/credential/presentation/05-verify-request-object.d.ts.map +1 -1
- 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.map +1 -1
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +30 -2
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/errors.d.ts +17 -12
- package/lib/typescript/credential/presentation/errors.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/index.d.ts +3 -3
- package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/types.d.ts +24 -17
- package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
- package/lib/typescript/credential/status/02-status-attestation.d.ts.map +1 -1
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts.map +1 -1
- package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils/decoder.d.ts.map +1 -1
- package/lib/typescript/utils/error-codes.d.ts +8 -0
- package/lib/typescript/utils/error-codes.d.ts.map +1 -1
- package/lib/typescript/utils/errors.d.ts +32 -18
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/utils/logging.d.ts +35 -0
- package/lib/typescript/utils/logging.d.ts.map +1 -0
- package/lib/typescript/utils/misc.d.ts.map +1 -1
- package/lib/typescript/utils/par.d.ts.map +1 -1
- package/lib/typescript/wallet-instance/index.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/credential/issuance/03-start-user-authorization.ts +18 -0
- package/src/credential/issuance/04-complete-user-authorization.ts +51 -0
- package/src/credential/issuance/05-authorize-access.ts +16 -0
- package/src/credential/issuance/06-obtain-credential.ts +31 -2
- package/src/credential/issuance/07-verify-and-parse-credential.ts +27 -1
- package/src/credential/presentation/01-start-flow.ts +12 -11
- package/src/credential/presentation/03-get-request-object.ts +5 -5
- package/src/credential/presentation/05-verify-request-object.ts +73 -15
- package/src/credential/presentation/07-evaluate-dcql-query.ts +43 -18
- package/src/credential/presentation/07-evaluate-input-descriptor.ts +25 -13
- package/src/credential/presentation/08-send-authorization-response.ts +110 -3
- package/src/credential/presentation/README.md +27 -9
- package/src/credential/presentation/errors.ts +24 -17
- package/src/credential/presentation/index.ts +4 -0
- package/src/credential/presentation/types.ts +22 -10
- package/src/credential/status/02-status-attestation.ts +3 -0
- package/src/credential/status/03-verify-and-parse-status-attestation.ts +10 -0
- package/src/credential/trustmark/get-credential-trustmark.ts +19 -0
- package/src/index.ts +2 -0
- package/src/utils/decoder.ts +5 -0
- package/src/utils/error-codes.ts +11 -0
- package/src/utils/errors.ts +59 -29
- package/src/utils/logging.ts +68 -0
- package/src/utils/misc.ts +5 -0
- package/src/utils/par.ts +6 -0
- package/src/wallet-instance/index.ts +17 -1
- package/src/wallet-instance-attestation/issuing.ts +19 -0
@@ -2,6 +2,7 @@ import { IoWalletError } from "../../utils/errors";
|
|
2
2
|
import { SdJwt4VC } from "../../sd-jwt/types";
|
3
3
|
import { verify as verifySdJwt } from "../../sd-jwt";
|
4
4
|
import { getValueFromDisclosures } from "../../sd-jwt/converters";
|
5
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
5
6
|
|
6
7
|
// The credential as a collection of attributes in plain value
|
7
8
|
|
@@ -16,14 +17,17 @@ const parseCredentialSdJwt = function (credentials_supported, _ref) {
|
|
16
17
|
let includeUndefinedAttributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
17
18
|
const credentialSubject = credentials_supported[sdJwt.payload.vct];
|
18
19
|
if (!credentialSubject) {
|
20
|
+
Logger.log(LogLevel.ERROR, `Credential type not supported by the issuer: ${sdJwt.payload.vct}`);
|
19
21
|
throw new IoWalletError("Credential type not supported by the issuer");
|
20
22
|
}
|
21
23
|
if (credentialSubject.format !== sdJwt.header.typ) {
|
24
|
+
Logger.log(LogLevel.ERROR, `Received credential is of an unknwown type. Expected one of [${credentialSubject.format}], received '${sdJwt.header.typ}'`);
|
22
25
|
throw new IoWalletError(`Received credential is of an unknwown type. Expected one of [${credentialSubject.format}], received '${sdJwt.header.typ}', `);
|
23
26
|
}
|
24
27
|
|
25
28
|
// transfrom a record { key: value } in an iterable of pairs [key, value]
|
26
29
|
if (!credentialSubject.claims) {
|
30
|
+
Logger.log(LogLevel.ERROR, "Missing claims in the credential subject");
|
27
31
|
throw new IoWalletError("Missing claims in the credential subject"); // TODO [SIW-1268]: should not be optional
|
28
32
|
}
|
29
33
|
|
@@ -41,6 +45,7 @@ const parseCredentialSdJwt = function (credentials_supported, _ref) {
|
|
41
45
|
const missing = attrsNotInDisclosures.map(_ => _[0 /* key */]).join(", ");
|
42
46
|
const received = disclosures.map(_ => _[1 /* name */]).join(", ");
|
43
47
|
if (!ignoreMissingAttributes) {
|
48
|
+
Logger.log(LogLevel.ERROR, `Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`);
|
44
49
|
throw new IoWalletError(`Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`);
|
45
50
|
}
|
46
51
|
}
|
@@ -119,6 +124,7 @@ async function verifyCredentialSdJwt(rawCredential, issuerKeys, holderBindingCon
|
|
119
124
|
cnf
|
120
125
|
} = decodedCredential.sdJwt.payload;
|
121
126
|
if (!cnf.jwk.kid || cnf.jwk.kid !== holderBindingKey.kid) {
|
127
|
+
Logger.log(LogLevel.ERROR, `Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`);
|
122
128
|
throw new IoWalletError(`Failed to verify holder binding, expected kid: ${holderBindingKey.kid}, got: ${decodedCredential.sdJwt.payload.cnf.jwk.kid}`);
|
123
129
|
}
|
124
130
|
return decodedCredential;
|
@@ -133,8 +139,10 @@ const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref8) =
|
|
133
139
|
includeUndefinedAttributes
|
134
140
|
} = _ref8;
|
135
141
|
const decoded = await verifyCredentialSdJwt(credential, issuerConf.openid_credential_issuer.jwks.keys, credentialCryptoContext);
|
142
|
+
Logger.log(LogLevel.DEBUG, `Decoded credential: ${JSON.stringify(decoded)}`);
|
136
143
|
const parsedCredential = parseCredentialSdJwt(issuerConf.openid_credential_issuer.credential_configurations_supported, decoded, ignoreMissingAttributes, includeUndefinedAttributes);
|
137
144
|
const maybeIssuedAt = getValueFromDisclosures(decoded.disclosures, "iat");
|
145
|
+
Logger.log(LogLevel.DEBUG, `Parsed credential: ${JSON.stringify(parsedCredential)}\nIssued at: ${maybeIssuedAt}`);
|
138
146
|
return {
|
139
147
|
parsedCredential,
|
140
148
|
expiration: new Date(decoded.sdJwt.payload.exp * 1000),
|
@@ -157,8 +165,10 @@ const verifyAndParseCredentialSdJwt = async (issuerConf, credential, _, _ref8) =
|
|
157
165
|
*/
|
158
166
|
export const verifyAndParseCredential = async (issuerConf, credential, format, context) => {
|
159
167
|
if (format === "vc+sd-jwt") {
|
168
|
+
Logger.log(LogLevel.DEBUG, "Parsing credential in vc+sd-jwt format");
|
160
169
|
return verifyAndParseCredentialSdJwt(issuerConf, credential, format, context);
|
161
170
|
}
|
171
|
+
Logger.log(LogLevel.ERROR, `Unsupported credential format: ${format}`);
|
162
172
|
throw new IoWalletError(`Unsupported credential format: ${format}`);
|
163
173
|
};
|
164
174
|
//# sourceMappingURL=07-verify-and-parse-credential.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["IoWalletError","SdJwt4VC","verify","verifySdJwt","getValueFromDisclosures","parseCredentialSdJwt","credentials_supported","_ref","sdJwt","disclosures","ignoreMissingAttributes","arguments","length","undefined","includeUndefinedAttributes","credentialSubject","payload","vct","format","header","typ","claims","attrDefinitions","Object","entries","attrsNotInDisclosures","filter","_ref2","attrKey","some","_ref3","name","missing","map","_","join","received","definedValues","fromEntries","_ref4","_disclosures$find","definition","value","find","_ref5","display","reduce","names","_ref6","locale","undefinedValues","keys","includes","_ref7","key","verifyCredentialSdJwt","rawCredential","issuerKeys","holderBindingContext","decodedCredential","holderBindingKey","Promise","all","getPublicKey","cnf","jwk","kid","verifyAndParseCredentialSdJwt","issuerConf","credential","_ref8","credentialCryptoContext","decoded","openid_credential_issuer","jwks","parsedCredential","credential_configurations_supported","maybeIssuedAt","expiration","Date","exp","issuedAt","verifyAndParseCredential","context"],"sourceRoot":"../../../../src","sources":["credential/issuance/07-verify-and-parse-credential.ts"],"mappings":"AAGA,SAASA,aAAa,QAAQ,oBAAoB;AAClD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,MAAM,IAAIC,WAAW,QAAQ,cAAc;AACpD,SAASC,uBAAuB,QAAQ,yBAAyB;;
|
1
|
+
{"version":3,"names":["IoWalletError","SdJwt4VC","verify","verifySdJwt","getValueFromDisclosures","LogLevel","Logger","parseCredentialSdJwt","credentials_supported","_ref","sdJwt","disclosures","ignoreMissingAttributes","arguments","length","undefined","includeUndefinedAttributes","credentialSubject","payload","vct","log","ERROR","format","header","typ","claims","attrDefinitions","Object","entries","attrsNotInDisclosures","filter","_ref2","attrKey","some","_ref3","name","missing","map","_","join","received","definedValues","fromEntries","_ref4","_disclosures$find","definition","value","find","_ref5","display","reduce","names","_ref6","locale","undefinedValues","keys","includes","_ref7","key","verifyCredentialSdJwt","rawCredential","issuerKeys","holderBindingContext","decodedCredential","holderBindingKey","Promise","all","getPublicKey","cnf","jwk","kid","verifyAndParseCredentialSdJwt","issuerConf","credential","_ref8","credentialCryptoContext","decoded","openid_credential_issuer","jwks","DEBUG","JSON","stringify","parsedCredential","credential_configurations_supported","maybeIssuedAt","expiration","Date","exp","issuedAt","verifyAndParseCredential","context"],"sourceRoot":"../../../../src","sources":["credential/issuance/07-verify-and-parse-credential.ts"],"mappings":"AAGA,SAASA,aAAa,QAAQ,oBAAoB;AAClD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,MAAM,IAAIC,WAAW,QAAQ,cAAc;AACpD,SAASC,uBAAuB,QAAQ,yBAAyB;AAGjE,SAASC,QAAQ,EAAEC,MAAM,QAAQ,qBAAqB;;AAuBtD;;AAkBA;;AAKA,MAAMC,oBAAoB,GAAG,SAAAA,CAE3BC,qBAAgI,EAAAC,IAAA,EAI3G;EAAA,IAHrB;IAAEC,KAAK;IAAEC;EAAoC,CAAC,GAAAF,IAAA;EAAA,IAC9CG,uBAAgC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAAA,IACxCG,0BAAmC,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,G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,EACN,OAAOJ,aAAa,KAAK,QAAQ,GAC7B,IAAIE,IAAI,CAACF,aAAa,GAAG,IAAI,CAAC,GAC9BrE;EACR,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM0E,wBAAkD,GAAG,MAAAA,CAChEjB,UAAU,EACVC,UAAU,EACVnD,MAAM,EACNoE,OAAO,KACJ;EACH,IAAIpE,MAAM,KAAK,WAAW,EAAE;IAC1BhB,MAAM,CAACc,GAAG,CAACf,QAAQ,CAAC0E,KAAK,EAAE,wCAAwC,CAAC;IACpE,OAAOR,6BAA6B,CAClCC,UAAU,EACVC,UAAU,EACVnD,MAAM,EACNoE,OACF,CAAC;EACH;EAEApF,MAAM,CAACc,GAAG,CAACf,QAAQ,CAACgB,KAAK,EAAG,kCAAiCC,MAAO,EAAC,CAAC;EACtE,MAAM,IAAItB,aAAa,CAAE,kCAAiCsB,MAAO,EAAC,CAAC;AACrE,CAAC"}
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import * as z from "zod";
|
2
2
|
import { InvalidQRCodeError } from "./errors";
|
3
3
|
const PresentationParams = z.object({
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
client_id: z.string().nonempty(),
|
5
|
+
request_uri: z.string().url(),
|
6
|
+
request_uri_method: z.enum(["get", "post"]),
|
7
7
|
state: z.string().optional()
|
8
8
|
});
|
9
9
|
|
@@ -11,21 +11,22 @@ const PresentationParams = z.object({
|
|
11
11
|
* The beginning of the presentation flow.
|
12
12
|
* To be implemented accordind to the user touchpoint
|
13
13
|
*
|
14
|
-
* @param params Presentation parameters, depending on the starting
|
14
|
+
* @param params Presentation parameters, depending on the starting touchpoint
|
15
15
|
* @returns The url for the Relying Party to connect with
|
16
16
|
*/
|
17
17
|
|
18
18
|
/**
|
19
|
-
* Start a presentation flow by
|
19
|
+
* Start a presentation flow by validating the required parameters.
|
20
|
+
* Parameters are extracted from a url encoded in a QR code or in a deep link.
|
20
21
|
*
|
21
|
-
* @param params The
|
22
|
+
* @param params The parameters to be validated
|
22
23
|
* @returns The url for the Relying Party to connect with
|
23
|
-
* @throws If the provided
|
24
|
+
* @throws If the provided parameters are not valid
|
24
25
|
*/
|
25
26
|
export const startFlowFromQR = params => {
|
26
27
|
const result = PresentationParams.safeParse({
|
27
28
|
...params,
|
28
|
-
|
29
|
+
request_uri_method: params.request_uri_method ?? "get"
|
29
30
|
});
|
30
31
|
if (result.success) {
|
31
32
|
return result.data;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["z","InvalidQRCodeError","PresentationParams","object","
|
1
|
+
{"version":3,"names":["z","InvalidQRCodeError","PresentationParams","object","client_id","string","nonempty","request_uri","url","request_uri_method","enum","state","optional","startFlowFromQR","params","result","safeParse","success","data","error","message"],"sourceRoot":"../../../../src","sources":["credential/presentation/01-start-flow.ts"],"mappings":"AAAA,OAAO,KAAKA,CAAC,MAAM,KAAK;AACxB,SAASC,kBAAkB,QAAQ,UAAU;AAE7C,MAAMC,kBAAkB,GAAGF,CAAC,CAACG,MAAM,CAAC;EAClCC,SAAS,EAAEJ,CAAC,CAACK,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAChCC,WAAW,EAAEP,CAAC,CAACK,MAAM,CAAC,CAAC,CAACG,GAAG,CAAC,CAAC;EAC7BC,kBAAkB,EAAET,CAAC,CAACU,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;EAC3CC,KAAK,EAAEX,CAAC,CAACK,MAAM,CAAC,CAAC,CAACO,QAAQ,CAAC;AAC7B,CAAC,CAAC;;AAGF;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,eAA0B,GAAIC,MAAM,IAAK;EACpD,MAAMC,MAAM,GAAGb,kBAAkB,CAACc,SAAS,CAAC;IAC1C,GAAGF,MAAM;IACTL,kBAAkB,EAAEK,MAAM,CAACL,kBAAkB,IAAI;EACnD,CAAC,CAAC;EAEF,IAAIM,MAAM,CAACE,OAAO,EAAE;IAClB,OAAOF,MAAM,CAACG,IAAI;EACpB;EAEA,MAAM,IAAIjB,kBAAkB,CAACc,MAAM,CAACI,KAAK,CAACC,OAAO,CAAC;AACpD,CAAC"}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { RelyingPartyResponseError } from "../../utils/errors";
|
1
2
|
import { hasStatusOrThrow } from "../../utils/misc";
|
2
3
|
import { RequestObjectWalletCapabilities } from "./types";
|
3
4
|
/**
|
@@ -33,14 +34,14 @@ export const getRequestObject = async function (requestUri) {
|
|
33
34
|
"Content-Type": "application/x-www-form-urlencoded"
|
34
35
|
},
|
35
36
|
body: formUrlEncodedBody.toString()
|
36
|
-
}).then(hasStatusOrThrow(200)).then(res => res.text());
|
37
|
+
}).then(hasStatusOrThrow(200, RelyingPartyResponseError)).then(res => res.text());
|
37
38
|
return {
|
38
39
|
requestObjectEncodedJwt
|
39
40
|
};
|
40
41
|
}
|
41
42
|
const requestObjectEncodedJwt = await appFetch(requestUri, {
|
42
43
|
method: "GET"
|
43
|
-
}).then(hasStatusOrThrow(200)).then(res => res.text());
|
44
|
+
}).then(hasStatusOrThrow(200, RelyingPartyResponseError)).then(res => res.text());
|
44
45
|
return {
|
45
46
|
requestObjectEncodedJwt
|
46
47
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["hasStatusOrThrow","RequestObjectWalletCapabilities","getRequestObject","requestUri","appFetch","fetch","walletCapabilities","arguments","length","undefined","wallet_metadata","wallet_nonce","parse","formUrlEncodedBody","URLSearchParams","JSON","stringify","requestObjectEncodedJwt","method","headers","body","toString","then","res","text"],"sourceRoot":"../../../../src","sources":["credential/presentation/03-get-request-object.ts"],"mappings":"AAAA,SAASA,gBAAgB,
|
1
|
+
{"version":3,"names":["RelyingPartyResponseError","hasStatusOrThrow","RequestObjectWalletCapabilities","getRequestObject","requestUri","appFetch","fetch","walletCapabilities","arguments","length","undefined","wallet_metadata","wallet_nonce","parse","formUrlEncodedBody","URLSearchParams","JSON","stringify","requestObjectEncodedJwt","method","headers","body","toString","then","res","text"],"sourceRoot":"../../../../src","sources":["credential/presentation/03-get-request-object.ts"],"mappings":"AAAA,SAASA,yBAAyB,QAAQ,oBAAoB;AAC9D,SAASC,gBAAgB,QAAQ,kBAAkB;AACnD,SAASC,+BAA+B,QAAQ,SAAS;AAUzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAkC,GAAG,eAAAA,CAChDC,UAAU,EAEP;EAAA,IADH;IAAEC,QAAQ,GAAGC,KAAK;IAAEC;EAAmB,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAE7C,IAAID,kBAAkB,EAAE;IACtB;IACA,MAAM;MAAEI,eAAe;MAAEC;IAAa,CAAC,GACrCV,+BAA+B,CAACW,KAAK,CAACN,kBAAkB,CAAC;IAE3D,MAAMO,kBAAkB,GAAG,IAAIC,eAAe,CAAC;MAC7CJ,eAAe,EAAEK,IAAI,CAACC,SAAS,CAACN,eAAe,CAAC;MAChD,IAAIC,YAAY,IAAI;QAAEA;MAAa,CAAC;IACtC,CAAC,CAAC;IAEF,MAAMM,uBAAuB,GAAG,MAAMb,QAAQ,CAACD,UAAU,EAAE;MACzDe,MAAM,EAAE,MAAM;MACdC,OAAO,EAAE;QACP,cAAc,EAAE;MAClB,CAAC;MACDC,IAAI,EAAEP,kBAAkB,CAACQ,QAAQ,CAAC;IACpC,CAAC,CAAC,CACCC,IAAI,CAACtB,gBAAgB,CAAC,GAAG,EAAED,yBAAyB,CAAC,CAAC,CACtDuB,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC;IAE5B,OAAO;MACLP;IACF,CAAC;EACH;EAEA,MAAMA,uBAAuB,GAAG,MAAMb,QAAQ,CAACD,UAAU,EAAE;IACzDe,MAAM,EAAE;EACV,CAAC,CAAC,CACCI,IAAI,CAACtB,gBAAgB,CAAC,GAAG,EAAED,yBAAyB,CAAC,CAAC,CACtDuB,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC;EAE5B,OAAO;IACLP;EACF,CAAC;AACH,CAAC"}
|
@@ -1,14 +1,15 @@
|
|
1
1
|
import { decode as decodeJwt, verify } from "@pagopa/io-react-native-jwt";
|
2
|
-
import {
|
2
|
+
import { InvalidRequestObjectError } from "./errors";
|
3
3
|
import { RequestObject } from "./types";
|
4
4
|
import { getJwksFromConfig } from "./04-retrieve-rp-jwks";
|
5
5
|
/**
|
6
|
-
* Function to verify the Request Object's signature
|
6
|
+
* Function to verify the Request Object's validity, from the signature to the required properties.
|
7
7
|
* @param requestObjectEncodedJwt The Request Object in JWT format
|
8
8
|
* @param context.clientId The client ID to verify
|
9
9
|
* @param context.rpConf The Entity Configuration of the Relying Party
|
10
10
|
* @param context.state Optional state
|
11
11
|
* @returns The verified Request Object
|
12
|
+
* @throws {InvalidRequestObjectError} if the Request Object cannot be validated
|
12
13
|
*/
|
13
14
|
export const verifyRequestObject = async (requestObjectEncodedJwt, _ref) => {
|
14
15
|
let {
|
@@ -18,36 +19,70 @@ export const verifyRequestObject = async (requestObjectEncodedJwt, _ref) => {
|
|
18
19
|
state
|
19
20
|
} = _ref;
|
20
21
|
const requestObjectJwt = decodeJwt(requestObjectEncodedJwt);
|
21
|
-
const
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
} = _ref2;
|
30
|
-
return kid === requestObjectJwt.protectedHeader.kid;
|
31
|
-
});
|
32
|
-
if (!pubKey) {
|
33
|
-
throw new UnverifiedEntityError("Request Object signature verification!");
|
22
|
+
const pubKey = getSigPublicKey(rpConf, requestObjectJwt.protectedHeader.kid);
|
23
|
+
try {
|
24
|
+
// Standard claims are verified within `verify`
|
25
|
+
await verify(requestObjectEncodedJwt, pubKey, {
|
26
|
+
issuer: clientId
|
27
|
+
});
|
28
|
+
} catch (_) {
|
29
|
+
throw new InvalidRequestObjectError("The Request Object signature verification failed");
|
34
30
|
}
|
35
|
-
|
36
|
-
// Standard claims are verified within `verify`
|
37
|
-
await verify(requestObjectEncodedJwt, pubKey, {
|
38
|
-
issuer: clientId
|
39
|
-
});
|
40
|
-
const requestObject = RequestObject.parse(requestObjectJwt.payload);
|
31
|
+
const requestObject = validateRequestObjectShape(requestObjectJwt.payload);
|
41
32
|
const isClientIdMatch = clientId === requestObject.client_id && clientId === rpSubject;
|
42
33
|
if (!isClientIdMatch) {
|
43
|
-
throw new
|
34
|
+
throw new InvalidRequestObjectError("Client ID does not match Request Object or Entity Configuration");
|
44
35
|
}
|
45
36
|
const isStateMatch = state && requestObject.state ? state === requestObject.state : true;
|
46
37
|
if (!isStateMatch) {
|
47
|
-
throw new
|
38
|
+
throw new InvalidRequestObjectError("The provided state does not match the Request Object's");
|
48
39
|
}
|
49
40
|
return {
|
50
41
|
requestObject
|
51
42
|
};
|
52
43
|
};
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Validate the shape of the Request Object to ensure all required properties are present and are of the expected type.
|
47
|
+
*
|
48
|
+
* @param payload The Request Object to validate
|
49
|
+
* @returns A valid Request Object
|
50
|
+
* @throws {InvalidRequestObjectError} when the Request Object cannot be parsed
|
51
|
+
*/
|
52
|
+
const validateRequestObjectShape = payload => {
|
53
|
+
const requestObjectParse = RequestObject.safeParse(payload);
|
54
|
+
if (requestObjectParse.success) {
|
55
|
+
return requestObjectParse.data;
|
56
|
+
}
|
57
|
+
throw new InvalidRequestObjectError("The Request Object cannot be parsed successfully", formatFlattenedZodErrors(requestObjectParse.error.flatten()));
|
58
|
+
};
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Get the public key to verify the Request Object's signature from the Relying Party's EC.
|
62
|
+
*
|
63
|
+
* @param rpConf The Relying Party's EC
|
64
|
+
* @param kid The identifier of the key to find
|
65
|
+
* @returns The corresponding public key to verify the signature
|
66
|
+
* @throws {InvalidRequestObjectError} when the key cannot be found
|
67
|
+
*/
|
68
|
+
const getSigPublicKey = (rpConf, kid) => {
|
69
|
+
try {
|
70
|
+
const {
|
71
|
+
keys
|
72
|
+
} = getJwksFromConfig(rpConf);
|
73
|
+
const pubKey = keys.find(k => k.kid === kid);
|
74
|
+
if (!pubKey) throw new Error();
|
75
|
+
return pubKey;
|
76
|
+
} catch (_) {
|
77
|
+
throw new InvalidRequestObjectError(`The public key for signature verification (${kid}) cannot be found in the Entity Configuration`);
|
78
|
+
}
|
79
|
+
};
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Utility to format flattened Zod errors into a simplified string `key1: key1_error, key2: key2_error`
|
83
|
+
*/
|
84
|
+
const formatFlattenedZodErrors = errors => Object.entries(errors.fieldErrors).map(_ref2 => {
|
85
|
+
let [key, error] = _ref2;
|
86
|
+
return `${key}: ${error[0]}`;
|
87
|
+
}).join(", ");
|
53
88
|
//# sourceMappingURL=05-verify-request-object.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["decode","decodeJwt","verify","
|
1
|
+
{"version":3,"names":["decode","decodeJwt","verify","InvalidRequestObjectError","RequestObject","getJwksFromConfig","verifyRequestObject","requestObjectEncodedJwt","_ref","clientId","rpConf","rpSubject","state","requestObjectJwt","pubKey","getSigPublicKey","protectedHeader","kid","issuer","_","requestObject","validateRequestObjectShape","payload","isClientIdMatch","client_id","isStateMatch","requestObjectParse","safeParse","success","data","formatFlattenedZodErrors","error","flatten","keys","find","k","Error","errors","Object","entries","fieldErrors","map","_ref2","key","join"],"sourceRoot":"../../../../src","sources":["credential/presentation/05-verify-request-object.ts"],"mappings":"AAAA,SAASA,MAAM,IAAIC,SAAS,EAAEC,MAAM,QAAQ,6BAA6B;AAEzE,SAASC,yBAAyB,QAAQ,UAAU;AACpD,SAASC,aAAa,QAAQ,SAAS;AACvC,SAASC,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AAE;IAC9B,OAAOF,kBAAkB,CAACG,IAAI;EAChC;EAEA,MAAM,IAAI1B,yBAAyB,CACjC,kDAAkD,EAClD2B,wBAAwB,CAACJ,kBAAkB,CAACK,KAAK,CAACC,OAAO,CAAC,CAAC,CAC7D,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMjB,eAAe,GAAGA,CACtBL,MAA8D,EAC9DO,GAAuB,KACpB;EACH,IAAI;IACF,MAAM;MAAEgB;IAAK,CAAC,GAAG5B,iBAAiB,CAACK,MAAM,CAAC;IAE1C,MAAMI,MAAM,GAAGmB,IAAI,CAACC,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAAClB,GAAG,KAAKA,GAAG,CAAC;IAE9C,IAAI,CAACH,MAAM,EAAE,MAAM,IAAIsB,KAAK,CAAC,CAAC;IAE9B,OAAOtB,MAAM;EACf,CAAC,CAAC,OAAOK,CAAC,EAAE;IACV,MAAM,IAAIhB,yBAAyB,CAChC,8CAA6Cc,GAAI,+CACpD,CAAC;EACH;AACF,CAAC;;AAED;AACA;AACA;AACA,MAAMa,wBAAwB,GAC5BO,MAA+C,IAE/CC,MAAM,CAACC,OAAO,CAACF,MAAM,CAACG,WAAW,CAAC,CAC/BC,GAAG,CAACC,KAAA;EAAA,IAAC,CAACC,GAAG,EAAEZ,KAAK,CAAC,GAAAW,KAAA;EAAA,OAAM,GAAEC,GAAI,KAAIZ,KAAK,CAAC,CAAC,CAAE,EAAC;AAAA,EAAC,CAC5Ca,IAAI,CAAC,IAAI,CAAC"}
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { DcqlQuery, DcqlError
|
1
|
+
import { DcqlQuery, DcqlError } from "dcql";
|
2
2
|
import { isValiError } from "valibot";
|
3
3
|
import { decode, prepareVpToken } from "../../sd-jwt";
|
4
|
-
import { ValidationFailed } from "../../utils/errors";
|
5
4
|
import { createCryptoContextFor } from "../../utils/crypto";
|
5
|
+
import { CredentialsNotFoundError } from "./errors";
|
6
6
|
|
7
7
|
/**
|
8
8
|
* The purpose for the credential request by the RP.
|
@@ -40,9 +40,38 @@ const getDcqlQueryMatches = result => Object.entries(result.credential_matches).
|
|
40
40
|
let [, match] = _ref;
|
41
41
|
return match.success === true;
|
42
42
|
});
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Extract only failed matches from the DCQL query result.
|
46
|
+
*/
|
47
|
+
const getDcqlQueryFailedMatches = result => Object.entries(result.credential_matches).filter(_ref2 => {
|
48
|
+
let [, match] = _ref2;
|
49
|
+
return match.success === false;
|
50
|
+
});
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Extract missing credentials from the DCQL query result.
|
54
|
+
* Note: here we are assuming a failed match is a missing credential,
|
55
|
+
* but there might be other reasons for its failure.
|
56
|
+
*/
|
57
|
+
const extractMissingCredentials = (queryResult, originalQuery) => {
|
58
|
+
return getDcqlQueryFailedMatches(queryResult).map(_ref3 => {
|
59
|
+
var _credential$meta;
|
60
|
+
let [id] = _ref3;
|
61
|
+
const credential = originalQuery.credentials.find(c => c.id === id);
|
62
|
+
if ((credential === null || credential === void 0 ? void 0 : credential.format) !== "vc+sd-jwt") {
|
63
|
+
throw new Error("Unsupported format"); // TODO [SIW-2082]: support MDOC credentials
|
64
|
+
}
|
65
|
+
|
66
|
+
return {
|
67
|
+
id,
|
68
|
+
vctValues: (_credential$meta = credential.meta) === null || _credential$meta === void 0 ? void 0 : _credential$meta.vct_values
|
69
|
+
};
|
70
|
+
});
|
71
|
+
};
|
43
72
|
export const evaluateDcqlQuery = (credentialsSdJwt, query) => {
|
44
|
-
const credentials = credentialsSdJwt.map(
|
45
|
-
let [, credential] =
|
73
|
+
const credentials = credentialsSdJwt.map(_ref4 => {
|
74
|
+
let [, credential] = _ref4;
|
46
75
|
return mapCredentialToObject(credential);
|
47
76
|
});
|
48
77
|
try {
|
@@ -51,16 +80,17 @@ export const evaluateDcqlQuery = (credentialsSdJwt, query) => {
|
|
51
80
|
DcqlQuery.validate(parsedQuery);
|
52
81
|
const queryResult = DcqlQuery.query(parsedQuery, credentials);
|
53
82
|
if (!queryResult.canBeSatisfied) {
|
54
|
-
throw new
|
83
|
+
throw new CredentialsNotFoundError(extractMissingCredentials(queryResult, parsedQuery));
|
55
84
|
}
|
85
|
+
|
56
86
|
// Build an object vct:credentialJwt to map matched credentials to their JWT
|
57
87
|
const credentialsSdJwtByVct = credentials.reduce((acc, c, i) => ({
|
58
88
|
...acc,
|
59
89
|
[c.vct]: credentialsSdJwt[i]
|
60
90
|
}), {});
|
61
|
-
return getDcqlQueryMatches(queryResult).map(
|
91
|
+
return getDcqlQueryMatches(queryResult).map(_ref5 => {
|
62
92
|
var _queryResult$credenti;
|
63
|
-
let [id, match] =
|
93
|
+
let [id, match] = _ref5;
|
64
94
|
if (match.output.credential_format !== "vc+sd-jwt") {
|
65
95
|
throw new Error("Unsupported format"); // TODO [SIW-2082]: support MDOC credentials
|
66
96
|
}
|
@@ -95,19 +125,16 @@ export const evaluateDcqlQuery = (credentialsSdJwt, query) => {
|
|
95
125
|
};
|
96
126
|
});
|
97
127
|
} catch (error) {
|
98
|
-
// Invalid DCQL query structure
|
128
|
+
// Invalid DCQL query structure. Remap to `DcqlError` for consistency.
|
99
129
|
if (isValiError(error)) {
|
100
|
-
throw new
|
101
|
-
message: "
|
102
|
-
|
130
|
+
throw new DcqlError({
|
131
|
+
message: "Failed to parse the provided DCQL query",
|
132
|
+
code: "PARSE_ERROR",
|
133
|
+
cause: error.issues
|
103
134
|
});
|
104
135
|
}
|
105
|
-
|
106
|
-
|
107
|
-
}
|
108
|
-
if (error instanceof DcqlCredentialSetError) {
|
109
|
-
// TODO [SIW-2110]: handle missing credentials or let the error propagate
|
110
|
-
}
|
136
|
+
|
137
|
+
// Let other errors propagate so they can be caught with `err instanceof DcqlError`
|
111
138
|
throw error;
|
112
139
|
}
|
113
140
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["DcqlQuery","DcqlError","
|
1
|
+
{"version":3,"names":["DcqlQuery","DcqlError","isValiError","decode","prepareVpToken","createCryptoContextFor","CredentialsNotFoundError","mapCredentialToObject","jwt","sdJwt","disclosures","credentialFormat","header","typ","Error","vct","payload","credential_format","claims","reduce","acc","disclosure","decoded","getDcqlQueryMatches","result","Object","entries","credential_matches","filter","_ref","match","success","getDcqlQueryFailedMatches","_ref2","extractMissingCredentials","queryResult","originalQuery","map","_ref3","_credential$meta","id","credential","credentials","find","c","format","vctValues","meta","vct_values","evaluateDcqlQuery","credentialsSdJwt","query","_ref4","parsedQuery","parse","validate","canBeSatisfied","credentialsSdJwtByVct","i","_ref5","_queryResult$credenti","output","purposes","credential_sets","set","_set$matching_options","matching_options","flat","includes","credentialSet","_credentialSet$purpos","description","purpose","toString","required","Boolean","keyTag","requiredDisclosures","values","error","message","code","cause","issues","prepareRemotePresentations","nonce","clientId","Promise","all","item","vp_token","requestedClaims","credentialId","vpToken"],"sourceRoot":"../../../../src","sources":["credential/presentation/07-evaluate-dcql-query.ts"],"mappings":"AAAA,SAASA,SAAS,EAAEC,SAAS,QAAyB,MAAM;AAC5D,SAASC,WAAW,QAAQ,SAAS;AACrC,SAASC,MAAM,EAAEC,cAAc,QAAQ,cAAc;AAErD,SAASC,sBAAsB,QAAQ,oBAAoB;AAE3D,SAASC,wBAAwB,QAA6B,UAAU;;AAExE;AACA;AACA;;AAuCA;AACA;AACA;AACA;AACA,MAAMC,qBAAqB,GAAIC,GAAW,IAAK;EAC7C,MAAM;IAAEC,KAAK;IAAEC;EAAY,CAAC,GAAGP,MAAM,CAACK,GAAG,CAAC;EAC1C,MAAMG,gBAAgB,GAAGF,KAAK,CAACG,MAAM,CAACC,GAAG;;EAEzC;EACA,IAAIF,gBAAgB,KAAK,WAAW,EAAE;IACpC,MAAM,IAAIG,KAAK,CAAE,kCAAiCH,gBAAiB,EAAC,CAAC;EACvE;EAEA,OAAO;IACLI,GAAG,EAAEN,KAAK,CAACO,OAAO,CAACD,GAAG;IACtBE,iBAAiB,EAAEN,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;IACJ;;IAEA;IACA,MAAMJ,KAAK;EACb;AACF,CAAC;AAED,OAAO,MAAMK,0BAAsD,GAAG,MAAAA,CACpE1C,WAAW,EACX2C,KAAK,EACLC,QAAQ,KACL;EACH,OAAOC,OAAO,CAACC,GAAG,CAChB9C,WAAW,CAACL,GAAG,CAAC,MAAOoD,IAAI,IAAK;IAC9B,MAAM;MAAEC;IAAS,CAAC,GAAG,MAAMtF,cAAc,CAACiF,KAAK,EAAEC,QAAQ,EAAE,CACzDG,IAAI,CAAChD,UAAU,EACfgD,IAAI,CAACE,eAAe,EACpBtF,sBAAsB,CAACoF,IAAI,CAACb,MAAM,CAAC,CACpC,CAAC;IAEF,OAAO;MACLgB,YAAY,EAAEH,IAAI,CAACjD,EAAE;MACrBmD,eAAe,EAAEF,IAAI,CAACE,eAAe;MACrCE,OAAO,EAAEH,QAAQ;MACjB7C,MAAM,EAAE;IACV,CAAC;EACH,CAAC,CACH,CAAC;AACH,CAAC"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { decode, prepareVpToken } from "../../sd-jwt";
|
2
2
|
import { createCryptoContextFor } from "../../utils/crypto";
|
3
3
|
import { JSONPath } from "jsonpath-plus";
|
4
|
-
import {
|
4
|
+
import { CredentialsNotFoundError, MissingDataError } from "./errors";
|
5
5
|
import Ajv from "ajv";
|
6
6
|
const ajv = new Ajv({
|
7
7
|
allErrors: true
|
@@ -194,7 +194,10 @@ export const findCredentialSdJwt = (inputDescriptor, decodedSdJwtCredentials) =>
|
|
194
194
|
continue;
|
195
195
|
}
|
196
196
|
}
|
197
|
-
throw new
|
197
|
+
throw new CredentialsNotFoundError([{
|
198
|
+
id: "",
|
199
|
+
reason: "None of the vc+sd-jwt credentials satisfy the requirements."
|
200
|
+
}]);
|
198
201
|
};
|
199
202
|
|
200
203
|
/**
|
@@ -230,7 +233,10 @@ export const evaluateInputDescriptors = async (inputDescriptors, credentialsSdJw
|
|
230
233
|
var _descriptor$format;
|
231
234
|
if ((_descriptor$format = descriptor.format) !== null && _descriptor$format !== void 0 && _descriptor$format["vc+sd-jwt"]) {
|
232
235
|
if (!decodedSdJwtCredentials.length) {
|
233
|
-
throw new
|
236
|
+
throw new CredentialsNotFoundError([{
|
237
|
+
id: descriptor.id,
|
238
|
+
reason: "vc+sd-jwt credential is not supported."
|
239
|
+
}]);
|
234
240
|
}
|
235
241
|
const {
|
236
242
|
matchedEvaluation,
|
@@ -244,7 +250,10 @@ export const evaluateInputDescriptors = async (inputDescriptors, credentialsSdJw
|
|
244
250
|
keyTag: matchedKeyTag
|
245
251
|
};
|
246
252
|
}
|
247
|
-
throw new
|
253
|
+
throw new CredentialsNotFoundError([{
|
254
|
+
id: descriptor.id,
|
255
|
+
reason: `${descriptor.format} format is not supported.`
|
256
|
+
}]);
|
248
257
|
}));
|
249
258
|
};
|
250
259
|
|
@@ -279,7 +288,10 @@ export const prepareLegacyRemotePresentations = async (credentialAndDescriptors,
|
|
279
288
|
format: "vc+sd-jwt"
|
280
289
|
};
|
281
290
|
}
|
282
|
-
throw new
|
291
|
+
throw new CredentialsNotFoundError([{
|
292
|
+
id: descriptor.id,
|
293
|
+
reason: `${descriptor.format} format is not supported.`
|
294
|
+
}]);
|
283
295
|
}));
|
284
296
|
};
|
285
297
|
//# sourceMappingURL=07-evaluate-input-descriptor.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["decode","prepareVpToken","createCryptoContextFor","JSONPath","
|
1
|
+
{"version":3,"names":["decode","prepareVpToken","createCryptoContextFor","JSONPath","CredentialsNotFoundError","MissingDataError","Ajv","ajv","allErrors","INDEX_CLAIM_NAME","mapDisclosuresToObject","disclosures","reduce","obj","_ref","decoded","claimName","claimValue","findMatchedClaim","paths","payload","matchedPath","matchedValue","some","singlePath","result","path","json","length","error","extractClaimName","regex","match","Error","evaluateInputDescriptorForSdJwt4VC","inputDescriptor","payloadCredential","_inputDescriptor$cons","constraints","fields","requiredDisclosures","optionalDisclosures","unrequestedDisclosures","requiredClaimNames","optionalClaimNames","disclosuresAsPayload","allFieldsValid","every","field","optional","push","filter","validateSchema","compile","disclosure","includes","isNotLimitDisclosure","limit_disclosure","findCredentialSdJwt","decodedSdJwtCredentials","keyTag","credential","sdJwt","evaluatedDisclosure","matchedEvaluation","matchedKeyTag","matchedCredential","id","reason","evaluateInputDescriptors","inputDescriptors","credentialsSdJwt","map","_ref2","Promise","all","descriptor","_descriptor$format","format","prepareLegacyRemotePresentations","credentialAndDescriptors","nonce","client_id","item","_descriptor$format2","vp_token","requestedClaims","vpToken"],"sourceRoot":"../../../../src","sources":["credential/presentation/07-evaluate-input-descriptor.ts"],"mappings":"AAEA,SAASA,MAAM,EAAEC,cAAc,QAAQ,cAAc;AACrD,SAASC,sBAAsB,QAAQ,oBAAoB;AAC3D,SAASC,QAAQ,QAAQ,eAAe;AACxC,SAASC,wBAAwB,EAAEC,gBAAgB,QAAQ,UAAU;AACrE,OAAOC,GAAG,MAAM,KAAK;AAErB,MAAMC,GAAG,GAAG,IAAID,GAAG,CAAC;EAAEE,SAAS,EAAE;AAAK,CAAC,CAAC;AACxC,MAAMC,gBAAgB,GAAG,CAAC;;AA0B1B;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA,MAAMC,sBAAsB,GAC1BC,WAAoC,IACR;EAC5B,OAAOA,WAAW,CAACC,MAAM,CACvB,CAACC,GAAG,EAAAC,IAAA,KAAkB;IAAA,IAAhB;MAAEC;IAAQ,CAAC,GAAAD,IAAA;IACf,MAAM,GAAGE,SAAS,EAAEC,UAAU,CAAC,GAAGF,OAAO;IACzCF,GAAG,CAACG,SAAS,CAAC,GAAGC,UAAU;IAC3B,OAAOJ,GAAG;EACZ,CAAC,EACD,CAAC,CACH,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,gBAAgB,GAAGA,CACvBC,KAAe,EACfC,OAAY,KACW;EACvB,IAAIC,WAAW;EACf,IAAIC,YAAY;EAChBH,KAAK,CAACI,IAAI,CAAEC,UA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