@pagopa/io-react-native-wallet 0.28.0 → 0.28.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/credential/issuance/03-start-user-authorization.js +3 -0
- package/lib/commonjs/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/commonjs/credential/presentation/01-start-flow.js +14 -24
- package/lib/commonjs/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/commonjs/credential/presentation/03-get-request-object.js +30 -42
- package/lib/commonjs/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js +32 -0
- package/lib/commonjs/credential/presentation/04-retrieve-rp-jwks.js.map +1 -0
- package/lib/commonjs/credential/presentation/05-verify-request-object.js +53 -0
- package/lib/commonjs/credential/presentation/05-verify-request-object.js.map +1 -0
- package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js +39 -0
- package/lib/commonjs/credential/presentation/06-fetch-presentation-definition.js.map +1 -0
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js +125 -0
- package/lib/commonjs/credential/presentation/07-evaluate-dcql-query.js.map +1 -0
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js +289 -0
- package/lib/commonjs/credential/presentation/07-evaluate-input-descriptor.js.map +1 -0
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js +170 -0
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -0
- package/lib/commonjs/credential/presentation/errors.js +69 -1
- package/lib/commonjs/credential/presentation/errors.js.map +1 -1
- package/lib/commonjs/credential/presentation/index.js +29 -1
- package/lib/commonjs/credential/presentation/index.js.map +1 -1
- package/lib/commonjs/credential/presentation/types.js +124 -3
- package/lib/commonjs/credential/presentation/types.js.map +1 -1
- package/lib/commonjs/sd-jwt/index.js +41 -1
- package/lib/commonjs/sd-jwt/index.js.map +1 -1
- package/lib/commonjs/trust/chain.js.map +1 -1
- package/lib/commonjs/trust/types.js +26 -6
- package/lib/commonjs/trust/types.js.map +1 -1
- package/lib/commonjs/trust/utils.js +5 -0
- package/lib/commonjs/trust/utils.js.map +1 -1
- package/lib/commonjs/utils/jwk.js +5 -1
- package/lib/commonjs/utils/jwk.js.map +1 -1
- package/lib/module/credential/issuance/03-start-user-authorization.js +3 -0
- package/lib/module/credential/issuance/03-start-user-authorization.js.map +1 -1
- package/lib/module/credential/presentation/01-start-flow.js +14 -24
- package/lib/module/credential/presentation/01-start-flow.js.map +1 -1
- package/lib/module/credential/presentation/03-get-request-object.js +31 -43
- package/lib/module/credential/presentation/03-get-request-object.js.map +1 -1
- package/lib/module/credential/presentation/04-retrieve-rp-jwks.js +25 -0
- package/lib/module/credential/presentation/04-retrieve-rp-jwks.js.map +1 -0
- package/lib/module/credential/presentation/05-verify-request-object.js +46 -0
- package/lib/module/credential/presentation/05-verify-request-object.js.map +1 -0
- package/lib/module/credential/presentation/06-fetch-presentation-definition.js +32 -0
- package/lib/module/credential/presentation/06-fetch-presentation-definition.js.map +1 -0
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js +117 -0
- package/lib/module/credential/presentation/07-evaluate-dcql-query.js.map +1 -0
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js +278 -0
- package/lib/module/credential/presentation/07-evaluate-input-descriptor.js.map +1 -0
- package/lib/module/credential/presentation/08-send-authorization-response.js +158 -0
- package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -0
- package/lib/module/credential/presentation/errors.js +64 -0
- package/lib/module/credential/presentation/errors.js.map +1 -1
- package/lib/module/credential/presentation/index.js +6 -2
- package/lib/module/credential/presentation/index.js.map +1 -1
- package/lib/module/credential/presentation/types.js +121 -2
- package/lib/module/credential/presentation/types.js.map +1 -1
- package/lib/module/sd-jwt/index.js +40 -1
- package/lib/module/sd-jwt/index.js.map +1 -1
- package/lib/module/trust/chain.js.map +1 -1
- package/lib/module/trust/types.js +26 -6
- package/lib/module/trust/types.js.map +1 -1
- package/lib/module/trust/utils.js +5 -0
- package/lib/module/trust/utils.js.map +1 -1
- package/lib/module/utils/jwk.js +3 -0
- package/lib/module/utils/jwk.js.map +1 -1
- package/lib/typescript/credential/issuance/03-start-user-authorization.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/01-start-flow.d.ts +26 -5
- package/lib/typescript/credential/presentation/01-start-flow.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts +7 -10
- package/lib/typescript/credential/presentation/03-get-request-object.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts +23 -0
- package/lib/typescript/credential/presentation/04-retrieve-rp-jwks.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/05-verify-request-object.d.ts +18 -0
- package/lib/typescript/credential/presentation/05-verify-request-object.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts +21 -0
- package/lib/typescript/credential/presentation/06-fetch-presentation-definition.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts +20 -0
- package/lib/typescript/credential/presentation/07-evaluate-dcql-query.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts +88 -0
- package/lib/typescript/credential/presentation/07-evaluate-input-descriptor.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +70 -0
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -0
- package/lib/typescript/credential/presentation/errors.d.ts +44 -0
- package/lib/typescript/credential/presentation/errors.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/index.d.ts +7 -3
- package/lib/typescript/credential/presentation/index.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/types.d.ts +747 -10
- package/lib/typescript/credential/presentation/types.d.ts.map +1 -1
- package/lib/typescript/sd-jwt/index.d.ts +19 -0
- package/lib/typescript/sd-jwt/index.d.ts.map +1 -1
- package/lib/typescript/trust/index.d.ts +236 -8
- package/lib/typescript/trust/index.d.ts.map +1 -1
- package/lib/typescript/trust/types.d.ts +3046 -76
- package/lib/typescript/trust/types.d.ts.map +1 -1
- package/lib/typescript/trust/utils.d.ts +6 -6
- package/lib/typescript/trust/utils.d.ts.map +1 -1
- package/lib/typescript/utils/decoder.d.ts +1 -1
- package/lib/typescript/utils/decoder.d.ts.map +1 -1
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/utils/jwk.d.ts +137 -0
- package/lib/typescript/utils/jwk.d.ts.map +1 -1
- package/lib/typescript/utils/misc.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/types.d.ts +16 -16
- package/package.json +15 -11
- package/src/credential/issuance/03-start-user-authorization.ts +3 -0
- package/src/credential/presentation/01-start-flow.ts +19 -26
- package/src/credential/presentation/03-get-request-object.ts +35 -58
- package/src/credential/presentation/04-retrieve-rp-jwks.ts +34 -0
- package/src/credential/presentation/05-verify-request-object.ts +52 -0
- package/src/credential/presentation/06-fetch-presentation-definition.ts +48 -0
- package/src/credential/presentation/07-evaluate-dcql-query.ts +166 -0
- package/src/credential/presentation/07-evaluate-input-descriptor.ts +391 -0
- package/src/credential/presentation/08-send-authorization-response.ts +220 -0
- package/src/credential/presentation/errors.ts +64 -0
- package/src/credential/presentation/index.ts +22 -1
- package/src/credential/presentation/types.ts +134 -3
- package/src/sd-jwt/index.ts +49 -1
- package/src/trust/chain.ts +2 -2
- package/src/trust/types.ts +25 -5
- package/src/trust/utils.ts +6 -3
- package/src/utils/decoder.ts +1 -1
- package/src/utils/errors.ts +2 -2
- package/src/utils/jwk.ts +8 -1
- package/src/utils/misc.ts +2 -2
- package/lib/commonjs/credential/presentation/04-send-authorization-response.js +0 -138
- package/lib/commonjs/credential/presentation/04-send-authorization-response.js.map +0 -1
- package/lib/module/credential/presentation/04-send-authorization-response.js +0 -128
- package/lib/module/credential/presentation/04-send-authorization-response.js.map +0 -1
- package/lib/typescript/credential/presentation/04-send-authorization-response.d.ts +0 -34
- package/lib/typescript/credential/presentation/04-send-authorization-response.d.ts.map +0 -1
- package/src/credential/presentation/04-send-authorization-response.ts +0 -168
@@ -0,0 +1,158 @@
|
|
1
|
+
import { EncryptJwe } from "@pagopa/io-react-native-jwt";
|
2
|
+
import uuid from "react-native-uuid";
|
3
|
+
import { getJwksFromConfig } from "./04-retrieve-rp-jwks";
|
4
|
+
import { NoSuitableKeysFoundInEntityConfiguration } from "./errors";
|
5
|
+
import { hasStatusOrThrow } from "../../utils/misc";
|
6
|
+
import * as z from "zod";
|
7
|
+
export const AuthorizationResponse = z.object({
|
8
|
+
status: z.string().optional(),
|
9
|
+
response_code: z.string() /**
|
10
|
+
FIXME: [SIW-627] we expect this value from every RP implementation
|
11
|
+
Actually some RP does not return the value
|
12
|
+
We make it optional to not break the flow.
|
13
|
+
*/.optional(),
|
14
|
+
redirect_uri: z.string().optional()
|
15
|
+
});
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Selects a public key (with `use = enc`) from the set of JWK keys
|
19
|
+
* offered by the Relying Party (RP) for encryption.
|
20
|
+
*
|
21
|
+
* @param rpJwkKeys - The array of JWKs retrieved from the RP entity configuration.
|
22
|
+
* @returns The first suitable public key found in the list.
|
23
|
+
* @throws {NoSuitableKeysFoundInEntityConfiguration} If no suitable encryption key is found.
|
24
|
+
*/
|
25
|
+
export const choosePublicKeyToEncrypt = rpJwkKeys => {
|
26
|
+
const encKey = rpJwkKeys.find(jwk => jwk.use === "enc");
|
27
|
+
if (encKey) {
|
28
|
+
return encKey;
|
29
|
+
}
|
30
|
+
|
31
|
+
// No suitable key found
|
32
|
+
throw new NoSuitableKeysFoundInEntityConfiguration("No suitable public key found for encryption.");
|
33
|
+
};
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Builds a URL-encoded form body for a direct POST response using JWT encryption.
|
37
|
+
*
|
38
|
+
* @param jwkKeys - Array of JWKs from the Relying Party for encryption.
|
39
|
+
* @param requestObject - Contains state, nonce, and other relevant info.
|
40
|
+
* @param payload - Object that contains the VP token to encrypt and the mapping of the credential disclosures
|
41
|
+
* @returns A URL-encoded string for an `application/x-www-form-urlencoded` POST body, where `response` contains the encrypted JWE.
|
42
|
+
*/
|
43
|
+
export const buildDirectPostJwtBody = async (requestObject, rpConf, payload) => {
|
44
|
+
// Prepare the authorization response payload to be encrypted
|
45
|
+
const authzResponsePayload = JSON.stringify({
|
46
|
+
state: requestObject.state,
|
47
|
+
...payload
|
48
|
+
});
|
49
|
+
|
50
|
+
// Choose a suitable public key for encryption
|
51
|
+
const {
|
52
|
+
keys
|
53
|
+
} = getJwksFromConfig(rpConf.metadata);
|
54
|
+
const encPublicJwk = choosePublicKeyToEncrypt(keys);
|
55
|
+
|
56
|
+
// Encrypt the authorization payload
|
57
|
+
const {
|
58
|
+
authorization_encrypted_response_alg,
|
59
|
+
authorization_encrypted_response_enc
|
60
|
+
} = rpConf.metadata.openid_credential_verifier;
|
61
|
+
const encryptedResponse = await new EncryptJwe(authzResponsePayload, {
|
62
|
+
alg: authorization_encrypted_response_alg || "RSA-OAEP-256",
|
63
|
+
enc: authorization_encrypted_response_enc || "A256CBC-HS512",
|
64
|
+
kid: encPublicJwk.kid
|
65
|
+
}).encrypt(encPublicJwk);
|
66
|
+
|
67
|
+
// Build the x-www-form-urlencoded form body
|
68
|
+
const formBody = new URLSearchParams({
|
69
|
+
response: encryptedResponse,
|
70
|
+
...(requestObject.state ? {
|
71
|
+
state: requestObject.state
|
72
|
+
} : {})
|
73
|
+
});
|
74
|
+
return formBody.toString();
|
75
|
+
};
|
76
|
+
|
77
|
+
/**
|
78
|
+
* Type definition for the function that sends the authorization response
|
79
|
+
* to the Relying Party, completing the presentation flow.
|
80
|
+
* Use with `presentation_definition`.
|
81
|
+
* @deprecated Use `sendAuthorizationResponse`
|
82
|
+
*/
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Sends the authorization response to the Relying Party (RP) using the specified `response_mode`.
|
86
|
+
* This function completes the presentation flow in an OpenID 4 Verifiable Presentations scenario.
|
87
|
+
*
|
88
|
+
* @param requestObject - The request details, including presentation requirements.
|
89
|
+
* @param presentationDefinition - The definition of the expected presentation.
|
90
|
+
* @param jwkKeys - Array of JWKs from the Relying Party for optional encryption.
|
91
|
+
* @param presentation - Tuple with verifiable credential, claims, and crypto context.
|
92
|
+
* @param context - Contains optional custom fetch implementation.
|
93
|
+
* @returns Parsed and validated authorization response from the Relying Party.
|
94
|
+
*/
|
95
|
+
export const sendLegacyAuthorizationResponse = async function (requestObject, presentationDefinitionId, remotePresentations, rpConf) {
|
96
|
+
var _remotePresentations$;
|
97
|
+
let {
|
98
|
+
appFetch = fetch
|
99
|
+
} = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
100
|
+
/**
|
101
|
+
* 1. Prepare the VP token and presentation submission
|
102
|
+
* If there is only one credential, `vpToken` is a single string.
|
103
|
+
* If there are multiple credential, `vpToken` is an array of string.
|
104
|
+
**/
|
105
|
+
const vp_token = (remotePresentations === null || remotePresentations === void 0 ? void 0 : remotePresentations.length) === 1 ? (_remotePresentations$ = remotePresentations[0]) === null || _remotePresentations$ === void 0 ? void 0 : _remotePresentations$.vpToken : remotePresentations.map(remotePresentation => remotePresentation.vpToken);
|
106
|
+
const descriptor_map = remotePresentations.map((remotePresentation, index) => ({
|
107
|
+
id: remotePresentation.inputDescriptor.id,
|
108
|
+
path: remotePresentations.length === 1 ? `$` : `$[${index}]`,
|
109
|
+
format: remotePresentation.format
|
110
|
+
}));
|
111
|
+
const presentation_submission = {
|
112
|
+
id: uuid.v4(),
|
113
|
+
definition_id: presentationDefinitionId,
|
114
|
+
descriptor_map
|
115
|
+
};
|
116
|
+
const requestBody = await buildDirectPostJwtBody(requestObject, rpConf, {
|
117
|
+
vp_token,
|
118
|
+
presentation_submission
|
119
|
+
});
|
120
|
+
|
121
|
+
// 3. Send the authorization response via HTTP POST and validate the response
|
122
|
+
return await appFetch(requestObject.response_uri, {
|
123
|
+
method: "POST",
|
124
|
+
headers: {
|
125
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
126
|
+
},
|
127
|
+
body: requestBody
|
128
|
+
}).then(hasStatusOrThrow(200)).then(res => res.json()).then(AuthorizationResponse.parse);
|
129
|
+
};
|
130
|
+
|
131
|
+
/**
|
132
|
+
* Type definition for the function that sends the authorization response
|
133
|
+
* to the Relying Party, completing the presentation flow.
|
134
|
+
* Use with DCQL queries.
|
135
|
+
*/
|
136
|
+
|
137
|
+
export const sendAuthorizationResponse = async function (requestObject, remotePresentations, rpConf) {
|
138
|
+
let {
|
139
|
+
appFetch = fetch
|
140
|
+
} = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
141
|
+
// 1. Prepare the VP token as a JSON object with keys corresponding to the DCQL query credential IDs
|
142
|
+
const requestBody = await buildDirectPostJwtBody(requestObject, rpConf, {
|
143
|
+
vp_token: remotePresentations.reduce((acc, presentation) => ({
|
144
|
+
...acc,
|
145
|
+
[presentation.credentialId]: presentation.vpToken
|
146
|
+
}), {})
|
147
|
+
});
|
148
|
+
|
149
|
+
// 2. Send the authorization response via HTTP POST and validate the response
|
150
|
+
return await appFetch(requestObject.response_uri, {
|
151
|
+
method: "POST",
|
152
|
+
headers: {
|
153
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
154
|
+
},
|
155
|
+
body: requestBody
|
156
|
+
}).then(hasStatusOrThrow(200)).then(res => res.json()).then(AuthorizationResponse.parse);
|
157
|
+
};
|
158
|
+
//# sourceMappingURL=08-send-authorization-response.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["EncryptJwe","uuid","getJwksFromConfig","NoSuitableKeysFoundInEntityConfiguration","hasStatusOrThrow","z","AuthorizationResponse","object","status","string","optional","response_code","redirect_uri","choosePublicKeyToEncrypt","rpJwkKeys","encKey","find","jwk","use","buildDirectPostJwtBody","requestObject","rpConf","payload","authzResponsePayload","JSON","stringify","state","keys","metadata","encPublicJwk","authorization_encrypted_response_alg","authorization_encrypted_response_enc","openid_credential_verifier","encryptedResponse","alg","enc","kid","encrypt","formBody","URLSearchParams","response","toString","sendLegacyAuthorizationResponse","presentationDefinitionId","remotePresentations","_remotePresentations$","appFetch","fetch","arguments","length","undefined","vp_token","vpToken","map","remotePresentation","descriptor_map","index","id","inputDescriptor","path","format","presentation_submission","v4","definition_id","requestBody","response_uri","method","headers","body","then","res","json","parse","sendAuthorizationResponse","reduce","acc","presentation","credentialId"],"sourceRoot":"../../../../src","sources":["credential/presentation/08-send-authorization-response.ts"],"mappings":"AAAA,SAASA,UAAU,QAAQ,6BAA6B;AACxD,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAASC,iBAAiB,QAAwB,uBAAuB;AAEzE,SAASC,wCAAwC,QAAQ,UAAU;AACnE,SAASC,gBAAgB,QAAkB,kBAAkB;AAO7D,OAAO,KAAKC,CAAC,MAAM,KAAK;AAKxB,OAAO,MAAMC,qBAAqB,GAAGD,CAAC,CAACE,MAAM,CAAC;EAC5CC,MAAM,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC;EAC7BC,aAAa,EAAEN,CAAC,CACbI,MAAM,CAAC,CAAC,CAAC;AACd;AACA;AACA;AACA,8BAJc,CAKTC,QAAQ,CAAC,CAAC;EACbE,YAAY,EAAEP,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC;AACpC,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,wBAAwB,GACnCC,SAAiC,IACzB;EACR,MAAMC,MAAM,GAAGD,SAAS,CAACE,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,GAAG,KAAK,KAAK,CAAC;EAEzD,IAAIH,MAAM,EAAE;IACV,OAAOA,MAAM;EACf;;EAEA;EACA,MAAM,IAAIZ,wCAAwC,CAChD,8CACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMgB,sBAAsB,GAAG,MAAAA,CACpCC,aAAwD,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ACA;;AAUA,OAAO,MAAMC,yBAAoD,GAAG,eAAAA,CAClErD,aAAa,EACbwB,mBAAmB,EACnBvB,MAAM,EAE6B;EAAA,IADnC;IAAEyB,QAAQ,GAAGC;EAAM,CAAC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAEzB;EACA,MAAMgB,WAAW,GAAG,MAAM7C,sBAAsB,CAACC,aAAa,EAAEC,MAAM,EAAE;IACtE8B,QAAQ,EAAEP,mBAAmB,CAAC8B,MAAM,CAClC,CAACC,GAAG,EAAEC,YAAY,MAAM;MACtB,GAAGD,GAAG;MACN,CAACC,YAAY,CAACC,YAAY,GAAGD,YAAY,CAACxB;IAC5C,CAAC,CAAC,EACF,CAAC,CACH;EACF,CAAC,CAAC;;EAEF;EACA,OAAO,MAAMN,QAAQ,CAAC1B,aAAa,CAAC6C,YAAY,EAAE;IAChDC,MAAM,EAAE,MAAM;IACdC,OAAO,EAAE;MACP,cAAc,EAAE;IAClB,CAAC;IACDC,IAAI,EAAEJ;EACR,CAAC,CAAC,CACCK,IAAI,CAACjE,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAC3BiE,IAAI,CAAEC,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CACzBF,IAAI,CAAC/D,qBAAqB,CAACkE,KAAK,CAAC;AACtC,CAAC"}
|
@@ -39,4 +39,68 @@ export class NoSuitableKeysFoundInEntityConfiguration extends IoWalletError {
|
|
39
39
|
super(message);
|
40
40
|
}
|
41
41
|
}
|
42
|
+
|
43
|
+
/**
|
44
|
+
* When a QR code is not valid.
|
45
|
+
*
|
46
|
+
*/
|
47
|
+
export class InvalidQRCodeError extends IoWalletError {
|
48
|
+
code = "ERR_INVALID_QR_CODE";
|
49
|
+
|
50
|
+
/**
|
51
|
+
* @param detail A description of why the QR code is considered invalid.
|
52
|
+
*/
|
53
|
+
constructor(detail) {
|
54
|
+
const message = `QR code is not valid: ${detail}.`;
|
55
|
+
super(message);
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
/**
|
60
|
+
* When the entity is unverified because the Relying Party is not trusted.
|
61
|
+
*
|
62
|
+
*/
|
63
|
+
export class UnverifiedEntityError extends IoWalletError {
|
64
|
+
code = "ERR_UNVERIFIED_RP_ENTITY";
|
65
|
+
|
66
|
+
/**
|
67
|
+
* @param reason A description of why the entity cannot be verified.
|
68
|
+
*/
|
69
|
+
constructor(reason) {
|
70
|
+
const message = `Unverified entity: ${reason}.`;
|
71
|
+
super(message);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
/**
|
76
|
+
* When some required data is missing to continue because certain attributes are not contained inside the wallet.
|
77
|
+
*
|
78
|
+
*/
|
79
|
+
export class MissingDataError extends IoWalletError {
|
80
|
+
code = "ERR_MISSING_DATA";
|
81
|
+
|
82
|
+
/**
|
83
|
+
* @param missingAttributes An array or description of the attributes that are missing.
|
84
|
+
*/
|
85
|
+
constructor(missingAttributes) {
|
86
|
+
const message = `Some required data is missing: ${missingAttributes}.`;
|
87
|
+
super(message);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
/**
|
92
|
+
* When a credential is not found in the wallet.
|
93
|
+
*
|
94
|
+
*/
|
95
|
+
export class CredentialNotFoundError extends IoWalletError {
|
96
|
+
code = "ERR_CREDENTIAL_NOT_FOUND";
|
97
|
+
|
98
|
+
/**
|
99
|
+
* @param credentialId The ID of the credential that was not found.
|
100
|
+
*/
|
101
|
+
constructor(credentialId) {
|
102
|
+
const message = `Credential not found: ${credentialId}.`;
|
103
|
+
super(message);
|
104
|
+
}
|
105
|
+
}
|
42
106
|
//# sourceMappingURL=errors.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["IoWalletError","serializeAttrs","AuthRequestDecodeError","code","constructor","message","claim","arguments","length","undefined","reason","NoSuitableKeysFoundInEntityConfiguration","scenario"],"sourceRoot":"../../../../src","sources":["credential/presentation/errors.ts"],"mappings":"AAAA,SAASA,aAAa,EAAEC,cAAc,QAAQ,oBAAoB;;AAElE;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,SAASF,aAAa,CAAC;EACxDG,IAAI,GAAG,oDAAoD;;EAE3D;;EAGA;;EAGAC,WAAWA,CACTC,OAAe,EAGf;IAAA,IAFAC,KAAa,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,aAAa;IAAA,IAC7BG,MAAc,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,aAAa;IAE9B,KAAK,CAACN,cAAc,CAAC;MAAEI,OAAO;MAAEC,KAAK;MAAEI;IAAO,CAAC,CAAC,CAAC;IACjD,IAAI,CAACJ,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACI,MAAM,GAAGA,MAAM;EACtB;AACF;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAMC,wCAAwC,SAASX,aAAa,CAAC;EAC1EG,IAAI,GAAG,gCAAgC;;EAEvC;AACF;AACA;EACEC,WAAWA,CAACQ,QAAgB,EAAE;IAC5B,MAAMP,OAAO,GAAI,0DAAyDO,QAAS,IAAG;IACtF,KAAK,CAACP,OAAO,CAAC;EAChB;AACF"}
|
1
|
+
{"version":3,"names":["IoWalletError","serializeAttrs","AuthRequestDecodeError","code","constructor","message","claim","arguments","length","undefined","reason","NoSuitableKeysFoundInEntityConfiguration","scenario","InvalidQRCodeError","detail","UnverifiedEntityError","MissingDataError","missingAttributes","CredentialNotFoundError","credentialId"],"sourceRoot":"../../../../src","sources":["credential/presentation/errors.ts"],"mappings":"AAAA,SAASA,aAAa,EAAEC,cAAc,QAAQ,oBAAoB;;AAElE;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,SAASF,aAAa,CAAC;EACxDG,IAAI,GAAG,oDAAoD;;EAE3D;;EAGA;;EAGAC,WAAWA,CACTC,OAAe,EAG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MZ,OAAO,GAAI,kCAAiCY,iBAAkB,GAAE;IACtE,KAAK,CAACZ,OAAO,CAAC;EAChB;AACF;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAMa,uBAAuB,SAASlB,aAAa,CAAC;EACzDG,IAAI,GAAG,0BAA0B;;EAEjC;AACF;AACA;EACEC,WAAWA,CAACe,YAAoB,EAAE;IAChC,MAAMd,OAAO,GAAI,yBAAwBc,YAAa,GAAE;IACxD,KAAK,CAACd,OAAO,CAAC;EAChB;AACF"}
|
@@ -1,7 +1,11 @@
|
|
1
1
|
import { startFlowFromQR } from "./01-start-flow";
|
2
2
|
import { evaluateRelyingPartyTrust } from "./02-evaluate-rp-trust";
|
3
3
|
import { getRequestObject } from "./03-get-request-object";
|
4
|
-
import {
|
4
|
+
import { getJwksFromConfig } from "./04-retrieve-rp-jwks";
|
5
|
+
import { verifyRequestObject } from "./05-verify-request-object";
|
6
|
+
import { fetchPresentDefinition } from "./06-fetch-presentation-definition";
|
7
|
+
import { evaluateInputDescriptorForSdJwt4VC } from "./07-evaluate-input-descriptor";
|
8
|
+
import { sendAuthorizationResponse } from "./08-send-authorization-response";
|
5
9
|
import * as Errors from "./errors";
|
6
|
-
export { startFlowFromQR, evaluateRelyingPartyTrust, getRequestObject, sendAuthorizationResponse, Errors };
|
10
|
+
export { startFlowFromQR, evaluateRelyingPartyTrust, getRequestObject, getJwksFromConfig, verifyRequestObject, fetchPresentDefinition, evaluateInputDescriptorForSdJwt4VC, sendAuthorizationResponse, Errors };
|
7
11
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["startFlowFromQR","evaluateRelyingPartyTrust","getRequestObject","sendAuthorizationResponse","Errors"],"sourceRoot":"../../../../src","sources":["credential/presentation/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAwB,iBAAiB;AACjE,SACEC,yBAAyB,QAEpB,wBAAwB;AAC/B,SACEC,gBAAgB,QAEX,yBAAyB;AAChC,SACEC,yBAAyB,QAEpB,kCAAkC;AACzC,OAAO,KAAKC,MAAM,MAAM,UAAU;AAElC,
|
1
|
+
{"version":3,"names":["startFlowFromQR","evaluateRelyingPartyTrust","getRequestObject","getJwksFromConfig","verifyRequestObject","fetchPresentDefinition","evaluateInputDescriptorForSdJwt4VC","sendAuthorizationResponse","Errors"],"sourceRoot":"../../../../src","sources":["credential/presentation/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAwB,iBAAiB;AACjE,SACEC,yBAAyB,QAEpB,wBAAwB;AAC/B,SACEC,gBAAgB,QAEX,yBAAyB;AAChC,SAASC,iBAAiB,QAAwB,uBAAuB;AACzE,SACEC,mBAAmB,QAEd,4BAA4B;AACnC,SACEC,sBAAsB,QAEjB,oCAAoC;AAC3C,SACEC,kCAAkC,QAE7B,gCAAgC;AACvC,SACEC,yBAAyB,QAEpB,kCAAkC;AACzC,OAAO,KAAKC,MAAM,MAAM,UAAU;AAElC,SACER,eAAe,EACfC,yBAAyB,EACzBC,gBAAgB,EAChBC,iBAAiB,EACjBC,mBAAmB,EACnBC,sBAAsB,EACtBC,kCAAkC,EAClCC,yBAAyB,EACzBC,MAAM"}
|
@@ -5,6 +5,80 @@ import * as z from "zod";
|
|
5
5
|
* A pair that associate a tokenized Verified Credential with the claims presented or requested to present.
|
6
6
|
*/
|
7
7
|
|
8
|
+
/**
|
9
|
+
* A object that associate the information needed to multiple remote presentation
|
10
|
+
* Used with `presentation_definition`
|
11
|
+
* @deprecated Use `RemotePresentation`
|
12
|
+
*/
|
13
|
+
|
14
|
+
/**
|
15
|
+
* A object that associate the information needed to multiple remote presentation
|
16
|
+
* Used with DCQL queries
|
17
|
+
*/
|
18
|
+
|
19
|
+
const Fields = z.object({
|
20
|
+
path: z.array(z.string().min(1)),
|
21
|
+
// Array of JSONPath string expressions
|
22
|
+
id: z.string().optional(),
|
23
|
+
// Unique string ID
|
24
|
+
purpose: z.string().optional(),
|
25
|
+
// Purpose of the field
|
26
|
+
name: z.string().optional(),
|
27
|
+
// Human-friendly name
|
28
|
+
filter: z.any().optional(),
|
29
|
+
// JSON Schema descriptor for filtering
|
30
|
+
optional: z.boolean().optional(),
|
31
|
+
// Boolean indicating if the field is optional
|
32
|
+
intent_to_retain: z.boolean().optional() // Boolean indicating that the Verifier intends to retain the Claim's data being requested
|
33
|
+
});
|
34
|
+
|
35
|
+
// Define the Constraints Object Schema
|
36
|
+
const Constraints = z.object({
|
37
|
+
fields: z.array(Fields).optional(),
|
38
|
+
// Array of Field Objects
|
39
|
+
limit_disclosure: z.enum(["required", "preferred"]).optional() // Limit disclosure property
|
40
|
+
});
|
41
|
+
|
42
|
+
// Define the Input Descriptor Object Schema
|
43
|
+
|
44
|
+
export const InputDescriptor = z.object({
|
45
|
+
id: z.string().min(1),
|
46
|
+
// Mandatory unique string ID
|
47
|
+
name: z.string().optional(),
|
48
|
+
// Human-friendly name
|
49
|
+
purpose: z.string().optional(),
|
50
|
+
// Purpose of the schema
|
51
|
+
format: z.record(z.string(), z.any()).optional(),
|
52
|
+
// Object with Claim Format Designations
|
53
|
+
constraints: Constraints,
|
54
|
+
// Constraints Object (mandatory)
|
55
|
+
group: z.string().optional() // Match one of the grouping strings listed in the "from" values of a Submission Requirement Rule
|
56
|
+
});
|
57
|
+
|
58
|
+
const SubmissionRequirement = z.object({
|
59
|
+
name: z.string().optional(),
|
60
|
+
purpose: z.string().optional(),
|
61
|
+
rule: z.string(),
|
62
|
+
// "all": all group's rules must be present, or "pick": at least group's "count" rules must be present
|
63
|
+
from: z.string().optional(),
|
64
|
+
// MUST contain either a "from" or "from_nested" property
|
65
|
+
from_nested: z.array(z.object({
|
66
|
+
name: z.string().optional(),
|
67
|
+
purpose: z.string().optional(),
|
68
|
+
rule: z.string(),
|
69
|
+
from: z.string()
|
70
|
+
})).optional(),
|
71
|
+
count: z.number().optional()
|
72
|
+
//"count", "min", and "max" may be present with a "pick" rule
|
73
|
+
});
|
74
|
+
|
75
|
+
export const PresentationDefinition = z.object({
|
76
|
+
id: z.string(),
|
77
|
+
name: z.string().optional(),
|
78
|
+
purpose: z.string().optional(),
|
79
|
+
input_descriptors: z.array(InputDescriptor),
|
80
|
+
submission_requirements: z.array(SubmissionRequirement).optional()
|
81
|
+
});
|
8
82
|
export const RequestObject = z.object({
|
9
83
|
iss: z.string(),
|
10
84
|
iat: UnixTime,
|
@@ -12,10 +86,55 @@ export const RequestObject = z.object({
|
|
12
86
|
state: z.string(),
|
13
87
|
nonce: z.string(),
|
14
88
|
response_uri: z.string(),
|
89
|
+
response_uri_method: z.string().optional(),
|
15
90
|
response_type: z.literal("vp_token"),
|
16
91
|
response_mode: z.literal("direct_post.jwt"),
|
17
92
|
client_id: z.string(),
|
18
|
-
|
19
|
-
|
93
|
+
dcql_query: z.record(z.string(), z.any()).optional(),
|
94
|
+
// Validation happens within the `dcql` library, no need to duplicate it here
|
95
|
+
scope: z.string().optional(),
|
96
|
+
presentation_definition: PresentationDefinition.optional()
|
97
|
+
});
|
98
|
+
export const WalletMetadata = z.object({
|
99
|
+
presentation_definition_uri_supported: z.boolean().optional(),
|
100
|
+
client_id_schemes_supported: z.array(z.string()).optional(),
|
101
|
+
request_object_signing_alg_values_supported: z.array(z.string()).optional(),
|
102
|
+
vp_formats_supported: z.record(z.string(),
|
103
|
+
// TODO [SIW-2110]: use explicit credential format?
|
104
|
+
z.object({
|
105
|
+
"sd-jwt_alg_values": z.array(z.string()).optional() // alg_values_supported?
|
106
|
+
}))
|
107
|
+
// TODO [SIW-2110]: include other metadata?
|
108
|
+
});
|
109
|
+
|
110
|
+
/**
|
111
|
+
* Wallet capabilities that must be submitted to get the Request Object
|
112
|
+
* via POST request when the `request_uri_method` is `post`.
|
113
|
+
*/
|
114
|
+
|
115
|
+
export const RequestObjectWalletCapabilities = z.object({
|
116
|
+
wallet_metadata: WalletMetadata,
|
117
|
+
wallet_nonce: z.string().optional()
|
118
|
+
});
|
119
|
+
|
120
|
+
/**
|
121
|
+
* Authorization Response payload when using `presentation_definition`.
|
122
|
+
* @deprecated Use `DirectAuthorizationBodyPayload`
|
123
|
+
*/
|
124
|
+
|
125
|
+
/**
|
126
|
+
* @deprecated Use `DirectAuthorizationBodyPayload`
|
127
|
+
*/
|
128
|
+
export const LegacyDirectAuthorizationBodyPayload = z.object({
|
129
|
+
vp_token: z.union([z.string(), z.array(z.string())]).optional(),
|
130
|
+
presentation_submission: z.record(z.string(), z.unknown())
|
131
|
+
});
|
132
|
+
|
133
|
+
/**
|
134
|
+
* Authorization Response payload when using DCQL queries.
|
135
|
+
*/
|
136
|
+
|
137
|
+
export const DirectAuthorizationBodyPayload = z.object({
|
138
|
+
vp_token: z.record(z.string(), z.string())
|
20
139
|
});
|
21
140
|
//# sourceMappingURL=types.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["UnixTime","z","
|
1
|
+
{"version":3,"names":["UnixTime","z","Fields","object","path","array","string","min","id","optional","purpose","name","filter","any","boolean","intent_to_retain","Constraints","fields","limit_disclosure","enum","InputDescriptor","format","record","constraints","group","SubmissionRequirement","rule","from","from_nested","count","number","PresentationDefinition","input_descriptors","submission_requirements","RequestObject","iss","iat","exp","state","nonce","response_uri","response_uri_method","response_type","literal","response_mode","client_id","dcql_query","scope","presentation_definition","WalletMetadata","presentation_definition_uri_supported","client_id_schemes_supported","request_object_signing_alg_values_supported","vp_formats_supported","RequestObjectWalletCapabilities","wallet_metadata","wallet_nonce","LegacyDirectAuthorizationBodyPayload","vp_token","union","presentation_submission","unknown","DirectAuthorizationBodyPayload"],"sourceRoot":"../../../../src","sources":["credential/presentation/types.ts"],"mappings":"AACA,SAASA,QAAQ,QAAQ,oBAAoB;AAC7C,OAAO,KAAKC,CAAC,MAAM,KAAK;;AAExB;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;;AAQA,MAAMC,MAAM,GAAGD,CAAC,CAACE,MAAM,CAAC;EACtBC,IAAI,EAAEH,CAAC,CAACI,KAAK,CAACJ,CAAC,CAACK,MAAM,CA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AG7D,CAAC,CAACE,MAAM,CAAC;EACrDuD,QAAQ,EAAEzD,CAAC,CAACqB,MAAM,CAACrB,CAAC,CAACK,MAAM,CAAC,CAAC,EAAEL,CAAC,CAACK,MAAM,CAAC,CAAC;AAC3C,CAAC,CAAC"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { decode as decodeJwt } from "@pagopa/io-react-native-jwt";
|
2
2
|
import { verify as verifyJwt } from "@pagopa/io-react-native-jwt";
|
3
|
-
import { sha256ToBase64 } from "@pagopa/io-react-native-jwt";
|
3
|
+
import { SignJWT, sha256ToBase64 } from "@pagopa/io-react-native-jwt";
|
4
4
|
import { Disclosure, SdJwt4VC } from "./types";
|
5
5
|
import { verifyDisclosure } from "./verifier";
|
6
6
|
import * as Errors from "./errors";
|
@@ -149,5 +149,44 @@ export const verify = async (token, publicKey, customSchema) => {
|
|
149
149
|
disclosures: decoded.disclosures.map(d => d.decoded)
|
150
150
|
};
|
151
151
|
};
|
152
|
+
|
153
|
+
/**
|
154
|
+
* Prepares a Verified Presentation (VP) token to be sent as part of an
|
155
|
+
* authorization response in an OpenID 4 Verifiable Presentations flow.
|
156
|
+
*
|
157
|
+
* @param nonce - The nonce provided by the relying party.
|
158
|
+
* @param client_id - The client identifier of the relying party.
|
159
|
+
* @param presentation - An object containing the verifiable credential, the claims to disclose,
|
160
|
+
* and the cryptographic context for signing.
|
161
|
+
* @returns An object containing the signed VP token (`vp_token`).
|
162
|
+
*
|
163
|
+
* @remarks
|
164
|
+
* 1. The `disclose()` function is used to produce a token with only the requested claims.
|
165
|
+
* 2. A KB-JWT is then signed, including sd_hash and `nonce`.
|
166
|
+
* 3. The `vp_token` is composed of the disclosed VP and the KB-JWT.
|
167
|
+
*/
|
168
|
+
export const prepareVpToken = async (nonce, client_id, _ref2) => {
|
169
|
+
let [verifiableCredential, requestedClaims, cryptoContext] = _ref2;
|
170
|
+
// Produce a VP token with only requested claims from the verifiable credential
|
171
|
+
const {
|
172
|
+
token: vp
|
173
|
+
} = await disclose(verifiableCredential, requestedClaims);
|
174
|
+
|
175
|
+
// <Issuer-signed JWT>~<Disclosure 1>~<Disclosure N>~
|
176
|
+
const sd_hash = await sha256ToBase64(`${vp}~`);
|
177
|
+
const kbJwt = await new SignJWT(cryptoContext).setProtectedHeader({
|
178
|
+
typ: "kb+jwt",
|
179
|
+
alg: "ES256"
|
180
|
+
}).setPayload({
|
181
|
+
sd_hash,
|
182
|
+
nonce: nonce
|
183
|
+
}).setAudience(client_id).setIssuedAt().sign();
|
184
|
+
|
185
|
+
// <Issuer-signed JWT>~<Disclosure 1>~...~<Disclosure N>~<KB-JWT>
|
186
|
+
const vp_token = [vp, kbJwt].join("~");
|
187
|
+
return {
|
188
|
+
vp_token
|
189
|
+
};
|
190
|
+
};
|
152
191
|
export { SdJwt4VC, Errors };
|
153
192
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["decode","decodeJwt","verify","verifyJwt","sha256ToBase64","Disclosure","SdJwt4VC","verifyDisclosure","Errors","Base64","decodeDisclosure","encoded","utf8String","decoded","parse","JSON","token","customSchema","slice","rawSdJwt","rawDisclosures","split","decodedJwt","parser","sdJwt","header","protectedHeader","payload","disclosures","map","disclose","claims","paths","Promise","all","claim","disclosure","find","_ref","name","ClaimsNotFoundBetweenDisclosures","hash","_sd","includes","index","indexOf","path","ClaimsNotFoundInToken","filteredDisclosures","filter","d","disclosedToken","join","publicKey"],"sourceRoot":"../../../src","sources":["sd-jwt/index.ts"],"mappings":"AAEA,SAASA,MAAM,IAAIC,SAAS,QAAQ,6BAA6B;AACjE,SAASC,MAAM,IAAIC,SAAS,QAAQ,6BAA6B;AACjE,SAASC,cAAc,QAAQ,6BAA6B;
|
1
|
+
{"version":3,"names":["decode","decodeJwt","verify","verifyJwt","SignJWT","sha256ToBase64","Disclosure","SdJwt4VC","verifyDisclosure","Errors","Base64","decodeDisclosure","encoded","utf8String","decoded","parse","JSON","token","customSchema","slice","rawSdJwt","rawDisclosures","split","decodedJwt","parser","sdJwt","header","protectedHeader","payload","disclosures","map","disclose","claims","paths","Promise","all","claim","disclosure","find","_ref","name","ClaimsNotFoundBetweenDisclosures","hash","_sd","includes","index","indexOf","path","ClaimsNotFoundInToken","filteredDisclosures","filter","d","disclosedToken","join","publicKey","prepareVpToken","nonce","client_id","_ref2","verifiableCredential","requestedClaims","cryptoContext","vp","sd_hash","kbJwt","setProtectedHeader","typ","alg","setPayload","setAudience","setIssuedAt","sign","vp_token"],"sourceRoot":"../../../src","sources":["sd-jwt/index.ts"],"mappings":"AAEA,SAASA,MAAM,IAAIC,SAAS,QAAQ,6BAA6B;AACjE,SAASC,MAAM,IAAIC,SAAS,QAAQ,6BAA6B;AACjE,SAASC,OAAO,EAAEC,cAAc,QAAQ,6BAA6B;AACrE,SAASC,UAAU,EAAEC,QAAQ,QAAoC,SAAS;AAC1E,SAASC,gBAAgB,QAAQ,YAAY;AAE7C,OAAO,KAAKC,MAAM,MAAM,UAAU;AAClC,SAASC,MAAM,QAAQ,WAAW;AAGlC,MAAMC,gBAAgB,GAAIC,OAAe,IAA4B;EACnE,MAAMC,UAAU,GAAGH,MAAM,CAACV,MAAM,CAACY,OAAO,CAAC,CAAC,CAAC;EAC3C,MAAME,OAAO,GAAGR,UAAU,CAACS,KAAK,CAACC,IAAI,CAACD,KAAK,CAACF,UAAU,CAAC,CAAC;EACxD,OAAO;IAAEC,OAAO;IAAEF;EAAQ,CAAC;AAC7B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMZ,MAAM,GAAGA,CACpBiB,KAAa,EACbC,YAAgB,KAIb;EACH;EACA,IAAID,KAAK,CAACE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;IAC3BF,KAAK,GAAGA,KAAK,CAACE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;EAC5B;EACA,MAAM,CAACC,QAAQ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,SAASjE,QAAQ,EAAEE,MAAM"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["EntityConfiguration","EntityStatement","TrustAnchorEntityConfiguration","IoWalletError","z","getSignedEntityConfiguration","getSignedEntityStatement","decode","verify","FirstElementShape","MiddleElementShape","LastElementShape","union","validateTrustChain","trustAnchorEntity","chain","length","selectTokenShape","elementIndex","selectKid","currentIndex","token","shape","parse","header","kid","selectKeys","payload","jwks","keys","nextIndex","nextToken","Promise","all","map","i","args","renewTrustChain","appFetch","arguments","undefined","fetch","index","decoded","entityStatementResult","safeParse","entityConfigurationResult","success","data","iss","entityStatement","parentBaseUrl","parentECJwt","parentEC","federationFetchEndpoint","metadata","federation_entity","federation_fetch_endpoint","sub"],"sourceRoot":"../../../src","sources":["trust/chain.ts"],"mappings":"AAAA,SACEA,mBAAmB,EACnBC,eAAe,EACfC,8BAA8B,QACzB,SAAS;AAEhB,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,OAAO,KAAKC,CAAC,MAAM,KAAK;AACxB,SAASC,4BAA4B,EAAEC,wBAAwB,QAAQ,GAAG;AAC1E,SAASC,MAAM,EAAoBC,MAAM,QAAQ,SAAS;;AAE1D;AACA,MAAMC,iBAAiB,GAAGT,mBAAmB;AAC7C;AACA,MAAMU,kBAAkB,GAAGT,eAAe;AAC1C;AACA;AACA,MAAMU,gBAAgB,GAAGP,CAAC,CAACQ,KAAK,CAAC,CAC/BX,eAAe,EACfC,8BAA8B,CAC/B,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeW,kBAAkBA,CACtCC,iBAAiD,EACjDC,KAAe,EACS;EACxB;EACA,IAAIA,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE;IACtB,MAAM,IAAIb,aAAa,CAAC,iCAAiC,CAAC;EAC5D;;EAEA;EACA,MAAMc,gBAAgB,GAAIC,YAAoB,IAC5CA,YAAY,KAAK,CAAC,GACdT,iBAAiB,GACjBS,YAAY,KAAKH,KAAK,CAACC,MAAM,GAAG,CAAC,
|
1
|
+
{"version":3,"names":["EntityConfiguration","EntityStatement","TrustAnchorEntityConfiguration","IoWalletError","z","getSignedEntityConfiguration","getSignedEntityStatement","decode","verify","FirstElementShape","MiddleElementShape","LastElementShape","union","validateTrustChain","trustAnchorEntity","chain","length","selectTokenShape","elementIndex","selectKid","currentIndex","token","shape","parse","header","kid","selectKeys","payload","jwks","keys","nextIndex","nextToken","Promise","all","map","i","args","renewTrustChain","appFetch","arguments","undefined","fetch","index","decoded","entityStatementResult","safeParse","entityConfigurationResult","success","data","iss","entityStatement","parentBaseUrl","parentECJwt","parentEC","federationFetchEndpoint","metadata","federation_entity","federation_fetch_endpoint","sub"],"sourceRoot":"../../../src","sources":["trust/chain.ts"],"mappings":"AAAA,SACEA,mBAAmB,EACnBC,eAAe,EACfC,8BAA8B,QACzB,SAAS;AAEhB,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,OAAO,KAAKC,CAAC,MAAM,KAAK;AACxB,SAASC,4BAA4B,EAAEC,wBAAwB,QAAQ,GAAG;AAC1E,SAASC,MAAM,EAAoBC,MAAM,QAAQ,SAAS;;AAE1D;AACA,MAAMC,iBAAiB,GAAGT,mBAAmB;AAC7C;AACA,MAAMU,kBAAkB,GAAGT,eAAe;AAC1C;AACA;AACA,MAAMU,gBAAgB,GAAGP,CAAC,CAACQ,KAAK,CAAC,CAC/BX,eAAe,EACfC,8BAA8B,CAC/B,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeW,kBAAkBA,CACtCC,iBAAiD,EACjDC,KAAe,EACS;EACxB;EACA,IAAIA,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE;IACtB,MAAM,IAAIb,aAAa,CAAC,iCAAiC,CAAC;EAC5D;;EAEA;EACA,MAAMc,gBAAgB,GAAIC,YAAoB,IAC5CA,YAAY,KAAK,CAAC,GACdT,iBAAiB,GACjBS,YAAY,KAAKH,KAAK,CAACC,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IACA,MAAM,IAAInC,aAAa,CACpB,6CAA4CuC,KAAM,mBACrD,CAAC;EACH,CAAC,CACH,CAAC;AACH"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { UnixTime } from "../sd-jwt/types";
|
2
2
|
import { JWK } from "../utils/jwk";
|
3
3
|
import * as z from "zod";
|
4
|
+
import { PresentationDefinition } from "../credential/presentation/types";
|
4
5
|
export const TrustMark = z.object({
|
5
6
|
id: z.string(),
|
6
7
|
trust_mark: z.string()
|
@@ -12,7 +13,12 @@ const RelyingPartyMetadata = z.object({
|
|
12
13
|
jwks: z.object({
|
13
14
|
keys: z.array(JWK)
|
14
15
|
}),
|
15
|
-
contacts: z.array(z.string()).optional()
|
16
|
+
contacts: z.array(z.string()).optional(),
|
17
|
+
presentation_definition: PresentationDefinition.optional(),
|
18
|
+
request_uris: z.array(z.string()).optional(),
|
19
|
+
authorization_signed_response_alg: z.string().optional(),
|
20
|
+
authorization_encrypted_response_alg: z.string().optional(),
|
21
|
+
authorization_encrypted_response_enc: z.string().optional()
|
16
22
|
});
|
17
23
|
|
18
24
|
// Display metadata for a credential, used by the issuer to
|
@@ -156,10 +162,24 @@ export const CredentialIssuerEntityConfiguration = BaseEntityConfiguration.and(z
|
|
156
162
|
token_endpoint_auth_signing_alg_values_supported: z.array(z.string()),
|
157
163
|
request_object_signing_alg_values_supported: z.array(z.string())
|
158
164
|
}),
|
159
|
-
/**
|
160
|
-
|
161
|
-
|
162
|
-
|
165
|
+
/**
|
166
|
+
* Credential Issuers act as Relying Party when they require the presentation of other credentials.
|
167
|
+
* This does not apply for PID issuance, which requires CIE authz.
|
168
|
+
*/
|
169
|
+
openid_credential_verifier: RelyingPartyMetadata.optional(),
|
170
|
+
/**
|
171
|
+
* @deprecated use `openid_credential_verifier`
|
172
|
+
* TODO [SIW-2111]: remove after migrating to 0.9.x
|
173
|
+
*/
|
174
|
+
wallet_relying_party: z.object({
|
175
|
+
application_type: z.string().optional(),
|
176
|
+
client_id: z.string().optional(),
|
177
|
+
client_name: z.string().optional(),
|
178
|
+
jwks: z.object({
|
179
|
+
keys: z.array(JWK)
|
180
|
+
}),
|
181
|
+
contacts: z.array(z.string()).optional()
|
182
|
+
}).optional()
|
163
183
|
})
|
164
184
|
})
|
165
185
|
}));
|
@@ -169,7 +189,7 @@ export const CredentialIssuerEntityConfiguration = BaseEntityConfiguration.and(z
|
|
169
189
|
export const RelyingPartyEntityConfiguration = BaseEntityConfiguration.and(z.object({
|
170
190
|
payload: z.object({
|
171
191
|
metadata: z.object({
|
172
|
-
|
192
|
+
openid_credential_verifier: RelyingPartyMetadata
|
173
193
|
})
|
174
194
|
})
|
175
195
|
}));
|