@pagopa/io-react-native-wallet 2.4.2 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/client/generated/wallet-provider.js +48 -42
- package/lib/commonjs/client/generated/wallet-provider.js.map +1 -1
- package/lib/commonjs/client/index.js +1 -1
- package/lib/commonjs/client/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +148 -123
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/sd-jwt/index.js.map +1 -1
- package/lib/commonjs/utils/parser.js +20 -0
- package/lib/commonjs/utils/parser.js.map +1 -0
- package/lib/commonjs/wallet-instance/index.js +4 -2
- package/lib/commonjs/wallet-instance/index.js.map +1 -1
- package/lib/module/client/generated/wallet-provider.js +37 -31
- package/lib/module/client/generated/wallet-provider.js.map +1 -1
- package/lib/module/client/index.js +2 -2
- package/lib/module/client/index.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +144 -119
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/sd-jwt/__test__/index.test.js +1 -1
- package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/module/sd-jwt/index.js +1 -3
- package/lib/module/sd-jwt/index.js.map +1 -1
- package/lib/module/utils/parser.js +12 -0
- package/lib/module/utils/parser.js.map +1 -0
- package/lib/module/wallet-instance/index.js +4 -2
- package/lib/module/wallet-instance/index.js.map +1 -1
- package/lib/typescript/client/generated/wallet-provider.d.ts +127 -124
- package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/index.d.ts +1 -1
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/utils/errors.d.ts +3 -3
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/utils/parser.d.ts +9 -0
- package/lib/typescript/utils/parser.d.ts.map +1 -0
- package/lib/typescript/wallet-instance/index.d.ts +1 -0
- package/lib/typescript/wallet-instance/index.d.ts.map +1 -1
- package/package.json +7 -2
- package/src/client/generated/wallet-provider.ts +53 -46
- package/src/client/index.ts +3 -3
- package/src/credential/issuance/07-verify-and-parse-credential.ts +138 -94
- package/src/sd-jwt/__test__/index.test.ts +1 -1
- package/src/sd-jwt/index.ts +7 -5
- package/src/utils/errors.ts +3 -3
- package/src/utils/parser.ts +18 -0
- package/src/wallet-instance/index.ts +3 -1
- package/lib/commonjs/utils/nestedProperty.js +0 -153
- package/lib/commonjs/utils/nestedProperty.js.map +0 -1
- package/lib/module/utils/nestedProperty.js +0 -147
- package/lib/module/utils/nestedProperty.js.map +0 -1
- package/lib/typescript/utils/nestedProperty.d.ts +0 -24
- package/lib/typescript/utils/nestedProperty.d.ts.map +0 -1
- package/src/utils/nestedProperty.ts +0 -223
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
|
+
export const SetWalletInstanceStatusData = z.object({
|
|
3
|
+
status: z.literal("REVOKED")
|
|
4
|
+
});
|
|
5
|
+
export const RevocationReason = z.union([z.literal("CERTIFICATE_REVOKED_BY_ISSUER"), z.literal("NEW_WALLET_INSTANCE_CREATED"), z.literal("WALLET_INSTANCE_RENEWAL"), z.literal("REVOKED_BY_USER")]);
|
|
6
|
+
export const WalletInstanceData = z.object({
|
|
7
|
+
id: z.string(),
|
|
8
|
+
is_revoked: z.boolean(),
|
|
9
|
+
revocation_reason: z.union([RevocationReason, z.undefined()]).optional()
|
|
10
|
+
});
|
|
2
11
|
export const NonceDetailView = z.object({
|
|
3
12
|
nonce: z.string()
|
|
4
13
|
});
|
|
5
|
-
export const WalletAttestationView = z.object({
|
|
6
|
-
wallet_attestation: z.string()
|
|
7
|
-
});
|
|
8
14
|
export const WalletAttestationsView = z.object({
|
|
9
15
|
wallet_attestations: z.array(z.object({
|
|
10
16
|
format: z.union([z.literal("jwt"), z.literal("dc+sd-jwt")]),
|
|
@@ -14,31 +20,24 @@ export const WalletAttestationsView = z.object({
|
|
|
14
20
|
export const CreateWalletInstanceBody = z.object({
|
|
15
21
|
challenge: z.string(),
|
|
16
22
|
key_attestation: z.string(),
|
|
17
|
-
hardware_key_tag: z.string()
|
|
23
|
+
hardware_key_tag: z.string(),
|
|
24
|
+
is_renewal: z.union([z.boolean(), z.undefined()]).optional()
|
|
18
25
|
});
|
|
19
26
|
export const CreateWalletAttestationBody = z.object({
|
|
20
|
-
grant_type: z.literal("urn:ietf:params:oauth:grant-type:jwt-bearer"),
|
|
21
27
|
assertion: z.string()
|
|
22
28
|
});
|
|
23
|
-
export const
|
|
24
|
-
assertion: z.string()
|
|
25
|
-
});
|
|
26
|
-
export const SetWalletInstanceStatusBody = z.object({
|
|
27
|
-
status: z.literal("REVOKED")
|
|
28
|
-
});
|
|
29
|
-
export const RevocationReason = z.union([z.literal("CERTIFICATE_REVOKED_BY_ISSUER"), z.literal("NEW_WALLET_INSTANCE_CREATED"), z.literal("REVOKED_BY_USER")]);
|
|
30
|
-
export const WalletInstanceData = z.object({
|
|
31
|
-
id: z.string(),
|
|
32
|
-
is_revoked: z.boolean(),
|
|
33
|
-
revocation_reason: z.union([RevocationReason, z.undefined()]).optional()
|
|
34
|
-
});
|
|
35
|
-
export const ProblemDetail = z.object({
|
|
29
|
+
export const ProblemJson = z.object({
|
|
36
30
|
type: z.string().optional(),
|
|
37
31
|
title: z.string().optional(),
|
|
38
32
|
status: z.number().optional(),
|
|
39
33
|
detail: z.string().optional(),
|
|
40
34
|
instance: z.string().optional()
|
|
41
35
|
});
|
|
36
|
+
export const WhitelistedFiscalCodeData = z.object({
|
|
37
|
+
whitelisted: z.boolean(),
|
|
38
|
+
whitelistedAt: z.union([z.string(), z.undefined()]).optional(),
|
|
39
|
+
fiscalCode: z.string()
|
|
40
|
+
});
|
|
42
41
|
export const get_GetNonce = {
|
|
43
42
|
method: z.literal("GET"),
|
|
44
43
|
path: z.literal("/nonce"),
|
|
@@ -54,18 +53,10 @@ export const post_CreateWalletInstance = {
|
|
|
54
53
|
response: z.unknown()
|
|
55
54
|
};
|
|
56
55
|
export const post_CreateWalletAttestation = {
|
|
57
|
-
method: z.literal("POST"),
|
|
58
|
-
path: z.literal("/token"),
|
|
59
|
-
parameters: z.object({
|
|
60
|
-
body: CreateWalletAttestationBody
|
|
61
|
-
}),
|
|
62
|
-
response: WalletAttestationView
|
|
63
|
-
};
|
|
64
|
-
export const post_CreateWalletAttestationV2 = {
|
|
65
56
|
method: z.literal("POST"),
|
|
66
57
|
path: z.literal("/wallet-attestations"),
|
|
67
58
|
parameters: z.object({
|
|
68
|
-
body:
|
|
59
|
+
body: CreateWalletAttestationBody
|
|
69
60
|
}),
|
|
70
61
|
response: WalletAttestationsView
|
|
71
62
|
};
|
|
@@ -92,22 +83,37 @@ export const put_SetWalletInstanceStatus = {
|
|
|
92
83
|
path: z.object({
|
|
93
84
|
id: z.string()
|
|
94
85
|
}),
|
|
95
|
-
body:
|
|
86
|
+
body: SetWalletInstanceStatusData
|
|
96
87
|
}),
|
|
97
88
|
response: z.unknown()
|
|
98
89
|
};
|
|
90
|
+
export const get_HealthCheck = {
|
|
91
|
+
method: z.literal("GET"),
|
|
92
|
+
path: z.literal("/info"),
|
|
93
|
+
parameters: z.never(),
|
|
94
|
+
response: z.object({
|
|
95
|
+
message: z.string().optional()
|
|
96
|
+
})
|
|
97
|
+
};
|
|
98
|
+
export const get_IsFiscalCodeWhitelisted = {
|
|
99
|
+
method: z.literal("GET"),
|
|
100
|
+
path: z.literal("/whitelisted-fiscal-code"),
|
|
101
|
+
parameters: z.never(),
|
|
102
|
+
response: WhitelistedFiscalCodeData
|
|
103
|
+
};
|
|
99
104
|
|
|
100
105
|
// <EndpointByMethod>
|
|
101
106
|
export const EndpointByMethod = {
|
|
102
107
|
get: {
|
|
103
108
|
"/nonce": get_GetNonce,
|
|
104
109
|
"/wallet-instances/current/status": get_GetCurrentWalletInstanceStatus,
|
|
105
|
-
"/wallet-instances/{id}/status": get_GetWalletInstanceStatus
|
|
110
|
+
"/wallet-instances/{id}/status": get_GetWalletInstanceStatus,
|
|
111
|
+
"/info": get_HealthCheck,
|
|
112
|
+
"/whitelisted-fiscal-code": get_IsFiscalCodeWhitelisted
|
|
106
113
|
},
|
|
107
114
|
post: {
|
|
108
115
|
"/wallet-instances": post_CreateWalletInstance,
|
|
109
|
-
"/
|
|
110
|
-
"/wallet-attestations": post_CreateWalletAttestationV2
|
|
116
|
+
"/wallet-attestations": post_CreateWalletAttestation
|
|
111
117
|
},
|
|
112
118
|
put: {
|
|
113
119
|
"/wallet-instances/{id}/status": put_SetWalletInstanceStatus
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["z","
|
|
1
|
+
{"version":3,"names":["z","SetWalletInstanceStatusData","object","status","literal","RevocationReason","union","WalletInstanceData","id","string","is_revoked","boolean","revocation_reason","undefined","optional","NonceDetailView","nonce","WalletAttestationsView","wallet_attestations","array","format","wallet_attestation","CreateWalletInstanceBody","challenge","key_attestation","hardware_key_tag","is_renewal","CreateWalletAttestationBody","assertion","ProblemJson","type","title","number","detail","instance","WhitelistedFiscalCodeData","whitelisted","whitelistedAt","fiscalCode","get_GetNonce","method","path","parameters","never","response","post_CreateWalletInstance","body","unknown","post_CreateWalletAttestation","get_GetCurrentWalletInstanceStatus","get_GetWalletInstanceStatus","put_SetWalletInstanceStatus","get_HealthCheck","message","get_IsFiscalCodeWhitelisted","EndpointByMethod","get","post","put","ApiClient","baseUrl","constructor","fetcher","setBaseUrl","arguments","length","createApiClient"],"sourceRoot":"../../../../src","sources":["client/generated/wallet-provider.ts"],"mappings":"AAAA,OAAOA,CAAC,MAAM,KAAK;AAGnB,OAAO,MAAMC,2BAA2B,GAAGD,CAAC,CAACE,MAAM,CAAC;EAClDC,MAAM,EAAEH,CAAC,CAACI,OAAO,CAAC,SAAS;AAC7B,CAAC,CAAC;AAGF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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { parseRawHttpResponse } from "../utils/misc";
|
|
2
2
|
import { WalletProviderResponseError } from "../utils/errors";
|
|
3
|
-
import {
|
|
3
|
+
import { ProblemJson, createApiClient as createWalletProviderApiClient } from "./generated/wallet-provider";
|
|
4
4
|
const validateResponse = async response => {
|
|
5
5
|
if (!response.ok) {
|
|
6
6
|
let problemDetail = {};
|
|
7
7
|
try {
|
|
8
|
-
problemDetail =
|
|
8
|
+
problemDetail = ProblemJson.parse(await response.json());
|
|
9
9
|
} catch {
|
|
10
10
|
problemDetail = {
|
|
11
11
|
title: "Invalid response from Wallet Provider"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["parseRawHttpResponse","WalletProviderResponseError","
|
|
1
|
+
{"version":3,"names":["parseRawHttpResponse","WalletProviderResponseError","ProblemJson","createApiClient","createWalletProviderApiClient","validateResponse","response","ok","problemDetail","parse","json","title","message","reason","statusCode","status","getWalletProviderClient","context","walletProviderBaseUrl","appFetch","fetch","method","url","params","interpolateUrl","body","JSON","stringify","undefined","headers","then","path","key","value","Object","entries","replace"],"sourceRoot":"../../../src","sources":["client/index.ts"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,eAAe;AACpD,SAASC,2BAA2B,QAAQ,iBAAiB;AAC7D,SACEC,WAAW,EACXC,eAAe,IAAIC,6BAA6B,QAG3C,6BAA6B;AAMpC,MAAMC,gBAAgB,GAAG,MAAOC,QAAkB,IAAK;EACrD,IAAI,CAACA,QAAQ,CAACC,EAAE,EAAE;IAChB,IAAIC,aAA0B,GAAG,CAAC,CAAC;IACnC,IAAI;MACFA,aAAa,GAAGN,WAAW,CAACO,KAAK,CAAC,MAAMH,QAAQ,CAACI,IAAI,CAAC,CAAC,CAAC;IAC1D,CAAC,CAAC,MAAM;MACNF,aAAa,GAAG;QACdG,KAAK,EAAE;MACT,CAAC;IACH;IAEA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"../../utils/errors";
|
|
2
2
|
import { SdJwt4VC, verify as verifySdJwt } from "../../sd-jwt";
|
|
3
|
-
import { getValueFromDisclosures } from "../../sd-jwt/converters";
|
|
4
3
|
import { isSameThumbprint } from "../../utils/jwk";
|
|
5
|
-
import { verify as verifyMdoc } from "../../mdoc";
|
|
4
|
+
import { getParsedCredentialClaimKey, verify as verifyMdoc } from "../../mdoc";
|
|
6
5
|
import { MDOC_DEFAULT_NAMESPACE } from "../../mdoc/const";
|
|
7
|
-
import { getParsedCredentialClaimKey } from "../../mdoc/utils";
|
|
8
6
|
import { Logger, LogLevel } from "../../utils/logging";
|
|
9
7
|
import { extractElementValueAsDate } from "../../mdoc/converter";
|
|
10
|
-
import {
|
|
8
|
+
import { SDJwtInstance } from "@sd-jwt/core";
|
|
9
|
+
import { digest } from "@sd-jwt/crypto-nodejs";
|
|
10
|
+
import { isPathEqual, isPrefixOf } from "../../utils/parser";
|
|
11
11
|
|
|
12
12
|
// The credential as a collection of attributes in plain value
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Parse a Sd-Jwt credential according to the issuer configuration
|
|
16
|
+
* @param credentialConfig - the list of supported credentials, as defined in the issuer configuration with their claims metadata
|
|
17
|
+
* @param parsedCredentialRaw - the raw parsed credential
|
|
18
|
+
* @param ignoreMissingAttributes - skip error when attributes declared in the issuer configuration are not found within disclosures
|
|
19
|
+
* @param includeUndefinedAttributes - include attributes not explicitly declared in the issuer configuration
|
|
20
|
+
* @returns The parsed credential with attributes in plain value
|
|
21
|
+
*/
|
|
22
|
+
const parseCredentialSdJwt = function (credentialConfig, parsedCredentialRaw) {
|
|
21
23
|
let ignoreMissingAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
22
24
|
let includeUndefinedAttributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
23
|
-
|
|
24
|
-
const message = `Received credential is of an unknown type. Expected one of [${credentialConfig.format}], received '${sdJwt.header.typ}'`;
|
|
25
|
-
Logger.log(LogLevel.ERROR, message);
|
|
26
|
-
throw new IoWalletError(message);
|
|
27
|
-
}
|
|
28
|
-
if (!credentialConfig.claims) {
|
|
29
|
-
Logger.log(LogLevel.ERROR, "Missing claims in the credential subject");
|
|
30
|
-
throw new IoWalletError("Missing claims in the credential subject"); // TODO [SIW-1268]: should not be optional
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const attrDefinitions = credentialConfig.claims;
|
|
25
|
+
const claimsMetadata = credentialConfig.claims || [];
|
|
34
26
|
|
|
35
|
-
//
|
|
27
|
+
// Check that all mandatory attributes defined in the issuer configuration are present in the credential
|
|
36
28
|
if (!ignoreMissingAttributes) {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
|
|
29
|
+
const missingPaths = [];
|
|
30
|
+
const rootKeysToVerify = new Set(claimsMetadata.map(c => c.path[0]).filter(p => typeof p === "string"));
|
|
31
|
+
for (const rootKey of rootKeysToVerify) {
|
|
32
|
+
if (!(rootKey in parsedCredentialRaw)) {
|
|
33
|
+
missingPaths.push(rootKey);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (missingPaths.length > 0) {
|
|
37
|
+
const missing = missingPaths.join(", ");
|
|
38
|
+
const received = Object.keys(parsedCredentialRaw).join(", ");
|
|
39
|
+
throw new IoWalletError(`Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`);
|
|
46
40
|
}
|
|
47
41
|
}
|
|
48
|
-
const definedValues = {};
|
|
49
42
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Helper to find display metadata for any given path
|
|
45
|
+
*/
|
|
46
|
+
const getDisplayNames = path => {
|
|
47
|
+
const match = claimsMetadata.find(c => isPathEqual(c.path, path));
|
|
48
|
+
if (!match) return undefined;
|
|
49
|
+
const nameMap = {};
|
|
50
|
+
for (const entry of match.display) {
|
|
51
|
+
nameMap[entry.locale] = entry.name;
|
|
58
52
|
}
|
|
59
|
-
return
|
|
60
|
-
}
|
|
53
|
+
return nameMap;
|
|
54
|
+
};
|
|
61
55
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Recursive function to build the localized structure
|
|
58
|
+
*/
|
|
59
|
+
const processLevel = (currentData, currentPath) => {
|
|
60
|
+
// Handle Arrays
|
|
61
|
+
if (Array.isArray(currentData)) {
|
|
62
|
+
return currentData.map(item => processLevel(item, [...currentPath, null]));
|
|
67
63
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (!disclosureForThisKey) {
|
|
73
|
-
continue;
|
|
64
|
+
|
|
65
|
+
// Handle Objects
|
|
66
|
+
if (typeof currentData !== "object" || currentData === null) {
|
|
67
|
+
return currentData;
|
|
74
68
|
}
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
path,
|
|
79
|
-
display
|
|
80
|
-
} = _ref4;
|
|
81
|
-
return createNestedProperty(acc, path, disclosureValue, display);
|
|
82
|
-
}, {});
|
|
69
|
+
const dataObj = currentData;
|
|
70
|
+
const result = {};
|
|
71
|
+
const processedKeys = new Set();
|
|
83
72
|
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
73
|
+
// Identify unique keys in config at this level
|
|
74
|
+
const configKeysAtThisLevel = [];
|
|
75
|
+
for (const claim of claimsMetadata) {
|
|
76
|
+
// Check if the claim path starts with the current path
|
|
77
|
+
if (isPrefixOf(currentPath, claim.path)) {
|
|
78
|
+
const nextPart = claim.path[currentPath.length];
|
|
79
|
+
if ((typeof nextPart === "string" || typeof nextPart === "number") && !configKeysAtThisLevel.includes(nextPart)) {
|
|
80
|
+
configKeysAtThisLevel.push(nextPart);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Process keys
|
|
86
|
+
for (const key of configKeysAtThisLevel) {
|
|
87
|
+
const stringKey = key.toString();
|
|
88
|
+
const dataValue = dataObj[stringKey];
|
|
89
|
+
if (dataValue === undefined) continue;
|
|
90
|
+
const newPath = [...currentPath, key];
|
|
91
|
+
let localizedNames = getDisplayNames(newPath);
|
|
92
|
+
|
|
93
|
+
// Fallback for arrays
|
|
94
|
+
if (!localizedNames && Array.isArray(dataValue)) {
|
|
95
|
+
localizedNames = getDisplayNames([...newPath, null]);
|
|
96
|
+
}
|
|
97
|
+
result[stringKey] = {
|
|
98
|
+
name: localizedNames || stringKey,
|
|
99
|
+
value: processLevel(dataValue, newPath)
|
|
100
|
+
};
|
|
101
|
+
processedKeys.add(key);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Handle Undefined Attributes
|
|
105
|
+
if (includeUndefinedAttributes) {
|
|
106
|
+
for (const [key, value] of Object.entries(dataObj)) {
|
|
107
|
+
if (!processedKeys.has(key)) {
|
|
108
|
+
result[key] = {
|
|
109
|
+
name: key,
|
|
110
|
+
value: value
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
};
|
|
117
|
+
return processLevel(parsedCredentialRaw, []);
|
|
103
118
|
};
|
|
104
|
-
const parseCredentialMDoc = function (credentialConfig,
|
|
119
|
+
const parseCredentialMDoc = function (credentialConfig, _ref) {
|
|
105
120
|
let {
|
|
106
121
|
issuerSigned
|
|
107
|
-
} =
|
|
122
|
+
} = _ref;
|
|
108
123
|
let ignoreMissingAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
109
124
|
let includeUndefinedAttributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
110
125
|
if (!credentialConfig) {
|
|
@@ -113,37 +128,37 @@ const parseCredentialMDoc = function (credentialConfig, _ref6) {
|
|
|
113
128
|
if (!credentialConfig.claims) {
|
|
114
129
|
throw new IoWalletError("Missing claims in the credential subject");
|
|
115
130
|
}
|
|
116
|
-
const attrDefinitions = credentialConfig.claims.map(
|
|
131
|
+
const attrDefinitions = credentialConfig.claims.map(_ref2 => {
|
|
117
132
|
let {
|
|
118
133
|
path: [namespace, attribute],
|
|
119
134
|
display
|
|
120
|
-
} =
|
|
135
|
+
} = _ref2;
|
|
121
136
|
return [namespace, attribute, display];
|
|
122
137
|
});
|
|
123
138
|
if (!issuerSigned.nameSpaces) {
|
|
124
139
|
throw new IoWalletError("Missing claims in the credential");
|
|
125
140
|
}
|
|
126
|
-
const flatNamespaces = Object.entries(issuerSigned.nameSpaces).flatMap(
|
|
127
|
-
let [namespace, values] =
|
|
141
|
+
const flatNamespaces = Object.entries(issuerSigned.nameSpaces).flatMap(_ref3 => {
|
|
142
|
+
let [namespace, values] = _ref3;
|
|
128
143
|
return values.map(v => [namespace, v.elementIdentifier, v.elementValue]);
|
|
129
144
|
});
|
|
130
145
|
|
|
131
146
|
// Check that all mandatory attributes defined in the issuer configuration are present in the disclosure set
|
|
132
147
|
// and filter the non present ones
|
|
133
|
-
const attrsNotInDisclosures = attrDefinitions.filter(
|
|
134
|
-
let [attrDefNamespace, attrKey] =
|
|
135
|
-
return !flatNamespaces.some(
|
|
136
|
-
let [namespace, claim] =
|
|
148
|
+
const attrsNotInDisclosures = attrDefinitions.filter(_ref4 => {
|
|
149
|
+
let [attrDefNamespace, attrKey] = _ref4;
|
|
150
|
+
return !flatNamespaces.some(_ref5 => {
|
|
151
|
+
let [namespace, claim] = _ref5;
|
|
137
152
|
return attrDefNamespace === namespace && attrKey === claim;
|
|
138
153
|
});
|
|
139
154
|
});
|
|
140
155
|
if (attrsNotInDisclosures.length > 0) {
|
|
141
|
-
const missing = attrsNotInDisclosures.map(
|
|
142
|
-
let [, attrKey] =
|
|
156
|
+
const missing = attrsNotInDisclosures.map(_ref6 => {
|
|
157
|
+
let [, attrKey] = _ref6;
|
|
143
158
|
return attrKey;
|
|
144
159
|
}).join(", ");
|
|
145
|
-
const received = flatNamespaces.map(
|
|
146
|
-
let [, attrKey] =
|
|
160
|
+
const received = flatNamespaces.map(_ref7 => {
|
|
161
|
+
let [, attrKey] = _ref7;
|
|
147
162
|
return attrKey;
|
|
148
163
|
}).join(", ");
|
|
149
164
|
if (!ignoreMissingAttributes) {
|
|
@@ -154,38 +169,38 @@ const parseCredentialMDoc = function (credentialConfig, _ref6) {
|
|
|
154
169
|
// Attributes defined in the issuer configuration and present in the disclosure set
|
|
155
170
|
const definedValues = attrDefinitions
|
|
156
171
|
// Retrieve the value from the corresponding disclosure
|
|
157
|
-
.map(
|
|
172
|
+
.map(_ref8 => {
|
|
158
173
|
var _flatNamespaces$find;
|
|
159
|
-
let [attrDefNamespace, attrKey, display] =
|
|
174
|
+
let [attrDefNamespace, attrKey, display] = _ref8;
|
|
160
175
|
return [attrDefNamespace, attrKey, {
|
|
161
176
|
display,
|
|
162
|
-
value: (_flatNamespaces$find = flatNamespaces.find(
|
|
163
|
-
let [namespace, name] =
|
|
177
|
+
value: (_flatNamespaces$find = flatNamespaces.find(_ref9 => {
|
|
178
|
+
let [namespace, name] = _ref9;
|
|
164
179
|
return attrDefNamespace === namespace && name === attrKey;
|
|
165
180
|
})) === null || _flatNamespaces$find === void 0 ? void 0 : _flatNamespaces$find[2]
|
|
166
181
|
}];
|
|
167
182
|
})
|
|
168
183
|
//filter the not found elements
|
|
169
|
-
.filter(
|
|
170
|
-
let [_, __, definition] =
|
|
184
|
+
.filter(_ref10 => {
|
|
185
|
+
let [_, __, definition] = _ref10;
|
|
171
186
|
return definition.value !== undefined;
|
|
172
187
|
})
|
|
173
188
|
// Add a human-readable attribute name, with i18n, in the form { locale: name }
|
|
174
189
|
// Example: { "it-IT": "Nome", "en-EN": "Name", "es-ES": "Nombre" }
|
|
175
|
-
.reduce((acc,
|
|
190
|
+
.reduce((acc, _ref11) => {
|
|
176
191
|
let [attrDefNamespace, attrKey, {
|
|
177
192
|
display,
|
|
178
193
|
value
|
|
179
|
-
}] =
|
|
194
|
+
}] = _ref11;
|
|
180
195
|
return {
|
|
181
196
|
...acc,
|
|
182
197
|
[getParsedCredentialClaimKey(attrDefNamespace, attrKey)]: {
|
|
183
198
|
value,
|
|
184
|
-
name: display.reduce((names,
|
|
199
|
+
name: display.reduce((names, _ref12) => {
|
|
185
200
|
let {
|
|
186
201
|
locale,
|
|
187
202
|
name
|
|
188
|
-
} =
|
|
203
|
+
} = _ref12;
|
|
189
204
|
return {
|
|
190
205
|
...names,
|
|
191
206
|
[locale]: name
|
|
@@ -195,11 +210,11 @@ const parseCredentialMDoc = function (credentialConfig, _ref6) {
|
|
|
195
210
|
};
|
|
196
211
|
}, {});
|
|
197
212
|
if (includeUndefinedAttributes) {
|
|
198
|
-
const undefinedValues = Object.fromEntries(Object.values(flatNamespaces).filter(
|
|
199
|
-
let [namespace, key] =
|
|
213
|
+
const undefinedValues = Object.fromEntries(Object.values(flatNamespaces).filter(_ref13 => {
|
|
214
|
+
let [namespace, key] = _ref13;
|
|
200
215
|
return !definedValues[getParsedCredentialClaimKey(namespace, key)];
|
|
201
|
-
}).map(
|
|
202
|
-
let [namespace, key, value] =
|
|
216
|
+
}).map(_ref14 => {
|
|
217
|
+
let [namespace, key, value] = _ref14;
|
|
203
218
|
return [getParsedCredentialClaimKey(namespace, key), {
|
|
204
219
|
value,
|
|
205
220
|
name: key
|
|
@@ -228,6 +243,7 @@ const parseCredentialMDoc = function (credentialConfig, _ref6) {
|
|
|
228
243
|
*
|
|
229
244
|
*/
|
|
230
245
|
async function verifyCredentialSdJwt(rawCredential, issuerKeys, holderBindingContext) {
|
|
246
|
+
// TODO: change verification using sd-jwt library with 1.3.x update
|
|
231
247
|
const [decodedCredential, holderBindingKey] =
|
|
232
248
|
// parallel for optimization
|
|
233
249
|
await Promise.all([verifySdJwt(rawCredential, issuerKeys, SdJwt4VC), holderBindingContext.getPublicKey()]);
|
|
@@ -239,8 +255,12 @@ async function verifyCredentialSdJwt(rawCredential, issuerKeys, holderBindingCon
|
|
|
239
255
|
Logger.log(LogLevel.ERROR, message);
|
|
240
256
|
throw new IoWalletError(message);
|
|
241
257
|
}
|
|
242
|
-
|
|
258
|
+
const sdJwtInstance = new SDJwtInstance({
|
|
259
|
+
hasher: digest
|
|
260
|
+
});
|
|
261
|
+
return await sdJwtInstance.decode(rawCredential);
|
|
243
262
|
}
|
|
263
|
+
|
|
244
264
|
/**
|
|
245
265
|
* Given a credential, verify it's in the supported format
|
|
246
266
|
* and the credential is correctly signed
|
|
@@ -269,12 +289,12 @@ async function verifyCredentialMDoc(rawCredential, x509CertRoot, holderBindingCo
|
|
|
269
289
|
}
|
|
270
290
|
return decodedCredential;
|
|
271
291
|
}
|
|
272
|
-
const verifyAndParseCredentialSdJwt = async (issuerConf, credential, credentialConfigurationId,
|
|
292
|
+
const verifyAndParseCredentialSdJwt = async (issuerConf, credential, credentialConfigurationId, _ref15) => {
|
|
273
293
|
let {
|
|
274
294
|
credentialCryptoContext,
|
|
275
295
|
ignoreMissingAttributes,
|
|
276
296
|
includeUndefinedAttributes
|
|
277
|
-
} =
|
|
297
|
+
} = _ref15;
|
|
278
298
|
const decoded = await verifyCredentialSdJwt(credential, issuerConf.openid_credential_issuer.jwks.keys, credentialCryptoContext);
|
|
279
299
|
Logger.log(LogLevel.DEBUG, `Decoded credential: ${JSON.stringify(decoded)}`);
|
|
280
300
|
const credentialConfig = issuerConf.openid_credential_issuer.credential_configurations_supported[credentialConfigurationId];
|
|
@@ -282,21 +302,26 @@ const verifyAndParseCredentialSdJwt = async (issuerConf, credential, credentialC
|
|
|
282
302
|
Logger.log(LogLevel.ERROR, `Credential type not supported by the issuer: ${credentialConfigurationId}`);
|
|
283
303
|
throw new IoWalletError("Credential type not supported by the issuer");
|
|
284
304
|
}
|
|
285
|
-
const
|
|
286
|
-
const
|
|
287
|
-
|
|
305
|
+
const parsedCredentialRaw = await decoded.getClaims(digest);
|
|
306
|
+
const parsedCredential = parseCredentialSdJwt(credentialConfig, parsedCredentialRaw, ignoreMissingAttributes, includeUndefinedAttributes);
|
|
307
|
+
const issuedAt = typeof parsedCredentialRaw.iat === "number" ? new Date(parsedCredentialRaw.iat * 1000) : undefined;
|
|
308
|
+
if (typeof parsedCredentialRaw.exp !== "number") {
|
|
309
|
+
throw new IoWalletError("Invalid or missing expiration claim (exp)");
|
|
310
|
+
}
|
|
311
|
+
const expiration = new Date(parsedCredentialRaw.exp * 1000);
|
|
312
|
+
Logger.log(LogLevel.DEBUG, `Parsed credential: ${JSON.stringify(parsedCredential)}\nIssued at: ${issuedAt}`);
|
|
288
313
|
return {
|
|
289
314
|
parsedCredential,
|
|
290
|
-
expiration
|
|
291
|
-
issuedAt
|
|
315
|
+
expiration,
|
|
316
|
+
issuedAt
|
|
292
317
|
};
|
|
293
318
|
};
|
|
294
|
-
const verifyAndParseCredentialMDoc = async (issuerConf, credential, credentialConfigurationId,
|
|
319
|
+
const verifyAndParseCredentialMDoc = async (issuerConf, credential, credentialConfigurationId, _ref16, x509CertRoot) => {
|
|
295
320
|
var _parsedCredential$get, _parsedCredential$get2;
|
|
296
321
|
let {
|
|
297
322
|
credentialCryptoContext,
|
|
298
323
|
ignoreMissingAttributes
|
|
299
|
-
} =
|
|
324
|
+
} = _ref16;
|
|
300
325
|
if (!x509CertRoot) {
|
|
301
326
|
throw new IoWalletError("Missing x509CertRoot");
|
|
302
327
|
}
|