@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
@@ -0,0 +1,56 @@
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var hooks_exports = {};
21
+ __export(hooks_exports, {
22
+ useClerk: () => import_react.useClerk,
23
+ useEmailLink: () => import_react.useEmailLink,
24
+ useOrganization: () => import_react.useOrganization,
25
+ useOrganizationList: () => import_react.useOrganizationList,
26
+ useReverification: () => import_react.useReverification,
27
+ useSession: () => import_react.useSession,
28
+ useSessionList: () => import_react.useSessionList,
29
+ useSignIn: () => import_react.useSignIn,
30
+ useSignUp: () => import_react.useSignUp,
31
+ useUser: () => import_react.useUser
32
+ });
33
+ module.exports = __toCommonJS(hooks_exports);
34
+ var import_react = require("@clerk/react");
35
+ __reExport(hooks_exports, require("./useSignInWithApple"), module.exports);
36
+ __reExport(hooks_exports, require("./useSSO"), module.exports);
37
+ __reExport(hooks_exports, require("./useOAuth"), module.exports);
38
+ __reExport(hooks_exports, require("./useAuth"), module.exports);
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ useClerk,
42
+ useEmailLink,
43
+ useOrganization,
44
+ useOrganizationList,
45
+ useReverification,
46
+ useSession,
47
+ useSessionList,
48
+ useSignIn,
49
+ useSignUp,
50
+ useUser,
51
+ ...require("./useSignInWithApple"),
52
+ ...require("./useSSO"),
53
+ ...require("./useOAuth"),
54
+ ...require("./useAuth")
55
+ });
56
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/index.ts"],"sourcesContent":["export {\n useClerk,\n useEmailLink,\n useOrganization,\n useOrganizationList,\n useSession,\n useSessionList,\n useSignIn,\n useSignUp,\n useUser,\n useReverification,\n} from '@clerk/react';\n\nexport * from './useSignInWithApple';\nexport * from './useSSO';\nexport * from './useOAuth';\nexport * from './useAuth';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAWO;AAEP,0BAAc,iCAbd;AAcA,0BAAc,qBAdd;AAeA,0BAAc,uBAfd;AAgBA,0BAAc,sBAhBd;","names":[]}
@@ -0,0 +1,3 @@
1
+ import type { UseAuthReturn } from '@clerk/shared/types';
2
+ export declare const useAuth: (initialAuthState?: any) => UseAuthReturn;
3
+ //# sourceMappingURL=useAuth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA6B,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAQpF,eAAO,MAAM,OAAO,GAAI,mBAAmB,GAAG,KAAG,aAuBhD,CAAC"}
@@ -0,0 +1,50 @@
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 useAuth_exports = {};
20
+ __export(useAuth_exports, {
21
+ useAuth: () => useAuth
22
+ });
23
+ module.exports = __toCommonJS(useAuth_exports);
24
+ var import_react = require("@clerk/react");
25
+ var import_error = require("@clerk/shared/error");
26
+ var import_cache = require("../cache");
27
+ const useAuth = (initialAuthState) => {
28
+ const { getToken: getTokenBase, ...rest } = (0, import_react.useAuth)(initialAuthState);
29
+ const getToken = (opts) => getTokenBase(opts).then((token) => {
30
+ if (!opts && import_cache.SessionJWTCache.checkInit()) {
31
+ if (token) {
32
+ void import_cache.SessionJWTCache.save(token);
33
+ } else {
34
+ void import_cache.SessionJWTCache.remove();
35
+ }
36
+ }
37
+ return token;
38
+ }).catch((error) => {
39
+ if (!opts && import_cache.SessionJWTCache.checkInit() && (0, import_error.isNetworkError)(error)) {
40
+ return import_cache.SessionJWTCache.load();
41
+ }
42
+ throw error;
43
+ });
44
+ return { ...rest, getToken };
45
+ };
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
48
+ useAuth
49
+ });
50
+ //# sourceMappingURL=useAuth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/useAuth.ts"],"sourcesContent":["import { useAuth as useAuthBase } from '@clerk/react';\nimport { isNetworkError } from '@clerk/shared/error';\nimport type { GetToken, GetTokenOptions, UseAuthReturn } from '@clerk/shared/types';\n\nimport { SessionJWTCache } from '../cache';\n\n/*\n * This hook extends the useAuth hook to add experimental JWT caching.\n * The caching is used only when no options are passed to getToken.\n */\nexport const useAuth = (initialAuthState?: any): UseAuthReturn => {\n const { getToken: getTokenBase, ...rest } = useAuthBase(initialAuthState);\n\n const getToken: GetToken = (opts?: GetTokenOptions): Promise<string | null> =>\n getTokenBase(opts)\n .then(token => {\n if (!opts && SessionJWTCache.checkInit()) {\n if (token) {\n void SessionJWTCache.save(token);\n } else {\n void SessionJWTCache.remove();\n }\n }\n return token;\n })\n .catch(error => {\n if (!opts && SessionJWTCache.checkInit() && isNetworkError(error)) {\n return SessionJWTCache.load();\n }\n throw error;\n });\n\n return { ...rest, getToken };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuC;AACvC,mBAA+B;AAG/B,mBAAgC;AAMzB,MAAM,UAAU,CAAC,qBAA0C;AAChE,QAAM,EAAE,UAAU,cAAc,GAAG,KAAK,QAAI,aAAAA,SAAY,gBAAgB;AAExE,QAAM,WAAqB,CAAC,SAC1B,aAAa,IAAI,EACd,KAAK,WAAS;AACb,QAAI,CAAC,QAAQ,6BAAgB,UAAU,GAAG;AACxC,UAAI,OAAO;AACT,aAAK,6BAAgB,KAAK,KAAK;AAAA,MACjC,OAAO;AACL,aAAK,6BAAgB,OAAO;AAAA,MAC9B;AAAA,IACF;AACA,WAAO;AAAA,EACT,CAAC,EACA,MAAM,WAAS;AACd,QAAI,CAAC,QAAQ,6BAAgB,UAAU,SAAK,6BAAe,KAAK,GAAG;AACjE,aAAO,6BAAgB,KAAK;AAAA,IAC9B;AACA,UAAM;AAAA,EACR,CAAC;AAEL,SAAO,EAAE,GAAG,MAAM,SAAS;AAC7B;","names":["useAuthBase"]}
@@ -0,0 +1,25 @@
1
+ import type { OAuthStrategy, SetActive, SignInResource, SignUpResource } from '@clerk/shared/types';
2
+ import * as WebBrowser from 'expo-web-browser';
3
+ export type UseOAuthFlowParams = {
4
+ strategy: OAuthStrategy;
5
+ redirectUrl?: string;
6
+ unsafeMetadata?: SignUpUnsafeMetadata;
7
+ };
8
+ export type StartOAuthFlowParams = {
9
+ redirectUrl?: string;
10
+ unsafeMetadata?: SignUpUnsafeMetadata;
11
+ };
12
+ export type StartOAuthFlowReturnType = {
13
+ createdSessionId: string;
14
+ setActive?: SetActive;
15
+ signIn?: SignInResource;
16
+ signUp?: SignUpResource;
17
+ authSessionResult?: WebBrowser.WebBrowserAuthSessionResult;
18
+ };
19
+ /**
20
+ * @deprecated Use `useSSO()` instead.
21
+ */
22
+ export declare function useOAuth(useOAuthParams: UseOAuthFlowParams): {
23
+ startOAuthFlow: (startOAuthFlowParams?: StartOAuthFlowParams) => Promise<StartOAuthFlowReturnType>;
24
+ };
25
+ //# sourceMappingURL=useOAuth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOAuth.d.ts","sourceRoot":"","sources":["../../src/hooks/useOAuth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEpG,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAI/C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,aAAa,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,oBAAoB,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,oBAAoB,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,iBAAiB,CAAC,EAAE,UAAU,CAAC,2BAA2B,CAAC;CAC5D,CAAC;AAEF;;GAEG;AACH,wBAAgB,QAAQ,CAAC,cAAc,EAAE,kBAAkB;4CASJ,oBAAoB,KAAG,OAAO,CAAC,wBAAwB,CAAC;EAiF9G"}
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var useOAuth_exports = {};
30
+ __export(useOAuth_exports, {
31
+ useOAuth: () => useOAuth
32
+ });
33
+ module.exports = __toCommonJS(useOAuth_exports);
34
+ var import_legacy = require("@clerk/react/legacy");
35
+ var AuthSession = __toESM(require("expo-auth-session"));
36
+ var WebBrowser = __toESM(require("expo-web-browser"));
37
+ var import_errors = require("../utils/errors");
38
+ function useOAuth(useOAuthParams) {
39
+ const { strategy } = useOAuthParams || {};
40
+ if (!strategy) {
41
+ return import_errors.errorThrower.throw("Missing oauth strategy");
42
+ }
43
+ const { signIn, setActive, isLoaded: isSignInLoaded } = (0, import_legacy.useSignIn)();
44
+ const { signUp, isLoaded: isSignUpLoaded } = (0, import_legacy.useSignUp)();
45
+ async function startOAuthFlow(startOAuthFlowParams) {
46
+ if (!isSignInLoaded || !isSignUpLoaded) {
47
+ return {
48
+ createdSessionId: "",
49
+ signIn,
50
+ signUp,
51
+ setActive
52
+ };
53
+ }
54
+ const oauthRedirectUrl = (startOAuthFlowParams == null ? void 0 : startOAuthFlowParams.redirectUrl) || useOAuthParams.redirectUrl || AuthSession.makeRedirectUri({
55
+ path: "oauth-native-callback"
56
+ });
57
+ await signIn.create({ strategy, redirectUrl: oauthRedirectUrl });
58
+ const { externalVerificationRedirectURL } = signIn.firstFactorVerification;
59
+ const authSessionResult = await WebBrowser.openAuthSessionAsync(
60
+ // @ts-ignore
61
+ externalVerificationRedirectURL.toString(),
62
+ oauthRedirectUrl
63
+ );
64
+ const { type, url } = authSessionResult || {};
65
+ if (type !== "success") {
66
+ return {
67
+ authSessionResult,
68
+ createdSessionId: "",
69
+ setActive,
70
+ signIn,
71
+ signUp
72
+ };
73
+ }
74
+ const params = new URL(url).searchParams;
75
+ const rotatingTokenNonce = params.get("rotating_token_nonce") || "";
76
+ await signIn.reload({ rotatingTokenNonce });
77
+ const { status, firstFactorVerification } = signIn;
78
+ let createdSessionId = "";
79
+ if (status === "complete") {
80
+ createdSessionId = signIn.createdSessionId;
81
+ } else if (firstFactorVerification.status === "transferable") {
82
+ await signUp.create({
83
+ transfer: true,
84
+ unsafeMetadata: (startOAuthFlowParams == null ? void 0 : startOAuthFlowParams.unsafeMetadata) || useOAuthParams.unsafeMetadata
85
+ });
86
+ createdSessionId = signUp.createdSessionId || "";
87
+ }
88
+ return {
89
+ authSessionResult,
90
+ createdSessionId,
91
+ setActive,
92
+ signIn,
93
+ signUp
94
+ };
95
+ }
96
+ return {
97
+ startOAuthFlow
98
+ };
99
+ }
100
+ // Annotate the CommonJS export names for ESM import in node:
101
+ 0 && (module.exports = {
102
+ useOAuth
103
+ });
104
+ //# sourceMappingURL=useOAuth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/useOAuth.ts"],"sourcesContent":["import { useSignIn, useSignUp } from '@clerk/react/legacy';\nimport type { OAuthStrategy, SetActive, SignInResource, SignUpResource } from '@clerk/shared/types';\nimport * as AuthSession from 'expo-auth-session';\nimport * as WebBrowser from 'expo-web-browser';\n\nimport { errorThrower } from '../utils/errors';\n\nexport type UseOAuthFlowParams = {\n strategy: OAuthStrategy;\n redirectUrl?: string;\n unsafeMetadata?: SignUpUnsafeMetadata;\n};\n\nexport type StartOAuthFlowParams = {\n redirectUrl?: string;\n unsafeMetadata?: SignUpUnsafeMetadata;\n};\n\nexport type StartOAuthFlowReturnType = {\n createdSessionId: string;\n setActive?: SetActive;\n signIn?: SignInResource;\n signUp?: SignUpResource;\n authSessionResult?: WebBrowser.WebBrowserAuthSessionResult;\n};\n\n/**\n * @deprecated Use `useSSO()` instead.\n */\nexport function useOAuth(useOAuthParams: UseOAuthFlowParams) {\n const { strategy } = useOAuthParams || {};\n if (!strategy) {\n return errorThrower.throw('Missing oauth strategy');\n }\n\n const { signIn, setActive, isLoaded: isSignInLoaded } = useSignIn();\n const { signUp, isLoaded: isSignUpLoaded } = useSignUp();\n\n async function startOAuthFlow(startOAuthFlowParams?: StartOAuthFlowParams): Promise<StartOAuthFlowReturnType> {\n if (!isSignInLoaded || !isSignUpLoaded) {\n return {\n createdSessionId: '',\n signIn,\n signUp,\n setActive,\n };\n }\n\n // Create a redirect url for the current platform and environment.\n //\n // This redirect URL needs to be whitelisted for your Clerk production instance via\n // https://clerk.com/docs/reference/backend-api/tag/Redirect-URLs#operation/CreateRedirectURL\n //\n // For more information go to:\n // https://docs.expo.dev/versions/latest/sdk/auth-session/#authsessionmakeredirecturi\n const oauthRedirectUrl =\n startOAuthFlowParams?.redirectUrl ||\n useOAuthParams.redirectUrl ||\n AuthSession.makeRedirectUri({\n path: 'oauth-native-callback',\n });\n\n await signIn.create({ strategy, redirectUrl: oauthRedirectUrl });\n\n const { externalVerificationRedirectURL } = signIn.firstFactorVerification;\n\n const authSessionResult = await WebBrowser.openAuthSessionAsync(\n // @ts-ignore\n externalVerificationRedirectURL.toString(),\n oauthRedirectUrl,\n );\n\n // @ts-expect-error\n const { type, url } = authSessionResult || {};\n\n // TODO: Check all the possible AuthSession results\n // https://docs.expo.dev/versions/latest/sdk/auth-session/#returns-7\n if (type !== 'success') {\n return {\n authSessionResult,\n createdSessionId: '',\n setActive,\n signIn,\n signUp,\n };\n }\n\n const params = new URL(url).searchParams;\n\n const rotatingTokenNonce = params.get('rotating_token_nonce') || '';\n await signIn.reload({ rotatingTokenNonce });\n\n const { status, firstFactorVerification } = signIn;\n\n let createdSessionId = '';\n\n if (status === 'complete') {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n createdSessionId = signIn.createdSessionId!;\n } else if (firstFactorVerification.status === 'transferable') {\n await signUp.create({\n transfer: true,\n unsafeMetadata: startOAuthFlowParams?.unsafeMetadata || useOAuthParams.unsafeMetadata,\n });\n createdSessionId = signUp.createdSessionId || '';\n }\n\n return {\n authSessionResult,\n createdSessionId,\n setActive,\n signIn,\n signUp,\n };\n }\n\n return {\n startOAuthFlow,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAqC;AAErC,kBAA6B;AAC7B,iBAA4B;AAE5B,oBAA6B;AAwBtB,SAAS,SAAS,gBAAoC;AAC3D,QAAM,EAAE,SAAS,IAAI,kBAAkB,CAAC;AACxC,MAAI,CAAC,UAAU;AACb,WAAO,2BAAa,MAAM,wBAAwB;AAAA,EACpD;AAEA,QAAM,EAAE,QAAQ,WAAW,UAAU,eAAe,QAAI,yBAAU;AAClE,QAAM,EAAE,QAAQ,UAAU,eAAe,QAAI,yBAAU;AAEvD,iBAAe,eAAe,sBAAgF;AAC5G,QAAI,CAAC,kBAAkB,CAAC,gBAAgB;AACtC,aAAO;AAAA,QACL,kBAAkB;AAAA,QAClB;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AASA,UAAM,oBACJ,6DAAsB,gBACtB,eAAe,eACf,YAAY,gBAAgB;AAAA,MAC1B,MAAM;AAAA,IACR,CAAC;AAEH,UAAM,OAAO,OAAO,EAAE,UAAU,aAAa,iBAAiB,CAAC;AAE/D,UAAM,EAAE,gCAAgC,IAAI,OAAO;AAEnD,UAAM,oBAAoB,MAAM,WAAW;AAAA;AAAA,MAEzC,gCAAgC,SAAS;AAAA,MACzC;AAAA,IACF;AAGA,UAAM,EAAE,MAAM,IAAI,IAAI,qBAAqB,CAAC;AAI5C,QAAI,SAAS,WAAW;AACtB,aAAO;AAAA,QACL;AAAA,QACA,kBAAkB;AAAA,QAClB;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,UAAM,SAAS,IAAI,IAAI,GAAG,EAAE;AAE5B,UAAM,qBAAqB,OAAO,IAAI,sBAAsB,KAAK;AACjE,UAAM,OAAO,OAAO,EAAE,mBAAmB,CAAC;AAE1C,UAAM,EAAE,QAAQ,wBAAwB,IAAI;AAE5C,QAAI,mBAAmB;AAEvB,QAAI,WAAW,YAAY;AAEzB,yBAAmB,OAAO;AAAA,IAC5B,WAAW,wBAAwB,WAAW,gBAAgB;AAC5D,YAAM,OAAO,OAAO;AAAA,QAClB,UAAU;AAAA,QACV,iBAAgB,6DAAsB,mBAAkB,eAAe;AAAA,MACzE,CAAC;AACD,yBAAmB,OAAO,oBAAoB;AAAA,IAChD;AAEA,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,23 @@
1
+ import type { EnterpriseSSOStrategy, OAuthStrategy, SetActive, SignInResource, SignUpResource } from '@clerk/shared/types';
2
+ import * as WebBrowser from 'expo-web-browser';
3
+ export type StartSSOFlowParams = {
4
+ redirectUrl?: string;
5
+ unsafeMetadata?: SignUpUnsafeMetadata;
6
+ authSessionOptions?: Pick<WebBrowser.AuthSessionOpenOptions, 'showInRecents'>;
7
+ } & ({
8
+ strategy: OAuthStrategy;
9
+ } | {
10
+ strategy: EnterpriseSSOStrategy;
11
+ identifier: string;
12
+ });
13
+ export type StartSSOFlowReturnType = {
14
+ createdSessionId: string | null;
15
+ authSessionResult: WebBrowser.WebBrowserAuthSessionResult | null;
16
+ setActive?: SetActive;
17
+ signIn?: SignInResource;
18
+ signUp?: SignUpResource;
19
+ };
20
+ export declare function useSSO(): {
21
+ startSSOFlow: (startSSOFlowParams: StartSSOFlowParams) => Promise<StartSSOFlowReturnType>;
22
+ };
23
+ //# sourceMappingURL=useSSO.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSSO.d.ts","sourceRoot":"","sources":["../../src/hooks/useSSO.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qBAAqB,EACrB,aAAa,EACb,SAAS,EACT,cAAc,EACd,cAAc,EACf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAI/C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC,kBAAkB,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,sBAAsB,EAAE,eAAe,CAAC,CAAC;CAC/E,GAAG,CACA;IACE,QAAQ,EAAE,aAAa,CAAC;CACzB,GACD;IACE,QAAQ,EAAE,qBAAqB,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;CACpB,CACJ,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,iBAAiB,EAAE,UAAU,CAAC,2BAA2B,GAAG,IAAI,CAAC;IACjE,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB,CAAC;AAEF,wBAAgB,MAAM;uCAI4B,kBAAkB,KAAG,OAAO,CAAC,sBAAsB,CAAC;EA2ErG"}
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var useSSO_exports = {};
30
+ __export(useSSO_exports, {
31
+ useSSO: () => useSSO
32
+ });
33
+ module.exports = __toCommonJS(useSSO_exports);
34
+ var import_legacy = require("@clerk/react/legacy");
35
+ var AuthSession = __toESM(require("expo-auth-session"));
36
+ var WebBrowser = __toESM(require("expo-web-browser"));
37
+ var import_errors = require("../utils/errors");
38
+ function useSSO() {
39
+ const { signIn, setActive, isLoaded: isSignInLoaded } = (0, import_legacy.useSignIn)();
40
+ const { signUp, isLoaded: isSignUpLoaded } = (0, import_legacy.useSignUp)();
41
+ async function startSSOFlow(startSSOFlowParams) {
42
+ var _a, _b, _c;
43
+ if (!isSignInLoaded || !isSignUpLoaded) {
44
+ return {
45
+ createdSessionId: null,
46
+ authSessionResult: null,
47
+ signIn,
48
+ signUp,
49
+ setActive
50
+ };
51
+ }
52
+ const { strategy, unsafeMetadata, authSessionOptions } = startSSOFlowParams != null ? startSSOFlowParams : {};
53
+ const redirectUrl = (_a = startSSOFlowParams.redirectUrl) != null ? _a : AuthSession.makeRedirectUri({
54
+ path: "sso-callback"
55
+ });
56
+ await signIn.create({
57
+ strategy,
58
+ redirectUrl,
59
+ ...startSSOFlowParams.strategy === "enterprise_sso" ? { identifier: startSSOFlowParams.identifier } : {}
60
+ });
61
+ const { externalVerificationRedirectURL } = signIn.firstFactorVerification;
62
+ if (!externalVerificationRedirectURL) {
63
+ return import_errors.errorThrower.throw("Missing external verification redirect URL for SSO flow");
64
+ }
65
+ const authSessionResult = await WebBrowser.openAuthSessionAsync(
66
+ externalVerificationRedirectURL.toString(),
67
+ redirectUrl,
68
+ authSessionOptions
69
+ );
70
+ if (authSessionResult.type !== "success" || !authSessionResult.url) {
71
+ return {
72
+ createdSessionId: null,
73
+ setActive,
74
+ signIn,
75
+ signUp,
76
+ authSessionResult
77
+ };
78
+ }
79
+ const params = new URL(authSessionResult.url).searchParams;
80
+ const rotatingTokenNonce = (_b = params.get("rotating_token_nonce")) != null ? _b : "";
81
+ await signIn.reload({ rotatingTokenNonce });
82
+ const userNeedsToBeCreated = signIn.firstFactorVerification.status === "transferable";
83
+ if (userNeedsToBeCreated) {
84
+ await signUp.create({
85
+ transfer: true,
86
+ unsafeMetadata
87
+ });
88
+ }
89
+ return {
90
+ createdSessionId: (_c = signUp.createdSessionId) != null ? _c : signIn.createdSessionId,
91
+ setActive,
92
+ signIn,
93
+ signUp,
94
+ authSessionResult
95
+ };
96
+ }
97
+ return {
98
+ startSSOFlow
99
+ };
100
+ }
101
+ // Annotate the CommonJS export names for ESM import in node:
102
+ 0 && (module.exports = {
103
+ useSSO
104
+ });
105
+ //# sourceMappingURL=useSSO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/useSSO.ts"],"sourcesContent":["import { useSignIn, useSignUp } from '@clerk/react/legacy';\nimport type {\n EnterpriseSSOStrategy,\n OAuthStrategy,\n SetActive,\n SignInResource,\n SignUpResource,\n} from '@clerk/shared/types';\nimport * as AuthSession from 'expo-auth-session';\nimport * as WebBrowser from 'expo-web-browser';\n\nimport { errorThrower } from '../utils/errors';\n\nexport type StartSSOFlowParams = {\n redirectUrl?: string;\n unsafeMetadata?: SignUpUnsafeMetadata;\n authSessionOptions?: Pick<WebBrowser.AuthSessionOpenOptions, 'showInRecents'>;\n} & (\n | {\n strategy: OAuthStrategy;\n }\n | {\n strategy: EnterpriseSSOStrategy;\n identifier: string;\n }\n);\n\nexport type StartSSOFlowReturnType = {\n createdSessionId: string | null;\n authSessionResult: WebBrowser.WebBrowserAuthSessionResult | null;\n setActive?: SetActive;\n signIn?: SignInResource;\n signUp?: SignUpResource;\n};\n\nexport function useSSO() {\n const { signIn, setActive, isLoaded: isSignInLoaded } = useSignIn();\n const { signUp, isLoaded: isSignUpLoaded } = useSignUp();\n\n async function startSSOFlow(startSSOFlowParams: StartSSOFlowParams): Promise<StartSSOFlowReturnType> {\n if (!isSignInLoaded || !isSignUpLoaded) {\n return {\n createdSessionId: null,\n authSessionResult: null,\n signIn,\n signUp,\n setActive,\n };\n }\n\n const { strategy, unsafeMetadata, authSessionOptions } = startSSOFlowParams ?? {};\n\n /**\n * Creates a redirect URL based on the application platform\n * It must be whitelisted, either via Clerk Dashboard, or BAPI, in order\n * to include the `rotating_token_nonce` on SSO callback\n * @ref https://clerk.com/docs/reference/backend-api/tag/Redirect-URLs#operation/CreateRedirectURL\n */\n const redirectUrl =\n startSSOFlowParams.redirectUrl ??\n AuthSession.makeRedirectUri({\n path: 'sso-callback',\n });\n\n await signIn.create({\n strategy,\n redirectUrl,\n ...(startSSOFlowParams.strategy === 'enterprise_sso' ? { identifier: startSSOFlowParams.identifier } : {}),\n });\n\n const { externalVerificationRedirectURL } = signIn.firstFactorVerification;\n if (!externalVerificationRedirectURL) {\n return errorThrower.throw('Missing external verification redirect URL for SSO flow');\n }\n\n const authSessionResult = await WebBrowser.openAuthSessionAsync(\n externalVerificationRedirectURL.toString(),\n redirectUrl,\n authSessionOptions,\n );\n if (authSessionResult.type !== 'success' || !authSessionResult.url) {\n return {\n createdSessionId: null,\n setActive,\n signIn,\n signUp,\n authSessionResult,\n };\n }\n\n const params = new URL(authSessionResult.url).searchParams;\n const rotatingTokenNonce = params.get('rotating_token_nonce') ?? '';\n await signIn.reload({ rotatingTokenNonce });\n\n const userNeedsToBeCreated = signIn.firstFactorVerification.status === 'transferable';\n if (userNeedsToBeCreated) {\n await signUp.create({\n transfer: true,\n unsafeMetadata,\n });\n }\n\n return {\n createdSessionId: signUp.createdSessionId ?? signIn.createdSessionId,\n setActive,\n signIn,\n signUp,\n authSessionResult,\n };\n }\n\n return {\n startSSOFlow,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAqC;AAQrC,kBAA6B;AAC7B,iBAA4B;AAE5B,oBAA6B;AAwBtB,SAAS,SAAS;AACvB,QAAM,EAAE,QAAQ,WAAW,UAAU,eAAe,QAAI,yBAAU;AAClE,QAAM,EAAE,QAAQ,UAAU,eAAe,QAAI,yBAAU;AAEvD,iBAAe,aAAa,oBAAyE;AAvCvG;AAwCI,QAAI,CAAC,kBAAkB,CAAC,gBAAgB;AACtC,aAAO;AAAA,QACL,kBAAkB;AAAA,QAClB,mBAAmB;AAAA,QACnB;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,UAAM,EAAE,UAAU,gBAAgB,mBAAmB,IAAI,kDAAsB,CAAC;AAQhF,UAAM,eACJ,wBAAmB,gBAAnB,YACA,YAAY,gBAAgB;AAAA,MAC1B,MAAM;AAAA,IACR,CAAC;AAEH,UAAM,OAAO,OAAO;AAAA,MAClB;AAAA,MACA;AAAA,MACA,GAAI,mBAAmB,aAAa,mBAAmB,EAAE,YAAY,mBAAmB,WAAW,IAAI,CAAC;AAAA,IAC1G,CAAC;AAED,UAAM,EAAE,gCAAgC,IAAI,OAAO;AACnD,QAAI,CAAC,iCAAiC;AACpC,aAAO,2BAAa,MAAM,yDAAyD;AAAA,IACrF;AAEA,UAAM,oBAAoB,MAAM,WAAW;AAAA,MACzC,gCAAgC,SAAS;AAAA,MACzC;AAAA,MACA;AAAA,IACF;AACA,QAAI,kBAAkB,SAAS,aAAa,CAAC,kBAAkB,KAAK;AAClE,aAAO;AAAA,QACL,kBAAkB;AAAA,QAClB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,UAAM,SAAS,IAAI,IAAI,kBAAkB,GAAG,EAAE;AAC9C,UAAM,sBAAqB,YAAO,IAAI,sBAAsB,MAAjC,YAAsC;AACjE,UAAM,OAAO,OAAO,EAAE,mBAAmB,CAAC;AAE1C,UAAM,uBAAuB,OAAO,wBAAwB,WAAW;AACvE,QAAI,sBAAsB;AACxB,YAAM,OAAO,OAAO;AAAA,QAClB,UAAU;AAAA,QACV;AAAA,MACF,CAAC;AAAA,IACH;AAEA,WAAO;AAAA,MACL,mBAAkB,YAAO,qBAAP,YAA2B,OAAO;AAAA,MACpD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,50 @@
1
+ import type { SetActive, SignInResource, SignUpResource } from '@clerk/shared/types';
2
+ export type StartAppleAuthenticationFlowParams = {
3
+ unsafeMetadata?: SignUpUnsafeMetadata;
4
+ };
5
+ export type StartAppleAuthenticationFlowReturnType = {
6
+ createdSessionId: string | null;
7
+ setActive?: SetActive;
8
+ signIn?: SignInResource;
9
+ signUp?: SignUpResource;
10
+ };
11
+ /**
12
+ * Stub for Apple Authentication hook on non-iOS platforms.
13
+ *
14
+ * Native Apple Authentication using expo-apple-authentication is only available on iOS.
15
+ * For web platforms, use the OAuth-based Apple Sign-In flow instead via useSSO.
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * import { useSSO } from '@clerk/clerk-expo';
20
+ * import { Button } from 'react-native';
21
+ *
22
+ * function AppleSignInButton() {
23
+ * const { startSSOFlow } = useSSO();
24
+ *
25
+ * const onPress = async () => {
26
+ * try {
27
+ * const { createdSessionId, setActive } = await startSSOFlow({
28
+ * strategy: 'oauth_apple'
29
+ * });
30
+ *
31
+ * if (createdSessionId && setActive) {
32
+ * await setActive({ session: createdSessionId });
33
+ * }
34
+ * } catch (err) {
35
+ * console.error('Apple Authentication error:', err);
36
+ * }
37
+ * };
38
+ *
39
+ * return <Button title="Sign in with Apple" onPress={onPress} />;
40
+ * }
41
+ * ```
42
+ *
43
+ * @platform iOS - This hook only works on iOS. On other platforms, it will throw an error.
44
+ *
45
+ * @returns An object containing the `startAppleAuthenticationFlow` function that throws an error
46
+ */
47
+ export declare function useSignInWithApple(): {
48
+ startAppleAuthenticationFlow: (startAppleAuthenticationFlowParams?: StartAppleAuthenticationFlowParams) => Promise<StartAppleAuthenticationFlowReturnType>;
49
+ };
50
+ //# sourceMappingURL=useSignInWithApple.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSignInWithApple.d.ts","sourceRoot":"","sources":["../../src/hooks/useSignInWithApple.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrF,MAAM,MAAM,kCAAkC,GAAG;IAC/C,cAAc,CAAC,EAAE,oBAAoB,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,sCAAsC,GAAG;IACnD,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,kBAAkB,IAAI;IACpC,4BAA4B,EAAE,CAC5B,kCAAkC,CAAC,EAAE,kCAAkC,KACpE,OAAO,CAAC,sCAAsC,CAAC,CAAC;CACtD,CAaA"}
@@ -0,0 +1,51 @@
1
+ import type { SetActive, SignInResource, SignUpResource } from '@clerk/shared/types';
2
+ export type StartAppleAuthenticationFlowParams = {
3
+ unsafeMetadata?: SignUpUnsafeMetadata;
4
+ };
5
+ export type StartAppleAuthenticationFlowReturnType = {
6
+ createdSessionId: string | null;
7
+ setActive?: SetActive;
8
+ signIn?: SignInResource;
9
+ signUp?: SignUpResource;
10
+ };
11
+ /**
12
+ * Hook for native Apple Authentication on iOS using expo-apple-authentication.
13
+ *
14
+ * This hook provides a simplified way to authenticate users with their Apple ID
15
+ * using the native iOS Sign in with Apple UI. The authentication flow automatically
16
+ * handles the ID token exchange with Clerk's backend and manages the transfer flow
17
+ * between sign-in and sign-up.
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * import { useSignInWithApple } from '@clerk/clerk-expo';
22
+ * import { Button } from 'react-native';
23
+ *
24
+ * function AppleSignInButton() {
25
+ * const { startAppleAuthenticationFlow } = useSignInWithApple();
26
+ *
27
+ * const onPress = async () => {
28
+ * try {
29
+ * const { createdSessionId, setActive } = await startAppleAuthenticationFlow();
30
+ *
31
+ * if (createdSessionId && setActive) {
32
+ * await setActive({ session: createdSessionId });
33
+ * }
34
+ * } catch (err) {
35
+ * console.error('Apple Authentication error:', err);
36
+ * }
37
+ * };
38
+ *
39
+ * return <Button title="Sign in with Apple" onPress={onPress} />;
40
+ * }
41
+ * ```
42
+ *
43
+ * @requires expo-apple-authentication - Must be installed as a peer dependency
44
+ * @platform iOS - This is the iOS-specific implementation
45
+ *
46
+ * @returns An object containing the `startAppleAuthenticationFlow` function
47
+ */
48
+ export declare function useSignInWithApple(): {
49
+ startAppleAuthenticationFlow: (startAppleAuthenticationFlowParams?: StartAppleAuthenticationFlowParams) => Promise<StartAppleAuthenticationFlowReturnType>;
50
+ };
51
+ //# sourceMappingURL=useSignInWithApple.ios.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSignInWithApple.ios.d.ts","sourceRoot":"","sources":["../../src/hooks/useSignInWithApple.ios.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrF,MAAM,MAAM,kCAAkC,GAAG;IAC/C,cAAc,CAAC,EAAE,oBAAoB,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,sCAAsC,GAAG;IACnD,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,kBAAkB;wEAKO,kCAAkC,KACtE,OAAO,CAAC,sCAAsC,CAAC;EAoGnD"}
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var useSignInWithApple_ios_exports = {};
30
+ __export(useSignInWithApple_ios_exports, {
31
+ useSignInWithApple: () => useSignInWithApple
32
+ });
33
+ module.exports = __toCommonJS(useSignInWithApple_ios_exports);
34
+ var import_legacy = require("@clerk/react/legacy");
35
+ var import_errors = require("../utils/errors");
36
+ function useSignInWithApple() {
37
+ const { signIn, setActive, isLoaded: isSignInLoaded } = (0, import_legacy.useSignIn)();
38
+ const { signUp, isLoaded: isSignUpLoaded } = (0, import_legacy.useSignUp)();
39
+ async function startAppleAuthenticationFlow(startAppleAuthenticationFlowParams) {
40
+ if (!isSignInLoaded || !isSignUpLoaded) {
41
+ return {
42
+ createdSessionId: null,
43
+ signIn,
44
+ signUp,
45
+ setActive
46
+ };
47
+ }
48
+ let AppleAuthentication;
49
+ let Crypto;
50
+ try {
51
+ [AppleAuthentication, Crypto] = await Promise.all([import("expo-apple-authentication"), import("expo-crypto")]);
52
+ } catch {
53
+ return import_errors.errorThrower.throw(
54
+ "expo-apple-authentication is required to use Sign in with Apple. Please install it by running: npx expo install expo-apple-authentication expo-crypto"
55
+ );
56
+ }
57
+ const isAvailable = await AppleAuthentication.isAvailableAsync();
58
+ if (!isAvailable) {
59
+ return import_errors.errorThrower.throw("Apple Authentication is not available on this device.");
60
+ }
61
+ try {
62
+ const nonce = Crypto.randomUUID();
63
+ const credential = await AppleAuthentication.signInAsync({
64
+ requestedScopes: [
65
+ AppleAuthentication.AppleAuthenticationScope.FULL_NAME,
66
+ AppleAuthentication.AppleAuthenticationScope.EMAIL
67
+ ],
68
+ nonce
69
+ });
70
+ const { identityToken } = credential;
71
+ if (!identityToken) {
72
+ return import_errors.errorThrower.throw("No identity token received from Apple Sign-In.");
73
+ }
74
+ await signIn.create({
75
+ strategy: "oauth_token_apple",
76
+ token: identityToken
77
+ });
78
+ const userNeedsToBeCreated = signIn.firstFactorVerification.status === "transferable";
79
+ if (userNeedsToBeCreated) {
80
+ await signUp.create({
81
+ transfer: true,
82
+ unsafeMetadata: startAppleAuthenticationFlowParams == null ? void 0 : startAppleAuthenticationFlowParams.unsafeMetadata
83
+ });
84
+ return {
85
+ createdSessionId: signUp.createdSessionId,
86
+ setActive,
87
+ signIn,
88
+ signUp
89
+ };
90
+ }
91
+ return {
92
+ createdSessionId: signIn.createdSessionId,
93
+ setActive,
94
+ signIn,
95
+ signUp
96
+ };
97
+ } catch (error) {
98
+ if (error && typeof error === "object" && "code" in error && error.code === "ERR_REQUEST_CANCELED") {
99
+ return {
100
+ createdSessionId: null,
101
+ setActive,
102
+ signIn,
103
+ signUp
104
+ };
105
+ }
106
+ throw error;
107
+ }
108
+ }
109
+ return {
110
+ startAppleAuthenticationFlow
111
+ };
112
+ }
113
+ // Annotate the CommonJS export names for ESM import in node:
114
+ 0 && (module.exports = {
115
+ useSignInWithApple
116
+ });
117
+ //# sourceMappingURL=useSignInWithApple.ios.js.map