@teammy/server 0.2.23 → 0.2.24

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.
Files changed (166) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +11 -7
  3. package/dist/main.js +20331 -13329
  4. package/dist/native-pi-entry.js +755 -19
  5. package/dist/project-pi-entry.js +758 -22
  6. package/dist/runtime/en/shared/system.md +9 -0
  7. package/dist/runtime/en/shared/tools.json +22 -0
  8. package/dist/runtime/en/workflows/directory-analysis/prompt.md +11 -0
  9. package/dist/runtime/en/workflows/file-summary/prompt.md +7 -0
  10. package/dist/runtime/en/workflows/session-handoff/prompt.md +31 -0
  11. package/dist/runtime/en/workflows/session-overview/prompt.md +26 -0
  12. package/dist/runtime/en/workflows/task-bootstrap/prompt.md +84 -0
  13. package/dist/runtime/shared/system.md +1 -1
  14. package/dist/runtime/workflows/session-handoff/prompt.md +1 -1
  15. package/dist/runtime/workflows/session-overview/prompt.md +1 -1
  16. package/dist/web/THIRD-PARTY-LICENSES.md +2025 -0
  17. package/dist/web/assets/Assistant-BeWIo88A.js +1 -0
  18. package/dist/web/assets/{Computers-BtcIsnDD.css → Computers-BJKv9oJv.css} +1 -1
  19. package/dist/web/assets/Computers-CEBC9xd4.js +14 -0
  20. package/dist/web/assets/Conversation-BMA0djTl.js +1 -0
  21. package/dist/web/assets/Dashboard-DtNpBYI5.js +1 -0
  22. package/dist/web/assets/Files-C-00txBh.js +1 -0
  23. package/dist/web/assets/Help-C5yLJzSE.js +2392 -0
  24. package/dist/web/assets/MessageComposer-D7ml-LaD.js +1 -0
  25. package/dist/web/assets/MessageComposer-DqcbXBIG.css +1 -0
  26. package/dist/web/assets/ResourceLibrary-Ceon9f0i.js +6 -0
  27. package/dist/web/assets/TerminalPane-CZYb0vIG.js +22 -0
  28. package/dist/web/assets/WorkspaceTree-C2sVptdG.js +1 -0
  29. package/dist/web/assets/file-links-CQ6ShuxD.js +1 -0
  30. package/dist/web/assets/index-B9gF6reY.css +1 -0
  31. package/dist/web/assets/index-BCj5CDtq.js +40 -0
  32. package/dist/web/assets/project-links-BwYckk7L.js +105 -0
  33. package/dist/web/assets/workflow-DR-M8YZx.svg +111 -0
  34. package/dist/web/downloads/teammy-inbox-skill.zip +0 -0
  35. package/dist/web/downloads/teammy-skill.zip +0 -0
  36. package/dist/web/index.html +4 -4
  37. package/dist/web/notification-worker.js +2 -10
  38. package/node_modules/i18next/LICENSE +21 -0
  39. package/node_modules/i18next/README.md +77 -0
  40. package/node_modules/i18next/dist/cjs/i18next.js +2495 -0
  41. package/node_modules/i18next/dist/esm/i18next.js +2505 -0
  42. package/node_modules/i18next/dist/esm/package.json +1 -0
  43. package/node_modules/i18next/dist/umd/i18next.js +2501 -0
  44. package/node_modules/i18next/dist/umd/i18next.min.js +1 -0
  45. package/node_modules/i18next/i18next.js +2501 -0
  46. package/node_modules/i18next/i18next.min.js +1 -0
  47. package/node_modules/i18next/index.d.mts +71 -0
  48. package/node_modules/i18next/index.d.ts +739 -0
  49. package/node_modules/i18next/package.json +125 -0
  50. package/node_modules/i18next/typescript/helpers.d.ts +73 -0
  51. package/node_modules/i18next/typescript/options.d.ts +871 -0
  52. package/node_modules/i18next/typescript/t.d.ts +1449 -0
  53. package/node_modules/jose/LICENSE.md +21 -0
  54. package/node_modules/jose/README.md +150 -0
  55. package/node_modules/jose/dist/types/index.d.ts +55 -0
  56. package/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +25 -0
  57. package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +40 -0
  58. package/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +25 -0
  59. package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +46 -0
  60. package/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +29 -0
  61. package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +51 -0
  62. package/node_modules/jose/dist/types/jwk/embedded.d.ts +10 -0
  63. package/node_modules/jose/dist/types/jwk/thumbprint.d.ts +15 -0
  64. package/node_modules/jose/dist/types/jwks/local.d.ts +17 -0
  65. package/node_modules/jose/dist/types/jwks/remote.d.ts +94 -0
  66. package/node_modules/jose/dist/types/jws/compact/sign.d.ts +21 -0
  67. package/node_modules/jose/dist/types/jws/compact/verify.d.ts +25 -0
  68. package/node_modules/jose/dist/types/jws/flattened/sign.d.ts +23 -0
  69. package/node_modules/jose/dist/types/jws/flattened/verify.d.ts +26 -0
  70. package/node_modules/jose/dist/types/jws/general/sign.d.ts +41 -0
  71. package/node_modules/jose/dist/types/jws/general/verify.d.ts +31 -0
  72. package/node_modules/jose/dist/types/jwt/decrypt.d.ts +38 -0
  73. package/node_modules/jose/dist/types/jwt/encrypt.d.ts +57 -0
  74. package/node_modules/jose/dist/types/jwt/sign.d.ts +21 -0
  75. package/node_modules/jose/dist/types/jwt/unsecured.d.ts +21 -0
  76. package/node_modules/jose/dist/types/jwt/verify.d.ts +36 -0
  77. package/node_modules/jose/dist/types/key/export.d.ts +19 -0
  78. package/node_modules/jose/dist/types/key/generate_key_pair.d.ts +33 -0
  79. package/node_modules/jose/dist/types/key/generate_secret.d.ts +30 -0
  80. package/node_modules/jose/dist/types/key/import.d.ts +67 -0
  81. package/node_modules/jose/dist/types/types.d.ts +802 -0
  82. package/node_modules/jose/dist/types/util/base64url.d.ts +16 -0
  83. package/node_modules/jose/dist/types/util/decode_jwt.d.ts +9 -0
  84. package/node_modules/jose/dist/types/util/decode_protected_header.d.ts +10 -0
  85. package/node_modules/jose/dist/types/util/errors.d.ts +182 -0
  86. package/node_modules/jose/dist/webapi/index.js +70 -0
  87. package/node_modules/jose/dist/webapi/jwe/compact/decrypt.js +7 -0
  88. package/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +26 -0
  89. package/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +15 -0
  90. package/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +35 -0
  91. package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +41 -0
  92. package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +105 -0
  93. package/node_modules/jose/dist/webapi/jwk/embedded.js +30 -0
  94. package/node_modules/jose/dist/webapi/jwk/thumbprint.js +55 -0
  95. package/node_modules/jose/dist/webapi/jwks/local.js +60 -0
  96. package/node_modules/jose/dist/webapi/jwks/remote.js +103 -0
  97. package/node_modules/jose/dist/webapi/jws/compact/sign.js +20 -0
  98. package/node_modules/jose/dist/webapi/jws/compact/verify.js +8 -0
  99. package/node_modules/jose/dist/webapi/jws/flattened/sign.js +23 -0
  100. package/node_modules/jose/dist/webapi/jws/flattened/verify.js +12 -0
  101. package/node_modules/jose/dist/webapi/jws/general/sign.js +58 -0
  102. package/node_modules/jose/dist/webapi/jws/general/verify.js +42 -0
  103. package/node_modules/jose/dist/webapi/jwt/decrypt.js +13 -0
  104. package/node_modules/jose/dist/webapi/jwt/encrypt.js +42 -0
  105. package/node_modules/jose/dist/webapi/jwt/sign.js +19 -0
  106. package/node_modules/jose/dist/webapi/jwt/unsecured.js +34 -0
  107. package/node_modules/jose/dist/webapi/jwt/verify.js +13 -0
  108. package/node_modules/jose/dist/webapi/key/export.js +35 -0
  109. package/node_modules/jose/dist/webapi/key/generate_key_pair.js +35 -0
  110. package/node_modules/jose/dist/webapi/key/generate_secret.js +36 -0
  111. package/node_modules/jose/dist/webapi/key/import.js +53 -0
  112. package/node_modules/jose/dist/webapi/lib/asn1.js +138 -0
  113. package/node_modules/jose/dist/webapi/lib/buffer_utils.js +75 -0
  114. package/node_modules/jose/dist/webapi/lib/content_encryption.js +90 -0
  115. package/node_modules/jose/dist/webapi/lib/deflate.js +41 -0
  116. package/node_modules/jose/dist/webapi/lib/jwe_algorithms.js +116 -0
  117. package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +190 -0
  118. package/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +75 -0
  119. package/node_modules/jose/dist/webapi/lib/jws_algorithms.js +74 -0
  120. package/node_modules/jose/dist/webapi/lib/jws_sign.js +46 -0
  121. package/node_modules/jose/dist/webapi/lib/jws_verify.js +89 -0
  122. package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +150 -0
  123. package/node_modules/jose/dist/webapi/lib/key.js +157 -0
  124. package/node_modules/jose/dist/webapi/lib/key_algorithm.js +15 -0
  125. package/node_modules/jose/dist/webapi/lib/key_descriptor.js +9 -0
  126. package/node_modules/jose/dist/webapi/lib/key_management.js +195 -0
  127. package/node_modules/jose/dist/webapi/lib/validate.js +122 -0
  128. package/node_modules/jose/dist/webapi/util/base64url.js +16 -0
  129. package/node_modules/jose/dist/webapi/util/decode_jwt.js +33 -0
  130. package/node_modules/jose/dist/webapi/util/decode_protected_header.js +19 -0
  131. package/node_modules/jose/dist/webapi/util/errors.js +109 -0
  132. package/node_modules/jose/package.json +134 -0
  133. package/node_modules/oauth4webapi/LICENSE.md +21 -0
  134. package/node_modules/oauth4webapi/README.md +104 -0
  135. package/node_modules/oauth4webapi/build/index.d.ts +3046 -0
  136. package/node_modules/oauth4webapi/build/index.js +2530 -0
  137. package/node_modules/oauth4webapi/build/index.js.map +1 -0
  138. package/node_modules/oauth4webapi/package.json +112 -0
  139. package/node_modules/openid-client/LICENSE.md +21 -0
  140. package/node_modules/openid-client/README.md +258 -0
  141. package/node_modules/openid-client/build/index.d.ts +2478 -0
  142. package/node_modules/openid-client/build/index.js +1347 -0
  143. package/node_modules/openid-client/build/index.js.map +1 -0
  144. package/node_modules/openid-client/build/passport.d.ts +258 -0
  145. package/node_modules/openid-client/build/passport.js +264 -0
  146. package/node_modules/openid-client/build/passport.js.map +1 -0
  147. package/node_modules/openid-client/package.json +130 -0
  148. package/package.json +5 -1
  149. package/dist/web/assets/Assistant-Dks48Y5w.js +0 -1
  150. package/dist/web/assets/Computers-CaCzZeCc.js +0 -13
  151. package/dist/web/assets/Conversation-kAMzKADw.js +0 -1
  152. package/dist/web/assets/Dashboard-ComNJNOg.js +0 -1
  153. package/dist/web/assets/Dropdown-DGFI68Vd.js +0 -55
  154. package/dist/web/assets/Files-Blsq_C-B.js +0 -1
  155. package/dist/web/assets/Help-BM23uS-t.js +0 -1079
  156. package/dist/web/assets/Markdown-CXnZDm5J.js +0 -29
  157. package/dist/web/assets/MessageComposer-BoOgfyPA.js +0 -1
  158. package/dist/web/assets/MessageComposer-hKEluJsT.css +0 -1
  159. package/dist/web/assets/ResourceLibrary-C12_47kE.js +0 -6
  160. package/dist/web/assets/TerminalPane-BTRM-36z.js +0 -22
  161. package/dist/web/assets/WorkspaceTree-Co7XG2RG.js +0 -1
  162. package/dist/web/assets/file-links-CoVqmrXg.js +0 -1
  163. package/dist/web/assets/index-CeKzFsxV.css +0 -1
  164. package/dist/web/assets/index-mhJ33-bH.js +0 -10
  165. package/dist/web/assets/task-links-BE36-8mc.js +0 -1
  166. /package/dist/web/assets/{Dropdown-ktgqMqAD.css → project-links-ktgqMqAD.css} +0 -0
@@ -0,0 +1,3046 @@
1
+ interface CryptoKeyStructuralFallback {
2
+ readonly algorithm: {
3
+ name: string;
4
+ };
5
+ readonly extractable: boolean;
6
+ readonly type: string;
7
+ readonly usages: string[];
8
+ }
9
+ /**
10
+ * A Web Cryptography key as declared by the host runtime.
11
+ *
12
+ * This aliases the key type returned by the host's `SubtleCrypto.generateKey()` API when it is
13
+ * exposed on `globalThis`. A structural fallback is used otherwise, keeping the package portable to
14
+ * runtimes and TypeScript projects that do not include DOM or Node.js ambient types.
15
+ */
16
+ export type CryptoKey = typeof globalThis extends {
17
+ crypto: {
18
+ subtle: {
19
+ generateKey(...args: any[]): Promise<infer R>;
20
+ };
21
+ };
22
+ } ? Extract<R, {
23
+ type: string;
24
+ }> : CryptoKeyStructuralFallback;
25
+ /**
26
+ * An asymmetric public and private `CryptoKey` pair.
27
+ */
28
+ export interface CryptoKeyPair {
29
+ privateKey: CryptoKey;
30
+ publicKey: CryptoKey;
31
+ }
32
+ /**
33
+ * A JSON object.
34
+ */
35
+ export type JsonObject = {
36
+ [Key in string]?: JsonValue;
37
+ };
38
+ /**
39
+ * A JSON array.
40
+ */
41
+ export type JsonArray = JsonValue[];
42
+ /**
43
+ * A JSON primitive value.
44
+ */
45
+ export type JsonPrimitive = string | number | boolean | null;
46
+ /**
47
+ * Any JSON-compatible value.
48
+ */
49
+ export type JsonValue = JsonPrimitive | JsonObject | JsonArray;
50
+ /**
51
+ * A callback that mutates a JWT assertion header and claims immediately before signing.
52
+ */
53
+ export interface ModifyAssertionFunction {
54
+ (
55
+ /**
56
+ * JWS Header to modify right before it is signed.
57
+ */
58
+ header: Record<string, JsonValue | undefined>,
59
+ /**
60
+ * JWT Claims Set to modify right before it is signed.
61
+ */
62
+ payload: Record<string, JsonValue | undefined>): void;
63
+ }
64
+ /**
65
+ * An asymmetric private key with an optional JWK Key ID for JOSE headers.
66
+ */
67
+ export interface PrivateKey {
68
+ /**
69
+ * An asymmetric private CryptoKey.
70
+ *
71
+ * Its algorithm must be compatible with a supported {@link JWSAlgorithm JWS Algorithm}.
72
+ */
73
+ key: CryptoKey;
74
+ /**
75
+ * JWK Key ID to add to JOSE headers when this key is used. When not provided no `kid` (JWK Key
76
+ * ID) will be added to the JOSE Header.
77
+ */
78
+ kid?: string;
79
+ }
80
+ /**
81
+ * A supported JWS `alg` identifier for digital signature validation.
82
+ *
83
+ * The identifiers come from the
84
+ * {@link https://www.iana.org/assignments/jose/jose.xhtml#web-signature-encryption-algorithms JSON Web Signature and Encryption Algorithms IANA registry}
85
+ * and are limited to those for which digital signature validation is implemented.
86
+ */
87
+ export type JWSAlgorithm = 'PS256' | 'ES256' | 'RS256' | 'Ed25519' | 'ES384' | 'PS384' | 'RS384' | 'ES512' | 'PS512' | 'RS512' | 'ML-DSA-44' | 'ML-DSA-65' | 'ML-DSA-87' | 'EdDSA';
88
+ /**
89
+ * A JSON Web Key with standard JOSE and supported extension parameters.
90
+ *
91
+ * > [!NOTE]\
92
+ * > This is declared as a type alias rather than an interface so that it remains bidirectionally
93
+ * > assignable with the `JsonWebKey` types shipped by `@types/node` and `lib.dom` without accepting
94
+ * > arbitrary parameters itself.
95
+ *
96
+ * Application-specific extension parameters can be represented by intersecting this type with a
97
+ * type that declares them.
98
+ */
99
+ export type JWK = {
100
+ /**
101
+ * JWK "kty" (Key Type) Parameter
102
+ */
103
+ readonly kty?: string;
104
+ /**
105
+ * JWK "alg" (Algorithm) Parameter
106
+ */
107
+ readonly alg?: string;
108
+ /**
109
+ * JWK "key_ops" (Key Operations) Parameter
110
+ */
111
+ readonly key_ops?: string[];
112
+ /**
113
+ * JWK "ext" (Extractable) Parameter
114
+ */
115
+ readonly ext?: boolean;
116
+ /**
117
+ * JWK "use" (Public Key Use) Parameter
118
+ */
119
+ readonly use?: string;
120
+ /**
121
+ * JWK "x5c" (X.509 Certificate Chain) Parameter
122
+ */
123
+ readonly x5c?: string[];
124
+ /**
125
+ * JWK "x5t" (X.509 Certificate SHA-1 Thumbprint) Parameter
126
+ */
127
+ readonly x5t?: string;
128
+ /**
129
+ * JWK "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) Parameter
130
+ */
131
+ readonly 'x5t#S256'?: string;
132
+ /**
133
+ * JWK "x5u" (X.509 URL) Parameter
134
+ */
135
+ readonly x5u?: string;
136
+ /**
137
+ * JWK "kid" (Key ID) Parameter
138
+ */
139
+ readonly kid?: string;
140
+ /**
141
+ * - EC JWK "crv" (Curve) Parameter
142
+ * - OKP JWK "crv" (The Subtype of Key Pair) Parameter
143
+ */
144
+ readonly crv?: string;
145
+ /**
146
+ * - Private RSA JWK "d" (Private Exponent) Parameter
147
+ * - Private EC JWK "d" (ECC Private Key) Parameter
148
+ * - Private OKP JWK "d" (The Private Key) Parameter
149
+ */
150
+ readonly d?: string;
151
+ /**
152
+ * Private RSA JWK "dp" (First Factor CRT Exponent) Parameter
153
+ */
154
+ readonly dp?: string;
155
+ /**
156
+ * Private RSA JWK "dq" (Second Factor CRT Exponent) Parameter
157
+ */
158
+ readonly dq?: string;
159
+ /**
160
+ * RSA JWK "e" (Exponent) Parameter
161
+ */
162
+ readonly e?: string;
163
+ /**
164
+ * Oct JWK "k" (Key Value) Parameter
165
+ */
166
+ readonly k?: string;
167
+ /**
168
+ * RSA JWK "n" (Modulus) Parameter
169
+ */
170
+ readonly n?: string;
171
+ /**
172
+ * Private RSA JWK "p" (First Prime Factor) Parameter
173
+ */
174
+ readonly p?: string;
175
+ /**
176
+ * Private RSA JWK "q" (Second Prime Factor) Parameter
177
+ */
178
+ readonly q?: string;
179
+ /**
180
+ * Private RSA JWK "qi" (First CRT Coefficient) Parameter
181
+ */
182
+ readonly qi?: string;
183
+ /**
184
+ * - EC JWK "x" (X Coordinate) Parameter
185
+ * - OKP JWK "x" (The public key) Parameter
186
+ */
187
+ readonly x?: string;
188
+ /**
189
+ * EC JWK "y" (Y Coordinate) Parameter
190
+ */
191
+ readonly y?: string;
192
+ /**
193
+ * AKP JWK "pub" (Public Key) Parameter
194
+ */
195
+ readonly pub?: string;
196
+ /**
197
+ * AKP JWK "priv" (Private Key) Parameter
198
+ */
199
+ readonly priv?: string;
200
+ /**
201
+ * RSA JWK "oth" (Other Primes Info) Parameter
202
+ */
203
+ readonly oth?: Array<{
204
+ /**
205
+ * The Factor CRT Exponent
206
+ */
207
+ d?: string;
208
+ /**
209
+ * The Prime Factor
210
+ */
211
+ r?: string;
212
+ /**
213
+ * The Factor CRT Coefficient
214
+ */
215
+ t?: string;
216
+ }>;
217
+ };
218
+ /**
219
+ * By default the module only allows interactions with HTTPS endpoints. Setting this option to
220
+ * `true` removes that restriction.
221
+ *
222
+ * @deprecated To make it stand out as something you shouldn't use, possibly only for local
223
+ * development and testing against non-TLS secured environments.
224
+ */
225
+ export declare const allowInsecureRequests: unique symbol;
226
+ /**
227
+ * Adjusts the current time used by protocol validations.
228
+ *
229
+ * Positive and negative finite values representing seconds are allowed. Default is `0`, so the
230
+ * current time is not adjusted.
231
+ *
232
+ * @example
233
+ *
234
+ * When the local clock is mistakenly 1 hour in the past
235
+ *
236
+ * ```ts
237
+ * let client: oauth.Client = {
238
+ * client_id: 'abc4ba37-4ab8-49b5-99d4-9441ba35d428',
239
+ * // ... other metadata
240
+ * [oauth.clockSkew]: +(60 * 60),
241
+ * }
242
+ * ```
243
+ *
244
+ * @example
245
+ *
246
+ * When the local clock is mistakenly 1 hour in the future
247
+ *
248
+ * ```ts
249
+ * let client: oauth.Client = {
250
+ * client_id: 'abc4ba37-4ab8-49b5-99d4-9441ba35d428',
251
+ * // ... other metadata
252
+ * [oauth.clockSkew]: -(60 * 60),
253
+ * }
254
+ * ```
255
+ */
256
+ export declare const clockSkew: unique symbol;
257
+ /**
258
+ * Sets the allowed clock tolerance for JWT timestamp claim validation.
259
+ *
260
+ * Only positive finite values representing seconds are allowed. Default is `30` (30 seconds).
261
+ *
262
+ * @example
263
+ *
264
+ * Tolerate 30 seconds clock skew when validating JWT claims like exp or nbf.
265
+ *
266
+ * ```ts
267
+ * let client: oauth.Client = {
268
+ * client_id: 'abc4ba37-4ab8-49b5-99d4-9441ba35d428',
269
+ * // ... other metadata
270
+ * [oauth.clockTolerance]: 30,
271
+ * }
272
+ * ```
273
+ */
274
+ export declare const clockTolerance: unique symbol;
275
+ /**
276
+ * Overrides the Fetch API implementation used for outbound HTTP requests.
277
+ *
278
+ * When configured on an interface that extends {@link HttpRequestOptions}, this applies to the
279
+ * `options` parameter for functions that may trigger HTTP requests and replaces the use of global
280
+ * `fetch`. As a fetch replacement, the arguments and expected return are the same as `fetch`.
281
+ *
282
+ * In theory any module that claims to be compatible with the Fetch API can be used but your mileage
283
+ * may vary. No workarounds to allow use of non-conform {@link !Response}s will be considered.
284
+ *
285
+ * If you only need to update the {@link !Request} properties you do not need to use a Fetch API
286
+ * module, just change what you need and pass it to globalThis.fetch just like this module would
287
+ * normally do.
288
+ *
289
+ * Its intended use cases are:
290
+ *
291
+ * - {@link !Request}/{@link !Response} tracing and logging
292
+ * - Custom caching strategies for responses of Authorization Server Metadata and JSON Web Key Set
293
+ * (JWKS) endpoints
294
+ * - Changing the {@link !Request} properties like headers, body, credentials, mode before it is passed
295
+ * to fetch
296
+ *
297
+ * Known caveats:
298
+ *
299
+ * - Expect Type-related issues when passing the inputs through to fetch-like modules, they hardly
300
+ * ever get their typings inline with actual fetch, you should `@ts-expect-error` them.
301
+ *
302
+ * @example
303
+ *
304
+ * Using [sindresorhus/ky](https://github.com/sindresorhus/ky) for retries and its hooks feature for
305
+ * logging outgoing requests and their responses.
306
+ *
307
+ * ```js
308
+ * import ky from 'ky'
309
+ *
310
+ * // example use
311
+ * await oauth.discoveryRequest(new URL('https://as.example.com'), {
312
+ * [oauth.customFetch]: (...args) =>
313
+ * ky(args[0], {
314
+ * ...args[1],
315
+ * hooks: {
316
+ * beforeRequest: [
317
+ * (request) => {
318
+ * logRequest(request)
319
+ * },
320
+ * ],
321
+ * beforeRetry: [
322
+ * ({ request, error, retryCount }) => {
323
+ * logRetry(request, error, retryCount)
324
+ * },
325
+ * ],
326
+ * afterResponse: [
327
+ * (request, _, response) => {
328
+ * logResponse(request, response)
329
+ * },
330
+ * ],
331
+ * },
332
+ * }),
333
+ * })
334
+ * ```
335
+ *
336
+ * @example
337
+ *
338
+ * Using [nodejs/undici](https://github.com/nodejs/undici) to detect and use HTTP proxies.
339
+ *
340
+ * ```ts
341
+ * import * as undici from 'undici'
342
+ *
343
+ * // see https://undici.nodejs.org/#/docs/api/EnvHttpProxyAgent
344
+ * let envHttpProxyAgent = new undici.EnvHttpProxyAgent()
345
+ *
346
+ * // example use
347
+ * await oauth.discoveryRequest(new URL('https://as.example.com'), {
348
+ * // @ts-ignore
349
+ * [oauth.customFetch](...args) {
350
+ * return undici.fetch(args[0], { ...args[1], dispatcher: envHttpProxyAgent }) // prettier-ignore
351
+ * },
352
+ * })
353
+ * ```
354
+ *
355
+ * @example
356
+ *
357
+ * Using [nodejs/undici](https://github.com/nodejs/undici) to automatically retry network errors.
358
+ *
359
+ * ```ts
360
+ * import * as undici from 'undici'
361
+ *
362
+ * // see https://undici.nodejs.org/#/docs/api/RetryAgent
363
+ * let retryAgent = new undici.RetryAgent(new undici.Agent(), {
364
+ * statusCodes: [],
365
+ * errorCodes: [
366
+ * 'ECONNRESET',
367
+ * 'ECONNREFUSED',
368
+ * 'ENOTFOUND',
369
+ * 'ENETDOWN',
370
+ * 'ENETUNREACH',
371
+ * 'EHOSTDOWN',
372
+ * 'UND_ERR_SOCKET',
373
+ * ],
374
+ * })
375
+ *
376
+ * // example use
377
+ * await oauth.discoveryRequest(new URL('https://as.example.com'), {
378
+ * // @ts-ignore
379
+ * [oauth.customFetch](...args) {
380
+ * return undici.fetch(args[0], { ...args[1], dispatcher: retryAgent }) // prettier-ignore
381
+ * },
382
+ * })
383
+ * ```
384
+ *
385
+ * @example
386
+ *
387
+ * Using [nodejs/undici](https://github.com/nodejs/undici) to mock responses in tests.
388
+ *
389
+ * ```ts
390
+ * import * as undici from 'undici'
391
+ *
392
+ * // see https://undici.nodejs.org/#/docs/api/MockAgent
393
+ * let mockAgent = new undici.MockAgent()
394
+ * mockAgent.disableNetConnect()
395
+ *
396
+ * // example use
397
+ * await oauth.discoveryRequest(new URL('https://as.example.com'), {
398
+ * // @ts-ignore
399
+ * [oauth.customFetch](...args) {
400
+ * return undici.fetch(args[0], { ...args[1], dispatcher: mockAgent }) // prettier-ignore
401
+ * },
402
+ * })
403
+ * ```
404
+ */
405
+ export declare const customFetch: unique symbol;
406
+ /**
407
+ * Provides a hook for mutating a JWT header and payload immediately before signing.
408
+ *
409
+ * Its intended use is working around non-conforming server behavior, such as modifying JWT `aud`
410
+ * (audience) claims or otherwise changing fixed claims used by this module.
411
+ *
412
+ * @example
413
+ *
414
+ * Changing the `alg: "Ed25519"` back to `alg: "EdDSA"`
415
+ *
416
+ * ```ts
417
+ * let as!: oauth.AuthorizationServer
418
+ * let client!: oauth.Client
419
+ * let parameters!: URLSearchParams
420
+ * let key!: oauth.CryptoKey | oauth.PrivateKey
421
+ * let keyPair!: oauth.CryptoKeyPair
422
+ *
423
+ * let remapEd25519: oauth.ModifyAssertionOptions = {
424
+ * [oauth.modifyAssertion]: (header, _payload) => {
425
+ * if (header.alg === 'Ed25519') {
426
+ * header.alg = 'EdDSA'
427
+ * }
428
+ * },
429
+ * }
430
+ *
431
+ * // For JAR
432
+ * oauth.issueRequestObject(as, client, parameters, key, remapEd25519)
433
+ *
434
+ * // For Private Key JWT
435
+ * oauth.PrivateKeyJwt(key, remapEd25519)
436
+ *
437
+ * // For DPoP
438
+ * oauth.DPoP(client, keyPair, remapEd25519)
439
+ * ```
440
+ */
441
+ export declare const modifyAssertion: unique symbol;
442
+ /**
443
+ * Adds support for decrypting JWEs encountered while processing responses.
444
+ *
445
+ * Supported JWEs include:
446
+ *
447
+ * - Encrypted ID Tokens returned by the Token Endpoint
448
+ * - Encrypted ID Tokens returned as part of FAPI 1.0 Advanced Detached Signature authorization
449
+ * responses
450
+ * - Encrypted JWT UserInfo responses
451
+ * - Encrypted JWT Introspection responses
452
+ * - Encrypted JARM Responses
453
+ *
454
+ * @example
455
+ *
456
+ * Decrypting JARM responses
457
+ *
458
+ * ```ts
459
+ * import * as jose from 'jose'
460
+ *
461
+ * let as!: oauth.AuthorizationServer
462
+ * let client!: oauth.Client
463
+ * let key!: oauth.CryptoKey
464
+ * let alg!: string
465
+ * let enc!: string
466
+ * let currentUrl!: URL
467
+ * let state!: string | undefined
468
+ *
469
+ * let decoder = new TextDecoder()
470
+ * let jweDecrypt: oauth.JweDecryptFunction = async (jwe) => {
471
+ * const { plaintext } = await jose
472
+ * .compactDecrypt(jwe, key, {
473
+ * keyManagementAlgorithms: [alg],
474
+ * contentEncryptionAlgorithms: [enc],
475
+ * })
476
+ * .catch((cause: unknown) => {
477
+ * throw new oauth.OperationProcessingError('decryption failed', { cause })
478
+ * })
479
+ *
480
+ * return decoder.decode(plaintext)
481
+ * }
482
+ *
483
+ * let params = await oauth.validateJwtAuthResponse(as, client, currentUrl, state, {
484
+ * [oauth.jweDecrypt]: jweDecrypt,
485
+ * })
486
+ * ```
487
+ */
488
+ export declare const jweDecrypt: unique symbol;
489
+ /**
490
+ * Provides an externally managed JSON Web Key Set cache for runtimes without persistent in-memory
491
+ * state.
492
+ *
493
+ * > [!WARNING]\
494
+ * > This option has security implications that must be understood, assessed for applicability, and
495
+ * > accepted before use. It is critical that the JSON Web Key Set cache only be writable by your own
496
+ * > code.
497
+ *
498
+ * This option is intended for cloud computing runtimes that cannot keep an in memory cache between
499
+ * their code's invocations. Use in runtimes where an in memory cache between requests is available
500
+ * is not desirable.
501
+ *
502
+ * When configured on an interface that extends {@link JWKSCacheOptions}, this applies to `options`
503
+ * parameter for functions that may trigger HTTP requests to
504
+ * {@link AuthorizationServer.jwks_uri `as.jwks_uri`}, this allows the passed in object to:
505
+ *
506
+ * - Serve as an initial value for the JSON Web Key Set that the module would otherwise need to
507
+ * trigger an HTTP request for
508
+ * - Have the JSON Web Key Set the function optionally ended up triggering an HTTP request for
509
+ * assigned to it as properties
510
+ *
511
+ * The intended use pattern is:
512
+ *
513
+ * - Before executing a function with {@link JWKSCacheOptions} in its `options` parameter you pull the
514
+ * previously cached object from a low-latency key-value store offered by the cloud computing
515
+ * runtime it is executed on;
516
+ * - Default to an empty object `{}` instead when there's no previously cached value;
517
+ * - Pass it into the options interfaces that extend {@link JWKSCacheOptions};
518
+ * - Afterwards, update the key-value storage if the {@link ExportedJWKSCache.uat `uat`} property of
519
+ * the object has changed.
520
+ *
521
+ * @example
522
+ *
523
+ * ```ts
524
+ * let as!: oauth.AuthorizationServer
525
+ * let request!: Request
526
+ * let expectedAudience!: string
527
+ * let getPreviouslyCachedJWKS!: () => Promise<oauth.ExportedJWKSCache>
528
+ * let storeNewJWKScache!: (cache: oauth.ExportedJWKSCache) => Promise<void>
529
+ *
530
+ * // Load JSON Web Key Set cache
531
+ * let jwksCache: oauth.JWKSCacheInput = (await getPreviouslyCachedJWKS()) || {}
532
+ * let { uat } = jwksCache
533
+ *
534
+ * // Use JSON Web Key Set cache
535
+ * let accessTokenClaims = await oauth.validateJwtAccessToken(as, request, expectedAudience, {
536
+ * [oauth.jwksCache]: jwksCache,
537
+ * })
538
+ *
539
+ * if (uat !== jwksCache.uat) {
540
+ * // Update JSON Web Key Set cache
541
+ * await storeNewJWKScache(jwksCache)
542
+ * }
543
+ * ```
544
+ */
545
+ export declare const jwksCache: unique symbol;
546
+ /**
547
+ * Metadata describing an OAuth 2.0 authorization server.
548
+ *
549
+ * @group Authorization Server Metadata
550
+ *
551
+ * @see [IANA OAuth Authorization Server Metadata registry](https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#authorization-server-metadata)
552
+ */
553
+ export interface AuthorizationServer {
554
+ /**
555
+ * Authorization server's Issuer Identifier URL.
556
+ */
557
+ readonly issuer: string;
558
+ /**
559
+ * URL of the authorization server's authorization endpoint.
560
+ */
561
+ readonly authorization_endpoint?: string;
562
+ /**
563
+ * URL of the authorization server's token endpoint.
564
+ */
565
+ readonly token_endpoint?: string;
566
+ /**
567
+ * URL of the authorization server's JWK Set document.
568
+ */
569
+ readonly jwks_uri?: string;
570
+ /**
571
+ * URL of the authorization server's Dynamic Client Registration Endpoint.
572
+ */
573
+ readonly registration_endpoint?: string;
574
+ /**
575
+ * JSON array containing a list of the `scope` values that this authorization server supports.
576
+ */
577
+ readonly scopes_supported?: string[];
578
+ /**
579
+ * JSON array containing a list of the `response_type` values that this authorization server
580
+ * supports.
581
+ */
582
+ readonly response_types_supported?: string[];
583
+ /**
584
+ * JSON array containing a list of the `response_mode` values that this authorization server
585
+ * supports.
586
+ */
587
+ readonly response_modes_supported?: string[];
588
+ /**
589
+ * JSON array containing a list of the `grant_type` values that this authorization server
590
+ * supports.
591
+ */
592
+ readonly grant_types_supported?: string[];
593
+ /**
594
+ * JSON array containing a list of client authentication methods supported by this token endpoint.
595
+ */
596
+ readonly token_endpoint_auth_methods_supported?: string[];
597
+ /**
598
+ * JSON array containing a list of the JWS signing algorithms supported by the token endpoint for
599
+ * the signature on the JWT used to authenticate the client at the token endpoint.
600
+ */
601
+ readonly token_endpoint_auth_signing_alg_values_supported?: string[];
602
+ /**
603
+ * URL of a page containing human-readable information that developers might want or need to know
604
+ * when using the authorization server.
605
+ */
606
+ readonly service_documentation?: string;
607
+ /**
608
+ * Languages and scripts supported for the user interface, represented as a JSON array of language
609
+ * tag values from RFC 5646.
610
+ */
611
+ readonly ui_locales_supported?: string[];
612
+ /**
613
+ * URL that the authorization server provides to the person registering the client to read about
614
+ * the authorization server's requirements on how the client can use the data provided by the
615
+ * authorization server.
616
+ */
617
+ readonly op_policy_uri?: string;
618
+ /**
619
+ * URL that the authorization server provides to the person registering the client to read about
620
+ * the authorization server's terms of service.
621
+ */
622
+ readonly op_tos_uri?: string;
623
+ /**
624
+ * URL of the authorization server's revocation endpoint.
625
+ */
626
+ readonly revocation_endpoint?: string;
627
+ /**
628
+ * JSON array containing a list of client authentication methods supported by this revocation
629
+ * endpoint.
630
+ */
631
+ readonly revocation_endpoint_auth_methods_supported?: string[];
632
+ /**
633
+ * JSON array containing a list of the JWS signing algorithms supported by the revocation endpoint
634
+ * for the signature on the JWT used to authenticate the client at the revocation endpoint.
635
+ */
636
+ readonly revocation_endpoint_auth_signing_alg_values_supported?: string[];
637
+ /**
638
+ * URL of the authorization server's introspection endpoint.
639
+ */
640
+ readonly introspection_endpoint?: string;
641
+ /**
642
+ * JSON array containing a list of client authentication methods supported by this introspection
643
+ * endpoint.
644
+ */
645
+ readonly introspection_endpoint_auth_methods_supported?: string[];
646
+ /**
647
+ * JSON array containing a list of the JWS signing algorithms supported by the introspection
648
+ * endpoint for the signature on the JWT used to authenticate the client at the introspection
649
+ * endpoint.
650
+ */
651
+ readonly introspection_endpoint_auth_signing_alg_values_supported?: string[];
652
+ /**
653
+ * PKCE code challenge methods supported by this authorization server.
654
+ */
655
+ readonly code_challenge_methods_supported?: string[];
656
+ /**
657
+ * Signed JWT containing metadata values about the authorization server as claims.
658
+ */
659
+ readonly signed_metadata?: string;
660
+ /**
661
+ * URL of the authorization server's device authorization endpoint.
662
+ */
663
+ readonly device_authorization_endpoint?: string;
664
+ /**
665
+ * Indicates authorization server support for mutual-TLS client certificate-bound access tokens.
666
+ */
667
+ readonly tls_client_certificate_bound_access_tokens?: boolean;
668
+ /**
669
+ * JSON object containing alternative authorization server endpoints, which a client intending to
670
+ * do mutual TLS will use in preference to the conventional endpoints.
671
+ */
672
+ readonly mtls_endpoint_aliases?: MTLSEndpointAliases;
673
+ /**
674
+ * URL of the authorization server's UserInfo Endpoint.
675
+ */
676
+ readonly userinfo_endpoint?: string;
677
+ /**
678
+ * JSON array containing a list of the Authentication Context Class References that this
679
+ * authorization server supports.
680
+ */
681
+ readonly acr_values_supported?: string[];
682
+ /**
683
+ * JSON array containing a list of the Subject Identifier types that this authorization server
684
+ * supports.
685
+ */
686
+ readonly subject_types_supported?: string[];
687
+ /**
688
+ * JSON array containing a list of the JWS `alg` values supported by the authorization server for
689
+ * the ID Token.
690
+ */
691
+ readonly id_token_signing_alg_values_supported?: string[];
692
+ /**
693
+ * JSON array containing a list of the JWE `alg` values supported by the authorization server for
694
+ * the ID Token.
695
+ */
696
+ readonly id_token_encryption_alg_values_supported?: string[];
697
+ /**
698
+ * JSON array containing a list of the JWE `enc` values supported by the authorization server for
699
+ * the ID Token.
700
+ */
701
+ readonly id_token_encryption_enc_values_supported?: string[];
702
+ /**
703
+ * JSON array containing a list of the JWS `alg` values supported by the UserInfo Endpoint.
704
+ */
705
+ readonly userinfo_signing_alg_values_supported?: string[];
706
+ /**
707
+ * JSON array containing a list of the JWE `alg` values supported by the UserInfo Endpoint.
708
+ */
709
+ readonly userinfo_encryption_alg_values_supported?: string[];
710
+ /**
711
+ * JSON array containing a list of the JWE `enc` values supported by the UserInfo Endpoint.
712
+ */
713
+ readonly userinfo_encryption_enc_values_supported?: string[];
714
+ /**
715
+ * JSON array containing a list of the JWS `alg` values supported by the authorization server for
716
+ * Request Objects.
717
+ */
718
+ readonly request_object_signing_alg_values_supported?: string[];
719
+ /**
720
+ * JSON array containing a list of the JWE `alg` values supported by the authorization server for
721
+ * Request Objects.
722
+ */
723
+ readonly request_object_encryption_alg_values_supported?: string[];
724
+ /**
725
+ * JSON array containing a list of the JWE `enc` values supported by the authorization server for
726
+ * Request Objects.
727
+ */
728
+ readonly request_object_encryption_enc_values_supported?: string[];
729
+ /**
730
+ * JSON array containing a list of the `display` parameter values that the authorization server
731
+ * supports.
732
+ */
733
+ readonly display_values_supported?: string[];
734
+ /**
735
+ * JSON array containing a list of the Claim Types that the authorization server supports.
736
+ */
737
+ readonly claim_types_supported?: string[];
738
+ /**
739
+ * JSON array containing a list of the Claim Names of the Claims that the authorization server MAY
740
+ * be able to supply values for.
741
+ */
742
+ readonly claims_supported?: string[];
743
+ /**
744
+ * Languages and scripts supported for values in Claims being returned, represented as a JSON
745
+ * array of RFC 5646 language tag values.
746
+ */
747
+ readonly claims_locales_supported?: string[];
748
+ /**
749
+ * Boolean value specifying whether the authorization server supports use of the `claims`
750
+ * parameter.
751
+ */
752
+ readonly claims_parameter_supported?: boolean;
753
+ /**
754
+ * Boolean value specifying whether the authorization server supports use of the `request`
755
+ * parameter.
756
+ */
757
+ readonly request_parameter_supported?: boolean;
758
+ /**
759
+ * Boolean value specifying whether the authorization server supports use of the `request_uri`
760
+ * parameter.
761
+ */
762
+ readonly request_uri_parameter_supported?: boolean;
763
+ /**
764
+ * Boolean value specifying whether the authorization server requires any `request_uri` values
765
+ * used to be pre-registered.
766
+ */
767
+ readonly require_request_uri_registration?: boolean;
768
+ /**
769
+ * Indicates where authorization request needs to be protected as Request Object and provided
770
+ * through either `request` or `request_uri` parameter.
771
+ */
772
+ readonly require_signed_request_object?: boolean;
773
+ /**
774
+ * URL of the authorization server's pushed authorization request endpoint.
775
+ */
776
+ readonly pushed_authorization_request_endpoint?: string;
777
+ /**
778
+ * Indicates whether the authorization server accepts authorization requests only via PAR.
779
+ */
780
+ readonly require_pushed_authorization_requests?: boolean;
781
+ /**
782
+ * JSON array containing a list of algorithms supported by the authorization server for
783
+ * introspection response signing.
784
+ */
785
+ readonly introspection_signing_alg_values_supported?: string[];
786
+ /**
787
+ * JSON array containing a list of algorithms supported by the authorization server for
788
+ * introspection response content key encryption (`alg` value).
789
+ */
790
+ readonly introspection_encryption_alg_values_supported?: string[];
791
+ /**
792
+ * JSON array containing a list of algorithms supported by the authorization server for
793
+ * introspection response content encryption (`enc` value).
794
+ */
795
+ readonly introspection_encryption_enc_values_supported?: string[];
796
+ /**
797
+ * Boolean value indicating whether the authorization server provides the `iss` parameter in the
798
+ * authorization response.
799
+ */
800
+ readonly authorization_response_iss_parameter_supported?: boolean;
801
+ /**
802
+ * JSON array containing a list of algorithms supported by the authorization server for
803
+ * introspection response signing.
804
+ */
805
+ readonly authorization_signing_alg_values_supported?: string[];
806
+ /**
807
+ * JSON array containing a list of algorithms supported by the authorization server for
808
+ * introspection response encryption (`alg` value).
809
+ */
810
+ readonly authorization_encryption_alg_values_supported?: string[];
811
+ /**
812
+ * JSON array containing a list of algorithms supported by the authorization server for
813
+ * introspection response encryption (`enc` value).
814
+ */
815
+ readonly authorization_encryption_enc_values_supported?: string[];
816
+ /**
817
+ * CIBA Backchannel Authentication Endpoint.
818
+ */
819
+ readonly backchannel_authentication_endpoint?: string;
820
+ /**
821
+ * JSON array containing a list of the JWS signing algorithms supported for validation of signed
822
+ * CIBA authentication requests.
823
+ */
824
+ readonly backchannel_authentication_request_signing_alg_values_supported?: string[];
825
+ /**
826
+ * Supported CIBA authentication result delivery modes.
827
+ */
828
+ readonly backchannel_token_delivery_modes_supported?: string[];
829
+ /**
830
+ * Indicates whether the authorization server supports the use of the CIBA `user_code` parameter.
831
+ */
832
+ readonly backchannel_user_code_parameter_supported?: boolean;
833
+ /**
834
+ * URL of an authorization server iframe that supports cross-origin communications for session
835
+ * state information with the RP Client, using the HTML5 postMessage API.
836
+ */
837
+ readonly check_session_iframe?: string;
838
+ /**
839
+ * JSON array containing a list of the JWS algorithms supported for DPoP Proof JWTs.
840
+ */
841
+ readonly dpop_signing_alg_values_supported?: string[];
842
+ /**
843
+ * URL at the authorization server to which an RP can perform a redirect to request that the
844
+ * End-User be logged out at the authorization server.
845
+ */
846
+ readonly end_session_endpoint?: string;
847
+ /**
848
+ * Boolean value specifying whether the authorization server can pass `iss` (issuer) and `sid`
849
+ * (session ID) query parameters to identify the RP session with the authorization server when the
850
+ * `frontchannel_logout_uri` is used.
851
+ */
852
+ readonly frontchannel_logout_session_supported?: boolean;
853
+ /**
854
+ * Boolean value specifying whether the authorization server supports HTTP-based logout.
855
+ */
856
+ readonly frontchannel_logout_supported?: boolean;
857
+ /**
858
+ * Boolean value specifying whether the authorization server can pass a `sid` (session ID) Claim
859
+ * in the Logout Token to identify the RP session with the OP.
860
+ */
861
+ readonly backchannel_logout_session_supported?: boolean;
862
+ /**
863
+ * Boolean value specifying whether the authorization server supports back-channel logout.
864
+ */
865
+ readonly backchannel_logout_supported?: boolean;
866
+ /**
867
+ * JSON array containing a list of resource identifiers for OAuth protected resources.
868
+ */
869
+ readonly protected_resources?: string[];
870
+ readonly [metadata: string]: JsonValue | undefined;
871
+ }
872
+ /**
873
+ * Authorization server endpoint aliases used for mutual TLS.
874
+ */
875
+ export interface MTLSEndpointAliases extends Pick<AuthorizationServer, 'backchannel_authentication_endpoint' | 'device_authorization_endpoint' | 'introspection_endpoint' | 'pushed_authorization_request_endpoint' | 'revocation_endpoint' | 'token_endpoint' | 'userinfo_endpoint'> {
876
+ readonly [metadata: string]: string | undefined;
877
+ }
878
+ /**
879
+ * Recognized client metadata that affects this module's behavior.
880
+ *
881
+ * @see [IANA OAuth Client Registration Metadata registry](https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#client-metadata)
882
+ */
883
+ export interface Client {
884
+ /**
885
+ * Client identifier.
886
+ */
887
+ client_id: string;
888
+ /**
889
+ * JWS `alg` algorithm required for signing the ID Token issued to this Client. When not
890
+ * configured the default is to allow only algorithms listed in
891
+ * {@link AuthorizationServer.id_token_signing_alg_values_supported `as.id_token_signing_alg_values_supported`}
892
+ * and fall back to `RS256` when the authorization server metadata is not set.
893
+ */
894
+ id_token_signed_response_alg?: string;
895
+ /**
896
+ * JWS `alg` algorithm required for signing authorization responses. When not configured the
897
+ * default is to allow only algorithms listed in
898
+ * {@link AuthorizationServer.authorization_signing_alg_values_supported `as.authorization_signing_alg_values_supported`}
899
+ * and fall back to `RS256` when the authorization server metadata is not set.
900
+ */
901
+ authorization_signed_response_alg?: string;
902
+ /**
903
+ * Boolean value specifying whether the {@link IDToken.auth_time `auth_time`} Claim in the ID Token
904
+ * is REQUIRED. Default is `false`.
905
+ */
906
+ require_auth_time?: boolean;
907
+ /**
908
+ * JWS `alg` algorithm REQUIRED for signing UserInfo Responses. When not configured the default is
909
+ * to allow only algorithms listed in
910
+ * {@link AuthorizationServer.userinfo_signing_alg_values_supported `as.userinfo_signing_alg_values_supported`}
911
+ * and fail otherwise.
912
+ */
913
+ userinfo_signed_response_alg?: string;
914
+ /**
915
+ * JWS `alg` algorithm REQUIRED for signed introspection responses. When not configured the
916
+ * default is to allow only algorithms listed in
917
+ * {@link AuthorizationServer.introspection_signing_alg_values_supported `as.introspection_signing_alg_values_supported`}
918
+ * and fall back to `RS256` when the authorization server metadata is not set.
919
+ */
920
+ introspection_signed_response_alg?: string;
921
+ /**
922
+ * Default Maximum Authentication Age.
923
+ */
924
+ default_max_age?: number;
925
+ /**
926
+ * Indicates the requirement for a client to use mutual TLS endpoint aliases defined by the AS
927
+ * where present. Default is `false`.
928
+ *
929
+ * When combined with {@link customFetch} (to use a Fetch API implementation that supports client
930
+ * certificates) this can be used to target security profiles that utilize Mutual-TLS for either
931
+ * client authentication or sender constraining.
932
+ *
933
+ * @example
934
+ *
935
+ * (Node.js) Using [nodejs/undici](https://github.com/nodejs/undici) for Mutual-TLS Client
936
+ * Authentication and Certificate-Bound Access Tokens support.
937
+ *
938
+ * ```ts
939
+ * import * as undici from 'undici'
940
+ *
941
+ * let as!: oauth.AuthorizationServer
942
+ * let client!: oauth.Client & { use_mtls_endpoint_aliases: true }
943
+ * let params!: URLSearchParams
944
+ * let key!: string // PEM-encoded key
945
+ * let cert!: string // PEM-encoded certificate
946
+ *
947
+ * let clientAuth = oauth.TlsClientAuth()
948
+ * let agent = new undici.Agent({ connect: { key, cert } })
949
+ *
950
+ * let response = await oauth.pushedAuthorizationRequest(as, client, clientAuth, params, {
951
+ * // @ts-ignore
952
+ * [oauth.customFetch]: (...args) =>
953
+ * undici.fetch(args[0], { ...args[1], dispatcher: agent }),
954
+ * })
955
+ * ```
956
+ *
957
+ * @example
958
+ *
959
+ * (Deno) Using Deno.createHttpClient API for Mutual-TLS Client Authentication and
960
+ * Certificate-Bound Access Tokens support.
961
+ *
962
+ * ```ts
963
+ * let as!: oauth.AuthorizationServer
964
+ * let client!: oauth.Client & { use_mtls_endpoint_aliases: true }
965
+ * let params!: URLSearchParams
966
+ * let key!: string // PEM-encoded key
967
+ * let cert!: string // PEM-encoded certificate
968
+ *
969
+ * let clientAuth = oauth.TlsClientAuth()
970
+ * // @ts-ignore
971
+ * let agent = Deno.createHttpClient({ key, cert })
972
+ *
973
+ * let response = await oauth.pushedAuthorizationRequest(as, client, clientAuth, params, {
974
+ * // @ts-ignore
975
+ * [oauth.customFetch]: (...args) => fetch(args[0], { ...args[1], client: agent }),
976
+ * })
977
+ * ```
978
+ *
979
+ * @see [RFC 8705 - OAuth 2.0 Mutual-TLS Client Authentication and Certificate-Bound Access Tokens](https://www.rfc-editor.org/rfc/rfc8705.html)
980
+ */
981
+ use_mtls_endpoint_aliases?: boolean;
982
+ /**
983
+ * See {@link clockSkew}.
984
+ */
985
+ [clockSkew]?: number;
986
+ /**
987
+ * See {@link clockTolerance}.
988
+ */
989
+ [clockTolerance]?: number;
990
+ [metadata: string]: JsonValue | undefined;
991
+ }
992
+ /**
993
+ * Thrown when an attempted operation is not supported.
994
+ *
995
+ * @group Errors
996
+ */
997
+ export declare class UnsupportedOperationError extends Error {
998
+ code: string;
999
+ /**
1000
+ * @ignore
1001
+ */
1002
+ constructor(message: string, options?: {
1003
+ cause?: unknown;
1004
+ });
1005
+ }
1006
+ /**
1007
+ * Thrown when an OAuth or OpenID Connect operation cannot be processed.
1008
+ *
1009
+ * @group Errors
1010
+ */
1011
+ export declare class OperationProcessingError extends Error {
1012
+ code?: string;
1013
+ /**
1014
+ * @ignore
1015
+ */
1016
+ constructor(message: string, options?: {
1017
+ cause?: unknown;
1018
+ code?: string;
1019
+ });
1020
+ }
1021
+ /**
1022
+ * Options for supplying an externally persisted JSON Web Key Set cache.
1023
+ */
1024
+ export interface JWKSCacheOptions {
1025
+ /**
1026
+ * See {@link jwksCache}.
1027
+ */
1028
+ [jwksCache]?: JWKSCacheInput;
1029
+ }
1030
+ /**
1031
+ * Fetch-style request options passed to a custom fetch implementation.
1032
+ */
1033
+ export interface CustomFetchOptions<Method, BodyType = undefined> {
1034
+ /**
1035
+ * The request body content to send to the server
1036
+ */
1037
+ body: BodyType;
1038
+ /**
1039
+ * HTTP Headers
1040
+ */
1041
+ headers: Record<string, string>;
1042
+ /**
1043
+ * The {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods request method}
1044
+ */
1045
+ method: Method;
1046
+ /**
1047
+ * See {@link !Request.redirect}
1048
+ */
1049
+ redirect: 'manual';
1050
+ /**
1051
+ * Request streaming mode. Set to `"half"` when {@link body} is a {@link !ReadableStream}.
1052
+ */
1053
+ duplex?: 'half';
1054
+ /**
1055
+ * Depending on whether {@link HttpRequestOptions.signal} was used, if so, it is the value passed,
1056
+ * otherwise undefined
1057
+ */
1058
+ signal?: AbortSignal;
1059
+ }
1060
+ /**
1061
+ * Shared transport options for HTTP requests made by this module.
1062
+ */
1063
+ export interface HttpRequestOptions<Method, BodyType = undefined> {
1064
+ /**
1065
+ * An AbortSignal instance, or a factory returning one, to abort the HTTP request(s) triggered by
1066
+ * this function's invocation.
1067
+ *
1068
+ * @example
1069
+ *
1070
+ * A 5000ms timeout AbortSignal for every request
1071
+ *
1072
+ * ```js
1073
+ * let signal = () => AbortSignal.timeout(5_000) // Note: AbortSignal.timeout may not yet be available in all runtimes.
1074
+ * ```
1075
+ */
1076
+ signal?: ((url: string) => AbortSignal) | AbortSignal;
1077
+ /**
1078
+ * Headers to additionally send with the HTTP request(s) triggered by this function's invocation.
1079
+ */
1080
+ headers?: [string, string][] | Record<string, string> | Headers;
1081
+ /**
1082
+ * See {@link customFetch}.
1083
+ */
1084
+ [customFetch]?: (
1085
+ /**
1086
+ * URL the request is being made sent to {@link !fetch} as the `resource` argument
1087
+ */
1088
+ url: string,
1089
+ /**
1090
+ * Options otherwise sent to {@link !fetch} as the `options` argument
1091
+ */
1092
+ options: CustomFetchOptions<Method, BodyType>) => Promise<Response>;
1093
+ /**
1094
+ * See {@link allowInsecureRequests}.
1095
+ *
1096
+ * @deprecated
1097
+ */
1098
+ [allowInsecureRequests]?: boolean;
1099
+ }
1100
+ /**
1101
+ * Options for an authorization server metadata discovery request.
1102
+ */
1103
+ export interface DiscoveryRequestOptions extends HttpRequestOptions<'GET'> {
1104
+ /**
1105
+ * The issuer transformation algorithm to use.
1106
+ */
1107
+ algorithm?: 'oidc' | 'oauth2';
1108
+ }
1109
+ /**
1110
+ * Performs an authorization server metadata discovery using one of two
1111
+ * {@link DiscoveryRequestOptions.algorithm transformation algorithms} applied to the
1112
+ * `issuerIdentifier` argument.
1113
+ *
1114
+ * - `oidc` (default) as defined by OpenID Connect Discovery 1.0.
1115
+ * - `oauth2` as defined by RFC 8414.
1116
+ *
1117
+ * @param issuerIdentifier Issuer Identifier to resolve the well-known discovery URI for.
1118
+ *
1119
+ * @returns Resolves with a {@link !Response} to then invoke {@link processDiscoveryResponse} with
1120
+ *
1121
+ * @group Authorization Server Metadata
1122
+ * @group OpenID Connect (OIDC) Discovery
1123
+ *
1124
+ * @see [RFC 8414 - OAuth 2.0 Authorization Server Metadata](https://www.rfc-editor.org/rfc/rfc8414.html#section-3)
1125
+ * @see [OpenID Connect Discovery 1.0](https://openid.net/specs/openid-connect-discovery-1_0-errata2.html#ProviderConfig)
1126
+ */
1127
+ export declare function discoveryRequest(issuerIdentifier: URL, options?: DiscoveryRequestOptions): Promise<Response>;
1128
+ /**
1129
+ * Processes an authorization server metadata discovery response.
1130
+ *
1131
+ * Validates {@link !Response} instance to be one coming from the authorization server's well-known
1132
+ * discovery endpoint.
1133
+ *
1134
+ * @param expectedIssuerIdentifier Expected Issuer Identifier value.
1135
+ * @param response Resolved value from {@link discoveryRequest}.
1136
+ *
1137
+ * @returns Resolves with the discovered Authorization Server Metadata.
1138
+ *
1139
+ * @group Authorization Server Metadata
1140
+ * @group OpenID Connect (OIDC) Discovery
1141
+ *
1142
+ * @see [RFC 8414 - OAuth 2.0 Authorization Server Metadata](https://www.rfc-editor.org/rfc/rfc8414.html#section-3)
1143
+ * @see [OpenID Connect Discovery 1.0](https://openid.net/specs/openid-connect-discovery-1_0-errata2.html#ProviderConfig)
1144
+ */
1145
+ export declare function processDiscoveryResponse(expectedIssuerIdentifier: URL, response: Response): Promise<AuthorizationServer>;
1146
+ /**
1147
+ * Generates a random `code_verifier` value.
1148
+ *
1149
+ * @group Utilities
1150
+ * @group Authorization Code Grant
1151
+ * @group Authorization Code Grant w/ OpenID Connect (OIDC)
1152
+ * @group Proof Key for Code Exchange (PKCE)
1153
+ *
1154
+ * @see [RFC 7636 - Proof Key for Code Exchange (PKCE)](https://www.rfc-editor.org/rfc/rfc7636.html#section-4)
1155
+ */
1156
+ export declare function generateRandomCodeVerifier(): string;
1157
+ /**
1158
+ * Generates a random `state` value.
1159
+ *
1160
+ * @group Utilities
1161
+ *
1162
+ * @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-4.1.1)
1163
+ */
1164
+ export declare function generateRandomState(): string;
1165
+ /**
1166
+ * Generates a random `nonce` value.
1167
+ *
1168
+ * @group Utilities
1169
+ *
1170
+ * @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0-errata2.html#IDToken)
1171
+ */
1172
+ export declare function generateRandomNonce(): string;
1173
+ /**
1174
+ * Calculates the PKCE `code_challenge` value to send with an authorization request using the S256
1175
+ * PKCE Code Challenge Method transformation.
1176
+ *
1177
+ * @param codeVerifier `code_verifier` value generated e.g. from {@link generateRandomCodeVerifier}.
1178
+ *
1179
+ * @group Authorization Code Grant
1180
+ * @group Authorization Code Grant w/ OpenID Connect (OIDC)
1181
+ * @group Proof Key for Code Exchange (PKCE)
1182
+ *
1183
+ * @see [RFC 7636 - Proof Key for Code Exchange (PKCE)](https://www.rfc-editor.org/rfc/rfc7636.html#section-4)
1184
+ */
1185
+ export declare function calculatePKCECodeChallenge(codeVerifier: string): Promise<string>;
1186
+ /**
1187
+ * Options for attaching a DPoP proof to an HTTP request.
1188
+ */
1189
+ export interface DPoPRequestOptions {
1190
+ /**
1191
+ * DPoP handle, obtained from {@link DPoP}
1192
+ */
1193
+ DPoP?: DPoPHandle;
1194
+ }
1195
+ /**
1196
+ * Options for an OAuth 2.0 Pushed Authorization Request.
1197
+ */
1198
+ export interface PushedAuthorizationRequestOptions extends HttpRequestOptions<'POST', URLSearchParams>, DPoPRequestOptions {
1199
+ }
1200
+ /**
1201
+ * A function that applies client authentication to an authorization server request.
1202
+ *
1203
+ * @see {@link ClientSecretPost}
1204
+ * @see {@link ClientSecretBasic}
1205
+ * @see {@link PrivateKeyJwt}
1206
+ * @see {@link None}
1207
+ * @see {@link TlsClientAuth}
1208
+ * @see [OAuth Token Endpoint Authentication Methods](https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#token-endpoint-auth-method)
1209
+ */
1210
+ export type ClientAuth = (as: AuthorizationServer, client: Client, body: URLSearchParams, headers: Headers) => void | Promise<void>;
1211
+ /**
1212
+ * **`client_secret_post`** sends `client_id` and `client_secret` in the form-encoded request body.
1213
+ *
1214
+ * @example
1215
+ *
1216
+ * ```ts
1217
+ * let clientSecret!: string
1218
+ *
1219
+ * let clientAuth = oauth.ClientSecretPost(clientSecret)
1220
+ * ```
1221
+ *
1222
+ * @param clientSecret
1223
+ *
1224
+ * @group Client Authentication
1225
+ *
1226
+ * @see [OAuth Token Endpoint Authentication Methods](https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#token-endpoint-auth-method)
1227
+ * @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-2.3)
1228
+ * @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0-errata2.html#ClientAuthentication)
1229
+ */
1230
+ export declare function ClientSecretPost(clientSecret: string): ClientAuth;
1231
+ /**
1232
+ * **`client_secret_basic`** sends `client_id` and `client_secret` using the HTTP Basic
1233
+ * authentication scheme.
1234
+ *
1235
+ * @example
1236
+ *
1237
+ * ```ts
1238
+ * let clientSecret!: string
1239
+ *
1240
+ * let clientAuth = oauth.ClientSecretBasic(clientSecret)
1241
+ * ```
1242
+ *
1243
+ * @param clientSecret
1244
+ *
1245
+ * @group Client Authentication
1246
+ *
1247
+ * @see [OAuth Token Endpoint Authentication Methods](https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#token-endpoint-auth-method)
1248
+ * @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-2.3)
1249
+ * @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0-errata2.html#ClientAuthentication)
1250
+ */
1251
+ export declare function ClientSecretBasic(clientSecret: string): ClientAuth;
1252
+ /**
1253
+ * Options for customizing a JWT assertion immediately before signing.
1254
+ */
1255
+ export interface ModifyAssertionOptions {
1256
+ /**
1257
+ * Use to modify a JWT assertion payload or header right before it is signed.
1258
+ *
1259
+ * @see {@link modifyAssertion}
1260
+ */
1261
+ [modifyAssertion]?: ModifyAssertionFunction;
1262
+ }
1263
+ /**
1264
+ * **`private_key_jwt`** authenticates the client with a digitally signed JWT assertion sent in the
1265
+ * form-encoded request body.
1266
+ *
1267
+ * @example
1268
+ *
1269
+ * ```ts
1270
+ * let key!: oauth.CryptoKey | oauth.PrivateKey
1271
+ *
1272
+ * let clientAuth = oauth.PrivateKeyJwt(key)
1273
+ * ```
1274
+ *
1275
+ * @param clientPrivateKey
1276
+ *
1277
+ * @group Client Authentication
1278
+ *
1279
+ * @see [OAuth Token Endpoint Authentication Methods](https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#token-endpoint-auth-method)
1280
+ * @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0-errata2.html#ClientAuthentication)
1281
+ */
1282
+ export declare function PrivateKeyJwt(clientPrivateKey: CryptoKey | PrivateKey, options?: ModifyAssertionOptions): ClientAuth;
1283
+ /**
1284
+ * **`client_secret_jwt`** authenticates the client with an HMAC-protected JWT assertion sent in the
1285
+ * form-encoded request body.
1286
+ *
1287
+ * @example
1288
+ *
1289
+ * ```ts
1290
+ * let clientSecret!: string
1291
+ *
1292
+ * let clientAuth = oauth.ClientSecretJwt(clientSecret)
1293
+ * ```
1294
+ *
1295
+ * @param clientSecret
1296
+ * @param options
1297
+ *
1298
+ * @group Client Authentication
1299
+ *
1300
+ * @see [OAuth Token Endpoint Authentication Methods](https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#token-endpoint-auth-method)
1301
+ * @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0-errata2.html#ClientAuthentication)
1302
+ */
1303
+ export declare function ClientSecretJwt(clientSecret: string, options?: ModifyAssertionOptions): ClientAuth;
1304
+ /**
1305
+ * **`none`** sends only `client_id` in the form-encoded request body for a public client.
1306
+ *
1307
+ * ```ts
1308
+ * let clientAuth = oauth.None()
1309
+ * ```
1310
+ *
1311
+ * @group Client Authentication
1312
+ *
1313
+ * @see [OAuth Token Endpoint Authentication Methods](https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#token-endpoint-auth-method)
1314
+ * @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0-errata2.html#ClientAuthentication)
1315
+ */
1316
+ export declare function None(): ClientAuth;
1317
+ /**
1318
+ * **`tls_client_auth`** sends `client_id` in the form-encoded request body while mTLS credentials
1319
+ * are configured through {@link customFetch}.
1320
+ *
1321
+ * ```ts
1322
+ * let clientAuth = oauth.TlsClientAuth()
1323
+ * ```
1324
+ *
1325
+ * @group Client Authentication
1326
+ *
1327
+ * @see [OAuth Token Endpoint Authentication Methods](https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#token-endpoint-auth-method)
1328
+ * @see [RFC 8705 - OAuth 2.0 Mutual-TLS Client Authentication (PKI Mutual-TLS Method)](https://www.rfc-editor.org/rfc/rfc8705.html#name-pki-mutual-tls-method)
1329
+ */
1330
+ export declare function TlsClientAuth(): ClientAuth;
1331
+ /**
1332
+ * Generates a signed JWT-Secured Authorization Request (JAR).
1333
+ *
1334
+ * @param as Authorization Server Metadata.
1335
+ * @param client Client Metadata.
1336
+ * @param privateKey Private key to sign the Request Object with.
1337
+ *
1338
+ * @group Authorization Code Grant
1339
+ * @group Authorization Code Grant w/ OpenID Connect (OIDC)
1340
+ * @group JWT-Secured Authorization Request (JAR)
1341
+ *
1342
+ * @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)
1343
+ */
1344
+ export declare function issueRequestObject(as: AuthorizationServer, client: Client, parameters: URLSearchParams | Record<string, string> | string[][], privateKey: CryptoKey | PrivateKey, options?: ModifyAssertionOptions): Promise<string>;
1345
+ /**
1346
+ * @ignore
1347
+ */
1348
+ export declare function checkProtocol(url: URL, enforceHttps: boolean | undefined): void;
1349
+ /**
1350
+ * Performs a Pushed Authorization Request.
1351
+ *
1352
+ * The request is sent to the
1353
+ * {@link AuthorizationServer.pushed_authorization_request_endpoint `as.pushed_authorization_request_endpoint`}.
1354
+ *
1355
+ * @param as Authorization Server Metadata.
1356
+ * @param client Client Metadata.
1357
+ * @param clientAuthentication Client Authentication Method.
1358
+ * @param parameters Authorization Request parameters.
1359
+ *
1360
+ * @returns Resolves with a {@link !Response} to then invoke
1361
+ * {@link processPushedAuthorizationResponse} with
1362
+ *
1363
+ * @group Pushed Authorization Requests (PAR)
1364
+ *
1365
+ * @see [RFC 9126 - OAuth 2.0 Pushed Authorization Requests (PAR)](https://www.rfc-editor.org/rfc/rfc9126.html#name-pushed-authorization-reques)
1366
+ * @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-with-pushed-authorizat)
1367
+ */
1368
+ export declare function pushedAuthorizationRequest(as: AuthorizationServer, client: Client, clientAuthentication: ClientAuth, parameters: URLSearchParams | Record<string, string> | string[][], options?: PushedAuthorizationRequestOptions): Promise<Response>;
1369
+ /**
1370
+ * A DPoP proof-generation and nonce-management handle returned by {@link DPoP}.
1371
+ */
1372
+ export interface DPoPHandle {
1373
+ /**
1374
+ * Calculates the JWK Thumbprint of the DPoP public key using the SHA-256 hash function for use as
1375
+ * the optional `dpop_jkt` authorization request parameter.
1376
+ *
1377
+ * @see [RFC 9449 - OAuth 2.0 Demonstrating Proof-of-Possession at the Application Layer (DPoP)](https://www.rfc-editor.org/rfc/rfc9449.html#name-authorization-code-binding-)
1378
+ */
1379
+ calculateThumbprint(): Promise<string>;
1380
+ }
1381
+ /**
1382
+ * Returns whether an error requires retrying the request with a fresh DPoP nonce.
1383
+ *
1384
+ * @group DPoP
1385
+ */
1386
+ export declare function isDPoPNonceError(err: unknown): boolean;
1387
+ /**
1388
+ * Creates a DPoP handle that signs sender-constraining proofs with a {@link CryptoKeyPair} and
1389
+ * tracks server-issued nonces.
1390
+ *
1391
+ * This wrapper / handle also keeps track of server-issued nonces, allowing requests to be retried
1392
+ * with a fresh nonce when the server indicates the need to use one. {@link isDPoPNonceError} can be
1393
+ * used to determine if a rejected error indicates the need to retry the request due to an
1394
+ * expired/missing nonce.
1395
+ *
1396
+ * @example
1397
+ *
1398
+ * ```ts
1399
+ * let client!: oauth.Client
1400
+ * let keyPair!: oauth.CryptoKeyPair
1401
+ *
1402
+ * let DPoP = oauth.DPoP(client, keyPair)
1403
+ * ```
1404
+ *
1405
+ * @param keyPair Public/private key pair to sign the DPoP Proof JWT with
1406
+ *
1407
+ * @group DPoP
1408
+ *
1409
+ * @see {@link https://www.rfc-editor.org/rfc/rfc9449.html RFC 9449 - OAuth 2.0 Demonstrating Proof of Possession (DPoP)}
1410
+ */
1411
+ export declare function DPoP(client: Pick<Client, typeof clockSkew>, keyPair: CryptoKeyPair, options?: ModifyAssertionOptions): DPoPHandle;
1412
+ /**
1413
+ * A parsed successful OAuth 2.0 Pushed Authorization Response.
1414
+ */
1415
+ export interface PushedAuthorizationResponse {
1416
+ readonly request_uri: string;
1417
+ readonly expires_in: number;
1418
+ readonly [parameter: string]: JsonValue | undefined;
1419
+ }
1420
+ /**
1421
+ * A parsed OAuth 2.0 protocol error response body.
1422
+ */
1423
+ export interface OAuth2Error {
1424
+ readonly error: string;
1425
+ readonly error_description?: string;
1426
+ readonly error_uri?: string;
1427
+ readonly algs?: string;
1428
+ readonly scope?: string;
1429
+ readonly [parameter: string]: JsonValue | undefined;
1430
+ }
1431
+ /**
1432
+ * Thrown when a server returns an OAuth-style error in a JSON response body.
1433
+ *
1434
+ * @example
1435
+ *
1436
+ * ```http
1437
+ * HTTP/1.1 400 Bad Request
1438
+ * Content-Type: application/json;charset=UTF-8
1439
+ * Cache-Control: no-store
1440
+ * Pragma: no-cache
1441
+ *
1442
+ * {
1443
+ * "error": "invalid_request"
1444
+ * }
1445
+ * ```
1446
+ *
1447
+ * @group Errors
1448
+ */
1449
+ export declare class ResponseBodyError extends Error {
1450
+ /**
1451
+ * The parsed JSON response body
1452
+ */
1453
+ cause: Record<string, JsonValue | undefined>;
1454
+ code: typeof RESPONSE_BODY_ERROR;
1455
+ /**
1456
+ * Error code given in the JSON response
1457
+ */
1458
+ error: string;
1459
+ /**
1460
+ * HTTP Status Code of the response
1461
+ */
1462
+ status: number;
1463
+ /**
1464
+ * Human-readable text providing additional information, used to assist the developer in
1465
+ * understanding the error that occurred, given in the JSON response
1466
+ */
1467
+ error_description?: string;
1468
+ /**
1469
+ * The "OAuth-style" error {@link !Response}, its {@link !Response.bodyUsed} is `true` and the JSON
1470
+ * body is available in {@link ResponseBodyError.cause}
1471
+ */
1472
+ response: Response;
1473
+ /**
1474
+ * @ignore
1475
+ */
1476
+ constructor(message: string, options: {
1477
+ cause: OAuth2Error;
1478
+ response: Response;
1479
+ });
1480
+ }
1481
+ /**
1482
+ * Thrown when an OAuth 2.0 Authorization Error Response is encountered.
1483
+ *
1484
+ * @example
1485
+ *
1486
+ * ```http
1487
+ * HTTP/1.1 302 Found
1488
+ * Location: https://client.example.com/cb?error=access_denied&state=xyz
1489
+ * ```
1490
+ *
1491
+ * @group Errors
1492
+ */
1493
+ export declare class AuthorizationResponseError extends Error {
1494
+ /**
1495
+ * Authorization Response parameters as {@link !URLSearchParams}
1496
+ */
1497
+ cause: URLSearchParams;
1498
+ code: typeof AUTHORIZATION_RESPONSE_ERROR;
1499
+ /**
1500
+ * Error code given in the Authorization Response
1501
+ */
1502
+ error: string;
1503
+ /**
1504
+ * Human-readable text providing additional information, used to assist the developer in
1505
+ * understanding the error that occurred, given in the Authorization Response
1506
+ */
1507
+ error_description?: string;
1508
+ /**
1509
+ * @ignore
1510
+ */
1511
+ constructor(message: string, options: {
1512
+ cause: URLSearchParams;
1513
+ });
1514
+ }
1515
+ /**
1516
+ * Thrown when a server response contains one or more parseable `WWW-Authenticate` challenges.
1517
+ *
1518
+ * This typically occurs because of expired tokens or bad client authentication.
1519
+ *
1520
+ * @example
1521
+ *
1522
+ * ```http
1523
+ * HTTP/1.1 401 Unauthorized
1524
+ * WWW-Authenticate: Bearer error="invalid_token", error_description="The access token expired"
1525
+ * ```
1526
+ *
1527
+ * @group Errors
1528
+ */
1529
+ export declare class WWWAuthenticateChallengeError extends Error {
1530
+ /**
1531
+ * The parsed WWW-Authenticate HTTP Header challenges
1532
+ */
1533
+ cause: WWWAuthenticateChallenge[];
1534
+ code: typeof WWW_AUTHENTICATE_CHALLENGE;
1535
+ /**
1536
+ * The {@link !Response} that included a WWW-Authenticate HTTP Header challenges, its
1537
+ * {@link !Response.bodyUsed} is `false`
1538
+ */
1539
+ response: Response;
1540
+ /**
1541
+ * HTTP Status Code of the response
1542
+ */
1543
+ status: number;
1544
+ /**
1545
+ * @ignore
1546
+ */
1547
+ constructor(message: string, options: {
1548
+ cause: WWWAuthenticateChallenge[];
1549
+ response: Response;
1550
+ });
1551
+ }
1552
+ /**
1553
+ * Known and extension authentication parameters from a `WWW-Authenticate` challenge.
1554
+ */
1555
+ export interface WWWAuthenticateChallengeParameters {
1556
+ /**
1557
+ * Identifies the protection space
1558
+ */
1559
+ readonly realm?: string;
1560
+ /**
1561
+ * A machine-readable error code value
1562
+ */
1563
+ readonly error?: string;
1564
+ /**
1565
+ * Human-readable ASCII text providing additional information, used to assist the client developer
1566
+ * in understanding the error that occurred
1567
+ */
1568
+ readonly error_description?: string;
1569
+ /**
1570
+ * A URI identifying a human-readable web page with information about the error, used to provide
1571
+ * the client developer with additional information about the error
1572
+ */
1573
+ readonly error_uri?: string;
1574
+ /**
1575
+ * A space-delimited list of supported algorithms, used in
1576
+ * {@link https://www.rfc-editor.org/rfc/rfc9449.html RFC 9449 - OAuth 2.0 Demonstrating Proof of Possession (DPoP)}
1577
+ * challenges
1578
+ */
1579
+ readonly algs?: string;
1580
+ /**
1581
+ * The scope necessary to access the protected resource, used with `insufficient_scope` error code
1582
+ */
1583
+ readonly scope?: string;
1584
+ /**
1585
+ * The URL of the protected resource metadata
1586
+ */
1587
+ readonly resource_metadata?: string;
1588
+ /**
1589
+ * > [!NOTE]\
1590
+ * > Because the parameter names are case insensitive they are always returned lowercased
1591
+ */
1592
+ readonly [parameter: Lowercase<string>]: string | undefined;
1593
+ }
1594
+ /**
1595
+ * A parsed `WWW-Authenticate` challenge.
1596
+ */
1597
+ export interface WWWAuthenticateChallenge {
1598
+ /**
1599
+ * Parsed WWW-Authenticate challenge auth-scheme
1600
+ *
1601
+ * > [!NOTE]\
1602
+ * > Because the value is case insensitive it is always returned lowercased
1603
+ */
1604
+ readonly scheme: Lowercase<string>;
1605
+ /**
1606
+ * Parsed WWW-Authenticate challenge auth-param dictionary (always present but may be empty, e.g.
1607
+ * when {@link WWWAuthenticateChallenge.token68 token68} is present, or when no auth-param pairs
1608
+ * were provided)
1609
+ */
1610
+ readonly parameters: WWWAuthenticateChallengeParameters;
1611
+ /**
1612
+ * Parsed WWW-Authenticate challenge token68
1613
+ */
1614
+ readonly token68?: string;
1615
+ }
1616
+ /**
1617
+ * Processes a Pushed Authorization Response.
1618
+ *
1619
+ * Validates {@link !Response} instance to be one coming from the
1620
+ * {@link AuthorizationServer.pushed_authorization_request_endpoint `as.pushed_authorization_request_endpoint`}.
1621
+ *
1622
+ * @param as Authorization Server Metadata.
1623
+ * @param client Client Metadata.
1624
+ * @param response Resolved value from {@link pushedAuthorizationRequest}.
1625
+ *
1626
+ * @returns Resolves with an object representing the parsed successful response. OAuth 2.0 protocol
1627
+ * style errors are rejected using {@link ResponseBodyError}. WWW-Authenticate HTTP Header
1628
+ * challenges are rejected with {@link WWWAuthenticateChallengeError}.
1629
+ *
1630
+ * @group Pushed Authorization Requests (PAR)
1631
+ *
1632
+ * @see [RFC 9126 - OAuth 2.0 Pushed Authorization Requests (PAR)](https://www.rfc-editor.org/rfc/rfc9126.html#name-pushed-authorization-reques)
1633
+ */
1634
+ export declare function processPushedAuthorizationResponse(as: AuthorizationServer, client: Client, response: Response): Promise<PushedAuthorizationResponse>;
1635
+ /**
1636
+ * An HTTP request body accepted by {@link protectedResourceRequest}.
1637
+ */
1638
+ export type ProtectedResourceRequestBody = ArrayBuffer | null | ReadableStream | string | Uint8Array | undefined | URLSearchParams;
1639
+ /**
1640
+ * Options for an authenticated protected resource request.
1641
+ */
1642
+ export interface ProtectedResourceRequestOptions extends Omit<HttpRequestOptions<string, ProtectedResourceRequestBody>, 'headers'>, DPoPRequestOptions {
1643
+ }
1644
+ /**
1645
+ * Performs a protected resource request at an arbitrary URL.
1646
+ *
1647
+ * Authorization Header is used to transmit the Access Token value.
1648
+ *
1649
+ * @param accessToken The Access Token for the request.
1650
+ * @param method The HTTP method for the request.
1651
+ * @param url Target URL for the request.
1652
+ * @param headers Headers for the request.
1653
+ * @param body Request body compatible with the Fetch API and the request's method.
1654
+ *
1655
+ * @returns Resolves with a {@link !Response} instance. WWW-Authenticate HTTP Header challenges are
1656
+ * rejected with {@link WWWAuthenticateChallengeError}.
1657
+ *
1658
+ * @group Accessing Protected Resources
1659
+ *
1660
+ * @see [RFC 6750 - The OAuth 2.0 Authorization Framework: Bearer Token Usage](https://www.rfc-editor.org/rfc/rfc6750.html#section-2.1)
1661
+ * @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)
1662
+ */
1663
+ export declare function protectedResourceRequest(accessToken: string, method: string, url: URL, headers?: Headers, body?: ProtectedResourceRequestBody, options?: ProtectedResourceRequestOptions): Promise<Response>;
1664
+ /**
1665
+ * Options for an OpenID Connect UserInfo request.
1666
+ */
1667
+ export interface UserInfoRequestOptions extends HttpRequestOptions<'GET'>, DPoPRequestOptions {
1668
+ }
1669
+ /**
1670
+ * Performs a UserInfo Request.
1671
+ *
1672
+ * The request is sent to the {@link AuthorizationServer.userinfo_endpoint `as.userinfo_endpoint`}.
1673
+ *
1674
+ * Authorization Header is used to transmit the Access Token value.
1675
+ *
1676
+ * @param as Authorization Server Metadata.
1677
+ * @param client Client Metadata.
1678
+ * @param accessToken Access Token value.
1679
+ *
1680
+ * @returns Resolves with a {@link !Response} to then invoke {@link processUserInfoResponse} with
1681
+ *
1682
+ * @group Authorization Code Grant w/ OpenID Connect (OIDC)
1683
+ * @group OpenID Connect (OIDC) UserInfo
1684
+ * @group Accessing Protected Resources
1685
+ *
1686
+ * @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0-errata2.html#UserInfo)
1687
+ * @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)
1688
+ */
1689
+ export declare function userInfoRequest(as: AuthorizationServer, client: Client, accessToken: string, options?: UserInfoRequestOptions): Promise<Response>;
1690
+ /**
1691
+ * The structured `address` claim in an OpenID Connect UserInfo response.
1692
+ */
1693
+ export interface UserInfoAddress {
1694
+ readonly formatted?: string;
1695
+ readonly street_address?: string;
1696
+ readonly locality?: string;
1697
+ readonly region?: string;
1698
+ readonly postal_code?: string;
1699
+ readonly country?: string;
1700
+ readonly [claim: string]: JsonValue | undefined;
1701
+ }
1702
+ /**
1703
+ * Claims from a parsed OpenID Connect UserInfo response.
1704
+ */
1705
+ export interface UserInfoResponse {
1706
+ readonly sub: string;
1707
+ readonly name?: string;
1708
+ readonly given_name?: string;
1709
+ readonly family_name?: string;
1710
+ readonly middle_name?: string;
1711
+ readonly nickname?: string;
1712
+ readonly preferred_username?: string;
1713
+ readonly profile?: string;
1714
+ readonly picture?: string;
1715
+ readonly website?: string;
1716
+ readonly email?: string;
1717
+ readonly email_verified?: boolean;
1718
+ readonly gender?: string;
1719
+ readonly birthdate?: string;
1720
+ readonly zoneinfo?: string;
1721
+ readonly locale?: string;
1722
+ readonly phone_number?: string;
1723
+ readonly updated_at?: number;
1724
+ readonly address?: UserInfoAddress;
1725
+ readonly [claim: string]: JsonValue | undefined;
1726
+ }
1727
+ /**
1728
+ * A JSON Web Key Set cache value suitable for external persistence.
1729
+ */
1730
+ export interface ExportedJWKSCache {
1731
+ jwks: JWKS;
1732
+ uat: number;
1733
+ }
1734
+ /**
1735
+ * A previously exported JSON Web Key Set cache or an empty object to receive one.
1736
+ */
1737
+ export type JWKSCacheInput = ExportedJWKSCache | Record<string, never>;
1738
+ /**
1739
+ * Skips the UserInfo `sub` claim value check performed by {@link processUserInfoResponse}.
1740
+ *
1741
+ * > [!WARNING]\
1742
+ * > This option has security implications that must be understood, assessed for applicability, and
1743
+ * > accepted before use.
1744
+ *
1745
+ * Use this as a value to {@link processUserInfoResponse} `expectedSubject` parameter to skip the
1746
+ * `sub` claim value check.
1747
+ *
1748
+ * @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0-errata2.html#UserInfoResponse)
1749
+ */
1750
+ export declare const skipSubjectCheck: unique symbol;
1751
+ /**
1752
+ * Options for supplying compact JWE decryption support.
1753
+ */
1754
+ export interface JWEDecryptOptions {
1755
+ /**
1756
+ * See {@link jweDecrypt}.
1757
+ */
1758
+ [jweDecrypt]?: JweDecryptFunction;
1759
+ }
1760
+ /**
1761
+ * A record of custom `token_type` handlers for processing non-standard token types in OAuth 2.0
1762
+ * token endpoint responses.
1763
+ *
1764
+ * This allows extending the library to support non-standard token types returned by the
1765
+ * authorization server's token endpoint with optional specific processing.
1766
+ *
1767
+ * By default, this library recognizes and handles `bearer` and `dpop` token types. When a token
1768
+ * endpoint response contains a different `token_type` value, you can provide custom handlers to
1769
+ * process these tokens appropriately. Token types other than `bearer`, `dpop`, and ones represented
1770
+ * in this record will be rejected as per https://www.rfc-editor.org/rfc/rfc6749.html#section-7.1
1771
+ *
1772
+ * @example
1773
+ *
1774
+ * Allow a custom `mac` token type
1775
+ *
1776
+ * ```ts
1777
+ * let recognizedTokenTypes: oauth.RecognizedTokenTypes = {
1778
+ * mac: () => {},
1779
+ * }
1780
+ * ```
1781
+ *
1782
+ * @example
1783
+ *
1784
+ * Allow a custom `mac` token type with additional constraints put on the token endpoint JSON
1785
+ * response
1786
+ *
1787
+ * ```ts
1788
+ * let recognizedTokenTypes: oauth.RecognizedTokenTypes = {
1789
+ * mac: (response: Response, tokenResponse: oauth.TokenEndpointResponse) => {
1790
+ * if (typeof tokenResponse.id !== 'string') {
1791
+ * throw new oauth.UnsupportedOperationError('invalid "mac" token_type', {
1792
+ * cause: { body: tokenResponse },
1793
+ * })
1794
+ * }
1795
+ * },
1796
+ * }
1797
+ * ```
1798
+ *
1799
+ * > [!NOTE]\
1800
+ * > Token type names are case insensitive and will be normalized to lowercase before lookup.
1801
+ *
1802
+ * @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-7.1)
1803
+ */
1804
+ export type RecognizedTokenTypes = Record<Lowercase<string>, (res: Response, body: TokenEndpointResponse) => void>;
1805
+ /**
1806
+ * Shared options for processing OAuth 2.0 token endpoint responses.
1807
+ */
1808
+ export interface ProcessTokenResponseOptions extends JWEDecryptOptions {
1809
+ /**
1810
+ * See {@link RecognizedTokenTypes}.
1811
+ */
1812
+ recognizedTokenTypes?: RecognizedTokenTypes;
1813
+ }
1814
+ /**
1815
+ * Processes an OpenID Connect UserInfo response.
1816
+ *
1817
+ * Validates {@link !Response} instance to be one coming from the
1818
+ * {@link AuthorizationServer.userinfo_endpoint `as.userinfo_endpoint`}.
1819
+ *
1820
+ * @param as Authorization Server Metadata.
1821
+ * @param client Client Metadata.
1822
+ * @param expectedSubject Expected `sub` claim value. In response to OpenID Connect authentication
1823
+ * requests, the expected subject is the one from the ID Token claims retrieved from
1824
+ * {@link getValidatedIdTokenClaims}.
1825
+ * @param response Resolved value from {@link userInfoRequest}.
1826
+ *
1827
+ * @returns Resolves with an object representing the parsed successful response. WWW-Authenticate
1828
+ * HTTP Header challenges are rejected with {@link WWWAuthenticateChallengeError}.
1829
+ *
1830
+ * @group Authorization Code Grant w/ OpenID Connect (OIDC)
1831
+ * @group OpenID Connect (OIDC) UserInfo
1832
+ * @group Accessing Protected Resources
1833
+ *
1834
+ * @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0-errata2.html#UserInfo)
1835
+ */
1836
+ export declare function processUserInfoResponse(as: AuthorizationServer, client: Client, expectedSubject: string | typeof skipSubjectCheck, response: Response, options?: JWEDecryptOptions): Promise<UserInfoResponse>;
1837
+ /**
1838
+ * Shared options for OAuth 2.0 token endpoint requests.
1839
+ */
1840
+ export interface TokenEndpointRequestOptions extends HttpRequestOptions<'POST', URLSearchParams>, DPoPRequestOptions {
1841
+ /**
1842
+ * Any additional parameters to send. This cannot override existing parameter values.
1843
+ */
1844
+ additionalParameters?: URLSearchParams | Record<string, string> | string[][];
1845
+ }
1846
+ /**
1847
+ * Performs a Refresh Token Grant request.
1848
+ *
1849
+ * The request is sent to the {@link AuthorizationServer.token_endpoint `as.token_endpoint`}.
1850
+ *
1851
+ * @param as Authorization Server Metadata.
1852
+ * @param client Client Metadata.
1853
+ * @param clientAuthentication Client Authentication Method.
1854
+ * @param refreshToken Refresh Token value.
1855
+ *
1856
+ * @returns Resolves with a {@link !Response} to then invoke {@link processRefreshTokenResponse} with
1857
+ *
1858
+ * @group Refreshing an Access Token
1859
+ *
1860
+ * @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-6)
1861
+ * @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0-errata2.html#RefreshTokens)
1862
+ * @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)
1863
+ */
1864
+ export declare function refreshTokenGrantRequest(as: AuthorizationServer, client: Client, clientAuthentication: ClientAuth, refreshToken: string, options?: TokenEndpointRequestOptions): Promise<Response>;
1865
+ /**
1866
+ * Returns validated ID Token claims from a processed {@link TokenEndpointResponse}, or `undefined`
1867
+ * when it contains no ID Token.
1868
+ *
1869
+ * @param ref {@link TokenEndpointResponse} previously resolved from e.g.
1870
+ * {@link processAuthorizationCodeResponse}
1871
+ *
1872
+ * @returns JWT Claims Set from an ID Token, or undefined if there is no ID Token in `ref`.
1873
+ *
1874
+ * @group Authorization Code Grant w/ OpenID Connect (OIDC)
1875
+ * @group Client-Initiated Backchannel Authentication (CIBA)
1876
+ * @group Device Authorization Grant
1877
+ */
1878
+ export declare function getValidatedIdTokenClaims(ref: TokenEndpointResponse): IDToken | undefined;
1879
+ /**
1880
+ * Options for validating a JWT signature with the authorization server's JSON Web Key Set.
1881
+ */
1882
+ export interface ValidateSignatureOptions extends HttpRequestOptions<'GET'>, JWKSCacheOptions {
1883
+ }
1884
+ /**
1885
+ * Validates the JWS signature of a processed JWT response body or ID Token.
1886
+ *
1887
+ * > [!NOTE]\
1888
+ * > Validating signatures of JWTs received via direct communication between the Client and a
1889
+ * > TLS-secured Endpoint (which it is here) is not mandatory since the TLS server validation is used
1890
+ * > to validate the issuer instead of checking the token signature. You only need to use this method
1891
+ * > for non-repudiation purposes.
1892
+ *
1893
+ * > [!NOTE]\
1894
+ * > Supports only digital signatures.
1895
+ *
1896
+ * @param as Authorization Server Metadata.
1897
+ * @param ref Response previously processed by this module that contained an ID Token or its
1898
+ * response body was a JWT
1899
+ *
1900
+ * @returns Resolves if the signature validates, rejects otherwise.
1901
+ *
1902
+ * @group FAPI 1.0 Advanced
1903
+ * @group FAPI 2.0 Message Signing
1904
+ * @group Authorization Code Grant w/ OpenID Connect (OIDC)
1905
+ * @group OpenID Connect (OIDC) UserInfo
1906
+ * @group Token Introspection
1907
+ *
1908
+ * @see [RFC 9701 - JWT Response for OAuth Token Introspection](https://www.rfc-editor.org/rfc/rfc9701.html#section-5)
1909
+ * @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0-errata2.html#UserInfo)
1910
+ */
1911
+ export declare function validateApplicationLevelSignature(as: AuthorizationServer, ref: Response, options?: ValidateSignatureOptions): Promise<void>;
1912
+ /**
1913
+ * Processes a token response for a Refresh Token Grant.
1914
+ *
1915
+ * Validates Refresh Token Grant {@link !Response} instance to be one coming from the
1916
+ * {@link AuthorizationServer.token_endpoint `as.token_endpoint`}.
1917
+ *
1918
+ * @param as Authorization Server Metadata.
1919
+ * @param client Client Metadata.
1920
+ * @param response Resolved value from {@link refreshTokenGrantRequest}.
1921
+ *
1922
+ * @returns Resolves with an object representing the parsed successful response. OAuth 2.0 protocol
1923
+ * style errors are rejected using {@link ResponseBodyError}. WWW-Authenticate HTTP Header
1924
+ * challenges are rejected with {@link WWWAuthenticateChallengeError}.
1925
+ *
1926
+ * @group Refreshing an Access Token
1927
+ *
1928
+ * @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-6)
1929
+ * @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0-errata2.html#RefreshTokens)
1930
+ */
1931
+ export declare function processRefreshTokenResponse(as: AuthorizationServer, client: Client, response: Response, options?: ProcessTokenResponseOptions): Promise<TokenEndpointResponse>;
1932
+ /**
1933
+ * Disables PKCE for an Authorization Code Grant request.
1934
+ *
1935
+ * > [!WARNING]\
1936
+ * > This option has security implications that must be understood, assessed for applicability, and
1937
+ * > accepted before use.
1938
+ *
1939
+ * Use this as a value to {@link authorizationCodeGrantRequest} `codeVerifier` parameter to skip the
1940
+ * use of PKCE.
1941
+ *
1942
+ * @deprecated To make it stand out as something you shouldn't have the need to use as the use of
1943
+ * PKCE is backwards compatible with authorization servers that don't support it and properly
1944
+ * ignore unrecognized parameters.
1945
+ *
1946
+ * @see [RFC 7636 - Proof Key for Code Exchange (PKCE)](https://www.rfc-editor.org/rfc/rfc7636.html)
1947
+ */
1948
+ export declare const nopkce: unique symbol;
1949
+ /**
1950
+ * Performs an Authorization Code Grant request.
1951
+ *
1952
+ * The request is sent to the {@link AuthorizationServer.token_endpoint `as.token_endpoint`}.
1953
+ *
1954
+ * @param as Authorization Server Metadata.
1955
+ * @param client Client Metadata.
1956
+ * @param clientAuthentication Client Authentication Method.
1957
+ * @param callbackParameters Parameters obtained from the callback to redirect_uri, this is returned
1958
+ * from {@link validateAuthResponse}, or {@link validateJwtAuthResponse}.
1959
+ * @param redirectUri `redirect_uri` value used in the authorization request.
1960
+ * @param codeVerifier PKCE `code_verifier` to send to the token endpoint.
1961
+ *
1962
+ * @returns Resolves with a {@link !Response} to then invoke {@link processAuthorizationCodeResponse}
1963
+ * with
1964
+ *
1965
+ * @group Authorization Code Grant
1966
+ * @group Authorization Code Grant w/ OpenID Connect (OIDC)
1967
+ *
1968
+ * @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-4.1)
1969
+ * @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0-errata2.html#CodeFlowAuth)
1970
+ * @see [RFC 7636 - Proof Key for Code Exchange (PKCE)](https://www.rfc-editor.org/rfc/rfc7636.html#section-4)
1971
+ * @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)
1972
+ */
1973
+ export declare function authorizationCodeGrantRequest(as: AuthorizationServer, client: Client, clientAuthentication: ClientAuth, callbackParameters: URLSearchParams, redirectUri: string, codeVerifier: string | typeof nopkce, options?: TokenEndpointRequestOptions): Promise<Response>;
1974
+ interface JWTPayload {
1975
+ readonly iss?: string;
1976
+ readonly sub?: string;
1977
+ readonly aud?: string | string[];
1978
+ readonly jti?: string;
1979
+ readonly nbf?: number;
1980
+ readonly exp?: number;
1981
+ readonly iat?: number;
1982
+ readonly cnf?: ConfirmationClaims;
1983
+ readonly [claim: string]: JsonValue | undefined;
1984
+ }
1985
+ /**
1986
+ * Claims from a validated OpenID Connect ID Token.
1987
+ */
1988
+ export interface IDToken extends JWTPayload {
1989
+ readonly iss: string;
1990
+ readonly sub: string;
1991
+ readonly aud: string | string[];
1992
+ readonly iat: number;
1993
+ readonly exp: number;
1994
+ readonly nonce?: string;
1995
+ readonly auth_time?: number;
1996
+ readonly azp?: string;
1997
+ readonly [claim: string]: JsonValue | undefined;
1998
+ }
1999
+ /**
2000
+ * An entry in an OAuth 2.0 Rich Authorization Requests `authorization_details` array.
2001
+ */
2002
+ export interface AuthorizationDetails {
2003
+ readonly type: string;
2004
+ readonly locations?: string[];
2005
+ readonly actions?: string[];
2006
+ readonly datatypes?: string[];
2007
+ readonly privileges?: string[];
2008
+ readonly identifier?: string;
2009
+ readonly [parameter: string]: JsonValue | undefined;
2010
+ }
2011
+ /**
2012
+ * A parsed successful OAuth 2.0 token endpoint response.
2013
+ */
2014
+ export interface TokenEndpointResponse {
2015
+ readonly access_token: string;
2016
+ readonly expires_in?: number;
2017
+ readonly id_token?: string;
2018
+ readonly refresh_token?: string;
2019
+ readonly scope?: string;
2020
+ readonly authorization_details?: AuthorizationDetails[];
2021
+ /**
2022
+ * > [!NOTE]\
2023
+ * > Because the value is case insensitive it is always returned lowercased
2024
+ */
2025
+ readonly token_type: 'bearer' | 'dpop' | Lowercase<string>;
2026
+ readonly [parameter: string]: JsonValue | undefined;
2027
+ }
2028
+ /**
2029
+ * Indicates that no ID Token `nonce` claim is expected.
2030
+ *
2031
+ * Use this as the {@link processAuthorizationCodeResponse} `oidc.expectedNonce` value when no
2032
+ * `nonce` parameter was sent with the authorization request.
2033
+ */
2034
+ export declare const expectNoNonce: unique symbol;
2035
+ /**
2036
+ * Skips validation of the ID Token `auth_time` claim.
2037
+ *
2038
+ * Use this as the {@link processAuthorizationCodeResponse} `oidc.maxAge` value.
2039
+ */
2040
+ export declare const skipAuthTimeCheck: unique symbol;
2041
+ /**
2042
+ * Options for processing an Authorization Code Grant token response.
2043
+ */
2044
+ export interface ProcessAuthorizationCodeResponseOptions extends ProcessTokenResponseOptions {
2045
+ /**
2046
+ * Expected ID Token `nonce` claim value. Default is {@link expectNoNonce}.
2047
+ */
2048
+ expectedNonce?: string | typeof expectNoNonce;
2049
+ /**
2050
+ * ID Token {@link IDToken.auth_time `auth_time`} claim value will be checked to be present and
2051
+ * conform to the `maxAge` value. Use of this option is required if you sent a `max_age` parameter
2052
+ * in an authorization request. Default is {@link Client.default_max_age `client.default_max_age`}
2053
+ * and falls back to {@link skipAuthTimeCheck}.
2054
+ */
2055
+ maxAge?: number | typeof skipAuthTimeCheck;
2056
+ /**
2057
+ * When true this requires {@link TokenEndpointResponse.id_token} to be present
2058
+ */
2059
+ requireIdToken?: boolean;
2060
+ }
2061
+ /**
2062
+ * Processes an Authorization Code Grant token response.
2063
+ *
2064
+ * Validates Authorization Code Grant {@link !Response} instance to be one coming from the
2065
+ * {@link AuthorizationServer.token_endpoint `as.token_endpoint`}.
2066
+ *
2067
+ * @param as Authorization Server Metadata.
2068
+ * @param client Client Metadata.
2069
+ * @param response Resolved value from {@link authorizationCodeGrantRequest}.
2070
+ *
2071
+ * @returns Resolves with an object representing the parsed successful response. OAuth 2.0 protocol
2072
+ * style errors are rejected using {@link ResponseBodyError}. WWW-Authenticate HTTP Header
2073
+ * challenges are rejected with {@link WWWAuthenticateChallengeError}.
2074
+ *
2075
+ * @group Authorization Code Grant
2076
+ * @group Authorization Code Grant w/ OpenID Connect (OIDC)
2077
+ *
2078
+ * @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-4.1)
2079
+ * @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0-errata2.html#CodeFlowAuth)
2080
+ */
2081
+ export declare function processAuthorizationCodeResponse(as: AuthorizationServer, client: Client, response: Response, options?: ProcessAuthorizationCodeResponseOptions): Promise<TokenEndpointResponse>;
2082
+ /**
2083
+ * Error code for responses containing parseable `WWW-Authenticate` challenges.
2084
+ *
2085
+ * Assigned to {@link WWWAuthenticateChallengeError.code}.
2086
+ *
2087
+ * @group Error Codes
2088
+ */
2089
+ export declare const WWW_AUTHENTICATE_CHALLENGE = "OAUTH_WWW_AUTHENTICATE_CHALLENGE";
2090
+ /**
2091
+ * Error code for OAuth-style JSON error responses.
2092
+ *
2093
+ * Assigned to {@link ResponseBodyError.code}.
2094
+ *
2095
+ * @group Error Codes
2096
+ */
2097
+ export declare const RESPONSE_BODY_ERROR = "OAUTH_RESPONSE_BODY_ERROR";
2098
+ /**
2099
+ * Error code for unsupported operations.
2100
+ *
2101
+ * Assigned to {@link UnsupportedOperationError.code}.
2102
+ *
2103
+ * @group Error Codes
2104
+ */
2105
+ export declare const UNSUPPORTED_OPERATION = "OAUTH_UNSUPPORTED_OPERATION";
2106
+ /**
2107
+ * Error code for OAuth 2.0 Authorization Error Responses.
2108
+ *
2109
+ * Assigned to {@link AuthorizationResponseError.code}.
2110
+ *
2111
+ * @group Error Codes
2112
+ */
2113
+ export declare const AUTHORIZATION_RESPONSE_ERROR = "OAUTH_AUTHORIZATION_RESPONSE_ERROR";
2114
+ /**
2115
+ * Error code for receiving a JSON UserInfo response when a JWT response was expected.
2116
+ *
2117
+ * Assigned to {@link OperationProcessingError.code}.
2118
+ *
2119
+ * @group Error Codes
2120
+ */
2121
+ export declare const JWT_USERINFO_EXPECTED = "OAUTH_JWT_USERINFO_EXPECTED";
2122
+ /**
2123
+ * Error code for JSON parsing failures.
2124
+ *
2125
+ * Assigned to {@link OperationProcessingError.code}.
2126
+ *
2127
+ * This includes:
2128
+ *
2129
+ * - JWS/JWE Headers
2130
+ * - JSON response bodies
2131
+ * - "claims" authorization request parameters
2132
+ * - "authorization_details" authorization request parameters
2133
+ *
2134
+ * @group Error Codes
2135
+ */
2136
+ export declare const PARSE_ERROR = "OAUTH_PARSE_ERROR";
2137
+ /**
2138
+ * Error code for invalid authorization server responses.
2139
+ *
2140
+ * Assigned to {@link OperationProcessingError.code}.
2141
+ *
2142
+ * @group Error Codes
2143
+ */
2144
+ export declare const INVALID_RESPONSE = "OAUTH_INVALID_RESPONSE";
2145
+ /**
2146
+ * Error code for invalid protected resource requests or request contents.
2147
+ *
2148
+ * Assigned to {@link OperationProcessingError.code}.
2149
+ *
2150
+ * @group Error Codes
2151
+ */
2152
+ export declare const INVALID_REQUEST = "OAUTH_INVALID_REQUEST";
2153
+ /**
2154
+ * Error code for responses with an unexpected media type.
2155
+ *
2156
+ * Assigned to {@link OperationProcessingError.code}.
2157
+ *
2158
+ * @group Error Codes
2159
+ */
2160
+ export declare const RESPONSE_IS_NOT_JSON = "OAUTH_RESPONSE_IS_NOT_JSON";
2161
+ /**
2162
+ * Error code for responses with an unexpected HTTP status code.
2163
+ *
2164
+ * Assigned to {@link OperationProcessingError.code}.
2165
+ *
2166
+ * @group Error Codes
2167
+ */
2168
+ export declare const RESPONSE_IS_NOT_CONFORM = "OAUTH_RESPONSE_IS_NOT_CONFORM";
2169
+ /**
2170
+ * Error code for requests targeting a non-TLS HTTP endpoint when insecure requests are disabled.
2171
+ *
2172
+ * Assigned to {@link OperationProcessingError.code}.
2173
+ *
2174
+ * @group Error Codes
2175
+ */
2176
+ export declare const HTTP_REQUEST_FORBIDDEN = "OAUTH_HTTP_REQUEST_FORBIDDEN";
2177
+ /**
2178
+ * Error code for requests targeting a non-HTTP(S) endpoint.
2179
+ *
2180
+ * Assigned to {@link OperationProcessingError.code}.
2181
+ *
2182
+ * @group Error Codes
2183
+ */
2184
+ export declare const REQUEST_PROTOCOL_FORBIDDEN = "OAUTH_REQUEST_PROTOCOL_FORBIDDEN";
2185
+ /**
2186
+ * Error code for failed JWT NumericDate comparisons with the current timestamp.
2187
+ *
2188
+ * Assigned to {@link OperationProcessingError.code}.
2189
+ *
2190
+ * @group Error Codes
2191
+ *
2192
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519.html#section-2 JSON Web Token (JWT)}
2193
+ */
2194
+ export declare const JWT_TIMESTAMP_CHECK = "OAUTH_JWT_TIMESTAMP_CHECK_FAILED";
2195
+ /**
2196
+ * Error code for unexpected JWT claim values.
2197
+ *
2198
+ * Assigned to {@link OperationProcessingError.code}.
2199
+ *
2200
+ * @group Error Codes
2201
+ *
2202
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519.html#section-2 JSON Web Token (JWT)}
2203
+ */
2204
+ export declare const JWT_CLAIM_COMPARISON = "OAUTH_JWT_CLAIM_COMPARISON_FAILED";
2205
+ /**
2206
+ * Error code for unexpected JSON response attribute values.
2207
+ *
2208
+ * Assigned to {@link OperationProcessingError.code}.
2209
+ *
2210
+ * @group Error Codes
2211
+ */
2212
+ export declare const JSON_ATTRIBUTE_COMPARISON = "OAUTH_JSON_ATTRIBUTE_COMPARISON_FAILED";
2213
+ /**
2214
+ * Error code for JWT signature key selection failures.
2215
+ *
2216
+ * Assigned to {@link OperationProcessingError.code}.
2217
+ *
2218
+ * @group Error Codes
2219
+ */
2220
+ export declare const KEY_SELECTION = "OAUTH_KEY_SELECTION_FAILED";
2221
+ /**
2222
+ * Error code for missing authorization server metadata.
2223
+ *
2224
+ * Assigned to {@link OperationProcessingError.code}.
2225
+ *
2226
+ * @group Error Codes
2227
+ */
2228
+ export declare const MISSING_SERVER_METADATA = "OAUTH_MISSING_SERVER_METADATA";
2229
+ /**
2230
+ * Error code for invalid authorization server metadata.
2231
+ *
2232
+ * Assigned to {@link OperationProcessingError.code}.
2233
+ *
2234
+ * @group Error Codes
2235
+ */
2236
+ export declare const INVALID_SERVER_METADATA = "OAUTH_INVALID_SERVER_METADATA";
2237
+ /**
2238
+ * Options for a Client Credentials Grant token request.
2239
+ */
2240
+ export interface ClientCredentialsGrantRequestOptions extends HttpRequestOptions<'POST', URLSearchParams>, DPoPRequestOptions {
2241
+ }
2242
+ /**
2243
+ * Performs a Client Credentials Grant request.
2244
+ *
2245
+ * The request is sent to the {@link AuthorizationServer.token_endpoint `as.token_endpoint`}.
2246
+ *
2247
+ * @param as Authorization Server Metadata.
2248
+ * @param client Client Metadata.
2249
+ * @param clientAuthentication Client Authentication Method.
2250
+ *
2251
+ * @returns Resolves with a {@link !Response} to then invoke {@link processClientCredentialsResponse}
2252
+ * with
2253
+ *
2254
+ * @group Client Credentials Grant
2255
+ *
2256
+ * @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-4.4)
2257
+ * @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)
2258
+ */
2259
+ export declare function clientCredentialsGrantRequest(as: AuthorizationServer, client: Client, clientAuthentication: ClientAuth, parameters: URLSearchParams | Record<string, string> | string[][], options?: ClientCredentialsGrantRequestOptions): Promise<Response>;
2260
+ /**
2261
+ * Performs an arbitrary OAuth grant request.
2262
+ *
2263
+ * The request is sent to the {@link AuthorizationServer.token_endpoint `as.token_endpoint`} and can
2264
+ * be used for token exchange and JWT or SAML bearer grants.
2265
+ *
2266
+ * @param as Authorization Server Metadata.
2267
+ * @param client Client Metadata.
2268
+ * @param clientAuthentication Client Authentication Method.
2269
+ * @param grantType Grant Type.
2270
+ *
2271
+ * @returns Resolves with a {@link !Response} to then invoke
2272
+ * {@link processGenericTokenEndpointResponse} with
2273
+ *
2274
+ * @group JWT Bearer Token Grant Type
2275
+ * @group SAML 2.0 Bearer Assertion Grant Type
2276
+ * @group Token Exchange Grant Type
2277
+ *
2278
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8693.html Token Exchange Grant Type}
2279
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7523.html#section-2.1 JWT Bearer Token Grant Type}
2280
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7522.html#section-2.1 SAML 2.0 Bearer Assertion Grant Type}
2281
+ */
2282
+ export declare function genericTokenEndpointRequest(as: AuthorizationServer, client: Client, clientAuthentication: ClientAuth, grantType: string, parameters: URLSearchParams | Record<string, string> | string[][], options?: Omit<TokenEndpointRequestOptions, 'additionalParameters'>): Promise<Response>;
2283
+ /**
2284
+ * Processes a token response for an arbitrary OAuth grant.
2285
+ *
2286
+ * Validates Token Endpoint {@link !Response} instance to be one coming from the
2287
+ * {@link AuthorizationServer.token_endpoint `as.token_endpoint`}.
2288
+ *
2289
+ * @param as Authorization Server Metadata.
2290
+ * @param client Client Metadata.
2291
+ * @param response Resolved value from {@link genericTokenEndpointRequest}.
2292
+ *
2293
+ * @group JWT Bearer Token Grant Type
2294
+ * @group SAML 2.0 Bearer Assertion Grant Type
2295
+ * @group Token Exchange Grant Type
2296
+ *
2297
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8693.html Token Exchange Grant Type}
2298
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7523.html#section-2.1 JWT Bearer Token Grant Type}
2299
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7522.html#section-2.1 SAML 2.0 Bearer Assertion Grant Type}
2300
+ */
2301
+ export declare function processGenericTokenEndpointResponse(as: AuthorizationServer, client: Client, response: Response, options?: ProcessTokenResponseOptions): Promise<TokenEndpointResponse>;
2302
+ /**
2303
+ * Processes a Client Credentials Grant token response.
2304
+ *
2305
+ * Validates Client Credentials Grant {@link !Response} instance to be one coming from the
2306
+ * {@link AuthorizationServer.token_endpoint `as.token_endpoint`}.
2307
+ *
2308
+ * @param as Authorization Server Metadata.
2309
+ * @param client Client Metadata.
2310
+ * @param response Resolved value from {@link clientCredentialsGrantRequest}.
2311
+ *
2312
+ * @returns Resolves with an object representing the parsed successful response. OAuth 2.0 protocol
2313
+ * style errors are rejected using {@link ResponseBodyError}. WWW-Authenticate HTTP Header
2314
+ * challenges are rejected with {@link WWWAuthenticateChallengeError}.
2315
+ *
2316
+ * @group Client Credentials Grant
2317
+ *
2318
+ * @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-4.4)
2319
+ */
2320
+ export declare function processClientCredentialsResponse(as: AuthorizationServer, client: Client, response: Response, options?: ProcessTokenResponseOptions): Promise<TokenEndpointResponse>;
2321
+ /**
2322
+ * Options for an OAuth 2.0 Token Revocation request.
2323
+ */
2324
+ export interface RevocationRequestOptions extends HttpRequestOptions<'POST', URLSearchParams> {
2325
+ /**
2326
+ * Any additional parameters to send. This cannot override existing parameter values.
2327
+ */
2328
+ additionalParameters?: URLSearchParams | Record<string, string> | string[][];
2329
+ }
2330
+ /**
2331
+ * Performs a Revocation Request.
2332
+ *
2333
+ * The request is sent to the
2334
+ * {@link AuthorizationServer.revocation_endpoint `as.revocation_endpoint`}.
2335
+ *
2336
+ * @param as Authorization Server Metadata.
2337
+ * @param client Client Metadata.
2338
+ * @param clientAuthentication Client Authentication Method.
2339
+ * @param token Token to revoke. You can provide the `token_type_hint` parameter via
2340
+ * {@link RevocationRequestOptions.additionalParameters options}.
2341
+ *
2342
+ * @returns Resolves with a {@link !Response} to then invoke {@link processRevocationResponse} with
2343
+ *
2344
+ * @group Token Revocation
2345
+ *
2346
+ * @see [RFC 7009 - OAuth 2.0 Token Revocation](https://www.rfc-editor.org/rfc/rfc7009.html#section-2)
2347
+ */
2348
+ export declare function revocationRequest(as: AuthorizationServer, client: Client, clientAuthentication: ClientAuth, token: string, options?: RevocationRequestOptions): Promise<Response>;
2349
+ /**
2350
+ * Processes a Token Revocation response.
2351
+ *
2352
+ * Validates {@link !Response} instance to be one coming from the
2353
+ * {@link AuthorizationServer.revocation_endpoint `as.revocation_endpoint`}.
2354
+ *
2355
+ * @param response Resolved value from {@link revocationRequest}.
2356
+ *
2357
+ * @returns Resolves with `undefined` when the request was successful, or an object representing an
2358
+ * OAuth 2.0 protocol style error.
2359
+ *
2360
+ * @group Token Revocation
2361
+ *
2362
+ * @see [RFC 7009 - OAuth 2.0 Token Revocation](https://www.rfc-editor.org/rfc/rfc7009.html#section-2)
2363
+ */
2364
+ export declare function processRevocationResponse(response: Response): Promise<undefined>;
2365
+ /**
2366
+ * Options for an OAuth 2.0 Token Introspection request.
2367
+ */
2368
+ export interface IntrospectionRequestOptions extends HttpRequestOptions<'POST', URLSearchParams> {
2369
+ /**
2370
+ * Any additional parameters to send. This cannot override existing parameter values.
2371
+ */
2372
+ additionalParameters?: URLSearchParams | Record<string, string> | string[][];
2373
+ /**
2374
+ * Request a JWT Response from the
2375
+ * {@link AuthorizationServer.introspection_endpoint `as.introspection_endpoint`}. Default is
2376
+ *
2377
+ * - True when
2378
+ * {@link Client.introspection_signed_response_alg `client.introspection_signed_response_alg`} is
2379
+ * set
2380
+ * - False otherwise
2381
+ */
2382
+ requestJwtResponse?: boolean;
2383
+ }
2384
+ /**
2385
+ * Performs an Introspection Request.
2386
+ *
2387
+ * The request is sent to the
2388
+ * {@link AuthorizationServer.introspection_endpoint `as.introspection_endpoint`}.
2389
+ *
2390
+ * @param as Authorization Server Metadata.
2391
+ * @param client Client Metadata.
2392
+ * @param clientAuthentication Client Authentication Method.
2393
+ * @param token Token to introspect. You can provide the `token_type_hint` parameter via
2394
+ * {@link IntrospectionRequestOptions.additionalParameters options}.
2395
+ *
2396
+ * @returns Resolves with a {@link !Response} to then invoke {@link processIntrospectionResponse} with
2397
+ *
2398
+ * @group Token Introspection
2399
+ *
2400
+ * @see [RFC 7662 - OAuth 2.0 Token Introspection](https://www.rfc-editor.org/rfc/rfc7662.html#section-2)
2401
+ * @see [RFC 9701 - JWT Response for OAuth Token Introspection](https://www.rfc-editor.org/rfc/rfc9701.html#section-4)
2402
+ */
2403
+ export declare function introspectionRequest(as: AuthorizationServer, client: Client, clientAuthentication: ClientAuth, token: string, options?: IntrospectionRequestOptions): Promise<Response>;
2404
+ /**
2405
+ * Proof-of-possession confirmation (`cnf`) claims associated with a token.
2406
+ */
2407
+ export interface ConfirmationClaims {
2408
+ readonly 'x5t#S256'?: string;
2409
+ readonly jkt?: string;
2410
+ readonly [claim: string]: JsonValue | undefined;
2411
+ }
2412
+ /**
2413
+ * A parsed successful OAuth 2.0 Token Introspection response.
2414
+ */
2415
+ export interface IntrospectionResponse {
2416
+ readonly active: boolean;
2417
+ readonly client_id?: string;
2418
+ readonly exp?: number;
2419
+ readonly iat?: number;
2420
+ readonly sid?: string;
2421
+ readonly iss?: string;
2422
+ readonly jti?: string;
2423
+ readonly username?: string;
2424
+ readonly aud?: string | string[];
2425
+ readonly scope?: string;
2426
+ readonly sub?: string;
2427
+ readonly nbf?: number;
2428
+ readonly token_type?: string;
2429
+ readonly cnf?: ConfirmationClaims;
2430
+ readonly authorization_details?: AuthorizationDetails[];
2431
+ readonly [claim: string]: JsonValue | undefined;
2432
+ }
2433
+ /**
2434
+ * Processes a Token Introspection response.
2435
+ *
2436
+ * Validates {@link !Response} instance to be one coming from the
2437
+ * {@link AuthorizationServer.introspection_endpoint `as.introspection_endpoint`}.
2438
+ *
2439
+ * @param as Authorization Server Metadata.
2440
+ * @param client Client Metadata.
2441
+ * @param response Resolved value from {@link introspectionRequest}.
2442
+ *
2443
+ * @returns Resolves with an object representing the parsed successful response. OAuth 2.0 protocol
2444
+ * style errors are rejected using {@link ResponseBodyError}. WWW-Authenticate HTTP Header
2445
+ * challenges are rejected with {@link WWWAuthenticateChallengeError}.
2446
+ *
2447
+ * @group Token Introspection
2448
+ *
2449
+ * @see [RFC 7662 - OAuth 2.0 Token Introspection](https://www.rfc-editor.org/rfc/rfc7662.html#section-2)
2450
+ * @see [RFC 9701 - JWT Response for OAuth Token Introspection](https://www.rfc-editor.org/rfc/rfc9701.html#section-5)
2451
+ */
2452
+ export declare function processIntrospectionResponse(as: AuthorizationServer, client: Client, response: Response, options?: JWEDecryptOptions): Promise<IntrospectionResponse>;
2453
+ /**
2454
+ * A JSON Web Key Set.
2455
+ */
2456
+ export interface JWKS {
2457
+ readonly keys: JWK[];
2458
+ }
2459
+ /**
2460
+ * A function that decrypts a compact JWE and returns its nested JWT string.
2461
+ */
2462
+ export type JweDecryptFunction = (jwe: string) => Promise<string>;
2463
+ /**
2464
+ * Validates a signed JARM authorization response.
2465
+ *
2466
+ * @param as Authorization Server Metadata.
2467
+ * @param client Client Metadata.
2468
+ * @param parameters JARM authorization response.
2469
+ * @param expectedState Expected `state` parameter value. Default is {@link expectNoState}.
2470
+ *
2471
+ * @returns Validated Authorization Response parameters. Authorization Error Responses are rejected
2472
+ * using {@link AuthorizationResponseError}.
2473
+ *
2474
+ * @group Authorization Code Grant
2475
+ * @group Authorization Code Grant w/ OpenID Connect (OIDC)
2476
+ * @group JWT Secured Authorization Response Mode for OAuth 2.0 (JARM)
2477
+ * @group FAPI 2.0 Message Signing
2478
+ * @group FAPI 1.0 Advanced
2479
+ *
2480
+ * @see [JWT Secured Authorization Response Mode for OAuth 2.0 (JARM)](https://openid.net/specs/openid-financial-api-jarm-final.html)
2481
+ */
2482
+ export declare function validateJwtAuthResponse(as: AuthorizationServer, client: Client, parameters: URLSearchParams | URL, expectedState?: string | typeof expectNoState | typeof skipStateCheck, options?: ValidateSignatureOptions & JWEDecryptOptions): Promise<URLSearchParams>;
2483
+ /**
2484
+ * Validates a FAPI 1.0 Advanced detached-signature authorization response.
2485
+ *
2486
+ * @param as Authorization Server Metadata.
2487
+ * @param client Client Metadata.
2488
+ * @param parameters Authorization Response parameters as URLSearchParams, instance of URL with
2489
+ * parameters in a fragment/hash, or a `form_post` Request instance.
2490
+ * @param expectedNonce Expected ID Token `nonce` claim value.
2491
+ * @param expectedState Expected `state` parameter value. Default is {@link expectNoState}.
2492
+ * @param maxAge ID Token {@link IDToken.auth_time `auth_time`} claim value will be checked to be
2493
+ * present and conform to the `maxAge` value. Use of this option is required if you sent a
2494
+ * `max_age` parameter in an authorization request. Default is
2495
+ * {@link Client.default_max_age `client.default_max_age`} and falls back to
2496
+ * {@link skipAuthTimeCheck}.
2497
+ *
2498
+ * @returns Validated Authorization Response parameters. Authorization Error Responses are rejected
2499
+ * using {@link AuthorizationResponseError}.
2500
+ *
2501
+ * @group FAPI 1.0 Advanced
2502
+ *
2503
+ * @see [Financial-grade API Security Profile 1.0 - Part 2: Advanced](https://openid.net/specs/openid-financial-api-part-2-1_0-final.html#id-token-as-detached-signature)
2504
+ */
2505
+ export declare function validateDetachedSignatureResponse(as: AuthorizationServer, client: Client, parameters: URLSearchParams | URL | Request, expectedNonce: string, expectedState?: string | typeof expectNoState, maxAge?: number | typeof skipAuthTimeCheck, options?: ValidateSignatureOptions & JWEDecryptOptions): Promise<URLSearchParams>;
2506
+ /**
2507
+ * Validates an OpenID Connect `code id_token` authorization response.
2508
+ *
2509
+ * @param as Authorization Server Metadata.
2510
+ * @param client Client Metadata.
2511
+ * @param parameters Authorization Response parameters as URLSearchParams, instance of URL with
2512
+ * parameters in a fragment/hash, or a `form_post` Request instance.
2513
+ * @param expectedNonce Expected ID Token `nonce` claim value.
2514
+ * @param expectedState Expected `state` parameter value. Default is {@link expectNoState}.
2515
+ * @param maxAge ID Token {@link IDToken.auth_time `auth_time`} claim value will be checked to be
2516
+ * present and conform to the `maxAge` value. Use of this option is required if you sent a
2517
+ * `max_age` parameter in an authorization request. Default is
2518
+ * {@link Client.default_max_age `client.default_max_age`} and falls back to
2519
+ * {@link skipAuthTimeCheck}.
2520
+ *
2521
+ * @returns Validated Authorization Response parameters. Authorization Error Responses are rejected
2522
+ * using {@link AuthorizationResponseError}.
2523
+ *
2524
+ * @group Authorization Code Grant w/ OpenID Connect (OIDC)
2525
+ *
2526
+ * @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-4.1.2)
2527
+ * @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0-errata2.html#HybridFlowAuth)
2528
+ */
2529
+ export declare function validateCodeIdTokenResponse(as: AuthorizationServer, client: Client, parameters: URLSearchParams | URL | Request, expectedNonce: string, expectedState?: string | typeof expectNoState, maxAge?: number | typeof skipAuthTimeCheck, options?: ValidateSignatureOptions & JWEDecryptOptions): Promise<URLSearchParams>;
2530
+ /**
2531
+ * Skips the authorization response `state` value check performed by {@link validateAuthResponse}.
2532
+ *
2533
+ * > [!WARNING]\
2534
+ * > This option has security implications that must be understood, assessed for applicability, and
2535
+ * > accepted before use.
2536
+ *
2537
+ * Use this as a value to {@link validateAuthResponse} `expectedState` parameter to skip the `state`
2538
+ * value check when you'll be validating such `state` value yourself instead. This should only be
2539
+ * done if you use a `state` parameter value that is integrity protected and bound to the browsing
2540
+ * session. One such mechanism to do so is described in an I-D
2541
+ * [draft-bradley-oauth-jwt-encoded-state-09](https://datatracker.ietf.org/doc/html/draft-bradley-oauth-jwt-encoded-state-09).
2542
+ */
2543
+ export declare const skipStateCheck: unique symbol;
2544
+ /**
2545
+ * Indicates that no authorization response `state` parameter is expected.
2546
+ *
2547
+ * Use this as the {@link validateAuthResponse} `expectedState` value when no `state` parameter was
2548
+ * sent with the authorization request.
2549
+ */
2550
+ export declare const expectNoState: unique symbol;
2551
+ /**
2552
+ * Validates an OAuth 2.0 Authorization Response or Authorization Error Response.
2553
+ *
2554
+ * The message is returned from the authorization server's
2555
+ * {@link AuthorizationServer.authorization_endpoint `as.authorization_endpoint`}.
2556
+ *
2557
+ * @param as Authorization Server Metadata.
2558
+ * @param client Client Metadata.
2559
+ * @param parameters Authorization response.
2560
+ * @param expectedState Expected `state` parameter value. Default is {@link expectNoState}.
2561
+ *
2562
+ * @returns Validated Authorization Response parameters. Authorization Error Responses throw
2563
+ * {@link AuthorizationResponseError}.
2564
+ *
2565
+ * @group Authorization Code Grant
2566
+ * @group Authorization Code Grant w/ OpenID Connect (OIDC)
2567
+ *
2568
+ * @see [RFC 6749 - The OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749.html#section-4.1.2)
2569
+ * @see [OpenID Connect Core 1.0](https://openid.net/specs/openid-connect-core-1_0-errata2.html#CodeFlowAuth)
2570
+ * @see [RFC 9207 - OAuth 2.0 Authorization Server Issuer Identification](https://www.rfc-editor.org/rfc/rfc9207.html)
2571
+ */
2572
+ export declare function validateAuthResponse(as: AuthorizationServer, client: Client, parameters: URLSearchParams | URL, expectedState?: string | typeof expectNoState | typeof skipStateCheck): URLSearchParams;
2573
+ /**
2574
+ * Options for an OAuth 2.0 Device Authorization Request.
2575
+ */
2576
+ export interface DeviceAuthorizationRequestOptions extends HttpRequestOptions<'POST', URLSearchParams> {
2577
+ }
2578
+ /**
2579
+ * Performs a Device Authorization Request.
2580
+ *
2581
+ * The request is sent to the
2582
+ * {@link AuthorizationServer.device_authorization_endpoint `as.device_authorization_endpoint`}.
2583
+ *
2584
+ * @param as Authorization Server Metadata.
2585
+ * @param client Client Metadata.
2586
+ * @param clientAuthentication Client Authentication Method.
2587
+ * @param parameters Device Authorization Request parameters.
2588
+ *
2589
+ * @returns Resolves with a {@link !Response} to then invoke
2590
+ * {@link processDeviceAuthorizationResponse} with
2591
+ *
2592
+ * @group Device Authorization Grant
2593
+ *
2594
+ * @see [RFC 8628 - OAuth 2.0 Device Authorization Grant](https://www.rfc-editor.org/rfc/rfc8628.html#section-3.1)
2595
+ */
2596
+ export declare function deviceAuthorizationRequest(as: AuthorizationServer, client: Client, clientAuthentication: ClientAuth, parameters: URLSearchParams | Record<string, string> | string[][], options?: DeviceAuthorizationRequestOptions): Promise<Response>;
2597
+ /**
2598
+ * A parsed successful OAuth 2.0 Device Authorization Response.
2599
+ */
2600
+ export interface DeviceAuthorizationResponse {
2601
+ /**
2602
+ * The device verification code
2603
+ */
2604
+ readonly device_code: string;
2605
+ /**
2606
+ * The end-user verification code
2607
+ */
2608
+ readonly user_code: string;
2609
+ /**
2610
+ * The end-user verification URI on the authorization server. The URI should be short and easy to
2611
+ * remember as end users will be asked to manually type it into their user agent.
2612
+ */
2613
+ readonly verification_uri: string;
2614
+ /**
2615
+ * The lifetime in seconds of the "device_code" and "user_code"
2616
+ */
2617
+ readonly expires_in: number;
2618
+ /**
2619
+ * A verification URI that includes the "user_code" (or other information with the same function
2620
+ * as the "user_code"), which is designed for non-textual transmission
2621
+ */
2622
+ readonly verification_uri_complete?: string;
2623
+ /**
2624
+ * The minimum amount of time in seconds that the client should wait between polling requests to
2625
+ * the token endpoint.
2626
+ */
2627
+ readonly interval?: number;
2628
+ readonly [parameter: string]: JsonValue | undefined;
2629
+ }
2630
+ /**
2631
+ * Processes a Device Authorization Response.
2632
+ *
2633
+ * Validates {@link !Response} instance to be one coming from the
2634
+ * {@link AuthorizationServer.device_authorization_endpoint `as.device_authorization_endpoint`}.
2635
+ *
2636
+ * @param as Authorization Server Metadata.
2637
+ * @param client Client Metadata.
2638
+ * @param response Resolved value from {@link deviceAuthorizationRequest}.
2639
+ *
2640
+ * @returns Resolves with an object representing the parsed successful response. OAuth 2.0 protocol
2641
+ * style errors are rejected using {@link ResponseBodyError}. WWW-Authenticate HTTP Header
2642
+ * challenges are rejected with {@link WWWAuthenticateChallengeError}.
2643
+ *
2644
+ * @group Device Authorization Grant
2645
+ *
2646
+ * @see [RFC 8628 - OAuth 2.0 Device Authorization Grant](https://www.rfc-editor.org/rfc/rfc8628.html#section-3.1)
2647
+ */
2648
+ export declare function processDeviceAuthorizationResponse(as: AuthorizationServer, client: Client, response: Response): Promise<DeviceAuthorizationResponse>;
2649
+ /**
2650
+ * Performs a Device Authorization Grant request.
2651
+ *
2652
+ * The request is sent to the {@link AuthorizationServer.token_endpoint `as.token_endpoint`}.
2653
+ *
2654
+ * @param as Authorization Server Metadata.
2655
+ * @param client Client Metadata.
2656
+ * @param clientAuthentication Client Authentication Method.
2657
+ * @param deviceCode Device Code. This is the
2658
+ * {@link DeviceAuthorizationResponse.device_code `device_code`} retrieved from
2659
+ * {@link processDeviceAuthorizationResponse}.
2660
+ *
2661
+ * @returns Resolves with a {@link !Response} to then invoke {@link processDeviceCodeResponse} with
2662
+ *
2663
+ * @group Device Authorization Grant
2664
+ *
2665
+ * @see [RFC 8628 - OAuth 2.0 Device Authorization Grant](https://www.rfc-editor.org/rfc/rfc8628.html#section-3.4)
2666
+ * @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)
2667
+ */
2668
+ export declare function deviceCodeGrantRequest(as: AuthorizationServer, client: Client, clientAuthentication: ClientAuth, deviceCode: string, options?: TokenEndpointRequestOptions): Promise<Response>;
2669
+ /**
2670
+ * Processes a Device Authorization Grant token response.
2671
+ *
2672
+ * Validates Device Authorization Grant {@link !Response} instance to be one coming from the
2673
+ * {@link AuthorizationServer.token_endpoint `as.token_endpoint`}.
2674
+ *
2675
+ * @param as Authorization Server Metadata.
2676
+ * @param client Client Metadata.
2677
+ * @param response Resolved value from {@link deviceCodeGrantRequest}.
2678
+ *
2679
+ * @returns Resolves with an object representing the parsed successful response. OAuth 2.0 protocol
2680
+ * style errors are rejected using {@link ResponseBodyError}. WWW-Authenticate HTTP Header
2681
+ * challenges are rejected with {@link WWWAuthenticateChallengeError}.
2682
+ *
2683
+ * @group Device Authorization Grant
2684
+ *
2685
+ * @see [RFC 8628 - OAuth 2.0 Device Authorization Grant](https://www.rfc-editor.org/rfc/rfc8628.html#section-3.4)
2686
+ */
2687
+ export declare function processDeviceCodeResponse(as: AuthorizationServer, client: Client, response: Response, options?: ProcessTokenResponseOptions): Promise<TokenEndpointResponse>;
2688
+ /**
2689
+ * Options for generating an asymmetric signing key pair.
2690
+ */
2691
+ export interface GenerateKeyPairOptions {
2692
+ /**
2693
+ * Indicates whether or not the private key may be exported. Default is `false`.
2694
+ */
2695
+ extractable?: boolean;
2696
+ /**
2697
+ * (RSA algorithms only) The length, in bits, of the RSA modulus. Default is `2048`.
2698
+ */
2699
+ modulusLength?: number;
2700
+ }
2701
+ /**
2702
+ * Generates a {@link CryptoKeyPair} for a supported JWS `alg` identifier.
2703
+ *
2704
+ * @param alg Supported JWS `alg` Algorithm identifier. Must be a
2705
+ * {@link JWSAlgorithm supported JWS Algorithm}.
2706
+ *
2707
+ * @group Utilities
2708
+ */
2709
+ export declare function generateKeyPair(alg: string, options?: GenerateKeyPairOptions): Promise<CryptoKeyPair>;
2710
+ /**
2711
+ * Claims from a validated JWT access token.
2712
+ */
2713
+ export interface JWTAccessTokenClaims extends JWTPayload {
2714
+ readonly iss: string;
2715
+ readonly exp: number;
2716
+ readonly aud: string | string[];
2717
+ readonly sub: string;
2718
+ readonly iat: number;
2719
+ readonly jti: string;
2720
+ readonly client_id: string;
2721
+ readonly authorization_details?: AuthorizationDetails[];
2722
+ readonly scope?: string;
2723
+ readonly [claim: string]: JsonValue | undefined;
2724
+ }
2725
+ /**
2726
+ * Options for validating a JWT access token at a protected resource.
2727
+ */
2728
+ export interface ValidateJWTAccessTokenOptions extends HttpRequestOptions<'GET'>, JWKSCacheOptions {
2729
+ /**
2730
+ * Indicates whether DPoP use is required.
2731
+ */
2732
+ requireDPoP?: boolean;
2733
+ /**
2734
+ * See {@link clockSkew}.
2735
+ */
2736
+ [clockSkew]?: number;
2737
+ /**
2738
+ * See {@link clockTolerance}.
2739
+ */
2740
+ [clockTolerance]?: number;
2741
+ /**
2742
+ * Supported (or expected) JWT "alg" header parameter values for the JWT Access Token (and DPoP
2743
+ * Proof JWTs). Default is all {@link JWSAlgorithm supported JWS Algorithms}.
2744
+ */
2745
+ signingAlgorithms?: string[];
2746
+ }
2747
+ /**
2748
+ * Validates a resource request's JWT access token according to RFC 6750, RFC 9068, and RFC 9449.
2749
+ *
2750
+ * The only supported means of sending access tokens is via the Authorization Request Header Field
2751
+ * method.
2752
+ *
2753
+ * This does validate the presence and type of all required claims as well as the values of the
2754
+ * {@link JWTAccessTokenClaims.iss `iss`}, {@link JWTAccessTokenClaims.exp `exp`},
2755
+ * {@link JWTAccessTokenClaims.aud `aud`} claims.
2756
+ *
2757
+ * This does NOT validate the {@link JWTAccessTokenClaims.sub `sub`},
2758
+ * {@link JWTAccessTokenClaims.jti `jti`}, and {@link JWTAccessTokenClaims.client_id `client_id`}
2759
+ * claims beyond just checking that they're present and that their type is a string. If you need to
2760
+ * validate these values further you would do so after this function's execution.
2761
+ *
2762
+ * This does NOT validate the DPoP Proof JWT nonce. If your server indicates RS-provided nonces to
2763
+ * clients you would check these after this function's execution.
2764
+ *
2765
+ * This does NOT validate authorization claims such as `scope` either, you would do so after this
2766
+ * function's execution.
2767
+ *
2768
+ * @param as Authorization Server to accept JWT Access Tokens from.
2769
+ * @param expectedAudience Audience identifier the resource server expects for itself.
2770
+ *
2771
+ * @group JWT Access Tokens
2772
+ *
2773
+ * @see [RFC 6750 - OAuth 2.0 Bearer Token Usage](https://www.rfc-editor.org/rfc/rfc6750.html)
2774
+ * @see [RFC 9068 - JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens](https://www.rfc-editor.org/rfc/rfc9068.html)
2775
+ * @see [RFC 9449 - OAuth 2.0 Demonstrating Proof-of-Possession at the Application Layer (DPoP)](https://www.rfc-editor.org/rfc/rfc9449.html)
2776
+ */
2777
+ export declare function validateJwtAccessToken(as: AuthorizationServer, request: Request, expectedAudience: string, options?: ValidateJWTAccessTokenOptions): Promise<JWTAccessTokenClaims>;
2778
+ /**
2779
+ * Options for a Client-Initiated Backchannel Authentication request.
2780
+ */
2781
+ export interface BackchannelAuthenticationRequestOptions extends HttpRequestOptions<'POST', URLSearchParams> {
2782
+ }
2783
+ /**
2784
+ * Performs a Backchannel Authentication Request.
2785
+ *
2786
+ * The request is sent to the
2787
+ * {@link AuthorizationServer.backchannel_authentication_endpoint `as.backchannel_authentication_endpoint`}.
2788
+ *
2789
+ * @param as Authorization Server Metadata.
2790
+ * @param client Client Metadata.
2791
+ * @param clientAuthentication Client Authentication Method.
2792
+ * @param parameters Backchannel Authentication Request parameters.
2793
+ *
2794
+ * @returns Resolves with a {@link !Response} to then invoke
2795
+ * {@link processBackchannelAuthenticationResponse} with
2796
+ *
2797
+ * @group Client-Initiated Backchannel Authentication (CIBA)
2798
+ *
2799
+ * @see [OpenID Connect Client-Initiated Backchannel Authentication](https://openid.net/specs/openid-client-initiated-backchannel-authentication-core-1_0-final.html#auth_request)
2800
+ */
2801
+ export declare function backchannelAuthenticationRequest(as: AuthorizationServer, client: Client, clientAuthentication: ClientAuth, parameters: URLSearchParams | Record<string, string> | string[][], options?: BackchannelAuthenticationRequestOptions): Promise<Response>;
2802
+ /**
2803
+ * A parsed successful Client-Initiated Backchannel Authentication response.
2804
+ */
2805
+ export interface BackchannelAuthenticationResponse {
2806
+ /**
2807
+ * Unique identifier to identify the authentication request.
2808
+ */
2809
+ readonly auth_req_id: string;
2810
+ /**
2811
+ * The lifetime in seconds of the "auth_req_id".
2812
+ */
2813
+ readonly expires_in: number;
2814
+ /**
2815
+ * The minimum amount of time in seconds that the client should wait between polling requests to
2816
+ * the token endpoint.
2817
+ */
2818
+ readonly interval?: number;
2819
+ readonly [parameter: string]: JsonValue | undefined;
2820
+ }
2821
+ /**
2822
+ * Processes a CIBA Backchannel Authentication Response.
2823
+ *
2824
+ * Validates {@link !Response} instance to be one coming from the
2825
+ * {@link AuthorizationServer.backchannel_authentication_endpoint `as.backchannel_authentication_endpoint`}.
2826
+ *
2827
+ * @param as Authorization Server Metadata.
2828
+ * @param client Client Metadata.
2829
+ * @param response Resolved value from {@link backchannelAuthenticationRequest}.
2830
+ *
2831
+ * @returns Resolves with an object representing the parsed successful response. OAuth 2.0 protocol
2832
+ * style errors are rejected using {@link ResponseBodyError}. WWW-Authenticate HTTP Header
2833
+ * challenges are rejected with {@link WWWAuthenticateChallengeError}.
2834
+ *
2835
+ * @group Client-Initiated Backchannel Authentication (CIBA)
2836
+ *
2837
+ * @see [OpenID Connect Client-Initiated Backchannel Authentication](https://openid.net/specs/openid-client-initiated-backchannel-authentication-core-1_0-final.html#auth_request)
2838
+ */
2839
+ export declare function processBackchannelAuthenticationResponse(as: AuthorizationServer, client: Client, response: Response): Promise<BackchannelAuthenticationResponse>;
2840
+ /**
2841
+ * Performs a Backchannel Authentication Grant request.
2842
+ *
2843
+ * The request is sent to the {@link AuthorizationServer.token_endpoint `as.token_endpoint`}.
2844
+ *
2845
+ * @param as Authorization Server Metadata.
2846
+ * @param client Client Metadata.
2847
+ * @param clientAuthentication Client Authentication Method.
2848
+ * @param authReqId Unique identifier to identify the authentication request. This is the
2849
+ * {@link BackchannelAuthenticationResponse.auth_req_id `auth_req_id`} retrieved from
2850
+ * {@link processBackchannelAuthenticationResponse}.
2851
+ *
2852
+ * @returns Resolves with a {@link !Response} to then invoke
2853
+ * {@link processBackchannelAuthenticationGrantResponse} with
2854
+ *
2855
+ * @group Client-Initiated Backchannel Authentication (CIBA)
2856
+ *
2857
+ * @see [OpenID Connect Client-Initiated Backchannel Authentication](https://openid.net/specs/openid-client-initiated-backchannel-authentication-core-1_0-final.html#token_request)
2858
+ * @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)
2859
+ */
2860
+ export declare function backchannelAuthenticationGrantRequest(as: AuthorizationServer, client: Client, clientAuthentication: ClientAuth, authReqId: string, options?: TokenEndpointRequestOptions): Promise<Response>;
2861
+ /**
2862
+ * Processes a CIBA Backchannel Authentication Grant token response.
2863
+ *
2864
+ * Validates Backchannel Authentication Grant {@link !Response} instance to be one coming from the
2865
+ * {@link AuthorizationServer.token_endpoint `as.token_endpoint`}.
2866
+ *
2867
+ * @param as Authorization Server Metadata.
2868
+ * @param client Client Metadata.
2869
+ * @param response Resolved value from {@link backchannelAuthenticationGrantRequest}.
2870
+ *
2871
+ * @returns Resolves with an object representing the parsed successful response. OAuth 2.0 protocol
2872
+ * style errors are rejected using {@link ResponseBodyError}. WWW-Authenticate HTTP Header
2873
+ * challenges are rejected with {@link WWWAuthenticateChallengeError}.
2874
+ *
2875
+ * @group Client-Initiated Backchannel Authentication (CIBA)
2876
+ *
2877
+ * @see [OpenID Connect Client-Initiated Backchannel Authentication](https://openid.net/specs/openid-client-initiated-backchannel-authentication-core-1_0-final.html#token_request)
2878
+ */
2879
+ export declare function processBackchannelAuthenticationGrantResponse(as: AuthorizationServer, client: Client, response: Response, options?: ProcessTokenResponseOptions): Promise<TokenEndpointResponse>;
2880
+ /**
2881
+ * Removes symbol-keyed properties from a type.
2882
+ */
2883
+ export type OmitSymbolProperties<T> = {
2884
+ [K in keyof T as K extends symbol ? never : K]: T[K];
2885
+ };
2886
+ /**
2887
+ * Options for an OAuth 2.0 Dynamic Client Registration request.
2888
+ */
2889
+ export interface DynamicClientRegistrationRequestOptions extends HttpRequestOptions<'POST', string>, DPoPRequestOptions {
2890
+ /**
2891
+ * Access token optionally issued by an authorization server used to authorize calls to the client
2892
+ * registration endpoint.
2893
+ */
2894
+ initialAccessToken?: string;
2895
+ }
2896
+ /**
2897
+ * Performs a Dynamic Client Registration request.
2898
+ *
2899
+ * The request is sent to the
2900
+ * {@link AuthorizationServer.registration_endpoint `as.registration_endpoint`} using the provided
2901
+ * client metadata.
2902
+ *
2903
+ * @param as Authorization Server Metadata.
2904
+ * @param metadata Requested Client Metadata.
2905
+ * @param options
2906
+ *
2907
+ * @returns Resolves with a {@link !Response} to then invoke
2908
+ * {@link processDynamicClientRegistrationResponse} with
2909
+ *
2910
+ * @group Dynamic Client Registration (DCR)
2911
+ *
2912
+ * @see [RFC 7591 - OAuth 2.0 Dynamic Client Registration Protocol (DCR)](https://www.rfc-editor.org/rfc/rfc7591.html#section-3.1)
2913
+ * @see [OpenID Connect Dynamic Client Registration 1.0 (DCR)](https://openid.net/specs/openid-connect-registration-1_0-errata2.html#RegistrationRequest)
2914
+ * @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)
2915
+ */
2916
+ export declare function dynamicClientRegistrationRequest(as: AuthorizationServer, metadata: Partial<OmitSymbolProperties<Client>>, options?: DynamicClientRegistrationRequestOptions): Promise<Response>;
2917
+ /**
2918
+ * Processes a Dynamic Client Registration response.
2919
+ *
2920
+ * Validates {@link !Response} instance to be one coming from the
2921
+ * {@link AuthorizationServer.registration_endpoint `as.registration_endpoint`}.
2922
+ *
2923
+ * @param response Resolved value from {@link dynamicClientRegistrationRequest}.
2924
+ *
2925
+ * @returns Resolves with an object representing the parsed successful response. OAuth 2.0 protocol
2926
+ * style errors are rejected using {@link ResponseBodyError}. WWW-Authenticate HTTP Header
2927
+ * challenges are rejected with {@link WWWAuthenticateChallengeError}.
2928
+ *
2929
+ * @group Dynamic Client Registration (DCR)
2930
+ *
2931
+ * @see [RFC 7591 - OAuth 2.0 Dynamic Client Registration Protocol (DCR)](https://www.rfc-editor.org/rfc/rfc7591.html#section-3.2)
2932
+ * @see [OpenID Connect Dynamic Client Registration 1.0 (DCR)](https://openid.net/specs/openid-connect-registration-1_0-errata2.html#RegistrationResponse)
2933
+ */
2934
+ export declare function processDynamicClientRegistrationResponse(response: Response): Promise<OmitSymbolProperties<Client>>;
2935
+ /**
2936
+ * Metadata describing an OAuth 2.0 protected resource server.
2937
+ *
2938
+ * @group Resource Server Metadata
2939
+ *
2940
+ * @see [IANA OAuth Protected Resource Server Metadata registry](https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#protected-resource-metadata)
2941
+ */
2942
+ export interface ResourceServer {
2943
+ /**
2944
+ * Resource server's Resource Identifier URL.
2945
+ */
2946
+ readonly resource: string;
2947
+ /**
2948
+ * JSON array containing a list of OAuth authorization server issuer identifiers
2949
+ */
2950
+ readonly authorization_servers?: string[];
2951
+ /**
2952
+ * URL of the protected resource's JWK Set document
2953
+ */
2954
+ readonly jwks_uri?: string;
2955
+ /**
2956
+ * JSON array containing a list of the OAuth 2.0 scope values that are used in authorization
2957
+ * requests to request access to this protected resource
2958
+ */
2959
+ readonly scopes_supported?: string[];
2960
+ /**
2961
+ * JSON array containing a list of the OAuth 2.0 Bearer Token presentation methods that this
2962
+ * protected resource supports
2963
+ */
2964
+ readonly bearer_methods_supported?: string[];
2965
+ /**
2966
+ * JSON array containing a list of the JWS signing algorithms (alg values) supported by the
2967
+ * protected resource for signed content
2968
+ */
2969
+ readonly resource_signing_alg_values_supported?: string[];
2970
+ /**
2971
+ * Human-readable name of the protected resource
2972
+ */
2973
+ readonly resource_name?: string;
2974
+ /**
2975
+ * URL of a page containing human-readable information that developers might want or need to know
2976
+ * when using the protected resource
2977
+ */
2978
+ readonly resource_documentation?: string;
2979
+ /**
2980
+ * URL of a page containing human-readable information about the protected resource's requirements
2981
+ * on how the client can use the data provided by the protected resource
2982
+ */
2983
+ readonly resource_policy_uri?: string;
2984
+ /**
2985
+ * URL of a page containing human-readable information about the protected resource's terms of
2986
+ * service
2987
+ */
2988
+ readonly resource_tos_uri?: string;
2989
+ /**
2990
+ * Boolean value indicating protected resource support for mutual-TLS client certificate-bound
2991
+ * access tokens
2992
+ */
2993
+ readonly tls_client_certificate_bound_access_tokens?: boolean;
2994
+ /**
2995
+ * JSON array containing a list of the authorization details type values supported by the resource
2996
+ * server when the authorization_details request parameter is used
2997
+ */
2998
+ readonly authorization_details_types_supported?: string[];
2999
+ /**
3000
+ * JSON array containing a list of the JWS alg values supported by the resource server for
3001
+ * validating DPoP proof JWTs
3002
+ */
3003
+ readonly dpop_signing_alg_values_supported?: string[];
3004
+ /**
3005
+ * Boolean value specifying whether the protected resource always requires the use of DPoP-bound
3006
+ * access tokens
3007
+ */
3008
+ readonly dpop_bound_access_tokens_required?: boolean;
3009
+ /**
3010
+ * Signed JWT containing metadata parameters about the protected resource as claims
3011
+ */
3012
+ readonly signed_metadata?: string;
3013
+ readonly [metadata: string]: JsonValue | undefined;
3014
+ }
3015
+ /**
3016
+ * Performs a protected resource metadata discovery.
3017
+ *
3018
+ * @param resourceIdentifier Protected resource's resource identifier to resolve the well-known
3019
+ * discovery URI for
3020
+ *
3021
+ * @returns Resolves with a {@link !Response} to then invoke {@link processResourceDiscoveryResponse}
3022
+ * with
3023
+ *
3024
+ * @group Resource Server Metadata
3025
+ *
3026
+ * @see [RFC 9728 - OAuth 2.0 Protected Resource Metadata](https://www.rfc-editor.org/rfc/rfc9728.html#name-protected-resource-metadata-)
3027
+ */
3028
+ export declare function resourceDiscoveryRequest(resourceIdentifier: URL, options?: HttpRequestOptions<'GET'>): Promise<Response>;
3029
+ /**
3030
+ * Processes a protected resource metadata discovery response.
3031
+ *
3032
+ * Validates {@link !Response} instance to be one coming from the resource server's well-known
3033
+ * discovery endpoint.
3034
+ *
3035
+ * @param expectedResourceIdentifier Expected Resource Identifier value.
3036
+ * @param response Resolved value from {@link resourceDiscoveryRequest} or from a general
3037
+ * {@link !fetch} following {@link WWWAuthenticateChallengeParameters.resource_metadata}.
3038
+ *
3039
+ * @returns Resolves with the discovered Resource Server Metadata.
3040
+ *
3041
+ * @group Resource Server Metadata
3042
+ *
3043
+ * @see [RFC 9728 - OAuth 2.0 Protected Resource Metadata](https://www.rfc-editor.org/rfc/rfc9728.html#name-protected-resource-metadata-r)
3044
+ */
3045
+ export declare function processResourceDiscoveryResponse(expectedResourceIdentifier: URL, response: Response): Promise<ResourceServer>;
3046
+ export {};