@pagopa/io-react-native-wallet 0.28.2 → 0.29.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.map +1 -1
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +36 -5
- 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/README.md +17 -9
- package/lib/commonjs/credential/presentation/errors.js +11 -13
- package/lib/commonjs/credential/presentation/errors.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/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.map +1 -1
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js +36 -5
- 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/README.md +17 -9
- package/lib/module/credential/presentation/errors.js +8 -10
- package/lib/module/credential/presentation/errors.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/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/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/errors.d.ts +11 -5
- package/lib/typescript/credential/presentation/errors.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/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 +2 -3
- package/src/credential/presentation/07-evaluate-dcql-query.ts +36 -1
- package/src/credential/presentation/07-evaluate-input-descriptor.ts +25 -13
- package/src/credential/presentation/README.md +17 -9
- package/src/credential/presentation/errors.ts +15 -8
- 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/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,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 +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":["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.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AC;AACH,CAAC"}
|
@@ -3,6 +3,7 @@ import { isValiError } from "valibot";
|
|
3
3
|
import { decode, prepareVpToken } from "../../sd-jwt";
|
4
4
|
import { ValidationFailed } from "../../utils/errors";
|
5
5
|
import { createCryptoContextFor } from "../../utils/crypto";
|
6
|
+
import { CredentialsNotFoundError } from "./errors";
|
6
7
|
|
7
8
|
/**
|
8
9
|
* The purpose for the credential request by the RP.
|
@@ -40,9 +41,38 @@ const getDcqlQueryMatches = result => Object.entries(result.credential_matches).
|
|
40
41
|
let [, match] = _ref;
|
41
42
|
return match.success === true;
|
42
43
|
});
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Extract only failed matches from the DCQL query result.
|
47
|
+
*/
|
48
|
+
const getDcqlQueryFailedMatches = result => Object.entries(result.credential_matches).filter(_ref2 => {
|
49
|
+
let [, match] = _ref2;
|
50
|
+
return match.success === false;
|
51
|
+
});
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Extract missing credentials from the DCQL query result.
|
55
|
+
* Note: here we are assuming a failed match is a missing credential,
|
56
|
+
* but there might be other reasons for its failure.
|
57
|
+
*/
|
58
|
+
const extractMissingCredentials = (queryResult, originalQuery) => {
|
59
|
+
return getDcqlQueryFailedMatches(queryResult).map(_ref3 => {
|
60
|
+
var _credential$meta;
|
61
|
+
let [id] = _ref3;
|
62
|
+
const credential = originalQuery.credentials.find(c => c.id === id);
|
63
|
+
if ((credential === null || credential === void 0 ? void 0 : credential.format) !== "vc+sd-jwt") {
|
64
|
+
throw new Error("Unsupported format"); // TODO [SIW-2082]: support MDOC credentials
|
65
|
+
}
|
66
|
+
|
67
|
+
return {
|
68
|
+
id,
|
69
|
+
vctValues: (_credential$meta = credential.meta) === null || _credential$meta === void 0 ? void 0 : _credential$meta.vct_values
|
70
|
+
};
|
71
|
+
});
|
72
|
+
};
|
43
73
|
export const evaluateDcqlQuery = (credentialsSdJwt, query) => {
|
44
|
-
const credentials = credentialsSdJwt.map(
|
45
|
-
let [, credential] =
|
74
|
+
const credentials = credentialsSdJwt.map(_ref4 => {
|
75
|
+
let [, credential] = _ref4;
|
46
76
|
return mapCredentialToObject(credential);
|
47
77
|
});
|
48
78
|
try {
|
@@ -51,16 +81,17 @@ export const evaluateDcqlQuery = (credentialsSdJwt, query) => {
|
|
51
81
|
DcqlQuery.validate(parsedQuery);
|
52
82
|
const queryResult = DcqlQuery.query(parsedQuery, credentials);
|
53
83
|
if (!queryResult.canBeSatisfied) {
|
54
|
-
throw new
|
84
|
+
throw new CredentialsNotFoundError(extractMissingCredentials(queryResult, parsedQuery));
|
55
85
|
}
|
86
|
+
|
56
87
|
// Build an object vct:credentialJwt to map matched credentials to their JWT
|
57
88
|
const credentialsSdJwtByVct = credentials.reduce((acc, c, i) => ({
|
58
89
|
...acc,
|
59
90
|
[c.vct]: credentialsSdJwt[i]
|
60
91
|
}), {});
|
61
|
-
return getDcqlQueryMatches(queryResult).map(
|
92
|
+
return getDcqlQueryMatches(queryResult).map(_ref5 => {
|
62
93
|
var _queryResult$credenti;
|
63
|
-
let [id, match] =
|
94
|
+
let [id, match] = _ref5;
|
64
95
|
if (match.output.credential_format !== "vc+sd-jwt") {
|
65
96
|
throw new Error("Unsupported format"); // TODO [SIW-2082]: support MDOC credentials
|
66
97
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["DcqlQuery","DcqlError","DcqlCredentialSetError","isValiError","decode","prepareVpToken","ValidationFailed","createCryptoContextFor","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","
|
1
|
+
{"version":3,"names":["DcqlQuery","DcqlError","DcqlCredentialSetError","isValiError","decode","prepareVpToken","ValidationFailed","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","reason","issues","issue","join","prepareRemotePresentations","nonce","clientId","Promise","all","item","vp_token","requestedClaims","credentialId","vpToken"],"sourceRoot":"../../../../src","sources":["credential/presentation/07-evaluate-dcql-query.ts"],"mappings":"AAAA,SACEA,SAAS,EACTC,SAAS,EACTC,sBAAsB,QAEjB,MAAM;AACb,SAASC,WAAW,QAAQ,SAAS;AACrC,SAASC,MAAM,EAAEC,cAAc,QAAQ,cAAc;AAErD,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,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,GAAGR,MAAM,CAACM,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,gBAAgB;IACnCO,MAAM,EAAER,WAAW,CAACS,MAAM,CACxB,CAACC,GAAG,EAAEC,UAAU,MAAM;MACpB,GAAGD,GAAG;MACN,CAACC,UAA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;MAC9B;IAAA;IAEF,IAAIgF,KAAK,YAAY/E,sBAAsB,EAAE;MAC3C;IAAA;IAEF,MAAM+E,KAAK;EACb;AACF,CAAC;AAED,OAAO,MAAMM,0BAAsD,GAAG,MAAAA,CACpE3C,WAAW,EACX4C,KAAK,EACLC,QAAQ,KACL;EACH,OAAOC,OAAO,CAACC,GAAG,CAChB/C,WAAW,CAACL,GAAG,CAAC,MAAOqD,IAAI,IAAK;IAC9B,MAAM;MAAEC;IAAS,CAAC,GAAG,MAAMxF,cAAc,CAACmF,KAAK,EAAEC,QAAQ,EAAE,CACzDG,IAAI,CAACjD,UAAU,EACfiD,IAAI,CAACE,eAAe,EACpBvF,sBAAsB,CAACqF,IAAI,CAACd,MAAM,CAAC,CACpC,CAAC;IAEF,OAAO;MACLiB,YAAY,EAAEH,IAAI,CAAClD,EAAE;MACrBoD,eAAe,EAAEF,IAAI,CAACE,eAAe;MACrCE,OAAO,EAAEH,QAAQ;MACjB9C,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,W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CAAC;EACJ,CAAC,CACH,CAAC;AACH,CAAC"}
|
@@ -15,12 +15,20 @@ 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
|
+
|`ValidationFailed`|The presentation request is not valid, for instance the DCQL query is invalid.|
|
30
|
+
|`CredentialsNotFoundError`|The presentation cannot be completed because the Wallet does not contain all requested credentials. The missing credentials can be found in `details`.|
|
31
|
+
|
24
32
|
|
25
33
|
## Examples
|
26
34
|
|
@@ -35,23 +43,23 @@ const qrCodeParams = decodeQrCode(qrCode)
|
|
35
43
|
|
36
44
|
// Start the issuance flow
|
37
45
|
const {
|
38
|
-
|
39
|
-
|
40
|
-
|
46
|
+
request_uri,
|
47
|
+
client_id,
|
48
|
+
request_uri_method,
|
41
49
|
state
|
42
50
|
} = Credential.Presentation.startFlowFromQR(qrCodeParams);
|
43
51
|
|
44
52
|
// Get the Relying Party's Entity Configuration and evaluate trust
|
45
|
-
const { rpConf } = await Credential.Presentation.evaluateRelyingPartyTrust(
|
53
|
+
const { rpConf } = await Credential.Presentation.evaluateRelyingPartyTrust(client_id);
|
46
54
|
|
47
55
|
// Get the Request Object from the RP
|
48
56
|
const { requestObjectEncodedJwt } =
|
49
|
-
await Credential.Presentation.getRequestObject(
|
57
|
+
await Credential.Presentation.getRequestObject(request_uri);
|
50
58
|
|
51
59
|
// Validate the Request Object
|
52
60
|
const { requestObject } = await Credential.Presentation.verifyRequestObject(
|
53
61
|
requestObjectEncodedJwt,
|
54
|
-
{ clientId, rpConf }
|
62
|
+
{ clientId: client_id, rpConf }
|
55
63
|
);
|
56
64
|
|
57
65
|
// All the credentials that might be requested by the Relying Party
|
@@ -86,20 +86,18 @@ export class MissingDataError extends IoWalletError {
|
|
86
86
|
super(message);
|
87
87
|
}
|
88
88
|
}
|
89
|
-
|
90
89
|
/**
|
91
|
-
*
|
92
|
-
*
|
90
|
+
* Error thrown when one or more credentials cannot be found in the wallet
|
91
|
+
* and the presentation request cannot be satisfied.
|
93
92
|
*/
|
94
|
-
export class
|
95
|
-
code = "
|
96
|
-
|
93
|
+
export class CredentialsNotFoundError extends IoWalletError {
|
94
|
+
code = "ERR_CREDENTIALS_NOT_FOUND";
|
97
95
|
/**
|
98
|
-
* @param
|
96
|
+
* @param details The details of the credentials that could not be found.
|
99
97
|
*/
|
100
|
-
constructor(
|
101
|
-
|
102
|
-
|
98
|
+
constructor(details) {
|
99
|
+
super("One or more credentials cannot be found in the wallet");
|
100
|
+
this.details = details;
|
103
101
|
}
|
104
102
|
}
|
105
103
|
//# sourceMappingURL=errors.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["IoWalletError","serializeAttrs","AuthRequestDecodeError","code","constructor","message","claim","arguments","length","undefined","reason","NoSuitableKeysFoundInEntityConfiguration","scenario","InvalidQRCodeError","UnverifiedEntityError","MissingDataError","missingAttributes","
|
1
|
+
{"version":3,"names":["IoWalletError","serializeAttrs","AuthRequestDecodeError","code","constructor","message","claim","arguments","length","undefined","reason","NoSuitableKeysFoundInEntityConfiguration","scenario","InvalidQRCodeError","UnverifiedEntityError","MissingDataError","missingAttributes","CredentialsNotFoundError","details"],"sourceRoot":"../../../../src","sources":["credential/presentation/errors.ts"],"mappings":"AAAA,SAASA,aAAa,EAAEC,cAAc,QAAQ,oBAAoB;;AAElE;AACA;AACA;AACA;AACA,OAAO,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AC;EAClDG,IAAI,GAAG,kBAAkB;;EAEzB;AACF;AACA;EACEC,WAAWA,CAACY,iBAAyB,EAAE;IACrC,MAAMX,OAAO,GAAI,kCAAiCW,iBAAkB,GAAE;IACtE,KAAK,CAACX,OAAO,CAAC;EAChB;AACF;AAQA;AACA;AACA;AACA;AACA,OAAO,MAAMY,wBAAwB,SAASjB,aAAa,CAAC;EAC1DG,IAAI,GAAG,2BAA2B;EAGlC;AACF;AACA;EACEC,WAAWA,CAACc,OAAyB,EAAE;IACrC,KAAK,CAAC,uDAAuD,CAAC;IAC9D,IAAI,CAACA,OAAO,GAAGA,OAAO;EACxB;AACF"}
|
@@ -3,6 +3,7 @@ import { SignJWT } from "@pagopa/io-react-native-jwt";
|
|
3
3
|
import { v4 as uuidv4 } from "uuid";
|
4
4
|
import { StatusAttestationResponse } from "./types";
|
5
5
|
import { IssuerResponseError, IssuerResponseErrorCodes, ResponseErrorBuilder, UnexpectedStatusCodeError } from "../../utils/errors";
|
6
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
6
7
|
/**
|
7
8
|
* WARNING: This function must be called after {@link startFlow}.
|
8
9
|
* Verify the status of the credential attestation.
|
@@ -31,6 +32,7 @@ export const statusAttestation = async function (issuerConf, credential, credent
|
|
31
32
|
const body = {
|
32
33
|
credential_pop: credentialPop
|
33
34
|
};
|
35
|
+
Logger.log(LogLevel.DEBUG, `Credential pop: ${credentialPop}`);
|
34
36
|
const result = await appFetch(statusAttUrl, {
|
35
37
|
method: "POST",
|
36
38
|
headers: {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["getCredentialHashWithouDiscloures","hasStatusOrThrow","SignJWT","v4","uuidv4","StatusAttestationResponse","IssuerResponseError","IssuerResponseErrorCodes","ResponseErrorBuilder","UnexpectedStatusCodeError","statusAttestation","issuerConf","credential","credentialCryptoContext","appFetch","arguments","length","undefined","fetch","jwk","getPublicKey","credentialHash","statusAttUrl","openid_credential_issuer","status_attestation_endpoint","credentialPop","setPayload","aud","jti","toString","credential_hash","credential_hash_alg","setProtectedHeader","alg","typ","kid","setIssuedAt","setExpirationTime","sign","body","credential_pop","result","method","headers","JSON","stringify","then","raw","json","parse","catch","handleStatusAttestationError","status_attestation","e","handle","code","CredentialInvalidStatus","message","StatusAttestationRequestFailed","buildFrom"],"sourceRoot":"../../../../src","sources":["credential/status/02-status-attestation.ts"],"mappings":"AAAA,SACEA,iCAAiC,EACjCC,gBAAgB,QAEX,kBAAkB;AAEzB,SAA6BC,OAAO,QAAQ,6BAA6B;AACzE,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,SAASC,yBAAyB,QAAQ,SAAS;AACnD,SACEC,mBAAmB,EACnBC,wBAAwB,EACxBC,oBAAoB,EACpBC,yBAAyB,QACpB,oBAAoB;
|
1
|
+
{"version":3,"names":["getCredentialHashWithouDiscloures","hasStatusOrThrow","SignJWT","v4","uuidv4","StatusAttestationResponse","IssuerResponseError","IssuerResponseErrorCodes","ResponseErrorBuilder","UnexpectedStatusCodeError","LogLevel","Logger","statusAttestation","issuerConf","credential","credentialCryptoContext","appFetch","arguments","length","undefined","fetch","jwk","getPublicKey","credentialHash","statusAttUrl","openid_credential_issuer","status_attestation_endpoint","credentialPop","setPayload","aud","jti","toString","credential_hash","credential_hash_alg","setProtectedHeader","alg","typ","kid","setIssuedAt","setExpirationTime","sign","body","credential_pop","log","DEBUG","result","method","headers","JSON","stringify","then","raw","json","parse","catch","handleStatusAttestationError","status_attestation","e","handle","code","CredentialInvalidStatus","message","StatusAttestationRequestFailed","buildFrom"],"sourceRoot":"../../../../src","sources":["credential/status/02-status-attestation.ts"],"mappings":"AAAA,SACEA,iCAAiC,EACjCC,gBAAgB,QAEX,kBAAkB;AAEzB,SAA6BC,OAAO,QAAQ,6BAA6B;AACzE,SAASC,EAAE,IAAIC,MAAM,QAAQ,MAAM;AACnC,SAASC,yBAAyB,QAAQ,SAAS;AACnD,SACEC,mBAAmB,EACnBC,wBAAwB,EACxBC,oBAAoB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,CAAC;IACDN,IAAI,EAAEO,IAAI,CAACC,SAAS,CAACR,IAAI;EAC3B,CAAC,CAAC,CACCS,IAAI,CAACjD,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAC3BiD,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBF,IAAI,CAAEE,IAAI,IAAK/C,yBAAyB,CAACgD,KAAK,CAACD,IAAI,CAAC,CAAC,CACrDE,KAAK,CAACC,4BAA4B,CAAC;EAEtC,OAAO;IAAE3C,iBAAiB,EAAEiC,MAAM,CAACW;EAAmB,CAAC;AACzD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMD,4BAA4B,GAAIE,CAAU,IAAK;EACnD,IAAI,EAAEA,CAAC,YAAYhD,yBAAyB,CAAC,EAAE;IAC7C,MAAMgD,CAAC;EACT;EAEA,MAAM,IAAIjD,oBAAoB,CAACF,mBAAmB,CAAC,CAChDoD,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEpD,wBAAwB,CAACqD,uBAAuB;IACtDC,OAAO,EAAE;EACX,CAAC,CAAC,CACDH,MAAM,CAAC,GAAG,EAAE;IACXC,IAAI,EAAEpD,wBAAwB,CAACuD,8BAA8B;IAC7DD,OAAO,EAAG;EACZ,CAAC,CAAC,CACDE,SAAS,CAACN,CAAC,CAAC;AACjB,CAAC"}
|
@@ -2,6 +2,7 @@ import { IoWalletError } from "../../utils/errors";
|
|
2
2
|
import { verify } from "@pagopa/io-react-native-jwt";
|
3
3
|
import { ParsedStatusAttestation } from "./types";
|
4
4
|
import { decode as decodeJwt } from "@pagopa/io-react-native-jwt";
|
5
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
5
6
|
/**
|
6
7
|
* Given a status attestation, verifies that:
|
7
8
|
* - It's in the supported format;
|
@@ -29,11 +30,13 @@ export const verifyAndParseStatusAttestation = async (issuerConf, rawStatusAttes
|
|
29
30
|
header: decodedJwt.protectedHeader,
|
30
31
|
payload: decodedJwt.payload
|
31
32
|
});
|
33
|
+
Logger.log(LogLevel.DEBUG, `Parsed status attestation: ${JSON.stringify(parsedStatusAttestation)}`);
|
32
34
|
const holderBindingKey = await credentialCryptoContext.getPublicKey();
|
33
35
|
const {
|
34
36
|
cnf
|
35
37
|
} = parsedStatusAttestation.payload;
|
36
38
|
if (!cnf.jwk.kid || cnf.jwk.kid !== holderBindingKey.kid) {
|
39
|
+
Logger.log(LogLevel.ERROR, `Failed to verify holder binding for status attestation, expected kid: ${holderBindingKey.kid}, got: ${parsedStatusAttestation.payload.cnf.jwk.kid}`);
|
37
40
|
throw new IoWalletError(`Failed to verify holder binding for status attestation, expected kid: ${holderBindingKey.kid}, got: ${parsedStatusAttestation.payload.cnf.jwk.kid}`);
|
38
41
|
}
|
39
42
|
return {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["IoWalletError","verify","ParsedStatusAttestation","decode","decodeJwt","verifyAndParseStatusAttestation","issuerConf","rawStatusAttestation","context","statusAttestation","credentialCryptoContext","openid_credential_issuer","jwks","keys","decodedJwt","parsedStatusAttestation","parse","header","protectedHeader","payload","holderBindingKey","getPublicKey","cnf","jwk","kid","
|
1
|
+
{"version":3,"names":["IoWalletError","verify","ParsedStatusAttestation","decode","decodeJwt","LogLevel","Logger","verifyAndParseStatusAttestation","issuerConf","rawStatusAttestation","context","statusAttestation","credentialCryptoContext","openid_credential_issuer","jwks","keys","decodedJwt","parsedStatusAttestation","parse","header","protectedHeader","payload","log","DEBUG","JSON","stringify","holderBindingKey","getPublicKey","cnf","jwk","kid","ERROR","e"],"sourceRoot":"../../../../src","sources":["credential/status/03-verify-and-parse-status-attestation.ts"],"mappings":"AACA,SAASA,aAAa,QAAQ,oBAAoB;AAClD,SAASC,MAAM,QAA4B,6BAA6B;AAExE,SAASC,uBAAuB,QAAQ,SAAS;AACjD,SAASC,MAAM,IAAIC,SAAS,QAAQ,6BAA6B;AACjE,SAASC,QAAQ,EAAEC,MAAM,QAAQ,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;IACH;IAEA,OAAO;MAAEb;IAAwB,CAAC;EACpC,CAAC,CAAC,OAAOe,CAAC,EAAE;IACV,MAAM,IAAIhC,aAAa,CACpB,wCAAuCwB,IAAI,CAACC,SAAS,CAACO,CAAC,CAAE,EAC5D,CAAC;EACH;AACF,CAAC"}
|
@@ -2,6 +2,7 @@ import { SignJWT, thumbprint, decode as decodeJwt } from "@pagopa/io-react-nativ
|
|
2
2
|
import * as WalletInstanceAttestation from "../../wallet-instance-attestation";
|
3
3
|
import { IoWalletError } from "../../utils/errors";
|
4
4
|
import { obfuscateString } from "../../utils/string";
|
5
|
+
import { LogLevel, Logger } from "../../utils/logging";
|
5
6
|
/**
|
6
7
|
* Generates a trustmark signed JWT, which is used to verify the authenticity of a credential.
|
7
8
|
* The public key used to sign the trustmark must the same used for the Wallet Instance Attestation.
|
@@ -31,11 +32,13 @@ export const getCredentialTrustmark = async _ref => {
|
|
31
32
|
*/
|
32
33
|
const holderBindingKey = await wiaCryptoContext.getPublicKey();
|
33
34
|
const decodedWia = WalletInstanceAttestation.decode(walletInstanceAttestation);
|
35
|
+
Logger.log(LogLevel.DEBUG, `Decoded wia ${JSON.stringify(decodedWia.payload)} with holder binding key ${JSON.stringify(holderBindingKey)}`);
|
34
36
|
|
35
37
|
/**
|
36
38
|
* Check that the WIA is not expired
|
37
39
|
*/
|
38
40
|
if (decodedWia.payload.exp * 1000 < Date.now()) {
|
41
|
+
Logger.log(LogLevel.ERROR, `Wallet Instance Attestation expired with exp: ${decodedWia.payload.exp}`);
|
39
42
|
throw new IoWalletError("Wallet Instance Attestation expired");
|
40
43
|
}
|
41
44
|
|
@@ -45,8 +48,10 @@ export const getCredentialTrustmark = async _ref => {
|
|
45
48
|
const wiaThumbprint = await thumbprint(decodedWia.payload.cnf.jwk);
|
46
49
|
const cryptoContextThumbprint = await thumbprint(holderBindingKey);
|
47
50
|
if (wiaThumbprint !== cryptoContextThumbprint) {
|
51
|
+
Logger.log(LogLevel.ERROR, `Failed to verify holder binding for status attestation, expected thumbprint: ${cryptoContextThumbprint}, got: ${wiaThumbprint}`);
|
48
52
|
throw new IoWalletError(`Failed to verify holder binding for status attestation, expected thumbprint: ${cryptoContextThumbprint}, got: ${wiaThumbprint}`);
|
49
53
|
}
|
54
|
+
Logger.log(LogLevel.DEBUG, `Wia thumbprint: ${wiaThumbprint} CryptoContext thumbprint: ${cryptoContextThumbprint}`);
|
50
55
|
|
51
56
|
/**
|
52
57
|
* Generate Trustmark signed JWT
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["SignJWT","thumbprint","decode","decodeJwt","WalletInstanceAttestation","IoWalletError","obfuscateString","getCredentialTrustmark","_ref","walletInstanceAttestation","wiaCryptoContext","credentialType","docNumber","expirationTime","holderBindingKey","getPublicKey","decodedWia","payload","exp","Date","now","wiaThumbprint","cnf","jwk","cryptoContextThumbprint","signedTrustmarkJwt","setProtectedHeader","alg","setPayload","iss","sub","subtyp","setIssuedAt","setExpirationTime","sign","decodedTrustmark","jwt"],"sourceRoot":"../../../../src","sources":["credential/trustmark/get-credential-trustmark.ts"],"mappings":"AAAA,SACEA,OAAO,EACPC,UAAU,EAEVC,MAAM,IAAIC,SAAS,QACd,6BAA6B;AACpC,OAAO,KAAKC,yBAAyB,MAAM,mCAAmC;AAC9E,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,eAAe,QAAQ,oBAAoB;
|
1
|
+
{"version":3,"names":["SignJWT","thumbprint","decode","decodeJwt","WalletInstanceAttestation","IoWalletError","obfuscateString","LogLevel","Logger","getCredentialTrustmark","_ref","walletInstanceAttestation","wiaCryptoContext","credentialType","docNumber","expirationTime","holderBindingKey","getPublicKey","decodedWia","log","DEBUG","JSON","stringify","payload","exp","Date","now","ERROR","wiaThumbprint","cnf","jwk","cryptoContextThumbprint","signedTrustmarkJwt","setProtectedHeader","alg","setPayload","iss","sub","subtyp","setIssuedAt","setExpirationTime","sign","decodedTrustmark","jwt"],"sourceRoot":"../../../../src","sources":["credential/trustmark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GAAG,MAAM9B,UAAU,CAACe,gBAAgB,CAAC;EAElE,IAAIY,aAAa,KAAKG,uBAAuB,EAAE;IAC7CvB,MAAM,CAACW,GAAG,CACRZ,QAAQ,CAACoB,KAAK,EACb,gFAA+EI,uBAAwB,UAASH,aAAc,EACjI,CAAC;IACD,MAAM,IAAIvB,aAAa,CACpB,gFAA+E0B,uBAAwB,UAASH,aAAc,EACjI,CAAC;EACH;EAEApB,MAAM,CAACW,GAAG,CACRZ,QAAQ,CAACa,KAAK,EACb,mBAAkBQ,aAAc,8BAA6BG,uBAAwB,EACxF,CAAC;;EAED;AACF;AACA;EACE,MAAMC,kBAAkB,GAAG,MAAM,IAAIhC,OAAO,CAACY,gBAAgB,CAAC,CAC3DqB,kBAAkB,CAAC;IAClBC,GAAG,EAAE;EACP,CAAC,CAAC,CACDC,UAAU,CAAC;IACVC,GAAG,EAAEzB,yBAAyB;IAC9B;AACN;AACA;IACM,IAAIG,SAAS,GAAG;MAAEuB,GAAG,EAAE/B,eAAe,CAACQ,SAAS;IAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACzDwB,MAAM,EAAEzB;EACV,CAAC,CAAC,CACD0B,WAAW,CAAC,CAAC,CACbC,iBAAiB,CAACzB,cAAc,CAAC,CACjC0B,IAAI,CAAC,CAAC;EAET,MAAMC,gBAAgB,GAAGvC,SAAS,CAAC6B,kBAAkB,CAAC;EAEtD,OAAO;IACLW,GAAG,EAAEX,kBAAkB;IACvBjB,cAAc,EAAE2B,gBAAgB,CAACnB,OAAO,CAACC,GAAG,IAAI;EAClD,CAAC;AACH,CAAC"}
|
package/lib/module/index.js
CHANGED
@@ -9,7 +9,8 @@ import * as Errors from "./utils/errors";
|
|
9
9
|
import * as WalletInstanceAttestation from "./wallet-instance-attestation";
|
10
10
|
import * as Trust from "./trust";
|
11
11
|
import * as WalletInstance from "./wallet-instance";
|
12
|
+
import * as Logging from "./utils/logging";
|
12
13
|
import { AuthorizationDetail, AuthorizationDetails } from "./utils/par";
|
13
14
|
import { createCryptoContextFor } from "./utils/crypto";
|
14
|
-
export { SdJwt, PID, Credential, WalletInstanceAttestation, WalletInstance, Errors, Trust, createCryptoContextFor, AuthorizationDetail, AuthorizationDetails, fixBase64EncodingOnKey };
|
15
|
+
export { SdJwt, PID, Credential, WalletInstanceAttestation, WalletInstance, Errors, Trust, createCryptoContextFor, AuthorizationDetail, AuthorizationDetails, fixBase64EncodingOnKey, Logging };
|
15
16
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["fixBase64EncodingOnKey","Credential","PID","SdJwt","Errors","WalletInstanceAttestation","Trust","WalletInstance","AuthorizationDetail","AuthorizationDetails","createCryptoContextFor"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AACA,SAASA,sBAAsB,QAAQ,aAAa;AACpD;AACA;AACA,OAAO,gCAAgC;AAEvC,OAAO,KAAKC,UAAU,MAAM,cAAc;AAC1C,OAAO,KAAKC,GAAG,MAAM,OAAO;AAC5B,OAAO,KAAKC,KAAK,MAAM,UAAU;AACjC,OAAO,KAAKC,MAAM,MAAM,gBAAgB;AACxC,OAAO,KAAKC,yBAAyB,MAAM,+BAA+B;AAC1E,OAAO,KAAKC,KAAK,MAAM,SAAS;AAChC,OAAO,KAAKC,cAAc,MAAM,mBAAmB;AACnD,SAASC,mBAAmB,EAAEC,oBAAoB,QAAQ,aAAa;AACvE,SAASC,sBAAsB,QAAQ,gBAAgB;AAGvD,
|
1
|
+
{"version":3,"names":["fixBase64EncodingOnKey","Credential","PID","SdJwt","Errors","WalletInstanceAttestation","Trust","WalletInstance","Logging","AuthorizationDetail","AuthorizationDetails","createCryptoContextFor"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AACA,SAASA,sBAAsB,QAAQ,aAAa;AACpD;AACA;AACA,OAAO,gCAAgC;AAEvC,OAAO,KAAKC,UAAU,MAAM,cAAc;AAC1C,OAAO,KAAKC,GAAG,MAAM,OAAO;AAC5B,OAAO,KAAKC,KAAK,MAAM,UAAU;AACjC,OAAO,KAAKC,MAAM,MAAM,gBAAgB;AACxC,OAAO,KAAKC,yBAAyB,MAAM,+BAA+B;AAC1E,OAAO,KAAKC,KAAK,MAAM,SAAS;AAChC,OAAO,KAAKC,cAAc,MAAM,mBAAmB;AACnD,OAAO,KAAKC,OAAO,MAAM,iBAAiB;AAC1C,SAASC,mBAAmB,EAAEC,oBAAoB,QAAQ,aAAa;AACvE,SAASC,sBAAsB,QAAQ,gBAAgB;AAGvD,SACER,KAAK,EACLD,GAAG,EACHD,UAAU,EACVI,yBAAyB,EACzBE,cAAc,EACdH,MAAM,EACNE,KAAK,EACLK,sBAAsB,EACtBF,mBAAmB,EACnBC,oBAAoB,EACpBV,sBAAsB,EACtBQ,OAAO"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { decode as decodeJwt } from "@pagopa/io-react-native-jwt";
|
2
2
|
import { ValidationFailed } from "./errors";
|
3
|
+
import { LogLevel, Logger } from "./logging";
|
3
4
|
|
4
5
|
/*
|
5
6
|
* Decode a form_post.jwt and return the final JWT.
|
@@ -44,6 +45,7 @@ export const getJwtFromFormPost = async formData => {
|
|
44
45
|
};
|
45
46
|
}
|
46
47
|
}
|
48
|
+
Logger.log(LogLevel.ERROR, `Unable to obtain JWT from form_post.jwt. Form data: ${formData}`);
|
47
49
|
throw new ValidationFailed({
|
48
50
|
message: `Unable to obtain JWT from form_post.jwt. Form data: ${formData}`
|
49
51
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["decode","decodeJwt","ValidationFailed","getJwtFromFormPost","formData","formPostRegex","lineExpressionRegex","match","exec","responseJwt","jwt","replace","decodedJwt","message"],"sourceRoot":"../../../src","sources":["utils/decoder.ts"],"mappings":"AAAA,SAASA,MAAM,IAAIC,SAAS,QAAQ,6BAA6B;AAEjE,SAASC,gBAAgB,QAAQ,UAAU;;
|
1
|
+
{"version":3,"names":["decode","decodeJwt","ValidationFailed","LogLevel","Logger","getJwtFromFormPost","formData","formPostRegex","lineExpressionRegex","match","exec","responseJwt","jwt","replace","decodedJwt","log","ERROR","message"],"sourceRoot":"../../../src","sources":["utils/decoder.ts"],"mappings":"AAAA,SAASA,MAAM,IAAIC,SAAS,QAAQ,6BAA6B;AAEjE,SAASC,gBAAgB,QAAQ,UAAU;AAC3C,SAASC,QAAQ,EAAEC,MAAM,QAAQ,WAAW;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,GAAG,MAChCC,QAAgB,IAC0C;EAC1D,MAAMC,aAAa,GAAG,iDAAiD;EACvE,MAAMC,mBAAmB,GAAG,sBAAsB;EAElD,MAAMC,KAAK,GAAGF,aAAa,CAACG,IAAI,CAACJ,QAAQ,CAAC;EAC1C,IAAIG,KAAK,IAAIA,KAAK,CAAC,CAAC,CAAC,EAAE;IACrB,MAAME,WAAW,GAAGF,KAAK,CAAC,CAAC,CAAC;IAE5B,IAAIE,WAAW,EAAE;MACf,MAAMC,GAAG,GAAGD,WAAW,CAACE,OAAO,CAACL,mBAAmB,EAAE,EAAE,CAAC;MACxD,MAAMM,UAAU,GAAGb,SAAS,CAACW,GAAG,CAAC;MACjC,OAAO;QAAEA,GAAG;QAAEE;MAAW,CAAC;IAC5B;EACF;EAEAV,MAAM,CAACW,GAAG,CACRZ,QAAQ,CAACa,KAAK,EACb,uDAAsDV,QAAS,EAClE,CAAC;EACD,MAAM,IAAIJ,gBAAgB,CAAC;IACzBe,OAAO,EAAG,uDAAsDX,QAAS;EAC3E,CAAC,CAAC;AACJ,CAAC"}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
/**
|
2
|
+
* Logger interface which can be provided to the Logger class as a custom implementation.
|
3
|
+
*/
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Supported debug levels.
|
7
|
+
*/
|
8
|
+
export let LogLevel = /*#__PURE__*/function (LogLevel) {
|
9
|
+
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
10
|
+
LogLevel[LogLevel["INFO"] = 1] = "INFO";
|
11
|
+
LogLevel[LogLevel["WARN"] = 2] = "WARN";
|
12
|
+
LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
|
13
|
+
return LogLevel;
|
14
|
+
}({});
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Logger singleton class which provides a simple logging interface with an init function to set the logging context and
|
18
|
+
* a static log function to log messages based on the debug level.
|
19
|
+
* This can be used as follows:
|
20
|
+
* const logger = Logger.getInstance();
|
21
|
+
* logger.initLogging(yourLoggingContext);
|
22
|
+
* logger.log(LogLevel.DEBUG, "Debug message");
|
23
|
+
*/
|
24
|
+
export class Logger {
|
25
|
+
static instance = null;
|
26
|
+
// Private constructor to prevent direct instantiation
|
27
|
+
constructor() {}
|
28
|
+
|
29
|
+
// Public static method to get the Logger instance
|
30
|
+
static getInstance() {
|
31
|
+
if (Logger.instance === null) {
|
32
|
+
Logger.instance = new Logger();
|
33
|
+
}
|
34
|
+
return Logger.instance;
|
35
|
+
}
|
36
|
+
|
37
|
+
// Method to initialize the logging context
|
38
|
+
initLogging(loggingCtx) {
|
39
|
+
Logger.loggingContext = loggingCtx;
|
40
|
+
}
|
41
|
+
|
42
|
+
// Method to log based on the level which wraps the null check for the logging context
|
43
|
+
static log(level, msg) {
|
44
|
+
if (Logger.loggingContext) {
|
45
|
+
switch (level) {
|
46
|
+
case LogLevel.DEBUG:
|
47
|
+
Logger.loggingContext.logDebug(msg);
|
48
|
+
break;
|
49
|
+
case LogLevel.INFO:
|
50
|
+
Logger.loggingContext.logInfo(msg);
|
51
|
+
break;
|
52
|
+
case LogLevel.WARN:
|
53
|
+
Logger.loggingContext.logWarn(msg);
|
54
|
+
break;
|
55
|
+
case LogLevel.ERROR:
|
56
|
+
Logger.loggingContext.logError(msg);
|
57
|
+
break;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
//# sourceMappingURL=logging.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["LogLevel","Logger","instance","constructor","getInstance","initLogging","loggingCtx","loggingContext","log","level","msg","DEBUG","logDebug","INFO","logInfo","WARN","logWarn","ERROR","logError"],"sourceRoot":"../../../src","sources":["utils/logging.ts"],"mappings":"AAAA;AACA;AACA;;AAQA;AACA;AACA;AACA,WAAYA,QAAQ,0BAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAARA,QAAQ,CAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;;AAOpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,MAAM,CAAC;EAClB,OAAeC,QAAQ,GAAkB,IAAI;EAG7C;EACQC,WAAWA,CAAA,EAAG,CAAC;;EAEvB;EACA,OAAcC,WAAWA,CAAA,EAAW;IAClC,IAAIH,MAAM,CAACC,QAAQ,KAAK,IAAI,EAAE;MAC5BD,MAAM,CAACC,QAAQ,GAAG,IAAID,MAAM,CAAC,CAAC;IAChC;IACA,OAAOA,MAAM,CAACC,QAAQ;EACxB;;EAEA;EACOG,WAAWA,CAACC,UAA0B,EAAQ;IACnDL,MAAM,CAACM,cAAc,GAAGD,UAAU;EACpC;;EAEA;EACA,OAAcE,GAAGA,CAACC,KAAe,EAAEC,GAAW,EAAQ;IACpD,IAAIT,MAAM,CAACM,cAAc,EAAE;MACzB,QAAQE,KAAK;QACX,KAAKT,QAAQ,CAACW,KAAK;UACjBV,MAAM,CAACM,cAAc,CAACK,QAAQ,CAACF,GAAG,CAAC;UACnC;QACF,KAAKV,QAAQ,CAACa,IAAI;UAChBZ,MAAM,CAACM,cAAc,CAACO,OAAO,CAACJ,GAAG,CAAC;UAClC;QACF,KAAKV,QAAQ,CAACe,IAAI;UAChBd,MAAM,CAACM,cAAc,CAACS,OAAO,CAACN,GAAG,CAAC;UAClC;QACF,KAAKV,QAAQ,CAACiB,KAAK;UACjBhB,MAAM,CAACM,cAAc,CAACW,QAAQ,CAACR,GAAG,CAAC;UACnC;MACJ;IACF;EACF;AACF"}
|
package/lib/module/utils/misc.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import { IoWalletError, UnexpectedStatusCodeError } from "./errors";
|
2
2
|
import { sha256 } from "js-sha256";
|
3
|
+
import { LogLevel, Logger } from "./logging";
|
3
4
|
|
4
5
|
/**
|
5
6
|
* Check if a response is in the expected status, otherwise throw an error
|
@@ -11,6 +12,7 @@ import { sha256 } from "js-sha256";
|
|
11
12
|
export const hasStatusOrThrow = (status, customError) => async res => {
|
12
13
|
if (res.status !== status) {
|
13
14
|
const ErrorClass = customError ?? UnexpectedStatusCodeError;
|
15
|
+
Logger.log(LogLevel.ERROR, `Http request failed. Expected ${status}, got ${res.status}, url: ${res.url}`);
|
14
16
|
throw new ErrorClass({
|
15
17
|
message: `Http request failed. Expected ${status}, got ${res.status}, url: ${res.url}`,
|
16
18
|
statusCode: res.status,
|