@openid4vc/oauth2 0.5.4-alpha-20260703092624 → 0.5.4
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/dist/index.d.mts +190 -146
- package/dist/index.mjs +96 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,148 +1,6 @@
|
|
|
1
1
|
import { BaseSchema, ContentType, Fetch, FetchHeaders, FetchRequestInit, FetchResponse, HttpMethod, HttpMethod as HttpMethod$1, InvalidFetchResponseError, Oid4vcTsConfig, OrPromise, StringWithAutoCompletion, getGlobalConfig, setGlobalConfig } from "@openid4vc/utils";
|
|
2
2
|
import z, { z as z$1 } from "zod";
|
|
3
3
|
|
|
4
|
-
//#region src/metadata/authorization-server/z-authorization-server-metadata.d.ts
|
|
5
|
-
declare const zAuthorizationServerMetadata: z.ZodObject<{
|
|
6
|
-
issuer: z.ZodURL;
|
|
7
|
-
token_endpoint: z.ZodURL;
|
|
8
|
-
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
|
|
9
|
-
client_secret_basic: "client_secret_basic";
|
|
10
|
-
client_secret_post: "client_secret_post";
|
|
11
|
-
attest_jwt_client_auth: "attest_jwt_client_auth";
|
|
12
|
-
attest_jwt_client_auth_dpop: "attest_jwt_client_auth_dpop";
|
|
13
|
-
client_secret_jwt: "client_secret_jwt";
|
|
14
|
-
private_key_jwt: "private_key_jwt";
|
|
15
|
-
}>, z.ZodString]>>>;
|
|
16
|
-
authorization_endpoint: z.ZodOptional<z.ZodURL>;
|
|
17
|
-
jwks_uri: z.ZodOptional<z.ZodURL>;
|
|
18
|
-
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
19
|
-
code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
20
|
-
dpop_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
21
|
-
require_pushed_authorization_requests: z.ZodOptional<z.ZodBoolean>;
|
|
22
|
-
pushed_authorization_request_endpoint: z.ZodOptional<z.ZodURL>;
|
|
23
|
-
introspection_endpoint: z.ZodOptional<z.ZodURL>;
|
|
24
|
-
introspection_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
|
|
25
|
-
client_secret_basic: "client_secret_basic";
|
|
26
|
-
client_secret_post: "client_secret_post";
|
|
27
|
-
attest_jwt_client_auth: "attest_jwt_client_auth";
|
|
28
|
-
attest_jwt_client_auth_dpop: "attest_jwt_client_auth_dpop";
|
|
29
|
-
client_secret_jwt: "client_secret_jwt";
|
|
30
|
-
private_key_jwt: "private_key_jwt";
|
|
31
|
-
}>, z.ZodString]>>>;
|
|
32
|
-
introspection_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
33
|
-
authorization_challenge_endpoint: z.ZodOptional<z.ZodURL>;
|
|
34
|
-
interactive_authorization_endpoint: z.ZodOptional<z.ZodURL>;
|
|
35
|
-
require_interactive_authorization_request: z.ZodOptional<z.ZodBoolean>;
|
|
36
|
-
'pre-authorized_grant_anonymous_access_supported': z.ZodOptional<z.ZodBoolean>;
|
|
37
|
-
client_attestation_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
38
|
-
client_attestation_pop_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
39
|
-
challenge_endpoint: z.ZodOptional<z.ZodURL>;
|
|
40
|
-
client_attestation_pop_nonce_required: z.ZodOptional<z.ZodBoolean>;
|
|
41
|
-
authorization_response_iss_parameter_supported: z.ZodOptional<z.ZodBoolean>;
|
|
42
|
-
}, z.core.$loose>;
|
|
43
|
-
type AuthorizationServerMetadata = z.infer<typeof zAuthorizationServerMetadata>;
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region src/client-authentication.d.ts
|
|
46
|
-
declare enum SupportedClientAuthenticationMethod {
|
|
47
|
-
ClientSecretBasic = "client_secret_basic",
|
|
48
|
-
ClientSecretPost = "client_secret_post",
|
|
49
|
-
ClientAttestationJwt = "attest_jwt_client_auth",
|
|
50
|
-
ClientAttestationJwtDpop = "attest_jwt_client_auth_dpop",
|
|
51
|
-
None = "none"
|
|
52
|
-
}
|
|
53
|
-
interface ClientAuthenticationDynamicOptions {
|
|
54
|
-
clientId: string;
|
|
55
|
-
clientSecret: string;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Dynamicaly get the client authentication method based on endpoint type and authorization server.
|
|
59
|
-
* Only `client_secret_post`, `client_secret_basic`, and `none` supported.
|
|
60
|
-
*
|
|
61
|
-
* It also supports anonymous access to the token endpoint for pre-authorized code flow
|
|
62
|
-
* if the authorization server has enabled `pre-authorized_grant_anonymous_access_supported`
|
|
63
|
-
*/
|
|
64
|
-
declare function clientAuthenticationDynamic(options: ClientAuthenticationDynamicOptions): ClientAuthenticationCallback;
|
|
65
|
-
/**
|
|
66
|
-
* Options for client authentication
|
|
67
|
-
*/
|
|
68
|
-
interface ClientAuthenticationCallbackOptions {
|
|
69
|
-
/**
|
|
70
|
-
* Metadata of the authorization server
|
|
71
|
-
*/
|
|
72
|
-
authorizationServerMetadata: AuthorizationServerMetadata;
|
|
73
|
-
/**
|
|
74
|
-
* URL to which the request will be made
|
|
75
|
-
*/
|
|
76
|
-
url: string;
|
|
77
|
-
/**
|
|
78
|
-
* http method that will be used
|
|
79
|
-
*/
|
|
80
|
-
method: HttpMethod$1;
|
|
81
|
-
/**
|
|
82
|
-
* Headers for the request. You can modify this object
|
|
83
|
-
*/
|
|
84
|
-
headers: FetchHeaders;
|
|
85
|
-
contentType: ContentType;
|
|
86
|
-
/**
|
|
87
|
-
* The body as a JSON object. If content type `x-www-form-urlencoded`
|
|
88
|
-
* is used, it will be encoded after this call.
|
|
89
|
-
*
|
|
90
|
-
* You can modify this object
|
|
91
|
-
*/
|
|
92
|
-
body: Record<string, unknown>;
|
|
93
|
-
/**
|
|
94
|
-
* A fresh Client Attestation challenge provided by the authorization server (draft 09), e.g.
|
|
95
|
-
* obtained from the `OAuth-Client-Attestation-Challenge` response header when retrying after a
|
|
96
|
-
* `use_attestation_challenge` error. When set it takes precedence over any statically configured
|
|
97
|
-
* challenge for methods that include a Client Attestation PoP.
|
|
98
|
-
*/
|
|
99
|
-
attestationChallenge?: string;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Callback method to determine the client authentication for a request.
|
|
103
|
-
*/
|
|
104
|
-
type ClientAuthenticationCallback = (options: ClientAuthenticationCallbackOptions) => Promise<void> | void;
|
|
105
|
-
interface ClientAuthenticationClientSecretPostOptions {
|
|
106
|
-
clientId: string;
|
|
107
|
-
clientSecret: string;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Client authentication using `client_secret_post` option
|
|
111
|
-
*/
|
|
112
|
-
declare function clientAuthenticationClientSecretPost(options: ClientAuthenticationClientSecretPostOptions): ClientAuthenticationCallback;
|
|
113
|
-
interface ClientAuthenticationClientSecretBasicOptions {
|
|
114
|
-
clientId: string;
|
|
115
|
-
clientSecret: string;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Client authentication using `client_secret_basic` option
|
|
119
|
-
*/
|
|
120
|
-
declare function clientAuthenticationClientSecretBasic(options: ClientAuthenticationClientSecretBasicOptions): ClientAuthenticationCallback;
|
|
121
|
-
interface ClientAuthenticationNoneOptions {
|
|
122
|
-
clientId: string;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Client authentication using `none` option
|
|
126
|
-
*/
|
|
127
|
-
declare function clientAuthenticationNone(options: ClientAuthenticationNoneOptions): ClientAuthenticationCallback;
|
|
128
|
-
/**
|
|
129
|
-
* Anonymous client authentication
|
|
130
|
-
*/
|
|
131
|
-
declare function clientAuthenticationAnonymous(): ClientAuthenticationCallback;
|
|
132
|
-
interface ClientAuthenticationClientAttestationJwtOptions {
|
|
133
|
-
clientAttestationJwt: string;
|
|
134
|
-
callbacks: Pick<CallbackContext, 'signJwt' | 'generateRandom'>;
|
|
135
|
-
/**
|
|
136
|
-
* Challenge provided by the authorization server (e.g. obtained from its `challenge_endpoint`)
|
|
137
|
-
* to include in the Client Attestation PoP JWT.
|
|
138
|
-
*/
|
|
139
|
-
challenge?: string;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Client authentication using `attest_jwt_client_auth` option.
|
|
143
|
-
*/
|
|
144
|
-
declare function clientAuthenticationClientAttestationJwt(options: ClientAuthenticationClientAttestationJwtOptions): ClientAuthenticationCallback;
|
|
145
|
-
//#endregion
|
|
146
4
|
//#region src/common/jwk/z-jwk.d.ts
|
|
147
5
|
declare const zJwk: z.ZodObject<{
|
|
148
6
|
kty: z.ZodString;
|
|
@@ -358,6 +216,172 @@ declare const zJwtHeader: z.ZodObject<{
|
|
|
358
216
|
}, z.core.$loose>;
|
|
359
217
|
type JwtHeader = z.infer<typeof zJwtHeader>;
|
|
360
218
|
//#endregion
|
|
219
|
+
//#region src/metadata/authorization-server/z-authorization-server-metadata.d.ts
|
|
220
|
+
declare const zAuthorizationServerMetadata: z.ZodObject<{
|
|
221
|
+
issuer: z.ZodURL;
|
|
222
|
+
token_endpoint: z.ZodURL;
|
|
223
|
+
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
|
|
224
|
+
client_secret_basic: "client_secret_basic";
|
|
225
|
+
client_secret_post: "client_secret_post";
|
|
226
|
+
attest_jwt_client_auth: "attest_jwt_client_auth";
|
|
227
|
+
attest_jwt_client_auth_dpop: "attest_jwt_client_auth_dpop";
|
|
228
|
+
client_secret_jwt: "client_secret_jwt";
|
|
229
|
+
private_key_jwt: "private_key_jwt";
|
|
230
|
+
}>, z.ZodString]>>>;
|
|
231
|
+
authorization_endpoint: z.ZodOptional<z.ZodURL>;
|
|
232
|
+
jwks_uri: z.ZodOptional<z.ZodURL>;
|
|
233
|
+
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
234
|
+
code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
235
|
+
dpop_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
236
|
+
require_pushed_authorization_requests: z.ZodOptional<z.ZodBoolean>;
|
|
237
|
+
pushed_authorization_request_endpoint: z.ZodOptional<z.ZodURL>;
|
|
238
|
+
introspection_endpoint: z.ZodOptional<z.ZodURL>;
|
|
239
|
+
introspection_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
|
|
240
|
+
client_secret_basic: "client_secret_basic";
|
|
241
|
+
client_secret_post: "client_secret_post";
|
|
242
|
+
attest_jwt_client_auth: "attest_jwt_client_auth";
|
|
243
|
+
attest_jwt_client_auth_dpop: "attest_jwt_client_auth_dpop";
|
|
244
|
+
client_secret_jwt: "client_secret_jwt";
|
|
245
|
+
private_key_jwt: "private_key_jwt";
|
|
246
|
+
}>, z.ZodString]>>>;
|
|
247
|
+
introspection_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
248
|
+
authorization_challenge_endpoint: z.ZodOptional<z.ZodURL>;
|
|
249
|
+
interactive_authorization_endpoint: z.ZodOptional<z.ZodURL>;
|
|
250
|
+
require_interactive_authorization_request: z.ZodOptional<z.ZodBoolean>;
|
|
251
|
+
'pre-authorized_grant_anonymous_access_supported': z.ZodOptional<z.ZodBoolean>;
|
|
252
|
+
client_attestation_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
253
|
+
client_attestation_pop_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
254
|
+
challenge_endpoint: z.ZodOptional<z.ZodURL>;
|
|
255
|
+
client_attestation_pop_nonce_required: z.ZodOptional<z.ZodBoolean>;
|
|
256
|
+
authorization_response_iss_parameter_supported: z.ZodOptional<z.ZodBoolean>;
|
|
257
|
+
}, z.core.$loose>;
|
|
258
|
+
type AuthorizationServerMetadata = z.infer<typeof zAuthorizationServerMetadata>;
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region src/client-authentication.d.ts
|
|
261
|
+
declare enum SupportedClientAuthenticationMethod {
|
|
262
|
+
ClientSecretBasic = "client_secret_basic",
|
|
263
|
+
ClientSecretPost = "client_secret_post",
|
|
264
|
+
ClientAttestationJwt = "attest_jwt_client_auth",
|
|
265
|
+
ClientAttestationJwtDpop = "attest_jwt_client_auth_dpop",
|
|
266
|
+
None = "none"
|
|
267
|
+
}
|
|
268
|
+
interface ClientAuthenticationDynamicOptions {
|
|
269
|
+
clientId: string;
|
|
270
|
+
clientSecret: string;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Dynamicaly get the client authentication method based on endpoint type and authorization server.
|
|
274
|
+
* Only `client_secret_post`, `client_secret_basic`, and `none` supported.
|
|
275
|
+
*
|
|
276
|
+
* It also supports anonymous access to the token endpoint for pre-authorized code flow
|
|
277
|
+
* if the authorization server has enabled `pre-authorized_grant_anonymous_access_supported`
|
|
278
|
+
*/
|
|
279
|
+
declare function clientAuthenticationDynamic(options: ClientAuthenticationDynamicOptions): ClientAuthenticationCallback;
|
|
280
|
+
/**
|
|
281
|
+
* Options for client authentication
|
|
282
|
+
*/
|
|
283
|
+
interface ClientAuthenticationCallbackOptions {
|
|
284
|
+
/**
|
|
285
|
+
* Metadata of the authorization server
|
|
286
|
+
*/
|
|
287
|
+
authorizationServerMetadata: AuthorizationServerMetadata;
|
|
288
|
+
/**
|
|
289
|
+
* URL to which the request will be made
|
|
290
|
+
*/
|
|
291
|
+
url: string;
|
|
292
|
+
/**
|
|
293
|
+
* http method that will be used
|
|
294
|
+
*/
|
|
295
|
+
method: HttpMethod$1;
|
|
296
|
+
/**
|
|
297
|
+
* Headers for the request. You can modify this object
|
|
298
|
+
*/
|
|
299
|
+
headers: FetchHeaders;
|
|
300
|
+
contentType: ContentType;
|
|
301
|
+
/**
|
|
302
|
+
* The body as a JSON object. If content type `x-www-form-urlencoded`
|
|
303
|
+
* is used, it will be encoded after this call.
|
|
304
|
+
*
|
|
305
|
+
* You can modify this object
|
|
306
|
+
*/
|
|
307
|
+
body: Record<string, unknown>;
|
|
308
|
+
/**
|
|
309
|
+
* A fresh Client Attestation challenge provided by the authorization server (draft 09), e.g.
|
|
310
|
+
* obtained from the `OAuth-Client-Attestation-Challenge` response header when retrying after a
|
|
311
|
+
* `use_attestation_challenge` error. When set it takes precedence over any statically configured
|
|
312
|
+
* challenge for methods that include a Client Attestation PoP.
|
|
313
|
+
*/
|
|
314
|
+
attestationChallenge?: string;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Callback method to determine the client authentication for a request.
|
|
318
|
+
*/
|
|
319
|
+
type ClientAuthenticationCallback = (options: ClientAuthenticationCallbackOptions) => Promise<void> | void;
|
|
320
|
+
interface ClientAuthenticationClientSecretPostOptions {
|
|
321
|
+
clientId: string;
|
|
322
|
+
clientSecret: string;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Client authentication using `client_secret_post` option
|
|
326
|
+
*/
|
|
327
|
+
declare function clientAuthenticationClientSecretPost(options: ClientAuthenticationClientSecretPostOptions): ClientAuthenticationCallback;
|
|
328
|
+
interface ClientAuthenticationClientSecretBasicOptions {
|
|
329
|
+
clientId: string;
|
|
330
|
+
clientSecret: string;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Client authentication using `client_secret_basic` option
|
|
334
|
+
*/
|
|
335
|
+
declare function clientAuthenticationClientSecretBasic(options: ClientAuthenticationClientSecretBasicOptions): ClientAuthenticationCallback;
|
|
336
|
+
interface ClientAuthenticationNoneOptions {
|
|
337
|
+
clientId: string;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Client authentication using `none` option
|
|
341
|
+
*/
|
|
342
|
+
declare function clientAuthenticationNone(options: ClientAuthenticationNoneOptions): ClientAuthenticationCallback;
|
|
343
|
+
/**
|
|
344
|
+
* Anonymous client authentication
|
|
345
|
+
*/
|
|
346
|
+
declare function clientAuthenticationAnonymous(): ClientAuthenticationCallback;
|
|
347
|
+
interface ClientAuthenticationClientAttestationJwtOptions {
|
|
348
|
+
clientAttestationJwt: string;
|
|
349
|
+
callbacks: Pick<CallbackContext, 'signJwt' | 'generateRandom'>;
|
|
350
|
+
/**
|
|
351
|
+
* Challenge provided by the authorization server (e.g. obtained from its `challenge_endpoint`)
|
|
352
|
+
* to include in the Client Attestation PoP JWT.
|
|
353
|
+
*/
|
|
354
|
+
challenge?: string;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Client authentication using `attest_jwt_client_auth` option.
|
|
358
|
+
*/
|
|
359
|
+
declare function clientAuthenticationClientAttestationJwt(options: ClientAuthenticationClientAttestationJwtOptions): ClientAuthenticationCallback;
|
|
360
|
+
interface ClientAuthenticationClientAttestationJwtDpopOptions {
|
|
361
|
+
clientAttestationJwt: string;
|
|
362
|
+
callbacks: Pick<CallbackContext, 'signJwt' | 'generateRandom' | 'hash'>;
|
|
363
|
+
/**
|
|
364
|
+
* The DPoP (client instance) key signer. In the DPoP-bound method the client instance key and the
|
|
365
|
+
* DPoP key are the same key. If not provided, the signer is derived from the `cnf.jwk` of the client
|
|
366
|
+
* attestation.
|
|
367
|
+
*/
|
|
368
|
+
signer?: JwtSignerJwk;
|
|
369
|
+
/**
|
|
370
|
+
* Challenge provided by the authorization server (e.g. obtained from its `challenge_endpoint`) to
|
|
371
|
+
* include in the DPoP proof. A server-provided challenge threaded through the client authentication
|
|
372
|
+
* callback takes precedence. The challenge is placed in the DPoP `nonce` claim.
|
|
373
|
+
*/
|
|
374
|
+
challenge?: string;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Client authentication using the `attest_jwt_client_auth_dpop` option (draft 09 §5.2).
|
|
378
|
+
*
|
|
379
|
+
* In this DPoP-bound variant the client instance key and the DPoP key are the same key, and a single
|
|
380
|
+
* DPoP proof serves as both the DPoP proof and the Client Attestation PoP. The request carries the
|
|
381
|
+
* `OAuth-Client-Attestation` and `DPoP` headers, but no separate `OAuth-Client-Attestation-PoP` header.
|
|
382
|
+
*/
|
|
383
|
+
declare function clientAuthenticationClientAttestationJwtDpop(options: ClientAuthenticationClientAttestationJwtDpopOptions): ClientAuthenticationCallback;
|
|
384
|
+
//#endregion
|
|
361
385
|
//#region src/callbacks.d.ts
|
|
362
386
|
/**
|
|
363
387
|
* Supported hashing algorithms
|
|
@@ -1287,7 +1311,11 @@ interface ParseAccessTokenRequestResult {
|
|
|
1287
1311
|
*/
|
|
1288
1312
|
clientAttestation?: {
|
|
1289
1313
|
clientAttestationJwt: string;
|
|
1290
|
-
|
|
1314
|
+
/**
|
|
1315
|
+
* Absent for the DPoP-bound `attest_jwt_client_auth_dpop` method (draft 09), where the DPoP proof
|
|
1316
|
+
* serves as the Client Attestation PoP.
|
|
1317
|
+
*/
|
|
1318
|
+
clientAttestationPopJwt?: string;
|
|
1291
1319
|
};
|
|
1292
1320
|
/**
|
|
1293
1321
|
* The pkce code verifier from the access token request
|
|
@@ -1330,6 +1358,14 @@ interface VerifyAccessTokenRequestDpop {
|
|
|
1330
1358
|
* to handle the alg.
|
|
1331
1359
|
*/
|
|
1332
1360
|
allowedSigningAlgs?: string[];
|
|
1361
|
+
/**
|
|
1362
|
+
* Expected nonce in the dpop proof. If not provided the nonce won't be validated.
|
|
1363
|
+
*
|
|
1364
|
+
* For the DPoP-bound `attest_jwt_client_auth_dpop` method (draft 09) the server-provided client
|
|
1365
|
+
* attestation challenge is carried in the dpop `nonce` claim, so this can be set to the issued
|
|
1366
|
+
* challenge to enforce it.
|
|
1367
|
+
*/
|
|
1368
|
+
expectedNonce?: string;
|
|
1333
1369
|
}
|
|
1334
1370
|
interface VerifyAccessTokenRequestClientAttestation {
|
|
1335
1371
|
/**
|
|
@@ -1368,7 +1404,11 @@ interface VerifyAccessTokenRequestReturn {
|
|
|
1368
1404
|
};
|
|
1369
1405
|
clientAttestation?: {
|
|
1370
1406
|
clientAttestation: VerifiedClientAttestationJwt;
|
|
1371
|
-
|
|
1407
|
+
/**
|
|
1408
|
+
* Absent for the DPoP-bound `attest_jwt_client_auth_dpop` method (draft 09), where the verified
|
|
1409
|
+
* DPoP proof serves as the Client Attestation PoP.
|
|
1410
|
+
*/
|
|
1411
|
+
clientAttestationPop?: VerifiedClientAttestationPopJwt;
|
|
1372
1412
|
};
|
|
1373
1413
|
}
|
|
1374
1414
|
interface VerifyPreAuthorizedCodeAccessTokenRequestOptions {
|
|
@@ -1539,7 +1579,11 @@ interface ParseAuthorizationRequestResult {
|
|
|
1539
1579
|
*/
|
|
1540
1580
|
clientAttestation?: {
|
|
1541
1581
|
clientAttestationJwt: string;
|
|
1542
|
-
|
|
1582
|
+
/**
|
|
1583
|
+
* Absent for the DPoP-bound `attest_jwt_client_auth_dpop` method (draft 09), where the DPoP proof
|
|
1584
|
+
* serves as the Client Attestation PoP.
|
|
1585
|
+
*/
|
|
1586
|
+
clientAttestationPopJwt?: string;
|
|
1543
1587
|
};
|
|
1544
1588
|
}
|
|
1545
1589
|
/**
|
|
@@ -4049,5 +4093,5 @@ declare function verifyResourceRequest(options: VerifyResourceRequestOptions): P
|
|
|
4049
4093
|
authorizationServer: string;
|
|
4050
4094
|
}>;
|
|
4051
4095
|
//#endregion
|
|
4052
|
-
export { type AccessTokenErrorResponse, type AccessTokenProfileJwtPayload, type AccessTokenResponse, type AuthorizationChallengeErrorResponse, type AuthorizationChallengeRequest, type AuthorizationChallengeResponse, type AuthorizationCodeGrantIdentifier, AuthorizationErrorResponse, type AuthorizationRequest, AuthorizationResponse, type AuthorizationServerMetadata, type CalculateJwkThumbprintOptions, type CallbackContext, type ClientAttestationChallengeResponse, type ClientAttestationJwtHeader, type ClientAttestationJwtPayload, type ClientAttestationPopJwtHeader, type ClientAttestationPopJwtPayload, type ClientAuthenticationCallback, type ClientAuthenticationCallbackOptions, type ClientAuthenticationClientAttestationJwtOptions, type ClientAuthenticationClientSecretBasicOptions, type ClientAuthenticationClientSecretPostOptions, type ClientAuthenticationDynamicOptions, type ClientAuthenticationNoneOptions, type ClientCredentialsGrantIdentifier, type CreateAuthorizationRequestUrlOptions, type CreateClientAttestationJwtOptions, type CreateJarAuthorizationRequestOptions, type CreatePkceReturn, type CreatePushedAuthorizationErrorResponseOptions, type CreatePushedAuthorizationResponseOptions, type DecodeJwtHeaderResult, type DecodeJwtOptions, type DecodeJwtResult, type DecryptJweCallback, type DecryptJweCallbackOptions, type EncryptJweCallback, type GenerateRandomCallback, HashAlgorithm, type HashCallback, type HttpMethod, IdTokenJwtHeader, IdTokenJwtPayload, InvalidFetchResponseError, type JarAuthorizationRequest, type JarRequestObjectPayload, type JweEncryptor, type Jwk, type JwkSet, type JwtHeader, type JwtPayload, type JwtSigner, type JwtSignerCustom, type JwtSignerDid, type JwtSignerJwk, type JwtSignerWithJwk, type JwtSignerX5c, Oauth2AuthorizationServer, type Oauth2AuthorizationServerOptions, Oauth2Client, Oauth2ClientAuthorizationChallengeError, Oauth2ClientErrorResponseError, type Oauth2ClientOptions, Oauth2Error, Oauth2ErrorCodes, type Oauth2ErrorOptions, type Oauth2ErrorResponse, Oauth2JwtParseError, Oauth2JwtVerificationError, Oauth2ResourceServer, type Oauth2ResourceServerOptions, Oauth2ResourceUnauthorizedError, Oauth2ServerErrorResponseError, type Oid4vcTsConfig, type ParseAuthorizationChallengeRequestOptions, type ParseAuthorizationChallengeRequestResult, type ParseAuthorizationRequestOptions, type ParseAuthorizationRequestResult, ParseAuthorizationResponseOptions, type ParsePushedAuthorizationRequestOptions, type ParsePushedAuthorizationRequestResult, type ParsedJarRequest, type ParsedJarRequestOptions, PkceCodeChallengeMethod, type PreAuthorizedCodeGrantIdentifier, type PushedAuthorizationRequestUriPrefix, type RefreshTokenGrantIdentifier, type RequestClientAttestationChallengeOptions, type RequestClientAttestationOptions, type RequestDpopOptions, type RequestLike, type ResourceRequestOptions, type ResourceRequestResponseNotOk, type ResourceRequestResponseOk, type RetrieveAuthorizationCodeAccessTokenOptions, type RetrieveClientCredentialsAccessTokenOptions, type RetrievePreAuthorizedCodeAccessTokenOptions, type ShouldRetryAuthorizationServerRequestWithClientAttestationChallengeOptions, type SignJwtCallback, SupportedAuthenticationScheme, SupportedClientAuthenticationMethod, type TokenIntrospectionResponse, type VerifiedClientAttestationJwt, type VerifiedJarRequest, type VerifyAccessTokenRequestReturn, type VerifyAuthorizationChallengeRequestOptions, type VerifyAuthorizationChallengeRequestReturn, type VerifyAuthorizationRequestOptions, type VerifyAuthorizationRequestReturn, VerifyAuthorizationResponseOptions, type VerifyDataIntegrityProofCallback, VerifyIdTokenJwtOptions, type VerifyJarRequestOptions, type VerifyJwtCallback, type VerifyPushedAuthorizationRequestOptions, type VerifyPushedAuthorizationRequestReturn, type VerifyResourceRequestOptions, type WwwAuthenticateHeaderChallenge, authorizationCodeGrantIdentifier, authorizationServerRequestWithClientAttestationChallengeRetry, authorizationServerRequestWithDpopRetry, calculateJwkThumbprint, clientAuthenticationAnonymous, clientAuthenticationClientAttestationJwt, clientAuthenticationClientSecretBasic, clientAuthenticationClientSecretPost, clientAuthenticationDynamic, clientAuthenticationNone, clientCredentialsGrantIdentifier, createClientAttestationJwt, createDpopHeadersForRequest, createJarAuthorizationRequest, createPkce, decodeJwt, decodeJwtHeader, defaultGrantTypesSupported, extractClientAttestationChallengeFromHeaders, extractDpopNonceFromHeaders, fetchAuthorizationServerMetadata, fetchJwks, fetchWellKnownMetadata, fullySpecifiedCoseAlgorithmArrayToJwaSignatureAlgorithmArray, fullySpecifiedCoseAlgorithmToJwaSignatureAlgorithm, getAuthorizationServerMetadataFromList, getGlobalConfig, getGrantTypesSupported, isJarAuthorizationRequest, isJwkInSet, jwaSignatureAlgorithmArrayToFullySpecifiedCoseAlgorithmArray, jwaSignatureAlgorithmToFullySpecifiedCoseAlgorithm, jwtAuthorizationRequestJwtHeaderTyp, jwtHeaderFromJwtSigner, jwtSignerFromJwt, parseAuthorizationRequest, parseAuthorizationResponseRedirectUrl, parseJarRequest, parsePushedAuthorizationRequestUriReferenceValue, preAuthorizedCodeGrantIdentifier, pushedAuthorizationRequestUriPrefix, refreshTokenGrantIdentifier, requestClientAttestationChallenge, resourceRequest, setGlobalConfig, shouldRetryAuthorizationServerRequestWithClientAttestationChallenge, signedAuthorizationRequestJwtHeaderTyp, validateJarRequestParams, verifyAuthorizationRequest, verifyAuthorizationResponse, verifyClientAttestationJwt, verifyIdTokenJwt, verifyJarRequest, verifyJwt, verifyResourceRequest, zAlgValueNotNone, zAuthorizationCodeGrantIdentifier, zAuthorizationErrorResponse, zAuthorizationRequest, zAuthorizationResponse, zAuthorizationResponseFromUriParams, zAuthorizationServerMetadata, zClientAttestationChallengeResponse, zClientCredentialsGrantIdentifier, zCompactJwe, zCompactJwt, zIdTokenJwtHeader, zIdTokenJwtPayload, zJarAuthorizationRequest, zJarRequestObjectPayload, zJwk, zJwkSet, zJwtHeader, zJwtPayload, zOauth2ErrorResponse, zPreAuthorizedCodeGrantIdentifier, zPushedAuthorizationRequestUriPrefix, zRefreshTokenGrantIdentifier };
|
|
4096
|
+
export { type AccessTokenErrorResponse, type AccessTokenProfileJwtPayload, type AccessTokenResponse, type AuthorizationChallengeErrorResponse, type AuthorizationChallengeRequest, type AuthorizationChallengeResponse, type AuthorizationCodeGrantIdentifier, AuthorizationErrorResponse, type AuthorizationRequest, AuthorizationResponse, type AuthorizationServerMetadata, type CalculateJwkThumbprintOptions, type CallbackContext, type ClientAttestationChallengeResponse, type ClientAttestationJwtHeader, type ClientAttestationJwtPayload, type ClientAttestationPopJwtHeader, type ClientAttestationPopJwtPayload, type ClientAuthenticationCallback, type ClientAuthenticationCallbackOptions, type ClientAuthenticationClientAttestationJwtDpopOptions, type ClientAuthenticationClientAttestationJwtOptions, type ClientAuthenticationClientSecretBasicOptions, type ClientAuthenticationClientSecretPostOptions, type ClientAuthenticationDynamicOptions, type ClientAuthenticationNoneOptions, type ClientCredentialsGrantIdentifier, type CreateAuthorizationRequestUrlOptions, type CreateClientAttestationJwtOptions, type CreateJarAuthorizationRequestOptions, type CreatePkceReturn, type CreatePushedAuthorizationErrorResponseOptions, type CreatePushedAuthorizationResponseOptions, type DecodeJwtHeaderResult, type DecodeJwtOptions, type DecodeJwtResult, type DecryptJweCallback, type DecryptJweCallbackOptions, type EncryptJweCallback, type GenerateRandomCallback, HashAlgorithm, type HashCallback, type HttpMethod, IdTokenJwtHeader, IdTokenJwtPayload, InvalidFetchResponseError, type JarAuthorizationRequest, type JarRequestObjectPayload, type JweEncryptor, type Jwk, type JwkSet, type JwtHeader, type JwtPayload, type JwtSigner, type JwtSignerCustom, type JwtSignerDid, type JwtSignerJwk, type JwtSignerWithJwk, type JwtSignerX5c, Oauth2AuthorizationServer, type Oauth2AuthorizationServerOptions, Oauth2Client, Oauth2ClientAuthorizationChallengeError, Oauth2ClientErrorResponseError, type Oauth2ClientOptions, Oauth2Error, Oauth2ErrorCodes, type Oauth2ErrorOptions, type Oauth2ErrorResponse, Oauth2JwtParseError, Oauth2JwtVerificationError, Oauth2ResourceServer, type Oauth2ResourceServerOptions, Oauth2ResourceUnauthorizedError, Oauth2ServerErrorResponseError, type Oid4vcTsConfig, type ParseAuthorizationChallengeRequestOptions, type ParseAuthorizationChallengeRequestResult, type ParseAuthorizationRequestOptions, type ParseAuthorizationRequestResult, ParseAuthorizationResponseOptions, type ParsePushedAuthorizationRequestOptions, type ParsePushedAuthorizationRequestResult, type ParsedJarRequest, type ParsedJarRequestOptions, PkceCodeChallengeMethod, type PreAuthorizedCodeGrantIdentifier, type PushedAuthorizationRequestUriPrefix, type RefreshTokenGrantIdentifier, type RequestClientAttestationChallengeOptions, type RequestClientAttestationOptions, type RequestDpopOptions, type RequestLike, type ResourceRequestOptions, type ResourceRequestResponseNotOk, type ResourceRequestResponseOk, type RetrieveAuthorizationCodeAccessTokenOptions, type RetrieveClientCredentialsAccessTokenOptions, type RetrievePreAuthorizedCodeAccessTokenOptions, type ShouldRetryAuthorizationServerRequestWithClientAttestationChallengeOptions, type SignJwtCallback, SupportedAuthenticationScheme, SupportedClientAuthenticationMethod, type TokenIntrospectionResponse, type VerifiedClientAttestationJwt, type VerifiedJarRequest, type VerifyAccessTokenRequestReturn, type VerifyAuthorizationChallengeRequestOptions, type VerifyAuthorizationChallengeRequestReturn, type VerifyAuthorizationRequestOptions, type VerifyAuthorizationRequestReturn, VerifyAuthorizationResponseOptions, type VerifyDataIntegrityProofCallback, VerifyIdTokenJwtOptions, type VerifyJarRequestOptions, type VerifyJwtCallback, type VerifyPushedAuthorizationRequestOptions, type VerifyPushedAuthorizationRequestReturn, type VerifyResourceRequestOptions, type WwwAuthenticateHeaderChallenge, authorizationCodeGrantIdentifier, authorizationServerRequestWithClientAttestationChallengeRetry, authorizationServerRequestWithDpopRetry, calculateJwkThumbprint, clientAuthenticationAnonymous, clientAuthenticationClientAttestationJwt, clientAuthenticationClientAttestationJwtDpop, clientAuthenticationClientSecretBasic, clientAuthenticationClientSecretPost, clientAuthenticationDynamic, clientAuthenticationNone, clientCredentialsGrantIdentifier, createClientAttestationJwt, createDpopHeadersForRequest, createJarAuthorizationRequest, createPkce, decodeJwt, decodeJwtHeader, defaultGrantTypesSupported, extractClientAttestationChallengeFromHeaders, extractDpopNonceFromHeaders, fetchAuthorizationServerMetadata, fetchJwks, fetchWellKnownMetadata, fullySpecifiedCoseAlgorithmArrayToJwaSignatureAlgorithmArray, fullySpecifiedCoseAlgorithmToJwaSignatureAlgorithm, getAuthorizationServerMetadataFromList, getGlobalConfig, getGrantTypesSupported, isJarAuthorizationRequest, isJwkInSet, jwaSignatureAlgorithmArrayToFullySpecifiedCoseAlgorithmArray, jwaSignatureAlgorithmToFullySpecifiedCoseAlgorithm, jwtAuthorizationRequestJwtHeaderTyp, jwtHeaderFromJwtSigner, jwtSignerFromJwt, parseAuthorizationRequest, parseAuthorizationResponseRedirectUrl, parseJarRequest, parsePushedAuthorizationRequestUriReferenceValue, preAuthorizedCodeGrantIdentifier, pushedAuthorizationRequestUriPrefix, refreshTokenGrantIdentifier, requestClientAttestationChallenge, resourceRequest, setGlobalConfig, shouldRetryAuthorizationServerRequestWithClientAttestationChallenge, signedAuthorizationRequestJwtHeaderTyp, validateJarRequestParams, verifyAuthorizationRequest, verifyAuthorizationResponse, verifyClientAttestationJwt, verifyIdTokenJwt, verifyJarRequest, verifyJwt, verifyResourceRequest, zAlgValueNotNone, zAuthorizationCodeGrantIdentifier, zAuthorizationErrorResponse, zAuthorizationRequest, zAuthorizationResponse, zAuthorizationResponseFromUriParams, zAuthorizationServerMetadata, zClientAttestationChallengeResponse, zClientCredentialsGrantIdentifier, zCompactJwe, zCompactJwt, zIdTokenJwtHeader, zIdTokenJwtPayload, zJarAuthorizationRequest, zJarRequestObjectPayload, zJwk, zJwkSet, zJwtHeader, zJwtPayload, zOauth2ErrorResponse, zPreAuthorizedCodeGrantIdentifier, zPushedAuthorizationRequestUriPrefix, zRefreshTokenGrantIdentifier };
|
|
4053
4097
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1155,8 +1155,13 @@ function extractClientAttestationJwtsFromHeaders(headers) {
|
|
|
1155
1155
|
const clientAttestationHeader = headers.get(oauthClientAttestationHeader);
|
|
1156
1156
|
const clientAttestationPopHeader = headers.get(oauthClientAttestationPopHeader);
|
|
1157
1157
|
if (!clientAttestationHeader && !clientAttestationPopHeader) return { valid: true };
|
|
1158
|
-
if (!clientAttestationHeader
|
|
1159
|
-
if (!zCompactJwt.safeParse(clientAttestationHeader).success
|
|
1158
|
+
if (!clientAttestationHeader) return { valid: false };
|
|
1159
|
+
if (!zCompactJwt.safeParse(clientAttestationHeader).success) return { valid: false };
|
|
1160
|
+
if (!clientAttestationPopHeader) return {
|
|
1161
|
+
valid: true,
|
|
1162
|
+
clientAttestationHeader
|
|
1163
|
+
};
|
|
1164
|
+
if (!zCompactJwt.safeParse(clientAttestationPopHeader).success) return { valid: false };
|
|
1160
1165
|
return {
|
|
1161
1166
|
valid: true,
|
|
1162
1167
|
clientAttestationPopHeader,
|
|
@@ -1859,6 +1864,38 @@ function clientAuthenticationClientAttestationJwt(options) {
|
|
|
1859
1864
|
headers.set(oauthClientAttestationPopHeader, clientAttestationPop);
|
|
1860
1865
|
};
|
|
1861
1866
|
}
|
|
1867
|
+
/**
|
|
1868
|
+
* Client authentication using the `attest_jwt_client_auth_dpop` option (draft 09 §5.2).
|
|
1869
|
+
*
|
|
1870
|
+
* In this DPoP-bound variant the client instance key and the DPoP key are the same key, and a single
|
|
1871
|
+
* DPoP proof serves as both the DPoP proof and the Client Attestation PoP. The request carries the
|
|
1872
|
+
* `OAuth-Client-Attestation` and `DPoP` headers, but no separate `OAuth-Client-Attestation-PoP` header.
|
|
1873
|
+
*/
|
|
1874
|
+
function clientAuthenticationClientAttestationJwtDpop(options) {
|
|
1875
|
+
return async ({ headers, url, method, attestationChallenge }) => {
|
|
1876
|
+
const clientAttestation = decodeJwt({
|
|
1877
|
+
jwt: options.clientAttestationJwt,
|
|
1878
|
+
headerSchema: zClientAttestationJwtHeader,
|
|
1879
|
+
payloadSchema: zClientAttestationJwtPayload
|
|
1880
|
+
});
|
|
1881
|
+
const signer = options.signer ?? {
|
|
1882
|
+
method: "jwk",
|
|
1883
|
+
alg: clientAttestation.header.alg,
|
|
1884
|
+
publicJwk: clientAttestation.payload.cnf.jwk
|
|
1885
|
+
};
|
|
1886
|
+
const dpopJwt = await createDpopJwt({
|
|
1887
|
+
request: {
|
|
1888
|
+
url,
|
|
1889
|
+
method
|
|
1890
|
+
},
|
|
1891
|
+
signer,
|
|
1892
|
+
nonce: attestationChallenge ?? options.challenge,
|
|
1893
|
+
callbacks: options.callbacks
|
|
1894
|
+
});
|
|
1895
|
+
headers.set(oauthClientAttestationHeader, options.clientAttestationJwt);
|
|
1896
|
+
headers.set("DPoP", dpopJwt);
|
|
1897
|
+
};
|
|
1898
|
+
}
|
|
1862
1899
|
//#endregion
|
|
1863
1900
|
//#region src/common/algorithm/algorithm-transform.ts
|
|
1864
1901
|
/**
|
|
@@ -2567,13 +2604,17 @@ async function verifyRefreshTokenAccessTokenRequest(options) {
|
|
|
2567
2604
|
};
|
|
2568
2605
|
}
|
|
2569
2606
|
async function verifyAccessTokenRequestClientAttestation(options, authorizationServerMetadata, callbacks, dpopJwkThumbprint, now) {
|
|
2570
|
-
if (!options.clientAttestationJwt
|
|
2571
|
-
if (!options.required && !options.
|
|
2607
|
+
if (!options.clientAttestationJwt) {
|
|
2608
|
+
if (!options.required && !options.clientAttestationPopJwt) return;
|
|
2572
2609
|
throw new Oauth2ServerErrorResponseError({
|
|
2573
2610
|
error: "invalid_client",
|
|
2574
2611
|
error_description: `Missing required client attestation parameters in access token request. Make sure to provide the '${oauthClientAttestationHeader}' and '${oauthClientAttestationPopHeader}' header values.`
|
|
2575
2612
|
});
|
|
2576
2613
|
}
|
|
2614
|
+
if (!options.clientAttestationPopJwt) return verifyAccessTokenRequestClientAttestationDpop({
|
|
2615
|
+
...options,
|
|
2616
|
+
clientAttestationJwt: options.clientAttestationJwt
|
|
2617
|
+
}, authorizationServerMetadata, callbacks, dpopJwkThumbprint, now);
|
|
2577
2618
|
const verifiedClientAttestation = await verifyClientAttestation({
|
|
2578
2619
|
authorizationServer: authorizationServerMetadata.issuer,
|
|
2579
2620
|
callbacks,
|
|
@@ -2581,21 +2622,56 @@ async function verifyAccessTokenRequestClientAttestation(options, authorizationS
|
|
|
2581
2622
|
clientAttestationPopJwt: options.clientAttestationPopJwt,
|
|
2582
2623
|
now
|
|
2583
2624
|
});
|
|
2584
|
-
|
|
2625
|
+
assertExpectedClientId(options.expectedClientId, verifiedClientAttestation.clientAttestation.payload.sub);
|
|
2626
|
+
if (options.ensureConfirmationKeyMatchesDpopKey && dpopJwkThumbprint) await assertConfirmationKeyMatchesDpopKey(verifiedClientAttestation.clientAttestation.payload.cnf.jwk, dpopJwkThumbprint, callbacks);
|
|
2627
|
+
return verifiedClientAttestation;
|
|
2628
|
+
}
|
|
2629
|
+
async function verifyAccessTokenRequestClientAttestationDpop(options, authorizationServerMetadata, callbacks, dpopJwkThumbprint, now) {
|
|
2630
|
+
const supportedMethods = authorizationServerMetadata.token_endpoint_auth_methods_supported;
|
|
2631
|
+
if (supportedMethods && !supportedMethods.includes("attest_jwt_client_auth_dpop")) throw new Oauth2ServerErrorResponseError({
|
|
2585
2632
|
error: "invalid_client",
|
|
2586
|
-
error_description: `The
|
|
2587
|
-
}
|
|
2588
|
-
if (
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2633
|
+
error_description: `The authorization server does not support the 'attest_jwt_client_auth_dpop' client authentication method.`
|
|
2634
|
+
});
|
|
2635
|
+
if (!dpopJwkThumbprint) throw new Oauth2ServerErrorResponseError({
|
|
2636
|
+
error: "invalid_client",
|
|
2637
|
+
error_description: `Client attestation provided without an '${oauthClientAttestationPopHeader}' header, but no valid DPoP proof is present. The 'attest_jwt_client_auth_dpop' method requires a DPoP proof.`
|
|
2638
|
+
});
|
|
2639
|
+
let clientAttestation;
|
|
2640
|
+
try {
|
|
2641
|
+
clientAttestation = await verifyClientAttestationJwt({
|
|
2642
|
+
callbacks,
|
|
2643
|
+
clientAttestationJwt: options.clientAttestationJwt,
|
|
2644
|
+
now
|
|
2645
|
+
});
|
|
2646
|
+
} catch (error) {
|
|
2647
|
+
if (error instanceof Oauth2Error) throw new Oauth2ServerErrorResponseError({
|
|
2648
|
+
error: "invalid_client",
|
|
2649
|
+
error_description: `Error verifying client attestation. ${error.message}`
|
|
2650
|
+
}, {
|
|
2651
|
+
status: 401,
|
|
2652
|
+
cause: error
|
|
2653
|
+
});
|
|
2654
|
+
throw error;
|
|
2597
2655
|
}
|
|
2598
|
-
|
|
2656
|
+
assertExpectedClientId(options.expectedClientId, clientAttestation.payload.sub);
|
|
2657
|
+
await assertConfirmationKeyMatchesDpopKey(clientAttestation.payload.cnf.jwk, dpopJwkThumbprint, callbacks);
|
|
2658
|
+
return { clientAttestation };
|
|
2659
|
+
}
|
|
2660
|
+
function assertExpectedClientId(expectedClientId, sub) {
|
|
2661
|
+
if (expectedClientId && expectedClientId !== sub) throw new Oauth2ServerErrorResponseError({
|
|
2662
|
+
error: "invalid_client",
|
|
2663
|
+
error_description: `The client id '${sub}' in the client attestation does not match the client id for the authorization.`
|
|
2664
|
+
}, { status: 401 });
|
|
2665
|
+
}
|
|
2666
|
+
async function assertConfirmationKeyMatchesDpopKey(confirmationJwk, dpopJwkThumbprint, callbacks) {
|
|
2667
|
+
if (await calculateJwkThumbprint({
|
|
2668
|
+
hashAlgorithm: "sha-256",
|
|
2669
|
+
hashCallback: callbacks.hash,
|
|
2670
|
+
jwk: confirmationJwk
|
|
2671
|
+
}) !== dpopJwkThumbprint) throw new Oauth2ServerErrorResponseError({
|
|
2672
|
+
error: "invalid_request",
|
|
2673
|
+
error_description: "Expected the DPoP JWK thumbprint value to match the JWK thumbprint of the client attestation confirmation JWK. Ensure both DPoP and client attestation use the same key."
|
|
2674
|
+
}, { status: 401 });
|
|
2599
2675
|
}
|
|
2600
2676
|
async function verifyAccessTokenRequestDpop(options, request, callbacks) {
|
|
2601
2677
|
if (options.required && !options.jwt) throw new Oauth2ServerErrorResponseError({
|
|
@@ -2608,7 +2684,8 @@ async function verifyAccessTokenRequestDpop(options, request, callbacks) {
|
|
|
2608
2684
|
dpopJwt: options.jwt,
|
|
2609
2685
|
request,
|
|
2610
2686
|
allowedSigningAlgs: options.allowedSigningAlgs,
|
|
2611
|
-
expectedJwkThumbprint: options.expectedJwkThumbprint
|
|
2687
|
+
expectedJwkThumbprint: options.expectedJwkThumbprint,
|
|
2688
|
+
expectedNonce: options.expectedNonce
|
|
2612
2689
|
});
|
|
2613
2690
|
return {
|
|
2614
2691
|
jwk: header.jwk,
|
|
@@ -3582,6 +3659,6 @@ async function verifyResourceRequest(options) {
|
|
|
3582
3659
|
};
|
|
3583
3660
|
}
|
|
3584
3661
|
//#endregion
|
|
3585
|
-
export { HashAlgorithm, InvalidFetchResponseError, Oauth2AuthorizationServer, Oauth2Client, Oauth2ClientAuthorizationChallengeError, Oauth2ClientErrorResponseError, Oauth2Error, Oauth2ErrorCodes, Oauth2JwtParseError, Oauth2JwtVerificationError, Oauth2ResourceServer, Oauth2ResourceUnauthorizedError, Oauth2ServerErrorResponseError, PkceCodeChallengeMethod, SupportedAuthenticationScheme, SupportedClientAuthenticationMethod, authorizationCodeGrantIdentifier, authorizationServerRequestWithClientAttestationChallengeRetry, authorizationServerRequestWithDpopRetry, calculateJwkThumbprint, clientAuthenticationAnonymous, clientAuthenticationClientAttestationJwt, clientAuthenticationClientSecretBasic, clientAuthenticationClientSecretPost, clientAuthenticationDynamic, clientAuthenticationNone, clientCredentialsGrantIdentifier, createClientAttestationJwt, createDpopHeadersForRequest, createJarAuthorizationRequest, createPkce, decodeJwt, decodeJwtHeader, defaultGrantTypesSupported, extractClientAttestationChallengeFromHeaders, extractDpopNonceFromHeaders, fetchAuthorizationServerMetadata, fetchJwks, fetchWellKnownMetadata, fullySpecifiedCoseAlgorithmArrayToJwaSignatureAlgorithmArray, fullySpecifiedCoseAlgorithmToJwaSignatureAlgorithm, getAuthorizationServerMetadataFromList, getGlobalConfig, getGrantTypesSupported, isJarAuthorizationRequest, isJwkInSet, jwaSignatureAlgorithmArrayToFullySpecifiedCoseAlgorithmArray, jwaSignatureAlgorithmToFullySpecifiedCoseAlgorithm, jwtAuthorizationRequestJwtHeaderTyp, jwtHeaderFromJwtSigner, jwtSignerFromJwt, parseAuthorizationRequest, parseAuthorizationResponseRedirectUrl, parseJarRequest, parsePushedAuthorizationRequestUriReferenceValue, preAuthorizedCodeGrantIdentifier, pushedAuthorizationRequestUriPrefix, refreshTokenGrantIdentifier, requestClientAttestationChallenge, resourceRequest, setGlobalConfig, shouldRetryAuthorizationServerRequestWithClientAttestationChallenge, signedAuthorizationRequestJwtHeaderTyp, validateJarRequestParams, verifyAuthorizationRequest, verifyAuthorizationResponse, verifyClientAttestationJwt, verifyIdTokenJwt, verifyJarRequest, verifyJwt, verifyResourceRequest, zAlgValueNotNone, zAuthorizationCodeGrantIdentifier, zAuthorizationErrorResponse, zAuthorizationRequest, zAuthorizationResponse, zAuthorizationResponseFromUriParams, zAuthorizationServerMetadata, zClientAttestationChallengeResponse, zClientCredentialsGrantIdentifier, zCompactJwe, zCompactJwt, zIdTokenJwtHeader, zIdTokenJwtPayload, zJarAuthorizationRequest, zJarRequestObjectPayload, zJwk, zJwkSet, zJwtHeader, zJwtPayload, zOauth2ErrorResponse, zPreAuthorizedCodeGrantIdentifier, zPushedAuthorizationRequestUriPrefix, zRefreshTokenGrantIdentifier };
|
|
3662
|
+
export { HashAlgorithm, InvalidFetchResponseError, Oauth2AuthorizationServer, Oauth2Client, Oauth2ClientAuthorizationChallengeError, Oauth2ClientErrorResponseError, Oauth2Error, Oauth2ErrorCodes, Oauth2JwtParseError, Oauth2JwtVerificationError, Oauth2ResourceServer, Oauth2ResourceUnauthorizedError, Oauth2ServerErrorResponseError, PkceCodeChallengeMethod, SupportedAuthenticationScheme, SupportedClientAuthenticationMethod, authorizationCodeGrantIdentifier, authorizationServerRequestWithClientAttestationChallengeRetry, authorizationServerRequestWithDpopRetry, calculateJwkThumbprint, clientAuthenticationAnonymous, clientAuthenticationClientAttestationJwt, clientAuthenticationClientAttestationJwtDpop, clientAuthenticationClientSecretBasic, clientAuthenticationClientSecretPost, clientAuthenticationDynamic, clientAuthenticationNone, clientCredentialsGrantIdentifier, createClientAttestationJwt, createDpopHeadersForRequest, createJarAuthorizationRequest, createPkce, decodeJwt, decodeJwtHeader, defaultGrantTypesSupported, extractClientAttestationChallengeFromHeaders, extractDpopNonceFromHeaders, fetchAuthorizationServerMetadata, fetchJwks, fetchWellKnownMetadata, fullySpecifiedCoseAlgorithmArrayToJwaSignatureAlgorithmArray, fullySpecifiedCoseAlgorithmToJwaSignatureAlgorithm, getAuthorizationServerMetadataFromList, getGlobalConfig, getGrantTypesSupported, isJarAuthorizationRequest, isJwkInSet, jwaSignatureAlgorithmArrayToFullySpecifiedCoseAlgorithmArray, jwaSignatureAlgorithmToFullySpecifiedCoseAlgorithm, jwtAuthorizationRequestJwtHeaderTyp, jwtHeaderFromJwtSigner, jwtSignerFromJwt, parseAuthorizationRequest, parseAuthorizationResponseRedirectUrl, parseJarRequest, parsePushedAuthorizationRequestUriReferenceValue, preAuthorizedCodeGrantIdentifier, pushedAuthorizationRequestUriPrefix, refreshTokenGrantIdentifier, requestClientAttestationChallenge, resourceRequest, setGlobalConfig, shouldRetryAuthorizationServerRequestWithClientAttestationChallenge, signedAuthorizationRequestJwtHeaderTyp, validateJarRequestParams, verifyAuthorizationRequest, verifyAuthorizationResponse, verifyClientAttestationJwt, verifyIdTokenJwt, verifyJarRequest, verifyJwt, verifyResourceRequest, zAlgValueNotNone, zAuthorizationCodeGrantIdentifier, zAuthorizationErrorResponse, zAuthorizationRequest, zAuthorizationResponse, zAuthorizationResponseFromUriParams, zAuthorizationServerMetadata, zClientAttestationChallengeResponse, zClientCredentialsGrantIdentifier, zCompactJwe, zCompactJwt, zIdTokenJwtHeader, zIdTokenJwtPayload, zJarAuthorizationRequest, zJarRequestObjectPayload, zJwk, zJwkSet, zJwtHeader, zJwtPayload, zOauth2ErrorResponse, zPreAuthorizedCodeGrantIdentifier, zPushedAuthorizationRequestUriPrefix, zRefreshTokenGrantIdentifier };
|
|
3586
3663
|
|
|
3587
3664
|
//# sourceMappingURL=index.mjs.map
|