@okta/auth-foundation 0.6.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.MD +136 -0
  2. package/claude.md +256 -0
  3. package/dist/esm/Credential/Credential.js +17 -14
  4. package/dist/esm/Credential/Credential.js.map +1 -1
  5. package/dist/esm/Credential/CredentialCoordinator.js +6 -2
  6. package/dist/esm/Credential/CredentialCoordinator.js.map +1 -1
  7. package/dist/esm/Credential/CredentialDataSource.js +6 -4
  8. package/dist/esm/Credential/CredentialDataSource.js.map +1 -1
  9. package/dist/esm/Credential/TokenStorage.js +3 -0
  10. package/dist/esm/Credential/TokenStorage.js.map +1 -1
  11. package/dist/esm/FetchClient.js +5 -1
  12. package/dist/esm/FetchClient.js.map +1 -1
  13. package/dist/esm/Token.js +1 -0
  14. package/dist/esm/Token.js.map +1 -1
  15. package/dist/esm/TokenOrchestrator.js +4 -1
  16. package/dist/esm/TokenOrchestrator.js.map +1 -1
  17. package/dist/esm/http/APIClient.js +4 -0
  18. package/dist/esm/http/APIClient.js.map +1 -1
  19. package/dist/esm/http/oktaUserAgent.js +1 -1
  20. package/dist/esm/http/requests/APIRequest.js.map +1 -1
  21. package/dist/esm/http/requests/OAuth2Request.js.map +1 -1
  22. package/dist/esm/http/wwwAuthenticate.js.map +1 -1
  23. package/dist/esm/jwt/IDTokenValidator.js +3 -0
  24. package/dist/esm/jwt/IDTokenValidator.js.map +1 -1
  25. package/dist/esm/jwt/JWK.js.map +1 -1
  26. package/dist/esm/jwt/JWT.js.map +1 -1
  27. package/dist/esm/jwt/TokenHashValidator.js.map +1 -1
  28. package/dist/esm/oauth2/client.js +14 -9
  29. package/dist/esm/oauth2/client.js.map +1 -1
  30. package/dist/esm/oauth2/configuration.js +7 -3
  31. package/dist/esm/oauth2/configuration.js.map +1 -1
  32. package/dist/esm/oauth2/dpop/index.js.map +1 -1
  33. package/dist/esm/oauth2/dpop/nonceCache.js.map +1 -1
  34. package/dist/esm/oauth2/dpop/storage.js.map +1 -1
  35. package/dist/esm/oauth2/pkce.js.map +1 -1
  36. package/dist/esm/oauth2/requests/UserInfo.js.map +1 -1
  37. package/dist/esm/platform/Platform.js.map +1 -1
  38. package/dist/esm/platform/defaults.js.map +1 -1
  39. package/dist/esm/types/oauth.js.map +1 -1
  40. package/dist/esm/utils/EventEmitter.js +29 -1
  41. package/dist/esm/utils/EventEmitter.js.map +1 -1
  42. package/dist/esm/utils/TaskBridge.js +13 -0
  43. package/dist/esm/utils/TaskBridge.js.map +1 -1
  44. package/dist/esm/utils/TimeCoordinator.js.map +1 -1
  45. package/dist/esm/utils/merge.js.map +1 -1
  46. package/dist/esm/utils/pause.js.map +1 -1
  47. package/dist/types/Credential/Credential.d.ts +38 -21
  48. package/dist/types/Credential/CredentialCoordinator.d.ts +10 -3
  49. package/dist/types/Credential/CredentialDataSource.d.ts +2 -1
  50. package/dist/types/Credential/TokenStorage.d.ts +13 -2
  51. package/dist/types/FetchClient.d.ts +26 -5
  52. package/dist/types/Token.d.ts +23 -11
  53. package/dist/types/TokenOrchestrator.d.ts +61 -11
  54. package/dist/types/http/APIClient.d.ts +220 -8
  55. package/dist/types/http/index.d.ts +5 -0
  56. package/dist/types/http/requests/APIRequest.d.ts +28 -2
  57. package/dist/types/http/requests/OAuth2Request.d.ts +12 -2
  58. package/dist/types/http/wwwAuthenticate.d.ts +10 -2
  59. package/dist/types/jwt/IDTokenValidator.d.ts +46 -3
  60. package/dist/types/jwt/JWK.d.ts +35 -0
  61. package/dist/types/jwt/JWT.d.ts +126 -4
  62. package/dist/types/jwt/TokenHashValidator.d.ts +6 -0
  63. package/dist/types/oauth2/client.d.ts +95 -11
  64. package/dist/types/oauth2/configuration.d.ts +81 -7
  65. package/dist/types/oauth2/dpop/index.d.ts +10 -5
  66. package/dist/types/oauth2/dpop/nonceCache.d.ts +18 -0
  67. package/dist/types/oauth2/dpop/storage.d.ts +1 -0
  68. package/dist/types/oauth2/dpop/types.d.ts +7 -0
  69. package/dist/types/oauth2/pkce.d.ts +19 -0
  70. package/dist/types/oauth2/requests/UserInfo.d.ts +2 -1
  71. package/dist/types/platform/Platform.d.ts +51 -3
  72. package/dist/types/platform/defaults.d.ts +1 -0
  73. package/dist/types/types/lib.d.ts +16 -2
  74. package/dist/types/types/oauth.d.ts +5 -5
  75. package/dist/types/types/openid.d.ts +50 -234
  76. package/dist/types/utils/EventEmitter.d.ts +84 -2
  77. package/dist/types/utils/TaskBridge.d.ts +9 -1
  78. package/dist/types/utils/TimeCoordinator.d.ts +2 -0
  79. package/dist/types/utils/merge.d.ts +2 -0
  80. package/dist/types/utils/pause.d.ts +1 -0
  81. package/package.json +1 -1
@@ -4,10 +4,13 @@
4
4
  */
5
5
  /**
6
6
  * Interface defining the response payload from `/.well-known/openid-configuration`
7
+ *
8
+ * @see
9
+ * * {@link https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata | OIDC Discovery 1.0 - Provider Metadata}
7
10
  */
8
11
  export interface OpenIdConfiguration {
9
12
  /**
10
- * Authorization server's Issuer Identifier URL.
13
+ * URL of the authorization server.
11
14
  */
12
15
  readonly issuer: string;
13
16
  /**
@@ -23,298 +26,111 @@ export interface OpenIdConfiguration {
23
26
  */
24
27
  readonly jwks_uri?: string;
25
28
  /**
26
- * URL of the authorization server's Dynamic Client Registration Endpoint.
29
+ * URL of the authorization server's UserInfo endpoint.
27
30
  */
28
- readonly registration_endpoint?: string;
29
- /**
30
- * JSON array containing a list of the `scope` values that this authorization server supports.
31
- */
32
- readonly scopes_supported?: string[];
33
- /**
34
- * JSON array containing a list of the `response_type` values that this authorization server
35
- * supports.
36
- */
37
- readonly response_types_supported?: string[];
38
- /**
39
- * JSON array containing a list of the `response_mode` values that this authorization server
40
- * supports.
41
- */
42
- readonly response_modes_supported?: string[];
43
- /**
44
- * JSON array containing a list of the `grant_type` values that this authorization server
45
- * supports.
46
- */
47
- readonly grant_types_supported?: string[];
48
- /**
49
- * JSON array containing a list of client authentication methods supported by this token endpoint.
50
- */
51
- readonly token_endpoint_auth_methods_supported?: string[];
52
- /**
53
- * JSON array containing a list of the JWS signing algorithms supported by the token endpoint for
54
- * the signature on the JWT used to authenticate the client at the token endpoint.
55
- */
56
- readonly token_endpoint_auth_signing_alg_values_supported?: string[];
57
- /**
58
- * URL of a page containing human-readable information that developers might want or need to know
59
- * when using the authorization server.
60
- */
61
- readonly service_documentation?: string;
62
- /**
63
- * Languages and scripts supported for the user interface, represented as a JSON array of language
64
- * tag values from RFC 5646.
65
- */
66
- readonly ui_locales_supported?: string[];
67
- /**
68
- * URL that the authorization server provides to the person registering the client to read about
69
- * the authorization server's requirements on how the client can use the data provided by the
70
- * authorization server.
71
- */
72
- readonly op_policy_uri?: string;
73
- /**
74
- * URL that the authorization server provides to the person registering the client to read about
75
- * the authorization server's terms of service.
76
- */
77
- readonly op_tos_uri?: string;
78
- /**
79
- * URL of the authorization server's revocation endpoint.
80
- */
81
- readonly revocation_endpoint?: string;
82
- /**
83
- * JSON array containing a list of client authentication methods supported by this revocation
84
- * endpoint.
85
- */
86
- readonly revocation_endpoint_auth_methods_supported?: string[];
31
+ readonly userinfo_endpoint?: string;
87
32
  /**
88
- * JSON array containing a list of the JWS signing algorithms supported by the revocation endpoint
89
- * for the signature on the JWT used to authenticate the client at the revocation endpoint.
33
+ * URL of the authorization server's Dynamic Client Registration endpoint.
90
34
  */
91
- readonly revocation_endpoint_auth_signing_alg_values_supported?: string[];
35
+ readonly registration_endpoint?: string;
92
36
  /**
93
37
  * URL of the authorization server's introspection endpoint.
38
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc7662 | RFC 7662 - OAuth 2.0 Token Introspection}
94
39
  */
95
40
  readonly introspection_endpoint?: string;
96
41
  /**
97
- * JSON array containing a list of client authentication methods supported by this introspection
98
- * endpoint.
42
+ * `token_endpoint_auth_methods_supported` values accepted by {@link OpenIdConfiguration.introspection_endpoint}
99
43
  */
100
44
  readonly introspection_endpoint_auth_methods_supported?: string[];
101
45
  /**
102
- * JSON array containing a list of the JWS signing algorithms supported by the introspection
103
- * endpoint for the signature on the JWT used to authenticate the client at the introspection
104
- * endpoint.
46
+ * URL of the authorization server's token revocation endpoint.
47
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc7009 | RFC 7009 - OAuth 2.0 Token Revocation}
105
48
  */
106
- readonly introspection_endpoint_auth_signing_alg_values_supported?: string[];
49
+ readonly revocation_endpoint?: string;
107
50
  /**
108
- * PKCE code challenge methods supported by this authorization server.
51
+ * `token_endpoint_auth_methods_supported` values accepted by {@link OpenIdConfiguration.revocation_endpoint}
109
52
  */
110
- readonly code_challenge_methods_supported?: string[];
53
+ readonly revocation_endpoint_auth_methods_supported?: string[];
111
54
  /**
112
- * Signed JWT containing metadata values about the authorization server as claims.
55
+ * URL of the authorization server's RP-Initiated Logout endpoint.
56
+ * @see {@link https://openid.net/specs/openid-connect-rpinitiated-1_0.html | OIDC RP-Initiated Logout 1.0}
113
57
  */
114
- readonly signed_metadata?: string;
58
+ readonly end_session_endpoint?: string;
115
59
  /**
116
- * URL of the authorization server's device authorization endpoint.
60
+ * URL of the authorization server's Device Authorization endpoint.
61
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc8628 | RFC 8628 - OAuth 2.0 Device Authorization Grant}
117
62
  */
118
63
  readonly device_authorization_endpoint?: string;
119
64
  /**
120
- * Indicates authorization server support for mutual-TLS client certificate-bound access tokens.
65
+ * URL of the authorization server's Pushed Authorization Request endpoint.
66
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc9126 | RFC 9126 - OAuth 2.0 Pushed Authorization Requests}
121
67
  */
122
- readonly tls_client_certificate_bound_access_tokens?: boolean;
68
+ readonly pushed_authorization_request_endpoint?: string;
123
69
  /**
124
- * JSON object containing alternative authorization server endpoints, which a client intending to
125
- * do mutual TLS will use in preference to the conventional endpoints.
70
+ * `response_type` values this authorization server supports
126
71
  */
72
+ readonly response_types_supported?: string[];
127
73
  /**
128
- * URL of the authorization server's UserInfo Endpoint.
74
+ * `response_mode` values this authorization server supports
129
75
  */
130
- readonly userinfo_endpoint?: string;
76
+ readonly response_modes_supported?: string[];
131
77
  /**
132
- * JSON array containing a list of the Authentication Context Class References that this
133
- * authorization server supports.
78
+ * `grant_type` values this authorization server supports
134
79
  */
135
- readonly acr_values_supported?: string[];
80
+ readonly grant_types_supported?: string[];
136
81
  /**
137
- * JSON array containing a list of the Subject Identifier types that this authorization server
138
- * supports.
82
+ * Subject Identifier types this authorization server supports, e.g. `pairwise` or `public`
139
83
  */
140
84
  readonly subject_types_supported?: string[];
141
85
  /**
142
- * JSON array containing a list of the JWS `alg` values supported by the authorization server for
143
- * the ID Token.
86
+ * JWS `alg` values supported for signing ID Tokens
144
87
  */
145
88
  readonly id_token_signing_alg_values_supported?: string[];
146
89
  /**
147
- * JSON array containing a list of the JWE `alg` values supported by the authorization server for
148
- * the ID Token.
90
+ * JWE `alg` values supported for encrypting ID Tokens
149
91
  */
150
92
  readonly id_token_encryption_alg_values_supported?: string[];
151
93
  /**
152
- * JSON array containing a list of the JWE `enc` values supported by the authorization server for
153
- * the ID Token.
94
+ * JWE `enc` values supported for encrypting ID Tokens
154
95
  */
155
96
  readonly id_token_encryption_enc_values_supported?: string[];
156
97
  /**
157
- * JSON array containing a list of the JWS `alg` values supported by the UserInfo Endpoint.
158
- */
159
- readonly userinfo_signing_alg_values_supported?: string[];
160
- /**
161
- * JSON array containing a list of the JWE `alg` values supported by the UserInfo Endpoint.
162
- */
163
- readonly userinfo_encryption_alg_values_supported?: string[];
164
- /**
165
- * JSON array containing a list of the JWE `enc` values supported by the UserInfo Endpoint.
166
- */
167
- readonly userinfo_encryption_enc_values_supported?: string[];
168
- /**
169
- * JSON array containing a list of the JWS `alg` values supported by the authorization server for
170
- * Request Objects.
171
- */
172
- readonly request_object_signing_alg_values_supported?: string[];
173
- /**
174
- * JSON array containing a list of the JWE `alg` values supported by the authorization server for
175
- * Request Objects.
98
+ * OAuth2 `scope` values this authorization server supports
176
99
  */
177
- readonly request_object_encryption_alg_values_supported?: string[];
178
- /**
179
- * JSON array containing a list of the JWE `enc` values supported by the authorization server for
180
- * Request Objects.
181
- */
182
- readonly request_object_encryption_enc_values_supported?: string[];
183
- /**
184
- * JSON array containing a list of the `display` parameter values that the authorization server
185
- * supports.
186
- */
187
- readonly display_values_supported?: string[];
100
+ readonly scopes_supported?: string[];
188
101
  /**
189
- * JSON array containing a list of the Claim Types that the authorization server supports.
102
+ * Client authentication methods supported by {@link OpenIdConfiguration.token_endpoint}
190
103
  */
191
- readonly claim_types_supported?: string[];
104
+ readonly token_endpoint_auth_methods_supported?: string[];
192
105
  /**
193
- * JSON array containing a list of the Claim Names of the Claims that the authorization server MAY
194
- * be able to supply values for.
106
+ * Claim names the authorization server may include in an ID Token or from the {@link OpenIdConfiguration.userinfo_endpoint}
195
107
  */
196
108
  readonly claims_supported?: string[];
197
109
  /**
198
- * Languages and scripts supported for values in Claims being returned, represented as a JSON
199
- * array of RFC 5646 language tag values.
110
+ * PKCE `code_challenge_method` values this authorization server supports
111
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc7636 | RFC 7636 - Proof Key for Code Exchange (PKCE)}
200
112
  */
201
- readonly claims_locales_supported?: string[];
202
- /**
203
- * Boolean value specifying whether the authorization server supports use of the `claims`
204
- * parameter.
205
- */
206
- readonly claims_parameter_supported?: boolean;
113
+ readonly code_challenge_methods_supported?: string[];
207
114
  /**
208
- * Boolean value specifying whether the authorization server supports use of the `request`
209
- * parameter.
115
+ * Whether this authorization server supports use of the `request` parameter
210
116
  */
211
117
  readonly request_parameter_supported?: boolean;
212
118
  /**
213
- * Boolean value specifying whether the authorization server supports use of the `request_uri`
214
- * parameter.
215
- */
216
- readonly request_uri_parameter_supported?: boolean;
217
- /**
218
- * Boolean value specifying whether the authorization server requires any `request_uri` values
219
- * used to be pre-registered.
220
- */
221
- readonly require_request_uri_registration?: boolean;
222
- /**
223
- * Indicates where authorization request needs to be protected as Request Object and provided
224
- * through either `request` or `request_uri` parameter.
225
- */
226
- readonly require_signed_request_object?: boolean;
227
- /**
228
- * URL of the authorization server's pushed authorization request endpoint.
229
- */
230
- readonly pushed_authorization_request_endpoint?: string;
231
- /**
232
- * Indicates whether the authorization server accepts authorization requests only via PAR.
233
- */
234
- readonly require_pushed_authorization_requests?: boolean;
235
- /**
236
- * JSON array containing a list of algorithms supported by the authorization server for
237
- * introspection response signing.
238
- */
239
- readonly introspection_signing_alg_values_supported?: string[];
240
- /**
241
- * JSON array containing a list of algorithms supported by the authorization server for
242
- * introspection response content key encryption (`alg` value).
243
- */
244
- readonly introspection_encryption_alg_values_supported?: string[];
245
- /**
246
- * JSON array containing a list of algorithms supported by the authorization server for
247
- * introspection response content encryption (`enc` value).
248
- */
249
- readonly introspection_encryption_enc_values_supported?: string[];
250
- /**
251
- * Boolean value indicating whether the authorization server provides the `iss` parameter in the
252
- * authorization response.
119
+ * JWS `alg` values supported for signing a JWT-encoded `request` parameter object
253
120
  */
254
- readonly authorization_response_iss_parameter_supported?: boolean;
255
- /**
256
- * JSON array containing a list of algorithms supported by the authorization server for
257
- * introspection response signing.
258
- */
259
- readonly authorization_signing_alg_values_supported?: string[];
260
- /**
261
- * JSON array containing a list of algorithms supported by the authorization server for
262
- * introspection response encryption (`alg` value).
263
- */
264
- readonly authorization_encryption_alg_values_supported?: string[];
265
- /**
266
- * JSON array containing a list of algorithms supported by the authorization server for
267
- * introspection response encryption (`enc` value).
268
- */
269
- readonly authorization_encryption_enc_values_supported?: string[];
270
- /**
271
- * CIBA Backchannel Authentication Endpoint.
272
- */
273
- readonly backchannel_authentication_endpoint?: string;
274
- /**
275
- * JSON array containing a list of the JWS signing algorithms supported for validation of signed
276
- * CIBA authentication requests.
277
- */
278
- readonly backchannel_authentication_request_signing_alg_values_supported?: string[];
121
+ readonly request_object_signing_alg_values_supported?: string[];
279
122
  /**
280
- * Supported CIBA authentication result delivery modes.
123
+ * Delivery modes this authorization server supports for CIBA
124
+ * @see {@link https://openid.net/specs/openid-client-initiated-backchannel-authentication-core-1_0.html | OIDC CIBA Core 1.0}
281
125
  */
282
126
  readonly backchannel_token_delivery_modes_supported?: string[];
283
127
  /**
284
- * Indicates whether the authorization server supports the use of the CIBA `user_code` parameter.
285
- */
286
- readonly backchannel_user_code_parameter_supported?: boolean;
287
- /**
288
- * URL of an authorization server iframe that supports cross-origin communications for session
289
- * state information with the RP Client, using the HTML5 postMessage API.
128
+ * JWS `alg` values supported for signing CIBA authentication request objects
290
129
  */
291
- readonly check_session_iframe?: string;
130
+ readonly backchannel_authentication_request_signing_alg_values_supported?: string[];
292
131
  /**
293
- * JSON array containing a list of the JWS algorithms supported for DPoP proof JWTs.
132
+ * JWS `alg` values supported for DPoP proof JWTs
133
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc9449 | RFC 9449 - OAuth 2.0 Demonstrating Proof of Possession (DPoP)}
294
134
  */
295
135
  readonly dpop_signing_alg_values_supported?: string[];
296
- /**
297
- * URL at the authorization server to which an RP can perform a redirect to request that the
298
- * End-User be logged out at the authorization server.
299
- */
300
- readonly end_session_endpoint?: string;
301
- /**
302
- * Boolean value specifying whether the authorization server can pass `iss` (issuer) and `sid`
303
- * (session ID) query parameters to identify the RP session with the authorization server when the
304
- * `frontchannel_logout_uri` is used.
305
- */
306
- readonly frontchannel_logout_session_supported?: boolean;
307
- /**
308
- * Boolean value specifying whether the authorization server supports HTTP-based logout.
309
- */
310
- readonly frontchannel_logout_supported?: boolean;
311
- /**
312
- * Boolean value specifying whether the authorization server can pass a `sid` (session ID) Claim
313
- * in the Logout Token to identify the RP session with the OP.
314
- */
315
- readonly backchannel_logout_session_supported?: boolean;
316
- /**
317
- * Boolean value specifying whether the authorization server supports back-channel logout.
318
- */
319
- readonly backchannel_logout_supported?: boolean;
320
136
  }
@@ -2,28 +2,110 @@
2
2
  * @module
3
3
  * @mergeModuleWith Core
4
4
  */
5
+ /** @inline */
5
6
  type EventMap = {
6
7
  [event: string]: any;
7
8
  };
8
- type EventListener<T> = T extends void ? () => void : (event: T) => void;
9
9
  /**
10
+ * A {@link EventEmitter} listener `function`.
11
+ * @public
12
+ * @typeParam T - The structure of the event payload
13
+ */
14
+ export type EventListener<T> = T extends void ? () => void : (event: T) => void;
15
+ type EventListenerOptions = {
16
+ signal: AbortSignal;
17
+ };
18
+ /**
19
+ * Subscription-only view of an {@link EventEmitter}, exposing just `on`/`off`.
20
+ * Useful for handing consumers a way to listen for events without also
21
+ * granting them the ability to `emit` or `relay` events.
10
22
  * @group EventEmitter
23
+ * @typeParam E - A map of possible events where the `key` is the event name
24
+ * and the `value` is the event payload structure
11
25
  */
12
26
  export interface Emitter<E extends EventMap> {
13
27
  on: (...args: Parameters<EventEmitter<E>['on']>) => void;
14
28
  off: (...args: Parameters<EventEmitter<E>['off']>) => void;
15
29
  }
16
30
  /**
31
+ * An object that implements the publish-subscribe pattern, allowing different parts of an
32
+ * application to communicate asynchronously through events
17
33
  * @group EventEmitter
34
+ * @typeParam Events - A map of possible events where the `key` is the event name
35
+ * and the `value` is the event payload structure
18
36
  */
19
37
  export declare class EventEmitter<Events extends EventMap> {
38
+ /** @internal */
20
39
  listeners: {
21
40
  [K in keyof Events]?: Array<EventListener<Events[K]>>;
22
41
  };
23
- on<K extends keyof Events>(eventName: K, handler: EventListener<Events[K]>): this;
42
+ signals: Map<keyof Events, WeakMap<(...arg: any[]) => void, {
43
+ signal: AbortSignal;
44
+ abortHandler: () => void;
45
+ }>>;
46
+ /**
47
+ * Binds a listener function to a specific event
48
+ * @typeParam K - The event name (also the key within `Events`)
49
+ */
50
+ on<K extends keyof Events>(eventName: K, handler: EventListener<Events[K]>, options?: Partial<EventListenerOptions>): this;
51
+ /**
52
+ * When a `handler` is provided, it is removed as a listener to the specified event `eventName`.
53
+ *
54
+ * When no `handler` is provided, all listeners for the specified event are removed.
55
+ *
56
+ * @typeParam K - The event name (also the key within `Events`)
57
+ *
58
+ * @remarks
59
+ * This method will no-op if the `function` provided as `handler` is not a registered listener
60
+ * to the provided `eventName`
61
+ */
24
62
  off<K extends keyof Events>(eventName: K, handler?: EventListener<Events[K]>): this;
63
+ /** @internal removes the `AbortSignal` registration (if any) associated with `handler` for `eventName` */
64
+ protected detachSignal<K extends keyof Events>(eventName: K, handler: EventListener<any>): void;
65
+ /**
66
+ * Synchronously calls each of the listeners registered for the event named `eventName`,
67
+ * in the order they were registered, passing the supplied `data` to each.
68
+ *
69
+ * @typeParam K - The event name (also the key within `Events`)
70
+ *
71
+ * @remarks
72
+ * `data` will be type checked to match the `Events` map. A `TS` error will occur if the
73
+ * `object` provided as `data` does not match the type defined at `Events[K]`.
74
+ */
25
75
  emit<K extends keyof Events>(eventName: K, data: Events[K]): void;
26
76
  emit<K extends keyof Events>(eventName: K): void;
77
+ /**
78
+ * Relays the specified events in `events` from `emitter` (or "relay-ee"). The "relay-er" (`this`) will relay all
79
+ * events emitted from the "relay-ee"
80
+ *
81
+ * @typeParam FromEvents - The `Events` map from the "relay-ee" `emitter`. This type param will
82
+ * be inferred and does not need to be explicitly provided.
83
+ * @typeParam K - The event name (also the key within `Events` OR `FromEvents`)
84
+ *
85
+ * @remarks
86
+ * The possibility of both emitters `Events` maps containing the same `key` (event name) has not been tested.
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * type WeekdayEvents = { "work": { foo: number } };
91
+ * type WeekendEvents = { "play": { bar: string } };
92
+ *
93
+ * const weekday = new EventEmitter<WeekdayEvents>();
94
+ * const weekend = new EventEmitter<WeekendEvents>();
95
+ *
96
+ * // for the types to work properly, the `Events` map of the relaying `EventEmitter`
97
+ * // must contain all events which will be relayed
98
+ * const daily = new EventEmitter<WeekdayEvents & WeekendEvents>();
99
+ * daily.relay(weekday, ['work']);
100
+ * daily.relay(weekend, ['play']);
101
+ *
102
+ * daily.on('play', (({ bar }) => { console.log(`yay fun ${bar}!`) });
103
+ * daily.on('work', (({ foo }) => { console.log(`boooo ${foo}!`) });
104
+ *
105
+ * weekday.emit('work', { foo: 1 }); // will fire `daily.on('work', ...)`;
106
+ * ```
107
+ */
27
108
  relay<FromEvents extends EventMap, K extends keyof Events & keyof FromEvents = keyof Events & keyof FromEvents>(emitter: EventEmitter<FromEvents>, events: K[]): void;
109
+ clear(): this;
28
110
  }
29
111
  export {};
@@ -1,6 +1,9 @@
1
1
  import type { BroadcastChannelLike } from '../types/index.ts';
2
2
  import { AuthSdkError } from '../errors/AuthSdkError.ts';
3
- /** @useDeclaredType */
3
+ /**
4
+ * @useDeclaredType
5
+ * @inline
6
+ */
4
7
  type TypeMap = Record<string, any>;
5
8
  /**
6
9
  * A bridge for passing messages between a `TaskHandler` and a `Requestor`. The `Requestor` is "asking" the `TaskHandler`
@@ -43,6 +46,11 @@ export declare abstract class TaskBridge<M extends TypeMap, R extends TypeMap> {
43
46
  }
44
47
  export declare namespace TaskBridge {
45
48
  const BridgeVersion = 2;
49
+ /**
50
+ * Toggles whether `console.warn` messages are broadcasted when bus messages are received with
51
+ * a mismatched BridgeVersion. Useful for debugging communication issues.
52
+ */
53
+ let warnOnBusMessageMismatch: boolean;
46
54
  /**
47
55
  * Possible `status` values indicating the process of an orchestrated request
48
56
  */
@@ -29,6 +29,7 @@ export declare class Timestamp {
29
29
  timeSinceNow(): number;
30
30
  }
31
31
  /**
32
+ * A sourece-of-truth for the current time.
32
33
  * @group TimeCoordinator
33
34
  */
34
35
  export interface TimeCoordinator {
@@ -38,6 +39,7 @@ export interface TimeCoordinator {
38
39
  }
39
40
  /**
40
41
  * @group TimeCoordinator
42
+ * @internal
41
43
  */
42
44
  export declare class DefaultTimeCoordinator implements TimeCoordinator {
43
45
  #private;
@@ -6,11 +6,13 @@
6
6
  * Merges `n` number of {@link !URLSearchParams} instances
7
7
  *
8
8
  * @group Utils
9
+ * @internal
9
10
  */
10
11
  export declare function mergeURLSearchParameters(target: URLSearchParams, ...source: (URLSearchParams | Record<string, string | undefined>)[]): URLSearchParams;
11
12
  /**
12
13
  * Merges `n` number of {@link !Headers} instances
13
14
  *
14
15
  * @group Utils
16
+ * @internal
15
17
  */
16
18
  export declare function mergeHeaders(target: Headers, ...source: (Headers | Record<string, string | undefined>)[]): Headers;
@@ -11,5 +11,6 @@
11
11
  * @param ms - length of delay in milliseconds
12
12
  *
13
13
  * @group Utils
14
+ * @internal
14
15
  */
15
16
  export declare function pause(ms: number): Promise<unknown>;
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@okta/auth-foundation","version":"0.6.0","type":"module","main":"dist/esm/index.js","module":"dist/esm/index.js","types":"dist/types/index.d.ts","author":"jared.perreault@okta.com","license":"Apache-2.0","engines":{"node":">=20.11.0"},"files":["./LICENSE","./dist","*.md","package.json"],"exports":{".":{"types":"./dist/types/index.d.ts","import":"./dist/esm/index.js"},"./core":{"types":"./dist/types/core.d.ts","import":"./dist/esm/core.js"},"./client":{"types":"./dist/types/client.d.ts","import":"./dist/esm/client.js"},"./internal":{"types":"./dist/types/internal.d.ts","import":"./dist/esm/internal.js"},"./package.json":"./package.json"},"sideEffects":["./src/oktaUserAgent.ts"],"scripts":{"lint":"eslint --ext .js,.ts,.jsx .","build":"yarn build:esm && yarn build:types","build:watch":"rollup -c --watch & tsc --watch","build:esm":"rollup -c","build:types":"tsc","test":"yarn test:unit","test:unit":"jest","test:watch":"jest --watchAll","test:browser":"jest --config jest.browser.config.js","test:node":"jest --config jest.node.config.js"},"dependencies":{},"devDependencies":{"@repo/eslint-config":"*","@repo/rollup-config":"*","@repo/typescript-config":"*","eslint":"^8.56.0","rollup":"^4.52.4","jest":"^29.7.0","typescript":"^5.9.2"},"devEngines":{"runtime":{"name":"node","version":">=22.13.1","onFail":"warn"},"packageManager":{"name":"yarn","version":">=1.19.0","onFail":"warn"}},"okta":{"commitSha":"533d076fb5f59d4214751d8414be8f0f3adac2f5","fullVersion":"0.6.0-g533d076-g533d076"}}
1
+ {"name":"@okta/auth-foundation","version":"0.9.0","type":"module","main":"dist/esm/index.js","module":"dist/esm/index.js","types":"dist/types/index.d.ts","license":"Apache-2.0","engines":{"node":">=20.11.0"},"files":["./LICENSE","./dist","*.md","package.json"],"exports":{".":{"types":"./dist/types/index.d.ts","import":"./dist/esm/index.js"},"./core":{"types":"./dist/types/core.d.ts","import":"./dist/esm/core.js"},"./internal":{"types":"./dist/types/internal.d.ts","import":"./dist/esm/internal.js"},"./package.json":"./package.json"},"sideEffects":["./src/index.ts","./src/oktaUserAgent.ts","./dist/esm/index.js","./dist/esm/oktaUserAgent.ts"],"scripts":{"lint":"eslint --ext .js,.ts,.jsx .","build":"yarn build:esm && yarn build:types","build:watch":"rollup -c --watch & tsc --watch","build:esm":"rollup -c","build:types":"tsc","test":"yarn test:unit","test:unit":"jest","test:watch":"jest --watchAll","test:browser":"jest --config jest.browser.config.js","test:node":"jest --config jest.node.config.js"},"dependencies":{},"devDependencies":{"@repo/eslint-config":"*","@repo/rollup-config":"*","@repo/typescript-config":"*","eslint":"^8.56.0","rollup":"^4.52.4","jest":"^29.7.0","typescript":"^5.9.2"},"devEngines":{"runtime":{"name":"node","version":">=22.13.1","onFail":"warn"},"packageManager":{"name":"yarn","version":">=1.19.0","onFail":"warn"}},"okta":{"commitSha":"a777274f98680847ae55a4d34a7101e07104c359","fullVersion":"0.9.0-ga777274-ga777274"}}