@tern-secure/nextjs 3.1.98 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39,28 +39,29 @@ var import_client_init = require("../../utils/client-init");
39
39
  var import_auth = require("firebase/auth");
40
40
  var import_TernSecureCtx = require("../../boundary/TernSecureCtx");
41
41
  const AuthStateContext = import_react.default.createContext(null);
42
- const auth = (0, import_client_init.TernSecureAuth)();
43
42
  function TernSecureClientProvider({
44
- children
43
+ children,
44
+ Loading = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: "Loading..." })
45
45
  }) {
46
46
  const [authState, setAuthState] = (0, import_react.useState)({
47
47
  userId: null,
48
- loading: true,
48
+ isLoaded: true,
49
49
  error: null,
50
50
  isSignedIn: false
51
51
  });
52
52
  (0, import_react.useEffect)(() => {
53
+ const auth = (0, import_client_init.TernSecureAuth)();
53
54
  const unsubscribe = (0, import_auth.onAuthStateChanged)(auth, (user) => {
54
55
  if (user) {
55
56
  setAuthState({
56
- loading: false,
57
+ isLoaded: false,
57
58
  isSignedIn: true,
58
59
  userId: user.uid,
59
60
  error: null
60
61
  });
61
62
  } else {
62
63
  setAuthState({
63
- loading: false,
64
+ isLoaded: false,
64
65
  isSignedIn: false,
65
66
  userId: null,
66
67
  error: null
@@ -69,7 +70,8 @@ function TernSecureClientProvider({
69
70
  });
70
71
  return () => unsubscribe();
71
72
  }, []);
72
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TernSecureCtx.TernSecureCtxProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AuthStateContext.Provider, { value: authState, children: authState.loading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: "Loading..." }) : children }) });
73
+ const contextValue = (0, import_react.useMemo)(() => authState, [authState]);
74
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TernSecureCtx.TernSecureCtxProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AuthStateContext.Provider, { value: contextValue, children: authState.isLoaded ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {}) : children }) });
73
75
  }
74
76
  // Annotate the CommonJS export names for ESM import in node:
75
77
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/app-router/client/TernSecureProvider.tsx"],"sourcesContent":["'use client'\r\n\r\nimport React, { useState, useEffect } from 'react'\r\nimport { TernSecureAuth } from '../../utils/client-init'\r\nimport { onAuthStateChanged } from \"firebase/auth\"\r\nimport { TernSecureCtxProvider } from '../../boundary/TernSecureCtx'\r\n\r\ninterface TernSecureState {\r\n userId: string | null\r\n loading: boolean\r\n error: string | null\r\n isSignedIn: boolean\r\n}\r\n\r\nexport const AuthStateContext = React.createContext<TernSecureState | null>(null)\r\n\r\nconst auth = TernSecureAuth();\r\n\r\nexport function TernSecureClientProvider({ \r\n children\r\n}: { \r\n children: React.ReactNode\r\n}) {\r\n const [authState, setAuthState] = useState<TernSecureState>({\r\n userId: null,\r\n loading: true,\r\n error: null,\r\n isSignedIn: false\r\n })\r\n\r\nuseEffect(() => {\r\n const unsubscribe = onAuthStateChanged(auth, (user) => {\r\n if (user) {\r\n setAuthState({\r\n loading: false,\r\n isSignedIn: true,\r\n userId: user.uid,\r\n error: null\r\n })\r\n } else {\r\n setAuthState({\r\n loading: false,\r\n isSignedIn: false,\r\n userId: null,\r\n error: null\r\n })\r\n }\r\n })\r\n \r\n return () => unsubscribe()\r\n }, [])\r\n\r\n\r\n return (\r\n <TernSecureCtxProvider>\r\n <AuthStateContext.Provider value={authState}>\r\n {authState.loading ? <div>Loading...</div> : children}\r\n </AuthStateContext.Provider>\r\n </TernSecureCtxProvider>\r\n )\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwD2B;AAtD3B,mBAA2C;AAC3C,yBAA+B;AAC/B,kBAAmC;AACnC,2BAAsC;AAS/B,MAAM,mBAAmB,aAAAA,QAAM,cAAsC,IAAI;AAEhF,MAAM,WAAO,mCAAe;AAErB,SAAS,yBAAyB;AAAA,EACvC;AACF,GAEI;AACF,QAAM,CAAC,WAAW,YAAY,QAAI,uBAA0B;AAAA,IAC1D,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,OAAO;AAAA,IACP,YAAY;AAAA,EACd,CAAC;AAEH,8BAAU,MAAM;AACZ,UAAM,kBAAc,gCAAmB,MAAM,CAAC,SAAS;AACrD,UAAI,MAAM;AACR,qBAAa;AAAA,UACX,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,QAAQ,KAAK;AAAA,UACb,OAAO;AAAA,QACT,CAAC;AAAA,MACH,OAAO;AACL,qBAAa;AAAA,UACX,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,QAAQ;AAAA,UACR,OAAO;AAAA,QACT,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAED,WAAO,MAAM,YAAY;AAAA,EAC3B,GAAG,CAAC,CAAC;AAGL,SACE,4CAAC,8CACC,sDAAC,iBAAiB,UAAjB,EAA0B,OAAO,WACjC,oBAAU,UAAU,4CAAC,SAAI,wBAAU,IAAS,UAC7C,GACF;AAEJ;","names":["React"]}
1
+ {"version":3,"sources":["../../../../src/app-router/client/TernSecureProvider.tsx"],"sourcesContent":["'use client'\r\n\r\nimport React, { useState, useEffect, useMemo} from 'react'\r\nimport { TernSecureAuth } from '../../utils/client-init'\r\nimport { onAuthStateChanged } from \"firebase/auth\"\r\nimport { TernSecureCtxProvider } from '../../boundary/TernSecureCtx'\r\n\r\ninterface TernSecureState {\r\n userId: string | null\r\n isLoaded: boolean\r\n error: string | null\r\n isSignedIn: boolean\r\n}\r\n\r\nexport const AuthStateContext = React.createContext<TernSecureState | null>(null)\r\n\r\nexport function TernSecureClientProvider({ \r\n children,\r\n Loading = () => <div>Loading...</div>\r\n}: { \r\n children: React.ReactNode\r\n Loading?: React.ComponentType\r\n}) {\r\n const [authState, setAuthState] = useState<TernSecureState>({\r\n userId: null,\r\n isLoaded: true,\r\n error: null,\r\n isSignedIn: false\r\n })\r\n\r\nuseEffect(() => {\r\n const auth = TernSecureAuth();\r\n const unsubscribe = onAuthStateChanged(auth, (user) => {\r\n if (user) {\r\n setAuthState({\r\n isLoaded: false,\r\n isSignedIn: true,\r\n userId: user.uid,\r\n error: null\r\n })\r\n } else {\r\n setAuthState({\r\n isLoaded: false,\r\n isSignedIn: false,\r\n userId: null,\r\n error: null\r\n })\r\n }\r\n })\r\n \r\n return () => unsubscribe()\r\n }, [])\r\n\r\n const contextValue = useMemo(() => authState, [authState])\r\n\r\n return (\r\n <TernSecureCtxProvider>\r\n <AuthStateContext.Provider value={contextValue}>\r\n {authState.isLoaded ? <Loading /> : children}\r\n </AuthStateContext.Provider>\r\n </TernSecureCtxProvider>\r\n )\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBkB;AAhBlB,mBAAmD;AACnD,yBAA+B;AAC/B,kBAAmC;AACnC,2BAAsC;AAS/B,MAAM,mBAAmB,aAAAA,QAAM,cAAsC,IAAI;AAEzE,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA,UAAU,MAAM,4CAAC,SAAI,wBAAU;AACjC,GAGI;AACF,QAAM,CAAC,WAAW,YAAY,QAAI,uBAA0B;AAAA,IAC1D,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,OAAO;AAAA,IACP,YAAY;AAAA,EACd,CAAC;AAEH,8BAAU,MAAM;AACd,UAAM,WAAO,mCAAe;AAC1B,UAAM,kBAAc,gCAAmB,MAAM,CAAC,SAAS;AACrD,UAAI,MAAM;AACR,qBAAa;AAAA,UACX,UAAU;AAAA,UACV,YAAY;AAAA,UACZ,QAAQ,KAAK;AAAA,UACb,OAAO;AAAA,QACT,CAAC;AAAA,MACH,OAAO;AACL,qBAAa;AAAA,UACX,UAAU;AAAA,UACV,YAAY;AAAA,UACZ,QAAQ;AAAA,UACR,OAAO;AAAA,QACT,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAED,WAAO,MAAM,YAAY;AAAA,EAC3B,GAAG,CAAC,CAAC;AAEL,QAAM,mBAAe,sBAAQ,MAAM,WAAW,CAAC,SAAS,CAAC;AAEzD,SACE,4CAAC,8CACC,sDAAC,iBAAiB,UAAjB,EAA0B,OAAO,cACjC,oBAAU,WAAW,4CAAC,WAAQ,IAAK,UACpC,GACF;AAEJ;","names":["React"]}
@@ -23,9 +23,6 @@ __export(TernSecureServerProvider_exports, {
23
23
  module.exports = __toCommonJS(TernSecureServerProvider_exports);
24
24
  var import_jsx_runtime = require("react/jsx-runtime");
25
25
  var import_TernSecureProvider = require("../client/TernSecureProvider");
26
- function TernSecureLoadingFallback() {
27
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only", children: "Loading authentication..." }) });
28
- }
29
26
  function TernSecureProvider({ children }) {
30
27
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TernSecureProvider.TernSecureClientProvider, { children });
31
28
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/app-router/server/TernSecureServerProvider.tsx"],"sourcesContent":["import React, { Suspense } from \"react\"\r\nimport { TernSecureClientProvider } from \"../client/TernSecureProvider\"\r\n\r\n\r\n\r\n// Loading fallback component\r\nfunction TernSecureLoadingFallback() {\r\n return (\r\n <div>\r\n <span className=\"sr-only\">Loading authentication...</span>\r\n </div>\r\n )\r\n}\r\n/**\r\n * Root Provider for TernSecure\r\n * Use this in your Next.js App Router root layout\r\n * Automatically handles client/server boundary and authentication state\r\n * \r\n * @example\r\n * // app/layout.tsx\r\n * import { TernSecureProvider } from '@tern/secure'\r\n * \r\n * export default function RootLayout({ children }) {\r\n * return (\r\n * <html>\r\n * <body>\r\n * <TernSecureProvider>\r\n * {children}\r\n * </TernSecureProvider>\r\n * </body>\r\n * </html>\r\n * )\r\n * }\r\n */\r\nexport function TernSecureProvider({ children }: { children: React.ReactNode }) {\r\n return (\r\n <TernSecureClientProvider>\r\n \r\n {children}\r\n \r\n </TernSecureClientProvider>\r\n )\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASM;AARN,gCAAyC;AAKzC,SAAS,4BAA4B;AACnC,SACE,4CAAC,SACC,sDAAC,UAAK,WAAU,WAAU,uCAAyB,GACrD;AAEJ;AAsBO,SAAS,mBAAmB,EAAE,SAAS,GAAkC;AAC9E,SACI,4CAAC,sDAEI,UAEL;AAEN;","names":[]}
1
+ {"version":3,"sources":["../../../../src/app-router/server/TernSecureServerProvider.tsx"],"sourcesContent":["import React from \"react\"\r\nimport { TernSecureClientProvider } from \"../client/TernSecureProvider\"\r\n\r\n\r\n\r\n// Loading fallback component\r\n/*function TernSecureLoadingFallback() {\r\n return (\r\n <div>\r\n <span className=\"sr-only\">Loading authentication...</span>\r\n </div>\r\n )\r\n}*/\r\n/**\r\n * Root Provider for TernSecure\r\n * Use this in your Next.js App Router root layout\r\n * Automatically handles client/server boundary and authentication state\r\n * \r\n * @example\r\n * // app/layout.tsx\r\n * import { TernSecureProvider } from '@tern/secure'\r\n * \r\n * export default function RootLayout({ children }) {\r\n * return (\r\n * <html>\r\n * <body>\r\n * <TernSecureProvider>\r\n * {children}\r\n * </TernSecureProvider>\r\n * </body>\r\n * </html>\r\n * )\r\n * }\r\n */\r\nexport function TernSecureProvider({ children }: { children: React.ReactNode }) {\r\n return (\r\n <TernSecureClientProvider>\r\n {children}\r\n </TernSecureClientProvider>\r\n )\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoCM;AAnCN,gCAAyC;AAiClC,SAAS,mBAAmB,EAAE,SAAS,GAAkC;AAC9E,SACI,4CAAC,sDACI,UACL;AAEN;","names":[]}
@@ -33,7 +33,7 @@ function useAuth() {
33
33
  }
34
34
  return {
35
35
  userId: authState.userId,
36
- loading: authState.loading,
36
+ loading: authState.isLoaded,
37
37
  error: authState.error,
38
38
  isSignedIn: authState.isSignedIn
39
39
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/boundary/hooks/useAuth.ts"],"sourcesContent":["'use client'\r\n\r\nimport { useContext } from 'react'\r\nimport { useInternalContext } from '../../boundary/TernSecureCtx'\r\nimport { AuthStateContext } from '../../app-router/client/TernSecureProvider'\r\n\r\nexport function useAuth(){\r\n // Verify we're within the provider boundary\r\n useInternalContext('useAuth')\r\n \r\n // Get the auth state from the AuthStateContext\r\n const authState = useContext(AuthStateContext)\r\n if (!authState) {\r\n throw new Error('Auth state not found')\r\n }\r\n\r\n\r\n return {\r\n userId: authState.userId,\r\n loading: authState.loading,\r\n error: authState.error,\r\n isSignedIn: authState.isSignedIn\r\n }\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA2B;AAC3B,2BAAmC;AACnC,gCAAiC;AAE1B,SAAS,UAAS;AAEvB,+CAAmB,SAAS;AAG5B,QAAM,gBAAY,yBAAW,0CAAgB;AAC7C,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,sBAAsB;AAAA,EACxC;AAGE,SAAO;AAAA,IACP,QAAQ,UAAU;AAAA,IAClB,SAAS,UAAU;AAAA,IACnB,OAAO,UAAU;AAAA,IACjB,YAAY,UAAU;AAAA,EACxB;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/boundary/hooks/useAuth.ts"],"sourcesContent":["'use client'\r\n\r\nimport { useContext } from 'react'\r\nimport { useInternalContext } from '../../boundary/TernSecureCtx'\r\nimport { AuthStateContext } from '../../app-router/client/TernSecureProvider'\r\n\r\nexport function useAuth(){\r\n // Verify we're within the provider boundary\r\n useInternalContext('useAuth')\r\n \r\n // Get the auth state from the AuthStateContext\r\n const authState = useContext(AuthStateContext)\r\n if (!authState) {\r\n throw new Error('Auth state not found')\r\n }\r\n\r\n\r\n return {\r\n userId: authState.userId,\r\n loading: authState.isLoaded,\r\n error: authState.error,\r\n isSignedIn: authState.isSignedIn\r\n }\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA2B;AAC3B,2BAAmC;AACnC,gCAAiC;AAE1B,SAAS,UAAS;AAEvB,+CAAmB,SAAS;AAG5B,QAAM,gBAAY,yBAAW,0CAAgB;AAC7C,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,sBAAsB;AAAA,EACxC;AAGE,SAAO;AAAA,IACP,QAAQ,UAAU;AAAA,IAClB,SAAS,UAAU;AAAA,IACnB,OAAO,UAAU;AAAA,IACjB,YAAY,UAAU;AAAA,EACxB;AACF;","names":[]}
@@ -1,32 +1,33 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
- import React, { useState, useEffect } from "react";
3
+ import React, { useState, useEffect, useMemo } from "react";
4
4
  import { TernSecureAuth } from "../../utils/client-init";
5
5
  import { onAuthStateChanged } from "firebase/auth";
6
6
  import { TernSecureCtxProvider } from "../../boundary/TernSecureCtx";
7
7
  const AuthStateContext = React.createContext(null);
8
- const auth = TernSecureAuth();
9
8
  function TernSecureClientProvider({
10
- children
9
+ children,
10
+ Loading = () => /* @__PURE__ */ jsx("div", { children: "Loading..." })
11
11
  }) {
12
12
  const [authState, setAuthState] = useState({
13
13
  userId: null,
14
- loading: true,
14
+ isLoaded: true,
15
15
  error: null,
16
16
  isSignedIn: false
17
17
  });
18
18
  useEffect(() => {
19
+ const auth = TernSecureAuth();
19
20
  const unsubscribe = onAuthStateChanged(auth, (user) => {
20
21
  if (user) {
21
22
  setAuthState({
22
- loading: false,
23
+ isLoaded: false,
23
24
  isSignedIn: true,
24
25
  userId: user.uid,
25
26
  error: null
26
27
  });
27
28
  } else {
28
29
  setAuthState({
29
- loading: false,
30
+ isLoaded: false,
30
31
  isSignedIn: false,
31
32
  userId: null,
32
33
  error: null
@@ -35,7 +36,8 @@ function TernSecureClientProvider({
35
36
  });
36
37
  return () => unsubscribe();
37
38
  }, []);
38
- return /* @__PURE__ */ jsx(TernSecureCtxProvider, { children: /* @__PURE__ */ jsx(AuthStateContext.Provider, { value: authState, children: authState.loading ? /* @__PURE__ */ jsx("div", { children: "Loading..." }) : children }) });
39
+ const contextValue = useMemo(() => authState, [authState]);
40
+ return /* @__PURE__ */ jsx(TernSecureCtxProvider, { children: /* @__PURE__ */ jsx(AuthStateContext.Provider, { value: contextValue, children: authState.isLoaded ? /* @__PURE__ */ jsx(Loading, {}) : children }) });
39
41
  }
40
42
  export {
41
43
  AuthStateContext,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/app-router/client/TernSecureProvider.tsx"],"sourcesContent":["'use client'\r\n\r\nimport React, { useState, useEffect } from 'react'\r\nimport { TernSecureAuth } from '../../utils/client-init'\r\nimport { onAuthStateChanged } from \"firebase/auth\"\r\nimport { TernSecureCtxProvider } from '../../boundary/TernSecureCtx'\r\n\r\ninterface TernSecureState {\r\n userId: string | null\r\n loading: boolean\r\n error: string | null\r\n isSignedIn: boolean\r\n}\r\n\r\nexport const AuthStateContext = React.createContext<TernSecureState | null>(null)\r\n\r\nconst auth = TernSecureAuth();\r\n\r\nexport function TernSecureClientProvider({ \r\n children\r\n}: { \r\n children: React.ReactNode\r\n}) {\r\n const [authState, setAuthState] = useState<TernSecureState>({\r\n userId: null,\r\n loading: true,\r\n error: null,\r\n isSignedIn: false\r\n })\r\n\r\nuseEffect(() => {\r\n const unsubscribe = onAuthStateChanged(auth, (user) => {\r\n if (user) {\r\n setAuthState({\r\n loading: false,\r\n isSignedIn: true,\r\n userId: user.uid,\r\n error: null\r\n })\r\n } else {\r\n setAuthState({\r\n loading: false,\r\n isSignedIn: false,\r\n userId: null,\r\n error: null\r\n })\r\n }\r\n })\r\n \r\n return () => unsubscribe()\r\n }, [])\r\n\r\n\r\n return (\r\n <TernSecureCtxProvider>\r\n <AuthStateContext.Provider value={authState}>\r\n {authState.loading ? <div>Loading...</div> : children}\r\n </AuthStateContext.Provider>\r\n </TernSecureCtxProvider>\r\n )\r\n}"],"mappings":";AAwD2B;AAtD3B,OAAO,SAAS,UAAU,iBAAiB;AAC3C,SAAS,sBAAsB;AAC/B,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AAS/B,MAAM,mBAAmB,MAAM,cAAsC,IAAI;AAEhF,MAAM,OAAO,eAAe;AAErB,SAAS,yBAAyB;AAAA,EACvC;AACF,GAEI;AACF,QAAM,CAAC,WAAW,YAAY,IAAI,SAA0B;AAAA,IAC1D,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,OAAO;AAAA,IACP,YAAY;AAAA,EACd,CAAC;AAEH,YAAU,MAAM;AACZ,UAAM,cAAc,mBAAmB,MAAM,CAAC,SAAS;AACrD,UAAI,MAAM;AACR,qBAAa;AAAA,UACX,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,QAAQ,KAAK;AAAA,UACb,OAAO;AAAA,QACT,CAAC;AAAA,MACH,OAAO;AACL,qBAAa;AAAA,UACX,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,QAAQ;AAAA,UACR,OAAO;AAAA,QACT,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAED,WAAO,MAAM,YAAY;AAAA,EAC3B,GAAG,CAAC,CAAC;AAGL,SACE,oBAAC,yBACC,8BAAC,iBAAiB,UAAjB,EAA0B,OAAO,WACjC,oBAAU,UAAU,oBAAC,SAAI,wBAAU,IAAS,UAC7C,GACF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../../src/app-router/client/TernSecureProvider.tsx"],"sourcesContent":["'use client'\r\n\r\nimport React, { useState, useEffect, useMemo} from 'react'\r\nimport { TernSecureAuth } from '../../utils/client-init'\r\nimport { onAuthStateChanged } from \"firebase/auth\"\r\nimport { TernSecureCtxProvider } from '../../boundary/TernSecureCtx'\r\n\r\ninterface TernSecureState {\r\n userId: string | null\r\n isLoaded: boolean\r\n error: string | null\r\n isSignedIn: boolean\r\n}\r\n\r\nexport const AuthStateContext = React.createContext<TernSecureState | null>(null)\r\n\r\nexport function TernSecureClientProvider({ \r\n children,\r\n Loading = () => <div>Loading...</div>\r\n}: { \r\n children: React.ReactNode\r\n Loading?: React.ComponentType\r\n}) {\r\n const [authState, setAuthState] = useState<TernSecureState>({\r\n userId: null,\r\n isLoaded: true,\r\n error: null,\r\n isSignedIn: false\r\n })\r\n\r\nuseEffect(() => {\r\n const auth = TernSecureAuth();\r\n const unsubscribe = onAuthStateChanged(auth, (user) => {\r\n if (user) {\r\n setAuthState({\r\n isLoaded: false,\r\n isSignedIn: true,\r\n userId: user.uid,\r\n error: null\r\n })\r\n } else {\r\n setAuthState({\r\n isLoaded: false,\r\n isSignedIn: false,\r\n userId: null,\r\n error: null\r\n })\r\n }\r\n })\r\n \r\n return () => unsubscribe()\r\n }, [])\r\n\r\n const contextValue = useMemo(() => authState, [authState])\r\n\r\n return (\r\n <TernSecureCtxProvider>\r\n <AuthStateContext.Provider value={contextValue}>\r\n {authState.isLoaded ? <Loading /> : children}\r\n </AuthStateContext.Provider>\r\n </TernSecureCtxProvider>\r\n )\r\n}"],"mappings":";AAkBkB;AAhBlB,OAAO,SAAS,UAAU,WAAW,eAAc;AACnD,SAAS,sBAAsB;AAC/B,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AAS/B,MAAM,mBAAmB,MAAM,cAAsC,IAAI;AAEzE,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA,UAAU,MAAM,oBAAC,SAAI,wBAAU;AACjC,GAGI;AACF,QAAM,CAAC,WAAW,YAAY,IAAI,SAA0B;AAAA,IAC1D,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,OAAO;AAAA,IACP,YAAY;AAAA,EACd,CAAC;AAEH,YAAU,MAAM;AACd,UAAM,OAAO,eAAe;AAC1B,UAAM,cAAc,mBAAmB,MAAM,CAAC,SAAS;AACrD,UAAI,MAAM;AACR,qBAAa;AAAA,UACX,UAAU;AAAA,UACV,YAAY;AAAA,UACZ,QAAQ,KAAK;AAAA,UACb,OAAO;AAAA,QACT,CAAC;AAAA,MACH,OAAO;AACL,qBAAa;AAAA,UACX,UAAU;AAAA,UACV,YAAY;AAAA,UACZ,QAAQ;AAAA,UACR,OAAO;AAAA,QACT,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAED,WAAO,MAAM,YAAY;AAAA,EAC3B,GAAG,CAAC,CAAC;AAEL,QAAM,eAAe,QAAQ,MAAM,WAAW,CAAC,SAAS,CAAC;AAEzD,SACE,oBAAC,yBACC,8BAAC,iBAAiB,UAAjB,EAA0B,OAAO,cACjC,oBAAU,WAAW,oBAAC,WAAQ,IAAK,UACpC,GACF;AAEJ;","names":[]}
@@ -1,8 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { TernSecureClientProvider } from "../client/TernSecureProvider";
3
- function TernSecureLoadingFallback() {
4
- return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading authentication..." }) });
5
- }
6
3
  function TernSecureProvider({ children }) {
7
4
  return /* @__PURE__ */ jsx(TernSecureClientProvider, { children });
8
5
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/app-router/server/TernSecureServerProvider.tsx"],"sourcesContent":["import React, { Suspense } from \"react\"\r\nimport { TernSecureClientProvider } from \"../client/TernSecureProvider\"\r\n\r\n\r\n\r\n// Loading fallback component\r\nfunction TernSecureLoadingFallback() {\r\n return (\r\n <div>\r\n <span className=\"sr-only\">Loading authentication...</span>\r\n </div>\r\n )\r\n}\r\n/**\r\n * Root Provider for TernSecure\r\n * Use this in your Next.js App Router root layout\r\n * Automatically handles client/server boundary and authentication state\r\n * \r\n * @example\r\n * // app/layout.tsx\r\n * import { TernSecureProvider } from '@tern/secure'\r\n * \r\n * export default function RootLayout({ children }) {\r\n * return (\r\n * <html>\r\n * <body>\r\n * <TernSecureProvider>\r\n * {children}\r\n * </TernSecureProvider>\r\n * </body>\r\n * </html>\r\n * )\r\n * }\r\n */\r\nexport function TernSecureProvider({ children }: { children: React.ReactNode }) {\r\n return (\r\n <TernSecureClientProvider>\r\n \r\n {children}\r\n \r\n </TernSecureClientProvider>\r\n )\r\n}"],"mappings":"AASM;AARN,SAAS,gCAAgC;AAKzC,SAAS,4BAA4B;AACnC,SACE,oBAAC,SACC,8BAAC,UAAK,WAAU,WAAU,uCAAyB,GACrD;AAEJ;AAsBO,SAAS,mBAAmB,EAAE,SAAS,GAAkC;AAC9E,SACI,oBAAC,4BAEI,UAEL;AAEN;","names":[]}
1
+ {"version":3,"sources":["../../../../src/app-router/server/TernSecureServerProvider.tsx"],"sourcesContent":["import React from \"react\"\r\nimport { TernSecureClientProvider } from \"../client/TernSecureProvider\"\r\n\r\n\r\n\r\n// Loading fallback component\r\n/*function TernSecureLoadingFallback() {\r\n return (\r\n <div>\r\n <span className=\"sr-only\">Loading authentication...</span>\r\n </div>\r\n )\r\n}*/\r\n/**\r\n * Root Provider for TernSecure\r\n * Use this in your Next.js App Router root layout\r\n * Automatically handles client/server boundary and authentication state\r\n * \r\n * @example\r\n * // app/layout.tsx\r\n * import { TernSecureProvider } from '@tern/secure'\r\n * \r\n * export default function RootLayout({ children }) {\r\n * return (\r\n * <html>\r\n * <body>\r\n * <TernSecureProvider>\r\n * {children}\r\n * </TernSecureProvider>\r\n * </body>\r\n * </html>\r\n * )\r\n * }\r\n */\r\nexport function TernSecureProvider({ children }: { children: React.ReactNode }) {\r\n return (\r\n <TernSecureClientProvider>\r\n {children}\r\n </TernSecureClientProvider>\r\n )\r\n}"],"mappings":"AAoCM;AAnCN,SAAS,gCAAgC;AAiClC,SAAS,mBAAmB,EAAE,SAAS,GAAkC;AAC9E,SACI,oBAAC,4BACI,UACL;AAEN;","names":[]}
@@ -10,7 +10,7 @@ function useAuth() {
10
10
  }
11
11
  return {
12
12
  userId: authState.userId,
13
- loading: authState.loading,
13
+ loading: authState.isLoaded,
14
14
  error: authState.error,
15
15
  isSignedIn: authState.isSignedIn
16
16
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/boundary/hooks/useAuth.ts"],"sourcesContent":["'use client'\r\n\r\nimport { useContext } from 'react'\r\nimport { useInternalContext } from '../../boundary/TernSecureCtx'\r\nimport { AuthStateContext } from '../../app-router/client/TernSecureProvider'\r\n\r\nexport function useAuth(){\r\n // Verify we're within the provider boundary\r\n useInternalContext('useAuth')\r\n \r\n // Get the auth state from the AuthStateContext\r\n const authState = useContext(AuthStateContext)\r\n if (!authState) {\r\n throw new Error('Auth state not found')\r\n }\r\n\r\n\r\n return {\r\n userId: authState.userId,\r\n loading: authState.loading,\r\n error: authState.error,\r\n isSignedIn: authState.isSignedIn\r\n }\r\n}"],"mappings":";AAEA,SAAS,kBAAkB;AAC3B,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AAE1B,SAAS,UAAS;AAEvB,qBAAmB,SAAS;AAG5B,QAAM,YAAY,WAAW,gBAAgB;AAC7C,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,sBAAsB;AAAA,EACxC;AAGE,SAAO;AAAA,IACP,QAAQ,UAAU;AAAA,IAClB,SAAS,UAAU;AAAA,IACnB,OAAO,UAAU;AAAA,IACjB,YAAY,UAAU;AAAA,EACxB;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/boundary/hooks/useAuth.ts"],"sourcesContent":["'use client'\r\n\r\nimport { useContext } from 'react'\r\nimport { useInternalContext } from '../../boundary/TernSecureCtx'\r\nimport { AuthStateContext } from '../../app-router/client/TernSecureProvider'\r\n\r\nexport function useAuth(){\r\n // Verify we're within the provider boundary\r\n useInternalContext('useAuth')\r\n \r\n // Get the auth state from the AuthStateContext\r\n const authState = useContext(AuthStateContext)\r\n if (!authState) {\r\n throw new Error('Auth state not found')\r\n }\r\n\r\n\r\n return {\r\n userId: authState.userId,\r\n loading: authState.isLoaded,\r\n error: authState.error,\r\n isSignedIn: authState.isSignedIn\r\n }\r\n}"],"mappings":";AAEA,SAAS,kBAAkB;AAC3B,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AAE1B,SAAS,UAAS;AAEvB,qBAAmB,SAAS;AAG5B,QAAM,YAAY,WAAW,gBAAgB;AAC7C,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,sBAAsB;AAAA,EACxC;AAGE,SAAO;AAAA,IACP,QAAQ,UAAU;AAAA,IAClB,SAAS,UAAU;AAAA,IACnB,OAAO,UAAU;AAAA,IACjB,YAAY,UAAU;AAAA,EACxB;AACF;","names":[]}
@@ -1,13 +1,14 @@
1
1
  import React from 'react';
2
2
  interface TernSecureState {
3
3
  userId: string | null;
4
- loading: boolean;
4
+ isLoaded: boolean;
5
5
  error: string | null;
6
6
  isSignedIn: boolean;
7
7
  }
8
8
  export declare const AuthStateContext: React.Context<TernSecureState | null>;
9
- export declare function TernSecureClientProvider({ children }: {
9
+ export declare function TernSecureClientProvider({ children, Loading }: {
10
10
  children: React.ReactNode;
11
+ Loading?: React.ComponentType;
11
12
  }): import("react/jsx-runtime").JSX.Element;
12
13
  export {};
13
14
  //# sourceMappingURL=TernSecureProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TernSecureProvider.d.ts","sourceRoot":"","sources":["../../../../src/app-router/client/TernSecureProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAKlD,UAAU,eAAe;IACvB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,UAAU,EAAE,OAAO,CAAA;CACpB;AAED,eAAO,MAAM,gBAAgB,uCAAoD,CAAA;AAIjF,wBAAgB,wBAAwB,CAAC,EACvC,QAAQ,EACT,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,2CAsCA"}
1
+ {"version":3,"file":"TernSecureProvider.d.ts","sourceRoot":"","sources":["../../../../src/app-router/client/TernSecureProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAA;AAK1D,UAAU,eAAe;IACvB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,UAAU,EAAE,OAAO,CAAA;CACpB;AAED,eAAO,MAAM,gBAAgB,uCAAoD,CAAA;AAEjF,wBAAgB,wBAAwB,CAAC,EACvC,QAAQ,EACR,OAAqC,EACtC,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,OAAO,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC9B,2CAwCA"}
@@ -1 +1 @@
1
- {"version":3,"file":"TernSecureServerProvider.d.ts","sourceRoot":"","sources":["../../../../src/app-router/server/TernSecureServerProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAavC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CAQ7E"}
1
+ {"version":3,"file":"TernSecureServerProvider.d.ts","sourceRoot":"","sources":["../../../../src/app-router/server/TernSecureServerProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAazB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CAM7E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tern-secure/nextjs",
3
- "version": "3.1.98",
3
+ "version": "3.2.0",
4
4
  "packageManager": "npm@10.9.0",
5
5
  "publishConfig": {
6
6
  "access": "public"