@pagopa/io-react-native-wallet 0.27.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/credential/index.js +1 -5
- package/lib/commonjs/credential/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/02-get-issuer-config.js +48 -0
- package/lib/commonjs/credential/issuance/02-get-issuer-config.js.map +1 -0
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js +16 -20
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js +8 -8
- package/lib/commonjs/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/issuance/05-authorize-access.js +8 -9
- package/lib/commonjs/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/commonjs/credential/issuance/06-obtain-credential.js +18 -21
- package/lib/commonjs/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js +3 -3
- package/lib/commonjs/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/commonjs/credential/issuance/README.md +18 -21
- package/lib/commonjs/credential/issuance/index.js +3 -3
- package/lib/commonjs/credential/issuance/index.js.map +1 -1
- package/lib/commonjs/credential/issuance/types.js +1 -1
- package/lib/commonjs/credential/issuance/types.js.map +1 -1
- package/lib/commonjs/credential/presentation/01-start-flow.js +7 -2
- package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js +2 -2
- package/lib/commonjs/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
- package/lib/commonjs/credential/presentation/03-retrieve-jwks.js +68 -0
- package/lib/commonjs/credential/presentation/03-retrieve-jwks.js.map +1 -0
- package/lib/commonjs/credential/presentation/{03-get-request-object.js → 04-get-request-object.js} +27 -13
- package/lib/commonjs/credential/presentation/04-get-request-object.js.map +1 -0
- package/lib/commonjs/credential/presentation/{04-send-authorization-response.js → 05-send-authorization-response.js} +1 -1
- package/lib/commonjs/credential/presentation/{04-send-authorization-response.js.map → 05-send-authorization-response.js.map} +1 -1
- package/lib/commonjs/credential/presentation/README.md +74 -2
- package/lib/commonjs/credential/presentation/index.js +15 -2
- package/lib/commonjs/credential/presentation/index.js.map +1 -1
- package/lib/commonjs/credential/presentation/types.js +5 -3
- package/lib/commonjs/credential/presentation/types.js.map +1 -1
- package/lib/commonjs/entity/openid-connect/issuer/index.js +25 -0
- package/lib/commonjs/entity/openid-connect/issuer/index.js.map +1 -0
- package/lib/commonjs/entity/openid-connect/issuer/types.js +61 -0
- package/lib/commonjs/entity/openid-connect/issuer/types.js.map +1 -0
- package/lib/commonjs/{trust → entity/trust}/chain.js +1 -1
- package/lib/commonjs/entity/trust/chain.js.map +1 -0
- package/lib/commonjs/{trust → entity/trust}/index.js +1 -1
- package/lib/commonjs/entity/trust/index.js.map +1 -0
- package/lib/commonjs/{trust → entity/trust}/types.js +2 -2
- package/lib/commonjs/entity/trust/types.js.map +1 -0
- package/lib/commonjs/index.js +1 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/pid/sd-jwt/types.js +2 -18
- package/lib/commonjs/pid/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/index.test.js +32 -23
- package/lib/commonjs/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/__test__/types.test.js +20 -11
- package/lib/commonjs/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/commonjs/sd-jwt/types.js +18 -5
- package/lib/commonjs/sd-jwt/types.js.map +1 -1
- package/lib/commonjs/utils/error-codes.js +1 -13
- package/lib/commonjs/utils/error-codes.js.map +1 -1
- package/lib/commonjs/utils/errors.js +2 -53
- package/lib/commonjs/utils/errors.js.map +1 -1
- package/lib/commonjs/utils/jwk.js +5 -1
- package/lib/commonjs/utils/jwk.js.map +1 -1
- package/lib/commonjs/utils/par.js +6 -12
- package/lib/commonjs/utils/par.js.map +1 -1
- package/lib/module/credential/index.js +1 -3
- package/lib/module/credential/index.js.map +1 -1
- package/lib/module/credential/issuance/02-get-issuer-config.js +42 -0
- package/lib/module/credential/issuance/02-get-issuer-config.js.map +1 -0
- package/lib/module/credential/issuance/03-start-user-authorization.js +16 -20
- package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/04-complete-user-authorization.js +8 -8
- package/lib/module/credential/issuance/04-complete-user-authorization.js.map +1 -1
- package/lib/module/credential/issuance/05-authorize-access.js +8 -9
- package/lib/module/credential/issuance/05-authorize-access.js.map +1 -1
- package/lib/module/credential/issuance/06-obtain-credential.js +18 -21
- package/lib/module/credential/issuance/06-obtain-credential.js.map +1 -1
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js +3 -3
- package/lib/module/credential/issuance/07-verify-and-parse-credential.js.map +1 -1
- package/lib/module/credential/issuance/README.md +18 -21
- package/lib/module/credential/issuance/index.js +2 -2
- package/lib/module/credential/issuance/index.js.map +1 -1
- package/lib/module/credential/issuance/types.js +1 -1
- package/lib/module/credential/issuance/types.js.map +1 -1
- package/lib/module/credential/presentation/01-start-flow.js +7 -2
- package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/module/credential/presentation/02-evaluate-rp-trust.js +1 -1
- package/lib/module/credential/presentation/02-evaluate-rp-trust.js.map +1 -1
- package/lib/module/credential/presentation/03-retrieve-jwks.js +61 -0
- package/lib/module/credential/presentation/03-retrieve-jwks.js.map +1 -0
- package/lib/module/credential/presentation/{03-get-request-object.js → 04-get-request-object.js} +26 -12
- package/lib/module/credential/presentation/04-get-request-object.js.map +1 -0
- package/lib/module/credential/presentation/{04-send-authorization-response.js → 05-send-authorization-response.js} +1 -1
- package/lib/module/credential/presentation/{04-send-authorization-response.js.map → 05-send-authorization-response.js.map} +1 -1
- package/lib/module/credential/presentation/README.md +74 -2
- package/lib/module/credential/presentation/index.js +4 -3
- package/lib/module/credential/presentation/index.js.map +1 -1
- package/lib/module/credential/presentation/types.js +5 -3
- package/lib/module/credential/presentation/types.js.map +1 -1
- package/lib/module/entity/openid-connect/issuer/index.js +20 -0
- package/lib/module/entity/openid-connect/issuer/index.js.map +1 -0
- package/lib/module/entity/openid-connect/issuer/types.js +47 -0
- package/lib/module/entity/openid-connect/issuer/types.js.map +1 -0
- package/lib/module/{trust → entity/trust}/chain.js +1 -1
- package/lib/module/entity/trust/chain.js.map +1 -0
- package/lib/module/{trust → entity/trust}/index.js +1 -1
- package/lib/module/entity/trust/index.js.map +1 -0
- package/lib/module/{trust → entity/trust}/types.js +2 -2
- package/lib/module/entity/trust/types.js.map +1 -0
- package/lib/module/index.js +1 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/pid/sd-jwt/types.js +1 -16
- package/lib/module/pid/sd-jwt/types.js.map +1 -1
- package/lib/module/sd-jwt/__test__/index.test.js +32 -23
- package/lib/module/sd-jwt/__test__/index.test.js.map +1 -1
- package/lib/module/sd-jwt/__test__/types.test.js +20 -11
- package/lib/module/sd-jwt/__test__/types.test.js.map +1 -1
- package/lib/module/sd-jwt/types.js +16 -4
- package/lib/module/sd-jwt/types.js.map +1 -1
- package/lib/module/utils/error-codes.js +1 -13
- package/lib/module/utils/error-codes.js.map +1 -1
- package/lib/module/utils/errors.js +0 -48
- package/lib/module/utils/errors.js.map +1 -1
- package/lib/module/utils/jwk.js +3 -0
- package/lib/module/utils/jwk.js.map +1 -1
- package/lib/module/utils/par.js +6 -12
- package/lib/module/utils/par.js.map +1 -1
- package/lib/typescript/credential/index.d.ts +1 -3
- package/lib/typescript/credential/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/01-start-flow.d.ts +1 -1
- package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts +32 -0
- package/lib/typescript/credential/issuance/02-get-issuer-config.d.ts.map +1 -0
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts +3 -3
- 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 +8 -8
- package/lib/typescript/credential/issuance/04-complete-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts +3 -3
- package/lib/typescript/credential/issuance/05-authorize-access.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/06-obtain-credential.d.ts +3 -3
- 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 +3 -3
- package/lib/typescript/credential/issuance/07-verify-and-parse-credential.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/index.d.ts +3 -3
- package/lib/typescript/credential/issuance/index.d.ts.map +1 -1
- package/lib/typescript/credential/issuance/types.d.ts +4 -9
- package/lib/typescript/credential/issuance/types.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts +1 -1
- package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/03-retrieve-jwks.d.ts +41 -0
- package/lib/typescript/credential/presentation/03-retrieve-jwks.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/{03-get-request-object.d.ts → 04-get-request-object.d.ts} +4 -4
- package/lib/typescript/credential/presentation/04-get-request-object.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/{04-send-authorization-response.d.ts → 05-send-authorization-response.d.ts} +2 -2
- package/lib/typescript/credential/presentation/{04-send-authorization-response.d.ts.map → 05-send-authorization-response.d.ts.map} +1 -1
- package/lib/typescript/credential/presentation/index.d.ts +5 -4
- package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/types.d.ts +15 -15
- package/lib/typescript/entity/openid-connect/issuer/index.d.ts +12 -0
- package/lib/typescript/entity/openid-connect/issuer/index.d.ts.map +1 -0
- package/lib/typescript/entity/openid-connect/issuer/types.d.ts +641 -0
- package/lib/typescript/entity/openid-connect/issuer/types.d.ts.map +1 -0
- package/lib/typescript/entity/trust/chain.d.ts.map +1 -0
- package/lib/typescript/{trust → entity/trust}/index.d.ts +97 -97
- package/lib/typescript/entity/trust/index.d.ts.map +1 -0
- package/lib/typescript/{trust → entity/trust}/types.d.ts +597 -597
- package/lib/typescript/{trust → entity/trust}/types.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/pid/sd-jwt/types.d.ts +25 -103
- package/lib/typescript/pid/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/index.d.ts +60 -20
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/types.d.ts +114 -24
- package/lib/typescript/sd-jwt/types.d.ts.map +1 -1
- package/lib/typescript/utils/error-codes.d.ts +0 -12
- package/lib/typescript/utils/error-codes.d.ts.map +1 -1
- package/lib/typescript/utils/errors.d.ts +6 -37
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/utils/jwk.d.ts +135 -0
- package/lib/typescript/utils/jwk.d.ts.map +1 -1
- package/lib/typescript/utils/par.d.ts +1 -8
- package/lib/typescript/utils/par.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/types.d.ts +12 -12
- package/package.json +1 -1
- package/src/credential/index.ts +1 -4
- package/src/credential/issuance/01-start-flow.ts +1 -1
- package/src/credential/issuance/02-get-issuer-config.ts +67 -0
- package/src/credential/issuance/03-start-user-authorization.ts +22 -30
- package/src/credential/issuance/04-complete-user-authorization.ts +11 -13
- package/src/credential/issuance/05-authorize-access.ts +8 -10
- package/src/credential/issuance/06-obtain-credential.ts +30 -31
- package/src/credential/issuance/07-verify-and-parse-credential.ts +6 -6
- package/src/credential/issuance/README.md +18 -21
- package/src/credential/issuance/index.ts +3 -6
- package/src/credential/issuance/types.ts +1 -1
- package/src/credential/presentation/01-start-flow.ts +8 -2
- package/src/credential/presentation/02-evaluate-rp-trust.ts +2 -2
- package/src/credential/presentation/03-retrieve-jwks.ts +73 -0
- package/src/credential/presentation/{03-get-request-object.ts → 04-get-request-object.ts} +33 -15
- package/src/credential/presentation/{04-send-authorization-response.ts → 05-send-authorization-response.ts} +1 -1
- package/src/credential/presentation/README.md +74 -2
- package/src/credential/presentation/index.ts +10 -2
- package/src/credential/presentation/types.ts +3 -3
- package/src/entity/openid-connect/issuer/index.ts +27 -0
- package/src/entity/openid-connect/issuer/types.ts +68 -0
- package/src/{trust → entity/trust}/chain.ts +2 -2
- package/src/{trust → entity/trust}/index.ts +1 -1
- package/src/{trust → entity/trust}/types.ts +2 -2
- package/src/index.ts +0 -2
- package/src/pid/sd-jwt/types.ts +1 -18
- package/src/sd-jwt/__test__/index.test.ts +47 -37
- package/src/sd-jwt/__test__/types.test.ts +26 -16
- package/src/sd-jwt/types.ts +16 -2
- package/src/utils/error-codes.ts +0 -12
- package/src/utils/errors.ts +12 -86
- package/src/utils/jwk.ts +5 -0
- package/src/utils/par.ts +3 -10
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js +0 -27
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.js.map +0 -1
- package/lib/commonjs/credential/presentation/03-get-request-object.js.map +0 -1
- package/lib/commonjs/credential/status/01-start-flow.js +0 -2
- package/lib/commonjs/credential/status/01-start-flow.js.map +0 -1
- package/lib/commonjs/credential/status/02-status-attestation.js +0 -72
- package/lib/commonjs/credential/status/02-status-attestation.js.map +0 -1
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js +0 -52
- package/lib/commonjs/credential/status/03-verify-and-parse-status-attestation.js.map +0 -1
- package/lib/commonjs/credential/status/README.md +0 -67
- package/lib/commonjs/credential/status/index.js +0 -27
- package/lib/commonjs/credential/status/index.js.map +0 -1
- package/lib/commonjs/credential/status/types.js +0 -48
- package/lib/commonjs/credential/status/types.js.map +0 -1
- package/lib/commonjs/credential/trustmark/README.md +0 -62
- package/lib/commonjs/credential/trustmark/get-credential-trustmark.js +0 -81
- package/lib/commonjs/credential/trustmark/get-credential-trustmark.js.map +0 -1
- package/lib/commonjs/credential/trustmark/index.js +0 -13
- package/lib/commonjs/credential/trustmark/index.js.map +0 -1
- package/lib/commonjs/trust/chain.js.map +0 -1
- package/lib/commonjs/trust/index.js.map +0 -1
- package/lib/commonjs/trust/types.js.map +0 -1
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js +0 -20
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js.map +0 -1
- package/lib/module/credential/presentation/03-get-request-object.js.map +0 -1
- package/lib/module/credential/status/01-start-flow.js +0 -2
- package/lib/module/credential/status/01-start-flow.js.map +0 -1
- package/lib/module/credential/status/02-status-attestation.js +0 -64
- package/lib/module/credential/status/02-status-attestation.js.map +0 -1
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js +0 -46
- package/lib/module/credential/status/03-verify-and-parse-status-attestation.js.map +0 -1
- package/lib/module/credential/status/README.md +0 -67
- package/lib/module/credential/status/index.js +0 -5
- package/lib/module/credential/status/index.js.map +0 -1
- package/lib/module/credential/status/types.js +0 -40
- package/lib/module/credential/status/types.js.map +0 -1
- package/lib/module/credential/trustmark/README.md +0 -62
- package/lib/module/credential/trustmark/get-credential-trustmark.js +0 -72
- package/lib/module/credential/trustmark/get-credential-trustmark.js.map +0 -1
- package/lib/module/credential/trustmark/index.js +0 -3
- package/lib/module/credential/trustmark/index.js.map +0 -1
- package/lib/module/trust/chain.js.map +0 -1
- package/lib/module/trust/index.js.map +0 -1
- package/lib/module/trust/types.js.map +0 -1
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts +0 -19
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts.map +0 -1
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +0 -1
- package/lib/typescript/credential/status/01-start-flow.d.ts +0 -10
- package/lib/typescript/credential/status/01-start-flow.d.ts.map +0 -1
- package/lib/typescript/credential/status/02-status-attestation.d.ts +0 -19
- package/lib/typescript/credential/status/02-status-attestation.d.ts.map +0 -1
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts +0 -24
- package/lib/typescript/credential/status/03-verify-and-parse-status-attestation.d.ts.map +0 -1
- package/lib/typescript/credential/status/index.d.ts +0 -7
- package/lib/typescript/credential/status/index.d.ts.map +0 -1
- package/lib/typescript/credential/status/types.d.ts +0 -305
- package/lib/typescript/credential/status/types.d.ts.map +0 -1
- package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts +0 -52
- package/lib/typescript/credential/trustmark/get-credential-trustmark.d.ts.map +0 -1
- package/lib/typescript/credential/trustmark/index.d.ts +0 -4
- package/lib/typescript/credential/trustmark/index.d.ts.map +0 -1
- package/lib/typescript/trust/chain.d.ts.map +0 -1
- package/lib/typescript/trust/index.d.ts.map +0 -1
- package/src/credential/issuance/02-evaluate-issuer-trust.ts +0 -32
- package/src/credential/status/01-start-flow.ts +0 -9
- package/src/credential/status/02-status-attestation.ts +0 -102
- package/src/credential/status/03-verify-and-parse-status-attestation.ts +0 -60
- package/src/credential/status/README.md +0 -67
- package/src/credential/status/index.ts +0 -22
- package/src/credential/status/types.ts +0 -43
- package/src/credential/trustmark/README.md +0 -62
- package/src/credential/trustmark/get-credential-trustmark.ts +0 -120
- package/src/credential/trustmark/index.ts +0 -8
- /package/lib/typescript/{trust → entity/trust}/chain.d.ts +0 -0
@@ -1,5 +1,5 @@
|
|
1
|
-
import { getRelyingPartyEntityConfiguration } from "../../trust";
|
2
|
-
import { RelyingPartyEntityConfiguration } from "../../trust/types";
|
1
|
+
import { getRelyingPartyEntityConfiguration } from "../../entity/trust/index";
|
2
|
+
import { RelyingPartyEntityConfiguration } from "../../entity/trust/types";
|
3
3
|
import type { StartFlow } from "../issuance/01-start-flow";
|
4
4
|
import type { Out } from "../../utils/misc";
|
5
5
|
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import { JWKS, JWK } from "../../utils/jwk";
|
2
|
+
import { hasStatusOrThrow } from "../../utils/misc";
|
3
|
+
import { RelyingPartyEntityConfiguration } from "../../entity/trust/types";
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Defines the signature for a function that retrieves JSON Web Key Sets (JWKS) from a client.
|
7
|
+
*
|
8
|
+
* @template T - The tuple type representing the function arguments.
|
9
|
+
* @param args - The arguments passed to the function.
|
10
|
+
* @returns A promise resolving to an object containing an array of JWKs.
|
11
|
+
*/
|
12
|
+
export type FetchJwks<T extends Array<unknown> = []> = (...args: T) => Promise<{
|
13
|
+
keys: JWK[];
|
14
|
+
}>;
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Retrieves the JSON Web Key Set (JWKS) from the specified client's well-known endpoint.
|
18
|
+
*
|
19
|
+
* @param clientUrl - The base URL of the client entity from which to retrieve the JWKS.
|
20
|
+
* @param options - Optional context containing a custom fetch implementation.
|
21
|
+
* @param options.context - Optional context object.
|
22
|
+
* @param options.context.appFetch - Optional custom fetch function to use instead of the global `fetch`.
|
23
|
+
* @returns A promise resolving to an object containing an array of JWKs.
|
24
|
+
* @throws Will throw an error if the JWKS retrieval fails.
|
25
|
+
*/
|
26
|
+
export const fetchJwksFromUri: FetchJwks<
|
27
|
+
[string, { context?: { appFetch?: GlobalFetch["fetch"] } }]
|
28
|
+
> = async (clientUrl, { context = {} } = {}) => {
|
29
|
+
const { appFetch = fetch } = context;
|
30
|
+
|
31
|
+
const wellKnownUrl = new URL(
|
32
|
+
"/.well-known/jar-issuer/jwk",
|
33
|
+
clientUrl
|
34
|
+
).toString();
|
35
|
+
|
36
|
+
// Fetches the JWKS from a specific endpoint of the entity's well-known configuration
|
37
|
+
const jwks = await appFetch(wellKnownUrl, {
|
38
|
+
method: "GET",
|
39
|
+
})
|
40
|
+
.then(hasStatusOrThrow(200))
|
41
|
+
.then((raw) => raw.json())
|
42
|
+
.then((json) => JWKS.parse(json));
|
43
|
+
|
44
|
+
return {
|
45
|
+
keys: jwks.keys,
|
46
|
+
};
|
47
|
+
};
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Retrieves the JSON Web Key Set (JWKS) from a Relying Party's entity configuration.
|
51
|
+
*
|
52
|
+
* @param rpConfig - The configuration object of the Relying Party entity.
|
53
|
+
* @returns An object containing an array of JWKs.
|
54
|
+
* @throws Will throw an error if the configuration is invalid or if JWKS is not found.
|
55
|
+
*/
|
56
|
+
export const fetchJwksFromConfig: FetchJwks<
|
57
|
+
[RelyingPartyEntityConfiguration]
|
58
|
+
> = async (rpConfig) => {
|
59
|
+
const parsedConfig = RelyingPartyEntityConfiguration.safeParse(rpConfig);
|
60
|
+
if (!parsedConfig.success) {
|
61
|
+
throw new Error("Invalid Relying Party configuration.");
|
62
|
+
}
|
63
|
+
|
64
|
+
const jwks = parsedConfig.data.payload.metadata.wallet_relying_party.jwks;
|
65
|
+
|
66
|
+
if (!jwks || !Array.isArray(jwks.keys)) {
|
67
|
+
throw new Error("JWKS not found in Relying Party configuration.");
|
68
|
+
}
|
69
|
+
|
70
|
+
return {
|
71
|
+
keys: jwks.keys,
|
72
|
+
};
|
73
|
+
};
|
@@ -8,19 +8,19 @@ import {
|
|
8
8
|
|
9
9
|
import { createDPopToken } from "../../utils/dpop";
|
10
10
|
import { NoSuitableKeysFoundInEntityConfiguration } from "./errors";
|
11
|
-
import type {
|
11
|
+
import type { FetchJwks } from "./03-retrieve-jwks";
|
12
12
|
import { hasStatusOrThrow, type Out } from "../../utils/misc";
|
13
13
|
import type { StartFlow } from "./01-start-flow";
|
14
14
|
import { RequestObject } from "./types";
|
15
15
|
|
16
16
|
export type GetRequestObject = (
|
17
17
|
requestUri: Out<StartFlow>["requestURI"],
|
18
|
-
rpConf: Out<EvaluateRelyingPartyTrust>["rpConf"],
|
19
18
|
context: {
|
20
19
|
wiaCryptoContext: CryptoContext;
|
21
20
|
appFetch?: GlobalFetch["fetch"];
|
22
21
|
walletInstanceAttestation: string;
|
23
|
-
}
|
22
|
+
},
|
23
|
+
jwkKeys?: Out<FetchJwks>["keys"]
|
24
24
|
) => Promise<{ requestObject: RequestObject }>;
|
25
25
|
|
26
26
|
/**
|
@@ -36,8 +36,8 @@ export type GetRequestObject = (
|
|
36
36
|
*/
|
37
37
|
export const getRequestObject: GetRequestObject = async (
|
38
38
|
requestUri,
|
39
|
-
|
40
|
-
|
39
|
+
{ wiaCryptoContext, appFetch = fetch, walletInstanceAttestation },
|
40
|
+
jwkKeys
|
41
41
|
) => {
|
42
42
|
const signedWalletInstanceDPoP = await createDPopToken(
|
43
43
|
{
|
@@ -62,10 +62,24 @@ export const getRequestObject: GetRequestObject = async (
|
|
62
62
|
|
63
63
|
const responseJwt = decodeJwt(responseEncodedJwt);
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
await verifyTokenSignature(jwkKeys, responseJwt);
|
66
|
+
|
67
|
+
// Ensure that the request object conforms to the expected specification.
|
68
|
+
const requestObject = RequestObject.parse(responseJwt.payload);
|
69
|
+
|
70
|
+
return {
|
71
|
+
requestObject,
|
72
|
+
};
|
73
|
+
};
|
74
|
+
|
75
|
+
const verifyTokenSignature = async (
|
76
|
+
jwkKeys?: Out<FetchJwks>["keys"],
|
77
|
+
responseJwt?: any
|
78
|
+
): Promise<void> => {
|
79
|
+
// verify token signature to ensure the request object is authentic
|
80
|
+
// 1. according to entity configuration if present
|
81
|
+
if (jwkKeys) {
|
82
|
+
const pubKey = jwkKeys.find(
|
69
83
|
({ kid }) => kid === responseJwt.protectedHeader.kid
|
70
84
|
);
|
71
85
|
if (!pubKey) {
|
@@ -73,13 +87,17 @@ export const getRequestObject: GetRequestObject = async (
|
|
73
87
|
"Request Object signature verification"
|
74
88
|
);
|
75
89
|
}
|
76
|
-
await verify(
|
90
|
+
await verify(responseJwt, pubKey);
|
91
|
+
return;
|
77
92
|
}
|
78
93
|
|
79
|
-
//
|
80
|
-
|
94
|
+
// 2. If jwk is not retrieved from entity config, check if the token contains the 'jwk' attribute
|
95
|
+
if (responseJwt.protectedHeader?.jwk) {
|
96
|
+
const pubKey = responseJwt.protectedHeader.jwk;
|
97
|
+
await verify(responseJwt, pubKey);
|
98
|
+
return;
|
99
|
+
}
|
81
100
|
|
82
|
-
|
83
|
-
|
84
|
-
};
|
101
|
+
// No verification condition matched: skipping signature verification for now.
|
102
|
+
// TODO: [EUDIW-215] Remove skipping signature verification
|
85
103
|
};
|
@@ -4,7 +4,7 @@ import * as WalletInstanceAttestation from "../../wallet-instance-attestation";
|
|
4
4
|
import type { JWK } from "@pagopa/io-react-native-jwt/lib/typescript/types";
|
5
5
|
import { NoSuitableKeysFoundInEntityConfiguration } from "./errors";
|
6
6
|
import { hasStatusOrThrow, type Out } from "../../utils/misc";
|
7
|
-
import type { GetRequestObject } from "./
|
7
|
+
import type { GetRequestObject } from "./04-get-request-object";
|
8
8
|
import { disclose } from "../../sd-jwt";
|
9
9
|
import type { EvaluateRelyingPartyTrust } from "./02-evaluate-rp-trust";
|
10
10
|
import { type Presentation } from "./types";
|
@@ -1,3 +1,75 @@
|
|
1
|
-
# Credential
|
1
|
+
# Credential Presentation
|
2
2
|
|
3
|
-
|
3
|
+
## Sequence Diagram
|
4
|
+
|
5
|
+
```mermaid
|
6
|
+
sequenceDiagram
|
7
|
+
autonumber
|
8
|
+
participant I as Individual using EUDI Wallet
|
9
|
+
participant O as Organisational Wallet (Verifier)
|
10
|
+
participant A as Organisational Wallet (Issuer)
|
11
|
+
|
12
|
+
O->>+I: QR-CODE: Authorisation request (`request_uri`)
|
13
|
+
I->>+O: GET: Request object, resolved from the `request_uri`
|
14
|
+
O->>+I: Respond with the Request object
|
15
|
+
I->>+O: GET: /.well-known/jar-issuer/jwk
|
16
|
+
O->>+I: Respond with the public key
|
17
|
+
|
18
|
+
I->>+O: POST: VP token response
|
19
|
+
O->>+A: GET: /.well-known/jwt-vc-issuer/jwk
|
20
|
+
A->>+O: Respond with the public key
|
21
|
+
O->>+I: Redirect: Authorisation response
|
22
|
+
```
|
23
|
+
|
24
|
+
## Mapped results
|
25
|
+
|
26
|
+
## Examples
|
27
|
+
|
28
|
+
<details>
|
29
|
+
<summary>Remote Presentation flow</summary>
|
30
|
+
|
31
|
+
```ts
|
32
|
+
// Scan e retrive qr-code
|
33
|
+
const qrcode = ...
|
34
|
+
|
35
|
+
// Retrieve the integrity key tag from the store and create its context
|
36
|
+
const integrityKeyTag = "example"; // Let's assume this is the key tag used to create the wallet instance
|
37
|
+
const integrityContext = getIntegrityContext(integrityKeyTag);
|
38
|
+
|
39
|
+
// Let's assume the key esists befor starting the presentation process
|
40
|
+
const wiaCryptoContext = createCryptoContextFor(WIA_KEYTAG);
|
41
|
+
|
42
|
+
const { WALLET_PROVIDER_BASE_URL, WALLET_EAA_PROVIDER_BASE_URL, REDIRECT_URI } =
|
43
|
+
env; // Let's assume these are the environment variables
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Obtains a new Wallet Instance Attestation.
|
47
|
+
* WARNING: The integrity context must be the same used when creating the Wallet Instance with the same keytag.
|
48
|
+
*/
|
49
|
+
const walletInstanceAttestation =
|
50
|
+
await WalletInstanceAttestation.getAttestation({
|
51
|
+
wiaCryptoContext,
|
52
|
+
integrityContext,
|
53
|
+
walletProviderBaseUrl: WALLET_PROVIDER_BASE_URL,
|
54
|
+
appFetch,
|
55
|
+
});
|
56
|
+
|
57
|
+
// Start the issuance flow
|
58
|
+
const { requestURI, clientId } = Credential.Presentation.startFlowFromQR(qrcode);
|
59
|
+
|
60
|
+
// If use trust federation: Evaluate issuer trust
|
61
|
+
const { rpConf } = await Credential.Presentation.evaluateRelyingPartyTrust(clientId);
|
62
|
+
|
63
|
+
// If use trust federation: Fetch Jwks from rpConf
|
64
|
+
const jwks = await Credential.Presentation.fetchJwksFromConfig(rpConf);
|
65
|
+
|
66
|
+
// If not use trust: Fetch Jwks from well-know
|
67
|
+
const jwks = await Credential.Presentation.fetchJwksFromUri(
|
68
|
+
requestURI,
|
69
|
+
appFetch,
|
70
|
+
);
|
71
|
+
|
72
|
+
|
73
|
+
```
|
74
|
+
|
75
|
+
</details>
|
@@ -3,19 +3,26 @@ import {
|
|
3
3
|
evaluateRelyingPartyTrust,
|
4
4
|
type EvaluateRelyingPartyTrust,
|
5
5
|
} from "./02-evaluate-rp-trust";
|
6
|
+
import {
|
7
|
+
fetchJwksFromUri,
|
8
|
+
fetchJwksFromConfig,
|
9
|
+
type FetchJwks,
|
10
|
+
} from "./03-retrieve-jwks";
|
6
11
|
import {
|
7
12
|
getRequestObject,
|
8
13
|
type GetRequestObject,
|
9
|
-
} from "./
|
14
|
+
} from "./04-get-request-object";
|
10
15
|
import {
|
11
16
|
sendAuthorizationResponse,
|
12
17
|
type SendAuthorizationResponse,
|
13
|
-
} from "./
|
18
|
+
} from "./05-send-authorization-response";
|
14
19
|
import * as Errors from "./errors";
|
15
20
|
|
16
21
|
export {
|
17
22
|
startFlowFromQR,
|
18
23
|
evaluateRelyingPartyTrust,
|
24
|
+
fetchJwksFromUri,
|
25
|
+
fetchJwksFromConfig,
|
19
26
|
getRequestObject,
|
20
27
|
sendAuthorizationResponse,
|
21
28
|
Errors,
|
@@ -23,6 +30,7 @@ export {
|
|
23
30
|
export type {
|
24
31
|
StartFlow,
|
25
32
|
EvaluateRelyingPartyTrust,
|
33
|
+
FetchJwks,
|
26
34
|
GetRequestObject,
|
27
35
|
SendAuthorizationResponse,
|
28
36
|
};
|
@@ -13,15 +13,15 @@ export type Presentation = [
|
|
13
13
|
|
14
14
|
export type RequestObject = z.infer<typeof RequestObject>;
|
15
15
|
export const RequestObject = z.object({
|
16
|
-
iss: z.string(),
|
16
|
+
iss: z.string().optional(), //optional by RFC 7519, mandatory for Potential
|
17
17
|
iat: UnixTime,
|
18
|
-
exp: UnixTime,
|
18
|
+
exp: UnixTime.optional(),
|
19
19
|
state: z.string(),
|
20
20
|
nonce: z.string(),
|
21
21
|
response_uri: z.string(),
|
22
22
|
response_type: z.literal("vp_token"),
|
23
23
|
response_mode: z.literal("direct_post.jwt"),
|
24
24
|
client_id: z.string(),
|
25
|
-
client_id_scheme: z.literal("entity_id"),
|
25
|
+
client_id_scheme: z.string(), // previous z.literal("entity_id"),
|
26
26
|
scope: z.string(),
|
27
27
|
});
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { hasStatusOrThrow } from "../../../utils/misc";
|
2
|
+
import { CredentialIssuerConfiguration } from "./types";
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Fetch the signed entity configuration token for an entity
|
6
|
+
*
|
7
|
+
* @param entityBaseUrl The url of the entity to fetch
|
8
|
+
* @param param.appFetch (optional) fetch api implemention
|
9
|
+
* @returns The signed Entity Configuration token
|
10
|
+
*/
|
11
|
+
export async function getCredentialIssuerMetadata(
|
12
|
+
entityBaseUrl: string,
|
13
|
+
{
|
14
|
+
appFetch = fetch,
|
15
|
+
}: {
|
16
|
+
appFetch?: GlobalFetch["fetch"];
|
17
|
+
} = {}
|
18
|
+
): Promise<CredentialIssuerConfiguration> {
|
19
|
+
const wellKnownUrl = `${entityBaseUrl}/.well-known/openid-credential-issuer`;
|
20
|
+
|
21
|
+
return await appFetch(wellKnownUrl, {
|
22
|
+
method: "GET",
|
23
|
+
})
|
24
|
+
.then(hasStatusOrThrow(200))
|
25
|
+
.then((res) => res.json())
|
26
|
+
.then(CredentialIssuerConfiguration.parse);
|
27
|
+
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import { JWK } from "../../../utils/jwk";
|
2
|
+
import * as z from "zod";
|
3
|
+
|
4
|
+
// Display metadata for a credential, used by the issuer to
|
5
|
+
// instruct the Wallet Solution on how to render the credential correctly
|
6
|
+
export type CredentialDisplay = z.infer<typeof CredentialDisplay>;
|
7
|
+
export const CredentialDisplay = z.object({
|
8
|
+
name: z.string(),
|
9
|
+
locale: z.string(),
|
10
|
+
logo: z
|
11
|
+
.object({
|
12
|
+
url: z.string(),
|
13
|
+
alt_text: z.string(),
|
14
|
+
})
|
15
|
+
.optional(),
|
16
|
+
background_color: z.string().optional(),
|
17
|
+
text_color: z.string().optional(),
|
18
|
+
});
|
19
|
+
|
20
|
+
export const CredentialClaimDisplay = z.object({
|
21
|
+
name: z.string(),
|
22
|
+
locale: z.string(),
|
23
|
+
});
|
24
|
+
|
25
|
+
export const CredentialFormat = z.union([
|
26
|
+
z.literal("vc+sd-jwt"),
|
27
|
+
z.literal("example+sd-jwt"),
|
28
|
+
]);
|
29
|
+
const CredentialSdJwtClaims = z.record(
|
30
|
+
z.object({
|
31
|
+
mandatory: z.boolean(),
|
32
|
+
display: z.array(CredentialClaimDisplay),
|
33
|
+
})
|
34
|
+
);
|
35
|
+
|
36
|
+
export type CredentialConfigurationSupported = z.infer<
|
37
|
+
typeof CredentialConfigurationSupported
|
38
|
+
>;
|
39
|
+
export const CredentialConfigurationSupported = z.record(
|
40
|
+
z.object({
|
41
|
+
cryptographic_suites_supported: z.array(z.string()),
|
42
|
+
vct: z.string(),
|
43
|
+
scope: z.string(),
|
44
|
+
cryptographic_binding_methods_supported: z.array(z.string()),
|
45
|
+
display: z.array(CredentialDisplay),
|
46
|
+
format: CredentialFormat,
|
47
|
+
claims: CredentialSdJwtClaims,
|
48
|
+
})
|
49
|
+
);
|
50
|
+
|
51
|
+
export type CredentialIssuerKeys = z.infer<typeof CredentialIssuerKeys>;
|
52
|
+
export const CredentialIssuerKeys = z.object({
|
53
|
+
keys: z.array(JWK),
|
54
|
+
});
|
55
|
+
|
56
|
+
export type CredentialIssuerConfiguration = z.infer<
|
57
|
+
typeof CredentialIssuerConfiguration
|
58
|
+
>;
|
59
|
+
export const CredentialIssuerConfiguration = z.object({
|
60
|
+
credential_configurations_supported: CredentialConfigurationSupported,
|
61
|
+
pushed_authorization_request_endpoint: z.string(),
|
62
|
+
dpop_signing_alg_values_supported: z.array(z.string()),
|
63
|
+
jwks: CredentialIssuerKeys,
|
64
|
+
credential_issuer: z.string(),
|
65
|
+
authorization_endpoint: z.string(),
|
66
|
+
token_endpoint: z.string(),
|
67
|
+
credential_endpoint: z.string(),
|
68
|
+
});
|
@@ -7,8 +7,8 @@ import {
|
|
7
7
|
EntityStatement,
|
8
8
|
TrustAnchorEntityConfiguration,
|
9
9
|
} from "./types";
|
10
|
-
import { JWK } from "
|
11
|
-
import { IoWalletError } from "
|
10
|
+
import { JWK } from "../../utils/jwk";
|
11
|
+
import { IoWalletError } from "../../utils/errors";
|
12
12
|
import * as z from "zod";
|
13
13
|
import type { JWTDecodeResult } from "@pagopa/io-react-native-jwt/lib/typescript/types";
|
14
14
|
import { getSignedEntityConfiguration, getSignedEntityStatement } from ".";
|
@@ -8,7 +8,7 @@ import {
|
|
8
8
|
EntityStatement,
|
9
9
|
} from "./types";
|
10
10
|
import { validateTrustChain, renewTrustChain } from "./chain";
|
11
|
-
import { hasStatusOrThrow } from "
|
11
|
+
import { hasStatusOrThrow } from "../../utils/misc";
|
12
12
|
|
13
13
|
export type {
|
14
14
|
WalletProviderEntityConfiguration,
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { UnixTime } from "
|
2
|
-
import { JWK } from "
|
1
|
+
import { UnixTime } from "../../sd-jwt/types";
|
2
|
+
import { JWK } from "../../utils/jwk";
|
3
3
|
import * as z from "zod";
|
4
4
|
|
5
5
|
export const TrustMark = z.object({ id: z.string(), trust_mark: z.string() });
|
package/src/index.ts
CHANGED
@@ -9,7 +9,6 @@ import * as PID from "./pid";
|
|
9
9
|
import * as SdJwt from "./sd-jwt";
|
10
10
|
import * as Errors from "./utils/errors";
|
11
11
|
import * as WalletInstanceAttestation from "./wallet-instance-attestation";
|
12
|
-
import * as Trust from "./trust";
|
13
12
|
import * as WalletInstance from "./wallet-instance";
|
14
13
|
import { AuthorizationDetail, AuthorizationDetails } from "./utils/par";
|
15
14
|
import { createCryptoContextFor } from "./utils/crypto";
|
@@ -22,7 +21,6 @@ export {
|
|
22
21
|
WalletInstanceAttestation,
|
23
22
|
WalletInstance,
|
24
23
|
Errors,
|
25
|
-
Trust,
|
26
24
|
createCryptoContextFor,
|
27
25
|
AuthorizationDetail,
|
28
26
|
AuthorizationDetails,
|
package/src/pid/sd-jwt/types.ts
CHANGED
@@ -1,22 +1,5 @@
|
|
1
1
|
import { z } from "zod";
|
2
|
-
|
3
|
-
const VerificationEvidence = z.object({
|
4
|
-
type: z.string(),
|
5
|
-
record: z.object({
|
6
|
-
type: z.string(),
|
7
|
-
source: z.object({
|
8
|
-
organization_name: z.string(),
|
9
|
-
organization_id: z.string(),
|
10
|
-
country_code: z.string(),
|
11
|
-
}),
|
12
|
-
}),
|
13
|
-
});
|
14
|
-
type Verification = z.infer<typeof Verification>;
|
15
|
-
const Verification = z.object({
|
16
|
-
trustFramework: z.literal("eidas"),
|
17
|
-
assuranceLevel: z.string(),
|
18
|
-
evidence: z.array(VerificationEvidence),
|
19
|
-
});
|
2
|
+
import { Verification } from "../../sd-jwt/types";
|
20
3
|
|
21
4
|
/**
|
22
5
|
* Data structure for the PID.
|
@@ -13,56 +13,66 @@ 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
|
+
"eyJraWQiOiJlTk4tZzVpNkNuTEtjbHRRQnA2YWJiaW9HTWJ6TTZtdVczdnV4dzZ1aDg4IiwidHlwIjoidmMrc2Qtand0IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJzajFPcFlpaUxUVllBTm5CR053U0sya3JNd3FwV2F6MmlIbU4xdDBfRXNnIiwiX3NkIjpbIjFVbXRJU3NkZDd1ZGJGYUZ5LVZpWjhkWkZoZXJiT0dEMk4zSGxYNFBJQzgiLCJGbWpzNHF6YzV2a2VPQVk1RzIwX1pQdlUtMXEtb1hhVjdBeDUxNkNDTUZrIiwiUTNiYWdOek1lUWg2RWd3UEJTSGltYmdRcGxtWV82djlTVzRnbzJYQWtnQSIsIlFWd2tuNzFCNHBXZkNPenpsUWw5SG54RlNWZEVIdVczNXpkVFFRZEZRR2MiLCJWVmRSNDFBMktPT1Z6eFlhZ1pDR2JWYW5nN3NTa2VnQ2VpdVdmM0RPdGpzIiwidk8yZHZuY216bHYzN01Ra21XdWRTRElIREU5W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zHafGQAwcwr3fyYwFZvfmLFEBoKmEawDrFC0Enfw7pE9EHP9jITxWRTIxn9NcVdnzki1FO-ERsjrDS2y-u2RK6uy6-_0kIx-1mDJ7krCkaxeol0zOLb7zJX8ooxC1QupSp1z457JKi7cPPoL1GWeTRoHFy_kZL_Jew";
|
23
23
|
|
24
24
|
const signed = `${unsigned}.${signature}`;
|
25
25
|
|
26
26
|
const tokenizedDisclosures = [
|
27
|
-
"
|
28
|
-
"
|
29
|
-
"
|
30
|
-
"
|
31
|
-
"
|
32
|
-
"
|
27
|
+
"WyJacnBvZllXMWs2NEpuUE05WjdEWS1RIiwiZ2l2ZW5fbmFtZSIsIk1hcmlvIl0",
|
28
|
+
"WyJ4d0o1UWM2OTB1eEgyZ0VKMHFDV2dRIiwiZmFtaWx5X25hbWUiLCJSb3NzaSJd",
|
29
|
+
"WyJlV3ZwQXAtVkFHM0tBdkVGTEgxRGZ3IiwidW5pcXVlX2lkIiwiaWRBTlBSIl0",
|
30
|
+
"WyJHcXZJTzV5SVN3bjg4eDkzbE1aalpRIiwiYmlydGhkYXRlIiwiMTk4MC0xMC0wMSJd",
|
31
|
+
"WyJvUmprWWxPc1JvSGZ4eEh2WmZueDN3IiwidGF4X2lkX2NvZGUiLCJUSU5JVC1SU1NNUkE4MEExMEg1MDFBIl0",
|
32
|
+
"WyJzOXBvSENQcW83cVdsb3BkQXRZc0V3IiwiaWF0IiwxNzM2OTU0MTk2XQ",
|
33
33
|
];
|
34
34
|
|
35
35
|
const sdJwt = {
|
36
36
|
header: {
|
37
|
-
kid: "-
|
37
|
+
kid: "eNN-g5i6CnLKcltQBp6abbioGMbzM6muW3vuxw6uh88",
|
38
38
|
typ: "vc+sd-jwt",
|
39
|
-
alg: "
|
39
|
+
alg: "RS256",
|
40
40
|
},
|
41
41
|
payload: {
|
42
|
+
sub: "sj1OpYiiLTVYANnBGNwSK2krMwqpWaz2iHmN1t0_Esg",
|
42
43
|
_sd: [
|
43
|
-
"
|
44
|
-
"
|
45
|
-
"
|
46
|
-
"
|
47
|
-
"
|
48
|
-
"
|
44
|
+
"1UmtISsdd7udbFaFy-ViZ8dZFherbOGD2N3HlX4PIC8",
|
45
|
+
"Fmjs4qzc5vkeOAY5G20_ZPvU-1q-oXaV7Ax516CCMFk",
|
46
|
+
"Q3bagNzMeQh6EgwPBSHimbgQplmY_6v9SW4go2XAkgA",
|
47
|
+
"QVwkn71B4pWfCOzzlQl9HnxFSVdEHuW35zdTQQdFQGc",
|
48
|
+
"VVdR41A2KOOVzxYagZCGbVang7sSkegCeiuWf3DOtjs",
|
49
|
+
"vO2dvncmzlv37MQkmWudSDIHDE9YHd0EFB8xBTDVjz0",
|
49
50
|
],
|
50
|
-
|
51
|
+
"vct#integrity":
|
52
|
+
"242302d97d38da2714a257f2a253bf2fa30aae5c109fe9581bfcda3b1d797c97",
|
51
53
|
_sd_alg: "sha-256",
|
52
|
-
vct: "
|
53
|
-
iss: "https://
|
54
|
+
vct: "urn:eu.europa.ec.eudi:pid:1",
|
55
|
+
iss: "https://api.potential-wallet-it-pid-provider.it",
|
54
56
|
cnf: {
|
55
57
|
jwk: {
|
56
58
|
kty: "EC",
|
57
59
|
crv: "P-256",
|
58
|
-
kid: "
|
59
|
-
x: "
|
60
|
-
y: "
|
60
|
+
kid: "LegnFQ8lvhA6qyPutYv48nWWpSnO5tHigavywyds5S0",
|
61
|
+
x: "czZrN9lcNuc0q69X40n27c5jKpii0A-aYX_Pbo9pqBQ",
|
62
|
+
y: "YGKGaCJNWfTiKiz3JmAG9ky7h4twPuUfzYOgy1bzLv8",
|
61
63
|
},
|
62
64
|
},
|
63
|
-
exp:
|
65
|
+
exp: 1768490196,
|
66
|
+
iat: 1736954196,
|
67
|
+
verification: {
|
68
|
+
evidence: {
|
69
|
+
method: "cie",
|
70
|
+
},
|
71
|
+
trust_framework: "eidas",
|
72
|
+
assurance_level: "high",
|
73
|
+
},
|
64
74
|
status: {
|
65
|
-
|
75
|
+
status_assertion: {
|
66
76
|
credential_hash_alg: "sha-256",
|
67
77
|
},
|
68
78
|
},
|
@@ -71,12 +81,12 @@ const sdJwt = {
|
|
71
81
|
|
72
82
|
// In the very same order than tokenizedDisclosures
|
73
83
|
const disclosures = [
|
74
|
-
["
|
75
|
-
["
|
76
|
-
["
|
77
|
-
["
|
78
|
-
["
|
79
|
-
["
|
84
|
+
["ZrpofYW1k64JnPM9Z7DY-Q", "given_name", "Mario"],
|
85
|
+
["xwJ5Qc690uxH2gEJ0qCWgQ", "family_name", "Rossi"],
|
86
|
+
["eWvpAp-VAG3KAvEFLH1Dfw", "unique_id", "idANPR"],
|
87
|
+
["GqvIO5yISwn88x93lMZjZQ", "birthdate", "1980-10-01"],
|
88
|
+
["oRjkYlOsRoHfxxHvZfnx3w", "tax_id_code", "TINIT-RSSMRA80A10H501A"],
|
89
|
+
["s9poHCPqo7qWlopdAtYsEw", "iat", 1736954196],
|
80
90
|
];
|
81
91
|
it("Ensures example data correctness", () => {
|
82
92
|
expect(
|
@@ -130,10 +140,10 @@ describe("decode", () => {
|
|
130
140
|
|
131
141
|
describe("disclose", () => {
|
132
142
|
it("should encode a valid sdjwt (one claim)", async () => {
|
133
|
-
const result = await disclose(token, ["
|
143
|
+
const result = await disclose(token, ["unique_id"]);
|
134
144
|
const expected = {
|
135
|
-
token: `${signed}~
|
136
|
-
paths: [{ claim: "
|
145
|
+
token: `${signed}~WyJlV3ZwQXAtVkFHM0tBdkVGTEgxRGZ3IiwidW5pcXVlX2lkIiwiaWRBTlBSIl0`,
|
146
|
+
paths: [{ claim: "unique_id", path: "verified_claims.claims._sd[5]" }],
|
137
147
|
};
|
138
148
|
|
139
149
|
expect(result).toEqual(expected);
|
@@ -149,15 +159,15 @@ describe("disclose", () => {
|
|
149
159
|
it("should encode a valid sdjwt (multiple claims)", async () => {
|
150
160
|
const result = await disclose(token, ["iat", "family_name"]);
|
151
161
|
const expected = {
|
152
|
-
token: `${signed}~
|
162
|
+
token: `${signed}~WyJ4d0o1UWM2OTB1eEgyZ0VKMHFDV2dRIiwiZmFtaWx5X25hbWUiLCJSb3NzaSJd~WyJzOXBvSENQcW83cVdsb3BkQXRZc0V3IiwiaWF0IiwxNzM2OTU0MTk2XQ`,
|
153
163
|
paths: [
|
154
164
|
{
|
155
165
|
claim: "iat",
|
156
|
-
path: "verified_claims.claims._sd[
|
166
|
+
path: "verified_claims.claims._sd[1]",
|
157
167
|
},
|
158
168
|
{
|
159
169
|
claim: "family_name",
|
160
|
-
path: "verified_claims.claims._sd[
|
170
|
+
path: "verified_claims.claims._sd[3]",
|
161
171
|
},
|
162
172
|
],
|
163
173
|
};
|