@okta/auth-foundation 0.6.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 (168) hide show
  1. package/LICENSE +189 -0
  2. package/THIRD-PARTY-NOTICES.md +5 -0
  3. package/dist/esm/Credential/Credential.js +219 -0
  4. package/dist/esm/Credential/Credential.js.map +1 -0
  5. package/dist/esm/Credential/CredentialCoordinator.js +160 -0
  6. package/dist/esm/Credential/CredentialCoordinator.js.map +1 -0
  7. package/dist/esm/Credential/CredentialDataSource.js +61 -0
  8. package/dist/esm/Credential/CredentialDataSource.js.map +1 -0
  9. package/dist/esm/Credential/TokenStorage.js +99 -0
  10. package/dist/esm/Credential/TokenStorage.js.map +1 -0
  11. package/dist/esm/FetchClient.js +91 -0
  12. package/dist/esm/FetchClient.js.map +1 -0
  13. package/dist/esm/Token.js +274 -0
  14. package/dist/esm/Token.js.map +1 -0
  15. package/dist/esm/TokenOrchestrator.js +56 -0
  16. package/dist/esm/TokenOrchestrator.js.map +1 -0
  17. package/dist/esm/core.js +59 -0
  18. package/dist/esm/core.js.map +1 -0
  19. package/dist/esm/crypto/index.js +60 -0
  20. package/dist/esm/crypto/index.js.map +1 -0
  21. package/dist/esm/errors/APIClientError.js +19 -0
  22. package/dist/esm/errors/APIClientError.js.map +1 -0
  23. package/dist/esm/errors/AuthSdkError.js +22 -0
  24. package/dist/esm/errors/AuthSdkError.js.map +1 -0
  25. package/dist/esm/errors/CredentialError.js +19 -0
  26. package/dist/esm/errors/CredentialError.js.map +1 -0
  27. package/dist/esm/errors/DPoPError.js +19 -0
  28. package/dist/esm/errors/DPoPError.js.map +1 -0
  29. package/dist/esm/errors/JWTError.js +19 -0
  30. package/dist/esm/errors/JWTError.js.map +1 -0
  31. package/dist/esm/errors/NetworkError.js +19 -0
  32. package/dist/esm/errors/NetworkError.js.map +1 -0
  33. package/dist/esm/errors/OAuth2Error.js +34 -0
  34. package/dist/esm/errors/OAuth2Error.js.map +1 -0
  35. package/dist/esm/errors/TokenError.js +19 -0
  36. package/dist/esm/errors/TokenError.js.map +1 -0
  37. package/dist/esm/errors/TokenOrchestratorError.js +19 -0
  38. package/dist/esm/errors/TokenOrchestratorError.js.map +1 -0
  39. package/dist/esm/http/APIClient.js +172 -0
  40. package/dist/esm/http/APIClient.js.map +1 -0
  41. package/dist/esm/http/oktaUserAgent.js +23 -0
  42. package/dist/esm/http/oktaUserAgent.js.map +1 -0
  43. package/dist/esm/http/requests/APIRequest.js +41 -0
  44. package/dist/esm/http/requests/APIRequest.js.map +1 -0
  45. package/dist/esm/http/requests/OAuth2Request.js +38 -0
  46. package/dist/esm/http/requests/OAuth2Request.js.map +1 -0
  47. package/dist/esm/http/wwwAuthenticate.js +48 -0
  48. package/dist/esm/http/wwwAuthenticate.js.map +1 -0
  49. package/dist/esm/index.js +64 -0
  50. package/dist/esm/index.js.map +1 -0
  51. package/dist/esm/internal.js +17 -0
  52. package/dist/esm/internal.js.map +1 -0
  53. package/dist/esm/jwt/IDTokenValidator.js +115 -0
  54. package/dist/esm/jwt/IDTokenValidator.js.map +1 -0
  55. package/dist/esm/jwt/JWK.js +48 -0
  56. package/dist/esm/jwt/JWK.js.map +1 -0
  57. package/dist/esm/jwt/JWT.js +159 -0
  58. package/dist/esm/jwt/JWT.js.map +1 -0
  59. package/dist/esm/jwt/TokenHashValidator.js +44 -0
  60. package/dist/esm/jwt/TokenHashValidator.js.map +1 -0
  61. package/dist/esm/oauth2/client.js +386 -0
  62. package/dist/esm/oauth2/client.js.map +1 -0
  63. package/dist/esm/oauth2/configuration.js +86 -0
  64. package/dist/esm/oauth2/configuration.js.map +1 -0
  65. package/dist/esm/oauth2/dpop/index.js +84 -0
  66. package/dist/esm/oauth2/dpop/index.js.map +1 -0
  67. package/dist/esm/oauth2/dpop/nonceCache.js +31 -0
  68. package/dist/esm/oauth2/dpop/nonceCache.js.map +1 -0
  69. package/dist/esm/oauth2/dpop/storage.js +39 -0
  70. package/dist/esm/oauth2/dpop/storage.js.map +1 -0
  71. package/dist/esm/oauth2/pkce.js +33 -0
  72. package/dist/esm/oauth2/pkce.js.map +1 -0
  73. package/dist/esm/oauth2/requests/UserInfo.js +40 -0
  74. package/dist/esm/oauth2/requests/UserInfo.js.map +1 -0
  75. package/dist/esm/platform/Platform.js +54 -0
  76. package/dist/esm/platform/Platform.js.map +1 -0
  77. package/dist/esm/platform/defaults.js +28 -0
  78. package/dist/esm/platform/defaults.js.map +1 -0
  79. package/dist/esm/types/oauth.js +41 -0
  80. package/dist/esm/types/oauth.js.map +1 -0
  81. package/dist/esm/utils/EventEmitter.js +63 -0
  82. package/dist/esm/utils/EventEmitter.js.map +1 -0
  83. package/dist/esm/utils/PromiseQueue.js +50 -0
  84. package/dist/esm/utils/PromiseQueue.js.map +1 -0
  85. package/dist/esm/utils/TaskBridge.js +242 -0
  86. package/dist/esm/utils/TaskBridge.js.map +1 -0
  87. package/dist/esm/utils/TimeCoordinator.js +77 -0
  88. package/dist/esm/utils/TimeCoordinator.js.map +1 -0
  89. package/dist/esm/utils/buildUrl.js +23 -0
  90. package/dist/esm/utils/buildUrl.js.map +1 -0
  91. package/dist/esm/utils/equality.js +38 -0
  92. package/dist/esm/utils/equality.js.map +1 -0
  93. package/dist/esm/utils/getSearchParam.js +24 -0
  94. package/dist/esm/utils/getSearchParam.js.map +1 -0
  95. package/dist/esm/utils/hashObject.js +30 -0
  96. package/dist/esm/utils/hashObject.js.map +1 -0
  97. package/dist/esm/utils/ignoreUndefineds.js +24 -0
  98. package/dist/esm/utils/ignoreUndefineds.js.map +1 -0
  99. package/dist/esm/utils/merge.js +47 -0
  100. package/dist/esm/utils/merge.js.map +1 -0
  101. package/dist/esm/utils/pause.js +20 -0
  102. package/dist/esm/utils/pause.js.map +1 -0
  103. package/dist/esm/utils/toRelativeUrl.js +19 -0
  104. package/dist/esm/utils/toRelativeUrl.js.map +1 -0
  105. package/dist/esm/utils/validators.js +32 -0
  106. package/dist/esm/utils/validators.js.map +1 -0
  107. package/dist/types/Credential/Credential.d.ts +292 -0
  108. package/dist/types/Credential/CredentialCoordinator.d.ts +103 -0
  109. package/dist/types/Credential/CredentialDataSource.d.ts +75 -0
  110. package/dist/types/Credential/TokenStorage.d.ts +116 -0
  111. package/dist/types/Credential/index.d.ts +8 -0
  112. package/dist/types/FetchClient.d.ts +28 -0
  113. package/dist/types/Token.d.ts +246 -0
  114. package/dist/types/TokenOrchestrator.d.ts +64 -0
  115. package/dist/types/core.d.ts +21 -0
  116. package/dist/types/crypto/index.d.ts +32 -0
  117. package/dist/types/errors/APIClientError.d.ts +12 -0
  118. package/dist/types/errors/AuthSdkError.d.ts +20 -0
  119. package/dist/types/errors/CredentialError.d.ts +12 -0
  120. package/dist/types/errors/DPoPError.d.ts +12 -0
  121. package/dist/types/errors/JWTError.d.ts +12 -0
  122. package/dist/types/errors/NetworkError.d.ts +12 -0
  123. package/dist/types/errors/OAuth2Error.d.ts +17 -0
  124. package/dist/types/errors/TokenError.d.ts +12 -0
  125. package/dist/types/errors/TokenOrchestratorError.d.ts +12 -0
  126. package/dist/types/errors/index.d.ts +13 -0
  127. package/dist/types/http/APIClient.d.ts +113 -0
  128. package/dist/types/http/index.d.ts +6 -0
  129. package/dist/types/http/oktaUserAgent.d.ts +8 -0
  130. package/dist/types/http/requests/APIRequest.d.ts +19 -0
  131. package/dist/types/http/requests/OAuth2Request.d.ts +30 -0
  132. package/dist/types/http/wwwAuthenticate.d.ts +32 -0
  133. package/dist/types/index.d.ts +4 -0
  134. package/dist/types/internal.d.ts +8 -0
  135. package/dist/types/jwt/IDTokenValidator.d.ts +38 -0
  136. package/dist/types/jwt/JWK.d.ts +31 -0
  137. package/dist/types/jwt/JWT.d.ts +107 -0
  138. package/dist/types/jwt/TokenHashValidator.d.ts +13 -0
  139. package/dist/types/jwt/index.d.ts +8 -0
  140. package/dist/types/oauth2/client.d.ts +120 -0
  141. package/dist/types/oauth2/configuration.d.ts +56 -0
  142. package/dist/types/oauth2/dpop/index.d.ts +70 -0
  143. package/dist/types/oauth2/dpop/nonceCache.d.ts +27 -0
  144. package/dist/types/oauth2/dpop/storage.d.ts +27 -0
  145. package/dist/types/oauth2/dpop/types.d.ts +52 -0
  146. package/dist/types/oauth2/pkce.d.ts +23 -0
  147. package/dist/types/oauth2/requests/UserInfo.d.ts +32 -0
  148. package/dist/types/platform/Platform.d.ts +121 -0
  149. package/dist/types/platform/defaults.d.ts +10 -0
  150. package/dist/types/types/index.d.ts +6 -0
  151. package/dist/types/types/lib.d.ts +106 -0
  152. package/dist/types/types/oauth.d.ts +117 -0
  153. package/dist/types/types/openid.d.ts +320 -0
  154. package/dist/types/utils/EventEmitter.d.ts +29 -0
  155. package/dist/types/utils/PromiseQueue.d.ts +18 -0
  156. package/dist/types/utils/TaskBridge.d.ts +153 -0
  157. package/dist/types/utils/TimeCoordinator.d.ts +49 -0
  158. package/dist/types/utils/buildUrl.d.ts +10 -0
  159. package/dist/types/utils/equality.d.ts +19 -0
  160. package/dist/types/utils/getSearchParam.d.ts +13 -0
  161. package/dist/types/utils/hashObject.d.ts +6 -0
  162. package/dist/types/utils/ignoreUndefineds.d.ts +14 -0
  163. package/dist/types/utils/index.d.ts +13 -0
  164. package/dist/types/utils/merge.d.ts +16 -0
  165. package/dist/types/utils/pause.d.ts +15 -0
  166. package/dist/types/utils/toRelativeUrl.d.ts +10 -0
  167. package/dist/types/utils/validators.d.ts +6 -0
  168. package/package.json +1 -0
@@ -0,0 +1,320 @@
1
+ /**
2
+ * @module
3
+ * @mergeModuleWith OAuth2
4
+ */
5
+ /**
6
+ * Interface defining the response payload from `/.well-known/openid-configuration`
7
+ */
8
+ export interface OpenIdConfiguration {
9
+ /**
10
+ * Authorization server's Issuer Identifier URL.
11
+ */
12
+ readonly issuer: string;
13
+ /**
14
+ * URL of the authorization server's authorization endpoint.
15
+ */
16
+ readonly authorization_endpoint?: string;
17
+ /**
18
+ * URL of the authorization server's token endpoint.
19
+ */
20
+ readonly token_endpoint?: string;
21
+ /**
22
+ * URL of the authorization server's JWK Set document.
23
+ */
24
+ readonly jwks_uri?: string;
25
+ /**
26
+ * URL of the authorization server's Dynamic Client Registration Endpoint.
27
+ */
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[];
87
+ /**
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.
90
+ */
91
+ readonly revocation_endpoint_auth_signing_alg_values_supported?: string[];
92
+ /**
93
+ * URL of the authorization server's introspection endpoint.
94
+ */
95
+ readonly introspection_endpoint?: string;
96
+ /**
97
+ * JSON array containing a list of client authentication methods supported by this introspection
98
+ * endpoint.
99
+ */
100
+ readonly introspection_endpoint_auth_methods_supported?: string[];
101
+ /**
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.
105
+ */
106
+ readonly introspection_endpoint_auth_signing_alg_values_supported?: string[];
107
+ /**
108
+ * PKCE code challenge methods supported by this authorization server.
109
+ */
110
+ readonly code_challenge_methods_supported?: string[];
111
+ /**
112
+ * Signed JWT containing metadata values about the authorization server as claims.
113
+ */
114
+ readonly signed_metadata?: string;
115
+ /**
116
+ * URL of the authorization server's device authorization endpoint.
117
+ */
118
+ readonly device_authorization_endpoint?: string;
119
+ /**
120
+ * Indicates authorization server support for mutual-TLS client certificate-bound access tokens.
121
+ */
122
+ readonly tls_client_certificate_bound_access_tokens?: boolean;
123
+ /**
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.
126
+ */
127
+ /**
128
+ * URL of the authorization server's UserInfo Endpoint.
129
+ */
130
+ readonly userinfo_endpoint?: string;
131
+ /**
132
+ * JSON array containing a list of the Authentication Context Class References that this
133
+ * authorization server supports.
134
+ */
135
+ readonly acr_values_supported?: string[];
136
+ /**
137
+ * JSON array containing a list of the Subject Identifier types that this authorization server
138
+ * supports.
139
+ */
140
+ readonly subject_types_supported?: string[];
141
+ /**
142
+ * JSON array containing a list of the JWS `alg` values supported by the authorization server for
143
+ * the ID Token.
144
+ */
145
+ readonly id_token_signing_alg_values_supported?: string[];
146
+ /**
147
+ * JSON array containing a list of the JWE `alg` values supported by the authorization server for
148
+ * the ID Token.
149
+ */
150
+ readonly id_token_encryption_alg_values_supported?: string[];
151
+ /**
152
+ * JSON array containing a list of the JWE `enc` values supported by the authorization server for
153
+ * the ID Token.
154
+ */
155
+ readonly id_token_encryption_enc_values_supported?: string[];
156
+ /**
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.
176
+ */
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[];
188
+ /**
189
+ * JSON array containing a list of the Claim Types that the authorization server supports.
190
+ */
191
+ readonly claim_types_supported?: string[];
192
+ /**
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.
195
+ */
196
+ readonly claims_supported?: string[];
197
+ /**
198
+ * Languages and scripts supported for values in Claims being returned, represented as a JSON
199
+ * array of RFC 5646 language tag values.
200
+ */
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;
207
+ /**
208
+ * Boolean value specifying whether the authorization server supports use of the `request`
209
+ * parameter.
210
+ */
211
+ readonly request_parameter_supported?: boolean;
212
+ /**
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.
253
+ */
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[];
279
+ /**
280
+ * Supported CIBA authentication result delivery modes.
281
+ */
282
+ readonly backchannel_token_delivery_modes_supported?: string[];
283
+ /**
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.
290
+ */
291
+ readonly check_session_iframe?: string;
292
+ /**
293
+ * JSON array containing a list of the JWS algorithms supported for DPoP proof JWTs.
294
+ */
295
+ 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
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @module
3
+ * @mergeModuleWith Core
4
+ */
5
+ type EventMap = {
6
+ [event: string]: any;
7
+ };
8
+ type EventListener<T> = T extends void ? () => void : (event: T) => void;
9
+ /**
10
+ * @group EventEmitter
11
+ */
12
+ export interface Emitter<E extends EventMap> {
13
+ on: (...args: Parameters<EventEmitter<E>['on']>) => void;
14
+ off: (...args: Parameters<EventEmitter<E>['off']>) => void;
15
+ }
16
+ /**
17
+ * @group EventEmitter
18
+ */
19
+ export declare class EventEmitter<Events extends EventMap> {
20
+ listeners: {
21
+ [K in keyof Events]?: Array<EventListener<Events[K]>>;
22
+ };
23
+ on<K extends keyof Events>(eventName: K, handler: EventListener<Events[K]>): this;
24
+ off<K extends keyof Events>(eventName: K, handler?: EventListener<Events[K]>): this;
25
+ emit<K extends keyof Events>(eventName: K, data: Events[K]): void;
26
+ emit<K extends keyof Events>(eventName: K): void;
27
+ relay<FromEvents extends EventMap, K extends keyof Events & keyof FromEvents = keyof Events & keyof FromEvents>(emitter: EventEmitter<FromEvents>, events: K[]): void;
28
+ }
29
+ export {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @internal
4
+ */
5
+ type QueueItem = {
6
+ method: () => Promise<unknown>;
7
+ resolve: (value?: any) => void;
8
+ reject: (reason?: unknown) => void;
9
+ };
10
+ /** @internal */
11
+ export declare class PromiseQueue {
12
+ queue: QueueItem[];
13
+ isRunning: boolean;
14
+ get size(): number;
15
+ push<T>(method: () => Promise<T>): Promise<T>;
16
+ private run;
17
+ }
18
+ export {};
@@ -0,0 +1,153 @@
1
+ import type { BroadcastChannelLike } from '../types/index.ts';
2
+ import { AuthSdkError } from '../errors/AuthSdkError.ts';
3
+ /** @useDeclaredType */
4
+ type TypeMap = Record<string, any>;
5
+ /**
6
+ * A bridge for passing messages between a `TaskHandler` and a `Requestor`. The `Requestor` is "asking" the `TaskHandler`
7
+ * To perform a `Task` on it's behave. Loosely based on TCP
8
+ *
9
+ * When a `TaskRequest` is received, a separate {@link TaskBridge.TaskChannel} is created between the `Handler` and
10
+ * the `Requestor` to communicate the status of the specific `Task`. Once the `Task` has completed the response will
11
+ * be sent to the `Requestor` via the {@link TaskBridge.TaskChannel} and the channel will be closed.
12
+ *
13
+ * The `TaskHandler` will broadcast a heartbeat, indicating it's still alive, to all pending {@link TaskBridge.TaskChannel}s.
14
+ * If a `Requestor` does not receive a response or heartbeat within a `timeout` interval, a Timeout error is thrown
15
+ *
16
+ * @typeParam M - A TypeMap of message payload structure for `TaskRequests`
17
+ * @typeParam R - A TypeMap of message payload structure for `TaskReponses`
18
+ */
19
+ export declare abstract class TaskBridge<M extends TypeMap, R extends TypeMap> {
20
+ #private;
21
+ name: string;
22
+ heartbeatInterval: number;
23
+ constructor(name: string);
24
+ /**
25
+ * A "public" channel opened on a known key (`this.name`) to send/receive task requests
26
+ *
27
+ * @remarks
28
+ * This has been written with an assumption there is one only {@link TaskBridge} listening on
29
+ * this public channel and responding to messages. There is currently no "message handling arbitartion"
30
+ */
31
+ protected abstract createBridgeChannel(): TaskBridge.BridgeChannel<M[keyof M]>;
32
+ protected abstract createTaskChannel<K extends keyof M & keyof R>(name: string): TaskBridge.TaskChannel<R[K]>;
33
+ protected onTick(): void;
34
+ protected pushMessage(message: TaskBridge.Task<any, any>): void;
35
+ protected clearMessage(messageId: string): void;
36
+ send<K extends keyof M & keyof R>(message: M[K], options?: TaskBridge.TaskOptions): TaskBridge.TaskResponse<R[K]>;
37
+ subscribe<K extends keyof M & keyof R>(handler: TaskBridge.TaskHandler<M, R>): void;
38
+ /**
39
+ * Returns the number of pending tasks
40
+ */
41
+ get pending(): number;
42
+ close(): void;
43
+ }
44
+ export declare namespace TaskBridge {
45
+ const BridgeVersion = 2;
46
+ /**
47
+ * Possible `status` values indicating the process of an orchestrated request
48
+ */
49
+ type TaskStatus = 'PENDING' | 'SUCCESS' | 'FAILED' | 'ABORTED';
50
+ type BridgeVersions = 1 | 2;
51
+ /**
52
+ * The payload of a message sent from Subscriber to Requestor, indicating the process or result of a request
53
+ */
54
+ type HandlerMessage<M extends TypeMap> = {
55
+ status: 'SUCCESS';
56
+ data: M;
57
+ __v: BridgeVersions;
58
+ } | {
59
+ status: 'FAILED';
60
+ data: M;
61
+ __v: BridgeVersions;
62
+ } | {
63
+ status: 'PENDING';
64
+ __v: BridgeVersions;
65
+ } | {
66
+ status: 'ABORTED';
67
+ __v: BridgeVersions;
68
+ };
69
+ /**
70
+ * The payload of a message sent from Requestor to Subscriber to alter the outcome of a request (`CANCEL` for example)
71
+ */
72
+ type RequestorMessage = {
73
+ action: string;
74
+ };
75
+ /**
76
+ * A channel with the purpose of receiving a request from a Requestor
77
+ */
78
+ type BridgeChannel<M extends TypeMap> = BroadcastChannelLike<M & {
79
+ requestId: string;
80
+ __v: BridgeVersions;
81
+ }>;
82
+ /**
83
+ * A channel created to communicate the results of a pending request (will be isolated to specific Subscriber and Requestor)
84
+ */
85
+ type TaskChannel<M extends TypeMap> = BroadcastChannelLike<(RequestorMessage | HandlerMessage<M>) & {
86
+ __v: BridgeVersions;
87
+ }>;
88
+ /**
89
+ * @internal
90
+ *
91
+ * @typeParam Q - re(Q)uest event payload
92
+ * @typeParam S - re(S)ponse event payload
93
+ */
94
+ type TaskInit<Q extends TypeMap, S extends TypeMap> = {
95
+ __v: BridgeVersions;
96
+ id: string;
97
+ message: Q;
98
+ channel: TaskChannel<S>;
99
+ reply?: (response: any) => void;
100
+ };
101
+ /**
102
+ * @internal
103
+ *
104
+ * @typeParam Q - re(Q)uest event payload
105
+ * @typeParam S - re(S)ponse event payload
106
+ */
107
+ class Task<Q extends TypeMap, S extends TypeMap> {
108
+ __v: TaskInit<Q, S>['__v'];
109
+ id: TaskInit<Q, S>['id'];
110
+ message: TaskInit<Q, S>['message'];
111
+ channel: TaskInit<Q, S>['channel'];
112
+ private replyFn;
113
+ controller: AbortController;
114
+ constructor({ id, message, channel, __v, reply }: TaskInit<Q, S>);
115
+ send(): {
116
+ requestId: string;
117
+ __v: BridgeVersions;
118
+ } & Q;
119
+ reply(data: S, status: TaskBridge.TaskStatus): void;
120
+ reply(status: 'PENDING' | 'ABORTED'): void;
121
+ abort(...args: Parameters<AbortController['abort']>): void;
122
+ get signal(): AbortSignal;
123
+ }
124
+ /**
125
+ * @internal
126
+ */
127
+ type TaskOptions = {
128
+ timeout?: number | null;
129
+ signal?: AbortSignal;
130
+ };
131
+ /**
132
+ * @internal
133
+ */
134
+ type TaskResponse<R extends TypeMap> = {
135
+ result: Promise<R>;
136
+ abort: () => void;
137
+ };
138
+ /**
139
+ * @internal
140
+ */
141
+ type TaskHandler<M extends TypeMap, R extends TypeMap> = (message: M[keyof M], reply: (response: R[keyof R]) => any, options?: {
142
+ signal: AbortSignal;
143
+ }) => any;
144
+ /**
145
+ * @group Errors
146
+ */
147
+ class TimeoutError extends AuthSdkError {
148
+ #private;
149
+ constructor(...args: ConstructorParameters<typeof AuthSdkError>);
150
+ get timeout(): boolean;
151
+ }
152
+ }
153
+ export {};
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @module
3
+ * @mergeModuleWith Core
4
+ */
5
+ import type { EpochTimestamp, Seconds } from '../types/index.ts';
6
+ /**
7
+ * Utility class for parse timestamps and performing time/date calculations
8
+ *
9
+ * @group TimeCoordinator
10
+ */
11
+ export declare class Timestamp {
12
+ private ts;
13
+ constructor(ts: EpochTimestamp);
14
+ static from(t: Timestamp): Timestamp;
15
+ static from(t: Date): Timestamp;
16
+ static from(t: EpochTimestamp): Timestamp;
17
+ static from(t: EpochTimestamp | Date | Timestamp): Timestamp;
18
+ get value(): EpochTimestamp;
19
+ get asDate(): Date;
20
+ isBefore(t: Timestamp): boolean;
21
+ isBefore(t: Date): boolean;
22
+ isBefore(t: EpochTimestamp): boolean;
23
+ isAfter(t: Timestamp): boolean;
24
+ isAfter(t: Date): boolean;
25
+ isAfter(t: EpochTimestamp): boolean;
26
+ timeSince(t: Timestamp): Seconds;
27
+ timeSince(t: Date): Seconds;
28
+ timeSince(t: EpochTimestamp): Seconds;
29
+ timeSinceNow(): number;
30
+ }
31
+ /**
32
+ * @group TimeCoordinator
33
+ */
34
+ export interface TimeCoordinator {
35
+ clockSkew: Seconds;
36
+ clockTolerance: Seconds;
37
+ now: () => Timestamp;
38
+ }
39
+ /**
40
+ * @group TimeCoordinator
41
+ */
42
+ export declare class DefaultTimeCoordinator implements TimeCoordinator {
43
+ #private;
44
+ get clockSkew(): Seconds;
45
+ set clockSkew(skew: Seconds);
46
+ get clockTolerance(): Seconds;
47
+ set clockTolerance(tolerance: Seconds);
48
+ now(): Timestamp;
49
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @module
3
+ * @mergeModuleWith Core
4
+ */
5
+ /**
6
+ * Utility function to build a URL from path segments
7
+ *
8
+ * @group Utils
9
+ */
10
+ export declare function buildURL(base: URL, ...path: string[]): URL;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @module
3
+ * @mergeModuleWith Core
4
+ */
5
+ /**
6
+ * Utility function to verify two arrays contain the same items
7
+ *
8
+ * @remarks
9
+ * Requires array contain unique items
10
+ *
11
+ * @group Utils
12
+ */
13
+ export declare function hasSameValues<T>(a1: T[], a2: T[], strict?: boolean): boolean;
14
+ /**
15
+ * Utility function to verify an object contains specific key/value pairs
16
+ *
17
+ * @group Utils
18
+ */
19
+ export declare function doesPartialMatch(target: Record<string, unknown>, partial: Record<string, unknown>): boolean;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @module
3
+ * @mergeModuleWith Core
4
+ */
5
+ /**
6
+ * Extracts a query parameter from a {@link !URLSearchParams} instance. Throws when more than one value exists for given parameter
7
+ * (which is allowed in the URI spec, but is not practiced in OAuth2)
8
+ *
9
+ * @throws {@link NetworkError}
10
+ *
11
+ * @group Utils
12
+ */
13
+ export declare function getSearchParam(parameters: URLSearchParams, name: string): string | undefined;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @internal
3
+ *
4
+ * Hashes an object into a string to be used as a key within a map
5
+ */
6
+ export declare function hashObject(obj: object): Promise<string>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @internal
4
+ */
5
+ /**
6
+ * @internal
7
+ * Removes `undefined` properties from an object (results in a new object)
8
+ *
9
+ * @remarks
10
+ * designed to be used in shallow spread operator merges, so undefined values don't override
11
+ * already defined properties (aka doesn't set the value of a key to `undefined`)
12
+ *
13
+ */
14
+ export declare function ignoreUndefineds<T extends Record<string | number, unknown> = Record<string | number, unknown>>(target: T): T;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @internal
4
+ */
5
+ export * from './buildUrl.ts';
6
+ export * from './merge.ts';
7
+ export * from './equality.ts';
8
+ export * from './getSearchParam.ts';
9
+ export * from './pause.ts';
10
+ export * from './ignoreUndefineds.ts';
11
+ export * from './toRelativeUrl.ts';
12
+ export * from './hashObject.ts';
13
+ export * from './validators.ts';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @module
3
+ * @mergeModuleWith Core
4
+ */
5
+ /**
6
+ * Merges `n` number of {@link !URLSearchParams} instances
7
+ *
8
+ * @group Utils
9
+ */
10
+ export declare function mergeURLSearchParameters(target: URLSearchParams, ...source: (URLSearchParams | Record<string, string | undefined>)[]): URLSearchParams;
11
+ /**
12
+ * Merges `n` number of {@link !Headers} instances
13
+ *
14
+ * @group Utils
15
+ */
16
+ export declare function mergeHeaders(target: Headers, ...source: (Headers | Record<string, string | undefined>)[]): Headers;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @module
3
+ * @mergeModuleWith Core
4
+ */
5
+ /**
6
+ * Returns a {@link !Promise} which resolves after a short delay (milliseconds)
7
+ *
8
+ * @remarks
9
+ * Wraps {@link !setTimeout} in a {@link !Promise}
10
+ *
11
+ * @param ms - length of delay in milliseconds
12
+ *
13
+ * @group Utils
14
+ */
15
+ export declare function pause(ms: number): Promise<unknown>;