@tern-secure/react 1.2.0-canary.v20251125170702 → 1.2.0-canary.v20251127221555

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Hook to access Firebase App Check instance and retrieve tokens
3
+ * @returns Object containing appCheck instance and getToken method
4
+ * @throws Error if TernSecure is not initialized or App Check is not configured
5
+ */
6
+ declare const useAppCheck: () => {
7
+ appCheck: any;
8
+ getToken: (forceRefresh?: boolean) => Promise<string | undefined>;
9
+ };
10
+
11
+ export { useAppCheck };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Hook to access Firebase App Check instance and retrieve tokens
3
+ * @returns Object containing appCheck instance and getToken method
4
+ * @throws Error if TernSecure is not initialized or App Check is not configured
5
+ */
6
+ declare const useAppCheck: () => {
7
+ appCheck: any;
8
+ getToken: (forceRefresh?: boolean) => Promise<string | undefined>;
9
+ };
10
+
11
+ export { useAppCheck };
@@ -0,0 +1,2 @@
1
+ "use strict";"use client";var s=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var l=(r,e)=>{for(var t in e)s(r,t,{get:e[t],enumerable:!0})},m=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of k(e))!h.call(r,n)&&n!==t&&s(r,n,{get:()=>e[n],enumerable:!(o=u(e,n))||o.enumerable});return r};var C=r=>m(s({},"__esModule",{value:!0}),r);var f={};l(f,{useAppCheck:()=>a});module.exports=C(f);var i=require("@tern-secure/shared/react"),p=require("firebase/app-check"),c=require("react");const a=()=>{const e=(0,i.useTernSecure)().appCheck;if(!e)throw new Error("Firebase App Check not initialized in TernSecure instance");const t=(0,c.useCallback)(async(o=!1)=>{try{return(await(0,p.getToken)(e,o)).token}catch(n){console.warn("Failed to get App Check token:",n);return}},[e]);return(0,c.useMemo)(()=>({appCheck:e,getToken:t}),[e,t])};0&&(module.exports={useAppCheck});
2
+ //# sourceMappingURL=useAppCheck.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/useAppCheck.ts"],"sourcesContent":["'use client';\n\nimport { useTernSecure } from \"@tern-secure/shared/react\";\nimport { getToken } from 'firebase/app-check';\nimport { useCallback, useMemo } from 'react';\n\n/**\n * Hook to access Firebase App Check instance and retrieve tokens\n * @returns Object containing appCheck instance and getToken method\n * @throws Error if TernSecure is not initialized or App Check is not configured\n */\nconst useAppCheck = () => {\n const ternSecure = useTernSecure();\n const appCheckInstance = ternSecure.appCheck;\n\n if (!appCheckInstance) {\n throw new Error('Firebase App Check not initialized in TernSecure instance');\n }\n\n const getAppCheckToken = useCallback(async (forceRefresh = false): Promise<string | undefined> => {\n try {\n const result = await getToken(appCheckInstance, forceRefresh);\n return result.token;\n } catch (error) {\n console.warn('Failed to get App Check token:', error);\n return undefined;\n }\n }, [appCheckInstance]);\n\n return useMemo(() => ({\n appCheck: appCheckInstance,\n getToken: getAppCheckToken,\n }), [appCheckInstance, getAppCheckToken]);\n};\n\n\n\nexport { useAppCheck };"],"mappings":"sbAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,IAAA,eAAAC,EAAAH,GAEA,IAAAI,EAA8B,qCAC9BC,EAAyB,8BACzBD,EAAqC,iBAOrC,MAAMF,EAAc,IAAM,CAEtB,MAAMI,KADa,iBAAc,EACG,SAEpC,GAAI,CAACA,EACD,MAAM,IAAI,MAAM,2DAA2D,EAG/E,MAAMC,KAAmB,eAAY,MAAOC,EAAe,KAAuC,CAC9F,GAAI,CAEA,OADe,QAAM,YAASF,EAAkBE,CAAY,GAC9C,KAClB,OAASC,EAAO,CACZ,QAAQ,KAAK,iCAAkCA,CAAK,EACpD,MACJ,CACJ,EAAG,CAACH,CAAgB,CAAC,EAErB,SAAO,WAAQ,KAAO,CAClB,SAAUA,EACV,SAAUC,CACd,GAAI,CAACD,EAAkBC,CAAgB,CAAC,CAC5C","names":["useAppCheck_exports","__export","useAppCheck","__toCommonJS","import_react","import_app_check","appCheckInstance","getAppCheckToken","forceRefresh","error"]}
@@ -0,0 +1,2 @@
1
+ "use client";import{useTernSecure as o}from"@tern-secure/shared/react";import{getToken as c}from"firebase/app-check";import{useCallback as s,useMemo as i}from"react";const p=()=>{const e=o().appCheck;if(!e)throw new Error("Firebase App Check not initialized in TernSecure instance");const r=s(async(t=!1)=>{try{return(await c(e,t)).token}catch(n){console.warn("Failed to get App Check token:",n);return}},[e]);return i(()=>({appCheck:e,getToken:r}),[e,r])};export{p as useAppCheck};
2
+ //# sourceMappingURL=useAppCheck.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/useAppCheck.ts"],"sourcesContent":["'use client';\n\nimport { useTernSecure } from \"@tern-secure/shared/react\";\nimport { getToken } from 'firebase/app-check';\nimport { useCallback, useMemo } from 'react';\n\n/**\n * Hook to access Firebase App Check instance and retrieve tokens\n * @returns Object containing appCheck instance and getToken method\n * @throws Error if TernSecure is not initialized or App Check is not configured\n */\nconst useAppCheck = () => {\n const ternSecure = useTernSecure();\n const appCheckInstance = ternSecure.appCheck;\n\n if (!appCheckInstance) {\n throw new Error('Firebase App Check not initialized in TernSecure instance');\n }\n\n const getAppCheckToken = useCallback(async (forceRefresh = false): Promise<string | undefined> => {\n try {\n const result = await getToken(appCheckInstance, forceRefresh);\n return result.token;\n } catch (error) {\n console.warn('Failed to get App Check token:', error);\n return undefined;\n }\n }, [appCheckInstance]);\n\n return useMemo(() => ({\n appCheck: appCheckInstance,\n getToken: getAppCheckToken,\n }), [appCheckInstance, getAppCheckToken]);\n};\n\n\n\nexport { useAppCheck };"],"mappings":"aAEA,OAAS,iBAAAA,MAAqB,4BAC9B,OAAS,YAAAC,MAAgB,qBACzB,OAAS,eAAAC,EAAa,WAAAC,MAAe,QAOrC,MAAMC,EAAc,IAAM,CAEtB,MAAMC,EADaL,EAAc,EACG,SAEpC,GAAI,CAACK,EACD,MAAM,IAAI,MAAM,2DAA2D,EAG/E,MAAMC,EAAmBJ,EAAY,MAAOK,EAAe,KAAuC,CAC9F,GAAI,CAEA,OADe,MAAMN,EAASI,EAAkBE,CAAY,GAC9C,KAClB,OAASC,EAAO,CACZ,QAAQ,KAAK,iCAAkCA,CAAK,EACpD,MACJ,CACJ,EAAG,CAACH,CAAgB,CAAC,EAErB,OAAOF,EAAQ,KAAO,CAClB,SAAUE,EACV,SAAUC,CACd,GAAI,CAACD,EAAkBC,CAAgB,CAAC,CAC5C","names":["useTernSecure","getToken","useCallback","useMemo","useAppCheck","appCheckInstance","getAppCheckToken","forceRefresh","error"]}
@@ -6,7 +6,7 @@ import { UseSignInReturn, SignInPasswordParams, SignInResponse, SocialProviderOp
6
6
  */
7
7
  declare const useSignIn: () => UseSignInReturn;
8
8
  declare const signIn: {
9
- authenticateWithPasswordd: (params: SignInPasswordParams) => Promise<SignInResponse>;
9
+ authenticateWithPassword: (params: SignInPasswordParams) => Promise<SignInResponse>;
10
10
  authenticateWithSocialProvider: (provider: string, customOptions: SocialProviderOptions) => Promise<SignInResponse | void>;
11
11
  attemptEmailVerification: () => Promise<SignInVerificationResponse>;
12
12
  checkRedirectResult: () => Promise<SignInResponse | null>;
@@ -6,7 +6,7 @@ import { UseSignInReturn, SignInPasswordParams, SignInResponse, SocialProviderOp
6
6
  */
7
7
  declare const useSignIn: () => UseSignInReturn;
8
8
  declare const signIn: {
9
- authenticateWithPasswordd: (params: SignInPasswordParams) => Promise<SignInResponse>;
9
+ authenticateWithPassword: (params: SignInPasswordParams) => Promise<SignInResponse>;
10
10
  authenticateWithSocialProvider: (provider: string, customOptions: SocialProviderOptions) => Promise<SignInResponse | void>;
11
11
  attemptEmailVerification: () => Promise<SignInVerificationResponse>;
12
12
  checkRedirectResult: () => Promise<SignInResponse | null>;
@@ -1,2 +1,2 @@
1
- "use strict";"use client";var o=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var d=(n,e)=>{for(var i in e)o(n,i,{get:e[i],enumerable:!0})},l=(n,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of c(e))!h.call(n,r)&&r!==i&&o(n,r,{get:()=>e[r],enumerable:!(s=u(e,r))||s.enumerable});return n};var S=n=>l(o({},"__esModule",{value:!0}),n);var I={};d(I,{signIn:()=>m,useSignIn:()=>g});module.exports=S(I);var t=require("../ctx/TernSecureAuthResourcesCtx"),a=require("./useAssertWrappedTernSecureProvider");const g=()=>{(0,a.useAssertWrappedByTernSecureAuthProvider)("useSignIn");const n=(0,t.useAuthSignInCtx)();return n?{isLoaded:!0,signIn:n}:{isLoaded:!1,signIn:void 0}},m={authenticateWithPasswordd:async n=>{const e=(0,t.useAuthSignInCtx)();if(!e)throw new Error("SignIn methods not available - auth not initialized");return e.authenticateWithPassword(n)},authenticateWithSocialProvider:async(n,e)=>{const i=(0,t.useAuthSignInCtx)();if(!i)throw new Error("SignIn methods not available - auth not initialized");return i.authenticateWithSocialProvider(n,e)},attemptEmailVerification:async()=>{const n=(0,t.useAuthSignInCtx)();if(!n)throw new Error("SignIn methods not available - auth not initialized");return n.attemptEmailVerification()},checkRedirectResult:async()=>{const n=(0,t.useAuthSignInCtx)();if(!n)throw new Error("SignIn methods not available - auth not initialized");return n.checkRedirectResult()}};0&&(module.exports={signIn,useSignIn});
1
+ "use strict";"use client";var o=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var d=(n,e)=>{for(var i in e)o(n,i,{get:e[i],enumerable:!0})},l=(n,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of c(e))!h.call(n,r)&&r!==i&&o(n,r,{get:()=>e[r],enumerable:!(s=u(e,r))||s.enumerable});return n};var S=n=>l(o({},"__esModule",{value:!0}),n);var I={};d(I,{signIn:()=>m,useSignIn:()=>g});module.exports=S(I);var t=require("../ctx/TernSecureAuthResourcesCtx"),a=require("./useAssertWrappedTernSecureProvider");const g=()=>{(0,a.useAssertWrappedByTernSecureAuthProvider)("useSignIn");const n=(0,t.useAuthSignInCtx)();return n?{isLoaded:!0,signIn:n}:{isLoaded:!1,signIn:void 0}},m={authenticateWithPassword:async n=>{const e=(0,t.useAuthSignInCtx)();if(!e)throw new Error("SignIn methods not available - auth not initialized");return e.authenticateWithPassword(n)},authenticateWithSocialProvider:async(n,e)=>{const i=(0,t.useAuthSignInCtx)();if(!i)throw new Error("SignIn methods not available - auth not initialized");return i.authenticateWithSocialProvider(n,e)},attemptEmailVerification:async()=>{const n=(0,t.useAuthSignInCtx)();if(!n)throw new Error("SignIn methods not available - auth not initialized");return n.attemptEmailVerification()},checkRedirectResult:async()=>{const n=(0,t.useAuthSignInCtx)();if(!n)throw new Error("SignIn methods not available - auth not initialized");return n.checkRedirectResult()}};0&&(module.exports={signIn,useSignIn});
2
2
  //# sourceMappingURL=useSignIn.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/useSignIn.tsx"],"sourcesContent":["'use client';\n\nimport type {\n SignInPasswordParams,\n SignInResponse,\n SignInVerificationResponse,\n SocialProviderOptions,\n UseSignInReturn,\n} from '@tern-secure/types';\n\nimport { useAuthSignInCtx } from '../ctx/TernSecureAuthResourcesCtx';\nimport { useAssertWrappedByTernSecureAuthProvider } from './useAssertWrappedTernSecureProvider';\n\n/**\n * Hook to access the SignInResource methods from TernSecureAuth\n * Provides type-safe access to all sign-in related functionality\n */\nexport const useSignIn = (): UseSignInReturn => {\n useAssertWrappedByTernSecureAuthProvider('useSignIn');\n const auth = useAuthSignInCtx();\n\n if (!auth) {\n return {\n isLoaded: false,\n signIn: undefined,\n };\n }\n\n return {\n isLoaded: true,\n signIn: auth,\n };\n};\n\nexport const signIn = {\n authenticateWithPasswordd: async (params: SignInPasswordParams): Promise<SignInResponse> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.authenticateWithPassword(params);\n },\n\n authenticateWithSocialProvider: async (\n provider: string,\n customOptions: SocialProviderOptions,\n ): Promise<SignInResponse | void> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.authenticateWithSocialProvider(provider, customOptions);\n },\n\n attemptEmailVerification: async (): Promise<SignInVerificationResponse> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.attemptEmailVerification();\n },\n\n checkRedirectResult: async (): Promise<SignInResponse | null> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.checkRedirectResult();\n },\n};\n"],"mappings":"sbAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,YAAAE,EAAA,cAAAC,IAAA,eAAAC,EAAAJ,GAUA,IAAAK,EAAiC,6CACjCC,EAAyD,gDAMlD,MAAMH,EAAY,IAAuB,IAC9C,4CAAyC,WAAW,EACpD,MAAMI,KAAO,oBAAiB,EAE9B,OAAKA,EAOE,CACL,SAAU,GACV,OAAQA,CACV,EATS,CACL,SAAU,GACV,OAAQ,MACV,CAOJ,EAEaL,EAAS,CACpB,0BAA2B,MAAOM,GAA0D,CAC1F,MAAMD,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,yBAAyBC,CAAM,CAC7C,EAEA,+BAAgC,MAC9BC,EACAC,IACmC,CACnC,MAAMH,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,+BAA+BE,EAAUC,CAAa,CACpE,EAEA,yBAA0B,SAAiD,CACzE,MAAMH,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,yBAAyB,CACvC,EAEA,oBAAqB,SAA4C,CAC/D,MAAMA,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,oBAAoB,CAClC,CACF","names":["useSignIn_exports","__export","signIn","useSignIn","__toCommonJS","import_TernSecureAuthResourcesCtx","import_useAssertWrappedTernSecureProvider","auth","params","provider","customOptions"]}
1
+ {"version":3,"sources":["../../src/hooks/useSignIn.tsx"],"sourcesContent":["'use client';\n\nimport type {\n SignInPasswordParams,\n SignInResponse,\n SignInVerificationResponse,\n SocialProviderOptions,\n UseSignInReturn,\n} from '@tern-secure/types';\n\nimport { useAuthSignInCtx } from '../ctx/TernSecureAuthResourcesCtx';\nimport { useAssertWrappedByTernSecureAuthProvider } from './useAssertWrappedTernSecureProvider';\n\n/**\n * Hook to access the SignInResource methods from TernSecureAuth\n * Provides type-safe access to all sign-in related functionality\n */\nexport const useSignIn = (): UseSignInReturn => {\n useAssertWrappedByTernSecureAuthProvider('useSignIn');\n const auth = useAuthSignInCtx();\n\n if (!auth) {\n return {\n isLoaded: false,\n signIn: undefined,\n };\n }\n\n return {\n isLoaded: true,\n signIn: auth,\n };\n};\n\nexport const signIn = {\n authenticateWithPassword: async (params: SignInPasswordParams): Promise<SignInResponse> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.authenticateWithPassword(params);\n },\n\n authenticateWithSocialProvider: async (\n provider: string,\n customOptions: SocialProviderOptions,\n ): Promise<SignInResponse | void> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.authenticateWithSocialProvider(provider, customOptions);\n },\n\n attemptEmailVerification: async (): Promise<SignInVerificationResponse> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.attemptEmailVerification();\n },\n\n checkRedirectResult: async (): Promise<SignInResponse | null> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.checkRedirectResult();\n },\n};\n"],"mappings":"sbAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,YAAAE,EAAA,cAAAC,IAAA,eAAAC,EAAAJ,GAUA,IAAAK,EAAiC,6CACjCC,EAAyD,gDAMlD,MAAMH,EAAY,IAAuB,IAC9C,4CAAyC,WAAW,EACpD,MAAMI,KAAO,oBAAiB,EAE9B,OAAKA,EAOE,CACL,SAAU,GACV,OAAQA,CACV,EATS,CACL,SAAU,GACV,OAAQ,MACV,CAOJ,EAEaL,EAAS,CACpB,yBAA0B,MAAOM,GAA0D,CACzF,MAAMD,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,yBAAyBC,CAAM,CAC7C,EAEA,+BAAgC,MAC9BC,EACAC,IACmC,CACnC,MAAMH,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,+BAA+BE,EAAUC,CAAa,CACpE,EAEA,yBAA0B,SAAiD,CACzE,MAAMH,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,yBAAyB,CACvC,EAEA,oBAAqB,SAA4C,CAC/D,MAAMA,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,oBAAoB,CAClC,CACF","names":["useSignIn_exports","__export","signIn","useSignIn","__toCommonJS","import_TernSecureAuthResourcesCtx","import_useAssertWrappedTernSecureProvider","auth","params","provider","customOptions"]}
@@ -1,2 +1,2 @@
1
- "use client";import{useAuthSignInCtx as e}from"../ctx/TernSecureAuthResourcesCtx";import{useAssertWrappedByTernSecureAuthProvider as r}from"./useAssertWrappedTernSecureProvider";const a=()=>{r("useSignIn");const n=e();return n?{isLoaded:!0,signIn:n}:{isLoaded:!1,signIn:void 0}},u={authenticateWithPasswordd:async n=>{const i=e();if(!i)throw new Error("SignIn methods not available - auth not initialized");return i.authenticateWithPassword(n)},authenticateWithSocialProvider:async(n,i)=>{const t=e();if(!t)throw new Error("SignIn methods not available - auth not initialized");return t.authenticateWithSocialProvider(n,i)},attemptEmailVerification:async()=>{const n=e();if(!n)throw new Error("SignIn methods not available - auth not initialized");return n.attemptEmailVerification()},checkRedirectResult:async()=>{const n=e();if(!n)throw new Error("SignIn methods not available - auth not initialized");return n.checkRedirectResult()}};export{u as signIn,a as useSignIn};
1
+ "use client";import{useAuthSignInCtx as e}from"../ctx/TernSecureAuthResourcesCtx";import{useAssertWrappedByTernSecureAuthProvider as r}from"./useAssertWrappedTernSecureProvider";const a=()=>{r("useSignIn");const n=e();return n?{isLoaded:!0,signIn:n}:{isLoaded:!1,signIn:void 0}},u={authenticateWithPassword:async n=>{const i=e();if(!i)throw new Error("SignIn methods not available - auth not initialized");return i.authenticateWithPassword(n)},authenticateWithSocialProvider:async(n,i)=>{const t=e();if(!t)throw new Error("SignIn methods not available - auth not initialized");return t.authenticateWithSocialProvider(n,i)},attemptEmailVerification:async()=>{const n=e();if(!n)throw new Error("SignIn methods not available - auth not initialized");return n.attemptEmailVerification()},checkRedirectResult:async()=>{const n=e();if(!n)throw new Error("SignIn methods not available - auth not initialized");return n.checkRedirectResult()}};export{u as signIn,a as useSignIn};
2
2
  //# sourceMappingURL=useSignIn.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/useSignIn.tsx"],"sourcesContent":["'use client';\n\nimport type {\n SignInPasswordParams,\n SignInResponse,\n SignInVerificationResponse,\n SocialProviderOptions,\n UseSignInReturn,\n} from '@tern-secure/types';\n\nimport { useAuthSignInCtx } from '../ctx/TernSecureAuthResourcesCtx';\nimport { useAssertWrappedByTernSecureAuthProvider } from './useAssertWrappedTernSecureProvider';\n\n/**\n * Hook to access the SignInResource methods from TernSecureAuth\n * Provides type-safe access to all sign-in related functionality\n */\nexport const useSignIn = (): UseSignInReturn => {\n useAssertWrappedByTernSecureAuthProvider('useSignIn');\n const auth = useAuthSignInCtx();\n\n if (!auth) {\n return {\n isLoaded: false,\n signIn: undefined,\n };\n }\n\n return {\n isLoaded: true,\n signIn: auth,\n };\n};\n\nexport const signIn = {\n authenticateWithPasswordd: async (params: SignInPasswordParams): Promise<SignInResponse> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.authenticateWithPassword(params);\n },\n\n authenticateWithSocialProvider: async (\n provider: string,\n customOptions: SocialProviderOptions,\n ): Promise<SignInResponse | void> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.authenticateWithSocialProvider(provider, customOptions);\n },\n\n attemptEmailVerification: async (): Promise<SignInVerificationResponse> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.attemptEmailVerification();\n },\n\n checkRedirectResult: async (): Promise<SignInResponse | null> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.checkRedirectResult();\n },\n};\n"],"mappings":"aAUA,OAAS,oBAAAA,MAAwB,oCACjC,OAAS,4CAAAC,MAAgD,uCAMlD,MAAMC,EAAY,IAAuB,CAC9CD,EAAyC,WAAW,EACpD,MAAME,EAAOH,EAAiB,EAE9B,OAAKG,EAOE,CACL,SAAU,GACV,OAAQA,CACV,EATS,CACL,SAAU,GACV,OAAQ,MACV,CAOJ,EAEaC,EAAS,CACpB,0BAA2B,MAAOC,GAA0D,CAC1F,MAAMF,EAAOH,EAAiB,EAC9B,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,yBAAyBE,CAAM,CAC7C,EAEA,+BAAgC,MAC9BC,EACAC,IACmC,CACnC,MAAMJ,EAAOH,EAAiB,EAC9B,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,+BAA+BG,EAAUC,CAAa,CACpE,EAEA,yBAA0B,SAAiD,CACzE,MAAMJ,EAAOH,EAAiB,EAC9B,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,yBAAyB,CACvC,EAEA,oBAAqB,SAA4C,CAC/D,MAAMA,EAAOH,EAAiB,EAC9B,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,oBAAoB,CAClC,CACF","names":["useAuthSignInCtx","useAssertWrappedByTernSecureAuthProvider","useSignIn","auth","signIn","params","provider","customOptions"]}
1
+ {"version":3,"sources":["../../src/hooks/useSignIn.tsx"],"sourcesContent":["'use client';\n\nimport type {\n SignInPasswordParams,\n SignInResponse,\n SignInVerificationResponse,\n SocialProviderOptions,\n UseSignInReturn,\n} from '@tern-secure/types';\n\nimport { useAuthSignInCtx } from '../ctx/TernSecureAuthResourcesCtx';\nimport { useAssertWrappedByTernSecureAuthProvider } from './useAssertWrappedTernSecureProvider';\n\n/**\n * Hook to access the SignInResource methods from TernSecureAuth\n * Provides type-safe access to all sign-in related functionality\n */\nexport const useSignIn = (): UseSignInReturn => {\n useAssertWrappedByTernSecureAuthProvider('useSignIn');\n const auth = useAuthSignInCtx();\n\n if (!auth) {\n return {\n isLoaded: false,\n signIn: undefined,\n };\n }\n\n return {\n isLoaded: true,\n signIn: auth,\n };\n};\n\nexport const signIn = {\n authenticateWithPassword: async (params: SignInPasswordParams): Promise<SignInResponse> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.authenticateWithPassword(params);\n },\n\n authenticateWithSocialProvider: async (\n provider: string,\n customOptions: SocialProviderOptions,\n ): Promise<SignInResponse | void> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.authenticateWithSocialProvider(provider, customOptions);\n },\n\n attemptEmailVerification: async (): Promise<SignInVerificationResponse> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.attemptEmailVerification();\n },\n\n checkRedirectResult: async (): Promise<SignInResponse | null> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error('SignIn methods not available - auth not initialized');\n }\n return auth.checkRedirectResult();\n },\n};\n"],"mappings":"aAUA,OAAS,oBAAAA,MAAwB,oCACjC,OAAS,4CAAAC,MAAgD,uCAMlD,MAAMC,EAAY,IAAuB,CAC9CD,EAAyC,WAAW,EACpD,MAAME,EAAOH,EAAiB,EAE9B,OAAKG,EAOE,CACL,SAAU,GACV,OAAQA,CACV,EATS,CACL,SAAU,GACV,OAAQ,MACV,CAOJ,EAEaC,EAAS,CACpB,yBAA0B,MAAOC,GAA0D,CACzF,MAAMF,EAAOH,EAAiB,EAC9B,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,yBAAyBE,CAAM,CAC7C,EAEA,+BAAgC,MAC9BC,EACAC,IACmC,CACnC,MAAMJ,EAAOH,EAAiB,EAC9B,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,+BAA+BG,EAAUC,CAAa,CACpE,EAEA,yBAA0B,SAAiD,CACzE,MAAMJ,EAAOH,EAAiB,EAC9B,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,yBAAyB,CACvC,EAEA,oBAAqB,SAA4C,CAC/D,MAAMA,EAAOH,EAAiB,EAC9B,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,oBAAoB,CAClC,CACF","names":["useAuthSignInCtx","useAssertWrappedByTernSecureAuthProvider","useSignIn","auth","signIn","params","provider","customOptions"]}
@@ -1,2 +1,2 @@
1
- "use strict";var o=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var f=(i,e)=>{for(var t in e)o(i,t,{get:e[t],enumerable:!0})},g=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of p(e))!S.call(i,n)&&n!==t&&o(i,n,{get:()=>e[n],enumerable:!(r=l(e,n))||r.enumerable});return i};var T=i=>g(o({},"__esModule",{value:!0}),i);var m={};f(m,{IsoTernSecureAuth:()=>h,inBrowser:()=>a});module.exports=T(m);var d=require("@tern-secure/shared/loadTernUIScript"),s=require("@tern-secure/shared/ternStatusEvent"),u=require("@tern-secure/shared/utils"),c=require("../utils/isConstructor");const w={name:"@tern-secure/react",version:"1.2.0-canary.v20251125170702",environment:process.env.NODE_ENV};function a(){return typeof window<"u"}class h{_mode;options;TernSecureAuth;TernSecure;ternauth=null;ternui=null;preAddListener=new Map;premountState={signInNodes:new Map,signUpNodes:new Map,userButttonNodes:new Map,verifyNodes:new Set,methodCalls:new Map,errorListeners:new Set};#s="loading";#r;#i;#n;#t=(0,s.createTernAuthEventBus)();static#e;get status(){return this.ternui?this.ternui.status||(this.ternui.isReady?"ready":"loading"):this.#s}get isReady(){return this.ternui?.isReady||!1}get isLoading(){return this.ternui?.isLoading||!1}get requiresVerification(){return this.options.requiresVerification??!0}get signIn(){if(this.ternui)return this.ternui.signIn||void 0}get signUp(){if(this.ternui)return this.ternui.signUp||void 0}get user(){return this.ternui?this.ternui.user:null}static getOrCreateInstance(e){return(!a()||!this.#e||e.TernSecureAuth&&this.#e.TernSecureAuth!==e.TernSecureAuth)&&(this.#e=new h(e)),this.#e}static clearInstances(){this.#e&&(this.#e.ternui=null,this.#e=null)}static clearInstance(){this.#e=null}get authDomain(){if(typeof window<"u"&&window.location)return(0,u.handleValueOrFn)(this.#i,new URL(window.location.href),"");if(typeof this.#i=="function")throw new Error("Unsupported customDomain type: function");return this.#i||""}get proxyUrl(){if(typeof window<"u"&&window.location)return(0,u.handleValueOrFn)(this.#n,new URL(window.location.href),"");if(typeof this.#n=="function")throw new Error("Unsupported customProxyUrl type: function");return this.#n||""}get mode(){return this._mode}_internal_getOption(e){return this.ternui?._internal_getOption?this.ternui?._internal_getOption(e):this.options[e]}_internal_getAllOptions(){return Object.freeze({...this.options})}constructor(e){const{TernSecureAuth:t=null,TernSecure:r=null}=e||{};this.#i=e.ternSecureConfig?.authDomain,this.options={...e},this._mode=a()?"browser":"server",this.#r=this.options.apiUrl,this.#n=this.options.proxyUrl,this.TernSecureAuth=t,this.TernSecure=r,this.options.sdkMetadata||(this.options.sdkMetadata=w),this.#r&&this.loadTernUI()}get sdkMetadata(){return this.ternui?.sdkMetadata||this.options.sdkMetadata}get version(){return this.ternui?.version}get instanceType(){return this.ternui?.instanceType}get apiUrl(){return this.#r||""}#o(){return new Promise(e=>{e(this.ternui)})}async loadTernUI(){if(!(this._mode!=="browser"||this.isReady)){typeof window<"u"&&(window._TernSecure_authDomain=this.authDomain,window._TernSecure_proxyUrl=this.proxyUrl,window._TernSecure_apiUrl=this.apiUrl);try{if(this.TernSecure){let e;(0,c.isConstructor)(this.TernSecure)?(e=new this.TernSecure(this.#r,{proxyUrl:this.proxyUrl,authDomain:this.authDomain}),this.beforeLoad(e),await e.load(this.options)):(e=this.TernSecure,e.isReady||(this.beforeLoad(e),await e.load(this.options))),global.TernSecure=e}else{if(global.TernSecure||await(0,d.loadTernUIScript)({...this.options,authDomain:this.authDomain,nonce:this.options.nonce}),!global.TernSecure)throw new Error("TernSecure instance is not available globally");this.beforeLoad(global.TernSecure),await global.TernSecure.load(this.options)}return global.TernSecure?.isReady?this.injectTernUI(global.TernSecure):void 0}catch(e){const t=e;console.error(t.stack||t.message||t);return}}}beforeLoad=e=>{if(!e)throw new Error("Failed to inject TernUI")};injectTernUI=e=>{if(!e)throw new Error("TernUI instance is not initialized");return this.ternui=e,this.premountState.methodCalls.forEach(t=>t()),this.preAddListener.forEach((t,r)=>{t.unsubscribe=e.addListener(r)}),this.#t.getListeners("status").forEach(t=>{this.on("status",t,{notify:!0})}),this.premountState.signInNodes.forEach((t,r)=>{e.showSignIn(r,t)}),this.premountState.signUpNodes.forEach((t,r)=>{e.showSignUp(r,t)}),typeof this.ternui.status>"u"&&(console.log("[IsomorphicTernSecure] TernUI has no status, setting internal status to ready"),this.#s="ready",this.#t.emit("status","ready"),console.log("[IsomorphicTernSecure] Set internal status to ready (ternui has no status)")),this.ternui};initTernSecureAuth(){if(this._mode!=="browser"||this.isReady)return;const e=TernSecureAuthImpl.initialize(this.options);this.loadTernSecureAuth(e)}loadTernSecureAuth=e=>{if(!e)throw new Error("TernAuth instance is not initialized");return this.ternauth=e,this.preAddListener.forEach((t,r)=>{t.unsubscribe=e.addListener(r)}),this.#t.getListeners("status").forEach(t=>{this.on("status",t,{notify:!0})}),typeof this.ternauth.status>"u"&&(console.log("[IsoTernSecureAuth] TernSecureAuth has no status, setting internal status to ready"),this.#s="ready",this.#t.emit(s.ternEvents.Status,"ready")),this.ternauth};on=(...e)=>this.ternui?.on?this.ternui.on(...e):this.#t.on(...e);off=(...e)=>this.ternui?.off?this.ternui.off(...e):this.#t.off(...e);addListener=e=>{if(this.ternui)return this.ternui.addListener(e);{const t=()=>{const r=this.preAddListener.get(e);r&&(r.unsubscribe(),this.preAddListener.delete(e))};return this.preAddListener.set(e,{unsubscribe:t}),t}};createActiveSession=e=>this.ternui?this.ternui.createActiveSession(e):Promise.reject(new Error("TernSecureAuth not initialized"));signOut=async e=>{if(!this.ternui)throw new Error("TernSecureAuth not initialized");await this.ternui.signOut()};get currentSession(){return this.ternui?this.ternui.currentSession:null}onAuthStateChanged(e){return this.ternui?this.ternui.onAuthStateChanged(e):(console.warn("[IsoTernSecureAuth] TernAuth not initialized, cannot set up auth state listener"),()=>{})}getRedirectResult=async()=>{if(!this.ternui?.getRedirectResult)throw new Error("TernSecure instance not initialized");return this.ternui.getRedirectResult()};constructUrlWithAuthRedirect=e=>this.ternui&&this.isReady?this.ternui.constructUrlWithAuthRedirect(e):"";constructAfterSignOutUrl=()=>{if(this.ternui&&this.isReady)return this.ternui.constructAfterSignOutUrl()||"";{const e=()=>this.ternui?.constructAfterSignOutUrl()||"";return this.premountState.methodCalls.set("constructAfterSignOutUrl",e),""}};navigate=e=>{this.ternui&&this.isReady&&this.ternui.navigate(e)};initialize=async()=>{try{await this.#o()}catch(e){throw console.error("[IsomorphicTernSecure] Failed to initialize TernUI:",e),e}};showSignIn=(e,t)=>{this.ternui&&this.isReady?this.ternui.showSignIn(e,t):this.premountState.signInNodes.set(e,t)};hideSignIn=e=>{this.ternui&&this.isReady?this.ternui.hideSignIn(e):this.premountState.signInNodes.delete(e)};showSignUp=(e,t)=>{this.ternui&&this.isReady?this.ternui.showSignUp(e,t):this.premountState.signUpNodes.set(e,t)};hideSignUp=e=>{this.ternui&&this.isReady?this.ternui.hideSignUp(e):this.premountState.signUpNodes.delete(e)};showUserButton=e=>{this.ternui&&this.isReady?this.ternui.showUserButton(e):this.premountState.userButttonNodes.set(e,void 0)};hideUserButton=e=>{this.ternui&&this.isReady?this.ternui.hideUserButton(e):this.premountState.userButttonNodes.delete(e)};redirectToSignIn=async e=>{this.ternui?.redirectToSignIn&&this.ternui.redirectToSignIn(e)};redirectToSignUp=async e=>{this.ternui?.redirectToSignUp&&this.ternui.redirectToSignUp()};redirectAfterSignIn=e=>{this.ternui?.redirectAfterSignIn&&this.ternui.redirectAfterSignIn()};redirectAfterSignUp=e=>{this.ternui?.redirectAfterSignUp&&this.ternui.redirectAfterSignUp()};#u(){return new Promise(e=>{e(this.ternauth)})}initializeAuth=async()=>{this.initTernSecureAuth();try{await this.#u()}catch(e){throw console.error("[IsomorphicTernSecure] Failed to initialize TernSecureAuth:",e),e}}}0&&(module.exports={IsoTernSecureAuth,inBrowser});
1
+ "use strict";var o=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var f=(i,e)=>{for(var t in e)o(i,t,{get:e[t],enumerable:!0})},g=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of p(e))!S.call(i,n)&&n!==t&&o(i,n,{get:()=>e[n],enumerable:!(r=l(e,n))||r.enumerable});return i};var T=i=>g(o({},"__esModule",{value:!0}),i);var m={};f(m,{IsoTernSecureAuth:()=>h,inBrowser:()=>a});module.exports=T(m);var d=require("@tern-secure/shared/loadTernUIScript"),s=require("@tern-secure/shared/ternStatusEvent"),u=require("@tern-secure/shared/utils"),c=require("../utils/isConstructor");const w={name:"@tern-secure/react",version:"1.2.0-canary.v20251127221555",environment:process.env.NODE_ENV};function a(){return typeof window<"u"}class h{_mode;options;TernSecureAuth;TernSecure;ternauth=null;ternui=null;preAddListener=new Map;premountState={signInNodes:new Map,signUpNodes:new Map,userButttonNodes:new Map,verifyNodes:new Set,methodCalls:new Map,errorListeners:new Set};#s="loading";#r;#i;#n;#t=(0,s.createTernAuthEventBus)();static#e;get status(){return this.ternui?this.ternui.status||(this.ternui.isReady?"ready":"loading"):this.#s}get isReady(){return this.ternui?.isReady||!1}get isLoading(){return this.ternui?.isLoading||!1}get requiresVerification(){return this.options.requiresVerification??!0}get signIn(){if(this.ternui)return this.ternui.signIn||void 0}get signUp(){if(this.ternui)return this.ternui.signUp||void 0}get user(){return this.ternui?this.ternui.user:null}static getOrCreateInstance(e){return(!a()||!this.#e||e.TernSecureAuth&&this.#e.TernSecureAuth!==e.TernSecureAuth)&&(this.#e=new h(e)),this.#e}static clearInstances(){this.#e&&(this.#e.ternui=null,this.#e=null)}static clearInstance(){this.#e=null}get authDomain(){if(typeof window<"u"&&window.location)return(0,u.handleValueOrFn)(this.#i,new URL(window.location.href),"");if(typeof this.#i=="function")throw new Error("Unsupported customDomain type: function");return this.#i||""}get proxyUrl(){if(typeof window<"u"&&window.location)return(0,u.handleValueOrFn)(this.#n,new URL(window.location.href),"");if(typeof this.#n=="function")throw new Error("Unsupported customProxyUrl type: function");return this.#n||""}get mode(){return this._mode}_internal_getOption(e){return this.ternui?._internal_getOption?this.ternui?._internal_getOption(e):this.options[e]}_internal_getAllOptions(){return Object.freeze({...this.options})}constructor(e){const{TernSecureAuth:t=null,TernSecure:r=null}=e||{};this.#i=e.ternSecureConfig?.authDomain,this.options={...e},this._mode=a()?"browser":"server",this.#r=this.options.apiUrl,this.#n=this.options.proxyUrl,this.TernSecureAuth=t,this.TernSecure=r,this.options.sdkMetadata||(this.options.sdkMetadata=w),this.#r&&this.loadTernUI()}get sdkMetadata(){return this.ternui?.sdkMetadata||this.options.sdkMetadata}get version(){return this.ternui?.version}get instanceType(){return this.ternui?.instanceType}get apiUrl(){return this.#r||""}#o(){return new Promise(e=>{e(this.ternui)})}async loadTernUI(){if(!(this._mode!=="browser"||this.isReady)){typeof window<"u"&&(window._TernSecure_authDomain=this.authDomain,window._TernSecure_proxyUrl=this.proxyUrl,window._TernSecure_apiUrl=this.apiUrl);try{if(this.TernSecure){let e;(0,c.isConstructor)(this.TernSecure)?(e=new this.TernSecure(this.#r,{proxyUrl:this.proxyUrl,authDomain:this.authDomain}),this.beforeLoad(e),await e.load(this.options)):(e=this.TernSecure,e.isReady||(this.beforeLoad(e),await e.load(this.options))),global.TernSecure=e}else{if(global.TernSecure||await(0,d.loadTernUIScript)({...this.options,authDomain:this.authDomain,nonce:this.options.nonce}),!global.TernSecure)throw new Error("TernSecure instance is not available globally");this.beforeLoad(global.TernSecure),await global.TernSecure.load(this.options)}return global.TernSecure?.isReady?this.injectTernUI(global.TernSecure):void 0}catch(e){const t=e;console.error(t.stack||t.message||t);return}}}beforeLoad=e=>{if(!e)throw new Error("Failed to inject TernUI")};injectTernUI=e=>{if(!e)throw new Error("TernUI instance is not initialized");return this.ternui=e,this.premountState.methodCalls.forEach(t=>t()),this.preAddListener.forEach((t,r)=>{t.unsubscribe=e.addListener(r)}),this.#t.getListeners("status").forEach(t=>{this.on("status",t,{notify:!0})}),this.premountState.signInNodes.forEach((t,r)=>{e.showSignIn(r,t)}),this.premountState.signUpNodes.forEach((t,r)=>{e.showSignUp(r,t)}),typeof this.ternui.status>"u"&&(console.log("[IsomorphicTernSecure] TernUI has no status, setting internal status to ready"),this.#s="ready",this.#t.emit("status","ready"),console.log("[IsomorphicTernSecure] Set internal status to ready (ternui has no status)")),this.ternui};initTernSecureAuth(){if(this._mode!=="browser"||this.isReady)return;const e=TernSecureAuthImpl.initialize(this.options);this.loadTernSecureAuth(e)}loadTernSecureAuth=e=>{if(!e)throw new Error("TernAuth instance is not initialized");return this.ternauth=e,this.preAddListener.forEach((t,r)=>{t.unsubscribe=e.addListener(r)}),this.#t.getListeners("status").forEach(t=>{this.on("status",t,{notify:!0})}),typeof this.ternauth.status>"u"&&(console.log("[IsoTernSecureAuth] TernSecureAuth has no status, setting internal status to ready"),this.#s="ready",this.#t.emit(s.ternEvents.Status,"ready")),this.ternauth};on=(...e)=>this.ternui?.on?this.ternui.on(...e):this.#t.on(...e);off=(...e)=>this.ternui?.off?this.ternui.off(...e):this.#t.off(...e);addListener=e=>{if(this.ternui)return this.ternui.addListener(e);{const t=()=>{const r=this.preAddListener.get(e);r&&(r.unsubscribe(),this.preAddListener.delete(e))};return this.preAddListener.set(e,{unsubscribe:t}),t}};createActiveSession=e=>this.ternui?this.ternui.createActiveSession(e):Promise.reject(new Error("TernSecureAuth not initialized"));signOut=async e=>{if(!this.ternui)throw new Error("TernSecureAuth not initialized");await this.ternui.signOut()};get currentSession(){return this.ternui?this.ternui.currentSession:null}onAuthStateChanged(e){return this.ternui?this.ternui.onAuthStateChanged(e):(console.warn("[IsoTernSecureAuth] TernAuth not initialized, cannot set up auth state listener"),()=>{})}getRedirectResult=async()=>{if(!this.ternui?.getRedirectResult)throw new Error("TernSecure instance not initialized");return this.ternui.getRedirectResult()};constructUrlWithAuthRedirect=e=>this.ternui&&this.isReady?this.ternui.constructUrlWithAuthRedirect(e):"";constructAfterSignOutUrl=()=>{if(this.ternui&&this.isReady)return this.ternui.constructAfterSignOutUrl()||"";{const e=()=>this.ternui?.constructAfterSignOutUrl()||"";return this.premountState.methodCalls.set("constructAfterSignOutUrl",e),""}};navigate=e=>{this.ternui&&this.isReady&&this.ternui.navigate(e)};initialize=async()=>{try{await this.#o()}catch(e){throw console.error("[IsomorphicTernSecure] Failed to initialize TernUI:",e),e}};showSignIn=(e,t)=>{this.ternui&&this.isReady?this.ternui.showSignIn(e,t):this.premountState.signInNodes.set(e,t)};hideSignIn=e=>{this.ternui&&this.isReady?this.ternui.hideSignIn(e):this.premountState.signInNodes.delete(e)};showSignUp=(e,t)=>{this.ternui&&this.isReady?this.ternui.showSignUp(e,t):this.premountState.signUpNodes.set(e,t)};hideSignUp=e=>{this.ternui&&this.isReady?this.ternui.hideSignUp(e):this.premountState.signUpNodes.delete(e)};showUserButton=e=>{this.ternui&&this.isReady?this.ternui.showUserButton(e):this.premountState.userButttonNodes.set(e,void 0)};hideUserButton=e=>{this.ternui&&this.isReady?this.ternui.hideUserButton(e):this.premountState.userButttonNodes.delete(e)};redirectToSignIn=async e=>{this.ternui?.redirectToSignIn&&this.ternui.redirectToSignIn(e)};redirectToSignUp=async e=>{this.ternui?.redirectToSignUp&&this.ternui.redirectToSignUp()};redirectAfterSignIn=e=>{this.ternui?.redirectAfterSignIn&&this.ternui.redirectAfterSignIn()};redirectAfterSignUp=e=>{this.ternui?.redirectAfterSignUp&&this.ternui.redirectAfterSignUp()};#u(){return new Promise(e=>{e(this.ternauth)})}initializeAuth=async()=>{this.initTernSecureAuth();try{await this.#u()}catch(e){throw console.error("[IsomorphicTernSecure] Failed to initialize TernSecureAuth:",e),e}}}0&&(module.exports={IsoTernSecureAuth,inBrowser});
2
2
  //# sourceMappingURL=isoTernSecureAuth.js.map
@@ -1,2 +1,2 @@
1
- import{loadTernUIScript as o}from"@tern-secure/shared/loadTernUIScript";import{createTernAuthEventBus as u,ternEvents as a}from"@tern-secure/shared/ternStatusEvent";import{handleValueOrFn as i}from"@tern-secure/shared/utils";import{isConstructor as h}from"../utils/isConstructor";const d={name:"@tern-secure/react",version:"1.2.0-canary.v20251125170702",environment:process.env.NODE_ENV};function n(){return typeof window<"u"}class s{_mode;options;TernSecureAuth;TernSecure;ternauth=null;ternui=null;preAddListener=new Map;premountState={signInNodes:new Map,signUpNodes:new Map,userButttonNodes:new Map,verifyNodes:new Set,methodCalls:new Map,errorListeners:new Set};#s="loading";#r;#i;#n;#t=u();static#e;get status(){return this.ternui?this.ternui.status||(this.ternui.isReady?"ready":"loading"):this.#s}get isReady(){return this.ternui?.isReady||!1}get isLoading(){return this.ternui?.isLoading||!1}get requiresVerification(){return this.options.requiresVerification??!0}get signIn(){if(this.ternui)return this.ternui.signIn||void 0}get signUp(){if(this.ternui)return this.ternui.signUp||void 0}get user(){return this.ternui?this.ternui.user:null}static getOrCreateInstance(e){return(!n()||!this.#e||e.TernSecureAuth&&this.#e.TernSecureAuth!==e.TernSecureAuth)&&(this.#e=new s(e)),this.#e}static clearInstances(){this.#e&&(this.#e.ternui=null,this.#e=null)}static clearInstance(){this.#e=null}get authDomain(){if(typeof window<"u"&&window.location)return i(this.#i,new URL(window.location.href),"");if(typeof this.#i=="function")throw new Error("Unsupported customDomain type: function");return this.#i||""}get proxyUrl(){if(typeof window<"u"&&window.location)return i(this.#n,new URL(window.location.href),"");if(typeof this.#n=="function")throw new Error("Unsupported customProxyUrl type: function");return this.#n||""}get mode(){return this._mode}_internal_getOption(e){return this.ternui?._internal_getOption?this.ternui?._internal_getOption(e):this.options[e]}_internal_getAllOptions(){return Object.freeze({...this.options})}constructor(e){const{TernSecureAuth:t=null,TernSecure:r=null}=e||{};this.#i=e.ternSecureConfig?.authDomain,this.options={...e},this._mode=n()?"browser":"server",this.#r=this.options.apiUrl,this.#n=this.options.proxyUrl,this.TernSecureAuth=t,this.TernSecure=r,this.options.sdkMetadata||(this.options.sdkMetadata=d),this.#r&&this.loadTernUI()}get sdkMetadata(){return this.ternui?.sdkMetadata||this.options.sdkMetadata}get version(){return this.ternui?.version}get instanceType(){return this.ternui?.instanceType}get apiUrl(){return this.#r||""}#o(){return new Promise(e=>{e(this.ternui)})}async loadTernUI(){if(!(this._mode!=="browser"||this.isReady)){typeof window<"u"&&(window._TernSecure_authDomain=this.authDomain,window._TernSecure_proxyUrl=this.proxyUrl,window._TernSecure_apiUrl=this.apiUrl);try{if(this.TernSecure){let e;h(this.TernSecure)?(e=new this.TernSecure(this.#r,{proxyUrl:this.proxyUrl,authDomain:this.authDomain}),this.beforeLoad(e),await e.load(this.options)):(e=this.TernSecure,e.isReady||(this.beforeLoad(e),await e.load(this.options))),global.TernSecure=e}else{if(global.TernSecure||await o({...this.options,authDomain:this.authDomain,nonce:this.options.nonce}),!global.TernSecure)throw new Error("TernSecure instance is not available globally");this.beforeLoad(global.TernSecure),await global.TernSecure.load(this.options)}return global.TernSecure?.isReady?this.injectTernUI(global.TernSecure):void 0}catch(e){const t=e;console.error(t.stack||t.message||t);return}}}beforeLoad=e=>{if(!e)throw new Error("Failed to inject TernUI")};injectTernUI=e=>{if(!e)throw new Error("TernUI instance is not initialized");return this.ternui=e,this.premountState.methodCalls.forEach(t=>t()),this.preAddListener.forEach((t,r)=>{t.unsubscribe=e.addListener(r)}),this.#t.getListeners("status").forEach(t=>{this.on("status",t,{notify:!0})}),this.premountState.signInNodes.forEach((t,r)=>{e.showSignIn(r,t)}),this.premountState.signUpNodes.forEach((t,r)=>{e.showSignUp(r,t)}),typeof this.ternui.status>"u"&&(console.log("[IsomorphicTernSecure] TernUI has no status, setting internal status to ready"),this.#s="ready",this.#t.emit("status","ready"),console.log("[IsomorphicTernSecure] Set internal status to ready (ternui has no status)")),this.ternui};initTernSecureAuth(){if(this._mode!=="browser"||this.isReady)return;const e=TernSecureAuthImpl.initialize(this.options);this.loadTernSecureAuth(e)}loadTernSecureAuth=e=>{if(!e)throw new Error("TernAuth instance is not initialized");return this.ternauth=e,this.preAddListener.forEach((t,r)=>{t.unsubscribe=e.addListener(r)}),this.#t.getListeners("status").forEach(t=>{this.on("status",t,{notify:!0})}),typeof this.ternauth.status>"u"&&(console.log("[IsoTernSecureAuth] TernSecureAuth has no status, setting internal status to ready"),this.#s="ready",this.#t.emit(a.Status,"ready")),this.ternauth};on=(...e)=>this.ternui?.on?this.ternui.on(...e):this.#t.on(...e);off=(...e)=>this.ternui?.off?this.ternui.off(...e):this.#t.off(...e);addListener=e=>{if(this.ternui)return this.ternui.addListener(e);{const t=()=>{const r=this.preAddListener.get(e);r&&(r.unsubscribe(),this.preAddListener.delete(e))};return this.preAddListener.set(e,{unsubscribe:t}),t}};createActiveSession=e=>this.ternui?this.ternui.createActiveSession(e):Promise.reject(new Error("TernSecureAuth not initialized"));signOut=async e=>{if(!this.ternui)throw new Error("TernSecureAuth not initialized");await this.ternui.signOut()};get currentSession(){return this.ternui?this.ternui.currentSession:null}onAuthStateChanged(e){return this.ternui?this.ternui.onAuthStateChanged(e):(console.warn("[IsoTernSecureAuth] TernAuth not initialized, cannot set up auth state listener"),()=>{})}getRedirectResult=async()=>{if(!this.ternui?.getRedirectResult)throw new Error("TernSecure instance not initialized");return this.ternui.getRedirectResult()};constructUrlWithAuthRedirect=e=>this.ternui&&this.isReady?this.ternui.constructUrlWithAuthRedirect(e):"";constructAfterSignOutUrl=()=>{if(this.ternui&&this.isReady)return this.ternui.constructAfterSignOutUrl()||"";{const e=()=>this.ternui?.constructAfterSignOutUrl()||"";return this.premountState.methodCalls.set("constructAfterSignOutUrl",e),""}};navigate=e=>{this.ternui&&this.isReady&&this.ternui.navigate(e)};initialize=async()=>{try{await this.#o()}catch(e){throw console.error("[IsomorphicTernSecure] Failed to initialize TernUI:",e),e}};showSignIn=(e,t)=>{this.ternui&&this.isReady?this.ternui.showSignIn(e,t):this.premountState.signInNodes.set(e,t)};hideSignIn=e=>{this.ternui&&this.isReady?this.ternui.hideSignIn(e):this.premountState.signInNodes.delete(e)};showSignUp=(e,t)=>{this.ternui&&this.isReady?this.ternui.showSignUp(e,t):this.premountState.signUpNodes.set(e,t)};hideSignUp=e=>{this.ternui&&this.isReady?this.ternui.hideSignUp(e):this.premountState.signUpNodes.delete(e)};showUserButton=e=>{this.ternui&&this.isReady?this.ternui.showUserButton(e):this.premountState.userButttonNodes.set(e,void 0)};hideUserButton=e=>{this.ternui&&this.isReady?this.ternui.hideUserButton(e):this.premountState.userButttonNodes.delete(e)};redirectToSignIn=async e=>{this.ternui?.redirectToSignIn&&this.ternui.redirectToSignIn(e)};redirectToSignUp=async e=>{this.ternui?.redirectToSignUp&&this.ternui.redirectToSignUp()};redirectAfterSignIn=e=>{this.ternui?.redirectAfterSignIn&&this.ternui.redirectAfterSignIn()};redirectAfterSignUp=e=>{this.ternui?.redirectAfterSignUp&&this.ternui.redirectAfterSignUp()};#u(){return new Promise(e=>{e(this.ternauth)})}initializeAuth=async()=>{this.initTernSecureAuth();try{await this.#u()}catch(e){throw console.error("[IsomorphicTernSecure] Failed to initialize TernSecureAuth:",e),e}}}export{s as IsoTernSecureAuth,n as inBrowser};
1
+ import{loadTernUIScript as o}from"@tern-secure/shared/loadTernUIScript";import{createTernAuthEventBus as u,ternEvents as a}from"@tern-secure/shared/ternStatusEvent";import{handleValueOrFn as i}from"@tern-secure/shared/utils";import{isConstructor as h}from"../utils/isConstructor";const d={name:"@tern-secure/react",version:"1.2.0-canary.v20251127221555",environment:process.env.NODE_ENV};function n(){return typeof window<"u"}class s{_mode;options;TernSecureAuth;TernSecure;ternauth=null;ternui=null;preAddListener=new Map;premountState={signInNodes:new Map,signUpNodes:new Map,userButttonNodes:new Map,verifyNodes:new Set,methodCalls:new Map,errorListeners:new Set};#s="loading";#r;#i;#n;#t=u();static#e;get status(){return this.ternui?this.ternui.status||(this.ternui.isReady?"ready":"loading"):this.#s}get isReady(){return this.ternui?.isReady||!1}get isLoading(){return this.ternui?.isLoading||!1}get requiresVerification(){return this.options.requiresVerification??!0}get signIn(){if(this.ternui)return this.ternui.signIn||void 0}get signUp(){if(this.ternui)return this.ternui.signUp||void 0}get user(){return this.ternui?this.ternui.user:null}static getOrCreateInstance(e){return(!n()||!this.#e||e.TernSecureAuth&&this.#e.TernSecureAuth!==e.TernSecureAuth)&&(this.#e=new s(e)),this.#e}static clearInstances(){this.#e&&(this.#e.ternui=null,this.#e=null)}static clearInstance(){this.#e=null}get authDomain(){if(typeof window<"u"&&window.location)return i(this.#i,new URL(window.location.href),"");if(typeof this.#i=="function")throw new Error("Unsupported customDomain type: function");return this.#i||""}get proxyUrl(){if(typeof window<"u"&&window.location)return i(this.#n,new URL(window.location.href),"");if(typeof this.#n=="function")throw new Error("Unsupported customProxyUrl type: function");return this.#n||""}get mode(){return this._mode}_internal_getOption(e){return this.ternui?._internal_getOption?this.ternui?._internal_getOption(e):this.options[e]}_internal_getAllOptions(){return Object.freeze({...this.options})}constructor(e){const{TernSecureAuth:t=null,TernSecure:r=null}=e||{};this.#i=e.ternSecureConfig?.authDomain,this.options={...e},this._mode=n()?"browser":"server",this.#r=this.options.apiUrl,this.#n=this.options.proxyUrl,this.TernSecureAuth=t,this.TernSecure=r,this.options.sdkMetadata||(this.options.sdkMetadata=d),this.#r&&this.loadTernUI()}get sdkMetadata(){return this.ternui?.sdkMetadata||this.options.sdkMetadata}get version(){return this.ternui?.version}get instanceType(){return this.ternui?.instanceType}get apiUrl(){return this.#r||""}#o(){return new Promise(e=>{e(this.ternui)})}async loadTernUI(){if(!(this._mode!=="browser"||this.isReady)){typeof window<"u"&&(window._TernSecure_authDomain=this.authDomain,window._TernSecure_proxyUrl=this.proxyUrl,window._TernSecure_apiUrl=this.apiUrl);try{if(this.TernSecure){let e;h(this.TernSecure)?(e=new this.TernSecure(this.#r,{proxyUrl:this.proxyUrl,authDomain:this.authDomain}),this.beforeLoad(e),await e.load(this.options)):(e=this.TernSecure,e.isReady||(this.beforeLoad(e),await e.load(this.options))),global.TernSecure=e}else{if(global.TernSecure||await o({...this.options,authDomain:this.authDomain,nonce:this.options.nonce}),!global.TernSecure)throw new Error("TernSecure instance is not available globally");this.beforeLoad(global.TernSecure),await global.TernSecure.load(this.options)}return global.TernSecure?.isReady?this.injectTernUI(global.TernSecure):void 0}catch(e){const t=e;console.error(t.stack||t.message||t);return}}}beforeLoad=e=>{if(!e)throw new Error("Failed to inject TernUI")};injectTernUI=e=>{if(!e)throw new Error("TernUI instance is not initialized");return this.ternui=e,this.premountState.methodCalls.forEach(t=>t()),this.preAddListener.forEach((t,r)=>{t.unsubscribe=e.addListener(r)}),this.#t.getListeners("status").forEach(t=>{this.on("status",t,{notify:!0})}),this.premountState.signInNodes.forEach((t,r)=>{e.showSignIn(r,t)}),this.premountState.signUpNodes.forEach((t,r)=>{e.showSignUp(r,t)}),typeof this.ternui.status>"u"&&(console.log("[IsomorphicTernSecure] TernUI has no status, setting internal status to ready"),this.#s="ready",this.#t.emit("status","ready"),console.log("[IsomorphicTernSecure] Set internal status to ready (ternui has no status)")),this.ternui};initTernSecureAuth(){if(this._mode!=="browser"||this.isReady)return;const e=TernSecureAuthImpl.initialize(this.options);this.loadTernSecureAuth(e)}loadTernSecureAuth=e=>{if(!e)throw new Error("TernAuth instance is not initialized");return this.ternauth=e,this.preAddListener.forEach((t,r)=>{t.unsubscribe=e.addListener(r)}),this.#t.getListeners("status").forEach(t=>{this.on("status",t,{notify:!0})}),typeof this.ternauth.status>"u"&&(console.log("[IsoTernSecureAuth] TernSecureAuth has no status, setting internal status to ready"),this.#s="ready",this.#t.emit(a.Status,"ready")),this.ternauth};on=(...e)=>this.ternui?.on?this.ternui.on(...e):this.#t.on(...e);off=(...e)=>this.ternui?.off?this.ternui.off(...e):this.#t.off(...e);addListener=e=>{if(this.ternui)return this.ternui.addListener(e);{const t=()=>{const r=this.preAddListener.get(e);r&&(r.unsubscribe(),this.preAddListener.delete(e))};return this.preAddListener.set(e,{unsubscribe:t}),t}};createActiveSession=e=>this.ternui?this.ternui.createActiveSession(e):Promise.reject(new Error("TernSecureAuth not initialized"));signOut=async e=>{if(!this.ternui)throw new Error("TernSecureAuth not initialized");await this.ternui.signOut()};get currentSession(){return this.ternui?this.ternui.currentSession:null}onAuthStateChanged(e){return this.ternui?this.ternui.onAuthStateChanged(e):(console.warn("[IsoTernSecureAuth] TernAuth not initialized, cannot set up auth state listener"),()=>{})}getRedirectResult=async()=>{if(!this.ternui?.getRedirectResult)throw new Error("TernSecure instance not initialized");return this.ternui.getRedirectResult()};constructUrlWithAuthRedirect=e=>this.ternui&&this.isReady?this.ternui.constructUrlWithAuthRedirect(e):"";constructAfterSignOutUrl=()=>{if(this.ternui&&this.isReady)return this.ternui.constructAfterSignOutUrl()||"";{const e=()=>this.ternui?.constructAfterSignOutUrl()||"";return this.premountState.methodCalls.set("constructAfterSignOutUrl",e),""}};navigate=e=>{this.ternui&&this.isReady&&this.ternui.navigate(e)};initialize=async()=>{try{await this.#o()}catch(e){throw console.error("[IsomorphicTernSecure] Failed to initialize TernUI:",e),e}};showSignIn=(e,t)=>{this.ternui&&this.isReady?this.ternui.showSignIn(e,t):this.premountState.signInNodes.set(e,t)};hideSignIn=e=>{this.ternui&&this.isReady?this.ternui.hideSignIn(e):this.premountState.signInNodes.delete(e)};showSignUp=(e,t)=>{this.ternui&&this.isReady?this.ternui.showSignUp(e,t):this.premountState.signUpNodes.set(e,t)};hideSignUp=e=>{this.ternui&&this.isReady?this.ternui.hideSignUp(e):this.premountState.signUpNodes.delete(e)};showUserButton=e=>{this.ternui&&this.isReady?this.ternui.showUserButton(e):this.premountState.userButttonNodes.set(e,void 0)};hideUserButton=e=>{this.ternui&&this.isReady?this.ternui.hideUserButton(e):this.premountState.userButttonNodes.delete(e)};redirectToSignIn=async e=>{this.ternui?.redirectToSignIn&&this.ternui.redirectToSignIn(e)};redirectToSignUp=async e=>{this.ternui?.redirectToSignUp&&this.ternui.redirectToSignUp()};redirectAfterSignIn=e=>{this.ternui?.redirectAfterSignIn&&this.ternui.redirectAfterSignIn()};redirectAfterSignUp=e=>{this.ternui?.redirectAfterSignUp&&this.ternui.redirectAfterSignUp()};#u(){return new Promise(e=>{e(this.ternauth)})}initializeAuth=async()=>{this.initTernSecureAuth();try{await this.#u()}catch(e){throw console.error("[IsomorphicTernSecure] Failed to initialize TernSecureAuth:",e),e}}}export{s as IsoTernSecureAuth,n as inBrowser};
2
2
  //# sourceMappingURL=isoTernSecureAuth.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tern-secure/react",
3
- "version": "1.2.0-canary.v20251125170702",
3
+ "version": "1.2.0-canary.v20251127221555",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/TernSecure/auth.git",
@@ -36,8 +36,8 @@
36
36
  "tailwind-merge": "^2.5.5",
37
37
  "tailwindcss-animate": "^1.0.7",
38
38
  "tslib": "2.8.1",
39
- "@tern-secure/shared": "1.3.0-canary.v20251125170702",
40
- "@tern-secure/types": "1.1.0-canary.v20251125170702"
39
+ "@tern-secure/shared": "1.3.0-canary.v20251127221555",
40
+ "@tern-secure/types": "1.1.0-canary.v20251127221555"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@tailwindcss/cli": "^4.1.6",
@@ -49,6 +49,7 @@
49
49
  "tailwindcss": "^4.1.6"
50
50
  },
51
51
  "peerDependencies": {
52
+ "firebase": "^12.0.0",
52
53
  "react": "^19.0.0 || ^19.0.0-0",
53
54
  "react-dom": "^19.0.0 || ^19.0.0-0"
54
55
  },