@faable/auth-js 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Known error codes. Note that the server may also return other error codes
3
+ * not included in this list (if the client library is older than the version
4
+ * on the server).
5
+ */
6
+ export type ErrorCode = "unexpected_failure" | "validation_failed" | "bad_json" | "email_exists" | "phone_exists" | "bad_jwt" | "not_admin" | "no_authorization" | "user_not_found" | "session_not_found" | "flow_state_not_found" | "flow_state_expired" | "signup_disabled" | "user_banned" | "provider_email_needs_verification" | "invite_not_found" | "bad_oauth_state" | "bad_oauth_callback" | "oauth_provider_not_supported" | "unexpected_audience" | "single_identity_not_deletable" | "email_conflict_identity_not_deletable" | "identity_already_exists" | "email_provider_disabled" | "phone_provider_disabled" | "too_many_enrolled_mfa_factors" | "mfa_factor_name_conflict" | "mfa_factor_not_found" | "mfa_ip_address_mismatch" | "mfa_challenge_expired" | "mfa_verification_failed" | "mfa_verification_rejected" | "insufficient_aal" | "captcha_failed" | "saml_provider_disabled" | "manual_linking_disabled" | "sms_send_failed" | "email_not_confirmed" | "phone_not_confirmed" | "reauth_nonce_missing" | "saml_relay_state_not_found" | "saml_relay_state_expired" | "saml_idp_not_found" | "saml_assertion_no_user_id" | "saml_assertion_no_email" | "user_already_exists" | "sso_provider_not_found" | "saml_metadata_fetch_failed" | "saml_idp_already_exists" | "sso_domain_already_exists" | "saml_entity_id_mismatch" | "conflict" | "provider_disabled" | "user_sso_managed" | "reauthentication_needed" | "same_password" | "reauthentication_not_valid" | "otp_expired" | "otp_disabled" | "identity_not_found" | "weak_password" | "over_request_rate_limit" | "over_email_send_rate_limit" | "over_sms_send_rate_limit" | "bad_code_verifier";
7
+ export declare class AuthError extends Error {
8
+ /**
9
+ * Error code associated with the error. Most errors coming from
10
+ * HTTP responses will have a code, though some errors that occur
11
+ * before a response is received will not have one present. In that
12
+ * case {@link #status} will also be undefined.
13
+ */
14
+ code: ErrorCode | string | undefined;
15
+ /** HTTP status code that caused the error. */
16
+ status: number | undefined;
17
+ protected __isAuthError: boolean;
18
+ constructor(message: string, status?: number, code?: string);
19
+ }
20
+ export declare class CustomAuthError extends AuthError {
21
+ name: string;
22
+ status: number;
23
+ constructor(message: string, name: string, status: number, code: string | undefined);
24
+ }
25
+ export declare class AuthSessionMissingError extends CustomAuthError {
26
+ constructor();
27
+ }
28
+ export declare function isAuthError(error: unknown): error is AuthError;
29
+ export declare class AuthApiError extends AuthError {
30
+ status: number;
31
+ constructor(message: string, status: number, code: string | undefined);
32
+ }
33
+ export declare function isAuthApiError(error: unknown): error is AuthApiError;
34
+ export declare class AuthImplicitGrantRedirectError extends CustomAuthError {
35
+ details: {
36
+ error: string;
37
+ code: string;
38
+ } | null;
39
+ constructor(message: string, details?: {
40
+ error: string;
41
+ code: string;
42
+ } | null);
43
+ toJSON(): {
44
+ name: string;
45
+ message: string;
46
+ status: number;
47
+ details: {
48
+ error: string;
49
+ code: string;
50
+ } | null;
51
+ };
52
+ }
53
+ export declare class AuthPKCEGrantCodeExchangeError extends CustomAuthError {
54
+ details: {
55
+ error: string;
56
+ code: string;
57
+ } | null;
58
+ constructor(message: string, details?: {
59
+ error: string;
60
+ code: string;
61
+ } | null);
62
+ toJSON(): {
63
+ name: string;
64
+ message: string;
65
+ status: number;
66
+ details: {
67
+ error: string;
68
+ code: string;
69
+ } | null;
70
+ };
71
+ }
72
+ export declare class AuthUnknownError extends AuthError {
73
+ originalError: unknown;
74
+ constructor(message: string, originalError: unknown);
75
+ }
76
+ export declare class AuthInvalidTokenResponseError extends CustomAuthError {
77
+ constructor();
78
+ }
79
+ export declare class AuthRetryableFetchError extends CustomAuthError {
80
+ constructor(message: string, status: number);
81
+ }
82
+ export declare function isAuthRetryableFetchError(error: unknown): error is AuthRetryableFetchError;
@@ -0,0 +1,11 @@
1
+ export type JsonResponse<T = any> = {
2
+ data: T | null;
3
+ error?: any;
4
+ };
5
+ type RequestInitWithToken = RequestInit & {
6
+ token: string;
7
+ raw: boolean;
8
+ };
9
+ export declare const _post: <T>(url: string, data: object, options?: Partial<RequestInitWithToken>) => Promise<JsonResponse<T>>;
10
+ export declare const _get: <T>(url: string, options?: Partial<RequestInitWithToken>) => Promise<JsonResponse<T>>;
11
+ export {};
@@ -0,0 +1,4 @@
1
+ declare const win: (Window & typeof globalThis) | undefined;
2
+ export declare const document: Document;
3
+ export { win as window };
4
+ export declare const fetch: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) & typeof globalThis.fetch;
@@ -0,0 +1,52 @@
1
+ import { AuthResponse, SupportedStorage, User } from "./types";
2
+ import { JsonResponse } from "./fetch";
3
+ export declare function decodeBase64URL(value: string): string;
4
+ export declare function generatePKCEVerifier(): string;
5
+ export declare function generatePKCEChallenge(verifier: string): Promise<string>;
6
+ export declare function getCodeChallengeAndMethod(storage: SupportedStorage, storageKey: string, isPasswordRecovery?: boolean): Promise<string[]>;
7
+ export declare const isBrowser: () => boolean;
8
+ /**
9
+ * Checks whether localStorage is supported on this browser.
10
+ */
11
+ export declare const supportsLocalStorage: () => boolean;
12
+ export declare function uuid(): string;
13
+ export type RawAuthResponse = {
14
+ expires_at: number;
15
+ expires_in: number;
16
+ user: User;
17
+ access_token: string;
18
+ refresh_token: string;
19
+ token_type: string;
20
+ };
21
+ export declare function expiresAt(expiresIn: number): number;
22
+ export declare function _sessionResponse({ data, }: JsonResponse<Partial<RawAuthResponse>>): AuthResponse;
23
+ /**
24
+ * A deferred represents some asynchronous work that is not yet finished, which
25
+ * may or may not culminate in a value.
26
+ * Taken from: https://github.com/mike-north/types/blob/master/src/async.ts
27
+ */
28
+ export declare class Deferred<T = any> {
29
+ static promiseConstructor: PromiseConstructor;
30
+ readonly promise: PromiseLike<T>;
31
+ readonly resolve: (value?: T | PromiseLike<T>) => void;
32
+ readonly reject: (reason?: any) => any;
33
+ constructor();
34
+ }
35
+ /**
36
+ * Converts the provided async function into a retryable function. Each result
37
+ * or thrown error is sent to the isRetryable function which should return true
38
+ * if the function should run again.
39
+ */
40
+ export declare function retryable<T>(fn: (attempt: number) => Promise<T>, isRetryable: (attempt: number, error: any | null, result?: T) => boolean): Promise<T>;
41
+ /**
42
+ * Creates a promise that resolves to null after some time.
43
+ */
44
+ export declare function sleep(time: number): Promise<null>;
45
+ export declare const checkExpiresInTime: ({ expires_in, expires_at, refreshTick, }: {
46
+ expires_in: string;
47
+ expires_at?: string;
48
+ refreshTick: number;
49
+ }) => {
50
+ expiresIn: number;
51
+ expiresAt: number;
52
+ };
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @ignore
3
+ */
4
+ export interface JWTVerifyOptions {
5
+ iss: string;
6
+ aud: string;
7
+ id_token: string;
8
+ nonce?: string;
9
+ leeway?: number;
10
+ max_age?: number;
11
+ organizationId?: string;
12
+ now?: number;
13
+ }
14
+ export interface IdToken {
15
+ __raw: string;
16
+ name?: string;
17
+ given_name?: string;
18
+ family_name?: string;
19
+ middle_name?: string;
20
+ nickname?: string;
21
+ preferred_username?: string;
22
+ profile?: string;
23
+ picture?: string;
24
+ website?: string;
25
+ email?: string;
26
+ email_verified?: boolean;
27
+ gender?: string;
28
+ birthdate?: string;
29
+ zoneinfo?: string;
30
+ locale?: string;
31
+ phone_number?: string;
32
+ phone_number_verified?: boolean;
33
+ address?: string;
34
+ updated_at?: string;
35
+ iss?: string;
36
+ aud?: string;
37
+ exp?: number;
38
+ nbf?: number;
39
+ iat?: number;
40
+ jti?: string;
41
+ azp?: string;
42
+ nonce?: string;
43
+ auth_time?: string;
44
+ at_hash?: string;
45
+ c_hash?: string;
46
+ acr?: string;
47
+ amr?: string;
48
+ sub_jwk?: string;
49
+ cnf?: string;
50
+ sid?: string;
51
+ org_id?: string;
52
+ [key: string]: any;
53
+ }
54
+ export declare function decodeJWTPayload(token: string): any;
55
+ export declare const verify: (options: JWTVerifyOptions) => any;
@@ -0,0 +1,12 @@
1
+ import { SupportedStorage } from "./types";
2
+ /**
3
+ * Provides safe access to the globalThis.localStorage property.
4
+ */
5
+ export declare const localStorageAdapter: SupportedStorage;
6
+ /**
7
+ * Returns a localStorage-like object that stores the key-value pairs in
8
+ * memory.
9
+ */
10
+ export declare function memoryLocalStorageAdapter(store?: {
11
+ [key: string]: string;
12
+ }): SupportedStorage;
@@ -0,0 +1,4 @@
1
+ import { SupportedStorage } from "./types";
2
+ export declare const setItemAsync: (storage: SupportedStorage, key: string, data: any) => Promise<void>;
3
+ export declare const getItemAsync: (storage: SupportedStorage, key: string) => Promise<unknown>;
4
+ export declare const removeItemAsync: (storage: SupportedStorage, key: string) => Promise<void>;
@@ -0,0 +1,383 @@
1
+ import { AuthError } from "./errors";
2
+ import { LockFunc } from "../lock/locks";
3
+ import { BaseLogOptions } from "../BaseLog";
4
+ /**
5
+ * @ignore
6
+ */
7
+ export interface AuthenticationResult {
8
+ state: string;
9
+ code?: string;
10
+ error?: string;
11
+ error_description?: string;
12
+ }
13
+ export declare class User {
14
+ name?: string;
15
+ profile?: string;
16
+ picture?: string;
17
+ email?: string;
18
+ website?: string;
19
+ birthdate?: string;
20
+ locale?: string;
21
+ sub?: string;
22
+ [key: string]: any;
23
+ }
24
+ /**
25
+ * The state of the application before the user was redirected to the login page.
26
+ */
27
+ export type AppState = {
28
+ returnTo?: string;
29
+ [key: string]: any;
30
+ };
31
+ export interface AuthorizationParams {
32
+ /**
33
+ * - `'page'`: displays the UI with a full page view
34
+ * - `'popup'`: displays the UI with a popup window
35
+ * - `'touch'`: displays the UI in a way that leverages a touch interface
36
+ * - `'wap'`: displays the UI with a "feature phone" type interface
37
+ */
38
+ display?: "page" | "popup" | "touch" | "wap";
39
+ /**
40
+ * - `'none'`: do not prompt user for login or consent on reauthentication
41
+ * - `'login'`: prompt user for reauthentication
42
+ * - `'consent'`: prompt user for consent before processing request
43
+ * - `'select_account'`: prompt user to select an account
44
+ */
45
+ prompt?: "none" | "login" | "consent" | "select_account";
46
+ /**
47
+ * Maximum allowable elapsed time (in seconds) since authentication.
48
+ * If the last time the user authenticated is greater than this value,
49
+ * the user must be reauthenticated.
50
+ */
51
+ max_age?: string | number;
52
+ /**
53
+ * The space-separated list of language tags, ordered by preference.
54
+ * For example: `'fr-CA fr en'`.
55
+ */
56
+ ui_locales?: string;
57
+ /**
58
+ * Previously issued ID Token.
59
+ */
60
+ id_token_hint?: string;
61
+ /**
62
+ * Provides a hint to Auth0 as to what flow should be displayed.
63
+ * The default behavior is to show a login page but you can override
64
+ * this by passing 'signup' to show the signup page instead.
65
+ *
66
+ * This only affects the New Universal Login Experience.
67
+ */
68
+ screen_hint?: "signup" | "login" | string;
69
+ /**
70
+ * The user's email address or other identifier. When your app knows
71
+ * which user is trying to authenticate, you can provide this parameter
72
+ * to pre-fill the email box or select the right session for sign-in.
73
+ *
74
+ * This currently only affects the classic Lock experience.
75
+ */
76
+ login_hint?: string;
77
+ acr_values?: string;
78
+ /**
79
+ * The default scope to be used on authentication requests.
80
+ *
81
+ * This defaults to `profile email` if not set. If you are setting extra scopes and require
82
+ * `profile` and `email` to be included then you must include them in the provided scope.
83
+ *
84
+ * Note: The `openid` scope is **always applied** regardless of this setting.
85
+ */
86
+ scope?: string;
87
+ /**
88
+ * The default audience to be used for requesting API access.
89
+ */
90
+ audience?: string;
91
+ /**
92
+ * The name of the connection configured for your application.
93
+ * If null, it will redirect to the Auth0 Login Page and show
94
+ * the Login Widget.
95
+ */
96
+ connection?: string;
97
+ /**
98
+ * The Id of an organization to log in to.
99
+ *
100
+ * This will specify an `organization` parameter in your user's login request and will add a step to validate
101
+ * the `org_id` claim in your user's ID Token.
102
+ */
103
+ organization?: string;
104
+ /**
105
+ * The Id of an invitation to accept. This is available from the user invitation URL that is given when participating in a user invitation flow.
106
+ */
107
+ invitation?: string;
108
+ /**
109
+ * The default URL where Auth0 will redirect your browser to with
110
+ * the authentication result. It must be whitelisted in
111
+ * the "Allowed Callback URLs" field in your Auth0 Application's
112
+ * settings. If not provided here, it should be provided in the other
113
+ * methods that provide authentication.
114
+ */
115
+ redirect_uri?: string;
116
+ /**
117
+ * If you need to send custom parameters to the Authorization Server,
118
+ * make sure to use the original parameter name.
119
+ */
120
+ [key: string]: any;
121
+ }
122
+ interface BaseLoginOptions {
123
+ /**
124
+ * URL parameters that will be sent back to the Authorization Server. This can be known parameters
125
+ * defined by Auth0 or custom parameters that you define.
126
+ */
127
+ authorizationParams?: AuthorizationParams;
128
+ }
129
+ export interface RedirectLoginOptions<TAppState = any> extends BaseLoginOptions {
130
+ /**
131
+ * Used to store state before doing the redirect
132
+ */
133
+ appState?: TAppState;
134
+ }
135
+ export interface IdToken {
136
+ __raw: string;
137
+ name?: string;
138
+ given_name?: string;
139
+ family_name?: string;
140
+ middle_name?: string;
141
+ nickname?: string;
142
+ preferred_username?: string;
143
+ profile?: string;
144
+ picture?: string;
145
+ website?: string;
146
+ email?: string;
147
+ email_verified?: boolean;
148
+ gender?: string;
149
+ birthdate?: string;
150
+ zoneinfo?: string;
151
+ locale?: string;
152
+ phone_number?: string;
153
+ phone_number_verified?: boolean;
154
+ address?: string;
155
+ updated_at?: string;
156
+ iss?: string;
157
+ aud?: string;
158
+ exp?: number;
159
+ nbf?: number;
160
+ iat?: number;
161
+ jti?: string;
162
+ azp?: string;
163
+ nonce?: string;
164
+ auth_time?: string;
165
+ at_hash?: string;
166
+ c_hash?: string;
167
+ acr?: string;
168
+ amr?: string;
169
+ sub_jwk?: string;
170
+ cnf?: string;
171
+ sid?: string;
172
+ org_id?: string;
173
+ [key: string]: any;
174
+ }
175
+ export interface GetTokenSilentlyOptions {
176
+ /**
177
+ * When `off`, ignores the cache and always sends a
178
+ * request to Auth0.
179
+ * When `cache-only`, only reads from the cache and never sends a request to Auth0.
180
+ * Defaults to `on`, where it both reads from the cache and sends a request to Auth0 as needed.
181
+ */
182
+ cacheMode?: "on" | "off" | "cache-only";
183
+ /**
184
+ * Parameters that will be sent back to Auth0 as part of a request.
185
+ */
186
+ authorizationParams?: {
187
+ /**
188
+ * There's no actual redirect when getting a token silently,
189
+ * but, according to the spec, a `redirect_uri` param is required.
190
+ * Auth0 uses this parameter to validate that the current `origin`
191
+ * matches the `redirect_uri` `origin` when sending the response.
192
+ * It must be whitelisted in the "Allowed Web Origins" in your
193
+ * Auth0 Application's settings.
194
+ */
195
+ redirect_uri?: string;
196
+ /**
197
+ * The scope that was used in the authentication request
198
+ */
199
+ scope?: string;
200
+ /**
201
+ * The audience that was used in the authentication request
202
+ */
203
+ audience?: string;
204
+ /**
205
+ * If you need to send custom parameters to the Authorization Server,
206
+ * make sure to use the original parameter name.
207
+ */
208
+ [key: string]: any;
209
+ };
210
+ /** A maximum number of seconds to wait before declaring the background /authorize call as failed for timeout
211
+ * Defaults to 60s.
212
+ */
213
+ timeoutInSeconds?: number;
214
+ /**
215
+ * If true, the full response from the /oauth/token endpoint (or the cache, if the cache was used) is returned
216
+ * (minus `refresh_token` if one was issued). Otherwise, just the access token is returned.
217
+ *
218
+ * The default is `false`.
219
+ */
220
+ detailedResponse?: boolean;
221
+ }
222
+ export type GetTokenSilentlyVerboseResponse = Omit<TokenEndpointResponse, "refresh_token">;
223
+ export type TokenEndpointResponse = {
224
+ id_token: string;
225
+ access_token: string;
226
+ refresh_token?: string;
227
+ expires_in: number;
228
+ scope?: string;
229
+ };
230
+ export type FaableAuthClientConfig = {
231
+ domain: string;
232
+ scope?: string;
233
+ audience?: string;
234
+ redirect_uri?: string;
235
+ clientId: string;
236
+ authorizationParams?: AuthorizationParams;
237
+ cookieDomain?: string;
238
+ useRefreshTokens?: boolean;
239
+ flowType?: AuthFlowType;
240
+ storage?: SupportedStorage;
241
+ storageKey?: string;
242
+ /**
243
+ * Provide your own locking mechanism based on the environment. By default no locking is done at this time.
244
+ *
245
+ * @experimental
246
+ */
247
+ lock?: LockFunc;
248
+ } & BaseLogOptions;
249
+ type AnyFunction = (...args: any[]) => any;
250
+ type MaybePromisify<T> = T | Promise<T>;
251
+ type PromisifyMethods<T> = {
252
+ [K in keyof T]: T[K] extends AnyFunction ? (...args: Parameters<T[K]>) => MaybePromisify<ReturnType<T[K]>> : T[K];
253
+ };
254
+ export type SupportedStorage = PromisifyMethods<Pick<Storage, "getItem" | "setItem" | "removeItem">> & {
255
+ /**
256
+ * If set to `true` signals to the library that the storage medium is used
257
+ * on a server and the values may not be authentic, such as reading from
258
+ * request cookies. Implementations should not set this to true if the client
259
+ * is used on a server that reads storage information from authenticated
260
+ * sources, such as a secure database or file.
261
+ */
262
+ isServer?: boolean;
263
+ };
264
+ export type Provider = "google" | "github";
265
+ export type AuthFlowType = "implicit" | "pkce";
266
+ export type SignInWithOAuthConnection = {
267
+ /** Default connection is used if not setted. */
268
+ connection?: string;
269
+ /** A URL to send the user to after they are confirmed. */
270
+ redirectTo?: string;
271
+ /** A space-separated list of scopes granted to the OAuth application. */
272
+ scopes?: string;
273
+ /** An object of query params */
274
+ queryParams?: {
275
+ [key: string]: string;
276
+ };
277
+ /** If set to true does not immediately redirect the current browser context to visit the OAuth authorization page for the provider. */
278
+ skipBrowserRedirect?: boolean;
279
+ };
280
+ export type OAuthResponse = {
281
+ data: {
282
+ url: string;
283
+ };
284
+ error: null;
285
+ } | {
286
+ data: {
287
+ url: null;
288
+ };
289
+ error: AuthError;
290
+ };
291
+ export interface Session {
292
+ /**
293
+ * The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.
294
+ */
295
+ provider_token?: string | null;
296
+ /**
297
+ * The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API.
298
+ * Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.
299
+ */
300
+ provider_refresh_token?: string | null;
301
+ /**
302
+ * The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.
303
+ */
304
+ access_token: string;
305
+ /**
306
+ * A one-time used refresh token that never expires.
307
+ */
308
+ refresh_token: string;
309
+ /**
310
+ * The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.
311
+ */
312
+ expires_in: number;
313
+ /**
314
+ * A timestamp of when the token will expire. Returned when a login is confirmed.
315
+ */
316
+ expires_at?: number;
317
+ token_type: string;
318
+ user: User;
319
+ }
320
+ export type AuthResponse = {
321
+ data: {
322
+ user: User | null;
323
+ session: Session | null;
324
+ };
325
+ error: null;
326
+ } | {
327
+ data: {
328
+ user: null;
329
+ session: null;
330
+ };
331
+ error: AuthError;
332
+ };
333
+ export type AuthChangeEventMFA = "MFA_CHALLENGE_VERIFIED";
334
+ export type AuthChangeEvent = "INITIAL_SESSION" | "PASSWORD_RECOVERY" | "SIGNED_IN" | "SIGNED_OUT" | "TOKEN_REFRESHED" | "USER_UPDATED" | AuthChangeEventMFA;
335
+ export interface Subscription {
336
+ /**
337
+ * The subscriber UUID. This will be set by the client.
338
+ */
339
+ id: string;
340
+ /**
341
+ * The function to call every time there is an event. eg: (eventName) => {}
342
+ */
343
+ callback: (event: AuthChangeEvent, session: Session | null) => void;
344
+ /**
345
+ * Call this to remove the listener.
346
+ */
347
+ unsubscribe: () => void;
348
+ }
349
+ export type SignOut = {
350
+ /**
351
+ * Determines which sessions should be
352
+ * logged out. Global means all
353
+ * sessions by this account. Local
354
+ * means only this session. Others
355
+ * means all other sessions except the
356
+ * current one. When using others,
357
+ * there is no sign-out event fired on
358
+ * the current session!
359
+ */
360
+ scope?: "global" | "local" | "others";
361
+ };
362
+ export type InitializeResult = {
363
+ error: AuthError | null;
364
+ };
365
+ export type UserResponse = {
366
+ data: {
367
+ user: User;
368
+ };
369
+ error: null;
370
+ } | {
371
+ data: {
372
+ user: null;
373
+ };
374
+ error: AuthError;
375
+ };
376
+ export type CallRefreshTokenResult = {
377
+ session: Session;
378
+ error: null;
379
+ } | {
380
+ session: null;
381
+ error: AuthError;
382
+ };
383
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Extracts parameters encoded in the URL both in the query and fragment.
3
+ */
4
+ export declare function parseParametersFromURL(href: string): {
5
+ [parameter: string]: string;
6
+ };
7
+ export declare const clearURLParameters: (delete_params?: string[]) => void;
@@ -0,0 +1 @@
1
+ export declare const version = "0.0.0";
@@ -0,0 +1,19 @@
1
+ import { Base } from "../Base";
2
+ import { BaseLogOptions } from "../BaseLog";
3
+ import { LockFunc } from "./locks";
4
+ type LockOptions = {
5
+ storageKey: string;
6
+ lock?: LockFunc;
7
+ } & BaseLogOptions;
8
+ export declare class Lock extends Base {
9
+ protected lock: LockFunc;
10
+ lockAcquired: boolean;
11
+ protected pendingInLock: Promise<any>[];
12
+ protected storageKey: string;
13
+ constructor(options: LockOptions);
14
+ /**
15
+ * Acquires a global lock based on the storage key.
16
+ */
17
+ _acquireLock<R>(acquireTimeout: number, fn: () => Promise<R>): Promise<R>;
18
+ }
19
+ export {};