oauth4webapi 1.2.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/LICENSE.md +21 -0
- package/README.md +100 -0
- package/build/index.d.ts +1179 -0
- package/build/index.js +1589 -0
- package/package.json +80 -0
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,1179 @@
|
|
|
1
|
+
/** @ignore */
|
|
2
|
+
export declare type JsonObject = {
|
|
3
|
+
[Key in string]?: JsonValue;
|
|
4
|
+
};
|
|
5
|
+
/** @ignore */
|
|
6
|
+
export declare type JsonArray = JsonValue[];
|
|
7
|
+
/** @ignore */
|
|
8
|
+
export declare type JsonPrimitive = string | number | boolean | null;
|
|
9
|
+
/** @ignore */
|
|
10
|
+
export declare type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
11
|
+
/**
|
|
12
|
+
* Interface to pass an asymmetric private key and, optionally, its associated JWK Key ID to be
|
|
13
|
+
* added as a `kid` JOSE Header Parameter.
|
|
14
|
+
*/
|
|
15
|
+
export interface PrivateKey {
|
|
16
|
+
/**
|
|
17
|
+
* An asymmetric private CryptoKey.
|
|
18
|
+
*
|
|
19
|
+
* Its algorithm must be compatible with a supported {@link JWSAlgorithm JWS `alg` Algorithm}.
|
|
20
|
+
*/
|
|
21
|
+
key: CryptoKey;
|
|
22
|
+
/**
|
|
23
|
+
* JWK Key ID to add to JOSE headers when this key is used. When not provided no `kid` (JWK Key
|
|
24
|
+
* ID) will be added to the JOSE Header.
|
|
25
|
+
*/
|
|
26
|
+
kid?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Supported Client Authentication Methods.
|
|
30
|
+
*
|
|
31
|
+
* - **`client_secret_basic`** (default) uses the HTTP `Basic` authentication scheme to send
|
|
32
|
+
* {@link Client.client_id `client_id`} and {@link Client.client_secret `client_secret`} in an
|
|
33
|
+
* `Authorization` HTTP Header.
|
|
34
|
+
* - **`client_secret_post`** uses the HTTP request body to send {@link Client.client_id `client_id`}
|
|
35
|
+
* and {@link Client.client_secret `client_secret`} as `application/x-www-form-urlencoded` body
|
|
36
|
+
* parameters.
|
|
37
|
+
* - **`private_key_jwt`** uses the HTTP request body to send {@link Client.client_id `client_id`},
|
|
38
|
+
* `client_assertion_type`, and `client_assertion` as `application/x-www-form-urlencoded` body
|
|
39
|
+
* parameters. The `client_assertion` is signed using a private key supplied as an
|
|
40
|
+
* {@link AuthenticatedRequestOptions.clientPrivateKey options parameter}.
|
|
41
|
+
* - **`none`** (public client) uses the HTTP request body to send only
|
|
42
|
+
* {@link Client.client_id `client_id`} as `application/x-www-form-urlencoded` body parameter.
|
|
43
|
+
*
|
|
44
|
+
* @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-2.3)
|
|
45
|
+
* @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0.html#ClientAuthentication)
|
|
46
|
+
* @see [OAuth Token Endpoint Authentication Methods](https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#token-endpoint-auth-method)
|
|
47
|
+
*/
|
|
48
|
+
export declare type ClientAuthenticationMethod = 'client_secret_basic' | 'client_secret_post' | 'private_key_jwt' | 'none';
|
|
49
|
+
/**
|
|
50
|
+
* Supported JWS `alg` Algorithm identifiers.
|
|
51
|
+
*
|
|
52
|
+
* @example CryptoKey algorithm for the `PS256` JWS Algorithm Identifier
|
|
53
|
+
*
|
|
54
|
+
* ```ts
|
|
55
|
+
* interface Ps256Algorithm extends RsaHashedKeyAlgorithm {
|
|
56
|
+
* name: 'RSA-PSS'
|
|
57
|
+
* hash: { name: 'SHA-256' }
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @example CryptoKey algorithm for the `ES256` JWS Algorithm Identifier
|
|
62
|
+
*
|
|
63
|
+
* ```ts
|
|
64
|
+
* interface Es256Algorithm extends EcKeyAlgorithm {
|
|
65
|
+
* name: 'ECDSA'
|
|
66
|
+
* namedCurve: 'P-256'
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @example CryptoKey algorithm for the `RS256` JWS Algorithm Identifier
|
|
71
|
+
*
|
|
72
|
+
* ```ts
|
|
73
|
+
* interface Rs256Algorithm extends RsaHashedKeyAlgorithm {
|
|
74
|
+
* name: 'RSASSA-PKCS1-v1_5'
|
|
75
|
+
* hash: { name: 'SHA-256' }
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @example CryptoKey algorithm for the `EdDSA` JWS Algorithm Identifier (Experimental)
|
|
80
|
+
*
|
|
81
|
+
* Runtime support for this algorithm is very limited, it depends on the [Secure Curves in the Web
|
|
82
|
+
* Cryptography API](https://wicg.github.io/webcrypto-secure-curves/) proposal which is yet to be
|
|
83
|
+
* widely adopted. If the proposal changes this implementation will follow up with a minor release.
|
|
84
|
+
*
|
|
85
|
+
* ```ts
|
|
86
|
+
* interface EdDSAAlgorithm extends KeyAlgorithm {
|
|
87
|
+
* name: 'Ed25519'
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export declare type JWSAlgorithm = 'PS256' | 'ES256' | 'RS256' | 'EdDSA';
|
|
92
|
+
/**
|
|
93
|
+
* JSON Web Key
|
|
94
|
+
*
|
|
95
|
+
* @ignore
|
|
96
|
+
*/
|
|
97
|
+
export interface JWK {
|
|
98
|
+
/** Key Type */
|
|
99
|
+
readonly kty?: string;
|
|
100
|
+
/** Key ID */
|
|
101
|
+
readonly kid?: string;
|
|
102
|
+
/** Algorithm */
|
|
103
|
+
readonly alg?: string;
|
|
104
|
+
/** Public Key Use */
|
|
105
|
+
readonly use?: string;
|
|
106
|
+
/** Key Operations */
|
|
107
|
+
readonly key_ops?: string[];
|
|
108
|
+
/** (RSA) Exponent */
|
|
109
|
+
readonly e?: string;
|
|
110
|
+
/** (RSA) Modulus */
|
|
111
|
+
readonly n?: string;
|
|
112
|
+
/**
|
|
113
|
+
* (EC) Curve
|
|
114
|
+
*
|
|
115
|
+
* (OKP) The subtype of key pair
|
|
116
|
+
*/
|
|
117
|
+
readonly crv?: string;
|
|
118
|
+
/**
|
|
119
|
+
* (EC) X Coordinate
|
|
120
|
+
*
|
|
121
|
+
* (OKP) The public key
|
|
122
|
+
*/
|
|
123
|
+
readonly x?: string;
|
|
124
|
+
/** (EC) Y Coordinate */
|
|
125
|
+
readonly y?: string;
|
|
126
|
+
readonly [parameter: string]: JsonValue | undefined;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Authorization Server Metadata
|
|
130
|
+
*
|
|
131
|
+
* @see [IANA OAuth Authorization Server Metadata registry](https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#authorization-server-metadata)
|
|
132
|
+
*/
|
|
133
|
+
export interface AuthorizationServer {
|
|
134
|
+
/** Authorization server's Issuer Identifier URL. */
|
|
135
|
+
readonly issuer: string;
|
|
136
|
+
/** URL of the authorization server's authorization endpoint. */
|
|
137
|
+
readonly authorization_endpoint?: string;
|
|
138
|
+
/** URL of the authorization server's token endpoint. */
|
|
139
|
+
readonly token_endpoint?: string;
|
|
140
|
+
/** URL of the authorization server's JWK Set document. */
|
|
141
|
+
readonly jwks_uri?: string;
|
|
142
|
+
/** URL of the authorization server's Dynamic Client Registration Endpoint. */
|
|
143
|
+
readonly registration_endpoint?: string;
|
|
144
|
+
/** JSON array containing a list of the `scope` values that this authorization server supports. */
|
|
145
|
+
readonly scopes_supported?: string[];
|
|
146
|
+
/**
|
|
147
|
+
* JSON array containing a list of the `response_type` values that this authorization server
|
|
148
|
+
* supports.
|
|
149
|
+
*/
|
|
150
|
+
readonly response_types_supported?: string[];
|
|
151
|
+
/**
|
|
152
|
+
* JSON array containing a list of the `response_mode` values that this authorization server
|
|
153
|
+
* supports.
|
|
154
|
+
*/
|
|
155
|
+
readonly response_modes_supported?: string[];
|
|
156
|
+
/**
|
|
157
|
+
* JSON array containing a list of the `grant_type` values that this authorization server
|
|
158
|
+
* supports.
|
|
159
|
+
*/
|
|
160
|
+
readonly grant_types_supported?: string[];
|
|
161
|
+
/** JSON array containing a list of client authentication methods supported by this token endpoint. */
|
|
162
|
+
readonly token_endpoint_auth_methods_supported?: string[];
|
|
163
|
+
/**
|
|
164
|
+
* JSON array containing a list of the JWS signing algorithms supported by the token endpoint for
|
|
165
|
+
* the signature on the JWT used to authenticate the client at the token endpoint.
|
|
166
|
+
*/
|
|
167
|
+
readonly token_endpoint_auth_signing_alg_values_supported?: string[];
|
|
168
|
+
/**
|
|
169
|
+
* URL of a page containing human-readable information that developers might want or need to know
|
|
170
|
+
* when using the authorization server.
|
|
171
|
+
*/
|
|
172
|
+
readonly service_documentation?: string;
|
|
173
|
+
/**
|
|
174
|
+
* Languages and scripts supported for the user interface, represented as a JSON array of language
|
|
175
|
+
* tag values from RFC 5646.
|
|
176
|
+
*/
|
|
177
|
+
readonly ui_locales_supported?: string[];
|
|
178
|
+
/**
|
|
179
|
+
* URL that the authorization server provides to the person registering the client to read about
|
|
180
|
+
* the authorization server's requirements on how the client can use the data provided by the
|
|
181
|
+
* authorization server.
|
|
182
|
+
*/
|
|
183
|
+
readonly op_policy_uri?: string;
|
|
184
|
+
/**
|
|
185
|
+
* URL that the authorization server provides to the person registering the client to read about
|
|
186
|
+
* the authorization server's terms of service.
|
|
187
|
+
*/
|
|
188
|
+
readonly op_tos_uri?: string;
|
|
189
|
+
/** URL of the authorization server's revocation endpoint. */
|
|
190
|
+
readonly revocation_endpoint?: string;
|
|
191
|
+
/**
|
|
192
|
+
* JSON array containing a list of client authentication methods supported by this revocation
|
|
193
|
+
* endpoint.
|
|
194
|
+
*/
|
|
195
|
+
readonly revocation_endpoint_auth_methods_supported?: string[];
|
|
196
|
+
/**
|
|
197
|
+
* JSON array containing a list of the JWS signing algorithms supported by the revocation endpoint
|
|
198
|
+
* for the signature on the JWT used to authenticate the client at the revocation endpoint.
|
|
199
|
+
*/
|
|
200
|
+
readonly revocation_endpoint_auth_signing_alg_values_supported?: string[];
|
|
201
|
+
/** URL of the authorization server's introspection endpoint. */
|
|
202
|
+
readonly introspection_endpoint?: string;
|
|
203
|
+
/**
|
|
204
|
+
* JSON array containing a list of client authentication methods supported by this introspection
|
|
205
|
+
* endpoint.
|
|
206
|
+
*/
|
|
207
|
+
readonly introspection_endpoint_auth_methods_supported?: string[];
|
|
208
|
+
/**
|
|
209
|
+
* JSON array containing a list of the JWS signing algorithms supported by the introspection
|
|
210
|
+
* endpoint for the signature on the JWT used to authenticate the client at the introspection
|
|
211
|
+
* endpoint.
|
|
212
|
+
*/
|
|
213
|
+
readonly introspection_endpoint_auth_signing_alg_values_supported?: string[];
|
|
214
|
+
/** PKCE code challenge methods supported by this authorization server. */
|
|
215
|
+
readonly code_challenge_methods_supported?: string[];
|
|
216
|
+
/** Signed JWT containing metadata values about the authorization server as claims. */
|
|
217
|
+
readonly signed_metadata?: string;
|
|
218
|
+
/** URL of the authorization server's device authorization endpoint. */
|
|
219
|
+
readonly device_authorization_endpoint?: string;
|
|
220
|
+
/** Indicates authorization server support for mutual-TLS client certificate-bound access tokens. */
|
|
221
|
+
readonly tls_client_certificate_bound_access_tokens?: boolean;
|
|
222
|
+
/**
|
|
223
|
+
* JSON object containing alternative authorization server endpoints, which a client intending to
|
|
224
|
+
* do mutual TLS will use in preference to the conventional endpoints.
|
|
225
|
+
*/
|
|
226
|
+
readonly mtls_endpoint_aliases?: MTLSEndpointAliases;
|
|
227
|
+
/** URL of the authorization server's UserInfo Endpoint. */
|
|
228
|
+
readonly userinfo_endpoint?: string;
|
|
229
|
+
/**
|
|
230
|
+
* JSON array containing a list of the Authentication Context Class References that this
|
|
231
|
+
* authorization server supports.
|
|
232
|
+
*/
|
|
233
|
+
readonly acr_values_supported?: string[];
|
|
234
|
+
/**
|
|
235
|
+
* JSON array containing a list of the Subject Identifier types that this authorization server
|
|
236
|
+
* supports.
|
|
237
|
+
*/
|
|
238
|
+
readonly subject_types_supported?: string[];
|
|
239
|
+
/**
|
|
240
|
+
* JSON array containing a list of the JWS `alg` values supported by the authorization server for
|
|
241
|
+
* the ID Token.
|
|
242
|
+
*/
|
|
243
|
+
readonly id_token_signing_alg_values_supported?: string[];
|
|
244
|
+
/**
|
|
245
|
+
* JSON array containing a list of the JWE `alg` values supported by the authorization server for
|
|
246
|
+
* the ID Token.
|
|
247
|
+
*/
|
|
248
|
+
readonly id_token_encryption_alg_values_supported?: string[];
|
|
249
|
+
/**
|
|
250
|
+
* JSON array containing a list of the JWE `enc` values supported by the authorization server for
|
|
251
|
+
* the ID Token.
|
|
252
|
+
*/
|
|
253
|
+
readonly id_token_encryption_enc_values_supported?: string[];
|
|
254
|
+
/** JSON array containing a list of the JWS `alg` values supported by the UserInfo Endpoint. */
|
|
255
|
+
readonly userinfo_signing_alg_values_supported?: string[];
|
|
256
|
+
/** JSON array containing a list of the JWE `alg` values supported by the UserInfo Endpoint. */
|
|
257
|
+
readonly userinfo_encryption_alg_values_supported?: string[];
|
|
258
|
+
/** JSON array containing a list of the JWE `enc` values supported by the UserInfo Endpoint. */
|
|
259
|
+
readonly userinfo_encryption_enc_values_supported?: string[];
|
|
260
|
+
/**
|
|
261
|
+
* JSON array containing a list of the JWS `alg` values supported by the authorization server for
|
|
262
|
+
* Request Objects.
|
|
263
|
+
*/
|
|
264
|
+
readonly request_object_signing_alg_values_supported?: string[];
|
|
265
|
+
/**
|
|
266
|
+
* JSON array containing a list of the JWE `alg` values supported by the authorization server for
|
|
267
|
+
* Request Objects.
|
|
268
|
+
*/
|
|
269
|
+
readonly request_object_encryption_alg_values_supported?: string[];
|
|
270
|
+
/**
|
|
271
|
+
* JSON array containing a list of the JWE `enc` values supported by the authorization server for
|
|
272
|
+
* Request Objects.
|
|
273
|
+
*/
|
|
274
|
+
readonly request_object_encryption_enc_values_supported?: string[];
|
|
275
|
+
/**
|
|
276
|
+
* JSON array containing a list of the `display` parameter values that the authorization server
|
|
277
|
+
* supports.
|
|
278
|
+
*/
|
|
279
|
+
readonly display_values_supported?: string[];
|
|
280
|
+
/** JSON array containing a list of the Claim Types that the authorization server supports. */
|
|
281
|
+
readonly claim_types_supported?: string[];
|
|
282
|
+
/**
|
|
283
|
+
* JSON array containing a list of the Claim Names of the Claims that the authorization server MAY
|
|
284
|
+
* be able to supply values for.
|
|
285
|
+
*/
|
|
286
|
+
readonly claims_supported?: string[];
|
|
287
|
+
/**
|
|
288
|
+
* Languages and scripts supported for values in Claims being returned, represented as a JSON
|
|
289
|
+
* array of RFC 5646 language tag values.
|
|
290
|
+
*/
|
|
291
|
+
readonly claims_locales_supported?: string[];
|
|
292
|
+
/**
|
|
293
|
+
* Boolean value specifying whether the authorization server supports use of the `claims`
|
|
294
|
+
* parameter.
|
|
295
|
+
*/
|
|
296
|
+
readonly claims_parameter_supported?: boolean;
|
|
297
|
+
/**
|
|
298
|
+
* Boolean value specifying whether the authorization server supports use of the `request`
|
|
299
|
+
* parameter.
|
|
300
|
+
*/
|
|
301
|
+
readonly request_parameter_supported?: boolean;
|
|
302
|
+
/**
|
|
303
|
+
* Boolean value specifying whether the authorization server supports use of the `request_uri`
|
|
304
|
+
* parameter.
|
|
305
|
+
*/
|
|
306
|
+
readonly request_uri_parameter_supported?: boolean;
|
|
307
|
+
/**
|
|
308
|
+
* Boolean value specifying whether the authorization server requires any `request_uri` values
|
|
309
|
+
* used to be pre-registered.
|
|
310
|
+
*/
|
|
311
|
+
readonly require_request_uri_registration?: boolean;
|
|
312
|
+
/**
|
|
313
|
+
* Indicates where authorization request needs to be protected as Request Object and provided
|
|
314
|
+
* through either `request` or `request_uri` parameter.
|
|
315
|
+
*/
|
|
316
|
+
readonly require_signed_request_object?: boolean;
|
|
317
|
+
/** URL of the authorization server's pushed authorization request endpoint. */
|
|
318
|
+
readonly pushed_authorization_request_endpoint?: string;
|
|
319
|
+
/** Indicates whether the authorization server accepts authorization requests only via PAR. */
|
|
320
|
+
readonly require_pushed_authorization_requests?: boolean;
|
|
321
|
+
/**
|
|
322
|
+
* JSON array containing a list of algorithms supported by the authorization server for
|
|
323
|
+
* introspection response signing.
|
|
324
|
+
*/
|
|
325
|
+
readonly introspection_signing_alg_values_supported?: string[];
|
|
326
|
+
/**
|
|
327
|
+
* JSON array containing a list of algorithms supported by the authorization server for
|
|
328
|
+
* introspection response content key encryption (`alg` value).
|
|
329
|
+
*/
|
|
330
|
+
readonly introspection_encryption_alg_values_supported?: string[];
|
|
331
|
+
/**
|
|
332
|
+
* JSON array containing a list of algorithms supported by the authorization server for
|
|
333
|
+
* introspection response content encryption (`enc` value).
|
|
334
|
+
*/
|
|
335
|
+
readonly introspection_encryption_enc_values_supported?: string[];
|
|
336
|
+
/**
|
|
337
|
+
* Boolean value indicating whether the authorization server provides the `iss` parameter in the
|
|
338
|
+
* authorization response.
|
|
339
|
+
*/
|
|
340
|
+
readonly authorization_response_iss_parameter_supported?: boolean;
|
|
341
|
+
/**
|
|
342
|
+
* JSON array containing a list of algorithms supported by the authorization server for
|
|
343
|
+
* introspection response signing.
|
|
344
|
+
*/
|
|
345
|
+
readonly authorization_signing_alg_values_supported?: string[];
|
|
346
|
+
/**
|
|
347
|
+
* JSON array containing a list of algorithms supported by the authorization server for
|
|
348
|
+
* introspection response encryption (`alg` value).
|
|
349
|
+
*/
|
|
350
|
+
readonly authorization_encryption_alg_values_supported?: string[];
|
|
351
|
+
/**
|
|
352
|
+
* JSON array containing a list of algorithms supported by the authorization server for
|
|
353
|
+
* introspection response encryption (`enc` value).
|
|
354
|
+
*/
|
|
355
|
+
readonly authorization_encryption_enc_values_supported?: string[];
|
|
356
|
+
/** CIBA Backchannel Authentication Endpoint. */
|
|
357
|
+
readonly backchannel_authentication_endpoint?: string;
|
|
358
|
+
/**
|
|
359
|
+
* JSON array containing a list of the JWS signing algorithms supported for validation of signed
|
|
360
|
+
* CIBA authentication requests.
|
|
361
|
+
*/
|
|
362
|
+
readonly backchannel_authentication_request_signing_alg_values_supported?: string[];
|
|
363
|
+
/** Supported CIBA authentication result delivery modes. */
|
|
364
|
+
readonly backchannel_token_delivery_modes_supported?: string[];
|
|
365
|
+
/** Indicates whether the authorization server supports the use of the CIBA `user_code` parameter. */
|
|
366
|
+
readonly backchannel_user_code_parameter_supported?: boolean;
|
|
367
|
+
/**
|
|
368
|
+
* URL of an authorization server iframe that supports cross-origin communications for session
|
|
369
|
+
* state information with the RP Client, using the HTML5 postMessage API.
|
|
370
|
+
*/
|
|
371
|
+
readonly check_session_iframe?: string;
|
|
372
|
+
/** JSON array containing a list of the JWS algorithms supported for DPoP proof JWTs. */
|
|
373
|
+
readonly dpop_signing_alg_values_supported?: string[];
|
|
374
|
+
/**
|
|
375
|
+
* URL at the authorization server to which an RP can perform a redirect to request that the
|
|
376
|
+
* End-User be logged out at the authorization server.
|
|
377
|
+
*/
|
|
378
|
+
readonly end_session_endpoint?: string;
|
|
379
|
+
/**
|
|
380
|
+
* Boolean value specifying whether the authorization server can pass `iss` (issuer) and `sid`
|
|
381
|
+
* (session ID) query parameters to identify the RP session with the authorization server when the
|
|
382
|
+
* `frontchannel_logout_uri` is used.
|
|
383
|
+
*/
|
|
384
|
+
readonly frontchannel_logout_session_supported?: boolean;
|
|
385
|
+
/** Boolean value specifying whether the authorization server supports HTTP-based logout. */
|
|
386
|
+
readonly frontchannel_logout_supported?: boolean;
|
|
387
|
+
/**
|
|
388
|
+
* Boolean value specifying whether the authorization server can pass a `sid` (session ID) Claim
|
|
389
|
+
* in the Logout Token to identify the RP session with the OP.
|
|
390
|
+
*/
|
|
391
|
+
readonly backchannel_logout_session_supported?: boolean;
|
|
392
|
+
/** Boolean value specifying whether the authorization server supports back-channel logout. */
|
|
393
|
+
readonly backchannel_logout_supported?: boolean;
|
|
394
|
+
readonly [metadata: string]: JsonValue | undefined;
|
|
395
|
+
}
|
|
396
|
+
export interface MTLSEndpointAliases extends Pick<AuthorizationServer, 'token_endpoint' | 'revocation_endpoint' | 'introspection_endpoint' | 'device_authorization_endpoint' | 'userinfo_endpoint' | 'pushed_authorization_request_endpoint'> {
|
|
397
|
+
readonly [metadata: string]: JsonValue | undefined;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Recognized Client Metadata that have an effect on the exposed functionality.
|
|
401
|
+
*
|
|
402
|
+
* @see [IANA OAuth Client Registration Metadata registry](https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#client-metadata)
|
|
403
|
+
*/
|
|
404
|
+
export interface Client {
|
|
405
|
+
/** Client identifier. */
|
|
406
|
+
client_id: string;
|
|
407
|
+
/** Client secret. */
|
|
408
|
+
client_secret?: string;
|
|
409
|
+
/**
|
|
410
|
+
* Client {@link ClientAuthenticationMethod authentication method} for the client's authenticated
|
|
411
|
+
* requests. Default is `client_secret_basic`.
|
|
412
|
+
*/
|
|
413
|
+
token_endpoint_auth_method?: ClientAuthenticationMethod;
|
|
414
|
+
/**
|
|
415
|
+
* JWS `alg` algorithm required for signing the ID Token issued to this Client. When not
|
|
416
|
+
* configured the default is to allow only {@link JWSAlgorithm supported algorithms} listed in
|
|
417
|
+
* {@link AuthorizationServer.id_token_signing_alg_values_supported `as.id_token_signing_alg_values_supported`}
|
|
418
|
+
* and fall back to `RS256` when the authorization server metadata is not set.
|
|
419
|
+
*/
|
|
420
|
+
id_token_signed_response_alg?: JWSAlgorithm;
|
|
421
|
+
/**
|
|
422
|
+
* JWS `alg` algorithm required for signing authorization responses. When not configured the
|
|
423
|
+
* default is to allow only {@link JWSAlgorithm supported algorithms} listed in
|
|
424
|
+
* {@link AuthorizationServer.authorization_signing_alg_values_supported `as.authorization_signing_alg_values_supported`}
|
|
425
|
+
* and fall back to `RS256` when the authorization server metadata is not set.
|
|
426
|
+
*/
|
|
427
|
+
authorization_signed_response_alg?: JWSAlgorithm;
|
|
428
|
+
/**
|
|
429
|
+
* Boolean value specifying whether the {@link IDToken.auth_time `auth_time`} Claim in the ID Token
|
|
430
|
+
* is REQUIRED. Default is `false`.
|
|
431
|
+
*/
|
|
432
|
+
require_auth_time?: boolean;
|
|
433
|
+
/**
|
|
434
|
+
* JWS `alg` algorithm REQUIRED for signing UserInfo Responses. When not configured the default is
|
|
435
|
+
* to allow only {@link JWSAlgorithm supported algorithms} listed in
|
|
436
|
+
* {@link AuthorizationServer.userinfo_signing_alg_values_supported `as.userinfo_signing_alg_values_supported`}
|
|
437
|
+
* and fall back to `RS256` when the authorization server metadata is not set.
|
|
438
|
+
*/
|
|
439
|
+
userinfo_signed_response_alg?: JWSAlgorithm;
|
|
440
|
+
/**
|
|
441
|
+
* JWS `alg` algorithm REQUIRED for signed introspection responses. When not configured the
|
|
442
|
+
* default is to allow only {@link JWSAlgorithm supported algorithms} listed in
|
|
443
|
+
* {@link AuthorizationServer.introspection_signing_alg_values_supported `as.introspection_signing_alg_values_supported`}
|
|
444
|
+
* and fall back to `RS256` when the authorization server metadata is not set.
|
|
445
|
+
*/
|
|
446
|
+
introspection_signed_response_alg?: JWSAlgorithm;
|
|
447
|
+
/** Default Maximum Authentication Age. */
|
|
448
|
+
default_max_age?: number;
|
|
449
|
+
[metadata: string]: JsonValue | undefined;
|
|
450
|
+
}
|
|
451
|
+
export declare class UnsupportedOperationError extends Error {
|
|
452
|
+
constructor(message?: string);
|
|
453
|
+
}
|
|
454
|
+
export declare class OperationProcessingError extends Error {
|
|
455
|
+
constructor(message: string);
|
|
456
|
+
}
|
|
457
|
+
export interface HttpRequestOptions {
|
|
458
|
+
/**
|
|
459
|
+
* An AbortSignal instance, or a factory returning one, to abort the HTTP Request(s) triggered by
|
|
460
|
+
* this function's invocation.
|
|
461
|
+
*
|
|
462
|
+
* @example A 5000ms timeout AbortSignal for every request
|
|
463
|
+
*
|
|
464
|
+
* ```js
|
|
465
|
+
* const signal = () => AbortSignal.timeout(5_000) // Note: AbortSignal.timeout may not yet be available in all runtimes.
|
|
466
|
+
* ```
|
|
467
|
+
*/
|
|
468
|
+
signal?: (() => AbortSignal) | AbortSignal;
|
|
469
|
+
/**
|
|
470
|
+
* A Headers instance to additionally send with the HTTP Request(s) triggered by this function's
|
|
471
|
+
* invocation.
|
|
472
|
+
*/
|
|
473
|
+
headers?: Headers;
|
|
474
|
+
}
|
|
475
|
+
export interface DiscoveryRequestOptions extends HttpRequestOptions {
|
|
476
|
+
/** The issuer transformation algorithm to use. */
|
|
477
|
+
algorithm?: 'oidc' | 'oauth2';
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Performs an authorization server metadata discovery using one of two
|
|
481
|
+
* {@link DiscoveryRequestOptions.algorithm transformation algorithms} applied to the
|
|
482
|
+
* `issuerIdentifier` argument.
|
|
483
|
+
*
|
|
484
|
+
* - `oidc` (default) as defined by OpenID Connect Discovery 1.0.
|
|
485
|
+
* - `oauth2` as defined by RFC 8414.
|
|
486
|
+
*
|
|
487
|
+
* @param issuerIdentifier Issuer Identifier to resolve the well-known discovery URI for.
|
|
488
|
+
*
|
|
489
|
+
* @see [RFC 8414 - OAuth 2.0 Authorization Server Metadata](https://www.rfc-editor.org/rfc/rfc8414.html#section-3)
|
|
490
|
+
* @see [OpenID Connect Discovery 1.0](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig)
|
|
491
|
+
*/
|
|
492
|
+
export declare function discoveryRequest(issuerIdentifier: URL, options?: DiscoveryRequestOptions): Promise<Response>;
|
|
493
|
+
/**
|
|
494
|
+
* Validates Response instance to be one coming from the authorization server's well-known discovery
|
|
495
|
+
* endpoint.
|
|
496
|
+
*
|
|
497
|
+
* @param expectedIssuerIdentifier Expected Issuer Identifier value.
|
|
498
|
+
* @param response Resolved value from {@link discoveryRequest}.
|
|
499
|
+
*
|
|
500
|
+
* @returns Resolves with the discovered Authorization Server Metadata.
|
|
501
|
+
*
|
|
502
|
+
* @see [RFC 8414 - OAuth 2.0 Authorization Server Metadata](https://www.rfc-editor.org/rfc/rfc8414.html#section-3)
|
|
503
|
+
* @see [OpenID Connect Discovery 1.0](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig)
|
|
504
|
+
*/
|
|
505
|
+
export declare function processDiscoveryResponse(expectedIssuerIdentifier: URL, response: Response): Promise<AuthorizationServer>;
|
|
506
|
+
/**
|
|
507
|
+
* Generate random `code_verifier` value.
|
|
508
|
+
*
|
|
509
|
+
* @see [RFC 7636 - Proof Key for Code Exchange by OAuth Public Clients (PKCE)](https://www.rfc-editor.org/rfc/rfc7636.html#section-4)
|
|
510
|
+
*/
|
|
511
|
+
export declare function generateRandomCodeVerifier(): string;
|
|
512
|
+
/**
|
|
513
|
+
* Generate random `state` value.
|
|
514
|
+
*
|
|
515
|
+
* @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-4.1.1)
|
|
516
|
+
*/
|
|
517
|
+
export declare function generateRandomState(): string;
|
|
518
|
+
/**
|
|
519
|
+
* Generate random `nonce` value.
|
|
520
|
+
*
|
|
521
|
+
* @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0.html#IDToken)
|
|
522
|
+
*/
|
|
523
|
+
export declare function generateRandomNonce(): string;
|
|
524
|
+
/**
|
|
525
|
+
* Calculates the PKCE `code_verifier` value to send with an authorization request using the S256
|
|
526
|
+
* PKCE Code Challenge Method transformation.
|
|
527
|
+
*
|
|
528
|
+
* @param codeVerifier `code_verifier` value generated e.g. from {@link generateRandomCodeVerifier}.
|
|
529
|
+
*
|
|
530
|
+
* @see [RFC 7636 - Proof Key for Code Exchange by OAuth Public Clients (PKCE)](https://www.rfc-editor.org/rfc/rfc7636.html#section-4)
|
|
531
|
+
*/
|
|
532
|
+
export declare function calculatePKCECodeChallenge(codeVerifier: string): Promise<string>;
|
|
533
|
+
export interface DPoPOptions extends CryptoKeyPair {
|
|
534
|
+
/**
|
|
535
|
+
* Private CryptoKey instance to sign the DPoP Proof JWT with.
|
|
536
|
+
*
|
|
537
|
+
* Its algorithm must be compatible with a supported {@link JWSAlgorithm JWS `alg` Algorithm}.
|
|
538
|
+
*/
|
|
539
|
+
privateKey: CryptoKey;
|
|
540
|
+
/** The public key corresponding to {@link DPoPOptions.privateKey} */
|
|
541
|
+
publicKey: CryptoKey;
|
|
542
|
+
/**
|
|
543
|
+
* Server-Provided Nonce to use in the request. This option serves as an override in case the
|
|
544
|
+
* self-correcting mechanism does not work with a particular server. Previously received nonces
|
|
545
|
+
* will be used automatically.
|
|
546
|
+
*/
|
|
547
|
+
nonce?: string;
|
|
548
|
+
}
|
|
549
|
+
export interface DPoPRequestOptions {
|
|
550
|
+
/** DPoP-related options. */
|
|
551
|
+
DPoP?: DPoPOptions;
|
|
552
|
+
}
|
|
553
|
+
export interface AuthenticatedRequestOptions {
|
|
554
|
+
/**
|
|
555
|
+
* Private key to use for `private_key_jwt`
|
|
556
|
+
* {@link ClientAuthenticationMethod client authentication}. Its algorithm must be compatible with
|
|
557
|
+
* a supported {@link JWSAlgorithm JWS `alg` Algorithm}.
|
|
558
|
+
*/
|
|
559
|
+
clientPrivateKey?: CryptoKey | PrivateKey;
|
|
560
|
+
}
|
|
561
|
+
export interface PushedAuthorizationRequestOptions extends HttpRequestOptions, AuthenticatedRequestOptions, DPoPRequestOptions {
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Generates a signed JWT-Secured Authorization Request (JAR).
|
|
565
|
+
*
|
|
566
|
+
* @param as Authorization Server Metadata.
|
|
567
|
+
* @param client Client Metadata.
|
|
568
|
+
* @param privateKey Private key to sign the Request Object with.
|
|
569
|
+
*
|
|
570
|
+
* @see [RFC 9101 - The OAuth 2.0 Authorization Framework: JWT-Secured Authorization Request (JAR)](https://www.rfc-editor.org/rfc/rfc9101.html#name-request-object-2)
|
|
571
|
+
*/
|
|
572
|
+
export declare function issueRequestObject(as: AuthorizationServer, client: Client, parameters: URLSearchParams, privateKey: CryptoKey | PrivateKey): Promise<string>;
|
|
573
|
+
/**
|
|
574
|
+
* Performs a Pushed Authorization Request at the
|
|
575
|
+
* {@link AuthorizationServer.pushed_authorization_request_endpoint `as.pushed_authorization_request_endpoint`}.
|
|
576
|
+
*
|
|
577
|
+
* @param as Authorization Server Metadata.
|
|
578
|
+
* @param client Client Metadata.
|
|
579
|
+
* @param parameters Authorization Request parameters.
|
|
580
|
+
*
|
|
581
|
+
* @see [RFC 9126 - OAuth 2.0 Pushed Authorization Requests](https://www.rfc-editor.org/rfc/rfc9126.html#name-pushed-authorization-reques)
|
|
582
|
+
* @see [draft-ietf-oauth-dpop-10 - OAuth 2.0 Demonstrating Proof-of-Possession at the Application Layer (DPoP)](https://www.ietf.org/archive/id/draft-ietf-oauth-dpop-10.html#name-dpop-with-pushed-authorizat)
|
|
583
|
+
*/
|
|
584
|
+
export declare function pushedAuthorizationRequest(as: AuthorizationServer, client: Client, parameters: URLSearchParams, options?: PushedAuthorizationRequestOptions): Promise<Response>;
|
|
585
|
+
export interface PushedAuthorizationResponse {
|
|
586
|
+
readonly request_uri: string;
|
|
587
|
+
readonly expires_in: number;
|
|
588
|
+
readonly [parameter: string]: JsonValue | undefined;
|
|
589
|
+
}
|
|
590
|
+
export interface OAuth2Error {
|
|
591
|
+
readonly error: string;
|
|
592
|
+
readonly error_description?: string;
|
|
593
|
+
readonly error_uri?: string;
|
|
594
|
+
readonly algs?: string;
|
|
595
|
+
readonly scope?: string;
|
|
596
|
+
readonly [parameter: string]: JsonValue | undefined;
|
|
597
|
+
}
|
|
598
|
+
/** A helper function used to determine if a response processing function returned an OAuth2Error. */
|
|
599
|
+
export declare function isOAuth2Error(input?: ReturnTypes): input is OAuth2Error;
|
|
600
|
+
export interface WWWAuthenticateChallenge {
|
|
601
|
+
/** NOTE: because the value is case insensitive it is always returned lowercased */
|
|
602
|
+
readonly scheme: string;
|
|
603
|
+
readonly parameters: {
|
|
604
|
+
readonly realm?: string;
|
|
605
|
+
readonly error?: string;
|
|
606
|
+
readonly error_description?: string;
|
|
607
|
+
readonly error_uri?: string;
|
|
608
|
+
readonly algs?: string;
|
|
609
|
+
readonly scope?: string;
|
|
610
|
+
/** NOTE: because the parameter names are case insensitive they are always returned lowercased */
|
|
611
|
+
readonly [parameter: string]: string | undefined;
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Parses the `WWW-Authenticate` HTTP Header from a Response instance.
|
|
616
|
+
*
|
|
617
|
+
* @returns Array of {@link WWWAuthenticateChallenge} objects. Their order from the response is
|
|
618
|
+
* preserved. `undefined` when there wasn't a `WWW-Authenticate` HTTP Header returned.
|
|
619
|
+
*/
|
|
620
|
+
export declare function parseWwwAuthenticateChallenges(response: Response): WWWAuthenticateChallenge[] | undefined;
|
|
621
|
+
/**
|
|
622
|
+
* Validates Response instance to be one coming from the
|
|
623
|
+
* {@link AuthorizationServer.pushed_authorization_request_endpoint `as.pushed_authorization_request_endpoint`}.
|
|
624
|
+
*
|
|
625
|
+
* @param as Authorization Server Metadata.
|
|
626
|
+
* @param client Client Metadata.
|
|
627
|
+
* @param response Resolved value from {@link pushedAuthorizationRequest}.
|
|
628
|
+
*
|
|
629
|
+
* @returns Resolves with an object representing the parsed successful response, or an object
|
|
630
|
+
* representing an OAuth 2.0 protocol style error. Use {@link isOAuth2Error} to determine if an
|
|
631
|
+
* OAuth 2.0 error was returned.
|
|
632
|
+
* @see [RFC 9126 - OAuth 2.0 Pushed Authorization Requests](https://www.rfc-editor.org/rfc/rfc9126.html#name-pushed-authorization-reques)
|
|
633
|
+
*/
|
|
634
|
+
export declare function processPushedAuthorizationResponse(as: AuthorizationServer, client: Client, response: Response): Promise<PushedAuthorizationResponse | OAuth2Error>;
|
|
635
|
+
export interface ProtectedResourceRequestOptions extends Omit<HttpRequestOptions, 'headers'>, DPoPRequestOptions {
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Performs a protected resource request at an arbitrary URL.
|
|
639
|
+
*
|
|
640
|
+
* Authorization Header is used to transmit the Access Token value.
|
|
641
|
+
*
|
|
642
|
+
* @param accessToken The Access Token for the request.
|
|
643
|
+
* @param method The HTTP method for the request.
|
|
644
|
+
* @param url Target URL for the request.
|
|
645
|
+
* @param headers Headers for the request.
|
|
646
|
+
* @param body Request body compatible with the Fetch API and the request's method.
|
|
647
|
+
*
|
|
648
|
+
* @see [RFC 6750 - The OAuth 2.0 Authorization Framework: Bearer Token Usage](https://www.rfc-editor.org/rfc/rfc6750.html#section-2.1)
|
|
649
|
+
* @see [draft-ietf-oauth-dpop-10 - OAuth 2.0 Demonstrating Proof-of-Possession at the Application Layer (DPoP)](https://www.ietf.org/archive/id/draft-ietf-oauth-dpop-10.html#name-protected-resource-access)
|
|
650
|
+
*/
|
|
651
|
+
export declare function protectedResourceRequest(accessToken: string, method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | string, url: URL, headers: Headers, body: RequestInit['body'], options?: ProtectedResourceRequestOptions): Promise<Response>;
|
|
652
|
+
export interface UserInfoRequestOptions extends HttpRequestOptions, DPoPRequestOptions {
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Performs a UserInfo Request at the
|
|
656
|
+
* {@link AuthorizationServer.userinfo_endpoint `as.userinfo_endpoint`}.
|
|
657
|
+
*
|
|
658
|
+
* Authorization Header is used to transmit the Access Token value.
|
|
659
|
+
*
|
|
660
|
+
* @param as Authorization Server Metadata.
|
|
661
|
+
* @param client Client Metadata.
|
|
662
|
+
* @param accessToken Access Token value.
|
|
663
|
+
*
|
|
664
|
+
* @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0.html#UserInfo)
|
|
665
|
+
* @see [draft-ietf-oauth-dpop-10 - OAuth 2.0 Demonstrating Proof-of-Possession at the Application Layer (DPoP)](https://www.ietf.org/archive/id/draft-ietf-oauth-dpop-10.html#name-protected-resource-access)
|
|
666
|
+
*/
|
|
667
|
+
export declare function userInfoRequest(as: AuthorizationServer, client: Client, accessToken: string, options?: UserInfoRequestOptions): Promise<Response>;
|
|
668
|
+
export interface UserInfoResponse {
|
|
669
|
+
readonly sub: string;
|
|
670
|
+
readonly name?: string;
|
|
671
|
+
readonly given_name?: string;
|
|
672
|
+
readonly family_name?: string;
|
|
673
|
+
readonly middle_name?: string;
|
|
674
|
+
readonly nickname?: string;
|
|
675
|
+
readonly preferred_username?: string;
|
|
676
|
+
readonly profile?: string;
|
|
677
|
+
readonly picture?: string;
|
|
678
|
+
readonly website?: string;
|
|
679
|
+
readonly email?: string;
|
|
680
|
+
readonly email_verified?: boolean;
|
|
681
|
+
readonly gender?: string;
|
|
682
|
+
readonly birthdate?: string;
|
|
683
|
+
readonly zoneinfo?: string;
|
|
684
|
+
readonly locale?: string;
|
|
685
|
+
readonly phone_number?: string;
|
|
686
|
+
readonly updated_at?: number;
|
|
687
|
+
readonly address?: {
|
|
688
|
+
readonly formatted?: string;
|
|
689
|
+
readonly street_address?: string;
|
|
690
|
+
readonly locality?: string;
|
|
691
|
+
readonly region?: string;
|
|
692
|
+
readonly postal_code?: string;
|
|
693
|
+
readonly country?: string;
|
|
694
|
+
};
|
|
695
|
+
readonly [claim: string]: JsonValue | undefined;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* DANGER ZONE
|
|
699
|
+
*
|
|
700
|
+
* Use this as a value to {@link processUserInfoResponse} `expectedSubject` parameter to skip the
|
|
701
|
+
* `sub` claim value check.
|
|
702
|
+
*
|
|
703
|
+
* @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0.html#UserInfoResponse)
|
|
704
|
+
*/
|
|
705
|
+
export declare const skipSubjectCheck: unique symbol;
|
|
706
|
+
/**
|
|
707
|
+
* Validates Response instance to be one coming from the
|
|
708
|
+
* {@link AuthorizationServer.userinfo_endpoint `as.userinfo_endpoint`}.
|
|
709
|
+
*
|
|
710
|
+
* @param as Authorization Server Metadata.
|
|
711
|
+
* @param client Client Metadata.
|
|
712
|
+
* @param expectedSubject Expected `sub` claim value. In response to OpenID Connect authentication
|
|
713
|
+
* requests, the expected subject is the one from the ID Token claims retrieved from
|
|
714
|
+
* {@link getValidatedIdTokenClaims}.
|
|
715
|
+
* @param response Resolved value from {@link userInfoRequest}.
|
|
716
|
+
*
|
|
717
|
+
* @returns Resolves with an object representing the parsed successful response, or an object
|
|
718
|
+
* representing an OAuth 2.0 protocol style error. Use {@link isOAuth2Error} to determine if an
|
|
719
|
+
* OAuth 2.0 error was returned.
|
|
720
|
+
* @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0.html#UserInfo)
|
|
721
|
+
*/
|
|
722
|
+
export declare function processUserInfoResponse(as: AuthorizationServer, client: Client, expectedSubject: string | typeof skipSubjectCheck, response: Response, options?: HttpRequestOptions): Promise<UserInfoResponse>;
|
|
723
|
+
export interface TokenEndpointRequestOptions extends HttpRequestOptions, AuthenticatedRequestOptions, DPoPRequestOptions {
|
|
724
|
+
/** Any additional parameters to send. This cannot override existing parameter values. */
|
|
725
|
+
additionalParameters?: URLSearchParams;
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* Performs a Refresh Token Grant request at the
|
|
729
|
+
* {@link AuthorizationServer.token_endpoint `as.token_endpoint`}.
|
|
730
|
+
*
|
|
731
|
+
* @param as Authorization Server Metadata.
|
|
732
|
+
* @param client Client Metadata.
|
|
733
|
+
* @param refreshToken Refresh Token value.
|
|
734
|
+
*
|
|
735
|
+
* @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-6)
|
|
736
|
+
* @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0.html#RefreshTokens)
|
|
737
|
+
* @see [draft-ietf-oauth-dpop-10 - OAuth 2.0 Demonstrating Proof-of-Possession at the Application Layer (DPoP)](https://www.ietf.org/archive/id/draft-ietf-oauth-dpop-10.html#name-dpop-access-token-request)
|
|
738
|
+
*/
|
|
739
|
+
export declare function refreshTokenGrantRequest(as: AuthorizationServer, client: Client, refreshToken: string, options?: TokenEndpointRequestOptions): Promise<Response>;
|
|
740
|
+
/**
|
|
741
|
+
* Returns ID Token claims validated during {@link processAuthorizationCodeOpenIDResponse}.
|
|
742
|
+
*
|
|
743
|
+
* @param ref Value previously resolved from {@link processAuthorizationCodeOpenIDResponse}.
|
|
744
|
+
*
|
|
745
|
+
* @returns JWT Claims Set from an ID Token.
|
|
746
|
+
*/
|
|
747
|
+
export declare function getValidatedIdTokenClaims(ref: OpenIDTokenEndpointResponse): IDToken;
|
|
748
|
+
/**
|
|
749
|
+
* Returns ID Token claims validated during {@link processRefreshTokenResponse} or
|
|
750
|
+
* {@link processDeviceCodeResponse}.
|
|
751
|
+
*
|
|
752
|
+
* @param ref Value previously resolved from {@link processRefreshTokenResponse} or
|
|
753
|
+
* {@link processDeviceCodeResponse}.
|
|
754
|
+
*
|
|
755
|
+
* @returns JWT Claims Set from an ID Token, or undefined if there is no ID Token in `ref`.
|
|
756
|
+
*/
|
|
757
|
+
export declare function getValidatedIdTokenClaims(ref: TokenEndpointResponse): IDToken | undefined;
|
|
758
|
+
/**
|
|
759
|
+
* Validates Refresh Token Grant Response instance to be one coming from the
|
|
760
|
+
* {@link AuthorizationServer.token_endpoint `as.token_endpoint`}.
|
|
761
|
+
*
|
|
762
|
+
* @param as Authorization Server Metadata.
|
|
763
|
+
* @param client Client Metadata.
|
|
764
|
+
* @param response Resolved value from {@link refreshTokenGrantRequest}.
|
|
765
|
+
*
|
|
766
|
+
* @returns Resolves with an object representing the parsed successful response, or an object
|
|
767
|
+
* representing an OAuth 2.0 protocol style error. Use {@link isOAuth2Error} to determine if an
|
|
768
|
+
* OAuth 2.0 error was returned.
|
|
769
|
+
* @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-6)
|
|
770
|
+
* @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0.html#RefreshTokens)
|
|
771
|
+
*/
|
|
772
|
+
export declare function processRefreshTokenResponse(as: AuthorizationServer, client: Client, response: Response, options?: HttpRequestOptions): Promise<TokenEndpointResponse | OAuth2Error>;
|
|
773
|
+
/**
|
|
774
|
+
* Performs an Authorization Code grant request at the
|
|
775
|
+
* {@link AuthorizationServer.token_endpoint `as.token_endpoint`}.
|
|
776
|
+
*
|
|
777
|
+
* @param as Authorization Server Metadata.
|
|
778
|
+
* @param client Client Metadata.
|
|
779
|
+
* @param callbackParameters Parameters obtained from the callback to redirect_uri, this is returned
|
|
780
|
+
* from {@link validateAuthResponse}, or {@link validateJwtAuthResponse}.
|
|
781
|
+
* @param redirectUri `redirect_uri` value used in the authorization request.
|
|
782
|
+
* @param codeVerifier PKCE `code_verifier` to send to the token endpoint.
|
|
783
|
+
*
|
|
784
|
+
* @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-4.1)
|
|
785
|
+
* @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth)
|
|
786
|
+
* @see [RFC 7636 - Proof Key for Code Exchange by OAuth Public Clients (PKCE)](https://www.rfc-editor.org/rfc/rfc7636.html#section-4)
|
|
787
|
+
* @see [draft-ietf-oauth-dpop-10 - OAuth 2.0 Demonstrating Proof-of-Possession at the Application Layer (DPoP)](https://www.ietf.org/archive/id/draft-ietf-oauth-dpop-10.html#name-dpop-access-token-request)
|
|
788
|
+
*/
|
|
789
|
+
export declare function authorizationCodeGrantRequest(as: AuthorizationServer, client: Client, callbackParameters: CallbackParameters, redirectUri: string, codeVerifier: string, options?: TokenEndpointRequestOptions): Promise<Response>;
|
|
790
|
+
interface JWTPayload {
|
|
791
|
+
readonly iss?: string;
|
|
792
|
+
readonly sub?: string;
|
|
793
|
+
readonly aud?: string | string[];
|
|
794
|
+
readonly jti?: string;
|
|
795
|
+
readonly nbf?: number;
|
|
796
|
+
readonly exp?: number;
|
|
797
|
+
readonly iat?: number;
|
|
798
|
+
readonly [claim: string]: JsonValue | undefined;
|
|
799
|
+
}
|
|
800
|
+
export interface IDToken extends JWTPayload {
|
|
801
|
+
readonly iss: string;
|
|
802
|
+
readonly sub: string;
|
|
803
|
+
readonly aud: string | string[];
|
|
804
|
+
readonly iat: number;
|
|
805
|
+
readonly exp: number;
|
|
806
|
+
readonly nonce?: string;
|
|
807
|
+
readonly auth_time?: number;
|
|
808
|
+
readonly azp?: string;
|
|
809
|
+
}
|
|
810
|
+
export interface TokenEndpointResponse {
|
|
811
|
+
readonly access_token: string;
|
|
812
|
+
readonly expires_in?: number;
|
|
813
|
+
readonly id_token?: string;
|
|
814
|
+
readonly refresh_token?: string;
|
|
815
|
+
readonly scope?: string;
|
|
816
|
+
/** NOTE: because the value is case insensitive it is always returned lowercased */
|
|
817
|
+
readonly token_type: string;
|
|
818
|
+
readonly [parameter: string]: JsonValue | undefined;
|
|
819
|
+
}
|
|
820
|
+
export interface OpenIDTokenEndpointResponse {
|
|
821
|
+
readonly access_token: string;
|
|
822
|
+
readonly expires_in?: number;
|
|
823
|
+
readonly id_token: string;
|
|
824
|
+
readonly refresh_token?: string;
|
|
825
|
+
readonly scope?: string;
|
|
826
|
+
/** NOTE: because the value is case insensitive it is always returned lowercased */
|
|
827
|
+
readonly token_type: string;
|
|
828
|
+
readonly [parameter: string]: JsonValue | undefined;
|
|
829
|
+
}
|
|
830
|
+
export interface OAuth2TokenEndpointResponse {
|
|
831
|
+
readonly access_token: string;
|
|
832
|
+
readonly expires_in?: number;
|
|
833
|
+
readonly id_token?: undefined;
|
|
834
|
+
readonly refresh_token?: string;
|
|
835
|
+
readonly scope?: string;
|
|
836
|
+
/** NOTE: because the value is case insensitive it is always returned lowercased */
|
|
837
|
+
readonly token_type: string;
|
|
838
|
+
readonly [parameter: string]: JsonValue | undefined;
|
|
839
|
+
}
|
|
840
|
+
export interface ClientCredentialsGrantResponse {
|
|
841
|
+
readonly access_token: string;
|
|
842
|
+
readonly expires_in?: number;
|
|
843
|
+
readonly scope?: string;
|
|
844
|
+
/** NOTE: because the value is case insensitive it is always returned lowercased */
|
|
845
|
+
readonly token_type: string;
|
|
846
|
+
readonly [parameter: string]: JsonValue | undefined;
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Use this as a value to {@link processAuthorizationCodeOpenIDResponse} `expectedNonce` parameter to
|
|
850
|
+
* indicate no `nonce` ID Token claim value is expected, i.e. no `nonce` parameter value was sent
|
|
851
|
+
* with the authorization request.
|
|
852
|
+
*/
|
|
853
|
+
export declare const expectNoNonce: unique symbol;
|
|
854
|
+
/**
|
|
855
|
+
* Use this as a value to {@link processAuthorizationCodeOpenIDResponse} `maxAge` parameter to
|
|
856
|
+
* indicate no `auth_time` ID Token claim value check should be performed.
|
|
857
|
+
*/
|
|
858
|
+
export declare const skipAuthTimeCheck: unique symbol;
|
|
859
|
+
/**
|
|
860
|
+
* (OpenID Connect only) Validates Authorization Code Grant Response instance to be one coming from
|
|
861
|
+
* the {@link AuthorizationServer.token_endpoint `as.token_endpoint`}.
|
|
862
|
+
*
|
|
863
|
+
* @param as Authorization Server Metadata.
|
|
864
|
+
* @param client Client Metadata.
|
|
865
|
+
* @param response Resolved value from {@link authorizationCodeGrantRequest}.
|
|
866
|
+
* @param expectedNonce Expected ID Token `nonce` claim value. Default is {@link expectNoNonce}.
|
|
867
|
+
* @param maxAge ID Token {@link IDToken.auth_time `auth_time`} claim value will be checked to be
|
|
868
|
+
* present and conform to the `maxAge` value. Use of this option is required if you sent a
|
|
869
|
+
* `max_age` parameter in an authorization request. Default is
|
|
870
|
+
* {@link Client.default_max_age `client.default_max_age`} and falls back to
|
|
871
|
+
* {@link skipAuthTimeCheck}.
|
|
872
|
+
*
|
|
873
|
+
* @returns Resolves with an object representing the parsed successful response, or an object
|
|
874
|
+
* representing an OAuth 2.0 protocol style error. Use {@link isOAuth2Error} to determine if an
|
|
875
|
+
* OAuth 2.0 error was returned.
|
|
876
|
+
* @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-4.1)
|
|
877
|
+
* @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth)
|
|
878
|
+
*/
|
|
879
|
+
export declare function processAuthorizationCodeOpenIDResponse(as: AuthorizationServer, client: Client, response: Response, expectedNonce?: string | typeof expectNoNonce, maxAge?: number | typeof skipAuthTimeCheck, options?: HttpRequestOptions): Promise<OpenIDTokenEndpointResponse | OAuth2Error>;
|
|
880
|
+
/**
|
|
881
|
+
* (OAuth 2.0 without OpenID Connect only) Validates Authorization Code Grant Response instance to
|
|
882
|
+
* be one coming from the {@link AuthorizationServer.token_endpoint `as.token_endpoint`}.
|
|
883
|
+
*
|
|
884
|
+
* @param as Authorization Server Metadata.
|
|
885
|
+
* @param client Client Metadata.
|
|
886
|
+
* @param response Resolved value from {@link authorizationCodeGrantRequest}.
|
|
887
|
+
*
|
|
888
|
+
* @returns Resolves with an object representing the parsed successful response, or an object
|
|
889
|
+
* representing an OAuth 2.0 protocol style error. Use {@link isOAuth2Error} to determine if an
|
|
890
|
+
* OAuth 2.0 error was returned.
|
|
891
|
+
* @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-4.1)
|
|
892
|
+
*/
|
|
893
|
+
export declare function processAuthorizationCodeOAuth2Response(as: AuthorizationServer, client: Client, response: Response): Promise<OAuth2TokenEndpointResponse | OAuth2Error>;
|
|
894
|
+
export interface ClientCredentialsGrantRequestOptions extends HttpRequestOptions, AuthenticatedRequestOptions, DPoPRequestOptions {
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Performs a Client Credentials Grant request at the
|
|
898
|
+
* {@link AuthorizationServer.token_endpoint `as.token_endpoint`}.
|
|
899
|
+
*
|
|
900
|
+
* @param as Authorization Server Metadata.
|
|
901
|
+
* @param client Client Metadata.
|
|
902
|
+
*
|
|
903
|
+
* @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-4.4)
|
|
904
|
+
* @see [draft-ietf-oauth-dpop-10 - OAuth 2.0 Demonstrating Proof-of-Possession at the Application Layer (DPoP)](https://www.ietf.org/archive/id/draft-ietf-oauth-dpop-10.html#name-dpop-access-token-request)
|
|
905
|
+
*/
|
|
906
|
+
export declare function clientCredentialsGrantRequest(as: AuthorizationServer, client: Client, parameters: URLSearchParams, options?: ClientCredentialsGrantRequestOptions): Promise<Response>;
|
|
907
|
+
/**
|
|
908
|
+
* Validates Client Credentials Grant Response instance to be one coming from the
|
|
909
|
+
* {@link AuthorizationServer.token_endpoint `as.token_endpoint`}.
|
|
910
|
+
*
|
|
911
|
+
* @param as Authorization Server Metadata.
|
|
912
|
+
* @param client Client Metadata.
|
|
913
|
+
* @param response Resolved value from {@link clientCredentialsGrantRequest}.
|
|
914
|
+
*
|
|
915
|
+
* @returns Resolves with an object representing the parsed successful response, or an object
|
|
916
|
+
* representing an OAuth 2.0 protocol style error. Use {@link isOAuth2Error} to determine if an
|
|
917
|
+
* OAuth 2.0 error was returned.
|
|
918
|
+
* @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-4.4)
|
|
919
|
+
*/
|
|
920
|
+
export declare function processClientCredentialsResponse(as: AuthorizationServer, client: Client, response: Response): Promise<ClientCredentialsGrantResponse | OAuth2Error>;
|
|
921
|
+
export interface RevocationRequestOptions extends HttpRequestOptions, AuthenticatedRequestOptions {
|
|
922
|
+
/** Any additional parameters to send. This cannot override existing parameter values. */
|
|
923
|
+
additionalParameters?: URLSearchParams;
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* Performs a Revocation Request at the
|
|
927
|
+
* {@link AuthorizationServer.revocation_endpoint `as.revocation_endpoint`}.
|
|
928
|
+
*
|
|
929
|
+
* @param as Authorization Server Metadata.
|
|
930
|
+
* @param client Client Metadata.
|
|
931
|
+
* @param token Token to revoke. You can provide the `token_type_hint` parameter via
|
|
932
|
+
* {@link RevocationRequestOptions.additionalParameters options}.
|
|
933
|
+
* @see [RFC 7009 - OAuth 2.0 Token Revocation](https://www.rfc-editor.org/rfc/rfc7009.html#section-2)
|
|
934
|
+
*/
|
|
935
|
+
export declare function revocationRequest(as: AuthorizationServer, client: Client, token: string, options?: RevocationRequestOptions): Promise<Response>;
|
|
936
|
+
/**
|
|
937
|
+
* Validates Response instance to be one coming from the
|
|
938
|
+
* {@link AuthorizationServer.revocation_endpoint `as.revocation_endpoint`}.
|
|
939
|
+
*
|
|
940
|
+
* @param response Resolved value from {@link revocationRequest}.
|
|
941
|
+
*
|
|
942
|
+
* @returns Resolves with `undefined` when the request was successful, or an object representing an
|
|
943
|
+
* OAuth 2.0 protocol style error.
|
|
944
|
+
* @see [RFC 7009 - OAuth 2.0 Token Revocation](https://www.rfc-editor.org/rfc/rfc7009.html#section-2)
|
|
945
|
+
*/
|
|
946
|
+
export declare function processRevocationResponse(response: Response): Promise<undefined | OAuth2Error>;
|
|
947
|
+
export interface IntrospectionRequestOptions extends HttpRequestOptions, AuthenticatedRequestOptions {
|
|
948
|
+
/** Any additional parameters to send. This cannot override existing parameter values. */
|
|
949
|
+
additionalParameters?: URLSearchParams;
|
|
950
|
+
/**
|
|
951
|
+
* Request a JWT Response from the
|
|
952
|
+
* {@link AuthorizationServer.introspection_endpoint `as.introspection_endpoint`}. Default is
|
|
953
|
+
*
|
|
954
|
+
* - True when
|
|
955
|
+
* {@link Client.introspection_signed_response_alg `client.introspection_signed_response_alg`} is
|
|
956
|
+
* set
|
|
957
|
+
* - False otherwise
|
|
958
|
+
*/
|
|
959
|
+
requestJwtResponse?: boolean;
|
|
960
|
+
}
|
|
961
|
+
/**
|
|
962
|
+
* Performs an Introspection Request at the
|
|
963
|
+
* {@link AuthorizationServer.introspection_endpoint `as.introspection_endpoint`}.
|
|
964
|
+
*
|
|
965
|
+
* @param as Authorization Server Metadata.
|
|
966
|
+
* @param client Client Metadata.
|
|
967
|
+
* @param token Token to introspect. You can provide the `token_type_hint` parameter via
|
|
968
|
+
* {@link IntrospectionRequestOptions.additionalParameters options}.
|
|
969
|
+
* @see [RFC 7662 - OAuth 2.0 Token Introspection](https://www.rfc-editor.org/rfc/rfc7662.html#section-2)
|
|
970
|
+
* @see [draft-ietf-oauth-jwt-introspection-response-12 - JWT Response for OAuth Token Introspection](https://www.ietf.org/archive/id/draft-ietf-oauth-jwt-introspection-response-12.html#section-4)
|
|
971
|
+
*/
|
|
972
|
+
export declare function introspectionRequest(as: AuthorizationServer, client: Client, token: string, options?: IntrospectionRequestOptions): Promise<Response>;
|
|
973
|
+
export interface IntrospectionResponse {
|
|
974
|
+
readonly active: boolean;
|
|
975
|
+
readonly client_id?: string;
|
|
976
|
+
readonly exp?: number;
|
|
977
|
+
readonly iat?: number;
|
|
978
|
+
readonly sid?: string;
|
|
979
|
+
readonly iss?: string;
|
|
980
|
+
readonly jti?: string;
|
|
981
|
+
readonly username?: string;
|
|
982
|
+
readonly aud?: string | string[];
|
|
983
|
+
readonly scope: string;
|
|
984
|
+
readonly sub?: string;
|
|
985
|
+
readonly nbf?: number;
|
|
986
|
+
readonly token_type?: string;
|
|
987
|
+
readonly cnf?: {
|
|
988
|
+
readonly 'x5t#S256'?: string;
|
|
989
|
+
readonly jkt?: string;
|
|
990
|
+
readonly [claim: string]: JsonValue | undefined;
|
|
991
|
+
};
|
|
992
|
+
readonly [claim: string]: JsonValue | undefined;
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* Validates Response instance to be one coming from the
|
|
996
|
+
* {@link AuthorizationServer.introspection_endpoint `as.introspection_endpoint`}.
|
|
997
|
+
*
|
|
998
|
+
* @param as Authorization Server Metadata.
|
|
999
|
+
* @param client Client Metadata.
|
|
1000
|
+
* @param response Resolved value from {@link introspectionRequest}.
|
|
1001
|
+
*
|
|
1002
|
+
* @returns Resolves with an object representing the parsed successful response, or an object
|
|
1003
|
+
* representing an OAuth 2.0 protocol style error. Use {@link isOAuth2Error} to determine if an
|
|
1004
|
+
* OAuth 2.0 error was returned.
|
|
1005
|
+
* @see [RFC 7662 - OAuth 2.0 Token Introspection](https://www.rfc-editor.org/rfc/rfc7662.html#section-2)
|
|
1006
|
+
* @see [draft-ietf-oauth-jwt-introspection-response-12 - JWT Response for OAuth Token Introspection](https://www.ietf.org/archive/id/draft-ietf-oauth-jwt-introspection-response-12.html#section-5)
|
|
1007
|
+
*/
|
|
1008
|
+
export declare function processIntrospectionResponse(as: AuthorizationServer, client: Client, response: Response, options?: HttpRequestOptions): Promise<IntrospectionResponse | OAuth2Error>;
|
|
1009
|
+
/** @ignore */
|
|
1010
|
+
export interface JwksRequestOptions extends HttpRequestOptions {
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Performs a request to the {@link AuthorizationServer.jwks_uri `as.jwks_uri`}.
|
|
1014
|
+
*
|
|
1015
|
+
* @ignore
|
|
1016
|
+
*
|
|
1017
|
+
* @param as Authorization Server Metadata.
|
|
1018
|
+
*
|
|
1019
|
+
* @see [JWK Set Format](https://www.rfc-editor.org/rfc/rfc7517.html#section-5)
|
|
1020
|
+
* @see [RFC 8414 - OAuth 2.0 Authorization Server Metadata](https://www.rfc-editor.org/rfc/rfc8414.html#section-3)
|
|
1021
|
+
* @see [OpenID Connect Discovery 1.0](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig)
|
|
1022
|
+
*/
|
|
1023
|
+
export declare function jwksRequest(as: AuthorizationServer, options?: JwksRequestOptions): Promise<Response>;
|
|
1024
|
+
/**
|
|
1025
|
+
* JSON Web Key Set
|
|
1026
|
+
*
|
|
1027
|
+
* @ignore
|
|
1028
|
+
*/
|
|
1029
|
+
export interface JsonWebKeySet {
|
|
1030
|
+
/** Array of JWK Values */
|
|
1031
|
+
readonly keys: JWK[];
|
|
1032
|
+
}
|
|
1033
|
+
/**
|
|
1034
|
+
* Validates Response instance to be one coming from the
|
|
1035
|
+
* {@link AuthorizationServer.jwks_uri `as.jwks_uri`}.
|
|
1036
|
+
*
|
|
1037
|
+
* @ignore
|
|
1038
|
+
*
|
|
1039
|
+
* @param response Resolved value from {@link jwksRequest}.
|
|
1040
|
+
*
|
|
1041
|
+
* @returns Resolves with an object representing the parsed successful response.
|
|
1042
|
+
*
|
|
1043
|
+
* @see [JWK Set Format](https://www.rfc-editor.org/rfc/rfc7517.html#section-5)
|
|
1044
|
+
*/
|
|
1045
|
+
export declare function processJwksResponse(response: Response): Promise<JsonWebKeySet>;
|
|
1046
|
+
/**
|
|
1047
|
+
* Same as {@link validateAuthResponse} but for signed JARM responses.
|
|
1048
|
+
*
|
|
1049
|
+
* @param as Authorization Server Metadata.
|
|
1050
|
+
* @param client Client Metadata.
|
|
1051
|
+
* @param parameters JARM authorization response.
|
|
1052
|
+
* @param expectedState Expected `state` parameter value. Default is {@link expectNoState}.
|
|
1053
|
+
*
|
|
1054
|
+
* @returns Validated Authorization Response parameters or Authorization Error Response.
|
|
1055
|
+
*
|
|
1056
|
+
* @see [openid-financial-api-jarm-ID1 - JWT Secured Authorization Response Mode for OAuth 2.0 (JARM)](https://openid.net/specs/openid-financial-api-jarm-ID1.html)
|
|
1057
|
+
*/
|
|
1058
|
+
export declare function validateJwtAuthResponse(as: AuthorizationServer, client: Client, parameters: URLSearchParams | URL, expectedState?: string | typeof expectNoState | typeof skipStateCheck, options?: HttpRequestOptions): Promise<CallbackParameters | OAuth2Error>;
|
|
1059
|
+
/**
|
|
1060
|
+
* DANGER ZONE
|
|
1061
|
+
*
|
|
1062
|
+
* Use this as a value to {@link validateAuthResponse} `expectedState` parameter to skip the `state`
|
|
1063
|
+
* value check. This should only ever be done if you use a `state` parameter value that is integrity
|
|
1064
|
+
* protected and bound to the browsing session. One such mechanism to do so is described in an I-D
|
|
1065
|
+
* [draft-bradley-oauth-jwt-encoded-state-09](https://datatracker.ietf.org/doc/html/draft-bradley-oauth-jwt-encoded-state-09).
|
|
1066
|
+
* It is expected you'll validate such `state` value yourself.
|
|
1067
|
+
*/
|
|
1068
|
+
export declare const skipStateCheck: unique symbol;
|
|
1069
|
+
/**
|
|
1070
|
+
* Use this as a value to {@link validateAuthResponse} `expectedState` parameter to indicate no
|
|
1071
|
+
* `state` parameter value is expected, i.e. no `state` parameter value was sent with the
|
|
1072
|
+
* authorization request.
|
|
1073
|
+
*/
|
|
1074
|
+
export declare const expectNoState: unique symbol;
|
|
1075
|
+
declare class CallbackParameters extends URLSearchParams {
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* Validates an OAuth 2.0 Authorization Response or Authorization Error Response message returned
|
|
1079
|
+
* from the authorization server's
|
|
1080
|
+
* {@link AuthorizationServer.authorization_endpoint `as.authorization_endpoint`}.
|
|
1081
|
+
*
|
|
1082
|
+
* @param as Authorization Server Metadata.
|
|
1083
|
+
* @param client Client Metadata.
|
|
1084
|
+
* @param parameters Authorization response.
|
|
1085
|
+
* @param expectedState Expected `state` parameter value. Default is {@link expectNoState}.
|
|
1086
|
+
*
|
|
1087
|
+
* @returns Validated Authorization Response parameters or Authorization Error Response.
|
|
1088
|
+
*
|
|
1089
|
+
* @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-4.1.2)
|
|
1090
|
+
* @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0.html#ClientAuthentication)
|
|
1091
|
+
* @see [RFC 9207 - OAuth 2.0 Authorization Server Issuer Identification](https://www.rfc-editor.org/rfc/rfc9207.html)
|
|
1092
|
+
*/
|
|
1093
|
+
export declare function validateAuthResponse(as: AuthorizationServer, client: Client, parameters: URLSearchParams | URL, expectedState?: string | typeof expectNoState | typeof skipStateCheck): CallbackParameters | OAuth2Error;
|
|
1094
|
+
declare type ReturnTypes = TokenEndpointResponse | OAuth2TokenEndpointResponse | OpenIDTokenEndpointResponse | ClientCredentialsGrantResponse | DeviceAuthorizationResponse | IntrospectionResponse | OAuth2Error | PushedAuthorizationResponse | URLSearchParams | UserInfoResponse;
|
|
1095
|
+
export interface DeviceAuthorizationRequestOptions extends HttpRequestOptions, AuthenticatedRequestOptions {
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Performs a Device Authorization Request at the
|
|
1099
|
+
* {@link AuthorizationServer.device_authorization_endpoint `as.device_authorization_endpoint`}.
|
|
1100
|
+
*
|
|
1101
|
+
* @param as Authorization Server Metadata.
|
|
1102
|
+
* @param client Client Metadata.
|
|
1103
|
+
* @param parameters Device Authorization Request parameters.
|
|
1104
|
+
*
|
|
1105
|
+
* @see [RFC 8628 - OAuth 2.0 Device Authorization Grant](https://www.rfc-editor.org/rfc/rfc8628.html#section-3.1)
|
|
1106
|
+
*/
|
|
1107
|
+
export declare function deviceAuthorizationRequest(as: AuthorizationServer, client: Client, parameters: URLSearchParams, options?: DeviceAuthorizationRequestOptions): Promise<Response>;
|
|
1108
|
+
export interface DeviceAuthorizationResponse {
|
|
1109
|
+
readonly device_code: string;
|
|
1110
|
+
readonly user_code: string;
|
|
1111
|
+
readonly verification_uri: string;
|
|
1112
|
+
readonly expires_in: number;
|
|
1113
|
+
readonly verification_uri_complete?: string;
|
|
1114
|
+
readonly interval?: number;
|
|
1115
|
+
readonly [parameter: string]: JsonValue | undefined;
|
|
1116
|
+
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Validates Response instance to be one coming from the
|
|
1119
|
+
* {@link AuthorizationServer.device_authorization_endpoint `as.device_authorization_endpoint`}.
|
|
1120
|
+
*
|
|
1121
|
+
* @param as Authorization Server Metadata.
|
|
1122
|
+
* @param client Client Metadata.
|
|
1123
|
+
* @param response Resolved value from {@link deviceAuthorizationRequest}.
|
|
1124
|
+
*
|
|
1125
|
+
* @returns Resolves with an object representing the parsed successful response, or an object
|
|
1126
|
+
* representing an OAuth 2.0 protocol style error. Use {@link isOAuth2Error} to determine if an
|
|
1127
|
+
* OAuth 2.0 error was returned.
|
|
1128
|
+
* @see [RFC 8628 - OAuth 2.0 Device Authorization Grant](https://www.rfc-editor.org/rfc/rfc8628.html#section-3.1)
|
|
1129
|
+
*/
|
|
1130
|
+
export declare function processDeviceAuthorizationResponse(as: AuthorizationServer, client: Client, response: Response): Promise<DeviceAuthorizationResponse | OAuth2Error>;
|
|
1131
|
+
/**
|
|
1132
|
+
* Performs a Device Authorization Grant request at the
|
|
1133
|
+
* {@link AuthorizationServer.token_endpoint `as.token_endpoint`}.
|
|
1134
|
+
*
|
|
1135
|
+
* @param as Authorization Server Metadata.
|
|
1136
|
+
* @param client Client Metadata.
|
|
1137
|
+
* @param deviceCode Device Code.
|
|
1138
|
+
*
|
|
1139
|
+
* @see [RFC 8628 - OAuth 2.0 Device Authorization Grant](https://www.rfc-editor.org/rfc/rfc8628.html#section-3.4)
|
|
1140
|
+
* @see [draft-ietf-oauth-dpop-10 - OAuth 2.0 Demonstrating Proof-of-Possession at the Application Layer (DPoP)](https://www.ietf.org/archive/id/draft-ietf-oauth-dpop-10.html#name-dpop-access-token-request)
|
|
1141
|
+
*/
|
|
1142
|
+
export declare function deviceCodeGrantRequest(as: AuthorizationServer, client: Client, deviceCode: string, options?: TokenEndpointRequestOptions): Promise<Response>;
|
|
1143
|
+
/**
|
|
1144
|
+
* Validates Device Authorization Grant Response instance to be one coming from the
|
|
1145
|
+
* {@link AuthorizationServer.token_endpoint `as.token_endpoint`}.
|
|
1146
|
+
*
|
|
1147
|
+
* @param as Authorization Server Metadata.
|
|
1148
|
+
* @param client Client Metadata.
|
|
1149
|
+
* @param response Resolved value from {@link deviceCodeGrantRequest}.
|
|
1150
|
+
*
|
|
1151
|
+
* @returns Resolves with an object representing the parsed successful response, or an object
|
|
1152
|
+
* representing an OAuth 2.0 protocol style error. Use {@link isOAuth2Error} to determine if an
|
|
1153
|
+
* OAuth 2.0 error was returned.
|
|
1154
|
+
* @see [RFC 8628 - OAuth 2.0 Device Authorization Grant](https://www.rfc-editor.org/rfc/rfc8628.html#section-3.4)
|
|
1155
|
+
*/
|
|
1156
|
+
export declare function processDeviceCodeResponse(as: AuthorizationServer, client: Client, response: Response, options?: HttpRequestOptions): Promise<TokenEndpointResponse | OAuth2Error>;
|
|
1157
|
+
export interface GenerateKeyPairOptions {
|
|
1158
|
+
/** Indicates whether or not the private key may be exported. Default is `false`. */
|
|
1159
|
+
extractable?: boolean;
|
|
1160
|
+
/** (RSA algorithms only) The length, in bits, of the RSA modulus. Default is `2048`. */
|
|
1161
|
+
modulusLength?: number;
|
|
1162
|
+
}
|
|
1163
|
+
/**
|
|
1164
|
+
* Generates a CryptoKeyPair for a given JWS `alg` Algorithm identifier.
|
|
1165
|
+
*
|
|
1166
|
+
* @param alg Supported JWS `alg` Algorithm identifier.
|
|
1167
|
+
*/
|
|
1168
|
+
export declare function generateKeyPair(alg: JWSAlgorithm, options?: GenerateKeyPairOptions): Promise<CryptoKeyPair>;
|
|
1169
|
+
/**
|
|
1170
|
+
* Calculates a base64url-encoded SHA-256 JWK Thumbprint.
|
|
1171
|
+
*
|
|
1172
|
+
* @ignore
|
|
1173
|
+
*
|
|
1174
|
+
* @param key A public extractable CryptoKey.
|
|
1175
|
+
*
|
|
1176
|
+
* @see [RFC 7638 - JSON Web Key (JWK) Thumbprint](https://www.rfc-editor.org/rfc/rfc7638.html)
|
|
1177
|
+
*/
|
|
1178
|
+
export declare function calculateJwkThumbprint(key: CryptoKey): Promise<string>;
|
|
1179
|
+
export {};
|