@clerk/expo 2.19.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 (173) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +74 -0
  3. package/dist/cache/MemoryTokenCache.d.ts +3 -0
  4. package/dist/cache/MemoryTokenCache.d.ts.map +1 -0
  5. package/dist/cache/MemoryTokenCache.js +44 -0
  6. package/dist/cache/MemoryTokenCache.js.map +1 -0
  7. package/dist/cache/ResourceCache.d.ts +6 -0
  8. package/dist/cache/ResourceCache.d.ts.map +1 -0
  9. package/dist/cache/ResourceCache.js +84 -0
  10. package/dist/cache/ResourceCache.js.map +1 -0
  11. package/dist/cache/dummy-data/client-resource.d.ts +3 -0
  12. package/dist/cache/dummy-data/client-resource.d.ts.map +1 -0
  13. package/dist/cache/dummy-data/client-resource.js +157 -0
  14. package/dist/cache/dummy-data/client-resource.js.map +1 -0
  15. package/dist/cache/dummy-data/environment-resource.d.ts +3 -0
  16. package/dist/cache/dummy-data/environment-resource.d.ts.map +1 -0
  17. package/dist/cache/dummy-data/environment-resource.js +260 -0
  18. package/dist/cache/dummy-data/environment-resource.js.map +1 -0
  19. package/dist/cache/dummy-data/index.d.ts +3 -0
  20. package/dist/cache/dummy-data/index.d.ts.map +1 -0
  21. package/dist/cache/dummy-data/index.js +32 -0
  22. package/dist/cache/dummy-data/index.js.map +1 -0
  23. package/dist/cache/index.d.ts +5 -0
  24. package/dist/cache/index.d.ts.map +1 -0
  25. package/dist/cache/index.js +44 -0
  26. package/dist/cache/index.js.map +1 -0
  27. package/dist/cache/types.d.ts +18 -0
  28. package/dist/cache/types.d.ts.map +1 -0
  29. package/dist/cache/types.js +17 -0
  30. package/dist/cache/types.js.map +1 -0
  31. package/dist/components/controlComponents.d.ts +2 -0
  32. package/dist/components/controlComponents.d.ts.map +1 -0
  33. package/dist/components/controlComponents.js +37 -0
  34. package/dist/components/controlComponents.js.map +1 -0
  35. package/dist/components/index.d.ts +2 -0
  36. package/dist/components/index.d.ts.map +1 -0
  37. package/dist/components/index.js +23 -0
  38. package/dist/components/index.js.map +1 -0
  39. package/dist/errorThrower.d.ts +3 -0
  40. package/dist/errorThrower.d.ts.map +1 -0
  41. package/dist/errorThrower.js +30 -0
  42. package/dist/errorThrower.js.map +1 -0
  43. package/dist/experimental.d.ts +2 -0
  44. package/dist/experimental.d.ts.map +1 -0
  45. package/dist/experimental.js +17 -0
  46. package/dist/experimental.js.map +1 -0
  47. package/dist/global.d.js +2 -0
  48. package/dist/global.d.js.map +1 -0
  49. package/dist/hooks/index.d.ts +6 -0
  50. package/dist/hooks/index.d.ts.map +1 -0
  51. package/dist/hooks/index.js +56 -0
  52. package/dist/hooks/index.js.map +1 -0
  53. package/dist/hooks/useAuth.d.ts +3 -0
  54. package/dist/hooks/useAuth.d.ts.map +1 -0
  55. package/dist/hooks/useAuth.js +50 -0
  56. package/dist/hooks/useAuth.js.map +1 -0
  57. package/dist/hooks/useOAuth.d.ts +25 -0
  58. package/dist/hooks/useOAuth.d.ts.map +1 -0
  59. package/dist/hooks/useOAuth.js +104 -0
  60. package/dist/hooks/useOAuth.js.map +1 -0
  61. package/dist/hooks/useSSO.d.ts +23 -0
  62. package/dist/hooks/useSSO.d.ts.map +1 -0
  63. package/dist/hooks/useSSO.js +105 -0
  64. package/dist/hooks/useSSO.js.map +1 -0
  65. package/dist/hooks/useSignInWithApple.d.ts +50 -0
  66. package/dist/hooks/useSignInWithApple.d.ts.map +1 -0
  67. package/dist/hooks/useSignInWithApple.ios.d.ts +51 -0
  68. package/dist/hooks/useSignInWithApple.ios.d.ts.map +1 -0
  69. package/dist/hooks/useSignInWithApple.ios.js +117 -0
  70. package/dist/hooks/useSignInWithApple.ios.js.map +1 -0
  71. package/dist/hooks/useSignInWithApple.js +39 -0
  72. package/dist/hooks/useSignInWithApple.js.map +1 -0
  73. package/dist/index.d.ts +11 -0
  74. package/dist/index.d.ts.map +1 -0
  75. package/dist/index.js +52 -0
  76. package/dist/index.js.map +1 -0
  77. package/dist/legacy.d.ts +2 -0
  78. package/dist/legacy.d.ts.map +1 -0
  79. package/dist/legacy.js +31 -0
  80. package/dist/legacy.js.map +1 -0
  81. package/dist/local-credentials/index.d.ts +2 -0
  82. package/dist/local-credentials/index.d.ts.map +1 -0
  83. package/dist/local-credentials/index.js +29 -0
  84. package/dist/local-credentials/index.js.map +1 -0
  85. package/dist/local-credentials/useLocalCredentials/index.d.ts +2 -0
  86. package/dist/local-credentials/useLocalCredentials/index.d.ts.map +1 -0
  87. package/dist/local-credentials/useLocalCredentials/index.js +29 -0
  88. package/dist/local-credentials/useLocalCredentials/index.js.map +1 -0
  89. package/dist/local-credentials/useLocalCredentials/shared.d.ts +24 -0
  90. package/dist/local-credentials/useLocalCredentials/shared.d.ts.map +1 -0
  91. package/dist/local-credentials/useLocalCredentials/shared.js +37 -0
  92. package/dist/local-credentials/useLocalCredentials/shared.js.map +1 -0
  93. package/dist/local-credentials/useLocalCredentials/useLocalCredentials.d.ts +7 -0
  94. package/dist/local-credentials/useLocalCredentials/useLocalCredentials.d.ts.map +1 -0
  95. package/dist/local-credentials/useLocalCredentials/useLocalCredentials.js +195 -0
  96. package/dist/local-credentials/useLocalCredentials/useLocalCredentials.js.map +1 -0
  97. package/dist/local-credentials/useLocalCredentials/useLocalCredentials.web.d.ts +3 -0
  98. package/dist/local-credentials/useLocalCredentials/useLocalCredentials.web.d.ts.map +1 -0
  99. package/dist/local-credentials/useLocalCredentials/useLocalCredentials.web.js +32 -0
  100. package/dist/local-credentials/useLocalCredentials/useLocalCredentials.web.js.map +1 -0
  101. package/dist/passkeys/index.d.ts +3 -0
  102. package/dist/passkeys/index.d.ts.map +1 -0
  103. package/dist/passkeys/index.js +29 -0
  104. package/dist/passkeys/index.js.map +1 -0
  105. package/dist/polyfills/base64Polyfill.d.ts +2 -0
  106. package/dist/polyfills/base64Polyfill.d.ts.map +1 -0
  107. package/dist/polyfills/base64Polyfill.js +10 -0
  108. package/dist/polyfills/base64Polyfill.js.map +1 -0
  109. package/dist/polyfills/index.d.ts +3 -0
  110. package/dist/polyfills/index.d.ts.map +1 -0
  111. package/dist/polyfills/index.js +4 -0
  112. package/dist/polyfills/index.js.map +1 -0
  113. package/dist/provider/ClerkProvider.d.ts +32 -0
  114. package/dist/provider/ClerkProvider.d.ts.map +1 -0
  115. package/dist/provider/ClerkProvider.js +85 -0
  116. package/dist/provider/ClerkProvider.js.map +1 -0
  117. package/dist/provider/singleton/createClerkInstance.d.ts +9 -0
  118. package/dist/provider/singleton/createClerkInstance.d.ts.map +1 -0
  119. package/dist/provider/singleton/createClerkInstance.js +167 -0
  120. package/dist/provider/singleton/createClerkInstance.js.map +1 -0
  121. package/dist/provider/singleton/index.d.ts +2 -0
  122. package/dist/provider/singleton/index.d.ts.map +1 -0
  123. package/dist/provider/singleton/index.js +23 -0
  124. package/dist/provider/singleton/index.js.map +1 -0
  125. package/dist/provider/singleton/singleton.d.ts +25 -0
  126. package/dist/provider/singleton/singleton.d.ts.map +1 -0
  127. package/dist/provider/singleton/singleton.js +34 -0
  128. package/dist/provider/singleton/singleton.js.map +1 -0
  129. package/dist/provider/singleton/singleton.web.d.ts +11 -0
  130. package/dist/provider/singleton/singleton.web.d.ts.map +1 -0
  131. package/dist/provider/singleton/singleton.web.js +36 -0
  132. package/dist/provider/singleton/singleton.web.js.map +1 -0
  133. package/dist/provider/singleton/types.d.ts +26 -0
  134. package/dist/provider/singleton/types.d.ts.map +1 -0
  135. package/dist/provider/singleton/types.js +17 -0
  136. package/dist/provider/singleton/types.js.map +1 -0
  137. package/dist/resource-cache/index.d.ts +2 -0
  138. package/dist/resource-cache/index.d.ts.map +1 -0
  139. package/dist/resource-cache/index.js +29 -0
  140. package/dist/resource-cache/index.js.map +1 -0
  141. package/dist/resource-cache/resource-cache.d.ts +17 -0
  142. package/dist/resource-cache/resource-cache.d.ts.map +1 -0
  143. package/dist/resource-cache/resource-cache.js +154 -0
  144. package/dist/resource-cache/resource-cache.js.map +1 -0
  145. package/dist/secure-store/index.d.ts +6 -0
  146. package/dist/secure-store/index.d.ts.map +1 -0
  147. package/dist/secure-store/index.js +30 -0
  148. package/dist/secure-store/index.js.map +1 -0
  149. package/dist/token-cache/index.d.ts +16 -0
  150. package/dist/token-cache/index.d.ts.map +1 -0
  151. package/dist/token-cache/index.js +66 -0
  152. package/dist/token-cache/index.js.map +1 -0
  153. package/dist/utils/errors.d.ts +2 -0
  154. package/dist/utils/errors.d.ts.map +1 -0
  155. package/dist/utils/errors.js +30 -0
  156. package/dist/utils/errors.js.map +1 -0
  157. package/dist/utils/index.d.ts +3 -0
  158. package/dist/utils/index.d.ts.map +1 -0
  159. package/dist/utils/index.js +25 -0
  160. package/dist/utils/index.js.map +1 -0
  161. package/dist/utils/runtime.d.ts +10 -0
  162. package/dist/utils/runtime.d.ts.map +1 -0
  163. package/dist/utils/runtime.js +47 -0
  164. package/dist/utils/runtime.js.map +1 -0
  165. package/dist/web/index.d.ts +3 -0
  166. package/dist/web/index.d.ts.map +1 -0
  167. package/dist/web/index.js +25 -0
  168. package/dist/web/index.js.map +1 -0
  169. package/dist/web/uiComponents.d.ts +18 -0
  170. package/dist/web/uiComponents.d.ts.map +1 -0
  171. package/dist/web/uiComponents.js +88 -0
  172. package/dist/web/uiComponents.js.map +1 -0
  173. package/package.json +138 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Clerk, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ <p align="center">
2
+ <a href="https://clerk.com?utm_source=github&utm_medium=clerk_expo" target="_blank" rel="noopener noreferrer">
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="https://images.clerk.com/static/logo-dark-mode-400x400.png">
5
+ <img src="https://images.clerk.com/static/logo-light-mode-400x400.png" height="64">
6
+ </picture>
7
+ </a>
8
+ <br />
9
+ <h1 align="center">@clerk/expo</h1>
10
+ </p>
11
+
12
+ <div align="center">
13
+
14
+ [![Chat on Discord](https://img.shields.io/discord/856971667393609759.svg?logo=discord)](https://clerk.com/discord)
15
+ [![Clerk documentation](https://img.shields.io/badge/documentation-clerk-green.svg)](https://clerk.com/docs?utm_source=github&utm_medium=clerk_expo)
16
+ [![Follow on Twitter](https://img.shields.io/twitter/follow/ClerkDev?style=social)](https://twitter.com/intent/follow?screen_name=ClerkDev)
17
+
18
+ [Changelog](https://github.com/clerk/javascript/blob/main/packages/expo/CHANGELOG.md)
19
+ ·
20
+ [Report a Bug](https://github.com/clerk/javascript/issues/new?assignees=&labels=needs-triage&projects=&template=BUG_REPORT.yml)
21
+ ·
22
+ [Request a Feature](https://feedback.clerk.com/roadmap)
23
+ ·
24
+ [Get help](https://clerk.com/contact/support?utm_source=github&utm_medium=clerk_expo)
25
+
26
+ </div>
27
+
28
+ ## Getting Started
29
+
30
+ [Clerk](https://clerk.com/?utm_source=github&utm_medium=clerk_expo) is the easiest way to add authentication and user management to your Expo application. Add sign up, sign in, and profile management to your application in minutes.
31
+
32
+ ### Prerequisites
33
+
34
+ - React 18 or later
35
+ - Expo 50 or later
36
+ - React Native 0.73 or later
37
+ - Node.js `>=18.17.0` or later
38
+ - An existing Expo application
39
+ - An existing Clerk application. [Create your account for free](https://dashboard.clerk.com/sign-up?utm_source=github&utm_medium=clerk_expo).
40
+
41
+ ### Installation
42
+
43
+ The fastest way to get started with Clerk is by following the [Expo Quickstart](https://clerk.com/docs/quickstarts/expo?utm_source=github&utm_medium=clerk_expo).
44
+
45
+ You'll learn how to create an Expo application, install `@clerk/expo`, set up your environment keys, add `<ClerkProvider>`, protect specific pages, and use Clerk's React hooks.
46
+
47
+ ## Usage
48
+
49
+ For further information, guides, and examples visit the [Expo reference documentation](https://clerk.com/docs/references/expo/overview?utm_source=github&utm_medium=clerk_expo).
50
+
51
+ ## Support
52
+
53
+ You can get in touch with us in any of the following ways:
54
+
55
+ - Join our official community [Discord server](https://clerk.com/discord)
56
+ - On [our support page](https://clerk.com/contact/support?utm_source=github&utm_medium=clerk_expo)
57
+
58
+ ## Contributing
59
+
60
+ We're open to all community contributions! If you'd like to contribute in any way, please read [our contribution guidelines](https://github.com/clerk/javascript/blob/main/docs/CONTRIBUTING.md) and [code of conduct](https://github.com/clerk/javascript/blob/main/docs/CODE_OF_CONDUCT.md).
61
+
62
+ ## Security
63
+
64
+ `@clerk/expo` follows good practices of security, but 100% security cannot be assured.
65
+
66
+ `@clerk/expo` is provided **"as is"** without any **warranty**. Use at your own risk.
67
+
68
+ _For more information and to report security issues, please refer to our [security documentation](https://github.com/clerk/javascript/blob/main/docs/SECURITY.md)._
69
+
70
+ ## License
71
+
72
+ This project is licensed under the **MIT license**.
73
+
74
+ See [LICENSE](https://github.com/clerk/javascript/blob/main/packages/expo/LICENSE) for more information.
@@ -0,0 +1,3 @@
1
+ import type { TokenCache } from './types';
2
+ export declare const MemoryTokenCache: TokenCache;
3
+ //# sourceMappingURL=MemoryTokenCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryTokenCache.d.ts","sourceRoot":"","sources":["../../src/cache/MemoryTokenCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAkB1C,eAAO,MAAM,gBAAgB,YAA2B,CAAC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var MemoryTokenCache_exports = {};
20
+ __export(MemoryTokenCache_exports, {
21
+ MemoryTokenCache: () => MemoryTokenCache
22
+ });
23
+ module.exports = __toCommonJS(MemoryTokenCache_exports);
24
+ const createMemoryTokenCache = () => {
25
+ const cache = {};
26
+ return {
27
+ saveToken: (key, token) => {
28
+ cache[key] = token;
29
+ return Promise.resolve();
30
+ },
31
+ getToken: (key) => {
32
+ return Promise.resolve(cache[key]);
33
+ },
34
+ clearToken: (key) => {
35
+ delete cache[key];
36
+ }
37
+ };
38
+ };
39
+ const MemoryTokenCache = createMemoryTokenCache();
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ MemoryTokenCache
43
+ });
44
+ //# sourceMappingURL=MemoryTokenCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/cache/MemoryTokenCache.ts"],"sourcesContent":["import type { TokenCache } from './types';\n\nconst createMemoryTokenCache = (): TokenCache => {\n const cache: Record<string, string> = {};\n return {\n saveToken: (key, token) => {\n cache[key] = token;\n return Promise.resolve();\n },\n getToken: key => {\n return Promise.resolve(cache[key]);\n },\n clearToken: key => {\n delete cache[key];\n },\n };\n};\n\nexport const MemoryTokenCache = createMemoryTokenCache();\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,MAAM,yBAAyB,MAAkB;AAC/C,QAAM,QAAgC,CAAC;AACvC,SAAO;AAAA,IACL,WAAW,CAAC,KAAK,UAAU;AACzB,YAAM,GAAG,IAAI;AACb,aAAO,QAAQ,QAAQ;AAAA,IACzB;AAAA,IACA,UAAU,SAAO;AACf,aAAO,QAAQ,QAAQ,MAAM,GAAG,CAAC;AAAA,IACnC;AAAA,IACA,YAAY,SAAO;AACjB,aAAO,MAAM,GAAG;AAAA,IAClB;AAAA,EACF;AACF;AAEO,MAAM,mBAAmB,uBAAuB;","names":[]}
@@ -0,0 +1,6 @@
1
+ import type { ClientJSONSnapshot } from '@clerk/shared/types';
2
+ import type { ResourceCache } from './types';
3
+ export declare const EnvironmentResourceCache: ResourceCache<import("@clerk/shared/types").EnvironmentJSON>;
4
+ export declare const ClientResourceCache: ResourceCache<ClientJSONSnapshot>;
5
+ export declare const SessionJWTCache: ResourceCache<string>;
6
+ //# sourceMappingURL=ResourceCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResourceCache.d.ts","sourceRoot":"","sources":["../../src/cache/ResourceCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAA2B,MAAM,qBAAqB,CAAC;AAGvF,OAAO,KAAK,EAAE,aAAa,EAA4B,MAAM,SAAS,CAAC;AA8DvE,eAAO,MAAM,wBAAwB,8DAA4E,CAAC;AAClH,eAAO,MAAM,mBAAmB,mCAAkE,CAAC;AACnG,eAAO,MAAM,eAAe,uBAA2D,CAAC"}
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var ResourceCache_exports = {};
20
+ __export(ResourceCache_exports, {
21
+ ClientResourceCache: () => ClientResourceCache,
22
+ EnvironmentResourceCache: () => EnvironmentResourceCache,
23
+ SessionJWTCache: () => SessionJWTCache
24
+ });
25
+ module.exports = __toCommonJS(ResourceCache_exports);
26
+ function createResourceCache(key) {
27
+ if (!key) {
28
+ throw new Error("Clerk: ResourceCache key is required!");
29
+ }
30
+ let storage = null;
31
+ let itemKey = null;
32
+ const init = (opts) => {
33
+ if (!opts.storage || !opts.publishableKey) {
34
+ throw new Error(`Clerk: ResourceCache for ${key} requires storage and publishableKey!`);
35
+ }
36
+ itemKey = `${key}_${opts.publishableKey.slice(-5)}`;
37
+ storage = opts.storage();
38
+ };
39
+ const checkInit = () => {
40
+ return !!storage && !!itemKey;
41
+ };
42
+ const assertInitiliazed = () => {
43
+ if (!storage || !itemKey) {
44
+ throw new Error(`Clerk: ResourceCache for ${key} not initialized!`);
45
+ }
46
+ };
47
+ const load = async () => {
48
+ assertInitiliazed();
49
+ try {
50
+ const value = await storage.get(itemKey);
51
+ return value ? JSON.parse(value) : null;
52
+ } catch (error) {
53
+ console.log(`Clerk: Error loading value on ${key} from storage:`, error);
54
+ return null;
55
+ }
56
+ };
57
+ const save = async (value) => {
58
+ assertInitiliazed();
59
+ try {
60
+ return await storage.set(itemKey, JSON.stringify(value));
61
+ } catch (error) {
62
+ console.log(`Clerk: Error saving value on ${key} in storage:`, error);
63
+ }
64
+ };
65
+ const remove = async () => {
66
+ assertInitiliazed();
67
+ try {
68
+ return await storage.set(itemKey, "");
69
+ } catch (error) {
70
+ console.log(`Clerk: Error deleting value on ${key} from storage:`, error);
71
+ }
72
+ };
73
+ return { checkInit, init, load, save, remove };
74
+ }
75
+ const EnvironmentResourceCache = createResourceCache("__clerk_cache_environment");
76
+ const ClientResourceCache = createResourceCache("__clerk_cache_client");
77
+ const SessionJWTCache = createResourceCache("__clerk_cache_session_jwt");
78
+ // Annotate the CommonJS export names for ESM import in node:
79
+ 0 && (module.exports = {
80
+ ClientResourceCache,
81
+ EnvironmentResourceCache,
82
+ SessionJWTCache
83
+ });
84
+ //# sourceMappingURL=ResourceCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/cache/ResourceCache.ts"],"sourcesContent":["import type { ClientJSONSnapshot, EnvironmentJSONSnapshot } from '@clerk/shared/types';\n\nimport type { IStorage } from '../provider/singleton/types';\nimport type { ResourceCache, ResourceCacheInitOptions } from './types';\n\nfunction createResourceCache<T>(key: string): ResourceCache<T> {\n if (!key) {\n throw new Error('Clerk: ResourceCache key is required!');\n }\n let storage: IStorage | null = null;\n let itemKey: string | null = null;\n\n const init = (opts: ResourceCacheInitOptions) => {\n if (!opts.storage || !opts.publishableKey) {\n throw new Error(`Clerk: ResourceCache for ${key} requires storage and publishableKey!`);\n }\n itemKey = `${key}_${opts.publishableKey.slice(-5)}`;\n storage = opts.storage();\n };\n\n const checkInit = (): boolean => {\n return !!storage && !!itemKey;\n };\n\n const assertInitiliazed = () => {\n if (!storage || !itemKey) {\n throw new Error(`Clerk: ResourceCache for ${key} not initialized!`);\n }\n };\n\n const load = async (): Promise<T | null> => {\n assertInitiliazed();\n try {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const value = await storage!.get(itemKey!);\n return value ? JSON.parse(value) : null;\n } catch (error) {\n console.log(`Clerk: Error loading value on ${key} from storage:`, error);\n return null;\n }\n };\n\n const save = async (value: T): Promise<void> => {\n assertInitiliazed();\n try {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return await storage!.set(itemKey!, JSON.stringify(value));\n } catch (error) {\n console.log(`Clerk: Error saving value on ${key} in storage:`, error);\n }\n };\n\n const remove = async (): Promise<void> => {\n assertInitiliazed();\n try {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return await storage!.set(itemKey!, '');\n } catch (error) {\n console.log(`Clerk: Error deleting value on ${key} from storage:`, error);\n }\n };\n\n return { checkInit, init, load, save, remove };\n}\n\nexport const EnvironmentResourceCache = createResourceCache<EnvironmentJSONSnapshot>('__clerk_cache_environment');\nexport const ClientResourceCache = createResourceCache<ClientJSONSnapshot>('__clerk_cache_client');\nexport const SessionJWTCache = createResourceCache<string>('__clerk_cache_session_jwt');\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,SAAS,oBAAuB,KAA+B;AAC7D,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,uCAAuC;AAAA,EACzD;AACA,MAAI,UAA2B;AAC/B,MAAI,UAAyB;AAE7B,QAAM,OAAO,CAAC,SAAmC;AAC/C,QAAI,CAAC,KAAK,WAAW,CAAC,KAAK,gBAAgB;AACzC,YAAM,IAAI,MAAM,4BAA4B,GAAG,uCAAuC;AAAA,IACxF;AACA,cAAU,GAAG,GAAG,IAAI,KAAK,eAAe,MAAM,EAAE,CAAC;AACjD,cAAU,KAAK,QAAQ;AAAA,EACzB;AAEA,QAAM,YAAY,MAAe;AAC/B,WAAO,CAAC,CAAC,WAAW,CAAC,CAAC;AAAA,EACxB;AAEA,QAAM,oBAAoB,MAAM;AAC9B,QAAI,CAAC,WAAW,CAAC,SAAS;AACxB,YAAM,IAAI,MAAM,4BAA4B,GAAG,mBAAmB;AAAA,IACpE;AAAA,EACF;AAEA,QAAM,OAAO,YAA+B;AAC1C,sBAAkB;AAClB,QAAI;AAEF,YAAM,QAAQ,MAAM,QAAS,IAAI,OAAQ;AACzC,aAAO,QAAQ,KAAK,MAAM,KAAK,IAAI;AAAA,IACrC,SAAS,OAAO;AACd,cAAQ,IAAI,iCAAiC,GAAG,kBAAkB,KAAK;AACvE,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,OAAO,OAAO,UAA4B;AAC9C,sBAAkB;AAClB,QAAI;AAEF,aAAO,MAAM,QAAS,IAAI,SAAU,KAAK,UAAU,KAAK,CAAC;AAAA,IAC3D,SAAS,OAAO;AACd,cAAQ,IAAI,gCAAgC,GAAG,gBAAgB,KAAK;AAAA,IACtE;AAAA,EACF;AAEA,QAAM,SAAS,YAA2B;AACxC,sBAAkB;AAClB,QAAI;AAEF,aAAO,MAAM,QAAS,IAAI,SAAU,EAAE;AAAA,IACxC,SAAS,OAAO;AACd,cAAQ,IAAI,kCAAkC,GAAG,kBAAkB,KAAK;AAAA,IAC1E;AAAA,EACF;AAEA,SAAO,EAAE,WAAW,MAAM,MAAM,MAAM,OAAO;AAC/C;AAEO,MAAM,2BAA2B,oBAA6C,2BAA2B;AACzG,MAAM,sBAAsB,oBAAwC,sBAAsB;AAC1F,MAAM,kBAAkB,oBAA4B,2BAA2B;","names":[]}
@@ -0,0 +1,3 @@
1
+ import type { ClientJSONSnapshot } from '@clerk/shared/types';
2
+ export declare const DUMMY_CLERK_CLIENT_RESOURCE: ClientJSONSnapshot;
3
+ //# sourceMappingURL=client-resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-resource.d.ts","sourceRoot":"","sources":["../../../src/cache/dummy-data/client-resource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,eAAO,MAAM,2BAA2B,EAgIxB,kBAAkB,CAAC"}
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var client_resource_exports = {};
20
+ __export(client_resource_exports, {
21
+ DUMMY_CLERK_CLIENT_RESOURCE: () => DUMMY_CLERK_CLIENT_RESOURCE
22
+ });
23
+ module.exports = __toCommonJS(client_resource_exports);
24
+ const DUMMY_CLERK_CLIENT_RESOURCE = {
25
+ object: "client",
26
+ status: null,
27
+ id: "client_DUMMY_ID",
28
+ sessions: [],
29
+ sign_up: {
30
+ object: "sign_up",
31
+ id: "",
32
+ status: null,
33
+ required_fields: [],
34
+ optional_fields: [],
35
+ missing_fields: [],
36
+ unverified_fields: [],
37
+ verifications: {
38
+ email_address: {
39
+ object: "verification",
40
+ id: "",
41
+ status: null,
42
+ strategy: null,
43
+ nonce: null,
44
+ message: null,
45
+ external_verification_redirect_url: null,
46
+ attempts: null,
47
+ expire_at: null,
48
+ error: { code: "", message: "", meta: {} },
49
+ verified_at_client: null,
50
+ next_action: "",
51
+ supported_strategies: []
52
+ },
53
+ phone_number: {
54
+ object: "verification",
55
+ id: "",
56
+ status: null,
57
+ strategy: null,
58
+ nonce: null,
59
+ message: null,
60
+ external_verification_redirect_url: null,
61
+ attempts: null,
62
+ expire_at: null,
63
+ error: { code: "", message: "", meta: {} },
64
+ verified_at_client: null,
65
+ next_action: "",
66
+ supported_strategies: []
67
+ },
68
+ web3_wallet: {
69
+ object: "verification",
70
+ id: "",
71
+ status: null,
72
+ strategy: null,
73
+ nonce: null,
74
+ message: null,
75
+ external_verification_redirect_url: null,
76
+ attempts: null,
77
+ expire_at: null,
78
+ error: { code: "", message: "", meta: {} },
79
+ verified_at_client: null,
80
+ next_action: "",
81
+ supported_strategies: []
82
+ },
83
+ external_account: {
84
+ object: "verification",
85
+ id: "",
86
+ status: null,
87
+ strategy: null,
88
+ nonce: null,
89
+ message: null,
90
+ external_verification_redirect_url: null,
91
+ attempts: null,
92
+ expire_at: null,
93
+ error: { code: "", message: "", meta: {} },
94
+ verified_at_client: null
95
+ }
96
+ },
97
+ username: null,
98
+ first_name: null,
99
+ last_name: null,
100
+ email_address: null,
101
+ phone_number: null,
102
+ has_password: false,
103
+ unsafe_metadata: {},
104
+ created_session_id: null,
105
+ created_user_id: null,
106
+ abandon_at: null,
107
+ web3_wallet: null,
108
+ legal_accepted_at: null
109
+ },
110
+ sign_in: {
111
+ object: "sign_in",
112
+ id: "",
113
+ status: null,
114
+ supported_identifiers: [],
115
+ supported_first_factors: [],
116
+ supported_second_factors: null,
117
+ first_factor_verification: {
118
+ object: "verification",
119
+ id: "",
120
+ status: null,
121
+ strategy: null,
122
+ nonce: null,
123
+ message: null,
124
+ external_verification_redirect_url: null,
125
+ attempts: null,
126
+ expire_at: null,
127
+ error: { code: "", message: "", meta: {} },
128
+ verified_at_client: null
129
+ },
130
+ second_factor_verification: {
131
+ object: "verification",
132
+ id: "",
133
+ status: null,
134
+ strategy: null,
135
+ nonce: null,
136
+ message: null,
137
+ external_verification_redirect_url: null,
138
+ attempts: null,
139
+ expire_at: null,
140
+ error: { code: "", message: "", meta: {} },
141
+ verified_at_client: null
142
+ },
143
+ identifier: null,
144
+ created_session_id: null,
145
+ user_data: {}
146
+ },
147
+ last_active_session_id: null,
148
+ cookie_expires_at: null,
149
+ last_authentication_strategy: null,
150
+ created_at: (/* @__PURE__ */ new Date()).getTime(),
151
+ updated_at: (/* @__PURE__ */ new Date()).getTime()
152
+ };
153
+ // Annotate the CommonJS export names for ESM import in node:
154
+ 0 && (module.exports = {
155
+ DUMMY_CLERK_CLIENT_RESOURCE
156
+ });
157
+ //# sourceMappingURL=client-resource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/cache/dummy-data/client-resource.ts"],"sourcesContent":["import type { ClientJSONSnapshot } from '@clerk/shared/types';\n\nexport const DUMMY_CLERK_CLIENT_RESOURCE = {\n object: 'client',\n status: null,\n id: 'client_DUMMY_ID',\n sessions: [],\n sign_up: {\n object: 'sign_up',\n id: '',\n status: null,\n required_fields: [],\n optional_fields: [],\n missing_fields: [],\n unverified_fields: [],\n verifications: {\n email_address: {\n object: 'verification',\n id: '',\n status: null,\n strategy: null,\n nonce: null,\n message: null,\n external_verification_redirect_url: null,\n attempts: null,\n expire_at: null,\n error: { code: '', message: '', meta: {} },\n verified_at_client: null,\n next_action: '',\n supported_strategies: [],\n },\n phone_number: {\n object: 'verification',\n id: '',\n status: null,\n strategy: null,\n nonce: null,\n message: null,\n external_verification_redirect_url: null,\n attempts: null,\n expire_at: null,\n error: { code: '', message: '', meta: {} },\n verified_at_client: null,\n next_action: '',\n supported_strategies: [],\n },\n web3_wallet: {\n object: 'verification',\n id: '',\n status: null,\n strategy: null,\n nonce: null,\n message: null,\n external_verification_redirect_url: null,\n attempts: null,\n expire_at: null,\n error: { code: '', message: '', meta: {} },\n verified_at_client: null,\n next_action: '',\n supported_strategies: [],\n },\n external_account: {\n object: 'verification',\n id: '',\n status: null,\n strategy: null,\n nonce: null,\n message: null,\n external_verification_redirect_url: null,\n attempts: null,\n expire_at: null,\n error: { code: '', message: '', meta: {} },\n verified_at_client: null,\n },\n },\n username: null,\n first_name: null,\n last_name: null,\n email_address: null,\n phone_number: null,\n has_password: false,\n unsafe_metadata: {},\n created_session_id: null,\n created_user_id: null,\n abandon_at: null,\n web3_wallet: null,\n legal_accepted_at: null,\n },\n sign_in: {\n object: 'sign_in',\n id: '',\n status: null,\n supported_identifiers: [],\n supported_first_factors: [],\n supported_second_factors: null,\n first_factor_verification: {\n object: 'verification',\n id: '',\n status: null,\n strategy: null,\n nonce: null,\n message: null,\n external_verification_redirect_url: null,\n attempts: null,\n expire_at: null,\n error: { code: '', message: '', meta: {} },\n verified_at_client: null,\n },\n second_factor_verification: {\n object: 'verification',\n id: '',\n status: null,\n strategy: null,\n nonce: null,\n message: null,\n external_verification_redirect_url: null,\n attempts: null,\n expire_at: null,\n error: { code: '', message: '', meta: {} },\n verified_at_client: null,\n },\n identifier: null,\n created_session_id: null,\n user_data: {},\n },\n last_active_session_id: null,\n cookie_expires_at: null,\n last_authentication_strategy: null,\n created_at: new Date().getTime(),\n updated_at: new Date().getTime(),\n} as unknown as ClientJSONSnapshot;\n"],"mappings":"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","names":[]}
@@ -0,0 +1,3 @@
1
+ import type { EnvironmentJSONSnapshot } from '@clerk/shared/types';
2
+ export declare const DUMMY_CLERK_ENVIRONMENT_RESOURCE: EnvironmentJSONSnapshot;
3
+ //# sourceMappingURL=environment-resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment-resource.d.ts","sourceRoot":"","sources":["../../../src/cache/dummy-data/environment-resource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,eAAO,MAAM,gCAAgC,EAuO7B,uBAAuB,CAAC"}