@tern-secure/nextjs 3.2.11 → 3.2.12
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.
- package/dist/cjs/boundary/TernSecureClientProvider.js +1 -3
- package/dist/cjs/boundary/TernSecureClientProvider.js.map +1 -1
- package/dist/cjs/boundary/TernSecureCtx.js +1 -0
- package/dist/cjs/boundary/TernSecureCtx.js.map +1 -1
- package/dist/esm/boundary/TernSecureClientProvider.js +1 -3
- package/dist/esm/boundary/TernSecureClientProvider.js.map +1 -1
- package/dist/esm/boundary/TernSecureCtx.js +1 -0
- package/dist/esm/boundary/TernSecureCtx.js.map +1 -1
- package/dist/types/boundary/TernSecureClientProvider.d.ts.map +1 -1
- package/dist/types/boundary/TernSecureCtx.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -27,9 +27,7 @@ var import_react = require("react");
|
|
|
27
27
|
var import_client_init = require("../utils/client-init");
|
|
28
28
|
var import_auth = require("firebase/auth");
|
|
29
29
|
var import_TernSecureCtx = require("./TernSecureCtx");
|
|
30
|
-
function TernSecureClientProvider({
|
|
31
|
-
children
|
|
32
|
-
}) {
|
|
30
|
+
function TernSecureClientProvider({ children }) {
|
|
33
31
|
const [authState, setAuthState] = (0, import_react.useState)({
|
|
34
32
|
userId: null,
|
|
35
33
|
isLoaded: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/boundary/TernSecureClientProvider.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/boundary/TernSecureClientProvider.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 { TernSecureCtx, TernSecureCtxValue, TernSecureState } from './TernSecureCtx'\r\n\r\n\r\nexport function TernSecureClientProvider({ children }: { children: React.ReactNode }) {\r\n const [authState, setAuthState] = useState<TernSecureState>({\r\n userId: null,\r\n isLoaded: false,\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: true,\r\n isSignedIn: true,\r\n userId: user.uid,\r\n error: null\r\n })\r\n } else {\r\n setAuthState({\r\n isLoaded: true,\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: TernSecureCtxValue = useMemo(() => ({\r\n ...authState\r\n }), [authState])\r\n\r\n if (!authState.isLoaded) {\r\n return (\r\n <TernSecureCtx.Provider value={contextValue}>\r\n <div>\r\n <span className=\"sr-only\">Loading authentication state...</span>\r\n </div>\r\n </TernSecureCtx.Provider>\r\n )\r\n }\r\n\r\n return (\r\n <TernSecureCtx.Provider value={contextValue}>\r\n {children}\r\n </TernSecureCtx.Provider>\r\n )\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA+CU;AA7CV,mBAAoD;AACpD,yBAA+B;AAC/B,kBAAmC;AACnC,2BAAmE;AAG5D,SAAS,yBAAyB,EAAE,SAAS,GAAkC;AACpF,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,mBAAmC,sBAAQ,OAAO;AAAA,IACtD,GAAG;AAAA,EACL,IAAI,CAAC,SAAS,CAAC;AAEf,MAAI,CAAC,UAAU,UAAU;AACvB,WACE,4CAAC,mCAAc,UAAd,EAAuB,OAAO,cAC7B,sDAAC,SACC,sDAAC,UAAK,WAAU,WAAU,6CAA+B,GAC3D,GACF;AAAA,EAEJ;AAEA,SACI,4CAAC,mCAAc,UAAd,EAAuB,OAAO,cAC7B,UACF;AAEN;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/boundary/TernSecureCtx.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/boundary/TernSecureCtx.tsx"],"sourcesContent":["\"use client\"\r\n\r\nimport { createContext, useContext } from 'react'\r\n\r\n// Core types\r\nexport interface TernSecureState {\r\n userId: string | null\r\n isLoaded: boolean\r\n error: Error | null;\r\n isSignedIn: boolean\r\n}\r\n\r\nexport type TernSecureCtxValue = TernSecureState\r\n\r\n\r\nexport const TernSecureCtx = createContext<TernSecureCtxValue | null>(null)\r\n\r\n// Set display name for better debugging\r\nTernSecureCtx.displayName = 'TernSecureCtx'\r\n\r\nexport const useTernSecure = (hookName: string) => {\r\n const context = useContext(TernSecureCtx)\r\n \r\n if (!context) {\r\n throw new Error(\r\n `${hookName} must be used within TernSecureProvider`\r\n )\r\n }\r\n\r\n return context\r\n}\r\n\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA0C;AAanC,MAAM,oBAAgB,4BAAyC,IAAI;AAG1E,cAAc,cAAc;AAErB,MAAM,gBAAgB,CAAC,aAAqB;AACjD,QAAM,cAAU,yBAAW,aAAa;AAExC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR,GAAG,QAAQ;AAAA,IACb;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -4,9 +4,7 @@ import { useState, useEffect, useMemo } from "react";
|
|
|
4
4
|
import { TernSecureAuth } from "../utils/client-init";
|
|
5
5
|
import { onAuthStateChanged } from "firebase/auth";
|
|
6
6
|
import { TernSecureCtx } from "./TernSecureCtx";
|
|
7
|
-
function TernSecureClientProvider({
|
|
8
|
-
children
|
|
9
|
-
}) {
|
|
7
|
+
function TernSecureClientProvider({ children }) {
|
|
10
8
|
const [authState, setAuthState] = useState({
|
|
11
9
|
userId: null,
|
|
12
10
|
isLoaded: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/boundary/TernSecureClientProvider.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/boundary/TernSecureClientProvider.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 { TernSecureCtx, TernSecureCtxValue, TernSecureState } from './TernSecureCtx'\r\n\r\n\r\nexport function TernSecureClientProvider({ children }: { children: React.ReactNode }) {\r\n const [authState, setAuthState] = useState<TernSecureState>({\r\n userId: null,\r\n isLoaded: false,\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: true,\r\n isSignedIn: true,\r\n userId: user.uid,\r\n error: null\r\n })\r\n } else {\r\n setAuthState({\r\n isLoaded: true,\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: TernSecureCtxValue = useMemo(() => ({\r\n ...authState\r\n }), [authState])\r\n\r\n if (!authState.isLoaded) {\r\n return (\r\n <TernSecureCtx.Provider value={contextValue}>\r\n <div>\r\n <span className=\"sr-only\">Loading authentication state...</span>\r\n </div>\r\n </TernSecureCtx.Provider>\r\n )\r\n }\r\n\r\n return (\r\n <TernSecureCtx.Provider value={contextValue}>\r\n {children}\r\n </TernSecureCtx.Provider>\r\n )\r\n}"],"mappings":";AA+CU;AA7CV,SAAgB,UAAU,WAAW,eAAe;AACpD,SAAS,sBAAsB;AAC/B,SAAS,0BAA0B;AACnC,SAAS,qBAA0D;AAG5D,SAAS,yBAAyB,EAAE,SAAS,GAAkC;AACpF,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,eAAmC,QAAQ,OAAO;AAAA,IACtD,GAAG;AAAA,EACL,IAAI,CAAC,SAAS,CAAC;AAEf,MAAI,CAAC,UAAU,UAAU;AACvB,WACE,oBAAC,cAAc,UAAd,EAAuB,OAAO,cAC7B,8BAAC,SACC,8BAAC,UAAK,WAAU,WAAU,6CAA+B,GAC3D,GACF;AAAA,EAEJ;AAEA,SACI,oBAAC,cAAc,UAAd,EAAuB,OAAO,cAC7B,UACF;AAEN;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/boundary/TernSecureCtx.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/boundary/TernSecureCtx.tsx"],"sourcesContent":["\"use client\"\r\n\r\nimport { createContext, useContext } from 'react'\r\n\r\n// Core types\r\nexport interface TernSecureState {\r\n userId: string | null\r\n isLoaded: boolean\r\n error: Error | null;\r\n isSignedIn: boolean\r\n}\r\n\r\nexport type TernSecureCtxValue = TernSecureState\r\n\r\n\r\nexport const TernSecureCtx = createContext<TernSecureCtxValue | null>(null)\r\n\r\n// Set display name for better debugging\r\nTernSecureCtx.displayName = 'TernSecureCtx'\r\n\r\nexport const useTernSecure = (hookName: string) => {\r\n const context = useContext(TernSecureCtx)\r\n \r\n if (!context) {\r\n throw new Error(\r\n `${hookName} must be used within TernSecureProvider`\r\n )\r\n }\r\n\r\n return context\r\n}\r\n\r\n"],"mappings":";AAEA,SAAS,eAAe,kBAAkB;AAanC,MAAM,gBAAgB,cAAyC,IAAI;AAG1E,cAAc,cAAc;AAErB,MAAM,gBAAgB,CAAC,aAAqB;AACjD,QAAM,UAAU,WAAW,aAAa;AAExC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR,GAAG,QAAQ;AAAA,IACb;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TernSecureClientProvider.d.ts","sourceRoot":"","sources":["../../../src/boundary/TernSecureClientProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAuC,MAAM,OAAO,CAAA;AAM3D,wBAAgB,wBAAwB,CAAC,
|
|
1
|
+
{"version":3,"file":"TernSecureClientProvider.d.ts","sourceRoot":"","sources":["../../../src/boundary/TernSecureClientProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAuC,MAAM,OAAO,CAAA;AAM3D,wBAAgB,wBAAwB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CAkDnF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TernSecureCtx.d.ts","sourceRoot":"","sources":["../../../src/boundary/TernSecureCtx.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TernSecureCtx.d.ts","sourceRoot":"","sources":["../../../src/boundary/TernSecureCtx.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,MAAM,kBAAkB,GAAG,eAAe,CAAA;AAGhD,eAAO,MAAM,aAAa,iDAAiD,CAAA;AAK3E,eAAO,MAAM,aAAa,aAAc,MAAM,oBAU7C,CAAA"}
|