oauth4webapi 2.8.1 → 2.9.0

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/README.md CHANGED
@@ -44,7 +44,7 @@ import * as oauth2 from 'oauth4webapi'
44
44
  **`example`** Deno import
45
45
 
46
46
  ```js
47
- import * as oauth2 from 'https://deno.land/x/oauth4webapi@v2.8.1/mod.ts'
47
+ import * as oauth2 from 'https://deno.land/x/oauth4webapi@v2.9.0/mod.ts'
48
48
  ```
49
49
 
50
50
  - Authorization Code Flow - OpenID Connect [source](examples/code.ts), or plain OAuth 2 [source](examples/oauth.ts)
package/build/index.d.ts CHANGED
@@ -1,12 +1,20 @@
1
- /** JSON Object */
1
+ /**
2
+ * JSON Object
3
+ */
2
4
  export type JsonObject = {
3
5
  [Key in string]?: JsonValue;
4
6
  };
5
- /** JSON Array */
7
+ /**
8
+ * JSON Array
9
+ */
6
10
  export type JsonArray = JsonValue[];
7
- /** JSON Primitives */
11
+ /**
12
+ * JSON Primitives
13
+ */
8
14
  export type JsonPrimitive = string | number | boolean | null;
9
- /** JSON Values */
15
+ /**
16
+ * JSON Values
17
+ */
10
18
  export type JsonValue = JsonPrimitive | JsonObject | JsonArray;
11
19
  /**
12
20
  * Interface to pass an asymmetric private key and, optionally, its associated JWK Key ID to be
@@ -130,9 +138,6 @@ export type JWSAlgorithm = 'PS256' | 'ES256' | 'RS256' | 'EdDSA' | 'ES384' | 'PS
130
138
  export declare const clockSkew: unique symbol;
131
139
  export declare const clockTolerance: unique symbol;
132
140
  /**
133
- * This is an experimental feature, it is not subject to semantic versioning rules. Non-backward
134
- * compatible changes or removal may occur in any future release.
135
- *
136
141
  * When configured on an interface that extends {@link HttpRequestOptions}, that's every `options`
137
142
  * parameter for functions that trigger HTTP Requests, this replaces the use of global fetch. As a
138
143
  * fetch replacement the arguments and expected return are the same as fetch.
@@ -169,7 +174,7 @@ export declare const clockTolerance: unique symbol;
169
174
  *
170
175
  * // example use
171
176
  * await oauth.discoveryRequest(new URL('https://as.example.com'), {
172
- * [oauth.experimental_customFetch]: (...args) =>
177
+ * [oauth.customFetch]: (...args) =>
173
178
  * ky(args[0], {
174
179
  * ...args[1],
175
180
  * hooks: {
@@ -210,26 +215,19 @@ export declare const clockTolerance: unique symbol;
210
215
  *
211
216
  * // example use
212
217
  * await oauth.discoveryRequest(new URL('https://as.example.com'), {
213
- * [oauth.experimental_customFetch]: undici.fetch,
218
+ * [oauth.customFetch]: undici.fetch,
214
219
  * })
215
220
  * ```
216
- *
217
- * @group Experimental
218
221
  */
219
- export declare const experimental_customFetch: unique symbol;
220
- /** @ignore */
221
- export declare const experimentalCustomFetch: symbol;
222
+ export declare const customFetch: unique symbol;
222
223
  /**
223
- * This is an experimental feature, it is not subject to semantic versioning rules. Non-backward
224
- * compatible changes or removal may occur in any future release.
225
- *
226
- * When combined with {@link experimental_customFetch} (to use a Fetch API implementation that
227
- * supports client certificates) this can be used to target FAPI 2.0 profiles that utilize
228
- * Mutual-TLS for either client authentication or sender constraining. FAPI 1.0 Advanced profiles
229
- * that use PAR and JARM can also be targetted.
224
+ * When combined with {@link customFetch} (to use a Fetch API implementation that supports client
225
+ * certificates) this can be used to target FAPI 2.0 profiles that utilize Mutual-TLS for either
226
+ * client authentication or sender constraining. FAPI 1.0 Advanced profiles that use PAR and JARM
227
+ * can also be targetted.
230
228
  *
231
- * When configured on an interface that extends {@link ExperimentalUseMTLSAliasOptions} this makes
232
- * the client prioritize an endpoint URL present in
229
+ * When configured on an interface that extends {@link UseMTLSAliasOptions} this makes the client
230
+ * prioritize an endpoint URL present in
233
231
  * {@link AuthorizationServer.mtls_endpoint_aliases `as.mtls_endpoint_aliases`}.
234
232
  *
235
233
  * @example
@@ -242,8 +240,8 @@ export declare const experimentalCustomFetch: symbol;
242
240
  * import * as oauth from 'oauth4webapi'
243
241
  *
244
242
  * const response = await oauth.pushedAuthorizationRequest(as, client, params, {
245
- * [oauth.experimental_useMtlsAlias]: true,
246
- * [oauth.experimental_customFetch]: (...args) => {
243
+ * [oauth.useMtlsAlias]: true,
244
+ * [oauth.customFetch]: (...args) => {
247
245
  * return undici.fetch(args[0], {
248
246
  * ...args[1],
249
247
  * dispatcher: new undici.Agent({
@@ -272,8 +270,8 @@ export declare const experimentalCustomFetch: symbol;
272
270
  * })
273
271
  *
274
272
  * const response = await oauth.pushedAuthorizationRequest(as, client, params, {
275
- * [oauth.experimental_useMtlsAlias]: true,
276
- * [oauth.experimental_customFetch]: (...args) => {
273
+ * [oauth.useMtlsAlias]: true,
274
+ * [oauth.customFetch]: (...args) => {
277
275
  * return fetch(args[0], {
278
276
  * ...args[1],
279
277
  * client: agent,
@@ -282,30 +280,38 @@ export declare const experimentalCustomFetch: symbol;
282
280
  * })
283
281
  * ```
284
282
  *
285
- * @group Experimental
286
- *
287
283
  * @see [RFC 8705 - OAuth 2.0 Mutual-TLS Client Authentication and Certificate-Bound Access Tokens](https://www.rfc-editor.org/rfc/rfc8705.html)
288
284
  */
289
- export declare const experimental_useMtlsAlias: unique symbol;
290
- /** @ignore */
291
- export declare const experimentalUseMtlsAlias: symbol;
285
+ export declare const useMtlsAlias: unique symbol;
292
286
  /**
293
287
  * Authorization Server Metadata
294
288
  *
295
289
  * @see [IANA OAuth Authorization Server Metadata registry](https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#authorization-server-metadata)
296
290
  */
297
291
  export interface AuthorizationServer {
298
- /** Authorization server's Issuer Identifier URL. */
292
+ /**
293
+ * Authorization server's Issuer Identifier URL.
294
+ */
299
295
  readonly issuer: string;
300
- /** URL of the authorization server's authorization endpoint. */
296
+ /**
297
+ * URL of the authorization server's authorization endpoint.
298
+ */
301
299
  readonly authorization_endpoint?: string;
302
- /** URL of the authorization server's token endpoint. */
300
+ /**
301
+ * URL of the authorization server's token endpoint.
302
+ */
303
303
  readonly token_endpoint?: string;
304
- /** URL of the authorization server's JWK Set document. */
304
+ /**
305
+ * URL of the authorization server's JWK Set document.
306
+ */
305
307
  readonly jwks_uri?: string;
306
- /** URL of the authorization server's Dynamic Client Registration Endpoint. */
308
+ /**
309
+ * URL of the authorization server's Dynamic Client Registration Endpoint.
310
+ */
307
311
  readonly registration_endpoint?: string;
308
- /** JSON array containing a list of the `scope` values that this authorization server supports. */
312
+ /**
313
+ * JSON array containing a list of the `scope` values that this authorization server supports.
314
+ */
309
315
  readonly scopes_supported?: string[];
310
316
  /**
311
317
  * JSON array containing a list of the `response_type` values that this authorization server
@@ -322,7 +328,9 @@ export interface AuthorizationServer {
322
328
  * supports.
323
329
  */
324
330
  readonly grant_types_supported?: string[];
325
- /** JSON array containing a list of client authentication methods supported by this token endpoint. */
331
+ /**
332
+ * JSON array containing a list of client authentication methods supported by this token endpoint.
333
+ */
326
334
  readonly token_endpoint_auth_methods_supported?: string[];
327
335
  /**
328
336
  * JSON array containing a list of the JWS signing algorithms supported by the token endpoint for
@@ -350,7 +358,9 @@ export interface AuthorizationServer {
350
358
  * the authorization server's terms of service.
351
359
  */
352
360
  readonly op_tos_uri?: string;
353
- /** URL of the authorization server's revocation endpoint. */
361
+ /**
362
+ * URL of the authorization server's revocation endpoint.
363
+ */
354
364
  readonly revocation_endpoint?: string;
355
365
  /**
356
366
  * JSON array containing a list of client authentication methods supported by this revocation
@@ -362,7 +372,9 @@ export interface AuthorizationServer {
362
372
  * for the signature on the JWT used to authenticate the client at the revocation endpoint.
363
373
  */
364
374
  readonly revocation_endpoint_auth_signing_alg_values_supported?: string[];
365
- /** URL of the authorization server's introspection endpoint. */
375
+ /**
376
+ * URL of the authorization server's introspection endpoint.
377
+ */
366
378
  readonly introspection_endpoint?: string;
367
379
  /**
368
380
  * JSON array containing a list of client authentication methods supported by this introspection
@@ -375,20 +387,30 @@ export interface AuthorizationServer {
375
387
  * endpoint.
376
388
  */
377
389
  readonly introspection_endpoint_auth_signing_alg_values_supported?: string[];
378
- /** PKCE code challenge methods supported by this authorization server. */
390
+ /**
391
+ * PKCE code challenge methods supported by this authorization server.
392
+ */
379
393
  readonly code_challenge_methods_supported?: string[];
380
- /** Signed JWT containing metadata values about the authorization server as claims. */
394
+ /**
395
+ * Signed JWT containing metadata values about the authorization server as claims.
396
+ */
381
397
  readonly signed_metadata?: string;
382
- /** URL of the authorization server's device authorization endpoint. */
398
+ /**
399
+ * URL of the authorization server's device authorization endpoint.
400
+ */
383
401
  readonly device_authorization_endpoint?: string;
384
- /** Indicates authorization server support for mutual-TLS client certificate-bound access tokens. */
402
+ /**
403
+ * Indicates authorization server support for mutual-TLS client certificate-bound access tokens.
404
+ */
385
405
  readonly tls_client_certificate_bound_access_tokens?: boolean;
386
406
  /**
387
407
  * JSON object containing alternative authorization server endpoints, which a client intending to
388
408
  * do mutual TLS will use in preference to the conventional endpoints.
389
409
  */
390
410
  readonly mtls_endpoint_aliases?: MTLSEndpointAliases;
391
- /** URL of the authorization server's UserInfo Endpoint. */
411
+ /**
412
+ * URL of the authorization server's UserInfo Endpoint.
413
+ */
392
414
  readonly userinfo_endpoint?: string;
393
415
  /**
394
416
  * JSON array containing a list of the Authentication Context Class References that this
@@ -415,11 +437,17 @@ export interface AuthorizationServer {
415
437
  * the ID Token.
416
438
  */
417
439
  readonly id_token_encryption_enc_values_supported?: string[];
418
- /** JSON array containing a list of the JWS `alg` values supported by the UserInfo Endpoint. */
440
+ /**
441
+ * JSON array containing a list of the JWS `alg` values supported by the UserInfo Endpoint.
442
+ */
419
443
  readonly userinfo_signing_alg_values_supported?: string[];
420
- /** JSON array containing a list of the JWE `alg` values supported by the UserInfo Endpoint. */
444
+ /**
445
+ * JSON array containing a list of the JWE `alg` values supported by the UserInfo Endpoint.
446
+ */
421
447
  readonly userinfo_encryption_alg_values_supported?: string[];
422
- /** JSON array containing a list of the JWE `enc` values supported by the UserInfo Endpoint. */
448
+ /**
449
+ * JSON array containing a list of the JWE `enc` values supported by the UserInfo Endpoint.
450
+ */
423
451
  readonly userinfo_encryption_enc_values_supported?: string[];
424
452
  /**
425
453
  * JSON array containing a list of the JWS `alg` values supported by the authorization server for
@@ -441,7 +469,9 @@ export interface AuthorizationServer {
441
469
  * supports.
442
470
  */
443
471
  readonly display_values_supported?: string[];
444
- /** JSON array containing a list of the Claim Types that the authorization server supports. */
472
+ /**
473
+ * JSON array containing a list of the Claim Types that the authorization server supports.
474
+ */
445
475
  readonly claim_types_supported?: string[];
446
476
  /**
447
477
  * JSON array containing a list of the Claim Names of the Claims that the authorization server MAY
@@ -478,9 +508,13 @@ export interface AuthorizationServer {
478
508
  * through either `request` or `request_uri` parameter.
479
509
  */
480
510
  readonly require_signed_request_object?: boolean;
481
- /** URL of the authorization server's pushed authorization request endpoint. */
511
+ /**
512
+ * URL of the authorization server's pushed authorization request endpoint.
513
+ */
482
514
  readonly pushed_authorization_request_endpoint?: string;
483
- /** Indicates whether the authorization server accepts authorization requests only via PAR. */
515
+ /**
516
+ * Indicates whether the authorization server accepts authorization requests only via PAR.
517
+ */
484
518
  readonly require_pushed_authorization_requests?: boolean;
485
519
  /**
486
520
  * JSON array containing a list of algorithms supported by the authorization server for
@@ -517,23 +551,31 @@ export interface AuthorizationServer {
517
551
  * introspection response encryption (`enc` value).
518
552
  */
519
553
  readonly authorization_encryption_enc_values_supported?: string[];
520
- /** CIBA Backchannel Authentication Endpoint. */
554
+ /**
555
+ * CIBA Backchannel Authentication Endpoint.
556
+ */
521
557
  readonly backchannel_authentication_endpoint?: string;
522
558
  /**
523
559
  * JSON array containing a list of the JWS signing algorithms supported for validation of signed
524
560
  * CIBA authentication requests.
525
561
  */
526
562
  readonly backchannel_authentication_request_signing_alg_values_supported?: string[];
527
- /** Supported CIBA authentication result delivery modes. */
563
+ /**
564
+ * Supported CIBA authentication result delivery modes.
565
+ */
528
566
  readonly backchannel_token_delivery_modes_supported?: string[];
529
- /** Indicates whether the authorization server supports the use of the CIBA `user_code` parameter. */
567
+ /**
568
+ * Indicates whether the authorization server supports the use of the CIBA `user_code` parameter.
569
+ */
530
570
  readonly backchannel_user_code_parameter_supported?: boolean;
531
571
  /**
532
572
  * URL of an authorization server iframe that supports cross-origin communications for session
533
573
  * state information with the RP Client, using the HTML5 postMessage API.
534
574
  */
535
575
  readonly check_session_iframe?: string;
536
- /** JSON array containing a list of the JWS algorithms supported for DPoP proof JWTs. */
576
+ /**
577
+ * JSON array containing a list of the JWS algorithms supported for DPoP proof JWTs.
578
+ */
537
579
  readonly dpop_signing_alg_values_supported?: string[];
538
580
  /**
539
581
  * URL at the authorization server to which an RP can perform a redirect to request that the
@@ -546,14 +588,18 @@ export interface AuthorizationServer {
546
588
  * `frontchannel_logout_uri` is used.
547
589
  */
548
590
  readonly frontchannel_logout_session_supported?: boolean;
549
- /** Boolean value specifying whether the authorization server supports HTTP-based logout. */
591
+ /**
592
+ * Boolean value specifying whether the authorization server supports HTTP-based logout.
593
+ */
550
594
  readonly frontchannel_logout_supported?: boolean;
551
595
  /**
552
596
  * Boolean value specifying whether the authorization server can pass a `sid` (session ID) Claim
553
597
  * in the Logout Token to identify the RP session with the OP.
554
598
  */
555
599
  readonly backchannel_logout_session_supported?: boolean;
556
- /** Boolean value specifying whether the authorization server supports back-channel logout. */
600
+ /**
601
+ * Boolean value specifying whether the authorization server supports back-channel logout.
602
+ */
557
603
  readonly backchannel_logout_supported?: boolean;
558
604
  readonly [metadata: string]: JsonValue | undefined;
559
605
  }
@@ -566,9 +612,13 @@ export interface MTLSEndpointAliases extends Pick<AuthorizationServer, 'token_en
566
612
  * @see [IANA OAuth Client Registration Metadata registry](https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#client-metadata)
567
613
  */
568
614
  export interface Client {
569
- /** Client identifier. */
615
+ /**
616
+ * Client identifier.
617
+ */
570
618
  client_id: string;
571
- /** Client secret. */
619
+ /**
620
+ * Client secret.
621
+ */
572
622
  client_secret?: string;
573
623
  /**
574
624
  * Client {@link ClientAuthenticationMethod authentication method} for the client's authenticated
@@ -608,7 +658,9 @@ export interface Client {
608
658
  * and fall back to `RS256` when the authorization server metadata is not set.
609
659
  */
610
660
  introspection_signed_response_alg?: string;
611
- /** Default Maximum Authentication Age. */
661
+ /**
662
+ * Default Maximum Authentication Age.
663
+ */
612
664
  default_max_age?: number;
613
665
  /**
614
666
  * Use to adjust the client's assumed current time. Positive and negative finite values
@@ -658,11 +710,15 @@ export interface Client {
658
710
  [clockTolerance]?: number;
659
711
  [metadata: string]: JsonValue | undefined;
660
712
  }
661
- /** @group Errors */
713
+ /**
714
+ * @group Errors
715
+ */
662
716
  export declare class UnsupportedOperationError extends Error {
663
717
  constructor(message?: string);
664
718
  }
665
- /** @group Errors */
719
+ /**
720
+ * @group Errors
721
+ */
666
722
  export declare class OperationProcessingError extends Error {
667
723
  constructor(message: string, options?: {
668
724
  cause?: unknown;
@@ -682,20 +738,19 @@ export interface HttpRequestOptions {
682
738
  * ```
683
739
  */
684
740
  signal?: (() => AbortSignal) | AbortSignal;
685
- /** Headers to additionally send with the HTTP Request(s) triggered by this function's invocation. */
741
+ /**
742
+ * Headers to additionally send with the HTTP Request(s) triggered by this function's invocation.
743
+ */
686
744
  headers?: [string, string][] | Record<string, string> | Headers;
687
745
  /**
688
- * This is an experimental feature, it is not subject to semantic versioning rules. Non-backward
689
- * compatible changes or removal may occur in any future release.
690
- *
691
- * See {@link experimental_customFetch} for its documentation.
692
- *
693
- * @group Experimental
746
+ * See {@link customFetch}.
694
747
  */
695
- [experimental_customFetch]?: typeof fetch;
748
+ [customFetch]?: typeof fetch;
696
749
  }
697
750
  export interface DiscoveryRequestOptions extends HttpRequestOptions {
698
- /** The issuer transformation algorithm to use. */
751
+ /**
752
+ * The issuer transformation algorithm to use.
753
+ */
699
754
  algorithm?: 'oidc' | 'oauth2';
700
755
  }
701
756
  /**
@@ -737,9 +792,9 @@ export declare function processDiscoveryResponse(expectedIssuerIdentifier: URL,
737
792
  * @group Utilities
738
793
  * @group Authorization Code Grant
739
794
  * @group Authorization Code Grant w/ OpenID Connect (OIDC)
740
- * @group Proof Key for Code Exchange by OAuth Public Clients (PKCE)
795
+ * @group Proof Key for Code Exchange (PKCE)
741
796
  *
742
- * @see [RFC 7636 - Proof Key for Code Exchange by OAuth Public Clients (PKCE)](https://www.rfc-editor.org/rfc/rfc7636.html#section-4)
797
+ * @see [RFC 7636 - Proof Key for Code Exchange (PKCE)](https://www.rfc-editor.org/rfc/rfc7636.html#section-4)
743
798
  */
744
799
  export declare function generateRandomCodeVerifier(): string;
745
800
  /**
@@ -766,9 +821,9 @@ export declare function generateRandomNonce(): string;
766
821
  *
767
822
  * @group Authorization Code Grant
768
823
  * @group Authorization Code Grant w/ OpenID Connect (OIDC)
769
- * @group Proof Key for Code Exchange by OAuth Public Clients (PKCE)
824
+ * @group Proof Key for Code Exchange (PKCE)
770
825
  *
771
- * @see [RFC 7636 - Proof Key for Code Exchange by OAuth Public Clients (PKCE)](https://www.rfc-editor.org/rfc/rfc7636.html#section-4)
826
+ * @see [RFC 7636 - Proof Key for Code Exchange (PKCE)](https://www.rfc-editor.org/rfc/rfc7636.html#section-4)
772
827
  */
773
828
  export declare function calculatePKCECodeChallenge(codeVerifier: string): Promise<string>;
774
829
  export interface DPoPOptions extends CryptoKeyPair {
@@ -778,7 +833,9 @@ export interface DPoPOptions extends CryptoKeyPair {
778
833
  * Its algorithm must be compatible with a supported {@link JWSAlgorithm JWS `alg` Algorithm}.
779
834
  */
780
835
  privateKey: CryptoKey;
781
- /** The public key corresponding to {@link DPoPOptions.privateKey}. */
836
+ /**
837
+ * The public key corresponding to {@link DPoPOptions.privateKey}.
838
+ */
782
839
  publicKey: CryptoKey;
783
840
  /**
784
841
  * Server-Provided Nonce to use in the request. This option serves as an override in case the
@@ -788,21 +845,18 @@ export interface DPoPOptions extends CryptoKeyPair {
788
845
  nonce?: string;
789
846
  }
790
847
  export interface DPoPRequestOptions {
791
- /** DPoP-related options. */
848
+ /**
849
+ * DPoP-related options.
850
+ */
792
851
  DPoP?: DPoPOptions;
793
852
  }
794
- export interface ExperimentalUseMTLSAliasOptions {
853
+ export interface UseMTLSAliasOptions {
795
854
  /**
796
- * This is an experimental feature, it is not subject to semantic versioning rules. Non-backward
797
- * compatible changes or removal may occur in any future release.
798
- *
799
- * See {@link experimental_useMtlsAlias} for its documentation.
800
- *
801
- * @group Experimental
855
+ * See {@link useMtlsAlias}.
802
856
  */
803
- [experimental_useMtlsAlias]?: boolean;
857
+ [useMtlsAlias]?: boolean;
804
858
  }
805
- export interface AuthenticatedRequestOptions extends ExperimentalUseMTLSAliasOptions {
859
+ export interface AuthenticatedRequestOptions extends UseMTLSAliasOptions {
806
860
  /**
807
861
  * Private key to use for `private_key_jwt`
808
862
  * {@link ClientAuthenticationMethod client authentication}. Its algorithm must be compatible with
@@ -874,11 +928,15 @@ export interface WWWAuthenticateChallengeParameters {
874
928
  readonly error_uri?: string;
875
929
  readonly algs?: string;
876
930
  readonly scope?: string;
877
- /** NOTE: because the parameter names are case insensitive they are always returned lowercased */
931
+ /**
932
+ * NOTE: because the parameter names are case insensitive they are always returned lowercased
933
+ */
878
934
  readonly [parameter: Lowercase<string>]: string | undefined;
879
935
  }
880
936
  export interface WWWAuthenticateChallenge {
881
- /** NOTE: because the value is case insensitive it is always returned lowercased */
937
+ /**
938
+ * NOTE: because the value is case insensitive it is always returned lowercased
939
+ */
882
940
  readonly scheme: Lowercase<string>;
883
941
  readonly parameters: WWWAuthenticateChallengeParameters;
884
942
  }
@@ -944,7 +1002,7 @@ export interface ProtectedResourceRequestOptions extends Omit<HttpRequestOptions
944
1002
  * @see [RFC 9449 - OAuth 2.0 Demonstrating Proof-of-Possession at the Application Layer (DPoP)](https://www.rfc-editor.org/rfc/rfc9449.html#name-protected-resource-access)
945
1003
  */
946
1004
  export declare function protectedResourceRequest(accessToken: string, method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | string, url: URL, headers: Headers, body?: ReadableStream | Blob | ArrayBufferView | ArrayBuffer | FormData | URLSearchParams | string | null, options?: ProtectedResourceRequestOptions): Promise<Response>;
947
- export interface UserInfoRequestOptions extends HttpRequestOptions, DPoPRequestOptions, ExperimentalUseMTLSAliasOptions {
1005
+ export interface UserInfoRequestOptions extends HttpRequestOptions, DPoPRequestOptions, UseMTLSAliasOptions {
948
1006
  }
949
1007
  /**
950
1008
  * Performs a UserInfo Request at the
@@ -1025,7 +1083,9 @@ export declare const skipSubjectCheck: unique symbol;
1025
1083
  */
1026
1084
  export declare function processUserInfoResponse(as: AuthorizationServer, client: Client, expectedSubject: string | typeof skipSubjectCheck, response: Response): Promise<UserInfoResponse>;
1027
1085
  export interface TokenEndpointRequestOptions extends HttpRequestOptions, AuthenticatedRequestOptions, DPoPRequestOptions {
1028
- /** Any additional parameters to send. This cannot override existing parameter values. */
1086
+ /**
1087
+ * Any additional parameters to send. This cannot override existing parameter values.
1088
+ */
1029
1089
  additionalParameters?: URLSearchParams | Record<string, string> | string[][];
1030
1090
  }
1031
1091
  /**
@@ -1097,7 +1157,7 @@ export declare function processRefreshTokenResponse(as: AuthorizationServer, cli
1097
1157
  *
1098
1158
  * @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-4.1)
1099
1159
  * @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth)
1100
- * @see [RFC 7636 - Proof Key for Code Exchange by OAuth Public Clients (PKCE)](https://www.rfc-editor.org/rfc/rfc7636.html#section-4)
1160
+ * @see [RFC 7636 - Proof Key for Code Exchange (PKCE)](https://www.rfc-editor.org/rfc/rfc7636.html#section-4)
1101
1161
  * @see [RFC 9449 - OAuth 2.0 Demonstrating Proof-of-Possession at the Application Layer (DPoP)](https://www.rfc-editor.org/rfc/rfc9449.html#name-dpop-access-token-request)
1102
1162
  */
1103
1163
  export declare function authorizationCodeGrantRequest(as: AuthorizationServer, client: Client, callbackParameters: URLSearchParams, redirectUri: string, codeVerifier: string, options?: TokenEndpointRequestOptions): Promise<Response>;
@@ -1129,7 +1189,9 @@ export interface TokenEndpointResponse {
1129
1189
  readonly id_token?: string;
1130
1190
  readonly refresh_token?: string;
1131
1191
  readonly scope?: string;
1132
- /** NOTE: because the value is case insensitive it is always returned lowercased */
1192
+ /**
1193
+ * NOTE: because the value is case insensitive it is always returned lowercased
1194
+ */
1133
1195
  readonly token_type: 'bearer' | 'dpop' | Lowercase<string>;
1134
1196
  readonly [parameter: string]: JsonValue | undefined;
1135
1197
  }
@@ -1139,7 +1201,9 @@ export interface OpenIDTokenEndpointResponse {
1139
1201
  readonly id_token: string;
1140
1202
  readonly refresh_token?: string;
1141
1203
  readonly scope?: string;
1142
- /** NOTE: because the value is case insensitive it is always returned lowercased */
1204
+ /**
1205
+ * NOTE: because the value is case insensitive it is always returned lowercased
1206
+ */
1143
1207
  readonly token_type: 'bearer' | 'dpop' | Lowercase<string>;
1144
1208
  readonly [parameter: string]: JsonValue | undefined;
1145
1209
  }
@@ -1149,7 +1213,9 @@ export interface OAuth2TokenEndpointResponse {
1149
1213
  readonly id_token?: undefined;
1150
1214
  readonly refresh_token?: string;
1151
1215
  readonly scope?: string;
1152
- /** NOTE: because the value is case insensitive it is always returned lowercased */
1216
+ /**
1217
+ * NOTE: because the value is case insensitive it is always returned lowercased
1218
+ */
1153
1219
  readonly token_type: 'bearer' | 'dpop' | Lowercase<string>;
1154
1220
  readonly [parameter: string]: JsonValue | undefined;
1155
1221
  }
@@ -1157,7 +1223,9 @@ export interface ClientCredentialsGrantResponse {
1157
1223
  readonly access_token: string;
1158
1224
  readonly expires_in?: number;
1159
1225
  readonly scope?: string;
1160
- /** NOTE: because the value is case insensitive it is always returned lowercased */
1226
+ /**
1227
+ * NOTE: because the value is case insensitive it is always returned lowercased
1228
+ */
1161
1229
  readonly token_type: 'bearer' | 'dpop' | Lowercase<string>;
1162
1230
  readonly [parameter: string]: JsonValue | undefined;
1163
1231
  }
@@ -1246,7 +1314,9 @@ export declare function clientCredentialsGrantRequest(as: AuthorizationServer, c
1246
1314
  */
1247
1315
  export declare function processClientCredentialsResponse(as: AuthorizationServer, client: Client, response: Response): Promise<ClientCredentialsGrantResponse | OAuth2Error>;
1248
1316
  export interface RevocationRequestOptions extends HttpRequestOptions, AuthenticatedRequestOptions {
1249
- /** Any additional parameters to send. This cannot override existing parameter values. */
1317
+ /**
1318
+ * Any additional parameters to send. This cannot override existing parameter values.
1319
+ */
1250
1320
  additionalParameters?: URLSearchParams | Record<string, string> | string[][];
1251
1321
  }
1252
1322
  /**
@@ -1278,7 +1348,9 @@ export declare function revocationRequest(as: AuthorizationServer, client: Clien
1278
1348
  */
1279
1349
  export declare function processRevocationResponse(response: Response): Promise<undefined | OAuth2Error>;
1280
1350
  export interface IntrospectionRequestOptions extends HttpRequestOptions, AuthenticatedRequestOptions {
1281
- /** Any additional parameters to send. This cannot override existing parameter values. */
1351
+ /**
1352
+ * Any additional parameters to send. This cannot override existing parameter values.
1353
+ */
1282
1354
  additionalParameters?: URLSearchParams | Record<string, string> | string[][];
1283
1355
  /**
1284
1356
  * Request a JWT Response from the
@@ -1311,8 +1383,6 @@ export interface ConfirmationClaims {
1311
1383
  readonly jkt?: string;
1312
1384
  readonly [claim: string]: JsonValue | undefined;
1313
1385
  }
1314
- /** @ignore */
1315
- export type IntrospectionConfirmationClaims = ConfirmationClaims;
1316
1386
  export interface IntrospectionResponse {
1317
1387
  readonly active: boolean;
1318
1388
  readonly client_id?: string;
@@ -1366,9 +1436,6 @@ export declare function processIntrospectionResponse(as: AuthorizationServer, cl
1366
1436
  */
1367
1437
  export declare function validateJwtAuthResponse(as: AuthorizationServer, client: Client, parameters: URLSearchParams | URL, expectedState?: string | typeof expectNoState | typeof skipStateCheck, options?: HttpRequestOptions): Promise<URLSearchParams | OAuth2Error>;
1368
1438
  /**
1369
- * This is an experimental feature, it is not subject to semantic versioning rules. Non-backward
1370
- * compatible changes or removal may occur in any future release.
1371
- *
1372
1439
  * Same as {@link validateAuthResponse} but for FAPI 1.0 Advanced Detached Signature authorization
1373
1440
  * responses.
1374
1441
  *
@@ -1387,11 +1454,10 @@ export declare function validateJwtAuthResponse(as: AuthorizationServer, client:
1387
1454
  * @returns Validated Authorization Response parameters or Authorization Error Response.
1388
1455
  *
1389
1456
  * @group FAPI 1.0 Advanced
1390
- * @group Experimental
1391
1457
  *
1392
1458
  * @see [Financial-grade API Security Profile 1.0 - Part 2: Advanced](https://openid.net/specs/openid-financial-api-part-2-1_0.html#id-token-as-detached-signature)
1393
1459
  */
1394
- export declare function experimental_validateDetachedSignatureResponse(as: AuthorizationServer, client: Client, parameters: URLSearchParams | URL, expectedNonce: string, expectedState?: string | typeof expectNoState, maxAge?: number | typeof skipAuthTimeCheck, options?: HttpRequestOptions): Promise<URLSearchParams | OAuth2Error>;
1460
+ export declare function validateDetachedSignatureResponse(as: AuthorizationServer, client: Client, parameters: URLSearchParams | URL, expectedNonce: string, expectedState?: string | typeof expectNoState, maxAge?: number | typeof skipAuthTimeCheck, options?: HttpRequestOptions): Promise<URLSearchParams | OAuth2Error>;
1395
1461
  /**
1396
1462
  * DANGER ZONE
1397
1463
  *
@@ -1501,11 +1567,17 @@ export declare function deviceCodeGrantRequest(as: AuthorizationServer, client:
1501
1567
  */
1502
1568
  export declare function processDeviceCodeResponse(as: AuthorizationServer, client: Client, response: Response): Promise<TokenEndpointResponse | OAuth2Error>;
1503
1569
  export interface GenerateKeyPairOptions {
1504
- /** Indicates whether or not the private key may be exported. Default is `false`. */
1570
+ /**
1571
+ * Indicates whether or not the private key may be exported. Default is `false`.
1572
+ */
1505
1573
  extractable?: boolean;
1506
- /** (RSA algorithms only) The length, in bits, of the RSA modulus. Default is `2048`. */
1574
+ /**
1575
+ * (RSA algorithms only) The length, in bits, of the RSA modulus. Default is `2048`.
1576
+ */
1507
1577
  modulusLength?: number;
1508
- /** (EdDSA algorithms only) The EdDSA sub-type. Default is `Ed25519`. */
1578
+ /**
1579
+ * (EdDSA algorithms only) The EdDSA sub-type. Default is `Ed25519`.
1580
+ */
1509
1581
  crv?: 'Ed25519' | 'Ed448';
1510
1582
  }
1511
1583
  /**
@@ -1527,17 +1599,20 @@ export interface JWTAccessTokenClaims extends JWTPayload {
1527
1599
  readonly [claim: string]: JsonValue | undefined;
1528
1600
  }
1529
1601
  export interface ValidateJWTAccessTokenOptions extends HttpRequestOptions {
1530
- /** Indicates whether DPoP use is required. */
1602
+ /**
1603
+ * Indicates whether DPoP use is required.
1604
+ */
1531
1605
  requireDPoP?: boolean;
1532
- /** Same functionality as in {@link Client} */
1606
+ /**
1607
+ * Same functionality as in {@link Client}
1608
+ */
1533
1609
  [clockSkew]?: number;
1534
- /** Same functionality as in {@link Client} */
1610
+ /**
1611
+ * Same functionality as in {@link Client}
1612
+ */
1535
1613
  [clockTolerance]?: number;
1536
1614
  }
1537
1615
  /**
1538
- * This is an experimental feature, it is not subject to semantic versioning rules. Non-backward
1539
- * compatible changes or removal may occur in any future release.
1540
- *
1541
1616
  * Validates use of JSON Web Token (JWT) OAuth 2.0 Access Tokens for a given {@link Request} as per
1542
1617
  * RFC 9068 and optionally also RFC 9449.
1543
1618
  *
@@ -1562,10 +1637,57 @@ export interface ValidateJWTAccessTokenOptions extends HttpRequestOptions {
1562
1637
  * @param options
1563
1638
  *
1564
1639
  * @group JWT Access Tokens
1565
- * @group Experimental
1566
1640
  *
1567
1641
  * @see [RFC 9068 - JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens](https://www.rfc-editor.org/rfc/rfc9068.html)
1568
1642
  * @see [RFC 9449 - OAuth 2.0 Demonstrating Proof-of-Possession at the Application Layer (DPoP)](https://www.rfc-editor.org/rfc/rfc9449.html)
1569
1643
  */
1570
- export declare function experimental_validateJwtAccessToken(as: AuthorizationServer, request: Request, expectedAudience: string, options?: ValidateJWTAccessTokenOptions): Promise<JWTAccessTokenClaims>;
1644
+ export declare function validateJwtAccessToken(as: AuthorizationServer, request: Request, expectedAudience: string, options?: ValidateJWTAccessTokenOptions): Promise<JWTAccessTokenClaims>;
1645
+ /**
1646
+ * @ignore
1647
+ *
1648
+ * @deprecated Use {@link customFetch}.
1649
+ */
1650
+ export declare const experimentalCustomFetch: symbol;
1651
+ /**
1652
+ * @ignore
1653
+ *
1654
+ * @deprecated Use {@link customFetch}.
1655
+ */
1656
+ export declare const experimental_customFetch: symbol;
1657
+ /**
1658
+ * @ignore
1659
+ *
1660
+ * @deprecated Use {@link useMtlsAlias}.
1661
+ */
1662
+ export declare const experimentalUseMtlsAlias: symbol;
1663
+ /**
1664
+ * @ignore
1665
+ *
1666
+ * @deprecated Use {@link useMtlsAlias}.
1667
+ */
1668
+ export declare const experimental_useMtlsAlias: symbol;
1669
+ /**
1670
+ * @ignore
1671
+ *
1672
+ * @deprecated Use {@link UseMTLSAliasOptions}.
1673
+ */
1674
+ export type ExperimentalUseMTLSAliasOptions = UseMTLSAliasOptions;
1675
+ /**
1676
+ * @ignore
1677
+ *
1678
+ * @deprecated Use {@link ConfirmationClaims}.
1679
+ */
1680
+ export type IntrospectionConfirmationClaims = ConfirmationClaims;
1681
+ /**
1682
+ * @ignore
1683
+ *
1684
+ * @deprecated Use {@link validateDetachedSignatureResponse}.
1685
+ */
1686
+ export declare const experimental_validateDetachedSignatureResponse: typeof validateDetachedSignatureResponse;
1687
+ /**
1688
+ * @ignore
1689
+ *
1690
+ * @deprecated Use {@link validateJwtAccessToken}.
1691
+ */
1692
+ export declare const experimental_validateJwtAccessToken: typeof validateJwtAccessToken;
1571
1693
  export {};
package/build/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  let USER_AGENT;
2
2
  if (typeof navigator === 'undefined' || !navigator.userAgent?.startsWith?.('Mozilla/5.0 ')) {
3
3
  const NAME = 'oauth4webapi';
4
- const VERSION = 'v2.8.1';
4
+ const VERSION = 'v2.9.0';
5
5
  USER_AGENT = `${NAME}/${VERSION}`;
6
6
  }
7
7
  function looseInstanceOf(input, expected) {
@@ -18,10 +18,8 @@ function looseInstanceOf(input, expected) {
18
18
  }
19
19
  export const clockSkew = Symbol();
20
20
  export const clockTolerance = Symbol();
21
- export const experimental_customFetch = Symbol();
22
- export const experimentalCustomFetch = experimental_customFetch;
23
- export const experimental_useMtlsAlias = Symbol();
24
- export const experimentalUseMtlsAlias = experimental_useMtlsAlias;
21
+ export const customFetch = Symbol();
22
+ export const useMtlsAlias = Symbol();
25
23
  const encoder = new TextEncoder();
26
24
  const decoder = new TextDecoder();
27
25
  function buf(input) {
@@ -214,7 +212,7 @@ export async function discoveryRequest(issuerIdentifier, options) {
214
212
  }
215
213
  const headers = prepareHeaders(options?.headers);
216
214
  headers.set('accept', 'application/json');
217
- return (options?.[experimental_customFetch] || fetch)(url.href, {
215
+ return (options?.[customFetch] || fetch)(url.href, {
218
216
  headers: Object.fromEntries(headers.entries()),
219
217
  method: 'GET',
220
218
  redirect: 'manual',
@@ -554,7 +552,7 @@ async function publicJwk(key) {
554
552
  }
555
553
  function validateEndpoint(value, endpoint, options) {
556
554
  if (typeof value !== 'string') {
557
- if (options?.[experimental_useMtlsAlias]) {
555
+ if (options?.[useMtlsAlias]) {
558
556
  throw new TypeError(`"as.mtls_endpoint_aliases.${endpoint}" must be a string`);
559
557
  }
560
558
  else {
@@ -564,9 +562,7 @@ function validateEndpoint(value, endpoint, options) {
564
562
  return new URL(value);
565
563
  }
566
564
  function resolveEndpoint(as, endpoint, options) {
567
- if (options?.[experimental_useMtlsAlias] &&
568
- as.mtls_endpoint_aliases &&
569
- endpoint in as.mtls_endpoint_aliases) {
565
+ if (options?.[useMtlsAlias] && as.mtls_endpoint_aliases && endpoint in as.mtls_endpoint_aliases) {
570
566
  return validateEndpoint(as.mtls_endpoint_aliases[endpoint], endpoint, options);
571
567
  }
572
568
  return validateEndpoint(as[endpoint], endpoint);
@@ -696,7 +692,7 @@ export async function protectedResourceRequest(accessToken, method, url, headers
696
692
  await dpopProofJwt(headers, options.DPoP, url, 'GET', getClockSkew({ [clockSkew]: options?.[clockSkew] }), accessToken);
697
693
  headers.set('authorization', `DPoP ${accessToken}`);
698
694
  }
699
- return (options?.[experimental_customFetch] || fetch)(url.href, {
695
+ return (options?.[customFetch] || fetch)(url.href, {
700
696
  body,
701
697
  headers: Object.fromEntries(headers.entries()),
702
698
  method,
@@ -859,7 +855,7 @@ export async function processUserInfoResponse(as, client, expectedSubject, respo
859
855
  async function authenticatedRequest(as, client, method, url, body, headers, options) {
860
856
  await clientAuthentication(as, client, body, headers, options?.clientPrivateKey);
861
857
  headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
862
- return (options?.[experimental_customFetch] || fetch)(url.href, {
858
+ return (options?.[customFetch] || fetch)(url.href, {
863
859
  body,
864
860
  headers: Object.fromEntries(headers.entries()),
865
861
  method,
@@ -1222,7 +1218,7 @@ async function jwksRequest(as, options) {
1222
1218
  const headers = prepareHeaders(options?.headers);
1223
1219
  headers.set('accept', 'application/json');
1224
1220
  headers.append('accept', 'application/jwk-set+json');
1225
- return (options?.[experimental_customFetch] || fetch)(url.href, {
1221
+ return (options?.[customFetch] || fetch)(url.href, {
1226
1222
  headers: Object.fromEntries(headers.entries()),
1227
1223
  method: 'GET',
1228
1224
  redirect: 'manual',
@@ -1472,7 +1468,7 @@ async function idTokenHashMatches(data, actual, alg, key) {
1472
1468
  const expected = await idTokenHash(alg, data, key);
1473
1469
  return actual === expected;
1474
1470
  }
1475
- export async function experimental_validateDetachedSignatureResponse(as, client, parameters, expectedNonce, expectedState, maxAge, options) {
1471
+ export async function validateDetachedSignatureResponse(as, client, parameters, expectedNonce, expectedState, maxAge, options) {
1476
1472
  assertAs(as);
1477
1473
  assertClient(client);
1478
1474
  if (parameters instanceof URL) {
@@ -1851,7 +1847,7 @@ async function validateDPoP(as, request, accessTokenClaims, options) {
1851
1847
  }
1852
1848
  }
1853
1849
  }
1854
- export async function experimental_validateJwtAccessToken(as, request, expectedAudience, options) {
1850
+ export async function validateJwtAccessToken(as, request, expectedAudience, options) {
1855
1851
  assertAs(as);
1856
1852
  if (!looseInstanceOf(request, Request)) {
1857
1853
  throw new TypeError('"request" must be an instance of Request');
@@ -1919,3 +1915,9 @@ export async function experimental_validateJwtAccessToken(as, request, expectedA
1919
1915
  }
1920
1916
  return claims;
1921
1917
  }
1918
+ export const experimentalCustomFetch = customFetch;
1919
+ export const experimental_customFetch = customFetch;
1920
+ export const experimentalUseMtlsAlias = useMtlsAlias;
1921
+ export const experimental_useMtlsAlias = useMtlsAlias;
1922
+ export const experimental_validateDetachedSignatureResponse = validateDetachedSignatureResponse;
1923
+ export const experimental_validateJwtAccessToken = validateJwtAccessToken;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oauth4webapi",
3
- "version": "2.8.1",
3
+ "version": "2.9.0",
4
4
  "description": "OAuth 2 / OpenID Connect for JavaScript Runtimes",
5
5
  "keywords": [
6
6
  "access token",
@@ -67,20 +67,20 @@
67
67
  "devDependencies": {
68
68
  "@koa/cors": "^5.0.0",
69
69
  "@types/koa__cors": "^5.0.0",
70
- "@types/node": "^20.11.6",
70
+ "@types/node": "^20.11.15",
71
71
  "@types/oidc-provider": "^8.4.3",
72
72
  "@types/qunit": "^2.19.10",
73
73
  "archiver": "^6.0.1",
74
74
  "ava": "^5.3.1",
75
75
  "chrome-launcher": "^1.1.0",
76
76
  "edge-runtime": "^2.5.8",
77
- "esbuild": "^0.19.12",
77
+ "esbuild": "^0.20.0",
78
78
  "jose": "^5.2.0",
79
79
  "oidc-provider": "^8.4.5",
80
80
  "patch-package": "^8.0.0",
81
81
  "prettier": "^3.2.4",
82
82
  "prettier-plugin-jsdoc": "^1.3.0",
83
- "puppeteer-core": "^21.7.0",
83
+ "puppeteer-core": "^21.10.0",
84
84
  "qunit": "^2.20.0",
85
85
  "raw-body": "^2.5.2",
86
86
  "selfsigned": "^2.4.1",
@@ -88,7 +88,7 @@
88
88
  "tsx": "^4.7.0",
89
89
  "typedoc": "^0.25.7",
90
90
  "typedoc-plugin-markdown": "^3.17.1",
91
- "typedoc-plugin-mdn-links": "^3.1.13",
91
+ "typedoc-plugin-mdn-links": "^3.1.14",
92
92
  "typescript": "^5.3.3",
93
93
  "undici": "^5.28.2"
94
94
  }