@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
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["_errors","require","_misc","_types","getRequestObject","requestUri","appFetch","fetch","walletCapabilities","arguments","length","undefined","wallet_metadata","wallet_nonce","RequestObjectWalletCapabilities","parse","formUrlEncodedBody","URLSearchParams","JSON","stringify","requestObjectEncodedJwt","method","headers","body","toString","then","hasStatusOrThrow","RelyingPartyResponseError","res","text","exports"],"sourceRoot":"../../../../src","sources":["credential/presentation/03-get-request-object.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,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,GACrCC,sCAA+B,CAACC,KAAK,CAACP,kBAAkB,CAAC;IAE3D,MAAMQ,kBAAkB,GAAG,IAAIC,eAAe,CAAC;MAC7CL,eAAe,EAAEM,IAAI,CAACC,SAAS,CAACP,eAAe,CAAC;MAChD,IAAIC,YAAY,IAAI;QAAEA;MAAa,CAAC;IACtC,CAAC,CAAC;IAEF,MAAMO,uBAAuB,GAAG,MAAMd,QAAQ,CAACD,UAAU,EAAE;MACzDgB,MAAM,EAAE,MAAM;MACdC,OAAO,EAAE;QACP,cAAc,EAAE;MAClB,CAAC;MACDC,IAAI,EAAEP,kBAAkB,CAACQ,QAAQ,CAAC;IACpC,CAAC,CAAC,CACCC,IAAI,CAAC,IAAAC,sBAAgB,EAAC,GAAG,EAAEC,iCAAyB,CAAC,CAAC,CACtDF,IAAI,CAAEG,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC;IAE5B,OAAO;MACLT;IACF,CAAC;EACH;EAEA,MAAMA,uBAAuB,GAAG,MAAMd,QAAQ,CAACD,UAAU,EAAE;IACzDgB,MAAM,EAAE;EACV,CAAC,CAAC,CACCI,IAAI,CAAC,IAAAC,sBAAgB,EAAC,GAAG,EAAEC,iCAAyB,CAAC,CAAC,CACtDF,IAAI,CAAEG,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC;EAE5B,OAAO;IACLT;EACF,CAAC;AACH,CAAC;AAACU,OAAA,CAAA1B,gBAAA,GAAAA,gBAAA"}
|
@@ -9,12 +9,13 @@ var _errors = require("./errors");
|
|
9
9
|
var _types = require("./types");
|
10
10
|
var _retrieveRpJwks = require("./04-retrieve-rp-jwks");
|
11
11
|
/**
|
12
|
-
* Function to verify the Request Object's signature
|
12
|
+
* Function to verify the Request Object's validity, from the signature to the required properties.
|
13
13
|
* @param requestObjectEncodedJwt The Request Object in JWT format
|
14
14
|
* @param context.clientId The client ID to verify
|
15
15
|
* @param context.rpConf The Entity Configuration of the Relying Party
|
16
16
|
* @param context.state Optional state
|
17
17
|
* @returns The verified Request Object
|
18
|
+
* @throws {InvalidRequestObjectError} if the Request Object cannot be validated
|
18
19
|
*/
|
19
20
|
const verifyRequestObject = async (requestObjectEncodedJwt, _ref) => {
|
20
21
|
let {
|
@@ -24,37 +25,71 @@ const verifyRequestObject = async (requestObjectEncodedJwt, _ref) => {
|
|
24
25
|
state
|
25
26
|
} = _ref;
|
26
27
|
const requestObjectJwt = (0, _ioReactNativeJwt.decode)(requestObjectEncodedJwt);
|
27
|
-
const
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
} = _ref2;
|
36
|
-
return kid === requestObjectJwt.protectedHeader.kid;
|
37
|
-
});
|
38
|
-
if (!pubKey) {
|
39
|
-
throw new _errors.UnverifiedEntityError("Request Object signature verification!");
|
28
|
+
const pubKey = getSigPublicKey(rpConf, requestObjectJwt.protectedHeader.kid);
|
29
|
+
try {
|
30
|
+
// Standard claims are verified within `verify`
|
31
|
+
await (0, _ioReactNativeJwt.verify)(requestObjectEncodedJwt, pubKey, {
|
32
|
+
issuer: clientId
|
33
|
+
});
|
34
|
+
} catch (_) {
|
35
|
+
throw new _errors.InvalidRequestObjectError("The Request Object signature verification failed");
|
40
36
|
}
|
41
|
-
|
42
|
-
// Standard claims are verified within `verify`
|
43
|
-
await (0, _ioReactNativeJwt.verify)(requestObjectEncodedJwt, pubKey, {
|
44
|
-
issuer: clientId
|
45
|
-
});
|
46
|
-
const requestObject = _types.RequestObject.parse(requestObjectJwt.payload);
|
37
|
+
const requestObject = validateRequestObjectShape(requestObjectJwt.payload);
|
47
38
|
const isClientIdMatch = clientId === requestObject.client_id && clientId === rpSubject;
|
48
39
|
if (!isClientIdMatch) {
|
49
|
-
throw new _errors.
|
40
|
+
throw new _errors.InvalidRequestObjectError("Client ID does not match Request Object or Entity Configuration");
|
50
41
|
}
|
51
42
|
const isStateMatch = state && requestObject.state ? state === requestObject.state : true;
|
52
43
|
if (!isStateMatch) {
|
53
|
-
throw new _errors.
|
44
|
+
throw new _errors.InvalidRequestObjectError("The provided state does not match the Request Object's");
|
54
45
|
}
|
55
46
|
return {
|
56
47
|
requestObject
|
57
48
|
};
|
58
49
|
};
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Validate the shape of the Request Object to ensure all required properties are present and are of the expected type.
|
53
|
+
*
|
54
|
+
* @param payload The Request Object to validate
|
55
|
+
* @returns A valid Request Object
|
56
|
+
* @throws {InvalidRequestObjectError} when the Request Object cannot be parsed
|
57
|
+
*/
|
59
58
|
exports.verifyRequestObject = verifyRequestObject;
|
59
|
+
const validateRequestObjectShape = payload => {
|
60
|
+
const requestObjectParse = _types.RequestObject.safeParse(payload);
|
61
|
+
if (requestObjectParse.success) {
|
62
|
+
return requestObjectParse.data;
|
63
|
+
}
|
64
|
+
throw new _errors.InvalidRequestObjectError("The Request Object cannot be parsed successfully", formatFlattenedZodErrors(requestObjectParse.error.flatten()));
|
65
|
+
};
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Get the public key to verify the Request Object's signature from the Relying Party's EC.
|
69
|
+
*
|
70
|
+
* @param rpConf The Relying Party's EC
|
71
|
+
* @param kid The identifier of the key to find
|
72
|
+
* @returns The corresponding public key to verify the signature
|
73
|
+
* @throws {InvalidRequestObjectError} when the key cannot be found
|
74
|
+
*/
|
75
|
+
const getSigPublicKey = (rpConf, kid) => {
|
76
|
+
try {
|
77
|
+
const {
|
78
|
+
keys
|
79
|
+
} = (0, _retrieveRpJwks.getJwksFromConfig)(rpConf);
|
80
|
+
const pubKey = keys.find(k => k.kid === kid);
|
81
|
+
if (!pubKey) throw new Error();
|
82
|
+
return pubKey;
|
83
|
+
} catch (_) {
|
84
|
+
throw new _errors.InvalidRequestObjectError(`The public key for signature verification (${kid}) cannot be found in the Entity Configuration`);
|
85
|
+
}
|
86
|
+
};
|
87
|
+
|
88
|
+
/**
|
89
|
+
* Utility to format flattened Zod errors into a simplified string `key1: key1_error, key2: key2_error`
|
90
|
+
*/
|
91
|
+
const formatFlattenedZodErrors = errors => Object.entries(errors.fieldErrors).map(_ref2 => {
|
92
|
+
let [key, error] = _ref2;
|
93
|
+
return `${key}: ${error[0]}`;
|
94
|
+
}).join(", ");
|
60
95
|
//# sourceMappingURL=05-verify-request-object.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_ioReactNativeJwt","require","_errors","_types","_retrieveRpJwks","verifyRequestObject","requestObjectEncodedJwt","_ref","clientId","rpConf","rpSubject","state","requestObjectJwt","decodeJwt","
|
1
|
+
{"version":3,"names":["_ioReactNativeJwt","require","_errors","_types","_retrieveRpJwks","verifyRequestObject","requestObjectEncodedJwt","_ref","clientId","rpConf","rpSubject","state","requestObjectJwt","decodeJwt","pubKey","getSigPublicKey","protectedHeader","kid","verify","issuer","_","InvalidRequestObjectError","requestObject","validateRequestObjectShape","payload","isClientIdMatch","client_id","isStateMatch","exports","requestObjectParse","RequestObject","safeParse","success","data","formatFlattenedZodErrors","error","flatten","keys","getJwksFromConfig","find","k","Error","errors","Object","entries","fieldErrors","map","_ref2","key","join"],"sourceRoot":"../../../../src","sources":["credential/presentation/05-verify-request-object.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMI,mBAAwC,GAAG,MAAAA,CACtDC,uBAAuB,EAAAC,IAAA,KAEpB;EAAA,IADH;IAAEC,QAAQ;IAAEC,MAAM;IAAEC,SAAS;IAAEC;EAAM,CAAC,GAAAJ,IAAA;EAEtC,MAAMK,gBAAgB,GAAG,IAAAC,wBAAS,EAACP,uBAAuB,CAAC;EAE3D,MAAMQ,MAAM,GAAGC,eAAe,CAACN,MAAM,EAAEG,gBAAgB,CAACI,eAAe,CAACC,GAAG,CAAC;EAE5E,IAAI;IACF;IACA,MAAM,IAAAC,wBAAM,EAACZ,uBAAuB,EAAEQ,MAAM,EAAE;MAAEK,MAAM,EAAEX;IAAS,CAAC,CAAC;EACrE,CAAC,CAAC,OAAOY,CAAC,EAAE;IACV,MAAM,IAAIC,iCAAyB,CACjC,kDACF,CAAC;EACH;EAEA,MAAMC,aAAa,GAAGC,0BAA0B,CAACX,gBAAgB,CAACY,OAAO,CAAC;EAE1E,MAAMC,eA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AyB,CAChC,8CAA6CJ,GAAI,+CACpD,CAAC;EACH;AACF,CAAC;;AAED;AACA;AACA;AACA,MAAMiB,wBAAwB,GAC5BQ,MAA+C,IAE/CC,MAAM,CAACC,OAAO,CAACF,MAAM,CAACG,WAAW,CAAC,CAC/BC,GAAG,CAACC,KAAA;EAAA,IAAC,CAACC,GAAG,EAAEb,KAAK,CAAC,GAAAY,KAAA;EAAA,OAAM,GAAEC,GAAI,KAAIb,KAAK,CAAC,CAAC,CAAE,EAAC;AAAA,EAAC,CAC5Cc,IAAI,CAAC,IAAI,CAAC"}
|
@@ -7,8 +7,8 @@ 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 _errors = require("../../utils/errors");
|
11
10
|
var _crypto = require("../../utils/crypto");
|
11
|
+
var _errors = require("./errors");
|
12
12
|
/**
|
13
13
|
* The purpose for the credential request by the RP.
|
14
14
|
*/
|
@@ -45,9 +45,38 @@ const getDcqlQueryMatches = result => Object.entries(result.credential_matches).
|
|
45
45
|
let [, match] = _ref;
|
46
46
|
return match.success === true;
|
47
47
|
});
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Extract only failed matches from the DCQL query result.
|
51
|
+
*/
|
52
|
+
const getDcqlQueryFailedMatches = result => Object.entries(result.credential_matches).filter(_ref2 => {
|
53
|
+
let [, match] = _ref2;
|
54
|
+
return match.success === false;
|
55
|
+
});
|
56
|
+
|
57
|
+
/**
|
58
|
+
* Extract missing credentials from the DCQL query result.
|
59
|
+
* Note: here we are assuming a failed match is a missing credential,
|
60
|
+
* but there might be other reasons for its failure.
|
61
|
+
*/
|
62
|
+
const extractMissingCredentials = (queryResult, originalQuery) => {
|
63
|
+
return getDcqlQueryFailedMatches(queryResult).map(_ref3 => {
|
64
|
+
var _credential$meta;
|
65
|
+
let [id] = _ref3;
|
66
|
+
const credential = originalQuery.credentials.find(c => c.id === id);
|
67
|
+
if ((credential === null || credential === void 0 ? void 0 : credential.format) !== "vc+sd-jwt") {
|
68
|
+
throw new Error("Unsupported format"); // TODO [SIW-2082]: support MDOC credentials
|
69
|
+
}
|
70
|
+
|
71
|
+
return {
|
72
|
+
id,
|
73
|
+
vctValues: (_credential$meta = credential.meta) === null || _credential$meta === void 0 ? void 0 : _credential$meta.vct_values
|
74
|
+
};
|
75
|
+
});
|
76
|
+
};
|
48
77
|
const evaluateDcqlQuery = (credentialsSdJwt, query) => {
|
49
|
-
const credentials = credentialsSdJwt.map(
|
50
|
-
let [, credential] =
|
78
|
+
const credentials = credentialsSdJwt.map(_ref4 => {
|
79
|
+
let [, credential] = _ref4;
|
51
80
|
return mapCredentialToObject(credential);
|
52
81
|
});
|
53
82
|
try {
|
@@ -56,16 +85,17 @@ const evaluateDcqlQuery = (credentialsSdJwt, query) => {
|
|
56
85
|
_dcql.DcqlQuery.validate(parsedQuery);
|
57
86
|
const queryResult = _dcql.DcqlQuery.query(parsedQuery, credentials);
|
58
87
|
if (!queryResult.canBeSatisfied) {
|
59
|
-
throw new
|
88
|
+
throw new _errors.CredentialsNotFoundError(extractMissingCredentials(queryResult, parsedQuery));
|
60
89
|
}
|
90
|
+
|
61
91
|
// Build an object vct:credentialJwt to map matched credentials to their JWT
|
62
92
|
const credentialsSdJwtByVct = credentials.reduce((acc, c, i) => ({
|
63
93
|
...acc,
|
64
94
|
[c.vct]: credentialsSdJwt[i]
|
65
95
|
}), {});
|
66
|
-
return getDcqlQueryMatches(queryResult).map(
|
96
|
+
return getDcqlQueryMatches(queryResult).map(_ref5 => {
|
67
97
|
var _queryResult$credenti;
|
68
|
-
let [id, match] =
|
98
|
+
let [id, match] = _ref5;
|
69
99
|
if (match.output.credential_format !== "vc+sd-jwt") {
|
70
100
|
throw new Error("Unsupported format"); // TODO [SIW-2082]: support MDOC credentials
|
71
101
|
}
|
@@ -100,19 +130,16 @@ const evaluateDcqlQuery = (credentialsSdJwt, query) => {
|
|
100
130
|
};
|
101
131
|
});
|
102
132
|
} catch (error) {
|
103
|
-
// Invalid DCQL query structure
|
133
|
+
// Invalid DCQL query structure. Remap to `DcqlError` for consistency.
|
104
134
|
if ((0, _valibot.isValiError)(error)) {
|
105
|
-
throw new
|
106
|
-
message: "
|
107
|
-
|
135
|
+
throw new _dcql.DcqlError({
|
136
|
+
message: "Failed to parse the provided DCQL query",
|
137
|
+
code: "PARSE_ERROR",
|
138
|
+
cause: error.issues
|
108
139
|
});
|
109
140
|
}
|
110
|
-
|
111
|
-
|
112
|
-
}
|
113
|
-
if (error instanceof _dcql.DcqlCredentialSetError) {
|
114
|
-
// TODO [SIW-2110]: handle missing credentials or let the error propagate
|
115
|
-
}
|
141
|
+
|
142
|
+
// Let other errors propagate so they can be caught with `err instanceof DcqlError`
|
116
143
|
throw error;
|
117
144
|
}
|
118
145
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_dcql","require","_valibot","_sdJwt","
|
1
|
+
{"version":3,"names":["_dcql","require","_valibot","_sdJwt","_crypto","_errors","mapCredentialToObject","jwt","sdJwt","disclosures","decode","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","DcqlQuery","parse","validate","canBeSatisfied","CredentialsNotFoundError","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","isValiError","DcqlError","message","code","cause","issues","exports","prepareRemotePresentations","nonce","clientId","Promise","all","item","vp_token","prepareVpToken","requestedClaims","createCryptoContextFor","credentialId","vpToken"],"sourceRoot":"../../../../src","sources":["credential/presentation/07-evaluate-dcql-query.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AAEA;AACA;AACA;;AAuCA;AACA;AACA;AACA;AACA,MAAMK,qBAAqB,GAAIC,GAAW,IAAK;EAC7C,MAAM;IAAEC,KAAK;IAAEC;EAAY,CAAC,GAAG,IAAAC,aAAM,EAACH,GAAG,CAAC;EAC1C,MAAMI,gBAAgB,GAAGH,KAAK,CAACI,MAAM,CAACC,GAAG;;EAEzC;EACA,IAAIF,gBAAgB,KAAK,WAAW,EAAE;IACpC,MAAM,IAAIG,KAAK,CAAE,kCAAiCH,gBAAiB,EAAC,CAAC;EACvE;EAEA,OAAO;IACLI,GAAG,EAAEP,KAAK,CAACQ,OAAO,CAACD,GAAG;IACtBE,iBAAiB,EAAEN,gBAAgB;IACnCO,MAAM,EAAET,WAAW,CAACU,MAAM,CACxB,CAACC,GAAG,EAAEC,UAAU,MAAM;MACpB,GAAGD,GAAG;MACN,CAACC,UAAU,CAACC,OAAO,CAAC,CAAC,CAAC,GAAGD,UAAU,CAACC;IACtC,CAAC,CAAC,EACF,CAAC,CACH;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA,MAAMC,mBAAmB,GAAIC,MAAuB,IAClDC,MAAM,CAACC,OAAO,CAACF,MAAM,CAACG,kBAAkB,CAAC,CAACC,MAAM,CAC9CC,IAAA;EAAA,IAAC,GAAGC,KAAK,CAAC,GAAAD,IAAA;EAAA,OAAKC,KAAK,CAACC,OAAO,KAAK,IAAI;AAAA,CACvC,CAAiC;;AAEnC;AACA;AACA;AACA,MAAMC,yBAAyB,GAAIR,MAAuB,IACxDC,MAAM,CAACC,OAAO,CAACF,MAAM,CAACG,kBAAkB,CAAC,CA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AAM,EAAE;IACV,CAAC;EACH,CAAC,CACH,CAAC;AACH,CAAC;AAAC2C,OAAA,CAAAC,0BAAA,GAAAA,0BAAA"}
|
@@ -202,7 +202,10 @@ const findCredentialSdJwt = (inputDescriptor, decodedSdJwtCredentials) => {
|
|
202
202
|
continue;
|
203
203
|
}
|
204
204
|
}
|
205
|
-
throw new _errors.
|
205
|
+
throw new _errors.CredentialsNotFoundError([{
|
206
|
+
id: "",
|
207
|
+
reason: "None of the vc+sd-jwt credentials satisfy the requirements."
|
208
|
+
}]);
|
206
209
|
};
|
207
210
|
|
208
211
|
/**
|
@@ -239,7 +242,10 @@ const evaluateInputDescriptors = async (inputDescriptors, credentialsSdJwt) => {
|
|
239
242
|
var _descriptor$format;
|
240
243
|
if ((_descriptor$format = descriptor.format) !== null && _descriptor$format !== void 0 && _descriptor$format["vc+sd-jwt"]) {
|
241
244
|
if (!decodedSdJwtCredentials.length) {
|
242
|
-
throw new _errors.
|
245
|
+
throw new _errors.CredentialsNotFoundError([{
|
246
|
+
id: descriptor.id,
|
247
|
+
reason: "vc+sd-jwt credential is not supported."
|
248
|
+
}]);
|
243
249
|
}
|
244
250
|
const {
|
245
251
|
matchedEvaluation,
|
@@ -253,7 +259,10 @@ const evaluateInputDescriptors = async (inputDescriptors, credentialsSdJwt) => {
|
|
253
259
|
keyTag: matchedKeyTag
|
254
260
|
};
|
255
261
|
}
|
256
|
-
throw new _errors.
|
262
|
+
throw new _errors.CredentialsNotFoundError([{
|
263
|
+
id: descriptor.id,
|
264
|
+
reason: `${descriptor.format} format is not supported.`
|
265
|
+
}]);
|
257
266
|
}));
|
258
267
|
};
|
259
268
|
|
@@ -289,7 +298,10 @@ const prepareLegacyRemotePresentations = async (credentialAndDescriptors, nonce,
|
|
289
298
|
format: "vc+sd-jwt"
|
290
299
|
};
|
291
300
|
}
|
292
|
-
throw new _errors.
|
301
|
+
throw new _errors.CredentialsNotFoundError([{
|
302
|
+
id: descriptor.id,
|
303
|
+
reason: `${descriptor.format} format is not supported.`
|
304
|
+
}]);
|
293
305
|
}));
|
294
306
|
};
|
295
307
|
exports.prepareLegacyRemotePresentations = prepareLegacyRemotePresentations;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_sdJwt","require","_crypto","_jsonpathPlus","_errors","_ajv","_interopRequireDefault","obj","__esModule","default","ajv","Ajv","allErrors","INDEX_CLAIM_NAME","mapDisclosuresToObject","disclosures","reduce","_ref","decoded","claimName","claimValue","findMatchedClaim","paths","payload","matchedPath","matchedValue","some","singlePath","result","JSONPath","path","json","length","error","MissingDataError","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","exports","findCredentialSdJwt","decodedSdJwtCredentials","keyTag","credential","sdJwt","evaluatedDisclosure","matchedEvaluation","matchedKeyTag","matchedCredential","
|
1
|
+
{"version":3,"names":["_sdJwt","require","_crypto","_jsonpathPlus","_errors","_ajv","_interopRequireDefault","obj","__esModule","default","ajv","Ajv","allErrors","INDEX_CLAIM_NAME","mapDisclosuresToObject","disclosures","reduce","_ref","decoded","claimName","claimValue","findMatchedClaim","paths","payload","matchedPath","matchedValue","some","singlePath","result","JSONPath","path","json","length","error","MissingDataError","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","exports","findCredentialSdJwt","decodedSdJwtCredentials","keyTag","credential","sdJwt","evaluatedDisclosure","matchedEvaluation","matchedKeyTag","matchedCredential","CredentialsNotFoundError","id","reason","evaluateInputDescriptors","inputDescriptors","credentialsSdJwt","map","_ref2","decode","Promise","all","descriptor","_descriptor$format","format","prepareLegacyRemotePresentations","credentialAndDescriptors","nonce","client_id","item","_descriptor$format2","vp_token","prepareVpToken","requestedClaims","createCryptoContextFor","vpToken"],"sourceRoot":"../../../../src","sources":["credential/presentation/07-evaluate-input-descriptor.ts"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAC,sBAAA,CAAAL,OAAA;AAAsB,SAAAK,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEtB,MAAMG,GAAG,GAAG,IAAIC,YAAG,CAAC;EAAEC,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,CAACT,GAAG,EAAAU,IAAA,KAAkB;IAAA,IAAhB;MAAEC;IAAQ,CAAC,GAAAD,IAAA;IACf,MAAM,GAAGE,SAAS,EAAEC,UAAU,CAAC,GAAGF,OAAO;IACzCX,GAAG,CAACY,SAAS,CAAC,GAAGC,UAAU;IAC3B,OAAOb,GAAG;EACZ,CAAC,EACD,CAAC,CACH,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMc,gBAAgB,GAAGA,CACvBC,KAAe,EACfC,OAAY,KACW;EACvB,IAAIC,WAAW;EACf,IAAIC,YAAY;EAChBH,KAAK,CAACI,IAAI,CAAEC,UAAU,IAAK;IACzB,IAAI;MACF,MAAMC,MAAM,GAAG,IAAAC,s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;EACJ,CAAC,CACH,CAAC;AACH,CAAC;AAACvB,OAAA,CAAAwB,gCAAA,GAAAA,gCAAA"}
|
@@ -3,13 +3,14 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.sendLegacyAuthorizationResponse = exports.sendAuthorizationResponse = exports.choosePublicKeyToEncrypt = exports.buildDirectPostJwtBody = exports.AuthorizationResponse = void 0;
|
6
|
+
exports.sendLegacyAuthorizationResponse = exports.sendAuthorizationResponse = exports.sendAuthorizationErrorResponse = exports.choosePublicKeyToEncrypt = exports.buildDirectPostJwtBody = exports.buildDirectPostBody = exports.AuthorizationResponse = void 0;
|
7
7
|
var _ioReactNativeJwt = require("@pagopa/io-react-native-jwt");
|
8
8
|
var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
|
9
9
|
var _retrieveRpJwks = require("./04-retrieve-rp-jwks");
|
10
10
|
var _errors = require("./errors");
|
11
11
|
var _misc = require("../../utils/misc");
|
12
12
|
var z = _interopRequireWildcard(require("zod"));
|
13
|
+
var _errors2 = require("../../utils/errors");
|
13
14
|
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); }
|
14
15
|
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; }
|
15
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -85,13 +86,37 @@ const buildDirectPostJwtBody = async (requestObject, rpConf, payload) => {
|
|
85
86
|
return formBody.toString();
|
86
87
|
};
|
87
88
|
|
89
|
+
/**
|
90
|
+
* Builds a URL-encoded form body for a direct POST response without encryption.
|
91
|
+
*
|
92
|
+
* @param requestObject - Contains state, nonce, and other relevant info.
|
93
|
+
* @param payload - Object that contains either the VP token to encrypt and the stringified mapping of the credential disclosures or the error code
|
94
|
+
* @returns A URL-encoded string suitable for an `application/x-www-form-urlencoded` POST body.
|
95
|
+
*/
|
96
|
+
exports.buildDirectPostJwtBody = buildDirectPostJwtBody;
|
97
|
+
const buildDirectPostBody = async (requestObject, payload) => {
|
98
|
+
const formUrlEncodedBody = new URLSearchParams({
|
99
|
+
...(requestObject.state && {
|
100
|
+
state: requestObject.state
|
101
|
+
}),
|
102
|
+
...Object.entries(payload).reduce((acc, _ref) => {
|
103
|
+
let [key, value] = _ref;
|
104
|
+
return {
|
105
|
+
...acc,
|
106
|
+
[key]: Array.isArray(value) || typeof value === "object" ? JSON.stringify(value) : value
|
107
|
+
};
|
108
|
+
}, {})
|
109
|
+
});
|
110
|
+
return formUrlEncodedBody.toString();
|
111
|
+
};
|
112
|
+
|
88
113
|
/**
|
89
114
|
* Type definition for the function that sends the authorization response
|
90
115
|
* to the Relying Party, completing the presentation flow.
|
91
116
|
* Use with `presentation_definition`.
|
92
117
|
* @deprecated Use `sendAuthorizationResponse`
|
93
118
|
*/
|
94
|
-
exports.
|
119
|
+
exports.buildDirectPostBody = buildDirectPostBody;
|
95
120
|
/**
|
96
121
|
* Sends the authorization response to the Relying Party (RP) using the specified `response_mode`.
|
97
122
|
* This function completes the presentation flow in an OpenID 4 Verifiable Presentations scenario.
|
@@ -164,7 +189,64 @@ const sendAuthorizationResponse = async function (requestObject, remotePresentat
|
|
164
189
|
"Content-Type": "application/x-www-form-urlencoded"
|
165
190
|
},
|
166
191
|
body: requestBody
|
167
|
-
}).then((0, _misc.hasStatusOrThrow)(200)).then(res => res.json()).then(AuthorizationResponse.parse);
|
192
|
+
}).then((0, _misc.hasStatusOrThrow)(200)).then(res => res.json()).then(AuthorizationResponse.parse).catch(handleAuthorizationResponseError);
|
168
193
|
};
|
194
|
+
|
195
|
+
/**
|
196
|
+
* Type definition for the function that sends the authorization response
|
197
|
+
* to the Relying Party, completing the presentation flow.
|
198
|
+
*/
|
169
199
|
exports.sendAuthorizationResponse = sendAuthorizationResponse;
|
200
|
+
/**
|
201
|
+
* Sends the authorization error response to the Relying Party (RP) using the specified `response_mode`.
|
202
|
+
* This function completes the presentation flow in an OpenID 4 Verifiable Presentations scenario.
|
203
|
+
*
|
204
|
+
* @param requestObject - The request details, including presentation requirements.
|
205
|
+
* @param error - The response error value, with description
|
206
|
+
* @param context - Contains optional custom fetch implementation.
|
207
|
+
* @returns Parsed and validated authorization response from the Relying Party.
|
208
|
+
*/
|
209
|
+
const sendAuthorizationErrorResponse = async function (requestObject, _ref2) {
|
210
|
+
let {
|
211
|
+
error,
|
212
|
+
errorDescription
|
213
|
+
} = _ref2;
|
214
|
+
let {
|
215
|
+
appFetch = fetch
|
216
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
217
|
+
const requestBody = await buildDirectPostBody(requestObject, {
|
218
|
+
error,
|
219
|
+
error_description: errorDescription
|
220
|
+
});
|
221
|
+
return await appFetch(requestObject.response_uri, {
|
222
|
+
method: "POST",
|
223
|
+
headers: {
|
224
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
225
|
+
},
|
226
|
+
body: requestBody
|
227
|
+
}).then((0, _misc.hasStatusOrThrow)(200, _errors2.RelyingPartyResponseError)).then(res => res.json()).then(AuthorizationResponse.parse);
|
228
|
+
};
|
229
|
+
|
230
|
+
/**
|
231
|
+
* Handle the the presentation error by mapping it to a custom exception.
|
232
|
+
* If the error is not an instance of {@link UnexpectedStatusCodeError}, it is thrown as is.
|
233
|
+
* @param e - The error to be handled
|
234
|
+
* @throws {RelyingPartyResponseError} with a specific code for more context
|
235
|
+
*/
|
236
|
+
exports.sendAuthorizationErrorResponse = sendAuthorizationErrorResponse;
|
237
|
+
const handleAuthorizationResponseError = e => {
|
238
|
+
if (!(e instanceof _errors2.UnexpectedStatusCodeError)) {
|
239
|
+
throw e;
|
240
|
+
}
|
241
|
+
throw new _errors2.ResponseErrorBuilder(_errors2.RelyingPartyResponseError).handle(400, {
|
242
|
+
code: _errors2.RelyingPartyResponseErrorCodes.InvalidAuthorizationResponse,
|
243
|
+
message: "The Authorization Response contains invalid parameters or it is malformed"
|
244
|
+
}).handle(403, {
|
245
|
+
code: _errors2.RelyingPartyResponseErrorCodes.InvalidAuthorizationResponse,
|
246
|
+
message: "The Authorization Response was forbidden"
|
247
|
+
}).handle("*", {
|
248
|
+
code: _errors2.RelyingPartyResponseErrorCodes.RelyingPartyGenericError,
|
249
|
+
message: "Unable to successfully send the Authorization Response"
|
250
|
+
}).buildFrom(e);
|
251
|
+
};
|
170
252
|
//# sourceMappingURL=08-send-authorization-response.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_ioReactNativeJwt","require","_reactNativeUuid","_interopRequireDefault","_retrieveRpJwks","_errors","_misc","z","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","AuthorizationResponse","object","status","string","optional","response_code","redirect_uri","exports","choosePublicKeyToEncrypt","rpJwkKeys","encKey","find","jwk","use","NoSuitableKeysFoundInEntityConfiguration","buildDirectPostJwtBody","requestObject","rpConf","payload","authzResponsePayload","JSON","stringify","state","keys","getJwksFromConfig","encPublicJwk","authorization_encrypted_response_alg","authorization_encrypted_response_enc","openid_credential_verifier","defaultAlg","kty","encryptedResponse","EncryptJwe","alg","enc","kid","encrypt","formBody","URLSearchParams","response","toString","sendLegacyAuthorizationResponse","presentationDefinitionId","remotePresentations","_remotePresentations$","appFetch","fetch","arguments","length","undefined","vp_token","vpToken","map","remotePresentation","descriptor_map","index","id","inputDescriptor","path","format","presentation_submission","uuid","v4","definition_id","requestBody","response_uri","method","headers","body","then","hasStatusOrThrow","res","json","parse","sendAuthorizationResponse","
|
1
|
+
{"version":3,"names":["_ioReactNativeJwt","require","_reactNativeUuid","_interopRequireDefault","_retrieveRpJwks","_errors","_misc","z","_interopRequireWildcard","_errors2","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","AuthorizationResponse","object","status","string","optional","response_code","redirect_uri","exports","choosePublicKeyToEncrypt","rpJwkKeys","encKey","find","jwk","use","NoSuitableKeysFoundInEntityConfiguration","buildDirectPostJwtBody","requestObject","rpConf","payload","authzResponsePayload","JSON","stringify","state","keys","getJwksFromConfig","encPublicJwk","authorization_encrypted_response_alg","authorization_encrypted_response_enc","openid_credential_verifier","defaultAlg","kty","encryptedResponse","EncryptJwe","alg","enc","kid","encrypt","formBody","URLSearchParams","response","toString","buildDirectPostBody","formUrlEncodedBody","entries","reduce","acc","_ref","value","Array","isArray","sendLegacyAuthorizationResponse","presentationDefinitionId","remotePresentations","_remotePresentations$","appFetch","fetch","arguments","length","undefined","vp_token","vpToken","map","remotePresentation","descriptor_map","index","id","inputDescriptor","path","format","presentation_submission","uuid","v4","definition_id","requestBody","response_uri","method","headers","body","then","hasStatusOrThrow","res","json","parse","sendAuthorizationResponse","presentation","credentialId","catch","handleAuthorizationResponseError","sendAuthorizationErrorResponse","_ref2","error","errorDescription","error_description","RelyingPartyResponseError","e","UnexpectedStatusCodeError","ResponseErrorBuilder","handle","code","RelyingPartyResponseErrorCodes","InvalidAuthorizationResponse","message","RelyingPartyGenericError","buildFrom"],"sourceRoot":"../../../../src","sources":["credential/presentation/08-send-authorization-response.ts"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAOA,IAAAM,CAAA,GAAAC,uBAAA,CAAAP,OAAA;AAGA,IAAAQ,QAAA,GAAAR,OAAA;AAK4B,SAAAS,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,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,I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C,CACtDf,IAAI,CAAEE,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBH,IAAI,CAAC9E,qBAAqB,CAACkF,KAAK,CAAC;AACtC,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AALA3E,OAAA,CAAAiF,8BAAA,GAAAA,8BAAA;AAMA,MAAMD,gCAAgC,GAAIO,CAAU,IAAK;EACvD,IAAI,EAAEA,CAAC,YAAYC,kCAAyB,CAAC,EAAE;IAC7C,MAAMD,CAAC;EACT;EAEA,MAAM,IAAIE,6BAAoB,CAACH,kCAAyB,CAAC,CACtDI,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,uCAA8B,CAACC,4BAA4B;IACjEC,OAAO,EACL;EACJ,CAAC,CAAC,CACDJ,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,uCAA8B,CAACC,4BAA4B;IACjEC,OAAO,EAAE;EACX,CAAC,CAAC,CACDJ,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEC,uCAA8B,CAACG,wBAAwB;IAC7DD,OAAO,EAAE;EACX,CAAC,CAAC,CACDE,SAAS,CAACT,CAAC,CAAC;AACjB,CAAC"}
|
@@ -15,12 +15,30 @@ sequenceDiagram
|
|
15
15
|
O->>+I: QR-CODE: Authorization Request (`request_uri`)
|
16
16
|
I->>+O: GET: Verifier's Entity Configuration
|
17
17
|
O->>+I: Respond with metadata (including public keys)
|
18
|
-
I->>+O: GET: Request Object, resolved from
|
18
|
+
I->>+O: GET: Request Object, resolved from `request_uri`
|
19
19
|
O->>+I: Respond with the Request Object
|
20
|
-
I->>+
|
21
|
-
O
|
20
|
+
I->>+I: Validate Request Object and give consent
|
21
|
+
I->>+O: POST: Authorization Response with encrypted VP token
|
22
|
+
O->>+I: Respond with optional `redirect_uri`
|
22
23
|
```
|
23
24
|
|
25
|
+
## Mapped results
|
26
|
+
|
27
|
+
| Error | Description|
|
28
|
+
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
29
|
+
| `InvalidRequestObject` | The Request Object is not valid, for instance it is malformed or its signature cannot be verified. |
|
30
|
+
| `DcqlError` | The DCQL query cannot be evaluated because it contains errors. |
|
31
|
+
| `CredentialsNotFoundError` | The presentation cannot be completed because the Wallet does not contain all requested credentials. The missing credentials can be found in `details`. |
|
32
|
+
| `RelyingPartyResponseError` | Error in the Relying Party's response. See the next table for more details. |
|
33
|
+
|
34
|
+
#### RelyingPartyResponseError
|
35
|
+
The following HTTP errors are mapped to a `RelyingPartyResponseError` with specific codes.
|
36
|
+
|
37
|
+
| HTTP Status | Error Code | Description |
|
38
|
+
| ------------ | --------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
|
39
|
+
| `400`, `403` | `ERR_RP_INVALID_AUTHORIZATION_RESPONSE` | The Relying Party rejected the Authorization Response sent by the Wallet because it was deemed invalid. |
|
40
|
+
| `*` | `ERR_RP_GENERIC_ERROR` | This is a generic error code to map unexpected errors that occurred when interacting with the Relying Party. |
|
41
|
+
|
24
42
|
|
25
43
|
## Examples
|
26
44
|
|
@@ -35,23 +53,23 @@ const qrCodeParams = decodeQrCode(qrCode)
|
|
35
53
|
|
36
54
|
// Start the issuance flow
|
37
55
|
const {
|
38
|
-
|
39
|
-
|
40
|
-
|
56
|
+
request_uri,
|
57
|
+
client_id,
|
58
|
+
request_uri_method,
|
41
59
|
state
|
42
60
|
} = Credential.Presentation.startFlowFromQR(qrCodeParams);
|
43
61
|
|
44
62
|
// Get the Relying Party's Entity Configuration and evaluate trust
|
45
|
-
const { rpConf } = await Credential.Presentation.evaluateRelyingPartyTrust(
|
63
|
+
const { rpConf } = await Credential.Presentation.evaluateRelyingPartyTrust(client_id);
|
46
64
|
|
47
65
|
// Get the Request Object from the RP
|
48
66
|
const { requestObjectEncodedJwt } =
|
49
|
-
await Credential.Presentation.getRequestObject(
|
67
|
+
await Credential.Presentation.getRequestObject(request_uri);
|
50
68
|
|
51
69
|
// Validate the Request Object
|
52
70
|
const { requestObject } = await Credential.Presentation.verifyRequestObject(
|
53
71
|
requestObjectEncodedJwt,
|
54
|
-
{ clientId, rpConf }
|
72
|
+
{ clientId: client_id, rpConf }
|
55
73
|
);
|
56
74
|
|
57
75
|
// All the credentials that might be requested by the Relying Party
|