@tern-secure/react 1.2.0-canary.v20251008131428 → 1.2.0-canary.v20251019190011

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 (54) hide show
  1. package/dist/ctx/AuthProvider.d.mts +3 -4
  2. package/dist/ctx/AuthProvider.d.ts +3 -4
  3. package/dist/ctx/AuthProvider.js +1 -1
  4. package/dist/ctx/AuthProvider.js.map +1 -1
  5. package/dist/ctx/AuthProvider.mjs +1 -1
  6. package/dist/ctx/AuthProvider.mjs.map +1 -1
  7. package/dist/ctx/SignInCtx.d.mts +23 -0
  8. package/dist/ctx/SignInCtx.d.ts +23 -0
  9. package/dist/ctx/SignInCtx.js +2 -0
  10. package/dist/ctx/SignInCtx.js.map +1 -0
  11. package/dist/ctx/SignInCtx.mjs +2 -0
  12. package/dist/ctx/SignInCtx.mjs.map +1 -0
  13. package/dist/ctx/TernSecureCtxProvider.d.mts +2 -2
  14. package/dist/ctx/TernSecureCtxProvider.d.ts +2 -2
  15. package/dist/ctx/TernSecureCtxProvider.js +1 -1
  16. package/dist/ctx/TernSecureCtxProvider.js.map +1 -1
  17. package/dist/ctx/TernSecureCtxProvider.mjs +1 -1
  18. package/dist/ctx/TernSecureCtxProvider.mjs.map +1 -1
  19. package/dist/hooks/useAuth.d.mts +2 -1
  20. package/dist/hooks/useAuth.d.ts +2 -1
  21. package/dist/hooks/useAuth.js +1 -1
  22. package/dist/hooks/useAuth.js.map +1 -1
  23. package/dist/hooks/useAuth.mjs +1 -1
  24. package/dist/hooks/useAuth.mjs.map +1 -1
  25. package/dist/hooks/useSession.d.mts +0 -1
  26. package/dist/hooks/useSession.d.ts +0 -1
  27. package/dist/hooks/useSession.js +1 -1
  28. package/dist/hooks/useSession.js.map +1 -1
  29. package/dist/hooks/useSession.mjs +1 -1
  30. package/dist/hooks/useSession.mjs.map +1 -1
  31. package/dist/hooks/useSignIn.d.mts +4 -4
  32. package/dist/hooks/useSignIn.d.ts +4 -4
  33. package/dist/hooks/useSignIn.js +1 -1
  34. package/dist/hooks/useSignIn.js.map +1 -1
  35. package/dist/hooks/useSignIn.mjs +1 -1
  36. package/dist/hooks/useSignIn.mjs.map +1 -1
  37. package/dist/index.d.mts +4 -1
  38. package/dist/index.d.ts +4 -1
  39. package/dist/index.js +1 -1
  40. package/dist/index.js.map +1 -1
  41. package/dist/index.mjs +1 -1
  42. package/dist/index.mjs.map +1 -1
  43. package/dist/lib/isoTernSecureAuth.d.mts +15 -1
  44. package/dist/lib/isoTernSecureAuth.d.ts +15 -1
  45. package/dist/lib/isoTernSecureAuth.js +1 -1
  46. package/dist/lib/isoTernSecureAuth.js.map +1 -1
  47. package/dist/lib/isoTernSecureAuth.mjs +1 -1
  48. package/dist/lib/isoTernSecureAuth.mjs.map +1 -1
  49. package/dist/types.d.mts +6 -6
  50. package/dist/types.d.ts +6 -6
  51. package/dist/types.js +1 -1
  52. package/dist/types.js.map +1 -1
  53. package/dist/types.mjs.map +1 -1
  54. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/useSignIn.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n ResendEmailVerification,\n SignInFormValuesTree,\n SignInResponseTree,\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 withEmailAndPassword: async (\n params: SignInFormValuesTree\n ): Promise<SignInResponseTree> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error(\"SignIn methods not available - auth not initialized\");\n }\n return auth.withEmailAndPassword(params);\n },\n\n withSocialProvider: async (\n provider: string,\n options?: { mode?: \"popup\" | \"redirect\" }\n ): Promise<SignInResponseTree | void> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error(\"SignIn methods not available - auth not initialized\");\n }\n return auth.withSocialProvider(provider, options);\n },\n\n resendEmailVerification: async (): Promise<ResendEmailVerification> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error(\"SignIn methods not available - auth not initialized\");\n }\n return auth.resendEmailVerification();\n },\n\n checkRedirectResult: async (): Promise<SignInResponseTree | 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,GASA,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,qBAAsB,MACpBM,GACgC,CAChC,MAAMD,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,qBAAqBC,CAAM,CACzC,EAEA,mBAAoB,MAClBC,EACAC,IACuC,CACvC,MAAMH,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,mBAAmBE,EAAUC,CAAO,CAClD,EAEA,wBAAyB,SAA8C,CACrE,MAAMH,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,wBAAwB,CACtC,EAEA,oBAAqB,SAAgD,CACnE,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","options"]}
1
+ {"version":3,"sources":["../../src/hooks/useSignIn.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n ResendEmailVerification,\n SignInFormValues,\n SignInResponse,\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 withEmailAndPassword: async (\n params: SignInFormValues\n ): Promise<SignInResponse> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error(\"SignIn methods not available - auth not initialized\");\n }\n return auth.withEmailAndPassword(params);\n },\n\n withSocialProvider: async (\n provider: string,\n options?: { mode?: \"popup\" | \"redirect\" }\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.withSocialProvider(provider, options);\n },\n\n resendEmailVerification: async (): Promise<ResendEmailVerification> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error(\"SignIn methods not available - auth not initialized\");\n }\n return auth.resendEmailVerification();\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,GASA,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,qBAAsB,MACpBM,GAC4B,CAC5B,MAAMD,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,qBAAqBC,CAAM,CACzC,EAEA,mBAAoB,MAClBC,EACAC,IACmC,CACnC,MAAMH,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,mBAAmBE,EAAUC,CAAO,CAClD,EAEA,wBAAyB,SAA8C,CACrE,MAAMH,KAAO,oBAAiB,EAC9B,GAAI,CAACA,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,wBAAwB,CACtC,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","options"]}
@@ -1,2 +1,2 @@
1
- "use client";import{useAuthSignInCtx as n}from"../ctx/TernSecureAuthResourcesCtx";import{useAssertWrappedByTernSecureAuthProvider as t}from"./useAssertWrappedTernSecureProvider";const a=()=>{t("useSignIn");const e=n();return e?{isLoaded:!0,signIn:e}:{isLoaded:!1,signIn:void 0}},u={withEmailAndPassword:async e=>{const i=n();if(!i)throw new Error("SignIn methods not available - auth not initialized");return i.withEmailAndPassword(e)},withSocialProvider:async(e,i)=>{const r=n();if(!r)throw new Error("SignIn methods not available - auth not initialized");return r.withSocialProvider(e,i)},resendEmailVerification:async()=>{const e=n();if(!e)throw new Error("SignIn methods not available - auth not initialized");return e.resendEmailVerification()},checkRedirectResult:async()=>{const e=n();if(!e)throw new Error("SignIn methods not available - auth not initialized");return e.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={withEmailAndPassword:async n=>{const i=e();if(!i)throw new Error("SignIn methods not available - auth not initialized");return i.withEmailAndPassword(n)},withSocialProvider:async(n,i)=>{const t=e();if(!t)throw new Error("SignIn methods not available - auth not initialized");return t.withSocialProvider(n,i)},resendEmailVerification:async()=>{const n=e();if(!n)throw new Error("SignIn methods not available - auth not initialized");return n.resendEmailVerification()},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 ResendEmailVerification,\n SignInFormValuesTree,\n SignInResponseTree,\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 withEmailAndPassword: async (\n params: SignInFormValuesTree\n ): Promise<SignInResponseTree> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error(\"SignIn methods not available - auth not initialized\");\n }\n return auth.withEmailAndPassword(params);\n },\n\n withSocialProvider: async (\n provider: string,\n options?: { mode?: \"popup\" | \"redirect\" }\n ): Promise<SignInResponseTree | void> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error(\"SignIn methods not available - auth not initialized\");\n }\n return auth.withSocialProvider(provider, options);\n },\n\n resendEmailVerification: async (): Promise<ResendEmailVerification> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error(\"SignIn methods not available - auth not initialized\");\n }\n return auth.resendEmailVerification();\n },\n\n checkRedirectResult: async (): Promise<SignInResponseTree | 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":"aASA,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,qBAAsB,MACpBC,GACgC,CAChC,MAAMF,EAAOH,EAAiB,EAC9B,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,qBAAqBE,CAAM,CACzC,EAEA,mBAAoB,MAClBC,EACAC,IACuC,CACvC,MAAMJ,EAAOH,EAAiB,EAC9B,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,mBAAmBG,EAAUC,CAAO,CAClD,EAEA,wBAAyB,SAA8C,CACrE,MAAMJ,EAAOH,EAAiB,EAC9B,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,wBAAwB,CACtC,EAEA,oBAAqB,SAAgD,CACnE,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","options"]}
1
+ {"version":3,"sources":["../../src/hooks/useSignIn.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n ResendEmailVerification,\n SignInFormValues,\n SignInResponse,\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 withEmailAndPassword: async (\n params: SignInFormValues\n ): Promise<SignInResponse> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error(\"SignIn methods not available - auth not initialized\");\n }\n return auth.withEmailAndPassword(params);\n },\n\n withSocialProvider: async (\n provider: string,\n options?: { mode?: \"popup\" | \"redirect\" }\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.withSocialProvider(provider, options);\n },\n\n resendEmailVerification: async (): Promise<ResendEmailVerification> => {\n const auth = useAuthSignInCtx();\n if (!auth) {\n throw new Error(\"SignIn methods not available - auth not initialized\");\n }\n return auth.resendEmailVerification();\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":"aASA,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,qBAAsB,MACpBC,GAC4B,CAC5B,MAAMF,EAAOH,EAAiB,EAC9B,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,qBAAqBE,CAAM,CACzC,EAEA,mBAAoB,MAClBC,EACAC,IACmC,CACnC,MAAMJ,EAAOH,EAAiB,EAC9B,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,mBAAmBG,EAAUC,CAAO,CAClD,EAEA,wBAAyB,SAA8C,CACrE,MAAMJ,EAAOH,EAAiB,EAC9B,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,qDAAqD,EAEvE,OAAOA,EAAK,wBAAwB,CACtC,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","options"]}
package/dist/index.d.mts CHANGED
@@ -1,13 +1,16 @@
1
- export { useAuth } from './hooks/useAuth.mjs';
1
+ export { useAuth, useDeriveAuth } from './hooks/useAuth.mjs';
2
2
  export { useIdToken } from './hooks/useIdToken.mjs';
3
3
  export { useSession } from './hooks/useSession.mjs';
4
4
  export { signIn, useSignIn } from './hooks/useSignIn.mjs';
5
5
  export { TernSecureCtxProvider } from './ctx/TernSecureCtxProvider.mjs';
6
6
  export { TernSecureProvider } from './ctx/TernSecureProvider.mjs';
7
+ export { SignInProvider, useSignInContext } from './ctx/SignInCtx.mjs';
7
8
  export { handleInternalRoute, isAuthRoute, isBaseAuthRoute, isInternalRoute } from './route-handler/internal-route.mjs';
8
9
  export { cn } from './lib/utils.mjs';
9
10
  export { Browser, IsoTernSecureAuthOptions, IsomorphicTernSecureOptions, TernSecureProviderProps } from './types.mjs';
11
+ export { useTernSecure } from '@tern-secure/shared/react';
10
12
  import '@tern-secure/types';
11
13
  import 'react/jsx-runtime';
12
14
  import 'react';
15
+ import '@tern-secure/auth';
13
16
  import 'clsx';
package/dist/index.d.ts CHANGED
@@ -1,13 +1,16 @@
1
- export { useAuth } from './hooks/useAuth.js';
1
+ export { useAuth, useDeriveAuth } from './hooks/useAuth.js';
2
2
  export { useIdToken } from './hooks/useIdToken.js';
3
3
  export { useSession } from './hooks/useSession.js';
4
4
  export { signIn, useSignIn } from './hooks/useSignIn.js';
5
5
  export { TernSecureCtxProvider } from './ctx/TernSecureCtxProvider.js';
6
6
  export { TernSecureProvider } from './ctx/TernSecureProvider.js';
7
+ export { SignInProvider, useSignInContext } from './ctx/SignInCtx.js';
7
8
  export { handleInternalRoute, isAuthRoute, isBaseAuthRoute, isInternalRoute } from './route-handler/internal-route.js';
8
9
  export { cn } from './lib/utils.js';
9
10
  export { Browser, IsoTernSecureAuthOptions, IsomorphicTernSecureOptions, TernSecureProviderProps } from './types.js';
11
+ export { useTernSecure } from '@tern-secure/shared/react';
10
12
  import '@tern-secure/types';
11
13
  import 'react/jsx-runtime';
12
14
  import 'react';
15
+ import '@tern-secure/auth';
13
16
  import 'clsx';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var u=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var d=(o,e)=>{for(var n in e)u(o,n,{get:e[n],enumerable:!0})},a=(o,e,n,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of h(e))!T.call(o,t)&&t!==n&&u(o,t,{get:()=>e[t],enumerable:!(p=S(e,t))||p.enumerable});return o};var A=o=>a(u({},"__esModule",{value:!0}),o);var P={};d(P,{TernSecureCtxProvider:()=>f.TernSecureCtxProvider,TernSecureProvider:()=>c.TernSecureProvider,cn:()=>I.cn,handleInternalRoute:()=>r.handleInternalRoute,isAuthRoute:()=>r.isAuthRoute,isBaseAuthRoute:()=>r.isBaseAuthRoute,isInternalRoute:()=>r.isInternalRoute,signIn:()=>s.signIn,useAuth:()=>i.useAuth,useIdToken:()=>m.useIdToken,useSession:()=>x.useSession,useSignIn:()=>s.useSignIn});module.exports=A(P);var i=require("./hooks/useAuth"),m=require("./hooks/useIdToken"),x=require("./hooks/useSession"),s=require("./hooks/useSignIn"),f=require("./ctx/TernSecureCtxProvider"),c=require("./ctx/TernSecureProvider"),r=require("./route-handler/internal-route"),I=require("./lib/utils");0&&(module.exports={TernSecureCtxProvider,TernSecureProvider,cn,handleInternalRoute,isAuthRoute,isBaseAuthRoute,isInternalRoute,signIn,useAuth,useIdToken,useSession,useSignIn});
1
+ "use strict";var p=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var v=(o,e)=>{for(var u in e)p(o,u,{get:e[u],enumerable:!0})},A=(o,e,u,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of T(e))!d.call(o,n)&&n!==u&&p(o,n,{get:()=>e[n],enumerable:!(x=h(e,n))||x.enumerable});return o};var P=o=>A(p({},"__esModule",{value:!0}),o);var a={};v(a,{SignInProvider:()=>t.SignInProvider,TernSecureCtxProvider:()=>S.TernSecureCtxProvider,TernSecureProvider:()=>I.TernSecureProvider,cn:()=>c.cn,handleInternalRoute:()=>r.handleInternalRoute,isAuthRoute:()=>r.isAuthRoute,isBaseAuthRoute:()=>r.isBaseAuthRoute,isInternalRoute:()=>r.isInternalRoute,signIn:()=>i.signIn,useAuth:()=>s.useAuth,useDeriveAuth:()=>s.useDeriveAuth,useIdToken:()=>m.useIdToken,useSession:()=>f.useSession,useSignIn:()=>i.useSignIn,useSignInContext:()=>t.useSignInContext,useTernSecure:()=>t.useTernSecure});module.exports=P(a);var s=require("./hooks/useAuth"),m=require("./hooks/useIdToken"),f=require("./hooks/useSession"),i=require("./hooks/useSignIn"),S=require("./ctx/TernSecureCtxProvider"),I=require("./ctx/TernSecureProvider"),t=require("./ctx/SignInCtx"),r=require("./route-handler/internal-route"),c=require("./lib/utils");0&&(module.exports={SignInProvider,TernSecureCtxProvider,TernSecureProvider,cn,handleInternalRoute,isAuthRoute,isBaseAuthRoute,isInternalRoute,signIn,useAuth,useDeriveAuth,useIdToken,useSession,useSignIn,useSignInContext,useTernSecure});
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { useAuth } from \"./hooks/useAuth\"\nexport { useIdToken } from \"./hooks/useIdToken\"\nexport { useSession } from \"./hooks/useSession\"\nexport { useSignIn, signIn } from \"./hooks/useSignIn\"\nexport {\n TernSecureCtxProvider\n} from './ctx/TernSecureCtxProvider'\nexport {\n TernSecureProvider\n} from './ctx/TernSecureProvider'\n\nexport {\n isAuthRoute,\n isBaseAuthRoute,\n isInternalRoute,\n handleInternalRoute\n} from './route-handler/internal-route'\n\nexport {\n cn\n} from './lib/utils'\n\nexport type {\n IsomorphicTernSecureOptions,\n IsoTernSecureAuthOptions,\n Browser,\n TernSecureProviderProps,\n} from './types'\n\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gZAAAE,EAAAF,GAAA,IAAAG,EAAwB,2BACxBC,EAA2B,8BAC3BC,EAA2B,8BAC3BC,EAAkC,6BAClCC,EAEO,uCACPC,EAEO,oCAEPC,EAKO,0CAEPC,EAEO","names":["index_exports","__export","__toCommonJS","import_useAuth","import_useIdToken","import_useSession","import_useSignIn","import_TernSecureCtxProvider","import_TernSecureProvider","import_internal_route","import_utils"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { useAuth, useDeriveAuth} from './hooks/useAuth';\nexport { useIdToken } from './hooks/useIdToken';\nexport { useSession } from './hooks/useSession';\nexport { useSignIn, signIn } from './hooks/useSignIn';\nexport { TernSecureCtxProvider } from './ctx/TernSecureCtxProvider';\nexport { TernSecureProvider } from './ctx/TernSecureProvider';\nexport { useSignInContext, SignInProvider, useTernSecure } from './ctx/SignInCtx';\n\nexport {\n isAuthRoute,\n isBaseAuthRoute,\n isInternalRoute,\n handleInternalRoute,\n} from './route-handler/internal-route';\n\nexport { cn } from './lib/utils';\n\nexport type {\n IsomorphicTernSecureOptions,\n IsoTernSecureAuthOptions,\n Browser,\n TernSecureProviderProps,\n} from './types';\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,giBAAAE,EAAAF,GAAA,IAAAG,EAAsC,2BACtCC,EAA2B,8BAC3BC,EAA2B,8BAC3BC,EAAkC,6BAClCC,EAAsC,uCACtCC,EAAmC,oCACnCC,EAAgE,2BAEhEC,EAKO,0CAEPC,EAAmB","names":["index_exports","__export","__toCommonJS","import_useAuth","import_useIdToken","import_useSession","import_useSignIn","import_TernSecureCtxProvider","import_TernSecureProvider","import_SignInCtx","import_internal_route","import_utils"]}
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{useAuth as o}from"./hooks/useAuth";import{useIdToken as n}from"./hooks/useIdToken";import{useSession as u}from"./hooks/useSession";import{useSignIn as i,signIn as m}from"./hooks/useSignIn";import{TernSecureCtxProvider as f}from"./ctx/TernSecureCtxProvider";import{TernSecureProvider as I}from"./ctx/TernSecureProvider";import{isAuthRoute as h,isBaseAuthRoute as T,isInternalRoute as d,handleInternalRoute as a}from"./route-handler/internal-route";import{cn as P}from"./lib/utils";export{f as TernSecureCtxProvider,I as TernSecureProvider,P as cn,a as handleInternalRoute,h as isAuthRoute,T as isBaseAuthRoute,d as isInternalRoute,m as signIn,o as useAuth,n as useIdToken,u as useSession,i as useSignIn};
1
+ import{useAuth as o,useDeriveAuth as t}from"./hooks/useAuth";import{useIdToken as u}from"./hooks/useIdToken";import{useSession as i}from"./hooks/useSession";import{useSignIn as x,signIn as m}from"./hooks/useSignIn";import{TernSecureCtxProvider as S}from"./ctx/TernSecureCtxProvider";import{TernSecureProvider as c}from"./ctx/TernSecureProvider";import{useSignInContext as T,SignInProvider as d,useTernSecure as v}from"./ctx/SignInCtx";import{isAuthRoute as P,isBaseAuthRoute as a,isInternalRoute as g,handleInternalRoute as R}from"./route-handler/internal-route";import{cn as y}from"./lib/utils";export{d as SignInProvider,S as TernSecureCtxProvider,c as TernSecureProvider,y as cn,R as handleInternalRoute,P as isAuthRoute,a as isBaseAuthRoute,g as isInternalRoute,m as signIn,o as useAuth,t as useDeriveAuth,u as useIdToken,i as useSession,x as useSignIn,T as useSignInContext,v as useTernSecure};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { useAuth } from \"./hooks/useAuth\"\nexport { useIdToken } from \"./hooks/useIdToken\"\nexport { useSession } from \"./hooks/useSession\"\nexport { useSignIn, signIn } from \"./hooks/useSignIn\"\nexport {\n TernSecureCtxProvider\n} from './ctx/TernSecureCtxProvider'\nexport {\n TernSecureProvider\n} from './ctx/TernSecureProvider'\n\nexport {\n isAuthRoute,\n isBaseAuthRoute,\n isInternalRoute,\n handleInternalRoute\n} from './route-handler/internal-route'\n\nexport {\n cn\n} from './lib/utils'\n\nexport type {\n IsomorphicTernSecureOptions,\n IsoTernSecureAuthOptions,\n Browser,\n TernSecureProviderProps,\n} from './types'\n\n"],"mappings":"AAAA,OAAS,WAAAA,MAAe,kBACxB,OAAS,cAAAC,MAAkB,qBAC3B,OAAS,cAAAC,MAAkB,qBAC3B,OAAS,aAAAC,EAAW,UAAAC,MAAc,oBAClC,OACI,yBAAAC,MACG,8BACP,OACI,sBAAAC,MACG,2BAEP,OACI,eAAAC,EACA,mBAAAC,EACA,mBAAAC,EACA,uBAAAC,MACG,iCAEP,OACI,MAAAC,MACG","names":["useAuth","useIdToken","useSession","useSignIn","signIn","TernSecureCtxProvider","TernSecureProvider","isAuthRoute","isBaseAuthRoute","isInternalRoute","handleInternalRoute","cn"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { useAuth, useDeriveAuth} from './hooks/useAuth';\nexport { useIdToken } from './hooks/useIdToken';\nexport { useSession } from './hooks/useSession';\nexport { useSignIn, signIn } from './hooks/useSignIn';\nexport { TernSecureCtxProvider } from './ctx/TernSecureCtxProvider';\nexport { TernSecureProvider } from './ctx/TernSecureProvider';\nexport { useSignInContext, SignInProvider, useTernSecure } from './ctx/SignInCtx';\n\nexport {\n isAuthRoute,\n isBaseAuthRoute,\n isInternalRoute,\n handleInternalRoute,\n} from './route-handler/internal-route';\n\nexport { cn } from './lib/utils';\n\nexport type {\n IsomorphicTernSecureOptions,\n IsoTernSecureAuthOptions,\n Browser,\n TernSecureProviderProps,\n} from './types';\n"],"mappings":"AAAA,OAAS,WAAAA,EAAS,iBAAAC,MAAoB,kBACtC,OAAS,cAAAC,MAAkB,qBAC3B,OAAS,cAAAC,MAAkB,qBAC3B,OAAS,aAAAC,EAAW,UAAAC,MAAc,oBAClC,OAAS,yBAAAC,MAA6B,8BACtC,OAAS,sBAAAC,MAA0B,2BACnC,OAAS,oBAAAC,EAAkB,kBAAAC,EAAgB,iBAAAC,MAAqB,kBAEhE,OACE,eAAAC,EACA,mBAAAC,EACA,mBAAAC,EACA,uBAAAC,MACK,iCAEP,OAAS,MAAAC,MAAU","names":["useAuth","useDeriveAuth","useIdToken","useSession","useSignIn","signIn","TernSecureCtxProvider","TernSecureProvider","useSignInContext","SignInProvider","useTernSecure","isAuthRoute","isBaseAuthRoute","isInternalRoute","handleInternalRoute","cn"]}
@@ -1,5 +1,5 @@
1
1
  import * as _tern_secure_types from '@tern-secure/types';
2
- import { TernSecureAuth, TernSecureAuthStatus, SignInResource, SignUpResource, ListenerCallback, UnsubscribeCallback, SignOutOptions, SignedInSession } from '@tern-secure/types';
2
+ import { TernSecureAuth, TernSecureAuthStatus, SignInResource, SignUpResource, TernSecureAuthOptions, ListenerCallback, UnsubscribeCallback, CreateActiveSessionParams, SignOutOptions, SignedInSession, SignInRedirectOptions, SignUpRedirectOptions } from '@tern-secure/types';
3
3
  import { IsoTernSecureAuthOptions } from '../types.mjs';
4
4
 
5
5
  declare function inBrowser(): boolean;
@@ -27,6 +27,14 @@ declare class IsoTernSecureAuth implements TernSecureAuth {
27
27
  get domain(): string;
28
28
  get proxyUrl(): string;
29
29
  get mode(): 'browser' | 'server';
30
+ /**
31
+ * @internal
32
+ */
33
+ _internal_getOption<K extends keyof TernSecureAuthOptions>(key: K): TernSecureAuthOptions[K] | undefined;
34
+ /**
35
+ * @internal
36
+ */
37
+ _internal_getAllOptions(): Readonly<TernSecureAuthOptions>;
30
38
  constructor(options: IsoTernSecureAuthOptions);
31
39
  get sdkMetadata(): _tern_secure_types.TernAuthSDK | undefined;
32
40
  get version(): string | undefined;
@@ -37,9 +45,15 @@ declare class IsoTernSecureAuth implements TernSecureAuth {
37
45
  on: TernSecureAuth['on'];
38
46
  off: TernSecureAuth['off'];
39
47
  addListener: (listener: ListenerCallback) => UnsubscribeCallback;
48
+ createActiveSession: (params: CreateActiveSessionParams) => Promise<void>;
40
49
  signOut: (options?: SignOutOptions) => Promise<void>;
41
50
  get currentSession(): SignedInSession | null;
42
51
  onAuthStateChanged(callback: (user: any) => void): () => void;
52
+ getRedirectResult: () => Promise<any>;
53
+ redirectToSignIn: (options?: SignInRedirectOptions) => Promise<void>;
54
+ redirectToSignUp: (options?: SignUpRedirectOptions) => Promise<void>;
55
+ redirectAfterSignIn: (redirectUrl?: string) => void;
56
+ redirectAfterSignUp: (redirectUrl?: string) => void;
43
57
  initialize: () => Promise<void>;
44
58
  }
45
59
 
@@ -1,5 +1,5 @@
1
1
  import * as _tern_secure_types from '@tern-secure/types';
2
- import { TernSecureAuth, TernSecureAuthStatus, SignInResource, SignUpResource, ListenerCallback, UnsubscribeCallback, SignOutOptions, SignedInSession } from '@tern-secure/types';
2
+ import { TernSecureAuth, TernSecureAuthStatus, SignInResource, SignUpResource, TernSecureAuthOptions, ListenerCallback, UnsubscribeCallback, CreateActiveSessionParams, SignOutOptions, SignedInSession, SignInRedirectOptions, SignUpRedirectOptions } from '@tern-secure/types';
3
3
  import { IsoTernSecureAuthOptions } from '../types.js';
4
4
 
5
5
  declare function inBrowser(): boolean;
@@ -27,6 +27,14 @@ declare class IsoTernSecureAuth implements TernSecureAuth {
27
27
  get domain(): string;
28
28
  get proxyUrl(): string;
29
29
  get mode(): 'browser' | 'server';
30
+ /**
31
+ * @internal
32
+ */
33
+ _internal_getOption<K extends keyof TernSecureAuthOptions>(key: K): TernSecureAuthOptions[K] | undefined;
34
+ /**
35
+ * @internal
36
+ */
37
+ _internal_getAllOptions(): Readonly<TernSecureAuthOptions>;
30
38
  constructor(options: IsoTernSecureAuthOptions);
31
39
  get sdkMetadata(): _tern_secure_types.TernAuthSDK | undefined;
32
40
  get version(): string | undefined;
@@ -37,9 +45,15 @@ declare class IsoTernSecureAuth implements TernSecureAuth {
37
45
  on: TernSecureAuth['on'];
38
46
  off: TernSecureAuth['off'];
39
47
  addListener: (listener: ListenerCallback) => UnsubscribeCallback;
48
+ createActiveSession: (params: CreateActiveSessionParams) => Promise<void>;
40
49
  signOut: (options?: SignOutOptions) => Promise<void>;
41
50
  get currentSession(): SignedInSession | null;
42
51
  onAuthStateChanged(callback: (user: any) => void): () => void;
52
+ getRedirectResult: () => Promise<any>;
53
+ redirectToSignIn: (options?: SignInRedirectOptions) => Promise<void>;
54
+ redirectToSignUp: (options?: SignUpRedirectOptions) => Promise<void>;
55
+ redirectAfterSignIn: (redirectUrl?: string) => void;
56
+ redirectAfterSignUp: (redirectUrl?: string) => void;
43
57
  initialize: () => Promise<void>;
44
58
  }
45
59
 
@@ -1,2 +1,2 @@
1
- "use strict";var u=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var f=(r,e)=>{for(var t in e)u(r,t,{get:e[t],enumerable:!0})},S=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of l(e))!p.call(r,i)&&i!==t&&u(r,i,{get:()=>e[i],enumerable:!(n=d(e,i))||n.enumerable});return r};var A=r=>S(u({},"__esModule",{value:!0}),r);var g={};f(g,{IsoTernSecureAuth:()=>h,inBrowser:()=>a});module.exports=A(g);var c=require("@tern-secure/auth"),s=require("@tern-secure/shared/ternStatusEvent"),o=require("@tern-secure/shared/utils");const T={name:"@tern-secure/react",version:"1.2.0-canary.v20251008131428",environment:process.env.NODE_ENV};function a(){return typeof window<"u"}class h{_mode;options;TernSecureAuth;ternauth=null;preAddListener=new Map;#i="loading";#s;#t;#n;#r=(0,s.createTernAuthEventBus)();static#e;get status(){return this.ternauth?this.ternauth.status||(this.ternauth.isReady?"ready":"loading"):this.#i}get isReady(){return this.ternauth?.isReady||!1}get isLoading(){return this.ternauth?.isLoading||!1}get requiresVerification(){return this.options.requiresVerification??!0}get signIn(){if(this.ternauth)return this.ternauth.signIn}get signUp(){if(this.ternauth)return this.ternauth.signUp}get user(){if(this.ternauth)return this.ternauth.user}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.ternauth=null,this.#e=null)}static clearInstance(){this.#e=null}get domain(){if(typeof window<"u"&&window.location)return(0,o.handleValueOrFn)(this.#t,new URL(window.location.href),"");if(typeof this.#t=="function")throw new Error("Unsupported customDomain type: function");return this.#t||""}get proxyUrl(){if(typeof window<"u"&&window.location)return(0,o.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}constructor(e){const{TernSecureAuth:t=null}=e||{};this.#t=e.ternSecureConfig?.authDomain,this.options={...e},this._mode=a()?"browser":"server",this.#s=this.options.apiUrl,this.TernSecureAuth=t,this.options.sdkMetadata||(this.options.sdkMetadata=T),this.initTernSecureAuth()}get sdkMetadata(){return this.ternauth?.sdkMetadata||this.options.sdkMetadata}get version(){return this.ternauth?.version}get instanceType(){return this.ternauth?.instanceType}get apiUrl(){return this.#s||""}async initTernSecureAuth(){if(this._mode!=="browser"&&this.isReady)return;const e=c.TernSecureAuth.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,n)=>{t.unsubscribe=e.addListener(n)}),this.#r.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.#i="ready",this.#r.emit(s.ternEvents.Status,"ready")),this.ternauth};on=(...e)=>this.ternauth?.on?this.ternauth.on(...e):this.#r.on(...e);off=(...e)=>this.ternauth?.off?this.ternauth.off(...e):this.#r.off(...e);addListener=e=>{if(this.ternauth)return this.ternauth.addListener(e);{const t=()=>{const n=this.preAddListener.get(e);n&&(n.unsubscribe(),this.preAddListener.delete(e))};return this.preAddListener.set(e,{unsubscribe:t}),t}};signOut=async e=>{if(!this.ternauth)throw new Error("TernSecureAuth not initialized");await this.ternauth.signOut()};get currentSession(){return this.ternauth?this.ternauth.currentSession:null}onAuthStateChanged(e){return this.ternauth?this.ternauth.onAuthStateChanged(e):(console.warn("[IsoTernSecureAuth] TernAuth not initialized, cannot set up auth state listener"),()=>{})}#u(){return new Promise(e=>{e(this.ternauth)})}initialize=async()=>{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 u=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var S=(r,e)=>{for(var t in e)u(r,t,{get:e[t],enumerable:!0})},f=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of l(e))!p.call(r,i)&&i!==t&&u(r,i,{get:()=>e[i],enumerable:!(n=d(e,i))||n.enumerable});return r};var A=r=>f(u({},"__esModule",{value:!0}),r);var T={};S(T,{IsoTernSecureAuth:()=>h,inBrowser:()=>a});module.exports=A(T);var c=require("@tern-secure/auth"),s=require("@tern-secure/shared/ternStatusEvent"),o=require("@tern-secure/shared/utils");const g={name:"@tern-secure/react",version:"1.2.0-canary.v20251019190011",environment:process.env.NODE_ENV};function a(){return typeof window<"u"}class h{_mode;options;TernSecureAuth;ternauth=null;preAddListener=new Map;#i="loading";#s;#t;#n;#r=(0,s.createTernAuthEventBus)();static#e;get status(){return this.ternauth?this.ternauth.status||(this.ternauth.isReady?"ready":"loading"):this.#i}get isReady(){return this.ternauth?.isReady||!1}get isLoading(){return this.ternauth?.isLoading||!1}get requiresVerification(){return this.options.requiresVerification??!0}get signIn(){if(this.ternauth)return this.ternauth.signIn}get signUp(){if(this.ternauth)return this.ternauth.signUp}get user(){if(this.ternauth)return this.ternauth.user}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.ternauth=null,this.#e=null)}static clearInstance(){this.#e=null}get domain(){if(typeof window<"u"&&window.location)return(0,o.handleValueOrFn)(this.#t,new URL(window.location.href),"");if(typeof this.#t=="function")throw new Error("Unsupported customDomain type: function");return this.#t||""}get proxyUrl(){if(typeof window<"u"&&window.location)return(0,o.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.ternauth?._internal_getOption?this.ternauth?._internal_getOption(e):this.options[e]}_internal_getAllOptions(){return Object.freeze({...this.options})}constructor(e){const{TernSecureAuth:t=null}=e||{};this.#t=e.ternSecureConfig?.authDomain,this.options={...e},this._mode=a()?"browser":"server",this.#s=this.options.apiUrl,this.TernSecureAuth=t,this.options.sdkMetadata||(this.options.sdkMetadata=g),this.initTernSecureAuth()}get sdkMetadata(){return this.ternauth?.sdkMetadata||this.options.sdkMetadata}get version(){return this.ternauth?.version}get instanceType(){return this.ternauth?.instanceType}get apiUrl(){return this.#s||""}async initTernSecureAuth(){if(this._mode!=="browser"&&this.isReady)return;const e=c.TernSecureAuth.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,n)=>{t.unsubscribe=e.addListener(n)}),this.#r.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.#i="ready",this.#r.emit(s.ternEvents.Status,"ready")),this.ternauth};on=(...e)=>this.ternauth?.on?this.ternauth.on(...e):this.#r.on(...e);off=(...e)=>this.ternauth?.off?this.ternauth.off(...e):this.#r.off(...e);addListener=e=>{if(this.ternauth)return this.ternauth.addListener(e);{const t=()=>{const n=this.preAddListener.get(e);n&&(n.unsubscribe(),this.preAddListener.delete(e))};return this.preAddListener.set(e,{unsubscribe:t}),t}};createActiveSession=e=>this.ternauth?this.ternauth.createActiveSession(e):Promise.reject(new Error("TernSecureAuth not initialized"));signOut=async e=>{if(!this.ternauth)throw new Error("TernSecureAuth not initialized");await this.ternauth.signOut()};get currentSession(){return this.ternauth?this.ternauth.currentSession:null}onAuthStateChanged(e){return this.ternauth?this.ternauth.onAuthStateChanged(e):(console.warn("[IsoTernSecureAuth] TernAuth not initialized, cannot set up auth state listener"),()=>{})}getRedirectResult=async()=>{if(!this.ternauth?.getRedirectResult)throw new Error("TernSecure instance not initialized");return this.ternauth.getRedirectResult()};redirectToSignIn=async e=>{this.ternauth?.redirectToSignIn&&this.ternauth.redirectToSignIn(e)};redirectToSignUp=async e=>{this.ternauth?.redirectToSignUp&&this.ternauth.redirectToSignUp()};redirectAfterSignIn=e=>{this.ternauth?.redirectAfterSignIn&&this.ternauth.redirectAfterSignIn()};redirectAfterSignUp=e=>{this.ternauth?.redirectAfterSignUp&&this.ternauth.redirectAfterSignUp()};#u(){return new Promise(e=>{e(this.ternauth)})}initialize=async()=>{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 +1 @@
1
- {"version":3,"sources":["../../src/lib/isoTernSecureAuth.ts"],"sourcesContent":["import { TernSecureAuth as TernSecureAuthImpl } from '@tern-secure/auth'\nimport { createTernAuthEventBus, ternEvents } from '@tern-secure/shared/ternStatusEvent';\nimport { handleValueOrFn } from '@tern-secure/shared/utils';\nimport type {\n DomainOrProxyUrl,\n ListenerCallback,\n SignedInSession,\n SignInResource,\n SignOutOptions,\n SignUpResource,\n TernSecureAuth,\n TernSecureAuthStatus,\n UnsubscribeCallback,\n} from '@tern-secure/types';\n\nimport type { IsoTernSecureAuthOptions, TernSecureAuthProps } from '../types';\n\nconst SDK_METADATA = {\n name: __PACKAGE_NAME__,\n version: __PACKAGE_VERSION__,\n environment: process.env.NODE_ENV,\n};\n\nexport function inBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\n/**\n * IsomorphicTernSecure class manages the auth state and UI rendering\n * in both browser and server environments, acting as a proxy for TernSecureAuth\n */\nexport class IsoTernSecureAuth implements TernSecureAuth {\n private readonly _mode: 'browser' | 'server';\n private readonly options: IsoTernSecureAuthOptions;\n private readonly TernSecureAuth: TernSecureAuthProps;\n private ternauth: TernSecureAuthProps | null = null;\n private preAddListener = new Map<ListenerCallback, { unsubscribe: UnsubscribeCallback }>();\n\n #status: TernSecureAuthStatus = 'loading';\n #apiUrl: string | undefined;\n #domain: DomainOrProxyUrl['domain'];\n #proxyUrl: DomainOrProxyUrl['proxyUrl'];\n #eventBus = createTernAuthEventBus();\n\n static #instance: IsoTernSecureAuth | null | undefined;\n\n get status(): TernSecureAuthStatus {\n if (!this.ternauth) {\n return this.#status;\n }\n return this.ternauth.status || (this.ternauth.isReady ? 'ready' : 'loading');\n }\n\n get isReady(): boolean {\n return this.ternauth?.isReady || false;\n }\n\n get isLoading(): boolean {\n return this.ternauth?.isLoading || false;\n }\n\n get requiresVerification(): boolean {\n return this.options.requiresVerification ?? true;\n }\n\n get signIn(): SignInResource | undefined | null {\n if (this.ternauth) {\n return this.ternauth.signIn;\n }\n return undefined;\n }\n\n get signUp(): SignUpResource | undefined | null {\n if (this.ternauth) {\n return this.ternauth.signUp;\n }\n return undefined;\n }\n\n get user() {\n if (this.ternauth) {\n return this.ternauth.user;\n }\n }\n\n static getOrCreateInstance(options: IsoTernSecureAuthOptions) {\n if (\n !inBrowser() ||\n !this.#instance ||\n (options.TernSecureAuth && this.#instance.TernSecureAuth !== options.TernSecureAuth)\n ) {\n this.#instance = new IsoTernSecureAuth(options);\n }\n //console.log('[IsoTernSecureAuth] getOrCreateInstance', this.#instance);\n return this.#instance;\n }\n\n static clearInstances() {\n if (this.#instance) {\n this.#instance.ternauth = null;\n this.#instance = null;\n }\n }\n\n static clearInstance() {\n this.#instance = null;\n }\n\n get domain(): string {\n if (typeof window !== 'undefined' && window.location) {\n return handleValueOrFn(this.#domain, new URL(window.location.href), '');\n }\n if (typeof this.#domain === 'function') {\n throw new Error('Unsupported customDomain type: function');\n }\n return this.#domain || '';\n }\n\n get proxyUrl(): string {\n if (typeof window !== 'undefined' && window.location) {\n return handleValueOrFn(this.#proxyUrl, new URL(window.location.href), '');\n }\n if (typeof this.#proxyUrl === 'function') {\n throw new Error('Unsupported customProxyUrl type: function');\n }\n return this.#proxyUrl || '';\n }\n\n get mode(): 'browser' | 'server' {\n return this._mode;\n }\n\n constructor(options: IsoTernSecureAuthOptions) {\n const { TernSecureAuth = null } = options || {};\n this.#domain = options.ternSecureConfig?.authDomain;\n this.options = { ...options };\n this._mode = inBrowser() ? 'browser' : 'server';\n this.#apiUrl = this.options.apiUrl;\n this.TernSecureAuth = TernSecureAuth;\n\n if (!this.options.sdkMetadata) {\n this.options.sdkMetadata = SDK_METADATA;\n }\n\n this.initTernSecureAuth();\n }\n\n get sdkMetadata() {\n return this.ternauth?.sdkMetadata || this.options.sdkMetadata;\n }\n\n get version() {\n return this.ternauth?.version;\n }\n\n get instanceType() {\n return this.ternauth?.instanceType;\n }\n\n get apiUrl() {\n return this.#apiUrl || '';\n }\n\n async initTernSecureAuth() {\n if (this._mode !== 'browser' && this.isReady) {\n return;\n }\n\n const tern = TernSecureAuthImpl.initialize(this.options);\n this.loadTernSecureAuth(tern);\n }\n\n private loadTernSecureAuth = (ternauth: TernSecureAuthProps | undefined) => {\n if (!ternauth) {\n throw new Error('TernAuth instance is not initialized');\n }\n\n this.ternauth = ternauth;\n this.preAddListener.forEach((listenerHandlers, listener) => {\n listenerHandlers.unsubscribe = ternauth.addListener(listener);\n });\n\n this.#eventBus.getListeners('status').forEach(listener => {\n this.on('status', listener, { notify: true });\n });\n\n if (typeof this.ternauth.status === 'undefined') {\n console.log(\n '[IsoTernSecureAuth] TernSecureAuth has no status, setting internal status to ready',\n );\n this.#status = 'ready';\n this.#eventBus.emit(ternEvents.Status, 'ready');\n }\n\n return this.ternauth;\n };\n\n public on: TernSecureAuth['on'] = (...args) => {\n if (this.ternauth?.on) {\n return this.ternauth.on(...args);\n } else {\n return this.#eventBus.on(...args);\n }\n };\n\n public off: TernSecureAuth['off'] = (...args) => {\n if (this.ternauth?.off) {\n return this.ternauth.off(...args);\n } else {\n return this.#eventBus.off(...args);\n }\n };\n\n addListener = (listener: ListenerCallback): UnsubscribeCallback => {\n if (this.ternauth) {\n return this.ternauth.addListener(listener);\n } else {\n const unsubscribe = () => {\n const listenerHandlers = this.preAddListener.get(listener);\n if (listenerHandlers) {\n listenerHandlers.unsubscribe();\n this.preAddListener.delete(listener);\n }\n };\n this.preAddListener.set(listener, { unsubscribe });\n return unsubscribe;\n }\n };\n\n signOut = async (options?: SignOutOptions): Promise<void> => {\n if (!this.ternauth) {\n throw new Error('TernSecureAuth not initialized');\n }\n await this.ternauth.signOut();\n };\n\n get currentSession(): SignedInSession | null {\n if (!this.ternauth) {\n return null;\n }\n return this.ternauth.currentSession;\n };\n\n onAuthStateChanged(callback: (user: any) => void): () => void {\n if (!this.ternauth) {\n console.warn(\n '[IsoTernSecureAuth] TernAuth not initialized, cannot set up auth state listener',\n );\n return () => {};\n }\n return this.ternauth.onAuthStateChanged(callback);\n }\n\n #awaitForTernSecureAuth(): Promise<TernSecureAuthProps> {\n return new Promise<TernSecureAuthProps>(resolve => {\n resolve(this.ternauth);\n });\n }\n\n initialize = async (): Promise<void> => {\n try {\n await this.#awaitForTernSecureAuth();\n } catch (error) {\n console.error('[IsomorphicTernSecure] Failed to initialize TernSecureAuth:', error);\n throw error;\n }\n };\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,EAAA,cAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAAqD,6BACrDC,EAAmD,+CACnDC,EAAgC,qCAehC,MAAMC,EAAe,CACnB,KAAM,qBACN,QAAS,+BACT,YAAa,QAAQ,IAAI,QAC3B,EAEO,SAASL,GAAqB,CACnC,OAAO,OAAO,O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owser","__toCommonJS","import_auth","import_ternStatusEvent","import_utils","SDK_METADATA","#status","#apiUrl","#domain","#proxyUrl","#eventBus","#instance","options","TernSecureAuth","tern","TernSecureAuthImpl","ternauth","listenerHandlers","listener","args","unsubscribe","callback","#awaitForTernSecureAuth","resolve","error"]}
1
+ {"version":3,"sources":["../../src/lib/isoTernSecureAuth.ts"],"sourcesContent":["import { TernSecureAuth as TernSecureAuthImpl } from '@tern-secure/auth'\nimport { createTernAuthEventBus, ternEvents } from '@tern-secure/shared/ternStatusEvent';\nimport { handleValueOrFn } from '@tern-secure/shared/utils';\nimport type {\n CreateActiveSessionParams,\n DomainOrProxyUrl,\n ListenerCallback,\n SignedInSession,\n SignInRedirectOptions,\n SignInResource,\n SignOutOptions,\n SignUpRedirectOptions,\n SignUpResource,\n TernSecureAuth,\n TernSecureAuthOptions,\n TernSecureAuthStatus,\n UnsubscribeCallback,\n} from '@tern-secure/types';\n\nimport type { IsoTernSecureAuthOptions, TernSecureAuthProps } from '../types';\n\nconst SDK_METADATA = {\n name: __PACKAGE_NAME__,\n version: __PACKAGE_VERSION__,\n environment: process.env.NODE_ENV,\n};\n\nexport function inBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\n/**\n * IsomorphicTernSecure class manages the auth state and UI rendering\n * in both browser and server environments, acting as a proxy for TernSecureAuth\n */\nexport class IsoTernSecureAuth implements TernSecureAuth {\n private readonly _mode: 'browser' | 'server';\n private readonly options: IsoTernSecureAuthOptions;\n private readonly TernSecureAuth: TernSecureAuthProps;\n private ternauth: TernSecureAuthProps | null = null;\n private preAddListener = new Map<ListenerCallback, { unsubscribe: UnsubscribeCallback }>();\n\n #status: TernSecureAuthStatus = 'loading';\n #apiUrl: string | undefined;\n #domain: DomainOrProxyUrl['domain'];\n #proxyUrl: DomainOrProxyUrl['proxyUrl'];\n #eventBus = createTernAuthEventBus();\n\n static #instance: IsoTernSecureAuth | null | undefined;\n\n get status(): TernSecureAuthStatus {\n if (!this.ternauth) {\n return this.#status;\n }\n return this.ternauth.status || (this.ternauth.isReady ? 'ready' : 'loading');\n }\n\n get isReady(): boolean {\n return this.ternauth?.isReady || false;\n }\n\n get isLoading(): boolean {\n return this.ternauth?.isLoading || false;\n }\n\n get requiresVerification(): boolean {\n return this.options.requiresVerification ?? true;\n }\n\n get signIn(): SignInResource | undefined | null {\n if (this.ternauth) {\n return this.ternauth.signIn;\n }\n return undefined;\n }\n\n get signUp(): SignUpResource | undefined | null {\n if (this.ternauth) {\n return this.ternauth.signUp;\n }\n return undefined;\n }\n\n get user() {\n if (this.ternauth) {\n return this.ternauth.user;\n }\n }\n\n static getOrCreateInstance(options: IsoTernSecureAuthOptions) {\n if (\n !inBrowser() ||\n !this.#instance ||\n (options.TernSecureAuth && this.#instance.TernSecureAuth !== options.TernSecureAuth)\n ) {\n this.#instance = new IsoTernSecureAuth(options);\n }\n //console.log('[IsoTernSecureAuth] getOrCreateInstance', this.#instance);\n return this.#instance;\n }\n\n static clearInstances() {\n if (this.#instance) {\n this.#instance.ternauth = null;\n this.#instance = null;\n }\n }\n\n static clearInstance() {\n this.#instance = null;\n }\n\n get domain(): string {\n if (typeof window !== 'undefined' && window.location) {\n return handleValueOrFn(this.#domain, new URL(window.location.href), '');\n }\n if (typeof this.#domain === 'function') {\n throw new Error('Unsupported customDomain type: function');\n }\n return this.#domain || '';\n }\n\n get proxyUrl(): string {\n if (typeof window !== 'undefined' && window.location) {\n return handleValueOrFn(this.#proxyUrl, new URL(window.location.href), '');\n }\n if (typeof this.#proxyUrl === 'function') {\n throw new Error('Unsupported customProxyUrl type: function');\n }\n return this.#proxyUrl || '';\n }\n\n get mode(): 'browser' | 'server' {\n return this._mode;\n }\n\n /**\n * @internal\n */\n public _internal_getOption<K extends keyof TernSecureAuthOptions>(key: K): TernSecureAuthOptions[K] | undefined {\n return this.ternauth?._internal_getOption ? this.ternauth?._internal_getOption(key) : this.options[key];\n }\n\n /** \n * @internal\n */\n public _internal_getAllOptions(): Readonly<TernSecureAuthOptions> {\n return Object.freeze({ ...this.options });\n }\n\n constructor(options: IsoTernSecureAuthOptions) {\n const { TernSecureAuth = null } = options || {};\n this.#domain = options.ternSecureConfig?.authDomain;\n this.options = { ...options };\n this._mode = inBrowser() ? 'browser' : 'server';\n this.#apiUrl = this.options.apiUrl;\n this.TernSecureAuth = TernSecureAuth;\n\n if (!this.options.sdkMetadata) {\n this.options.sdkMetadata = SDK_METADATA;\n }\n\n this.initTernSecureAuth();\n }\n\n get sdkMetadata() {\n return this.ternauth?.sdkMetadata || this.options.sdkMetadata;\n }\n\n get version() {\n return this.ternauth?.version;\n }\n\n get instanceType() {\n return this.ternauth?.instanceType;\n }\n\n get apiUrl() {\n return this.#apiUrl || '';\n }\n\n async initTernSecureAuth() {\n if (this._mode !== 'browser' && this.isReady) {\n return;\n }\n\n const tern = TernSecureAuthImpl.initialize(this.options);\n this.loadTernSecureAuth(tern);\n }\n\n private loadTernSecureAuth = (ternauth: TernSecureAuthProps | undefined) => {\n if (!ternauth) {\n throw new Error('TernAuth instance is not initialized');\n }\n\n this.ternauth = ternauth;\n this.preAddListener.forEach((listenerHandlers, listener) => {\n listenerHandlers.unsubscribe = ternauth.addListener(listener);\n });\n\n this.#eventBus.getListeners('status').forEach(listener => {\n this.on('status', listener, { notify: true });\n });\n\n if (typeof this.ternauth.status === 'undefined') {\n console.log(\n '[IsoTernSecureAuth] TernSecureAuth has no status, setting internal status to ready',\n );\n this.#status = 'ready';\n this.#eventBus.emit(ternEvents.Status, 'ready');\n }\n\n return this.ternauth;\n };\n\n public on: TernSecureAuth['on'] = (...args) => {\n if (this.ternauth?.on) {\n return this.ternauth.on(...args);\n } else {\n return this.#eventBus.on(...args);\n }\n };\n\n public off: TernSecureAuth['off'] = (...args) => {\n if (this.ternauth?.off) {\n return this.ternauth.off(...args);\n } else {\n return this.#eventBus.off(...args);\n }\n };\n\n addListener = (listener: ListenerCallback): UnsubscribeCallback => {\n if (this.ternauth) {\n return this.ternauth.addListener(listener);\n } else {\n const unsubscribe = () => {\n const listenerHandlers = this.preAddListener.get(listener);\n if (listenerHandlers) {\n listenerHandlers.unsubscribe();\n this.preAddListener.delete(listener);\n }\n };\n this.preAddListener.set(listener, { unsubscribe });\n return unsubscribe;\n }\n };\n\n createActiveSession = (params: CreateActiveSessionParams): Promise<void> => {\n if (this.ternauth) {\n return this.ternauth.createActiveSession(params);\n } else {\n return Promise.reject(new Error('TernSecureAuth not initialized'));\n }\n }\n\n signOut = async (options?: SignOutOptions): Promise<void> => {\n if (!this.ternauth) {\n throw new Error('TernSecureAuth not initialized');\n }\n await this.ternauth.signOut();\n };\n\n get currentSession(): SignedInSession | null {\n if (!this.ternauth) {\n return null;\n }\n return this.ternauth.currentSession;\n };\n\n onAuthStateChanged(callback: (user: any) => void): () => void {\n if (!this.ternauth) {\n console.warn(\n '[IsoTernSecureAuth] TernAuth not initialized, cannot set up auth state listener',\n );\n return () => {};\n }\n return this.ternauth.onAuthStateChanged(callback);\n }\n\n getRedirectResult = async (): Promise<any> => {\n if (!this.ternauth?.getRedirectResult) {\n throw new Error('TernSecure instance not initialized');\n }\n return this.ternauth.getRedirectResult();\n };\n\n redirectToSignIn = async (options?: SignInRedirectOptions) => {\n if (this.ternauth?.redirectToSignIn) {\n this.ternauth.redirectToSignIn(options);\n }\n };\n\n redirectToSignUp = async (options?: SignUpRedirectOptions) => {\n if (this.ternauth?.redirectToSignUp) {\n this.ternauth.redirectToSignUp();\n }\n };\n\n redirectAfterSignIn = (redirectUrl?: string): void => {\n if (this.ternauth?.redirectAfterSignIn) {\n this.ternauth.redirectAfterSignIn();\n }\n }\n\n redirectAfterSignUp = (redirectUrl?: string): void => {\n if (this.ternauth?.redirectAfterSignUp) {\n this.ternauth.redirectAfterSignUp();\n }\n };\n\n #awaitForTernSecureAuth(): Promise<TernSecureAuthProps> {\n return new Promise<TernSecureAuthProps>(resolve => {\n resolve(this.ternauth);\n });\n }\n\n initialize = async (): Promise<void> => {\n try {\n await this.#awaitForTernSecureAuth();\n } catch (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M,EAExC,QAAQ,OAAO,IAAI,MAAM,gCAAgC,CAAC,EAIrE,QAAU,MAAOV,GAA4C,CAC3D,GAAI,CAAC,KAAK,SACR,MAAM,IAAI,MAAM,gCAAgC,EAElD,MAAM,KAAK,SAAS,QAAQ,CAC9B,EAEA,IAAI,gBAAyC,CAC3C,OAAK,KAAK,SAGH,KAAK,SAAS,eAFZ,IAGX,CAEA,mBAAmBW,EAA2C,CAC5D,OAAK,KAAK,SAMH,KAAK,SAAS,mBAAmBA,CAAQ,GAL9C,QAAQ,KACN,iFACF,EACO,IAAM,CAAC,EAGlB,CAEA,kBAAoB,SAA0B,CAC5C,GAAI,CAAC,KAAK,UAAU,kBAClB,MAAM,IAAI,MAAM,qCAAqC,EAEvD,OAAO,KAAK,SAAS,kBAAkB,CACzC,EAEA,iBAAmB,MAAOX,GAAoC,CACxD,KAAK,UAAU,kBACjB,KAAK,SAAS,iBAAiBA,CAAO,CAE1C,EAEA,iBAAmB,MAAOA,GAAoC,CACxD,KAAK,UAAU,kBACjB,KAAK,SAAS,iBAAiB,CAEnC,EAEA,oBAAuBY,GAA+B,CAChD,KAAK,UAAU,qBACjB,KAAK,SAAS,oBAAoB,CAEtC,EAEA,oBAAuBA,GAA+B,CAChD,KAAK,UAAU,qBACjB,KAAK,SAAS,oBAAoB,CAEtC,EAEAC,IAAwD,CACtD,OAAO,IAAI,QAA6BC,GAAW,CACjDA,EAAQ,KAAK,QAAQ,CACvB,CAAC,CACH,CAEA,WAAa,SAA2B,CACtC,GAAI,CACF,MAAM,KAAKD,GAAwB,CACrC,OAASE,EAAO,CACd,cAAQ,MAAM,8DAA+DA,CAAK,EAC5EA,CACR,CACF,CACF","names":["isoTernSecureAuth_exports","__export","IsoTernSecureAuth","inBrowser","__toCommonJS","import_auth","import_ternStatusEvent","import_utils","SDK_METADATA","#status","#apiUrl","#domain","#proxyUrl","#eventBus","#instance","options","key","TernSecureAuth","tern","TernSecureAuthImpl","ternauth","listenerHandlers","listener","args","unsubscribe","params","callback","redirectUrl","#awaitForTernSecureAuth","resolve","error"]}
@@ -1,2 +1,2 @@
1
- import{TernSecureAuth as u}from"@tern-secure/auth";import{createTernAuthEventBus as o,ternEvents as a}from"@tern-secure/shared/ternStatusEvent";import{handleValueOrFn as n}from"@tern-secure/shared/utils";const h={name:"@tern-secure/react",version:"1.2.0-canary.v20251008131428",environment:process.env.NODE_ENV};function i(){return typeof window<"u"}class s{_mode;options;TernSecureAuth;ternauth=null;preAddListener=new Map;#i="loading";#s;#t;#n;#r=o();static#e;get status(){return this.ternauth?this.ternauth.status||(this.ternauth.isReady?"ready":"loading"):this.#i}get isReady(){return this.ternauth?.isReady||!1}get isLoading(){return this.ternauth?.isLoading||!1}get requiresVerification(){return this.options.requiresVerification??!0}get signIn(){if(this.ternauth)return this.ternauth.signIn}get signUp(){if(this.ternauth)return this.ternauth.signUp}get user(){if(this.ternauth)return this.ternauth.user}static getOrCreateInstance(e){return(!i()||!this.#e||e.TernSecureAuth&&this.#e.TernSecureAuth!==e.TernSecureAuth)&&(this.#e=new s(e)),this.#e}static clearInstances(){this.#e&&(this.#e.ternauth=null,this.#e=null)}static clearInstance(){this.#e=null}get domain(){if(typeof window<"u"&&window.location)return n(this.#t,new URL(window.location.href),"");if(typeof this.#t=="function")throw new Error("Unsupported customDomain type: function");return this.#t||""}get proxyUrl(){if(typeof window<"u"&&window.location)return n(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}constructor(e){const{TernSecureAuth:t=null}=e||{};this.#t=e.ternSecureConfig?.authDomain,this.options={...e},this._mode=i()?"browser":"server",this.#s=this.options.apiUrl,this.TernSecureAuth=t,this.options.sdkMetadata||(this.options.sdkMetadata=h),this.initTernSecureAuth()}get sdkMetadata(){return this.ternauth?.sdkMetadata||this.options.sdkMetadata}get version(){return this.ternauth?.version}get instanceType(){return this.ternauth?.instanceType}get apiUrl(){return this.#s||""}async initTernSecureAuth(){if(this._mode!=="browser"&&this.isReady)return;const e=u.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.#r.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.#i="ready",this.#r.emit(a.Status,"ready")),this.ternauth};on=(...e)=>this.ternauth?.on?this.ternauth.on(...e):this.#r.on(...e);off=(...e)=>this.ternauth?.off?this.ternauth.off(...e):this.#r.off(...e);addListener=e=>{if(this.ternauth)return this.ternauth.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}};signOut=async e=>{if(!this.ternauth)throw new Error("TernSecureAuth not initialized");await this.ternauth.signOut()};get currentSession(){return this.ternauth?this.ternauth.currentSession:null}onAuthStateChanged(e){return this.ternauth?this.ternauth.onAuthStateChanged(e):(console.warn("[IsoTernSecureAuth] TernAuth not initialized, cannot set up auth state listener"),()=>{})}#u(){return new Promise(e=>{e(this.ternauth)})}initialize=async()=>{try{await this.#u()}catch(e){throw console.error("[IsomorphicTernSecure] Failed to initialize TernSecureAuth:",e),e}}}export{s as IsoTernSecureAuth,i as inBrowser};
1
+ import{TernSecureAuth as u}from"@tern-secure/auth";import{createTernAuthEventBus as o,ternEvents as a}from"@tern-secure/shared/ternStatusEvent";import{handleValueOrFn as n}from"@tern-secure/shared/utils";const h={name:"@tern-secure/react",version:"1.2.0-canary.v20251019190011",environment:process.env.NODE_ENV};function i(){return typeof window<"u"}class s{_mode;options;TernSecureAuth;ternauth=null;preAddListener=new Map;#i="loading";#s;#t;#n;#r=o();static#e;get status(){return this.ternauth?this.ternauth.status||(this.ternauth.isReady?"ready":"loading"):this.#i}get isReady(){return this.ternauth?.isReady||!1}get isLoading(){return this.ternauth?.isLoading||!1}get requiresVerification(){return this.options.requiresVerification??!0}get signIn(){if(this.ternauth)return this.ternauth.signIn}get signUp(){if(this.ternauth)return this.ternauth.signUp}get user(){if(this.ternauth)return this.ternauth.user}static getOrCreateInstance(e){return(!i()||!this.#e||e.TernSecureAuth&&this.#e.TernSecureAuth!==e.TernSecureAuth)&&(this.#e=new s(e)),this.#e}static clearInstances(){this.#e&&(this.#e.ternauth=null,this.#e=null)}static clearInstance(){this.#e=null}get domain(){if(typeof window<"u"&&window.location)return n(this.#t,new URL(window.location.href),"");if(typeof this.#t=="function")throw new Error("Unsupported customDomain type: function");return this.#t||""}get proxyUrl(){if(typeof window<"u"&&window.location)return n(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.ternauth?._internal_getOption?this.ternauth?._internal_getOption(e):this.options[e]}_internal_getAllOptions(){return Object.freeze({...this.options})}constructor(e){const{TernSecureAuth:t=null}=e||{};this.#t=e.ternSecureConfig?.authDomain,this.options={...e},this._mode=i()?"browser":"server",this.#s=this.options.apiUrl,this.TernSecureAuth=t,this.options.sdkMetadata||(this.options.sdkMetadata=h),this.initTernSecureAuth()}get sdkMetadata(){return this.ternauth?.sdkMetadata||this.options.sdkMetadata}get version(){return this.ternauth?.version}get instanceType(){return this.ternauth?.instanceType}get apiUrl(){return this.#s||""}async initTernSecureAuth(){if(this._mode!=="browser"&&this.isReady)return;const e=u.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.#r.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.#i="ready",this.#r.emit(a.Status,"ready")),this.ternauth};on=(...e)=>this.ternauth?.on?this.ternauth.on(...e):this.#r.on(...e);off=(...e)=>this.ternauth?.off?this.ternauth.off(...e):this.#r.off(...e);addListener=e=>{if(this.ternauth)return this.ternauth.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.ternauth?this.ternauth.createActiveSession(e):Promise.reject(new Error("TernSecureAuth not initialized"));signOut=async e=>{if(!this.ternauth)throw new Error("TernSecureAuth not initialized");await this.ternauth.signOut()};get currentSession(){return this.ternauth?this.ternauth.currentSession:null}onAuthStateChanged(e){return this.ternauth?this.ternauth.onAuthStateChanged(e):(console.warn("[IsoTernSecureAuth] TernAuth not initialized, cannot set up auth state listener"),()=>{})}getRedirectResult=async()=>{if(!this.ternauth?.getRedirectResult)throw new Error("TernSecure instance not initialized");return this.ternauth.getRedirectResult()};redirectToSignIn=async e=>{this.ternauth?.redirectToSignIn&&this.ternauth.redirectToSignIn(e)};redirectToSignUp=async e=>{this.ternauth?.redirectToSignUp&&this.ternauth.redirectToSignUp()};redirectAfterSignIn=e=>{this.ternauth?.redirectAfterSignIn&&this.ternauth.redirectAfterSignIn()};redirectAfterSignUp=e=>{this.ternauth?.redirectAfterSignUp&&this.ternauth.redirectAfterSignUp()};#u(){return new Promise(e=>{e(this.ternauth)})}initialize=async()=>{try{await this.#u()}catch(e){throw console.error("[IsomorphicTernSecure] Failed to initialize TernSecureAuth:",e),e}}}export{s as IsoTernSecureAuth,i as inBrowser};
2
2
  //# sourceMappingURL=isoTernSecureAuth.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/isoTernSecureAuth.ts"],"sourcesContent":["import { TernSecureAuth as TernSecureAuthImpl } from '@tern-secure/auth'\nimport { createTernAuthEventBus, ternEvents } from '@tern-secure/shared/ternStatusEvent';\nimport { handleValueOrFn } from '@tern-secure/shared/utils';\nimport type {\n DomainOrProxyUrl,\n ListenerCallback,\n SignedInSession,\n SignInResource,\n SignOutOptions,\n SignUpResource,\n TernSecureAuth,\n TernSecureAuthStatus,\n UnsubscribeCallback,\n} from '@tern-secure/types';\n\nimport type { IsoTernSecureAuthOptions, TernSecureAuthProps } from '../types';\n\nconst SDK_METADATA = {\n name: __PACKAGE_NAME__,\n version: __PACKAGE_VERSION__,\n environment: process.env.NODE_ENV,\n};\n\nexport function inBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\n/**\n * IsomorphicTernSecure class manages the auth state and UI rendering\n * in both browser and server environments, acting as a proxy for TernSecureAuth\n */\nexport class IsoTernSecureAuth implements TernSecureAuth {\n private readonly _mode: 'browser' | 'server';\n private readonly options: IsoTernSecureAuthOptions;\n private readonly TernSecureAuth: TernSecureAuthProps;\n private ternauth: TernSecureAuthProps | null = null;\n private preAddListener = new Map<ListenerCallback, { unsubscribe: UnsubscribeCallback }>();\n\n #status: TernSecureAuthStatus = 'loading';\n #apiUrl: string | undefined;\n #domain: DomainOrProxyUrl['domain'];\n #proxyUrl: DomainOrProxyUrl['proxyUrl'];\n #eventBus = createTernAuthEventBus();\n\n static #instance: IsoTernSecureAuth | null | undefined;\n\n get status(): TernSecureAuthStatus {\n if (!this.ternauth) {\n return this.#status;\n }\n return this.ternauth.status || (this.ternauth.isReady ? 'ready' : 'loading');\n }\n\n get isReady(): boolean {\n return this.ternauth?.isReady || false;\n }\n\n get isLoading(): boolean {\n return this.ternauth?.isLoading || false;\n }\n\n get requiresVerification(): boolean {\n return this.options.requiresVerification ?? true;\n }\n\n get signIn(): SignInResource | undefined | null {\n if (this.ternauth) {\n return this.ternauth.signIn;\n }\n return undefined;\n }\n\n get signUp(): SignUpResource | undefined | null {\n if (this.ternauth) {\n return this.ternauth.signUp;\n }\n return undefined;\n }\n\n get user() {\n if (this.ternauth) {\n return this.ternauth.user;\n }\n }\n\n static getOrCreateInstance(options: IsoTernSecureAuthOptions) {\n if (\n !inBrowser() ||\n !this.#instance ||\n (options.TernSecureAuth && this.#instance.TernSecureAuth !== options.TernSecureAuth)\n ) {\n this.#instance = new IsoTernSecureAuth(options);\n }\n //console.log('[IsoTernSecureAuth] getOrCreateInstance', this.#instance);\n return this.#instance;\n }\n\n static clearInstances() {\n if (this.#instance) {\n this.#instance.ternauth = null;\n this.#instance = null;\n }\n }\n\n static clearInstance() {\n this.#instance = null;\n }\n\n get domain(): string {\n if (typeof window !== 'undefined' && window.location) {\n return handleValueOrFn(this.#domain, new URL(window.location.href), '');\n }\n if (typeof this.#domain === 'function') {\n throw new Error('Unsupported customDomain type: function');\n }\n return this.#domain || '';\n }\n\n get proxyUrl(): string {\n if (typeof window !== 'undefined' && window.location) {\n return handleValueOrFn(this.#proxyUrl, new URL(window.location.href), '');\n }\n if (typeof this.#proxyUrl === 'function') {\n throw new Error('Unsupported customProxyUrl type: function');\n }\n return this.#proxyUrl || '';\n }\n\n get mode(): 'browser' | 'server' {\n return this._mode;\n }\n\n constructor(options: IsoTernSecureAuthOptions) {\n const { TernSecureAuth = null } = options || {};\n this.#domain = options.ternSecureConfig?.authDomain;\n this.options = { ...options };\n this._mode = inBrowser() ? 'browser' : 'server';\n this.#apiUrl = this.options.apiUrl;\n this.TernSecureAuth = TernSecureAuth;\n\n if (!this.options.sdkMetadata) {\n this.options.sdkMetadata = SDK_METADATA;\n }\n\n this.initTernSecureAuth();\n }\n\n get sdkMetadata() {\n return this.ternauth?.sdkMetadata || this.options.sdkMetadata;\n }\n\n get version() {\n return this.ternauth?.version;\n }\n\n get instanceType() {\n return this.ternauth?.instanceType;\n }\n\n get apiUrl() {\n return this.#apiUrl || '';\n }\n\n async initTernSecureAuth() {\n if (this._mode !== 'browser' && this.isReady) {\n return;\n }\n\n const tern = TernSecureAuthImpl.initialize(this.options);\n this.loadTernSecureAuth(tern);\n }\n\n private loadTernSecureAuth = (ternauth: TernSecureAuthProps | undefined) => {\n if (!ternauth) {\n throw new Error('TernAuth instance is not initialized');\n }\n\n this.ternauth = ternauth;\n this.preAddListener.forEach((listenerHandlers, listener) => {\n listenerHandlers.unsubscribe = ternauth.addListener(listener);\n });\n\n this.#eventBus.getListeners('status').forEach(listener => {\n this.on('status', listener, { notify: true });\n });\n\n if (typeof this.ternauth.status === 'undefined') {\n console.log(\n '[IsoTernSecureAuth] TernSecureAuth has no status, setting internal status to ready',\n );\n this.#status = 'ready';\n this.#eventBus.emit(ternEvents.Status, 'ready');\n }\n\n return this.ternauth;\n };\n\n public on: TernSecureAuth['on'] = (...args) => {\n if (this.ternauth?.on) {\n return this.ternauth.on(...args);\n } else {\n return this.#eventBus.on(...args);\n }\n };\n\n public off: TernSecureAuth['off'] = (...args) => {\n if (this.ternauth?.off) {\n return this.ternauth.off(...args);\n } else {\n return this.#eventBus.off(...args);\n }\n };\n\n addListener = (listener: ListenerCallback): UnsubscribeCallback => {\n if (this.ternauth) {\n return this.ternauth.addListener(listener);\n } else {\n const unsubscribe = () => {\n const listenerHandlers = this.preAddListener.get(listener);\n if (listenerHandlers) {\n listenerHandlers.unsubscribe();\n this.preAddListener.delete(listener);\n }\n };\n this.preAddListener.set(listener, { unsubscribe });\n return unsubscribe;\n }\n };\n\n signOut = async (options?: SignOutOptions): Promise<void> => {\n if (!this.ternauth) {\n throw new Error('TernSecureAuth not initialized');\n }\n await this.ternauth.signOut();\n };\n\n get currentSession(): SignedInSession | null {\n if (!this.ternauth) {\n return null;\n }\n return this.ternauth.currentSession;\n };\n\n onAuthStateChanged(callback: (user: any) => void): () => void {\n if (!this.ternauth) {\n console.warn(\n '[IsoTernSecureAuth] TernAuth not initialized, cannot set up auth state listener',\n );\n return () => {};\n }\n return this.ternauth.onAuthStateChanged(callback);\n }\n\n #awaitForTernSecureAuth(): Promise<TernSecureAuthProps> {\n return new Promise<TernSecureAuthProps>(resolve => {\n resolve(this.ternauth);\n });\n }\n\n initialize = async (): Promise<void> => {\n try {\n await this.#awaitForTernSecureAuth();\n } catch (error) {\n console.error('[IsomorphicTernSecure] Failed to initialize TernSecureAuth:', error);\n throw error;\n }\n };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,GAAW,CACjDA,EAAQ,KAAK,QAAQ,CACvB,CAAC,CACH,CAEA,WAAa,SAA2B,CACtC,GAAI,CACF,MAAM,KAAKD,GAAwB,CACrC,OAASE,EAAO,CACd,cAAQ,MAAM,8DAA+DA,CAAK,EAC5EA,CACR,CACF,CACF","names":["TernSecureAuthImpl","createTernAuthEventBus","ternEvents","handleValueOrFn","SDK_METADATA","inBrowser","IsoTernSecureAuth","#status","#apiUrl","#domain","#proxyUrl","#eventBus","#instance","options","TernSecureAuth","tern","ternauth","listenerHandlers","listener","args","unsubscribe","callback","#awaitForTernSecureAuth","resolve","error"]}
1
+ {"version":3,"sources":["../../src/lib/isoTernSecureAuth.ts"],"sourcesContent":["import { TernSecureAuth as TernSecureAuthImpl } from '@tern-secure/auth'\nimport { createTernAuthEventBus, ternEvents } from '@tern-secure/shared/ternStatusEvent';\nimport { handleValueOrFn } from '@tern-secure/shared/utils';\nimport type {\n CreateActiveSessionParams,\n DomainOrProxyUrl,\n ListenerCallback,\n SignedInSession,\n SignInRedirectOptions,\n SignInResource,\n SignOutOptions,\n SignUpRedirectOptions,\n SignUpResource,\n TernSecureAuth,\n TernSecureAuthOptions,\n TernSecureAuthStatus,\n UnsubscribeCallback,\n} from '@tern-secure/types';\n\nimport type { IsoTernSecureAuthOptions, TernSecureAuthProps } from '../types';\n\nconst SDK_METADATA = {\n name: __PACKAGE_NAME__,\n version: __PACKAGE_VERSION__,\n environment: process.env.NODE_ENV,\n};\n\nexport function inBrowser(): boolean {\n return typeof window !== 'undefined';\n}\n\n/**\n * IsomorphicTernSecure class manages the auth state and UI rendering\n * in both browser and server environments, acting as a proxy for TernSecureAuth\n */\nexport class IsoTernSecureAuth implements TernSecureAuth {\n private readonly _mode: 'browser' | 'server';\n private readonly options: IsoTernSecureAuthOptions;\n private readonly TernSecureAuth: TernSecureAuthProps;\n private ternauth: TernSecureAuthProps | null = null;\n private preAddListener = new Map<ListenerCallback, { unsubscribe: UnsubscribeCallback }>();\n\n #status: TernSecureAuthStatus = 'loading';\n #apiUrl: string | undefined;\n #domain: DomainOrProxyUrl['domain'];\n #proxyUrl: DomainOrProxyUrl['proxyUrl'];\n #eventBus = createTernAuthEventBus();\n\n static #instance: IsoTernSecureAuth | null | undefined;\n\n get status(): TernSecureAuthStatus {\n if (!this.ternauth) {\n return this.#status;\n }\n return this.ternauth.status || (this.ternauth.isReady ? 'ready' : 'loading');\n }\n\n get isReady(): boolean {\n return this.ternauth?.isReady || false;\n }\n\n get isLoading(): boolean {\n return this.ternauth?.isLoading || false;\n }\n\n get requiresVerification(): boolean {\n return this.options.requiresVerification ?? true;\n }\n\n get signIn(): SignInResource | undefined | null {\n if (this.ternauth) {\n return this.ternauth.signIn;\n }\n return undefined;\n }\n\n get signUp(): SignUpResource | undefined | null {\n if (this.ternauth) {\n return this.ternauth.signUp;\n }\n return undefined;\n }\n\n get user() {\n if (this.ternauth) {\n return this.ternauth.user;\n }\n }\n\n static getOrCreateInstance(options: IsoTernSecureAuthOptions) {\n if (\n !inBrowser() ||\n !this.#instance ||\n (options.TernSecureAuth && this.#instance.TernSecureAuth !== options.TernSecureAuth)\n ) {\n this.#instance = new IsoTernSecureAuth(options);\n }\n //console.log('[IsoTernSecureAuth] getOrCreateInstance', this.#instance);\n return this.#instance;\n }\n\n static clearInstances() {\n if (this.#instance) {\n this.#instance.ternauth = null;\n this.#instance = null;\n }\n }\n\n static clearInstance() {\n this.#instance = null;\n }\n\n get domain(): string {\n if (typeof window !== 'undefined' && window.location) {\n return handleValueOrFn(this.#domain, new URL(window.location.href), '');\n }\n if (typeof this.#domain === 'function') {\n throw new Error('Unsupported customDomain type: function');\n }\n return this.#domain || '';\n }\n\n get proxyUrl(): string {\n if (typeof window !== 'undefined' && window.location) {\n return handleValueOrFn(this.#proxyUrl, new URL(window.location.href), '');\n }\n if (typeof this.#proxyUrl === 'function') {\n throw new Error('Unsupported customProxyUrl type: function');\n }\n return this.#proxyUrl || '';\n }\n\n get mode(): 'browser' | 'server' {\n return this._mode;\n }\n\n /**\n * @internal\n */\n public _internal_getOption<K extends keyof TernSecureAuthOptions>(key: K): TernSecureAuthOptions[K] | undefined {\n return this.ternauth?._internal_getOption ? this.ternauth?._internal_getOption(key) : this.options[key];\n }\n\n /** \n * @internal\n */\n public _internal_getAllOptions(): Readonly<TernSecureAuthOptions> {\n return Object.freeze({ ...this.options });\n }\n\n constructor(options: IsoTernSecureAuthOptions) {\n const { TernSecureAuth = null } = options || {};\n this.#domain = options.ternSecureConfig?.authDomain;\n this.options = { ...options };\n this._mode = inBrowser() ? 'browser' : 'server';\n this.#apiUrl = this.options.apiUrl;\n this.TernSecureAuth = TernSecureAuth;\n\n if (!this.options.sdkMetadata) {\n this.options.sdkMetadata = SDK_METADATA;\n }\n\n this.initTernSecureAuth();\n }\n\n get sdkMetadata() {\n return this.ternauth?.sdkMetadata || this.options.sdkMetadata;\n }\n\n get version() {\n return this.ternauth?.version;\n }\n\n get instanceType() {\n return this.ternauth?.instanceType;\n }\n\n get apiUrl() {\n return this.#apiUrl || '';\n }\n\n async initTernSecureAuth() {\n if (this._mode !== 'browser' && this.isReady) {\n return;\n }\n\n const tern = TernSecureAuthImpl.initialize(this.options);\n this.loadTernSecureAuth(tern);\n }\n\n private loadTernSecureAuth = (ternauth: TernSecureAuthProps | undefined) => {\n if (!ternauth) {\n throw new Error('TernAuth instance is not initialized');\n }\n\n this.ternauth = ternauth;\n this.preAddListener.forEach((listenerHandlers, listener) => {\n listenerHandlers.unsubscribe = ternauth.addListener(listener);\n });\n\n this.#eventBus.getListeners('status').forEach(listener => {\n this.on('status', listener, { notify: true });\n });\n\n if (typeof this.ternauth.status === 'undefined') {\n console.log(\n '[IsoTernSecureAuth] TernSecureAuth has no status, setting internal status to ready',\n );\n this.#status = 'ready';\n this.#eventBus.emit(ternEvents.Status, 'ready');\n }\n\n return this.ternauth;\n };\n\n public on: TernSecureAuth['on'] = (...args) => {\n if (this.ternauth?.on) {\n return this.ternauth.on(...args);\n } else {\n return this.#eventBus.on(...args);\n }\n };\n\n public off: TernSecureAuth['off'] = (...args) => {\n if (this.ternauth?.off) {\n return this.ternauth.off(...args);\n } else {\n return this.#eventBus.off(...args);\n }\n };\n\n addListener = (listener: ListenerCallback): UnsubscribeCallback => {\n if (this.ternauth) {\n return this.ternauth.addListener(listener);\n } else {\n const unsubscribe = () => {\n const listenerHandlers = this.preAddListener.get(listener);\n if (listenerHandlers) {\n listenerHandlers.unsubscribe();\n this.preAddListener.delete(listener);\n }\n };\n this.preAddListener.set(listener, { unsubscribe });\n return unsubscribe;\n }\n };\n\n createActiveSession = (params: CreateActiveSessionParams): Promise<void> => {\n if (this.ternauth) {\n return this.ternauth.createActiveSession(params);\n } else {\n return Promise.reject(new Error('TernSecureAuth not initialized'));\n }\n }\n\n signOut = async (options?: SignOutOptions): Promise<void> => {\n if (!this.ternauth) {\n throw new Error('TernSecureAuth not initialized');\n }\n await this.ternauth.signOut();\n };\n\n get currentSession(): SignedInSession | null {\n if (!this.ternauth) {\n return null;\n }\n return this.ternauth.currentSession;\n };\n\n onAuthStateChanged(callback: (user: any) => void): () => void {\n if (!this.ternauth) {\n console.warn(\n '[IsoTernSecureAuth] TernAuth not initialized, cannot set up auth state listener',\n );\n return () => {};\n }\n return this.ternauth.onAuthStateChanged(callback);\n }\n\n getRedirectResult = async (): Promise<any> => {\n if (!this.ternauth?.getRedirectResult) {\n throw new Error('TernSecure instance not initialized');\n }\n return this.ternauth.getRedirectResult();\n };\n\n redirectToSignIn = async (options?: SignInRedirectOptions) => {\n if (this.ternauth?.redirectToSignIn) {\n this.ternauth.redirectToSignIn(options);\n }\n };\n\n redirectToSignUp = async (options?: SignUpRedirectOptions) => {\n if (this.ternauth?.redirectToSignUp) {\n this.ternauth.redirectToSignUp();\n }\n };\n\n redirectAfterSignIn = (redirectUrl?: string): void => {\n if (this.ternauth?.redirectAfterSignIn) {\n this.ternauth.redirectAfterSignIn();\n }\n }\n\n redirectAfterSignUp = (redirectUrl?: string): void => {\n if (this.ternauth?.redirectAfterSignUp) {\n this.ternauth.redirectAfterSignUp();\n }\n };\n\n #awaitForTernSecureAuth(): Promise<TernSecureAuthProps> {\n return new Promise<TernSecureAuthProps>(resolve => {\n resolve(this.ternauth);\n });\n }\n\n initialize = async (): Promise<void> => {\n try {\n await this.#awaitForTernSecureAuth();\n } catch (error) {\n console.error('[IsomorphicTernSecure] Failed to initialize TernSecureAuth:', error);\n throw error;\n }\n };\n}\n"],"mappings":"AAAA,OAAS,kBAAkBA,MAA0B,oBACrD,OAAS,0BAAAC,EAAwB,cAAAC,MAAkB,sCACnD,OAAS,mBAAAC,MAAuB,4BAmBhC,MAAMC,EAAe,CACnB,KAAM,qBACN,QAAS,+BACT,YAAa,QAAQ,IAAI,QAC3B,EAEO,SAASC,GAAqB,CACnC,OAAO,OAAO,OAAW,GAC3B,CAMO,MAAMC,CAA4C,CACtC,MACA,QACA,eACT,SAAuC,KACvC,eAAiB,IAAI,IAE7BC,GAAgC,UAChCC,GACAC,GACAC,GACAC,GAAYV,EAAuB,EAEnC,MAAOW,GAEP,IAAI,QAA+B,CACjC,OAAK,KAAK,SAGH,KAAK,SAAS,SAAW,KAAK,SAAS,QAAU,QAAU,WAFzD,KAAKL,EAGhB,CAEA,IAAI,SAAmB,CACrB,OAAO,KAAK,UAAU,SAAW,EACnC,CAEA,IAAI,WAAqB,CACvB,OAAO,KAAK,UAAU,WAAa,EACrC,CAEA,IAAI,sBAAgC,CAClC,OAAO,KAAK,QAAQ,sBAAwB,EAC9C,CAEA,IAAI,QAA4C,CAC9C,GAAI,KAAK,SACP,OAAO,KAAK,SAAS,MAGzB,CAEA,IAAI,QAA4C,CAC9C,GAAI,KAAK,SACP,OAAO,KAAK,SAAS,MAGzB,CAEA,IAAI,MAAO,CACT,GAAI,KAAK,SACP,OAAO,KAAK,SAAS,IAEzB,CAEA,OAAO,oBAAoBM,EAAmC,CAC5D,OACE,CAACR,EAAU,GACX,CAAC,KAAKO,IACLC,EAAQ,gBAAkB,KAAKD,GA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","ternEvents","handleValueOrFn","SDK_METADATA","inBrowser","IsoTernSecureAuth","#status","#apiUrl","#domain","#proxyUrl","#eventBus","#instance","options","key","TernSecureAuth","tern","ternauth","listenerHandlers","listener","args","unsubscribe","params","callback","redirectUrl","#awaitForTernSecureAuth","resolve","error"]}
package/dist/types.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { TernSecureInstanceTree, TernSecureAuthOptions, TernSecureAuth, TernSecureState, TernSecureInstanceTreeOptions, TernSecureConfig } from '@tern-secure/types';
1
+ import { TernSecureInstanceTree, TernSecureAuthOptions, TernSecureAuth, TernSecureStateExtended, TernSecureInstanceTreeOptions, TernSecureConfig } from '@tern-secure/types';
2
2
 
3
3
  declare global {
4
4
  interface Window {
@@ -70,7 +70,7 @@ interface HeadlessUIBrowserConstructor {
70
70
  */
71
71
  type TernSecureProviderPropsOld = IsomorphicTernSecureOptions & {
72
72
  children: React.ReactNode;
73
- initialState?: TernSecureState;
73
+ initialState?: TernSecureStateExtended;
74
74
  loadingComponent?: React.ReactNode;
75
75
  bypassApiKey?: boolean;
76
76
  };
@@ -92,15 +92,15 @@ type IsomorphicTernSecureOptions = TernSecureInstanceTreeOptions & {
92
92
  projectId?: string;
93
93
  ternSecureConfig?: TernSecureConfig;
94
94
  };
95
+ type IsoTernSecureAuthOptions = TernSecureAuthOptions & {
96
+ TernSecureAuth?: TernSecureAuthProps;
97
+ };
95
98
  type TernSecureProviderProps = IsoTernSecureAuthOptions & {
96
99
  children: React.ReactNode;
97
- initialState?: TernSecureState;
100
+ initialState?: TernSecureStateExtended;
98
101
  loadingComponent?: React.ReactNode;
99
102
  bypassApiKey?: boolean;
100
103
  };
101
104
  type TernSecureAuthProps = TernSecureAuth | undefined | null;
102
- type IsoTernSecureAuthOptions = TernSecureAuthOptions & {
103
- TernSecureAuth?: TernSecureAuthProps;
104
- };
105
105
 
106
106
  export { type AuthError, type Browser, type BrowserConstructor, type ConfigValidationResult, type HeadlessUIBrowser, type HeadlessUIBrowserConstructor, type IsoTernSecureAuthOptions, type IsomorphicTernSecureOptions, type SignInResponse, type TernSecureAuthProps, type TernSecureAuthState, type TernSecureProps, type TernSecureProviderProps, type TernSecureProviderPropsOld, type TernSecureUserData, type initialState, isSignInResponse };
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { TernSecureInstanceTree, TernSecureAuthOptions, TernSecureAuth, TernSecureState, TernSecureInstanceTreeOptions, TernSecureConfig } from '@tern-secure/types';
1
+ import { TernSecureInstanceTree, TernSecureAuthOptions, TernSecureAuth, TernSecureStateExtended, TernSecureInstanceTreeOptions, TernSecureConfig } from '@tern-secure/types';
2
2
 
3
3
  declare global {
4
4
  interface Window {
@@ -70,7 +70,7 @@ interface HeadlessUIBrowserConstructor {
70
70
  */
71
71
  type TernSecureProviderPropsOld = IsomorphicTernSecureOptions & {
72
72
  children: React.ReactNode;
73
- initialState?: TernSecureState;
73
+ initialState?: TernSecureStateExtended;
74
74
  loadingComponent?: React.ReactNode;
75
75
  bypassApiKey?: boolean;
76
76
  };
@@ -92,15 +92,15 @@ type IsomorphicTernSecureOptions = TernSecureInstanceTreeOptions & {
92
92
  projectId?: string;
93
93
  ternSecureConfig?: TernSecureConfig;
94
94
  };
95
+ type IsoTernSecureAuthOptions = TernSecureAuthOptions & {
96
+ TernSecureAuth?: TernSecureAuthProps;
97
+ };
95
98
  type TernSecureProviderProps = IsoTernSecureAuthOptions & {
96
99
  children: React.ReactNode;
97
- initialState?: TernSecureState;
100
+ initialState?: TernSecureStateExtended;
98
101
  loadingComponent?: React.ReactNode;
99
102
  bypassApiKey?: boolean;
100
103
  };
101
104
  type TernSecureAuthProps = TernSecureAuth | undefined | null;
102
- type IsoTernSecureAuthOptions = TernSecureAuthOptions & {
103
- TernSecureAuth?: TernSecureAuthProps;
104
- };
105
105
 
106
106
  export { type AuthError, type Browser, type BrowserConstructor, type ConfigValidationResult, type HeadlessUIBrowser, type HeadlessUIBrowserConstructor, type IsoTernSecureAuthOptions, type IsomorphicTernSecureOptions, type SignInResponse, type TernSecureAuthProps, type TernSecureAuthState, type TernSecureProps, type TernSecureProviderProps, type TernSecureProviderPropsOld, type TernSecureUserData, type initialState, isSignInResponse };
package/dist/types.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var u=(e,r)=>{for(var t in r)o(e,t,{get:r[t],enumerable:!0})},p=(e,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of a(r))!c.call(e,n)&&n!==t&&o(e,n,{get:()=>r[n],enumerable:!(s=i(r,n))||s.enumerable});return e};var l=e=>p(o({},"__esModule",{value:!0}),e);var S={};u(S,{isSignInResponse:()=>d});module.exports=l(S);function d(e){return typeof e=="object"&&"success"in e&&typeof e.success=="boolean"}0&&(module.exports={isSignInResponse});
1
+ "use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var u=(e,r)=>{for(var t in r)o(e,t,{get:r[t],enumerable:!0})},p=(e,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of a(r))!c.call(e,n)&&n!==t&&o(e,n,{get:()=>r[n],enumerable:!(s=i(r,n))||s.enumerable});return e};var d=e=>p(o({},"__esModule",{value:!0}),e);var S={};u(S,{isSignInResponse:()=>l});module.exports=d(S);function l(e){return typeof e=="object"&&"success"in e&&typeof e.success=="boolean"}0&&(module.exports={isSignInResponse});
2
2
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n TernSecureAuth,\n TernSecureAuthOptions,\n TernSecureConfig,\n TernSecureInstanceTree,\n TernSecureInstanceTreeOptions,\n TernSecureState,\n} from \"@tern-secure/types\";\n\ndeclare global {\n interface Window {\n apiKey?: string;\n customDomain?: TernSecureInstanceTree[\"customDomain\"];\n proxyUrl?: TernSecureInstanceTree[\"proxyUrl\"];\n projectId?: TernSecureInstanceTree[\"projectId\"];\n }\n}\n\n/**\n * TernSecure User\n */\n//export type TernSecureUser = FirebaseUser\n\nexport type TernSecureUserData = {\n uid: string;\n email: string | null;\n emailVerified?: boolean;\n displayName?: string | null;\n};\n\n/**\n * TernSecure Firebase configuration interface\n * Extends Firebase's base configuration options\n */\n{\n /*export interface TernSecureConfig {\n apiKey: string\n authDomain: string\n projectId: string\n storageBucket: string\n messagingSenderId: string\n appId: string\n measurementId?: string\n}*/\n}\n\nexport interface SignInResponse {\n success: boolean;\n message?: string;\n error?: any | undefined;\n user?: any; // Consider a more specific user type if possible, e.g., TernSecureUserData | null\n}\n\nexport interface AuthError extends Error {\n code?: any | string; // Allow string for other potential errors, or be stricter with just AuthErrorCode\n message: string;\n response?: SignInResponse;\n}\n\nexport function isSignInResponse(value: any): value is SignInResponse {\n return (\n typeof value === \"object\" &&\n \"success\" in value &&\n typeof value.success === \"boolean\"\n );\n}\n\n/**\n * Configuration validation result\n */\nexport interface ConfigValidationResult {\n isValid: boolean;\n errors: string[];\n //config: TernSecureConfig\n}\n\n/**\n * TernSecureAuthState\n */\n\nexport type TernSecureAuthState = {\n userId: string | null;\n isLoaded: boolean;\n error: Error | null;\n isValid: boolean;\n isVerified: boolean;\n isAuthenticated: boolean;\n token: any | null;\n email: string | null;\n status: \"loading\" | \"authenticated\" | \"unauthenticated\" | \"unverified\";\n requiresVerification: boolean;\n};\n\n/**\n * TernSecureInitialState\n */\n\nexport type initialState = {\n userId: string | null;\n sessionId: string | undefined;\n};\n\nexport interface BrowserConstructor {\n new (customDomain?: string): Browser;\n}\n\nexport interface HeadlessUIBrowserConstructor {\n new (customDomain?: string): HeadlessUIBrowser;\n}\n/**\n * TernSecureProviderProps\n * @param interface\n */\n\nexport type TernSecureProviderPropsOld = IsomorphicTernSecureOptions & {\n children: React.ReactNode;\n initialState?: TernSecureState;\n loadingComponent?: React.ReactNode;\n bypassApiKey?: boolean;\n};\n\nexport interface HeadlessUIBrowser extends TernSecureInstanceTree {\n load: (options?: TernSecureInstanceTreeOptions) => Promise<void>;\n setTernAuth: (provider: any) => void;\n}\n\nexport interface Browser extends HeadlessUIBrowser {\n onComponentsReady: Promise<void>;\n components: any;\n}\n\nexport type TernSecureProps =\n | HeadlessUIBrowserConstructor\n | HeadlessUIBrowser\n | Browser\n | BrowserConstructor\n | null\n | undefined;\n\nexport type IsomorphicTernSecureOptions = TernSecureInstanceTreeOptions & {\n TernSecure?: TernSecureProps;\n ternUIVersion?: string;\n apiKey?: string;\n customDomain?: string;\n proxyUrl?: string;\n projectId?: string;\n ternSecureConfig?: TernSecureConfig;\n};\n\nexport type TernSecureProviderProps = IsoTernSecureAuthOptions & {\n children: React.ReactNode;\n initialState?: TernSecureState;\n loadingComponent?: React.ReactNode;\n bypassApiKey?: boolean;\n};\n\nexport type TernSecureAuthProps = TernSecureAuth | undefined | null;\n\nexport type IsoTernSecureAuthOptions = TernSecureAuthOptions & {\n TernSecureAuth?: TernSecureAuthProps;\n};\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GA2DO,SAASE,EAAiBE,EAAqC,CACpE,OACE,OAAOA,GAAU,UACjB,YAAaA,GACb,OAAOA,EAAM,SAAY,SAE7B","names":["types_exports","__export","isSignInResponse","__toCommonJS","value"]}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n TernSecureAuth,\n TernSecureAuthOptions,\n TernSecureConfig,\n TernSecureInstanceTree,\n TernSecureInstanceTreeOptions,\n TernSecureStateExtended,\n} from \"@tern-secure/types\";\n\ndeclare global {\n interface Window {\n apiKey?: string;\n customDomain?: TernSecureInstanceTree[\"customDomain\"];\n proxyUrl?: TernSecureInstanceTree[\"proxyUrl\"];\n projectId?: TernSecureInstanceTree[\"projectId\"];\n }\n}\n\n/**\n * TernSecure User\n */\n//export type TernSecureUser = FirebaseUser\n\nexport type TernSecureUserData = {\n uid: string;\n email: string | null;\n emailVerified?: boolean;\n displayName?: string | null;\n};\n\n/**\n * TernSecure Firebase configuration interface\n * Extends Firebase's base configuration options\n */\n{\n /*export interface TernSecureConfig {\n apiKey: string\n authDomain: string\n projectId: string\n storageBucket: string\n messagingSenderId: string\n appId: string\n measurementId?: string\n}*/\n}\n\nexport interface SignInResponse {\n success: boolean;\n message?: string;\n error?: any | undefined;\n user?: any; // Consider a more specific user type if possible, e.g., TernSecureUserData | null\n}\n\nexport interface AuthError extends Error {\n code?: any | string; // Allow string for other potential errors, or be stricter with just AuthErrorCode\n message: string;\n response?: SignInResponse;\n}\n\nexport function isSignInResponse(value: any): value is SignInResponse {\n return (\n typeof value === \"object\" &&\n \"success\" in value &&\n typeof value.success === \"boolean\"\n );\n}\n\n/**\n * Configuration validation result\n */\nexport interface ConfigValidationResult {\n isValid: boolean;\n errors: string[];\n //config: TernSecureConfig\n}\n\n/**\n * TernSecureAuthState\n */\n\nexport type TernSecureAuthState = {\n userId: string | null;\n isLoaded: boolean;\n error: Error | null;\n isValid: boolean;\n isVerified: boolean;\n isAuthenticated: boolean;\n token: any | null;\n email: string | null;\n status: \"loading\" | \"authenticated\" | \"unauthenticated\" | \"unverified\";\n requiresVerification: boolean;\n};\n\n/**\n * TernSecureInitialState\n */\n\nexport type initialState = {\n userId: string | null;\n sessionId: string | undefined;\n};\n\nexport interface BrowserConstructor {\n new (customDomain?: string): Browser;\n}\n\nexport interface HeadlessUIBrowserConstructor {\n new (customDomain?: string): HeadlessUIBrowser;\n}\n/**\n * TernSecureProviderProps\n * @param interface\n */\n\nexport type TernSecureProviderPropsOld = IsomorphicTernSecureOptions & {\n children: React.ReactNode;\n initialState?: TernSecureStateExtended;\n loadingComponent?: React.ReactNode;\n bypassApiKey?: boolean;\n};\n\nexport interface HeadlessUIBrowser extends TernSecureInstanceTree {\n load: (options?: TernSecureInstanceTreeOptions) => Promise<void>;\n setTernAuth: (provider: any) => void;\n}\n\nexport interface Browser extends HeadlessUIBrowser {\n onComponentsReady: Promise<void>;\n components: any;\n}\n\nexport type TernSecureProps =\n | HeadlessUIBrowserConstructor\n | HeadlessUIBrowser\n | Browser\n | BrowserConstructor\n | null\n | undefined;\n\nexport type IsomorphicTernSecureOptions = TernSecureInstanceTreeOptions & {\n TernSecure?: TernSecureProps;\n ternUIVersion?: string;\n apiKey?: string;\n customDomain?: string;\n proxyUrl?: string;\n projectId?: string;\n ternSecureConfig?: TernSecureConfig;\n};\n\nexport type IsoTernSecureAuthOptions = TernSecureAuthOptions & {\n TernSecureAuth?: TernSecureAuthProps;\n};\n\nexport type TernSecureProviderProps = IsoTernSecureAuthOptions & {\n children: React.ReactNode;\n initialState?: TernSecureStateExtended;\n loadingComponent?: React.ReactNode;\n bypassApiKey?: boolean;\n};\n\nexport type TernSecureAuthProps = TernSecureAuth | undefined | null;\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GA2DO,SAASE,EAAiBE,EAAqC,CACpE,OACE,OAAOA,GAAU,UACjB,YAAaA,GACb,OAAOA,EAAM,SAAY,SAE7B","names":["types_exports","__export","isSignInResponse","__toCommonJS","value"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n TernSecureAuth,\n TernSecureAuthOptions,\n TernSecureConfig,\n TernSecureInstanceTree,\n TernSecureInstanceTreeOptions,\n TernSecureState,\n} from \"@tern-secure/types\";\n\ndeclare global {\n interface Window {\n apiKey?: string;\n customDomain?: TernSecureInstanceTree[\"customDomain\"];\n proxyUrl?: TernSecureInstanceTree[\"proxyUrl\"];\n projectId?: TernSecureInstanceTree[\"projectId\"];\n }\n}\n\n/**\n * TernSecure User\n */\n//export type TernSecureUser = FirebaseUser\n\nexport type TernSecureUserData = {\n uid: string;\n email: string | null;\n emailVerified?: boolean;\n displayName?: string | null;\n};\n\n/**\n * TernSecure Firebase configuration interface\n * Extends Firebase's base configuration options\n */\n{\n /*export interface TernSecureConfig {\n apiKey: string\n authDomain: string\n projectId: string\n storageBucket: string\n messagingSenderId: string\n appId: string\n measurementId?: string\n}*/\n}\n\nexport interface SignInResponse {\n success: boolean;\n message?: string;\n error?: any | undefined;\n user?: any; // Consider a more specific user type if possible, e.g., TernSecureUserData | null\n}\n\nexport interface AuthError extends Error {\n code?: any | string; // Allow string for other potential errors, or be stricter with just AuthErrorCode\n message: string;\n response?: SignInResponse;\n}\n\nexport function isSignInResponse(value: any): value is SignInResponse {\n return (\n typeof value === \"object\" &&\n \"success\" in value &&\n typeof value.success === \"boolean\"\n );\n}\n\n/**\n * Configuration validation result\n */\nexport interface ConfigValidationResult {\n isValid: boolean;\n errors: string[];\n //config: TernSecureConfig\n}\n\n/**\n * TernSecureAuthState\n */\n\nexport type TernSecureAuthState = {\n userId: string | null;\n isLoaded: boolean;\n error: Error | null;\n isValid: boolean;\n isVerified: boolean;\n isAuthenticated: boolean;\n token: any | null;\n email: string | null;\n status: \"loading\" | \"authenticated\" | \"unauthenticated\" | \"unverified\";\n requiresVerification: boolean;\n};\n\n/**\n * TernSecureInitialState\n */\n\nexport type initialState = {\n userId: string | null;\n sessionId: string | undefined;\n};\n\nexport interface BrowserConstructor {\n new (customDomain?: string): Browser;\n}\n\nexport interface HeadlessUIBrowserConstructor {\n new (customDomain?: string): HeadlessUIBrowser;\n}\n/**\n * TernSecureProviderProps\n * @param interface\n */\n\nexport type TernSecureProviderPropsOld = IsomorphicTernSecureOptions & {\n children: React.ReactNode;\n initialState?: TernSecureState;\n loadingComponent?: React.ReactNode;\n bypassApiKey?: boolean;\n};\n\nexport interface HeadlessUIBrowser extends TernSecureInstanceTree {\n load: (options?: TernSecureInstanceTreeOptions) => Promise<void>;\n setTernAuth: (provider: any) => void;\n}\n\nexport interface Browser extends HeadlessUIBrowser {\n onComponentsReady: Promise<void>;\n components: any;\n}\n\nexport type TernSecureProps =\n | HeadlessUIBrowserConstructor\n | HeadlessUIBrowser\n | Browser\n | BrowserConstructor\n | null\n | undefined;\n\nexport type IsomorphicTernSecureOptions = TernSecureInstanceTreeOptions & {\n TernSecure?: TernSecureProps;\n ternUIVersion?: string;\n apiKey?: string;\n customDomain?: string;\n proxyUrl?: string;\n projectId?: string;\n ternSecureConfig?: TernSecureConfig;\n};\n\nexport type TernSecureProviderProps = IsoTernSecureAuthOptions & {\n children: React.ReactNode;\n initialState?: TernSecureState;\n loadingComponent?: React.ReactNode;\n bypassApiKey?: boolean;\n};\n\nexport type TernSecureAuthProps = TernSecureAuth | undefined | null;\n\nexport type IsoTernSecureAuthOptions = TernSecureAuthOptions & {\n TernSecureAuth?: TernSecureAuthProps;\n};\n"],"mappings":"AA2DO,SAASA,EAAiBC,EAAqC,CACpE,OACE,OAAOA,GAAU,UACjB,YAAaA,GACb,OAAOA,EAAM,SAAY,SAE7B","names":["isSignInResponse","value"]}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n TernSecureAuth,\n TernSecureAuthOptions,\n TernSecureConfig,\n TernSecureInstanceTree,\n TernSecureInstanceTreeOptions,\n TernSecureStateExtended,\n} from \"@tern-secure/types\";\n\ndeclare global {\n interface Window {\n apiKey?: string;\n customDomain?: TernSecureInstanceTree[\"customDomain\"];\n proxyUrl?: TernSecureInstanceTree[\"proxyUrl\"];\n projectId?: TernSecureInstanceTree[\"projectId\"];\n }\n}\n\n/**\n * TernSecure User\n */\n//export type TernSecureUser = FirebaseUser\n\nexport type TernSecureUserData = {\n uid: string;\n email: string | null;\n emailVerified?: boolean;\n displayName?: string | null;\n};\n\n/**\n * TernSecure Firebase configuration interface\n * Extends Firebase's base configuration options\n */\n{\n /*export interface TernSecureConfig {\n apiKey: string\n authDomain: string\n projectId: string\n storageBucket: string\n messagingSenderId: string\n appId: string\n measurementId?: string\n}*/\n}\n\nexport interface SignInResponse {\n success: boolean;\n message?: string;\n error?: any | undefined;\n user?: any; // Consider a more specific user type if possible, e.g., TernSecureUserData | null\n}\n\nexport interface AuthError extends Error {\n code?: any | string; // Allow string for other potential errors, or be stricter with just AuthErrorCode\n message: string;\n response?: SignInResponse;\n}\n\nexport function isSignInResponse(value: any): value is SignInResponse {\n return (\n typeof value === \"object\" &&\n \"success\" in value &&\n typeof value.success === \"boolean\"\n );\n}\n\n/**\n * Configuration validation result\n */\nexport interface ConfigValidationResult {\n isValid: boolean;\n errors: string[];\n //config: TernSecureConfig\n}\n\n/**\n * TernSecureAuthState\n */\n\nexport type TernSecureAuthState = {\n userId: string | null;\n isLoaded: boolean;\n error: Error | null;\n isValid: boolean;\n isVerified: boolean;\n isAuthenticated: boolean;\n token: any | null;\n email: string | null;\n status: \"loading\" | \"authenticated\" | \"unauthenticated\" | \"unverified\";\n requiresVerification: boolean;\n};\n\n/**\n * TernSecureInitialState\n */\n\nexport type initialState = {\n userId: string | null;\n sessionId: string | undefined;\n};\n\nexport interface BrowserConstructor {\n new (customDomain?: string): Browser;\n}\n\nexport interface HeadlessUIBrowserConstructor {\n new (customDomain?: string): HeadlessUIBrowser;\n}\n/**\n * TernSecureProviderProps\n * @param interface\n */\n\nexport type TernSecureProviderPropsOld = IsomorphicTernSecureOptions & {\n children: React.ReactNode;\n initialState?: TernSecureStateExtended;\n loadingComponent?: React.ReactNode;\n bypassApiKey?: boolean;\n};\n\nexport interface HeadlessUIBrowser extends TernSecureInstanceTree {\n load: (options?: TernSecureInstanceTreeOptions) => Promise<void>;\n setTernAuth: (provider: any) => void;\n}\n\nexport interface Browser extends HeadlessUIBrowser {\n onComponentsReady: Promise<void>;\n components: any;\n}\n\nexport type TernSecureProps =\n | HeadlessUIBrowserConstructor\n | HeadlessUIBrowser\n | Browser\n | BrowserConstructor\n | null\n | undefined;\n\nexport type IsomorphicTernSecureOptions = TernSecureInstanceTreeOptions & {\n TernSecure?: TernSecureProps;\n ternUIVersion?: string;\n apiKey?: string;\n customDomain?: string;\n proxyUrl?: string;\n projectId?: string;\n ternSecureConfig?: TernSecureConfig;\n};\n\nexport type IsoTernSecureAuthOptions = TernSecureAuthOptions & {\n TernSecureAuth?: TernSecureAuthProps;\n};\n\nexport type TernSecureProviderProps = IsoTernSecureAuthOptions & {\n children: React.ReactNode;\n initialState?: TernSecureStateExtended;\n loadingComponent?: React.ReactNode;\n bypassApiKey?: boolean;\n};\n\nexport type TernSecureAuthProps = TernSecureAuth | undefined | null;\n"],"mappings":"AA2DO,SAASA,EAAiBC,EAAqC,CACpE,OACE,OAAOA,GAAU,UACjB,YAAaA,GACb,OAAOA,EAAM,SAAY,SAE7B","names":["isSignInResponse","value"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tern-secure/react",
3
- "version": "1.2.0-canary.v20251008131428",
3
+ "version": "1.2.0-canary.v20251019190011",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/TernSecure/auth.git",
@@ -36,9 +36,9 @@
36
36
  "tailwind-merge": "^2.5.5",
37
37
  "tailwindcss-animate": "^1.0.7",
38
38
  "tslib": "2.4.1",
39
- "@tern-secure/shared": "1.3.0-canary.v20251008131428",
40
- "@tern-secure/auth": "1.1.0-canary.v20251008131428",
41
- "@tern-secure/types": "1.1.0-canary.v20251008131428"
39
+ "@tern-secure/auth": "1.1.0-canary.v20251019190011",
40
+ "@tern-secure/shared": "1.3.0-canary.v20251019190011",
41
+ "@tern-secure/types": "1.1.0-canary.v20251019190011"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@tailwindcss/cli": "^4.1.6",