@faable/auth-js 1.2.2 → 1.3.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 (55) hide show
  1. package/README.md +26 -1
  2. package/dist/faableauth.js +7 -0
  3. package/dist/faableauth.js.map +1 -0
  4. package/package.json +4 -24
  5. package/dist/Base.d.ts +0 -8
  6. package/dist/Base.d.ts.map +0 -1
  7. package/dist/Base.js +0 -16
  8. package/dist/BaseLog.d.ts +0 -11
  9. package/dist/BaseLog.d.ts.map +0 -1
  10. package/dist/BaseLog.js +0 -21
  11. package/dist/FaableAuthApi.d.ts +0 -14
  12. package/dist/FaableAuthApi.d.ts.map +0 -1
  13. package/dist/FaableAuthApi.js +0 -37
  14. package/dist/FaableAuthClient.d.ts +0 -227
  15. package/dist/FaableAuthClient.d.ts.map +0 -1
  16. package/dist/FaableAuthClient.js +0 -1073
  17. package/dist/index.d.ts +0 -7
  18. package/dist/index.d.ts.map +0 -1
  19. package/dist/index.js +0 -13
  20. package/dist/lib/constants.d.ts +0 -11
  21. package/dist/lib/constants.d.ts.map +0 -1
  22. package/dist/lib/constants.js +0 -13
  23. package/dist/lib/errors.d.ts +0 -83
  24. package/dist/lib/errors.d.ts.map +0 -1
  25. package/dist/lib/errors.js +0 -100
  26. package/dist/lib/fetch.d.ts +0 -8
  27. package/dist/lib/fetch.d.ts.map +0 -1
  28. package/dist/lib/fetch.js +0 -53
  29. package/dist/lib/helpers.d.ts +0 -42
  30. package/dist/lib/helpers.d.ts.map +0 -1
  31. package/dist/lib/helpers.js +0 -257
  32. package/dist/lib/jwt.d.ts +0 -56
  33. package/dist/lib/jwt.d.ts.map +0 -1
  34. package/dist/lib/jwt.js +0 -139
  35. package/dist/lib/local-storage.d.ts +0 -13
  36. package/dist/lib/local-storage.d.ts.map +0 -1
  37. package/dist/lib/local-storage.js +0 -45
  38. package/dist/lib/storage_helpers.d.ts +0 -5
  39. package/dist/lib/storage_helpers.d.ts.map +0 -1
  40. package/dist/lib/storage_helpers.js +0 -34
  41. package/dist/lib/types.d.ts +0 -384
  42. package/dist/lib/types.d.ts.map +0 -1
  43. package/dist/lib/types.js +0 -6
  44. package/dist/lib/version.d.ts +0 -2
  45. package/dist/lib/version.d.ts.map +0 -1
  46. package/dist/lib/version.js +0 -5
  47. package/dist/lock/Lock.d.ts +0 -20
  48. package/dist/lock/Lock.d.ts.map +0 -1
  49. package/dist/lock/Lock.js +0 -82
  50. package/dist/lock/locks.d.ts +0 -64
  51. package/dist/lock/locks.d.ts.map +0 -1
  52. package/dist/lock/locks.js +0 -137
  53. package/dist/utils.d.ts +0 -18
  54. package/dist/utils.d.ts.map +0 -1
  55. package/dist/utils.js +0 -88
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,qBAAa,IAAI;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;GAEG;AACH,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,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;IACpE;;OAEG;IACH,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB;AAED,MAAM,MAAM,OAAO,GAAG;IACpB;;;;;;;;;OASG;IACH,KAAK,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAAA;CAAE,CAAC;AAE3D,MAAM,MAAM,YAAY,GACpB;IACE,IAAI,EAAE;QACJ,IAAI,EAAE,IAAI,CAAC;KACZ,CAAC;IACF,KAAK,EAAE,IAAI,CAAC;CACb,GACD;IACE,IAAI,EAAE;QACJ,IAAI,EAAE,IAAI,CAAC;KACZ,CAAC;IACF,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEN,MAAM,MAAM,sBAAsB,GAC9B;IACE,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,IAAI,CAAC;CACb,GACD;IACE,OAAO,EAAE,IAAI,CAAC;IACd,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC"}
package/dist/lib/types.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.User = void 0;
4
- class User {
5
- }
6
- exports.User = User;
@@ -1,2 +0,0 @@
1
- export declare const version = "0.0.0";
2
- //# sourceMappingURL=version.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/lib/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,UAAU,CAAC"}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.version = void 0;
4
- // Will be overwriten by .github/workflows/release.yml
5
- exports.version = "0.0.0";
@@ -1,20 +0,0 @@
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 {};
20
- //# sourceMappingURL=Lock.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Lock.d.ts","sourceRoot":"","sources":["../../src/lock/Lock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAY,MAAM,SAAS,CAAC;AAE7C,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,QAAQ,CAAC;CACjB,GAAG,cAAc,CAAC;AAEnB,qBAAa,IAAK,SAAQ,IAAI;IAC5B,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC;IACzB,YAAY,UAAS;IACrB,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAM;IAE7C,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEjB,OAAO,EAAE,WAAW;IAMhC;;OAEG;IACG,YAAY,CAAC,CAAC,EAClB,cAAc,EAAE,MAAM,EACtB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC;CA+Ed"}
package/dist/lock/Lock.js DELETED
@@ -1,82 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Lock = void 0;
13
- const Base_1 = require("../Base");
14
- const locks_1 = require("./locks");
15
- class Lock extends Base_1.Base {
16
- constructor(options) {
17
- super({ debug: options.debug });
18
- this.lockAcquired = false;
19
- this.pendingInLock = [];
20
- this.lock = options.lock || locks_1.lockNoOp;
21
- this.storageKey = options.storageKey;
22
- }
23
- /**
24
- * Acquires a global lock based on the storage key.
25
- */
26
- _acquireLock(acquireTimeout, fn) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- this._debug("#_acquireLock", "begin", acquireTimeout);
29
- try {
30
- if (this.lockAcquired) {
31
- const last = this.pendingInLock.length
32
- ? this.pendingInLock[this.pendingInLock.length - 1]
33
- : Promise.resolve();
34
- const result = (() => __awaiter(this, void 0, void 0, function* () {
35
- yield last;
36
- return yield fn();
37
- }))();
38
- this.pendingInLock.push((() => __awaiter(this, void 0, void 0, function* () {
39
- try {
40
- yield result;
41
- }
42
- catch (e) {
43
- // we just care if it finished
44
- }
45
- }))());
46
- return result;
47
- }
48
- return yield this.lock(`lock:${this.storageKey}`, acquireTimeout, () => __awaiter(this, void 0, void 0, function* () {
49
- this._debug("#_acquireLock", "lock acquired for storage key", this.storageKey);
50
- try {
51
- this.lockAcquired = true;
52
- const result = fn();
53
- this.pendingInLock.push((() => __awaiter(this, void 0, void 0, function* () {
54
- try {
55
- yield result;
56
- }
57
- catch (e) {
58
- // we just care if it finished
59
- }
60
- }))());
61
- yield result;
62
- // keep draining the queue until there's nothing to wait on
63
- while (this.pendingInLock.length) {
64
- const waitOn = [...this.pendingInLock];
65
- yield Promise.all(waitOn);
66
- this.pendingInLock.splice(0, waitOn.length);
67
- }
68
- return yield result;
69
- }
70
- finally {
71
- this._debug("#_acquireLock", "lock released for storage key", this.storageKey);
72
- this.lockAcquired = false;
73
- }
74
- }));
75
- }
76
- finally {
77
- this._debug("#_acquireLock", "end");
78
- }
79
- });
80
- }
81
- }
82
- exports.Lock = Lock;
@@ -1,64 +0,0 @@
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>;
64
- //# sourceMappingURL=locks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"locks.d.ts","sourceRoot":"","sources":["../../src/lock/locks.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,EACvB,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM,EACtB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,KACjB,OAAO,CAAC,CAAC,CAAC,CAAC;AAEhB;;GAEG;AACH,eAAO,MAAM,SAAS;IACpB;;OAEG;;CAOJ,CAAC;AAEF;;;;GAIG;AACH,8BAAsB,uBAAwB,SAAQ,KAAK;IACzD,SAAgB,gBAAgB,QAAQ;gBAE5B,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,gCAAiC,SAAQ,uBAAuB;CAAG;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,aAAa,CAAC,CAAC,EACnC,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM,EACtB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAmGZ;AAED,wBAAsB,QAAQ,CAAC,CAAC,EAC9B,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM,EACtB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAEZ"}
@@ -1,137 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.lockNoOp = exports.navigatorLock = exports.NavigatorLockAcquireTimeoutError = exports.LockAcquireTimeoutError = exports.internals = void 0;
13
- const helpers_1 = require("../lib/helpers");
14
- /**
15
- * @experimental
16
- */
17
- exports.internals = {
18
- /**
19
- * @experimental
20
- */
21
- debug: !!(globalThis &&
22
- (0, helpers_1.supportsLocalStorage)() &&
23
- globalThis.localStorage &&
24
- globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug") === "true"),
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
- class LockAcquireTimeoutError extends Error {
32
- constructor(message) {
33
- super(message);
34
- this.isAcquireTimeout = true;
35
- }
36
- }
37
- exports.LockAcquireTimeoutError = LockAcquireTimeoutError;
38
- class NavigatorLockAcquireTimeoutError extends LockAcquireTimeoutError {
39
- }
40
- exports.NavigatorLockAcquireTimeoutError = NavigatorLockAcquireTimeoutError;
41
- /**
42
- * Implements a global exclusive lock using the Navigator LockManager API. It
43
- * is available on all browsers released after 2022-03-15 with Safari being the
44
- * last one to release support. If the API is not available, this function will
45
- * throw. Make sure you check availablility before configuring {@link
46
- * GoTrueClient}.
47
- *
48
- * You can turn on debugging by setting the `supabase.gotrue-js.locks.debug`
49
- * local storage item to `true`.
50
- *
51
- * Internals:
52
- *
53
- * Since the LockManager API does not preserve stack traces for the async
54
- * function passed in the `request` method, a trick is used where acquiring the
55
- * lock releases a previously started promise to run the operation in the `fn`
56
- * function. The lock waits for that promise to finish (with or without error),
57
- * while the function will finally wait for the result anyway.
58
- *
59
- * @param name Name of the lock to be acquired.
60
- * @param acquireTimeout If negative, no timeout. If 0 an error is thrown if
61
- * the lock can't be acquired without waiting. If positive, the lock acquire
62
- * will time out after so many milliseconds. An error is
63
- * a timeout if it has `isAcquireTimeout` set to true.
64
- * @param fn The operation to run once the lock is acquired.
65
- */
66
- function navigatorLock(name, acquireTimeout, fn) {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- if (exports.internals.debug) {
69
- console.log("@supabase/gotrue-js: navigatorLock: acquire lock", name, acquireTimeout);
70
- }
71
- const abortController = new globalThis.AbortController();
72
- if (acquireTimeout > 0) {
73
- setTimeout(() => {
74
- abortController.abort();
75
- if (exports.internals.debug) {
76
- console.log("@supabase/gotrue-js: navigatorLock acquire timed out", name);
77
- }
78
- }, acquireTimeout);
79
- }
80
- // MDN article: https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request
81
- return yield globalThis.navigator.locks.request(name, acquireTimeout === 0
82
- ? {
83
- mode: "exclusive",
84
- ifAvailable: true,
85
- }
86
- : {
87
- mode: "exclusive",
88
- signal: abortController.signal,
89
- }, (lock) => __awaiter(this, void 0, void 0, function* () {
90
- if (lock) {
91
- if (exports.internals.debug) {
92
- console.log("@supabase/gotrue-js: navigatorLock: acquired", name, lock.name);
93
- }
94
- try {
95
- return yield fn();
96
- }
97
- finally {
98
- if (exports.internals.debug) {
99
- console.log("@supabase/gotrue-js: navigatorLock: released", name, lock.name);
100
- }
101
- }
102
- }
103
- else {
104
- if (acquireTimeout === 0) {
105
- if (exports.internals.debug) {
106
- console.log("@supabase/gotrue-js: navigatorLock: not immediately available", name);
107
- }
108
- throw new NavigatorLockAcquireTimeoutError(`Acquiring an exclusive Navigator LockManager lock "${name}" immediately failed`);
109
- }
110
- else {
111
- if (exports.internals.debug) {
112
- try {
113
- const result = yield globalThis.navigator.locks.query();
114
- console.log("@supabase/gotrue-js: Navigator LockManager state", JSON.stringify(result, null, " "));
115
- }
116
- catch (e) {
117
- console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state", e);
118
- }
119
- }
120
- // Browser is not following the Navigator LockManager spec, it
121
- // returned a null lock when we didn't use ifAvailable. So we can
122
- // pretend the lock is acquired in the name of backward compatibility
123
- // and user experience and just run the function.
124
- console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request");
125
- return yield fn();
126
- }
127
- }
128
- }));
129
- });
130
- }
131
- exports.navigatorLock = navigatorLock;
132
- function lockNoOp(name, acquireTimeout, fn) {
133
- return __awaiter(this, void 0, void 0, function* () {
134
- return yield fn();
135
- });
136
- }
137
- exports.lockNoOp = lockNoOp;
package/dist/utils.d.ts DELETED
@@ -1,18 +0,0 @@
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;
18
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,eAAO,MAAM,yBAAyB,gBACvB,MAAM,KAClB,oBAaF,CAAC;AAQF,eAAO,MAAM,iBAAiB,uCAAwC,GAAG,WAIxE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,WACjB,MAAM,GAAG,SAAS,aACf,MAAM,WAOlB,CAAC;AAEF,eAAO,MAAM,SAAS,cAAe,MAAM,WAM1C,CAAC;AAEF,eAAO,MAAM,MAAM,UAAW,MAAM,WAAgB,CAAC;AACrD,eAAO,MAAM,MAAM,UAAW,MAAM,WAAgB,CAAC;AAkBrD,eAAO,MAAM,YAAY,UAAW,MAAM,WACc,CAAC;AAEzD,eAAO,MAAM,wBAAwB,UAAW,MAAM,EAAE,GAAG,UAAU,WAKpE,CAAC;AAEF,eAAO,MAAM,WAAW,UAAW,GAAG,KAAG,MAAM,GAAG,SAKjD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,8BAA8B,aAAc,MAAM,WACzB,CAAC"}
package/dist/utils.js DELETED
@@ -1,88 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.buildIsAuthenticatedCookieName = exports.parseNumber = exports.bufferToBase64UrlEncoded = exports.urlDecodeB64 = exports.decode = exports.encode = exports.getDomain = exports.getTokenIssuer = exports.createQueryParams = exports.parseAuthenticationResult = void 0;
15
- const parseAuthenticationResult = (queryString) => {
16
- if (queryString.indexOf("#") > -1) {
17
- queryString = queryString.substring(0, queryString.indexOf("#"));
18
- }
19
- const searchParams = new URLSearchParams(queryString);
20
- return {
21
- state: searchParams.get("state"),
22
- code: searchParams.get("code") || undefined,
23
- error: searchParams.get("error") || undefined,
24
- error_description: searchParams.get("error_description") || undefined,
25
- };
26
- };
27
- exports.parseAuthenticationResult = parseAuthenticationResult;
28
- const stripUndefined = (params) => {
29
- return Object.keys(params)
30
- .filter((k) => typeof params[k] !== "undefined")
31
- .reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [key]: params[key] })), {});
32
- };
33
- const createQueryParams = (_a) => {
34
- var { clientId: client_id } = _a, params = __rest(_a, ["clientId"]);
35
- return new URLSearchParams(stripUndefined(Object.assign({ client_id }, params))).toString();
36
- };
37
- exports.createQueryParams = createQueryParams;
38
- /**
39
- * @ignore
40
- */
41
- const getTokenIssuer = (issuer, domainUrl) => {
42
- if (issuer) {
43
- return issuer.startsWith("https://") ? issuer : `https://${issuer}`;
44
- }
45
- return `${domainUrl}`;
46
- };
47
- exports.getTokenIssuer = getTokenIssuer;
48
- const getDomain = (domainUrl) => {
49
- if (!/^https?:\/\//.test(domainUrl)) {
50
- return `https://${domainUrl}`;
51
- }
52
- return domainUrl;
53
- };
54
- exports.getDomain = getDomain;
55
- const encode = (value) => btoa(value);
56
- exports.encode = encode;
57
- const decode = (value) => atob(value);
58
- exports.decode = decode;
59
- // https://stackoverflow.com/questions/30106476/
60
- const decodeB64 = (input) => decodeURIComponent(atob(input)
61
- .split("")
62
- .map((c) => {
63
- return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
64
- })
65
- .join(""));
66
- const urlEncodeB64 = (input) => {
67
- const b64Chars = { "+": "-", "/": "_", "=": "" };
68
- return input.replace(/[+/=]/g, (m) => b64Chars[m]);
69
- };
70
- const urlDecodeB64 = (input) => decodeB64(input.replace(/_/g, "/").replace(/-/g, "+"));
71
- exports.urlDecodeB64 = urlDecodeB64;
72
- const bufferToBase64UrlEncoded = (input) => {
73
- const ie11SafeInput = new Uint8Array(input);
74
- return urlEncodeB64(window.btoa(String.fromCharCode(...Array.from(ie11SafeInput))));
75
- };
76
- exports.bufferToBase64UrlEncoded = bufferToBase64UrlEncoded;
77
- const parseNumber = (value) => {
78
- if (typeof value !== "string") {
79
- return value;
80
- }
81
- return parseInt(value, 10) || undefined;
82
- };
83
- exports.parseNumber = parseNumber;
84
- /**
85
- * @ignore
86
- */
87
- const buildIsAuthenticatedCookieName = (clientId) => `auth0.${clientId}.is.authenticated`;
88
- exports.buildIsAuthenticatedCookieName = buildIsAuthenticatedCookieName;