@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.
- package/dist/Base.d.ts +7 -0
- package/dist/BaseLog.d.ts +10 -0
- package/dist/FaableAuthApi.d.ts +13 -0
- package/dist/FaableAuthClient.d.ts +231 -0
- package/dist/entrypoints/faableauth.d.ts +6 -0
- package/dist/faableauth.js +1 -1
- package/dist/faableauth.js.map +1 -1
- package/dist/lib/constants.d.ts +10 -0
- package/dist/lib/errors.d.ts +82 -0
- package/dist/lib/fetch.d.ts +11 -0
- package/dist/lib/globals.d.ts +4 -0
- package/dist/lib/helpers.d.ts +52 -0
- package/dist/lib/jwt.d.ts +55 -0
- package/dist/lib/local-storage.d.ts +12 -0
- package/dist/lib/storage_helpers.d.ts +4 -0
- package/dist/lib/types.d.ts +383 -0
- package/dist/lib/url_helpers.d.ts +7 -0
- package/dist/lib/version.d.ts +1 -0
- package/dist/lock/Lock.d.ts +19 -0
- package/dist/lock/locks.d.ts +63 -0
- package/dist/utils.d.ts +17 -0
- package/package.json +3 -2
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provide your own global lock implementation instead of the default
|
|
3
|
+
* implementation. The function should acquire a lock for the duration of the
|
|
4
|
+
* `fn` async function, such that no other client instances will be able to
|
|
5
|
+
* hold it at the same time.
|
|
6
|
+
*
|
|
7
|
+
* @experimental
|
|
8
|
+
*
|
|
9
|
+
* @param name Name of the lock to be acquired.
|
|
10
|
+
* @param acquireTimeout If negative, no timeout should occur. If positive it
|
|
11
|
+
* should throw an Error with an `isAcquireTimeout`
|
|
12
|
+
* property set to true if the operation fails to be
|
|
13
|
+
* acquired after this much time (ms).
|
|
14
|
+
* @param fn The operation to execute when the lock is acquired.
|
|
15
|
+
*/
|
|
16
|
+
export type LockFunc = <R>(name: string, acquireTimeout: number, fn: () => Promise<R>) => Promise<R>;
|
|
17
|
+
/**
|
|
18
|
+
* @experimental
|
|
19
|
+
*/
|
|
20
|
+
export declare const internals: {
|
|
21
|
+
/**
|
|
22
|
+
* @experimental
|
|
23
|
+
*/
|
|
24
|
+
debug: boolean;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* An error thrown when a lock cannot be acquired after some amount of time.
|
|
28
|
+
*
|
|
29
|
+
* Use the {@link #isAcquireTimeout} property instead of checking with `instanceof`.
|
|
30
|
+
*/
|
|
31
|
+
export declare abstract class LockAcquireTimeoutError extends Error {
|
|
32
|
+
readonly isAcquireTimeout = true;
|
|
33
|
+
constructor(message: string);
|
|
34
|
+
}
|
|
35
|
+
export declare class NavigatorLockAcquireTimeoutError extends LockAcquireTimeoutError {
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Implements a global exclusive lock using the Navigator LockManager API. It
|
|
39
|
+
* is available on all browsers released after 2022-03-15 with Safari being the
|
|
40
|
+
* last one to release support. If the API is not available, this function will
|
|
41
|
+
* throw. Make sure you check availablility before configuring {@link
|
|
42
|
+
* GoTrueClient}.
|
|
43
|
+
*
|
|
44
|
+
* You can turn on debugging by setting the `supabase.gotrue-js.locks.debug`
|
|
45
|
+
* local storage item to `true`.
|
|
46
|
+
*
|
|
47
|
+
* Internals:
|
|
48
|
+
*
|
|
49
|
+
* Since the LockManager API does not preserve stack traces for the async
|
|
50
|
+
* function passed in the `request` method, a trick is used where acquiring the
|
|
51
|
+
* lock releases a previously started promise to run the operation in the `fn`
|
|
52
|
+
* function. The lock waits for that promise to finish (with or without error),
|
|
53
|
+
* while the function will finally wait for the result anyway.
|
|
54
|
+
*
|
|
55
|
+
* @param name Name of the lock to be acquired.
|
|
56
|
+
* @param acquireTimeout If negative, no timeout. If 0 an error is thrown if
|
|
57
|
+
* the lock can't be acquired without waiting. If positive, the lock acquire
|
|
58
|
+
* will time out after so many milliseconds. An error is
|
|
59
|
+
* a timeout if it has `isAcquireTimeout` set to true.
|
|
60
|
+
* @param fn The operation to run once the lock is acquired.
|
|
61
|
+
*/
|
|
62
|
+
export declare function navigatorLock<R>(name: string, acquireTimeout: number, fn: () => Promise<R>): Promise<R>;
|
|
63
|
+
export declare function lockNoOp<R>(name: string, acquireTimeout: number, fn: () => Promise<R>): Promise<R>;
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AuthenticationResult } from "./lib/types";
|
|
2
|
+
export declare const parseAuthenticationResult: (queryString: string) => AuthenticationResult;
|
|
3
|
+
export declare const createQueryParams: ({ clientId: client_id, ...params }: any) => string;
|
|
4
|
+
/**
|
|
5
|
+
* @ignore
|
|
6
|
+
*/
|
|
7
|
+
export declare const getTokenIssuer: (issuer: string | undefined, domainUrl: string) => string;
|
|
8
|
+
export declare const getDomain: (domainUrl: string) => string;
|
|
9
|
+
export declare const encode: (value: string) => string;
|
|
10
|
+
export declare const decode: (value: string) => string;
|
|
11
|
+
export declare const urlDecodeB64: (input: string) => string;
|
|
12
|
+
export declare const bufferToBase64UrlEncoded: (input: number[] | Uint8Array) => string;
|
|
13
|
+
export declare const parseNumber: (value: any) => number | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* @ignore
|
|
16
|
+
*/
|
|
17
|
+
export declare const buildIsAuthenticatedCookieName: (clientId: string) => string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faable/auth-js",
|
|
3
|
-
"main": "dist/
|
|
4
|
-
"
|
|
3
|
+
"main": "dist/faableauth.js",
|
|
4
|
+
"types": "dist/entrypints/faableauth.d.ts",
|
|
5
|
+
"version": "1.3.1",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"license": "SEE LICENSE.md",
|
|
7
8
|
"author": "Marc Pomar <marc@faable.com>",
|