@pagopa/io-react-native-wallet 2.0.0-next.1 → 2.0.0-next.2
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/02-evaluate-issuer-trust.js +2 -2
- package/lib/commonjs/credential/issuance/02-evaluate-issuer-trust.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/05-verify-request-object.js.map +1 -1
- package/lib/commonjs/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/commonjs/trust/build-chain.js +252 -0
- package/lib/commonjs/trust/build-chain.js.map +1 -0
- package/lib/commonjs/trust/index.js +11 -282
- package/lib/commonjs/trust/index.js.map +1 -1
- package/lib/commonjs/trust/{chain.js → verify-chain.js} +40 -5
- package/lib/commonjs/trust/verify-chain.js.map +1 -0
- package/lib/commonjs/utils/errors.js.map +1 -1
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.js +1 -1
- package/lib/module/credential/issuance/02-evaluate-issuer-trust.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/05-verify-request-object.js.map +1 -1
- package/lib/module/credential/presentation/08-send-authorization-response.js +1 -1
- package/lib/module/credential/presentation/08-send-authorization-response.js.map +1 -1
- package/lib/module/trust/build-chain.js +235 -0
- package/lib/module/trust/build-chain.js.map +1 -0
- package/lib/module/trust/index.js +5 -268
- package/lib/module/trust/index.js.map +1 -1
- package/lib/module/trust/{chain.js → verify-chain.js} +36 -2
- package/lib/module/trust/verify-chain.js.map +1 -0
- package/lib/module/utils/errors.js +1 -1
- package/lib/module/utils/errors.js.map +1 -1
- package/lib/typescript/client/generated/wallet-provider.d.ts +12 -12
- package/lib/typescript/credential/issuance/02-evaluate-issuer-trust.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/02-evaluate-rp-trust.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/05-verify-request-object.d.ts +1 -1
- package/lib/typescript/credential/presentation/05-verify-request-object.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts +2 -2
- package/lib/typescript/credential/presentation/08-send-authorization-response.d.ts.map +1 -1
- package/lib/typescript/credential/presentation/types.d.ts +4 -4
- package/lib/typescript/trust/build-chain.d.ts +1284 -0
- package/lib/typescript/trust/build-chain.d.ts.map +1 -0
- package/lib/typescript/trust/index.d.ts +5 -1301
- package/lib/typescript/trust/index.d.ts.map +1 -1
- package/lib/typescript/trust/types.d.ts +506 -506
- package/lib/typescript/trust/{chain.d.ts → verify-chain.d.ts} +17 -1
- package/lib/typescript/trust/verify-chain.d.ts.map +1 -0
- package/lib/typescript/utils/errors.d.ts +2 -2
- package/lib/typescript/utils/errors.d.ts.map +1 -1
- package/lib/typescript/wallet-instance-attestation/types.d.ts +4 -4
- package/package.json +1 -1
- package/src/credential/issuance/02-evaluate-issuer-trust.ts +1 -1
- package/src/credential/presentation/02-evaluate-rp-trust.ts +1 -1
- package/src/credential/presentation/05-verify-request-object.ts +1 -1
- package/src/credential/presentation/08-send-authorization-response.ts +4 -4
- package/src/trust/build-chain.ts +395 -0
- package/src/trust/index.ts +5 -442
- package/src/trust/{chain.ts → verify-chain.ts} +41 -1
- package/src/utils/errors.ts +4 -4
- package/lib/commonjs/trust/chain.js.map +0 -1
- package/lib/module/trust/chain.js.map +0 -1
- package/lib/typescript/trust/chain.d.ts.map +0 -1
package/src/trust/index.ts
CHANGED
@@ -1,443 +1,6 @@
|
|
1
|
-
import
|
2
|
-
import
|
3
|
-
import
|
4
|
-
|
5
|
-
EntityConfiguration,
|
6
|
-
EntityStatement,
|
7
|
-
FederationListResponse,
|
8
|
-
RelyingPartyEntityConfiguration,
|
9
|
-
TrustAnchorEntityConfiguration,
|
10
|
-
WalletProviderEntityConfiguration,
|
11
|
-
} from "./types";
|
12
|
-
import { renewTrustChain, validateTrustChain } from "./chain";
|
13
|
-
import { hasStatusOrThrow } from "../utils/misc";
|
14
|
-
import type { JWK } from "../utils/jwk";
|
15
|
-
import {
|
16
|
-
BuildTrustChainError,
|
17
|
-
FederationListParseError,
|
18
|
-
MissingFederationFetchEndpointError,
|
19
|
-
RelyingPartyNotAuthorizedError,
|
20
|
-
TrustAnchorKidMissingError,
|
21
|
-
} from "./errors";
|
22
|
-
import type { X509CertificateOptions } from "@pagopa/io-react-native-crypto";
|
1
|
+
import * as Build from "./build-chain";
|
2
|
+
import * as Verify from "./verify-chain";
|
3
|
+
import * as Errors from "./errors";
|
4
|
+
import * as Types from "./types";
|
23
5
|
|
24
|
-
export
|
25
|
-
WalletProviderEntityConfiguration,
|
26
|
-
TrustAnchorEntityConfiguration,
|
27
|
-
CredentialIssuerEntityConfiguration,
|
28
|
-
RelyingPartyEntityConfiguration,
|
29
|
-
EntityConfiguration,
|
30
|
-
EntityStatement,
|
31
|
-
};
|
32
|
-
|
33
|
-
/**
|
34
|
-
* Verify a given trust chain is actually valid.
|
35
|
-
* It can handle fast chain renewal, which means we try to fetch a fresh version of each statement.
|
36
|
-
*
|
37
|
-
* @param trustAnchorEntity The entity configuration of the known trust anchor
|
38
|
-
* @param chain The chain of statements to be validated
|
39
|
-
* @param x509Options Options for the verification process
|
40
|
-
* @param appFetch (optional) fetch api implementation
|
41
|
-
* @param renewOnFail Whether to attempt to renew the trust chain if the initial validation fails
|
42
|
-
* @returns The result of the chain validation
|
43
|
-
* @throws {FederationError} If the chain is not valid
|
44
|
-
*/
|
45
|
-
export async function verifyTrustChain(
|
46
|
-
trustAnchorEntity: TrustAnchorEntityConfiguration,
|
47
|
-
chain: string[],
|
48
|
-
x509Options: X509CertificateOptions = {
|
49
|
-
connectTimeout: 10000,
|
50
|
-
readTimeout: 10000,
|
51
|
-
requireCrl: true,
|
52
|
-
},
|
53
|
-
{
|
54
|
-
appFetch = fetch,
|
55
|
-
renewOnFail = true,
|
56
|
-
}: { appFetch?: GlobalFetch["fetch"]; renewOnFail?: boolean } = {}
|
57
|
-
): Promise<ReturnType<typeof validateTrustChain>> {
|
58
|
-
try {
|
59
|
-
return validateTrustChain(trustAnchorEntity, chain, x509Options);
|
60
|
-
} catch (error) {
|
61
|
-
if (renewOnFail) {
|
62
|
-
const renewedChain = await renewTrustChain(chain, appFetch);
|
63
|
-
return validateTrustChain(trustAnchorEntity, renewedChain, x509Options);
|
64
|
-
} else {
|
65
|
-
throw error;
|
66
|
-
}
|
67
|
-
}
|
68
|
-
}
|
69
|
-
|
70
|
-
/**
|
71
|
-
* Fetch the signed entity configuration token for an entity
|
72
|
-
*
|
73
|
-
* @param entityBaseUrl The url of the entity to fetch
|
74
|
-
* @param appFetch (optional) fetch api implementation
|
75
|
-
* @returns The signed Entity Configuration token
|
76
|
-
*/
|
77
|
-
export async function getSignedEntityConfiguration(
|
78
|
-
entityBaseUrl: string,
|
79
|
-
{
|
80
|
-
appFetch = fetch,
|
81
|
-
}: {
|
82
|
-
appFetch?: GlobalFetch["fetch"];
|
83
|
-
} = {}
|
84
|
-
): Promise<string> {
|
85
|
-
const wellKnownUrl = `${entityBaseUrl}/.well-known/openid-federation`;
|
86
|
-
|
87
|
-
return await appFetch(wellKnownUrl, {
|
88
|
-
method: "GET",
|
89
|
-
})
|
90
|
-
.then(hasStatusOrThrow(200))
|
91
|
-
.then((res) => res.text());
|
92
|
-
}
|
93
|
-
|
94
|
-
/**
|
95
|
-
* Fetch and parse the entity configuration document for a given federation entity.
|
96
|
-
* This is an inner method to serve public interfaces.
|
97
|
-
*
|
98
|
-
* To add another entity configuration type (example: Foo entity type):
|
99
|
-
* - create its zod schema and type by inherit from the base type (example: FooEntityConfiguration = BaseEntityConfiguration.and(...))
|
100
|
-
* - add such type to EntityConfiguration union
|
101
|
-
* - add an overload to this function
|
102
|
-
* - create a public function which use such type (example: getFooEntityConfiguration = (url, options) => Promise<FooEntityConfiguration>)
|
103
|
-
*
|
104
|
-
* @param entityBaseUrl The base url of the entity.
|
105
|
-
* @param schema The expected schema of the entity configuration, according to the kind of entity we are fetching from.
|
106
|
-
* @param options An optional object with additional options.
|
107
|
-
* @param options.appFetch An optional instance of the http client to be used.
|
108
|
-
* @returns The parsed entity configuration object
|
109
|
-
* @throws {IoWalletError} If the http request fails
|
110
|
-
* @throws Parse error if the document is not in the expected shape.
|
111
|
-
*/
|
112
|
-
async function fetchAndParseEntityConfiguration(
|
113
|
-
entityBaseUrl: string,
|
114
|
-
schema: typeof WalletProviderEntityConfiguration,
|
115
|
-
options?: {
|
116
|
-
appFetch?: GlobalFetch["fetch"];
|
117
|
-
}
|
118
|
-
): Promise<WalletProviderEntityConfiguration>;
|
119
|
-
async function fetchAndParseEntityConfiguration(
|
120
|
-
entityBaseUrl: string,
|
121
|
-
schema: typeof RelyingPartyEntityConfiguration,
|
122
|
-
options?: {
|
123
|
-
appFetch?: GlobalFetch["fetch"];
|
124
|
-
}
|
125
|
-
): Promise<RelyingPartyEntityConfiguration>;
|
126
|
-
async function fetchAndParseEntityConfiguration(
|
127
|
-
entityBaseUrl: string,
|
128
|
-
schema: typeof TrustAnchorEntityConfiguration,
|
129
|
-
options?: {
|
130
|
-
appFetch?: GlobalFetch["fetch"];
|
131
|
-
}
|
132
|
-
): Promise<TrustAnchorEntityConfiguration>;
|
133
|
-
async function fetchAndParseEntityConfiguration(
|
134
|
-
entityBaseUrl: string,
|
135
|
-
schema: typeof CredentialIssuerEntityConfiguration,
|
136
|
-
options?: {
|
137
|
-
appFetch?: GlobalFetch["fetch"];
|
138
|
-
}
|
139
|
-
): Promise<CredentialIssuerEntityConfiguration>;
|
140
|
-
async function fetchAndParseEntityConfiguration(
|
141
|
-
entityBaseUrl: string,
|
142
|
-
schema: typeof EntityConfiguration,
|
143
|
-
options?: {
|
144
|
-
appFetch?: GlobalFetch["fetch"];
|
145
|
-
}
|
146
|
-
): Promise<EntityConfiguration>;
|
147
|
-
async function fetchAndParseEntityConfiguration(
|
148
|
-
entityBaseUrl: string,
|
149
|
-
schema: /* FIXME: why is it different from "typeof EntityConfiguration"? */
|
150
|
-
| typeof CredentialIssuerEntityConfiguration
|
151
|
-
| typeof WalletProviderEntityConfiguration
|
152
|
-
| typeof RelyingPartyEntityConfiguration
|
153
|
-
| typeof TrustAnchorEntityConfiguration
|
154
|
-
| typeof EntityConfiguration,
|
155
|
-
{
|
156
|
-
appFetch = fetch,
|
157
|
-
}: {
|
158
|
-
appFetch?: GlobalFetch["fetch"];
|
159
|
-
} = {}
|
160
|
-
) {
|
161
|
-
const responseText = await getSignedEntityConfiguration(entityBaseUrl, {
|
162
|
-
appFetch,
|
163
|
-
});
|
164
|
-
|
165
|
-
const responseJwt = decodeJwt(responseText);
|
166
|
-
return schema.parse({
|
167
|
-
header: responseJwt.protectedHeader,
|
168
|
-
payload: responseJwt.payload,
|
169
|
-
});
|
170
|
-
}
|
171
|
-
|
172
|
-
export const getWalletProviderEntityConfiguration = (
|
173
|
-
entityBaseUrl: Parameters<typeof fetchAndParseEntityConfiguration>[0],
|
174
|
-
options?: Parameters<typeof fetchAndParseEntityConfiguration>[2]
|
175
|
-
) =>
|
176
|
-
fetchAndParseEntityConfiguration(
|
177
|
-
entityBaseUrl,
|
178
|
-
WalletProviderEntityConfiguration,
|
179
|
-
options
|
180
|
-
);
|
181
|
-
|
182
|
-
export const getCredentialIssuerEntityConfiguration = (
|
183
|
-
entityBaseUrl: Parameters<typeof fetchAndParseEntityConfiguration>[0],
|
184
|
-
options?: Parameters<typeof fetchAndParseEntityConfiguration>[2]
|
185
|
-
) =>
|
186
|
-
fetchAndParseEntityConfiguration(
|
187
|
-
entityBaseUrl,
|
188
|
-
CredentialIssuerEntityConfiguration,
|
189
|
-
options
|
190
|
-
);
|
191
|
-
|
192
|
-
export const getTrustAnchorEntityConfiguration = (
|
193
|
-
entityBaseUrl: Parameters<typeof fetchAndParseEntityConfiguration>[0],
|
194
|
-
options?: Parameters<typeof fetchAndParseEntityConfiguration>[2]
|
195
|
-
) =>
|
196
|
-
fetchAndParseEntityConfiguration(
|
197
|
-
entityBaseUrl,
|
198
|
-
TrustAnchorEntityConfiguration,
|
199
|
-
options
|
200
|
-
);
|
201
|
-
|
202
|
-
export const getRelyingPartyEntityConfiguration = (
|
203
|
-
entityBaseUrl: Parameters<typeof fetchAndParseEntityConfiguration>[0],
|
204
|
-
options?: Parameters<typeof fetchAndParseEntityConfiguration>[2]
|
205
|
-
) =>
|
206
|
-
fetchAndParseEntityConfiguration(
|
207
|
-
entityBaseUrl,
|
208
|
-
RelyingPartyEntityConfiguration,
|
209
|
-
options
|
210
|
-
);
|
211
|
-
|
212
|
-
export const getEntityConfiguration = (
|
213
|
-
entityBaseUrl: Parameters<typeof fetchAndParseEntityConfiguration>[0],
|
214
|
-
options?: Parameters<typeof fetchAndParseEntityConfiguration>[2]
|
215
|
-
) =>
|
216
|
-
fetchAndParseEntityConfiguration(entityBaseUrl, EntityConfiguration, options);
|
217
|
-
|
218
|
-
/**
|
219
|
-
* Fetch and parse the entity statement document for a given federation entity.
|
220
|
-
*
|
221
|
-
* @param accreditationBodyBaseUrl The base url of the accreditation body which holds and signs the required entity statement
|
222
|
-
* @param subordinatedEntityBaseUrl The url that identifies the subordinate entity
|
223
|
-
* @param appFetch An optional instance of the http client to be used.
|
224
|
-
* @returns The parsed entity configuration object
|
225
|
-
* @throws {IoWalletError} If the http request fails
|
226
|
-
*/
|
227
|
-
export async function getEntityStatement(
|
228
|
-
accreditationBodyBaseUrl: string,
|
229
|
-
subordinatedEntityBaseUrl: string,
|
230
|
-
{
|
231
|
-
appFetch = fetch,
|
232
|
-
}: {
|
233
|
-
appFetch?: GlobalFetch["fetch"];
|
234
|
-
} = {}
|
235
|
-
) {
|
236
|
-
const responseText = await getSignedEntityStatement(
|
237
|
-
accreditationBodyBaseUrl,
|
238
|
-
subordinatedEntityBaseUrl,
|
239
|
-
{
|
240
|
-
appFetch,
|
241
|
-
}
|
242
|
-
);
|
243
|
-
|
244
|
-
const responseJwt = decodeJwt(responseText);
|
245
|
-
return EntityStatement.parse({
|
246
|
-
header: responseJwt.protectedHeader,
|
247
|
-
payload: responseJwt.payload,
|
248
|
-
});
|
249
|
-
}
|
250
|
-
|
251
|
-
/**
|
252
|
-
* Fetch the entity statement document for a given federation entity.
|
253
|
-
*
|
254
|
-
* @param federationFetchEndpoint The exact endpoint provided by the parent EC's metadata.
|
255
|
-
* @param subordinatedEntityBaseUrl The url that identifies the subordinate entity.
|
256
|
-
* @param appFetch An optional instance of the http client to be used.
|
257
|
-
* @returns The signed entity statement token.
|
258
|
-
* @throws {IoWalletError} If the http request fails.
|
259
|
-
*/
|
260
|
-
export async function getSignedEntityStatement(
|
261
|
-
federationFetchEndpoint: string,
|
262
|
-
subordinatedEntityBaseUrl: string,
|
263
|
-
{
|
264
|
-
appFetch = fetch,
|
265
|
-
}: {
|
266
|
-
appFetch?: GlobalFetch["fetch"];
|
267
|
-
} = {}
|
268
|
-
) {
|
269
|
-
const url = new URL(federationFetchEndpoint);
|
270
|
-
url.searchParams.set("sub", subordinatedEntityBaseUrl);
|
271
|
-
|
272
|
-
return await appFetch(url.toString(), {
|
273
|
-
method: "GET",
|
274
|
-
})
|
275
|
-
.then(hasStatusOrThrow(200))
|
276
|
-
.then((res) => res.text());
|
277
|
-
}
|
278
|
-
|
279
|
-
/**
|
280
|
-
* Fetch the federation list document from a given endpoint.
|
281
|
-
*
|
282
|
-
* @param federationListEndpoint The URL of the federation list endpoint.
|
283
|
-
* @param appFetch An optional instance of the http client to be used.
|
284
|
-
* @returns The federation list as an array of strings.
|
285
|
-
* @throws {IoWalletError} If the HTTP request fails.
|
286
|
-
* @throws {FederationError} If the result is not in the expected format.
|
287
|
-
*/
|
288
|
-
export async function getFederationList(
|
289
|
-
federationListEndpoint: string,
|
290
|
-
{
|
291
|
-
appFetch = fetch,
|
292
|
-
}: {
|
293
|
-
appFetch?: GlobalFetch["fetch"];
|
294
|
-
} = {}
|
295
|
-
): Promise<string[]> {
|
296
|
-
return await appFetch(federationListEndpoint, {
|
297
|
-
method: "GET",
|
298
|
-
})
|
299
|
-
.then(hasStatusOrThrow(200))
|
300
|
-
.then((res) => res.json())
|
301
|
-
.then((json) => {
|
302
|
-
const result = FederationListResponse.safeParse(json);
|
303
|
-
if (!result.success) {
|
304
|
-
throw new FederationListParseError(
|
305
|
-
`Invalid federation list format received from ${federationListEndpoint}. Error: ${result.error.message}`,
|
306
|
-
{ url: federationListEndpoint, parseError: result.error.toString() }
|
307
|
-
);
|
308
|
-
}
|
309
|
-
return result.data;
|
310
|
-
});
|
311
|
-
}
|
312
|
-
|
313
|
-
/**
|
314
|
-
* Build a not-verified trust chain for a given Relying Party (RP) entity.
|
315
|
-
*
|
316
|
-
* @param relyingPartyEntityBaseUrl The base URL of the RP entity
|
317
|
-
* @param trustAnchorKey The public key of the Trust Anchor (TA) entity
|
318
|
-
* @param appFetch An optional instance of the http client to be used.
|
319
|
-
* @returns A list of signed tokens that represent the trust chain, in the order of the chain (from the RP to the Trust Anchor)
|
320
|
-
* @throws {FederationError} When an element of the chain fails to parse or other build steps fail.
|
321
|
-
*/
|
322
|
-
export async function buildTrustChain(
|
323
|
-
relyingPartyEntityBaseUrl: string,
|
324
|
-
trustAnchorKey: JWK,
|
325
|
-
appFetch: GlobalFetch["fetch"] = fetch
|
326
|
-
): Promise<string[]> {
|
327
|
-
// 1: Recursively gather the trust chain from the RP up to the Trust Anchor
|
328
|
-
const trustChain = await gatherTrustChain(
|
329
|
-
relyingPartyEntityBaseUrl,
|
330
|
-
appFetch
|
331
|
-
);
|
332
|
-
|
333
|
-
// 2: Trust Anchor signature verification
|
334
|
-
const trustAnchorJwt = trustChain[trustChain.length - 1];
|
335
|
-
if (!trustAnchorJwt) {
|
336
|
-
throw new BuildTrustChainError(
|
337
|
-
"Cannot verify trust anchor: missing entity configuration in gathered chain.",
|
338
|
-
{ relyingPartyUrl: relyingPartyEntityBaseUrl }
|
339
|
-
);
|
340
|
-
}
|
341
|
-
|
342
|
-
if (!trustAnchorKey.kid) {
|
343
|
-
throw new TrustAnchorKidMissingError();
|
344
|
-
}
|
345
|
-
|
346
|
-
await verify(trustAnchorJwt, trustAnchorKey.kid, [trustAnchorKey]);
|
347
|
-
|
348
|
-
// 3: Check the federation list
|
349
|
-
const trustAnchorConfig = EntityConfiguration.parse(decode(trustAnchorJwt));
|
350
|
-
const federationListEndpoint =
|
351
|
-
trustAnchorConfig.payload.metadata.federation_entity
|
352
|
-
.federation_list_endpoint;
|
353
|
-
|
354
|
-
if (federationListEndpoint) {
|
355
|
-
const federationList = await getFederationList(federationListEndpoint, {
|
356
|
-
appFetch,
|
357
|
-
});
|
358
|
-
|
359
|
-
if (!federationList.includes(relyingPartyEntityBaseUrl)) {
|
360
|
-
throw new RelyingPartyNotAuthorizedError(
|
361
|
-
"Relying Party entity base URL is not authorized by the Trust Anchor's federation list.",
|
362
|
-
{ relyingPartyUrl: relyingPartyEntityBaseUrl, federationListEndpoint }
|
363
|
-
);
|
364
|
-
}
|
365
|
-
}
|
366
|
-
|
367
|
-
return trustChain;
|
368
|
-
}
|
369
|
-
|
370
|
-
/**
|
371
|
-
* Recursively gather the trust chain for an entity and all its superiors.
|
372
|
-
* @param entityBaseUrl The base URL of the entity for which to gather the chain.
|
373
|
-
* @param appFetch An optional instance of the http client to be used.
|
374
|
-
* @param isLeaf Whether the current entity is the leaf of the chain.
|
375
|
-
* @returns A full ordered list of JWTs (ECs and ESs) forming the trust chain.
|
376
|
-
* @throws {FederationError} If any of the fetched documents fail to parse or other errors occur during the gathering process.
|
377
|
-
*/
|
378
|
-
async function gatherTrustChain(
|
379
|
-
entityBaseUrl: string,
|
380
|
-
appFetch: GlobalFetch["fetch"],
|
381
|
-
isLeaf: boolean = true
|
382
|
-
): Promise<string[]> {
|
383
|
-
const chain: string[] = [];
|
384
|
-
|
385
|
-
// Fetch self-signed EC (only needed for the leaf)
|
386
|
-
const entityECJwt = await getSignedEntityConfiguration(entityBaseUrl, {
|
387
|
-
appFetch,
|
388
|
-
});
|
389
|
-
const entityEC = EntityConfiguration.parse(decode(entityECJwt));
|
390
|
-
|
391
|
-
if (isLeaf) {
|
392
|
-
// Only push EC for the leaf
|
393
|
-
chain.push(entityECJwt);
|
394
|
-
}
|
395
|
-
|
396
|
-
// Find authority_hints (parent, if any)
|
397
|
-
const authorityHints = entityEC.payload.authority_hints ?? [];
|
398
|
-
if (authorityHints.length === 0) {
|
399
|
-
// This is the Trust Anchor (no parent)
|
400
|
-
if (!isLeaf) {
|
401
|
-
chain.push(entityECJwt);
|
402
|
-
}
|
403
|
-
return chain;
|
404
|
-
}
|
405
|
-
|
406
|
-
const parentEntityBaseUrl = authorityHints[0]!;
|
407
|
-
|
408
|
-
// Fetch parent EC
|
409
|
-
const parentECJwt = await getSignedEntityConfiguration(parentEntityBaseUrl, {
|
410
|
-
appFetch,
|
411
|
-
});
|
412
|
-
const parentEC = EntityConfiguration.parse(decode(parentECJwt));
|
413
|
-
|
414
|
-
// Fetch ES
|
415
|
-
const federationFetchEndpoint =
|
416
|
-
parentEC.payload.metadata.federation_entity.federation_fetch_endpoint;
|
417
|
-
if (!federationFetchEndpoint) {
|
418
|
-
throw new MissingFederationFetchEndpointError(
|
419
|
-
`Missing federation_fetch_endpoint in parent's (${parentEntityBaseUrl}) configuration when gathering chain for ${entityBaseUrl}.`,
|
420
|
-
{ entityBaseUrl, missingInEntityUrl: parentEntityBaseUrl }
|
421
|
-
);
|
422
|
-
}
|
423
|
-
|
424
|
-
const entityStatementJwt = await getSignedEntityStatement(
|
425
|
-
federationFetchEndpoint,
|
426
|
-
entityBaseUrl,
|
427
|
-
{ appFetch }
|
428
|
-
);
|
429
|
-
// Validate the ES
|
430
|
-
EntityStatement.parse(decode(entityStatementJwt));
|
431
|
-
|
432
|
-
// Push this ES into the chain
|
433
|
-
chain.push(entityStatementJwt);
|
434
|
-
|
435
|
-
// Recurse into the parent
|
436
|
-
const parentChain = await gatherTrustChain(
|
437
|
-
parentEntityBaseUrl,
|
438
|
-
appFetch,
|
439
|
-
false
|
440
|
-
);
|
441
|
-
|
442
|
-
return chain.concat(parentChain);
|
443
|
-
}
|
6
|
+
export { Build, Verify, Errors, Types };
|
@@ -5,7 +5,6 @@ import {
|
|
5
5
|
} from "./types";
|
6
6
|
import { JWK } from "../utils/jwk";
|
7
7
|
import * as z from "zod";
|
8
|
-
import { getSignedEntityConfiguration, getSignedEntityStatement } from ".";
|
9
8
|
import {
|
10
9
|
decode,
|
11
10
|
getTrustAnchorX509Certificate,
|
@@ -26,6 +25,10 @@ import {
|
|
26
25
|
verifyCertificateChain,
|
27
26
|
type X509CertificateOptions,
|
28
27
|
} from "@pagopa/io-react-native-crypto";
|
28
|
+
import {
|
29
|
+
getSignedEntityConfiguration,
|
30
|
+
getSignedEntityStatement,
|
31
|
+
} from "./build-chain";
|
29
32
|
|
30
33
|
// The first element of the chain is supposed to be the Entity Configuration for the document issuer
|
31
34
|
const FirstElementShape = EntityConfiguration;
|
@@ -225,3 +228,40 @@ export async function renewTrustChain(
|
|
225
228
|
})
|
226
229
|
);
|
227
230
|
}
|
231
|
+
|
232
|
+
/**
|
233
|
+
* Verify a given trust chain is actually valid.
|
234
|
+
* It can handle fast chain renewal, which means we try to fetch a fresh version of each statement.
|
235
|
+
*
|
236
|
+
* @param trustAnchorEntity The entity configuration of the known trust anchor
|
237
|
+
* @param chain The chain of statements to be validated
|
238
|
+
* @param x509Options Options for the verification process
|
239
|
+
* @param appFetch (optional) fetch api implementation
|
240
|
+
* @param renewOnFail Whether to attempt to renew the trust chain if the initial validation fails
|
241
|
+
* @returns The result of the chain validation
|
242
|
+
* @throws {FederationError} If the chain is not valid
|
243
|
+
*/
|
244
|
+
export async function verifyTrustChain(
|
245
|
+
trustAnchorEntity: TrustAnchorEntityConfiguration,
|
246
|
+
chain: string[],
|
247
|
+
x509Options: X509CertificateOptions = {
|
248
|
+
connectTimeout: 10000,
|
249
|
+
readTimeout: 10000,
|
250
|
+
requireCrl: true,
|
251
|
+
},
|
252
|
+
{
|
253
|
+
appFetch = fetch,
|
254
|
+
renewOnFail = true,
|
255
|
+
}: { appFetch?: GlobalFetch["fetch"]; renewOnFail?: boolean } = {}
|
256
|
+
): Promise<ReturnType<typeof validateTrustChain>> {
|
257
|
+
try {
|
258
|
+
return validateTrustChain(trustAnchorEntity, chain, x509Options);
|
259
|
+
} catch (error) {
|
260
|
+
if (renewOnFail) {
|
261
|
+
const renewedChain = await renewTrustChain(chain, appFetch);
|
262
|
+
return validateTrustChain(trustAnchorEntity, renewedChain, x509Options);
|
263
|
+
} else {
|
264
|
+
throw error;
|
265
|
+
}
|
266
|
+
}
|
267
|
+
}
|
package/src/utils/errors.ts
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
import type { ProblemDetail } from "../client/generated/wallet-provider";
|
2
|
-
import type { CredentialIssuerEntityConfiguration } from "../trust";
|
3
2
|
import {
|
3
|
+
type IssuerResponseErrorCode,
|
4
4
|
IssuerResponseErrorCodes,
|
5
|
-
|
5
|
+
type RelyingPartyResponseErrorCode,
|
6
6
|
RelyingPartyResponseErrorCodes,
|
7
|
-
type IssuerResponseErrorCode,
|
8
7
|
type WalletProviderResponseErrorCode,
|
9
|
-
|
8
|
+
WalletProviderResponseErrorCodes,
|
10
9
|
} from "./error-codes";
|
10
|
+
import type { CredentialIssuerEntityConfiguration } from "../trust/types";
|
11
11
|
|
12
12
|
export {
|
13
13
|
IssuerResponseErrorCodes,
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["_types","require","z","_interopRequireWildcard","_","_utils","_errors","_ioReactNativeCrypto","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","FirstElementShape","EntityConfiguration","MiddleElementShape","EntityStatement","LastElementShape","union","TrustAnchorEntityConfiguration","validateTrustChain","trustAnchorEntity","chain","x509Options","length","TrustChainEmptyError","selectTokenShape","elementIndex","selectKid","currentIndex","token","TrustChainTokenMissingError","index","shape","parse","decode","header","kid","selectKeys","payload","jwks","keys","nextIndex","nextToken","x509TrustAnchorCertBase64","getTrustAnchorX509Certificate","validationPromises","map","tokenString","i","kidFromTokenHeader","signerJwks","parsedToken","verify","jwkUsedForVerification","find","k","FederationError","tokenIndex","x5c","MissingX509CertsError","certChainBase64","at","slice","x509ValidationResult","verifyCertificateChain","isValid","X509ValidationError","validationStatus","errorMessage","x509ValidationStatus","x509ErrorMessage","Promise","all","renewTrustChain","appFetch","arguments","undefined","fetch","decoded","entityStatementResult","safeParse","entityConfigurationResult","success","getSignedEntityConfiguration","data","iss","entityStatement","parentBaseUrl","parentECJwt","parentEC","federationFetchEndpoint","metadata","federation_entity","federation_fetch_endpoint","MissingFederationFetchEndpointError","sub","entityBaseUrl","missingInEntityUrl","getSignedEntityStatement","TrustChainRenewalError","originalChain"],"sourceRoot":"../../../src","sources":["trust/chain.ts"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAMA,IAAAC,CAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,CAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAMA,IAAAK,OAAA,GAAAL,OAAA;AASA,IAAAM,oBAAA,GAAAN,OAAA;AAIwC,SAAAO,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAN,wBAAAU,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UA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AAW,CAAC,CAAC;MAE/D,MAAME,uBAAuB,GAC3BD,QAAQ,CAACnD,OAAO,CAACqD,QAAQ,CAACC,iBAAiB,CAACC,yBAAyB;MACvE,IAAI,CAACH,uBAAuB,EAAE;QAC5B,MAAM,IAAII,2CAAmC,CAC1C,gBAAeP,aAAc,8DAA6DD,eAAe,CAAChD,OAAO,CAACyD,GAAI,GAAE,EACzH;UACEC,aAAa,EAAEV,eAAe,CAAChD,OAAO,CAACyD,GAAG;UAC1CE,kBAAkB,EAAEV;QACtB,CACF,CAAC;MACH;MACA,OAAO,IAAAW,0BAAwB,EAC7BR,uBAAuB,EACvBJ,eAAe,CAAChD,OAAO,CAACyD,GAAG,EAC3B;QAAErB;MAAS,CACb,CAAC;IACH;IACA,MAAM,IAAIyB,8BAAsB,CAC7B,iDAAgDpE,KAAM,mBAAkB,EACzE;MAAEqE,aAAa,EAAE/E;IAAM,CACzB,CAAC;EACH,CAAC,CACH,CAAC;AACH"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["EntityConfiguration","EntityStatement","TrustAnchorEntityConfiguration","z","getSignedEntityConfiguration","getSignedEntityStatement","decode","getTrustAnchorX509Certificate","verify","FederationError","MissingFederationFetchEndpointError","MissingX509CertsError","TrustChainEmptyError","TrustChainRenewalError","TrustChainTokenMissingError","X509ValidationError","verifyCertificateChain","FirstElementShape","MiddleElementShape","LastElementShape","union","validateTrustChain","trustAnchorEntity","chain","x509Options","length","selectTokenShape","elementIndex","selectKid","currentIndex","token","index","shape","parse","header","kid","selectKeys","payload","jwks","keys","nextIndex","nextToken","x509TrustAnchorCertBase64","validationPromises","map","tokenString","i","kidFromTokenHeader","signerJwks","parsedToken","jwkUsedForVerification","find","k","tokenIndex","x5c","certChainBase64","at","slice","x509ValidationResult","isValid","validationStatus","errorMessage","x509ValidationStatus","x509ErrorMessage","Promise","all","renewTrustChain","appFetch","arguments","undefined","fetch","decoded","entityStatementResult","safeParse","entityConfigurationResult","success","data","iss","entityStatement","parentBaseUrl","parentECJwt","parentEC","federationFetchEndpoint","metadata","federation_entity","federation_fetch_endpoint","sub","entityBaseUrl","missingInEntityUrl","originalChain"],"sourceRoot":"../../../src","sources":["trust/chain.ts"],"mappings":"AAAA,SACEA,mBAAmB,EACnBC,eAAe,EACfC,8BAA8B,QACzB,SAAS;AAEhB,OAAO,KAAKC,CAAC,MAAM,KAAK;AACxB,SAASC,4BAA4B,EAAEC,wBAAwB,QAAQ,GAAG;AAC1E,SACEC,MAAM,EACNC,6BAA6B,EAE7BC,MAAM,QACD,SAAS;AAChB,SACEC,eAAe,EACfC,mCAAmC,EACnCC,qBAAqB,EACrBC,oBAAoB,EACpBC,sBAAsB,EACtBC,2BAA2B,EAC3BC,mBAAmB,QACd,UAAU;AACjB,SAEEC,sBAAsB,QAEjB,gCAAgC;;AAEvC;AACA,MAAMC,iBAAiB,GAAGjB,mBAAmB;AAC7C;AACA,MAAMkB,kBAAkB,GAAGjB,eAAe;AAC1C;AACA;AACA,MAAMkB,gBAAgB,GAAGhB,CAAC,CAACiB,KAAK,CAAC,CAC/BnB,eAAe,EACfC,8BAA8B,CAC/B,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAemB,kBAAkBA,CACtCC,iBAAiD,EACjDC,KAAe,EACfC,WAAmC,EACX;EACxB;EACA,IAAID,KAAK,CAACE,MAAM,KAAK,CAAC,EAAE;IACtB,MAAM,IAAIb,oBAAoB,CAAC,kCAAkC,CAAC;EACpE;;EAEA;EACA,MAAMc,gBAAgB,GAAIC,YAAoB,IAC5CA,YAAY,KAAK,CAAC,GACdV,iBAAiB,GACjBU,YAAY,KAAKJ,KAAK,CAACE,MAAM,GAAG,CAAC,GAC/BN,gBAAgB,GAChBD,kBAAkB;;EAE1B;EACA,MAAMU,SAAS,GAAIC,YAAoB,IAAa;IAClD,MAAMC,KAAK,GAAGP,KAAK,CAACM,YAAY,CAAC;IACjC,IAAI,CAACC,KAAK,EAAE;MAC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