@pagopa/io-react-native-wallet 0.11.1 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/client/generated/wallet-provider.js +126 -0
- package/lib/commonjs/client/generated/wallet-provider.js.map +1 -0
- package/lib/commonjs/client/index.js +40 -0
- package/lib/commonjs/client/index.js.map +1 -0
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js +2 -1
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js.map +1 -1
- package/lib/commonjs/credential/issuance/03-start-credential-issuance.js +287 -0
- package/lib/commonjs/credential/issuance/03-start-credential-issuance.js.map +1 -0
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js +56 -83
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +88 -0
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/05-authorize-access.js +56 -33
- package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +51 -78
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +21 -44
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/index.js +7 -0
- package/lib/commonjs/credential/issuance/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/types.js +28 -0
- package/lib/commonjs/credential/issuance/types.js.map +1 -0
- package/lib/commonjs/index.js +10 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/pid/sd-jwt/converters.js +5 -9
- package/lib/commonjs/pid/sd-jwt/converters.js.map +1 -1
- package/lib/commonjs/pid/sd-jwt/types.js +3 -3
- package/lib/commonjs/pid/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/converters.test.js +1 -1
- package/lib/commonjs/sd-jwt/__test__/converters.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/index.test.js +30 -43
- package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/types.test.js +16 -24
- package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/index.js +3 -9
- package/lib/commonjs/sd-jwt/index.js.map +1 -1
- package/lib/commonjs/sd-jwt/types.js +11 -16
- package/lib/commonjs/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/trust/types.js +70 -29
- package/lib/commonjs/trust/types.js.map +1 -1
- package/lib/commonjs/utils/auth.js +44 -0
- package/lib/commonjs/utils/auth.js.map +1 -0
- package/lib/commonjs/utils/errors.js +104 -1
- package/lib/commonjs/utils/errors.js.map +1 -1
- package/lib/commonjs/utils/integrity.js +2 -0
- package/lib/commonjs/utils/integrity.js.map +1 -0
- package/lib/commonjs/utils/misc.js +34 -1
- package/lib/commonjs/utils/misc.js.map +1 -1
- package/lib/commonjs/utils/par.js +23 -15
- package/lib/commonjs/utils/par.js.map +1 -1
- package/lib/commonjs/utils/pop.js +33 -0
- package/lib/commonjs/utils/pop.js.map +1 -0
- package/lib/commonjs/wallet-instance/index.js +29 -0
- package/lib/commonjs/wallet-instance/index.js.map +1 -0
- package/lib/commonjs/wallet-instance-attestation/issuing.js +62 -65
- package/lib/commonjs/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/commonjs/wallet-instance-attestation/types.js +8 -8
- package/lib/commonjs/wallet-instance-attestation/types.js.map +1 -1
- package/lib/module/client/generated/wallet-provider.js +102 -0
- package/lib/module/client/generated/wallet-provider.js.map +1 -0
- package/lib/module/client/index.js +33 -0
- package/lib/module/client/index.js.map +1 -0
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js +2 -1
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js.map +1 -1
- package/lib/module/credential/issuance/03-start-credential-issuance.js +276 -0
- package/lib/module/credential/issuance/03-start-credential-issuance.js.map +1 -0
- package/lib/module/credential/issuance/03-start-user-authorization.js +56 -80
- package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js +85 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/05-authorize-access.js +54 -33
- package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +50 -75
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +21 -44
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/credential/issuance/index.js +2 -1
- package/lib/module/credential/issuance/index.js.map +1 -1
- package/lib/module/credential/issuance/types.js +18 -0
- package/lib/module/credential/issuance/types.js.map +1 -0
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/pid/sd-jwt/converters.js +5 -9
- package/lib/module/pid/sd-jwt/converters.js.map +1 -1
- package/lib/module/pid/sd-jwt/types.js +3 -3
- package/lib/module/pid/sd-jwt/types.js.map +1 -1
- package/lib/module/sd-jwt/__test__/converters.test.js +1 -1
- package/lib/module/sd-jwt/__test__/converters.test.js.map +1 -1
- package/lib/module/sd-jwt/__test__/index.test.js +30 -43
- package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/module/sd-jwt/__test__/types.test.js +16 -24
- package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/module/sd-jwt/index.js +3 -9
- package/lib/module/sd-jwt/index.js.map +1 -1
- package/lib/module/sd-jwt/types.js +11 -16
- package/lib/module/sd-jwt/types.js.map +1 -1
- package/lib/module/trust/types.js +70 -29
- package/lib/module/trust/types.js.map +1 -1
- package/lib/module/utils/auth.js +35 -0
- package/lib/module/utils/auth.js.map +1 -0
- package/lib/module/utils/errors.js +98 -0
- package/lib/module/utils/errors.js.map +1 -1
- package/lib/module/utils/integrity.js +2 -0
- package/lib/module/utils/integrity.js.map +1 -0
- package/lib/module/utils/misc.js +31 -0
- package/lib/module/utils/misc.js.map +1 -1
- package/lib/module/utils/par.js +24 -16
- package/lib/module/utils/par.js.map +1 -1
- package/lib/module/utils/pop.js +24 -0
- package/lib/module/utils/pop.js.map +1 -0
- package/lib/module/wallet-instance/index.js +23 -0
- package/lib/module/wallet-instance/index.js.map +1 -0
- package/lib/module/wallet-instance-attestation/issuing.js +63 -67
- package/lib/module/wallet-instance-attestation/issuing.js.map +1 -1
- package/lib/module/wallet-instance-attestation/types.js +8 -8
- package/lib/module/wallet-instance-attestation/types.js.map +1 -1
- package/lib/typescript/client/generated/wallet-provider.d.ts +264 -0
- package/lib/typescript/client/generated/wallet-provider.d.ts.map +1 -0
- package/lib/typescript/client/index.d.ts +7 -0
- package/lib/typescript/client/index.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/01-start-flow.d.ts +1 -0
- package/lib/typescript/credential/issuance/01-start-flow.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts +2 -1
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/03-start-credential-issuance.d.ts +41 -0
- package/lib/typescript/credential/issuance/03-start-credential-issuance.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +23 -18
- 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 +24 -12
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts +22 -16
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +19 -26
- 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 +10 -15
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/index.d.ts +3 -4
- package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/types.d.ts +63 -0
- package/lib/typescript/credential/issuance/types.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/types.d.ts +6 -6
- package/lib/typescript/index.d.ts +6 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/pid/sd-jwt/converters.d.ts.map +1 -1
- package/lib/typescript/pid/sd-jwt/types.d.ts +36 -36
- package/lib/typescript/pid/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/index.d.ts +40 -68
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/types.d.ts +64 -121
- package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/trust/index.d.ts +150 -48
- package/lib/typescript/trust/index.d.ts.map +1 -1
- package/lib/typescript/trust/types.d.ts +2838 -1740
- package/lib/typescript/trust/types.d.ts.map +1 -1
- package/lib/typescript/utils/auth.d.ts +52 -0
- package/lib/typescript/utils/auth.d.ts.map +1 -0
- package/lib/typescript/utils/errors.d.ts +48 -0
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/utils/integrity.d.ts +21 -0
- package/lib/typescript/utils/integrity.d.ts.map +1 -0
- package/lib/typescript/utils/misc.d.ts +18 -0
- package/lib/typescript/utils/misc.d.ts.map +1 -1
- package/lib/typescript/utils/par.d.ts +8 -31
- package/lib/typescript/utils/par.d.ts.map +1 -1
- package/lib/typescript/utils/pop.d.ts +26 -0
- package/lib/typescript/utils/pop.d.ts.map +1 -0
- package/lib/typescript/wallet-instance/index.d.ts +7 -0
- package/lib/typescript/wallet-instance/index.d.ts.map +1 -0
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts +17 -4
- package/lib/typescript/wallet-instance-attestation/issuing.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/types.d.ts +64 -64
- package/lib/typescript/wallet-instance-attestation/types.d.ts.map +1 -1
- package/package.json +9 -5
- package/src/client/generated/wallet-provider.ts +173 -0
- package/src/client/index.ts +53 -0
- package/src/credential/issuance/01-start-flow.ts +1 -0
- package/src/credential/issuance/02-evaluate-issuer-trust.ts +2 -1
- package/src/credential/issuance/03-start-credential-issuance.ts +407 -0
- package/src/credential/issuance/03-start-user-authorization.ts +91 -92
- package/src/credential/issuance/04-complete-user-authorization.ts +114 -13
- package/src/credential/issuance/05-authorize-access.ts +74 -49
- package/src/credential/issuance/06-obtain-credential.ts +77 -111
- package/src/credential/issuance/07-verify-and-parse-credential.ts +30 -67
- package/src/credential/issuance/index.ts +6 -4
- package/src/credential/issuance/types.ts +25 -0
- package/src/index.ts +8 -0
- package/src/pid/sd-jwt/converters.ts +5 -11
- package/src/pid/sd-jwt/types.ts +8 -6
- package/src/sd-jwt/__test__/converters.test.ts +1 -1
- package/src/sd-jwt/__test__/index.test.ts +45 -74
- package/src/sd-jwt/__test__/types.test.ts +21 -33
- package/src/sd-jwt/index.ts +3 -12
- package/src/sd-jwt/types.ts +17 -22
- package/src/trust/types.ts +64 -32
- package/src/utils/auth.ts +37 -0
- package/src/utils/errors.ts +112 -0
- package/src/utils/integrity.ts +23 -0
- package/src/utils/misc.ts +43 -0
- package/src/utils/par.ts +29 -17
- package/src/utils/pop.ts +34 -0
- package/src/wallet-instance/index.ts +29 -0
- package/src/wallet-instance-attestation/issuing.ts +101 -97
- package/src/wallet-instance-attestation/types.ts +12 -8
- package/lib/commonjs/credential/issuance/07-confirm-credential.js +0 -6
- package/lib/commonjs/credential/issuance/07-confirm-credential.js.map +0 -1
- package/lib/commonjs/credential/issuance/08-confirm-credential.js +0 -6
- package/lib/commonjs/credential/issuance/08-confirm-credential.js.map +0 -1
- package/lib/module/credential/issuance/07-confirm-credential.js +0 -2
- package/lib/module/credential/issuance/07-confirm-credential.js.map +0 -1
- package/lib/module/credential/issuance/08-confirm-credential.js +0 -2
- package/lib/module/credential/issuance/08-confirm-credential.js.map +0 -1
- package/lib/typescript/credential/issuance/07-confirm-credential.d.ts +0 -11
- package/lib/typescript/credential/issuance/07-confirm-credential.d.ts.map +0 -1
- package/lib/typescript/credential/issuance/08-confirm-credential.d.ts +0 -11
- package/lib/typescript/credential/issuance/08-confirm-credential.d.ts.map +0 -1
- package/src/credential/issuance/07-confirm-credential.ts +0 -14
- package/src/credential/issuance/08-confirm-credential.ts +0 -14
@@ -1,11 +1,11 @@
|
|
1
1
|
import type { Out } from "../../utils/misc";
|
2
2
|
import type { EvaluateIssuerTrust } from "./02-evaluate-issuer-trust";
|
3
|
-
import type { ObtainCredential } from "./06-obtain-credential";
|
4
3
|
import { IoWalletError } from "../../utils/errors";
|
5
4
|
import { SdJwt4VC } from "../../sd-jwt/types";
|
6
5
|
import { verify as verifySdJwt } from "../../sd-jwt";
|
7
6
|
import type { JWK } from "../../utils/jwk";
|
8
7
|
import type { CryptoContext } from "@pagopa/io-react-native-jwt";
|
8
|
+
import type { ObtainCredential } from "./06-obtain-credential";
|
9
9
|
|
10
10
|
export type VerifyAndParseCredential = (
|
11
11
|
issuerConf: Out<EvaluateIssuerTrust>["issuerConf"],
|
@@ -13,7 +13,6 @@ export type VerifyAndParseCredential = (
|
|
13
13
|
format: Out<ObtainCredential>["format"],
|
14
14
|
context: {
|
15
15
|
credentialCryptoContext: CryptoContext;
|
16
|
-
ignoreMissingAttributes?: boolean;
|
17
16
|
}
|
18
17
|
) => Promise<{ parsedCredential: ParsedCredential }>;
|
19
18
|
|
@@ -28,9 +27,8 @@ type ParsedCredential = Record<
|
|
28
27
|
string /* locale */,
|
29
28
|
string /* value */
|
30
29
|
>
|
31
|
-
| /* if no i18n is provided */ string
|
32
|
-
|
33
|
-
mandatory: boolean;
|
30
|
+
| /* if no i18n is provided */ string
|
31
|
+
| undefined; // Add undefined as a possible value for the name property
|
34
32
|
/** The actual value of the attribute */
|
35
33
|
value: unknown;
|
36
34
|
}
|
@@ -43,48 +41,34 @@ type DecodedSdJwtCredential = Out<typeof verifySdJwt> & {
|
|
43
41
|
|
44
42
|
const parseCredentialSdJwt = (
|
45
43
|
// the list of supported credentials, as defined in the issuer configuration
|
46
|
-
credentials_supported: Out<EvaluateIssuerTrust>["issuerConf"]["openid_credential_issuer"]["
|
47
|
-
{ sdJwt, disclosures }: DecodedSdJwtCredential
|
48
|
-
ignoreMissingAttributes: boolean = false
|
44
|
+
credentials_supported: Out<EvaluateIssuerTrust>["issuerConf"]["openid_credential_issuer"]["credential_configurations_supported"],
|
45
|
+
{ sdJwt, disclosures }: DecodedSdJwtCredential
|
49
46
|
): ParsedCredential => {
|
50
|
-
|
51
|
-
|
52
|
-
const credentialSubject = credentials_supported.find(
|
53
|
-
(c) =>
|
54
|
-
c.format === "vc+sd-jwt" &&
|
55
|
-
c.credential_definition.type.includes(sdJwt.payload.type)
|
56
|
-
)?.credential_definition.credentialSubject;
|
57
|
-
|
58
|
-
// the received credential matches no supported credential, throw an exception
|
47
|
+
const credentialSubject = credentials_supported[sdJwt.payload.vct];
|
48
|
+
|
59
49
|
if (!credentialSubject) {
|
60
|
-
|
61
|
-
|
62
|
-
|
50
|
+
throw new IoWalletError("Credential type not supported by the issuer");
|
51
|
+
}
|
52
|
+
|
53
|
+
if (credentialSubject.format !== sdJwt.header.typ) {
|
63
54
|
throw new IoWalletError(
|
64
|
-
`Received credential is of an unknwown type. Expected one of [${
|
55
|
+
`Received credential is of an unknwown type. Expected one of [${credentialSubject.format}], received '${sdJwt.header.typ}', `
|
65
56
|
);
|
66
57
|
}
|
67
58
|
|
68
59
|
// transfrom a record { key: value } in an iterable of pairs [key, value]
|
69
|
-
const attrDefinitions = Object.entries(credentialSubject);
|
60
|
+
const attrDefinitions = Object.entries(credentialSubject.claims);
|
70
61
|
|
71
|
-
// every mandatory attribute must be present in the credential's disclosures
|
72
62
|
// the key of the attribute defintion must match the disclosure's name
|
73
63
|
const attrsNotInDisclosures = attrDefinitions.filter(
|
74
|
-
([attrKey
|
75
|
-
mandatory && !disclosures.some(([, name]) => name === attrKey)
|
64
|
+
([attrKey]) => !disclosures.some(([, name]) => name === attrKey)
|
76
65
|
);
|
77
66
|
if (attrsNotInDisclosures.length > 0) {
|
78
67
|
const missing = attrsNotInDisclosures.map((_) => _[0 /* key */]).join(", ");
|
79
68
|
const received = disclosures.map((_) => _[1 /* name */]).join(", ");
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
if (!ignoreMissingAttributes) {
|
84
|
-
throw new IoWalletError(
|
85
|
-
`Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`
|
86
|
-
);
|
87
|
-
}
|
69
|
+
throw new IoWalletError(
|
70
|
+
`Some attributes are missing in the credential. Missing: [${missing}], received: [${received}]`
|
71
|
+
);
|
88
72
|
}
|
89
73
|
|
90
74
|
// attributes that are defined in the issuer configuration
|
@@ -126,7 +110,7 @@ const parseCredentialSdJwt = (
|
|
126
110
|
const undefinedValues = Object.fromEntries(
|
127
111
|
disclosures
|
128
112
|
.filter((_) => !Object.keys(definedValues).includes(_[1]))
|
129
|
-
.map(([, key, value]) => [key, { value,
|
113
|
+
.map(([, key, value]) => [key, { value, name: key }])
|
130
114
|
);
|
131
115
|
|
132
116
|
return {
|
@@ -185,7 +169,7 @@ const verifyAndParseCredentialSdJwt: WithFormat<"vc+sd-jwt"> = async (
|
|
185
169
|
issuerConf,
|
186
170
|
credential,
|
187
171
|
_,
|
188
|
-
{ credentialCryptoContext
|
172
|
+
{ credentialCryptoContext }
|
189
173
|
) => {
|
190
174
|
const decoded = await verifyCredentialSdJwt(
|
191
175
|
credential,
|
@@ -194,36 +178,23 @@ const verifyAndParseCredentialSdJwt: WithFormat<"vc+sd-jwt"> = async (
|
|
194
178
|
);
|
195
179
|
|
196
180
|
const parsedCredential = parseCredentialSdJwt(
|
197
|
-
issuerConf.openid_credential_issuer.
|
198
|
-
decoded
|
199
|
-
ignoreMissingAttributes
|
181
|
+
issuerConf.openid_credential_issuer.credential_configurations_supported,
|
182
|
+
decoded
|
200
183
|
);
|
201
184
|
|
202
185
|
return { parsedCredential };
|
203
186
|
};
|
204
187
|
|
205
|
-
const verifyAndParseCredentialMdoc: WithFormat<"vc+mdoc-cbor"> = async (
|
206
|
-
_issuerConf,
|
207
|
-
_credential,
|
208
|
-
_,
|
209
|
-
_ctx
|
210
|
-
) => {
|
211
|
-
// TODO: [SIW-686] decode MDOC credentials
|
212
|
-
throw new Error("verifyAndParseCredentialMdoc not implemented yet");
|
213
|
-
};
|
214
|
-
|
215
188
|
/**
|
216
|
-
* Verify and parse an encoded credential
|
217
|
-
*
|
218
|
-
* @param
|
219
|
-
* @param
|
220
|
-
* @param
|
221
|
-
* @param context.credentialCryptoContext The context to access the key the Credential will be bound to
|
222
|
-
* @param context.ignoreMissingAttributes (optional) Whether to fail if a defined attribute is note present in the credentual. Default: false
|
189
|
+
* Verify and parse an encoded credential.
|
190
|
+
* @param issuerConf The Issuer configuration returned by {@link evaluateIssuerTrust}
|
191
|
+
* @param credential The encoded credential returned by {@link obtainCredential}
|
192
|
+
* @param format The format of the credentual returned by {@link obtainCredential}
|
193
|
+
* @param context.credentialCryptoContext The crypto context used to obtain the credential in {@link obtainCredential}
|
223
194
|
* @returns A parsed credential with attributes in plain value
|
224
|
-
* @throws If the credential signature is not verified with the Issuer key set
|
225
|
-
* @throws If the credential is not bound to the provided user key
|
226
|
-
* @throws If the credential data fail to parse
|
195
|
+
* @throws {IoWalletError} If the credential signature is not verified with the Issuer key set
|
196
|
+
* @throws {IoWalletError} If the credential is not bound to the provided user key
|
197
|
+
* @throws {IoWalletError} If the credential data fail to parse
|
227
198
|
*/
|
228
199
|
export const verifyAndParseCredential: VerifyAndParseCredential = async (
|
229
200
|
issuerConf,
|
@@ -238,15 +209,7 @@ export const verifyAndParseCredential: VerifyAndParseCredential = async (
|
|
238
209
|
format,
|
239
210
|
context
|
240
211
|
);
|
241
|
-
} else if (format === "vc+mdoc-cbor") {
|
242
|
-
return verifyAndParseCredentialMdoc(
|
243
|
-
issuerConf,
|
244
|
-
credential,
|
245
|
-
format,
|
246
|
-
context
|
247
|
-
);
|
248
212
|
}
|
249
213
|
|
250
|
-
|
251
|
-
throw new IoWalletError(`Unsupported credential format: ${_}`);
|
214
|
+
throw new IoWalletError(`Unsupported credential format: ${format}`);
|
252
215
|
};
|
@@ -7,7 +7,10 @@ import {
|
|
7
7
|
startUserAuthorization,
|
8
8
|
type StartUserAuthorization,
|
9
9
|
} from "./03-start-user-authorization";
|
10
|
-
import {
|
10
|
+
import {
|
11
|
+
completeUserAuthorizationWithQueryMode,
|
12
|
+
type CompleteUserAuthorizationWithQueryMode,
|
13
|
+
} from "./04-complete-user-authorization";
|
11
14
|
import { authorizeAccess, type AuthorizeAccess } from "./05-authorize-access";
|
12
15
|
import {
|
13
16
|
obtainCredential,
|
@@ -17,11 +20,11 @@ import {
|
|
17
20
|
verifyAndParseCredential,
|
18
21
|
type VerifyAndParseCredential,
|
19
22
|
} from "./07-verify-and-parse-credential";
|
20
|
-
import type { ConfirmCredential } from "./08-confirm-credential";
|
21
23
|
|
22
24
|
export {
|
23
25
|
evaluateIssuerTrust,
|
24
26
|
startUserAuthorization,
|
27
|
+
completeUserAuthorizationWithQueryMode,
|
25
28
|
authorizeAccess,
|
26
29
|
obtainCredential,
|
27
30
|
verifyAndParseCredential,
|
@@ -30,9 +33,8 @@ export type {
|
|
30
33
|
StartFlow,
|
31
34
|
EvaluateIssuerTrust,
|
32
35
|
StartUserAuthorization,
|
33
|
-
|
36
|
+
CompleteUserAuthorizationWithQueryMode,
|
34
37
|
AuthorizeAccess,
|
35
38
|
ObtainCredential,
|
36
39
|
VerifyAndParseCredential,
|
37
|
-
ConfirmCredential,
|
38
40
|
};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { AuthorizationDetail } from "../../utils/par";
|
2
|
+
import * as z from "zod";
|
3
|
+
import { SupportedCredentialFormat } from "./const";
|
4
|
+
|
5
|
+
export type TokenResponse = z.infer<typeof TokenResponse>;
|
6
|
+
|
7
|
+
export const TokenResponse = z.object({
|
8
|
+
access_token: z.string(),
|
9
|
+
authorization_details: z.array(AuthorizationDetail),
|
10
|
+
c_nonce: z.string(),
|
11
|
+
c_nonce_expires_in: z.number(),
|
12
|
+
expires_in: z.number(),
|
13
|
+
token_type: z.string(),
|
14
|
+
});
|
15
|
+
|
16
|
+
export type CredentialResponse = z.infer<typeof CredentialResponse>;
|
17
|
+
|
18
|
+
export const CredentialResponse = z.object({
|
19
|
+
c_nonce: z.string(),
|
20
|
+
c_nonce_expires_in: z.number(),
|
21
|
+
credential: z.string(),
|
22
|
+
format: SupportedCredentialFormat,
|
23
|
+
});
|
24
|
+
|
25
|
+
export type ResponseMode = "query" | "form_post.jwt";
|
package/src/index.ts
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
import type { AuthorizationContext } from "./utils/auth";
|
2
|
+
import { fixBase64EncodingOnKey } from "./utils/jwk";
|
1
3
|
// polyfill due to known bugs on URL implementation for react native
|
2
4
|
// https://github.com/facebook/react-native/issues/24428
|
3
5
|
import "react-native-url-polyfill/auto";
|
@@ -8,17 +10,23 @@ import * as SdJwt from "./sd-jwt";
|
|
8
10
|
import * as Errors from "./utils/errors";
|
9
11
|
import * as WalletInstanceAttestation from "./wallet-instance-attestation";
|
10
12
|
import * as Trust from "./trust";
|
13
|
+
import * as WalletInstance from "./wallet-instance";
|
11
14
|
import { AuthorizationDetail, AuthorizationDetails } from "./utils/par";
|
12
15
|
import { createCryptoContextFor } from "./utils/crypto";
|
16
|
+
import type { IntegrityContext } from "./utils/integrity";
|
13
17
|
|
14
18
|
export {
|
15
19
|
SdJwt,
|
16
20
|
PID,
|
17
21
|
Credential,
|
18
22
|
WalletInstanceAttestation,
|
23
|
+
WalletInstance,
|
19
24
|
Errors,
|
20
25
|
Trust,
|
21
26
|
createCryptoContextFor,
|
22
27
|
AuthorizationDetail,
|
23
28
|
AuthorizationDetails,
|
29
|
+
fixBase64EncodingOnKey,
|
24
30
|
};
|
31
|
+
|
32
|
+
export type { IntegrityContext, AuthorizationContext };
|
@@ -3,24 +3,18 @@ import type { Disclosure, SdJwt4VC } from "../../sd-jwt/types";
|
|
3
3
|
import { PID } from "./types";
|
4
4
|
|
5
5
|
export function pidFromToken(sdJwt: SdJwt4VC, disclosures: Disclosure[]): PID {
|
6
|
+
const placeOfBirth = getValueFromDisclosures(disclosures, "place_of_birth");
|
6
7
|
return PID.parse({
|
7
8
|
issuer: sdJwt.payload.iss,
|
8
|
-
issuedAt: new Date(
|
9
|
+
issuedAt: new Date(getValueFromDisclosures(disclosures, "iat") * 1000),
|
9
10
|
expiration: new Date(sdJwt.payload.exp * 1000),
|
10
|
-
verification: {
|
11
|
-
trustFramework:
|
12
|
-
sdJwt.payload.verified_claims.verification.trust_framework,
|
13
|
-
assuranceLevel:
|
14
|
-
sdJwt.payload.verified_claims.verification.assurance_level,
|
15
|
-
evidence: getValueFromDisclosures(disclosures, "evidence"),
|
16
|
-
},
|
17
11
|
claims: {
|
18
12
|
uniqueId: getValueFromDisclosures(disclosures, "unique_id"),
|
19
13
|
givenName: getValueFromDisclosures(disclosures, "given_name"),
|
20
14
|
familyName: getValueFromDisclosures(disclosures, "family_name"),
|
21
|
-
|
22
|
-
placeOfBirth
|
23
|
-
taxIdCode: getValueFromDisclosures(disclosures, "
|
15
|
+
birthDate: getValueFromDisclosures(disclosures, "birth_date"),
|
16
|
+
...(placeOfBirth && placeOfBirth),
|
17
|
+
taxIdCode: getValueFromDisclosures(disclosures, "tax_id_code"),
|
24
18
|
},
|
25
19
|
});
|
26
20
|
}
|
package/src/pid/sd-jwt/types.ts
CHANGED
@@ -29,16 +29,18 @@ export const PID = z.object({
|
|
29
29
|
issuer: z.string(),
|
30
30
|
issuedAt: z.date(),
|
31
31
|
expiration: z.date(),
|
32
|
-
verification: Verification,
|
32
|
+
verification: Verification.optional(),
|
33
33
|
claims: z.object({
|
34
34
|
uniqueId: z.string(),
|
35
35
|
givenName: z.string(),
|
36
36
|
familyName: z.string(),
|
37
|
-
|
38
|
-
placeOfBirth: z
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
birthDate: z.string(),
|
38
|
+
placeOfBirth: z
|
39
|
+
.object({
|
40
|
+
country: z.string(),
|
41
|
+
locality: z.string(),
|
42
|
+
})
|
43
|
+
.optional(),
|
42
44
|
taxIdCode: z.string(),
|
43
45
|
}),
|
44
46
|
});
|
@@ -3,7 +3,7 @@ import { Disclosure } from "../types";
|
|
3
3
|
|
4
4
|
const disclosures: Disclosure[] = [
|
5
5
|
["6w1_soRXFgaHKfpYn3cvfQ", "given_name", "Mario"],
|
6
|
-
["fuNp97Hf3wV6y48y-QZhIg", "
|
6
|
+
["fuNp97Hf3wV6y48y-QZhIg", "birth_date", "1980-10-01"],
|
7
7
|
[
|
8
8
|
"p-9LzyWHZBVDvhXDWkN2xA",
|
9
9
|
"place_of_birth",
|
@@ -13,99 +13,70 @@ import { SdJwt4VC } from "../types";
|
|
13
13
|
// - "address" is used as verification._sd
|
14
14
|
// - all others disclosures are in claims._sd
|
15
15
|
const token =
|
16
|
-
"
|
16
|
+
"eyJraWQiOiItRl82VWdhOG4zVmVnalkyVTdZVUhLMXpMb2FELU5QVGM2M1JNSVNuTGF3IiwidHlwIjoidmMrc2Qtand0IiwiYWxnIjoiRVMyNTYifQ.eyJfc2QiOlsiMHExRDVKbWF2NnBRYUVoX0pfRmN2X3VOTk1RSWdDeWhRT3hxbFk0bDNxVSIsIktDSi1BVk52ODhkLXhqNnNVSUFPSnhGbmJVaDNySFhES2tJSDFsRnFiUnMiLCJNOWxvOVl4RE5JWHJBcTJxV2VpQ0E0MHpwSl96WWZGZFJfNEFFQUxjUnRVIiwiY3pnalVrMG5xUkNzd1NoQ2hDamRTNkExLXY0N2RfcVRDU0ZJdklIaE1vSSIsIm5HblFyN2NsbTN0ZlRwOHlqTF91SHJEU090elIyUFZiOFM3R2VMZEFxQlEiLCJ4TklWd2xwU3NhWjhDSlNmMGd6NXhfNzVWUldXYzZWMW1scGVqZENycVVzIl0sInN1YiI6IjIxNmY4OTQ2LTllY2ItNDgxOS05MzA5LWMwNzZmMzRhN2UxMSIsIl9zZF9hbGciOiJzaGEtMjU2IiwidmN0IjoiUGVyc29uSWRlbnRpZmljYXRpb25EYXRhIiwiaXNzIjoiaHR0cHM6Ly9wcmUuZWlkLndhbGxldC5pcHpzLml0IiwiY25mIjp7Imp3ayI6eyJrdHkiOiJFQyIsImNydiI6IlAtMjU2Iiwia2lkIjoiUnYzVy1FaUtwdkJUeWs1eVp4dnJldi03TURCNlNselVDQm9fQ1FqamRkVSIsIngiOiIwV294N1F0eVBxQnlnMzVNSF9YeUNjbmQ1TGUtSm0wQVhIbFVnREJBMDNZIiwieSI6ImVFaFZ2ZzFKUHFOZDNEVFNhNG1HREdCbHdZNk5QLUVaYkxiTkZYU1h3SWcifX0sImV4cCI6MTc1MTU0NjU3Niwic3RhdHVzIjp7InN0YXR1c19hdHRlc3RhdGlvbiI6eyJjcmVkZW50aWFsX2hhc2hfYWxnIjoic2hhLTI1NiJ9fX0.qXHA2oqr8trX4fGxpxpUft2GX380TM3pzfo1MYAsDjUC8HsODA-4rdRWAvDe2zYP57x4tJU7eiABkd1Kmln9yQ~WyJrSkRFUDhFYU5URU1CRE9aelp6VDR3IiwidW5pcXVlX2lkIiwiVElOSVQtTFZMREFBODVUNTBHNzAyQiJd~WyJ6SUF5VUZ2UGZJcEUxekJxeEk1aGFRIiwiYmlydGhfZGF0ZSIsIjE5ODUtMTItMTAiXQ~WyJHcjNSM3MyOTBPa1FVbS1ORlR1OTZBIiwidGF4X2lkX2NvZGUiLCJUSU5JVC1MVkxEQUE4NVQ1MEc3MDJCIl0~WyJHeE9SYWxNQWVsZlowZWRGSmpqWVV3IiwiZ2l2ZW5fbmFtZSIsIkFkYSJd~WyJfdlY1UklrbDBJT0VYS290czlrdDF3IiwiZmFtaWx5X25hbWUiLCJMb3ZlbGFjZSJd~WyJDajV0Y2NSNzJKd3J6ZTJUVzRhLXdnIiwiaWF0IiwxNzIwMDEwNTc1XQ";
|
17
17
|
|
18
18
|
const unsigned =
|
19
|
-
"
|
19
|
+
"eyJraWQiOiItRl82VWdhOG4zVmVnalkyVTdZVUhLMXpMb2FELU5QVGM2M1JNSVNuTGF3IiwidHlwIjoidmMrc2Qtand0IiwiYWxnIjoiRVMyNTYifQ.eyJfc2QiOlsiMHExRDVKbWF2NnBRYUVoX0pfRmN2X3VOTk1RSWdDeWhRT3hxbFk0bDNxVSIsIktDSi1BVk52ODhkLXhqNnNVSUFPSnhGbmJVaDNySFhES2tJSDFsRnFiUnMiLCJNOWxvOVl4RE5JWHJBcTJxV2VpQ0E0MHpwSl96WWZGZFJfNEFFQUxjUnRVIiwiY3pnalVrMG5xUkNzd1NoQ2hDamRTNkExLXY0N2RfcVRDU0ZJdklIaE1vSSIsIm5HblFyN2NsbTN0ZlRwOHlqTF91SHJEU090elIyUFZiOFM3R2VMZEFxQlEiLCJ4TklWd2xwU3NhWjhDSlNmMGd6NXhfNzVWUldXYzZWMW1scGVqZENycVVzIl0sInN1YiI6IjIxNmY4OTQ2LTllY2ItNDgxOS05MzA5LWMwNzZmMzRhN2UxMSIsIl9zZF9hbGciOiJzaGEtMjU2IiwidmN0IjoiUGVyc29uSWRlbnRpZmljYXRpb25EYXRhIiwiaXNzIjoiaHR0cHM6Ly9wcmUuZWlkLndhbGxldC5pcHpzLml0IiwiY25mIjp7Imp3ayI6eyJrdHkiOiJFQyIsImNydiI6IlAtMjU2Iiwia2lkIjoiUnYzVy1FaUtwdkJUeWs1eVp4dnJldi03TURCNlNselVDQm9fQ1FqamRkVSIsIngiOiIwV294N1F0eVBxQnlnMzVNSF9YeUNjbmQ1TGUtSm0wQVhIbFVnREJBMDNZIiwieSI6ImVFaFZ2ZzFKUHFOZDNEVFNhNG1HREdCbHdZNk5QLUVaYkxiTkZYU1h3SWcifX0sImV4cCI6MTc1MTU0NjU3Niwic3RhdHVzIjp7InN0YXR1c19hdHRlc3RhdGlvbiI6eyJjcmVkZW50aWFsX2hhc2hfYWxnIjoic2hhLTI1NiJ9fX0";
|
20
20
|
|
21
21
|
const signature =
|
22
|
-
"
|
22
|
+
"qXHA2oqr8trX4fGxpxpUft2GX380TM3pzfo1MYAsDjUC8HsODA-4rdRWAvDe2zYP57x4tJU7eiABkd1Kmln9yQ";
|
23
23
|
|
24
24
|
const signed = `${unsigned}.${signature}`;
|
25
25
|
|
26
26
|
const tokenizedDisclosures = [
|
27
|
-
"
|
28
|
-
"
|
29
|
-
"
|
30
|
-
"
|
31
|
-
"
|
32
|
-
"
|
33
|
-
"WyJHMDJOU3JRZmpGWFE3SW8wOXN5YWpBIiwgImlzX292ZXJfMjEiLCB0cnVlXQ",
|
34
|
-
"WyJsa2x4RjVqTVlsR1RQVW92TU5JdkNBIiwgImlzX292ZXJfNjUiLCB0cnVlXQ",
|
35
|
-
"WyJRZ19PNjR6cUF4ZTQxMmExMDhpcm9BIiwgImFkZHJlc3MiLCB7InN0cmVldF9hZGRyZXNzIjogIjEyMyBNYWluIFN0IiwgImxvY2FsaXR5IjogIkFueXRvd24iLCAicmVnaW9uIjogIkFueXN0YXRlIiwgImNvdW50cnkiOiAiVVMifV0",
|
27
|
+
"WyJrSkRFUDhFYU5URU1CRE9aelp6VDR3IiwidW5pcXVlX2lkIiwiVElOSVQtTFZMREFBODVUNTBHNzAyQiJd",
|
28
|
+
"WyJ6SUF5VUZ2UGZJcEUxekJxeEk1aGFRIiwiYmlydGhfZGF0ZSIsIjE5ODUtMTItMTAiXQ",
|
29
|
+
"WyJHcjNSM3MyOTBPa1FVbS1ORlR1OTZBIiwidGF4X2lkX2NvZGUiLCJUSU5JVC1MVkxEQUE4NVQ1MEc3MDJCIl0",
|
30
|
+
"WyJHeE9SYWxNQWVsZlowZWRGSmpqWVV3IiwiZ2l2ZW5fbmFtZSIsIkFkYSJd",
|
31
|
+
"WyJfdlY1UklrbDBJT0VYS290czlrdDF3IiwiZmFtaWx5X25hbWUiLCJMb3ZlbGFjZSJd",
|
32
|
+
"WyJDajV0Y2NSNzJKd3J6ZTJUVzRhLXdnIiwiaWF0IiwxNzIwMDEwNTc1XQ",
|
36
33
|
];
|
37
34
|
|
38
35
|
const sdJwt = {
|
39
36
|
header: {
|
37
|
+
kid: "-F_6Uga8n3VegjY2U7YUHK1zLoaD-NPTc63RMISnLaw",
|
40
38
|
typ: "vc+sd-jwt",
|
41
39
|
alg: "ES256",
|
42
|
-
kid: "b186ea0c1925793097bf01b8a289a45f",
|
43
|
-
trust_chain: [
|
44
|
-
"NEhRdERpYnlHY3M5WldWTWZ2aUhm ...",
|
45
|
-
"eyJhbGciOiJSUzI1NiIsImtpZCI6 ...",
|
46
|
-
"IkJYdmZybG5oQU11SFIwN2FqVW1B ...",
|
47
|
-
],
|
48
40
|
},
|
49
41
|
payload: {
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
42
|
+
_sd: [
|
43
|
+
"0q1D5Jmav6pQaEh_J_Fcv_uNNMQIgCyhQOxqlY4l3qU",
|
44
|
+
"KCJ-AVNv88d-xj6sUIAOJxFnbUh3rHXDKkIH1lFqbRs",
|
45
|
+
"M9lo9YxDNIXrAq2qWeiCA40zpJ_zYfFdR_4AEALcRtU",
|
46
|
+
"czgjUk0nqRCswShChCjdS6A1-v47d_qTCSFIvIHhMoI",
|
47
|
+
"nGnQr7clm3tfTp8yjL_uHrDSOtzR2PVb8S7GeLdAqBQ",
|
48
|
+
"xNIVwlpSsaZ8CJSf0gz5x_75VRWWc6V1mlpejdCrqUs",
|
49
|
+
],
|
50
|
+
sub: "216f8946-9ecb-4819-9309-c076f34a7e11",
|
51
|
+
_sd_alg: "sha-256",
|
52
|
+
vct: "PersonIdentificationData",
|
53
|
+
iss: "https://pre.eid.wallet.ipzs.it",
|
56
54
|
cnf: {
|
57
55
|
jwk: {
|
58
|
-
kty: "
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
56
|
+
kty: "EC",
|
57
|
+
crv: "P-256",
|
58
|
+
kid: "Rv3W-EiKpvBTyk5yZxvrev-7MDB6SlzUCBo_CQjjddU",
|
59
|
+
x: "0Wox7QtyPqByg35MH_XyCcnd5Le-Jm0AXHlUgDBA03Y",
|
60
|
+
y: "eEhVvg1JPqNd3DTSa4mGDGBlwY6NP-EZbLbNFXSXwIg",
|
63
61
|
},
|
64
62
|
},
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
trust_framework: "eidas",
|
70
|
-
assurance_level: "high",
|
71
|
-
},
|
72
|
-
claims: {
|
73
|
-
_sd: [
|
74
|
-
"09vKrJMOlyTWM0sjpu_pdOBVBQ2M1y3KhpH515nXkpY",
|
75
|
-
"2rsjGbaC0ky8mT0pJrPioWTq0_daw1sX76poUlgCwbI",
|
76
|
-
"EkO8dhW0dHEJbvUHlE_VCeuC9uRELOieLZhh7XbUTtA",
|
77
|
-
"IlDzIKeiZdDwpqpK6ZfbyphFvz5FgnWa-sN6wqQXCiw",
|
78
|
-
"PorFbpKuVu6xymJagvkFsFXAbRoc2JGlAUA2BA4o7cI",
|
79
|
-
"TGf4oLbgwd5JQaHyKVQZU9UdGE0w5rtDsrZzfUaomLo",
|
80
|
-
"jdrTE8YcbY4EifugihiAe_BPekxJQZICeiUQwY9QqxI",
|
81
|
-
"jsu9yVulwQQlhFlM_3JlzMaSFzglhQG0DpfayQwLUK4",
|
82
|
-
],
|
63
|
+
exp: 1751546576,
|
64
|
+
status: {
|
65
|
+
status_attestation: {
|
66
|
+
credential_hash_alg: "sha-256",
|
83
67
|
},
|
84
68
|
},
|
85
|
-
_sd_alg: "sha-256",
|
86
69
|
},
|
87
70
|
};
|
88
71
|
|
89
72
|
// In the very same order than tokenizedDisclosures
|
90
73
|
const disclosures = [
|
91
|
-
["
|
92
|
-
["
|
93
|
-
["
|
94
|
-
["
|
95
|
-
["
|
96
|
-
["
|
97
|
-
["G02NSrQfjFXQ7Io09syajA", "is_over_21", true],
|
98
|
-
["lklxF5jMYlGTPUovMNIvCA", "is_over_65", true],
|
99
|
-
[
|
100
|
-
"Qg_O64zqAxe412a108iroA",
|
101
|
-
"address",
|
102
|
-
{
|
103
|
-
street_address: "123 Main St",
|
104
|
-
locality: "Anytown",
|
105
|
-
region: "Anystate",
|
106
|
-
country: "US",
|
107
|
-
},
|
108
|
-
],
|
74
|
+
["kJDEP8EaNTEMBDOZzZzT4w", "unique_id", "TINIT-LVLDAA85T50G702B"],
|
75
|
+
["zIAyUFvPfIpE1zBqxI5haQ", "birth_date", "1985-12-10"],
|
76
|
+
["Gr3R3s290OkQUm-NFTu96A", "tax_id_code", "TINIT-LVLDAA85T50G702B"],
|
77
|
+
["GxORalMAelfZ0edFJjjYUw", "given_name", "Ada"],
|
78
|
+
["_vV5RIkl0IOEXKots9kt1w", "family_name", "Lovelace"],
|
79
|
+
["Cj5tccR72Jwrze2TW4a-wg", "iat", 1720010575],
|
109
80
|
];
|
110
81
|
it("Ensures example data correctness", () => {
|
111
82
|
expect(
|
@@ -161,8 +132,8 @@ describe("disclose", () => {
|
|
161
132
|
it("should encode a valid sdjwt (one claim)", async () => {
|
162
133
|
const result = await disclose(token, ["given_name"]);
|
163
134
|
const expected = {
|
164
|
-
token: `${signed}~
|
165
|
-
paths: [{ claim: "given_name", path: "verified_claims.claims._sd[
|
135
|
+
token: `${signed}~WyJHeE9SYWxNQWVsZlowZWRGSmpqWVV3IiwiZ2l2ZW5fbmFtZSIsIkFkYSJd`,
|
136
|
+
paths: [{ claim: "given_name", path: "verified_claims.claims._sd[3]" }],
|
166
137
|
};
|
167
138
|
|
168
139
|
expect(result).toEqual(expected);
|
@@ -176,17 +147,17 @@ describe("disclose", () => {
|
|
176
147
|
});
|
177
148
|
|
178
149
|
it("should encode a valid sdjwt (multiple claims)", async () => {
|
179
|
-
const result = await disclose(token, ["
|
150
|
+
const result = await disclose(token, ["iat", "family_name"]);
|
180
151
|
const expected = {
|
181
|
-
token: `${signed}~
|
152
|
+
token: `${signed}~WyJfdlY1UklrbDBJT0VYS290czlrdDF3IiwiZmFtaWx5X25hbWUiLCJMb3ZlbGFjZSJd~WyJDajV0Y2NSNzJKd3J6ZTJUVzRhLXdnIiwiaWF0IiwxNzIwMDEwNTc1XQ`,
|
182
153
|
paths: [
|
183
154
|
{
|
184
|
-
claim: "
|
185
|
-
path: "verified_claims.claims._sd[
|
155
|
+
claim: "iat",
|
156
|
+
path: "verified_claims.claims._sd[4]",
|
186
157
|
},
|
187
158
|
{
|
188
|
-
claim: "
|
189
|
-
path: "verified_claims.
|
159
|
+
claim: "family_name",
|
160
|
+
path: "verified_claims.claims._sd[0]",
|
190
161
|
},
|
191
162
|
],
|
192
163
|
};
|
@@ -8,47 +8,35 @@ describe("SdJwt4VC", () => {
|
|
8
8
|
typ: "vc+sd-jwt",
|
9
9
|
alg: "RS512",
|
10
10
|
kid: "dB67gL7ck3TFiIAf7N6_7SHvqk0MDYMEQcoGGlkUAAw",
|
11
|
-
trust_chain: [
|
12
|
-
"NEhRdERpYnlHY3M5WldWTWZ2aUhm ...",
|
13
|
-
"eyJhbGciOiJSUzI1NiIsImtpZCI6 ...",
|
14
|
-
"IkJYdmZybG5oQU11SFIwN2FqVW1B ...",
|
15
|
-
],
|
16
11
|
},
|
17
12
|
payload: {
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
13
|
+
_sd: [
|
14
|
+
"0q1D5Jmav6pQaEh_J_Fcv_uNNMQIgCyhQOxqlY4l3qU",
|
15
|
+
"KCJ-AVNv88d-xj6sUIAOJxFnbUh3rHXDKkIH1lFqbRs",
|
16
|
+
"M9lo9YxDNIXrAq2qWeiCA40zpJ_zYfFdR_4AEALcRtU",
|
17
|
+
"czgjUk0nqRCswShChCjdS6A1-v47d_qTCSFIvIHhMoI",
|
18
|
+
"nGnQr7clm3tfTp8yjL_uHrDSOtzR2PVb8S7GeLdAqBQ",
|
19
|
+
"xNIVwlpSsaZ8CJSf0gz5x_75VRWWc6V1mlpejdCrqUs",
|
20
|
+
],
|
21
|
+
sub: "216f8946-9ecb-4819-9309-c076f34a7e11",
|
22
|
+
_sd_alg: "sha-256",
|
23
|
+
vct: "PersonIdentificationData",
|
24
|
+
iss: "https://pidprovider.example.com",
|
24
25
|
cnf: {
|
25
26
|
jwk: {
|
26
|
-
kty: "
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
kty: "EC",
|
28
|
+
crv: "P-256",
|
29
|
+
kid: "zEv_qGSL5r0_F67j2dwEgUJmBgbMNSEJ5K_iH1PYc7A",
|
30
|
+
x: "0Pj7v_afNp9ETJx11JbYgkI7yQpd0rtiYuo5feuAN2o",
|
31
|
+
y: "XB62Um02vHqedkOzSfJ5hdtjPz-zmV9jmWh4sKgdD9o",
|
31
32
|
},
|
32
33
|
},
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
trust_framework: "eidas",
|
38
|
-
assurance_level: "high",
|
39
|
-
},
|
40
|
-
claims: {
|
41
|
-
_sd: [
|
42
|
-
"8JjozBfovMNvQ3HflmPWy4O19Gpxs61FWHjZebU589E",
|
43
|
-
"BoMGktW1rbikntw8Fzx_BeL4YbAndr6AHsdgpatFCig",
|
44
|
-
"CFLGzentGNRFngnLVVQVcoAFi05r6RJUX-rdbLdEfew",
|
45
|
-
"JU_sTaHCngS32X-0ajHrd1-HCLCkpT5YqgcfQme168w",
|
46
|
-
"VQI-S1mT1Kxfq2o8J9io7xMMX2MIxaG9M9PeJVqrMcA",
|
47
|
-
"zVdghcmClMVWlUgGsGpSkCPkEHZ4u9oWj1SlIBlCc1o",
|
48
|
-
],
|
34
|
+
exp: 1751107255,
|
35
|
+
status: {
|
36
|
+
status_attestation: {
|
37
|
+
credential_hash_alg: "sha-256",
|
49
38
|
},
|
50
39
|
},
|
51
|
-
_sd_alg: "sha-256",
|
52
40
|
},
|
53
41
|
};
|
54
42
|
|
package/src/sd-jwt/index.ts
CHANGED
@@ -101,15 +101,9 @@ export const disclose = async (
|
|
101
101
|
|
102
102
|
// _sd is defined in verified_claims.claims and verified_claims.verification
|
103
103
|
// we must look into both
|
104
|
-
if (sdJwt.payload.
|
105
|
-
const index = sdJwt.payload.
|
104
|
+
if (sdJwt.payload._sd.includes(hash)) {
|
105
|
+
const index = sdJwt.payload._sd.indexOf(hash);
|
106
106
|
return { claim, path: `verified_claims.claims._sd[${index}]` };
|
107
|
-
} else if (
|
108
|
-
sdJwt.payload.verified_claims.verification._sd.includes(hash)
|
109
|
-
) {
|
110
|
-
const index =
|
111
|
-
sdJwt.payload.verified_claims.verification._sd.indexOf(hash);
|
112
|
-
return { claim, path: `verified_claims.verification._sd[${index}]` };
|
113
107
|
}
|
114
108
|
|
115
109
|
throw new ClaimsNotFoundInToken(claim);
|
@@ -158,10 +152,7 @@ export const verify = async <S extends z.ZodType<SdJwt4VC>>(
|
|
158
152
|
await verifyJwt(rawSdJwt, publicKey);
|
159
153
|
|
160
154
|
//Check disclosures in sd-jwt
|
161
|
-
const claims = [
|
162
|
-
...decoded.sdJwt.payload.verified_claims.verification._sd,
|
163
|
-
...decoded.sdJwt.payload.verified_claims.claims._sd,
|
164
|
-
];
|
155
|
+
const claims = [...decoded.sdJwt.payload._sd];
|
165
156
|
|
166
157
|
await Promise.all(
|
167
158
|
decoded.disclosures.map(
|