@tern-secure/nextjs 3.2.2 → 3.2.4
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/app-router/client/TernSecureProvider.js +9 -42
- package/dist/cjs/app-router/client/TernSecureProvider.js.map +1 -1
- package/dist/cjs/app-router/{server → client}/auth.js.map +1 -1
- package/dist/cjs/boundary/TernSecureClientProvider.js +73 -0
- package/dist/cjs/boundary/TernSecureClientProvider.js.map +1 -0
- package/dist/cjs/boundary/TernSecureCtx.js +10 -17
- package/dist/cjs/boundary/TernSecureCtx.js.map +1 -1
- package/dist/cjs/boundary/hooks/useAuth.js +2 -8
- package/dist/cjs/boundary/hooks/useAuth.js.map +1 -1
- package/dist/cjs/components/sign-in.js +1 -1
- package/dist/cjs/components/sign-in.js.map +1 -1
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/app-router/client/TernSecureProvider.js +8 -40
- package/dist/esm/app-router/client/TernSecureProvider.js.map +1 -1
- package/dist/esm/app-router/{server → client}/auth.js.map +1 -1
- package/dist/esm/boundary/TernSecureClientProvider.js +49 -0
- package/dist/esm/boundary/TernSecureClientProvider.js.map +1 -0
- package/dist/esm/boundary/TernSecureCtx.js +7 -14
- package/dist/esm/boundary/TernSecureCtx.js.map +1 -1
- package/dist/esm/boundary/hooks/useAuth.js +2 -8
- package/dist/esm/boundary/hooks/useAuth.js.map +1 -1
- package/dist/esm/components/sign-in.js +1 -1
- package/dist/esm/components/sign-in.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/types/app-router/client/TernSecureProvider.d.ts +23 -11
- package/dist/types/app-router/client/TernSecureProvider.d.ts.map +1 -1
- package/dist/types/app-router/{server → client}/auth.d.ts.map +1 -1
- package/dist/types/boundary/TernSecureClientProvider.d.ts +8 -0
- package/dist/types/boundary/TernSecureClientProvider.d.ts.map +1 -0
- package/dist/types/boundary/TernSecureCtx.d.ts +9 -12
- package/dist/types/boundary/TernSecureCtx.d.ts.map +1 -1
- package/dist/types/boundary/hooks/useAuth.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/app-router/server/TernSecureServerProvider.js +0 -48
- package/dist/cjs/app-router/server/TernSecureServerProvider.js.map +0 -1
- package/dist/esm/app-router/server/TernSecureServerProvider.js +0 -14
- package/dist/esm/app-router/server/TernSecureServerProvider.js.map +0 -1
- package/dist/types/app-router/server/TernSecureServerProvider.d.ts +0 -26
- package/dist/types/app-router/server/TernSecureServerProvider.d.ts.map +0 -1
- /package/dist/cjs/app-router/{server → client}/auth.js +0 -0
- /package/dist/esm/app-router/{server → client}/auth.js +0 -0
- /package/dist/types/app-router/{server → client}/auth.d.ts +0 -0
|
@@ -29,53 +29,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
30
|
var TernSecureProvider_exports = {};
|
|
31
31
|
__export(TernSecureProvider_exports, {
|
|
32
|
-
|
|
33
|
-
TernSecureClientProvider: () => TernSecureClientProvider
|
|
32
|
+
TernSecureProvider: () => TernSecureProvider
|
|
34
33
|
});
|
|
35
34
|
module.exports = __toCommonJS(TernSecureProvider_exports);
|
|
36
35
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
function
|
|
43
|
-
children
|
|
44
|
-
Loading = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: "Loading..." })
|
|
45
|
-
}) {
|
|
46
|
-
const [authState, setAuthState] = (0, import_react.useState)({
|
|
47
|
-
userId: null,
|
|
48
|
-
isLoaded: true,
|
|
49
|
-
error: null,
|
|
50
|
-
isSignedIn: false
|
|
51
|
-
});
|
|
52
|
-
(0, import_react.useEffect)(() => {
|
|
53
|
-
const auth = (0, import_client_init.TernSecureAuth)();
|
|
54
|
-
const unsubscribe = (0, import_auth.onAuthStateChanged)(auth, (user) => {
|
|
55
|
-
if (user) {
|
|
56
|
-
setAuthState({
|
|
57
|
-
isLoaded: false,
|
|
58
|
-
isSignedIn: true,
|
|
59
|
-
userId: user.uid,
|
|
60
|
-
error: null
|
|
61
|
-
});
|
|
62
|
-
} else {
|
|
63
|
-
setAuthState({
|
|
64
|
-
isLoaded: false,
|
|
65
|
-
isSignedIn: false,
|
|
66
|
-
userId: null,
|
|
67
|
-
error: null
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
return () => unsubscribe();
|
|
72
|
-
}, []);
|
|
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 }) });
|
|
36
|
+
var import_dynamic = __toESM(require("next/dynamic"));
|
|
37
|
+
const TernSecureClientProvider = (0, import_dynamic.default)(
|
|
38
|
+
() => import("../../boundary/TernSecureClientProvider").then((mod) => mod.TernSecureClientProvider),
|
|
39
|
+
{ ssr: false }
|
|
40
|
+
);
|
|
41
|
+
function TernSecureProvider({ children }) {
|
|
42
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TernSecureClientProvider, { children });
|
|
75
43
|
}
|
|
76
44
|
// Annotate the CommonJS export names for ESM import in node:
|
|
77
45
|
0 && (module.exports = {
|
|
78
|
-
|
|
79
|
-
TernSecureClientProvider
|
|
46
|
+
TernSecureProvider
|
|
80
47
|
});
|
|
81
48
|
//# sourceMappingURL=TernSecureProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/app-router/client/TernSecureProvider.tsx"],"sourcesContent":["'use client'\r\n\r\nimport React
|
|
1
|
+
{"version":3,"sources":["../../../../src/app-router/client/TernSecureProvider.tsx"],"sourcesContent":["'use client'\r\n\r\nimport React from \"react\"\r\nimport dynamic from \"next/dynamic\"\r\n\r\nconst TernSecureClientProvider = dynamic(\r\n () => import(\"../../boundary/TernSecureClientProvider\").then(mod => mod.TernSecureClientProvider),\r\n { ssr: false }\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;AAyCM;AAtCN,qBAAoB;AAEpB,MAAM,+BAA2B,eAAAA;AAAA,EAC/B,MAAM,OAAO,yCAAyC,EAAE,KAAK,SAAO,IAAI,wBAAwB;AAAA,EAChG,EAAE,KAAK,MAAM;AACf;AA+BO,SAAS,mBAAmB,EAAE,SAAS,GAAkC;AAC9E,SACI,4CAAC,4BACI,UACL;AAEN;","names":["dynamic"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/app-router/
|
|
1
|
+
{"version":3,"sources":["../../../../src/app-router/client/auth.ts"],"sourcesContent":["import { TernSecureAuth } from '../../utils/client-init'\r\nimport { signInWithEmailAndPassword } from 'firebase/auth'\r\n\r\n//export interface SignInCredentials {\r\n //email: string\r\n //password: string\r\n//}\r\n\r\nexport async function signInWithEmail(email: string, password: string){\r\n const auth = TernSecureAuth()\r\n const UserCredential = await signInWithEmailAndPassword(auth, email, password)\r\n return UserCredential.user\r\n} "],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA+B;AAC/B,kBAA2C;AAO3C,eAAsB,gBAAgB,OAAe,UAAiB;AACpE,QAAM,WAAO,mCAAe;AAC5B,QAAM,iBAAiB,UAAM,wCAA2B,MAAM,OAAO,QAAQ;AAC7E,SAAO,eAAe;AACxB;","names":[]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var TernSecureClientProvider_exports = {};
|
|
21
|
+
__export(TernSecureClientProvider_exports, {
|
|
22
|
+
TernSecureClientProvider: () => TernSecureClientProvider
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(TernSecureClientProvider_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_client_init = require("../utils/client-init");
|
|
28
|
+
var import_auth = require("firebase/auth");
|
|
29
|
+
var import_TernSecureCtx = require("./TernSecureCtx");
|
|
30
|
+
function TernSecureClientProvider({
|
|
31
|
+
children,
|
|
32
|
+
Loading = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: "Loading..." })
|
|
33
|
+
}) {
|
|
34
|
+
const [authState, setAuthState] = (0, import_react.useState)({
|
|
35
|
+
userId: null,
|
|
36
|
+
isLoaded: false,
|
|
37
|
+
error: null,
|
|
38
|
+
isSignedIn: false
|
|
39
|
+
});
|
|
40
|
+
(0, import_react.useEffect)(() => {
|
|
41
|
+
const auth = (0, import_client_init.TernSecureAuth)();
|
|
42
|
+
const unsubscribe = (0, import_auth.onAuthStateChanged)(auth, (user) => {
|
|
43
|
+
if (user) {
|
|
44
|
+
setAuthState({
|
|
45
|
+
isLoaded: true,
|
|
46
|
+
isSignedIn: true,
|
|
47
|
+
userId: user.uid,
|
|
48
|
+
error: null
|
|
49
|
+
});
|
|
50
|
+
} else {
|
|
51
|
+
setAuthState({
|
|
52
|
+
isLoaded: true,
|
|
53
|
+
isSignedIn: false,
|
|
54
|
+
userId: null,
|
|
55
|
+
error: null
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return () => unsubscribe();
|
|
60
|
+
}, []);
|
|
61
|
+
const contextValue = (0, import_react.useMemo)(() => ({
|
|
62
|
+
...authState
|
|
63
|
+
}), [authState]);
|
|
64
|
+
if (!authState.isLoaded) {
|
|
65
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {});
|
|
66
|
+
}
|
|
67
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TernSecureCtx.TernSecureCtx.Provider, { value: contextValue, children });
|
|
68
|
+
}
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
TernSecureClientProvider
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=TernSecureClientProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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, TernSecureState, TernSecureCtxValue } from './TernSecureCtx'\r\n\r\ninterface TernSecureClientProviderProps {\r\n children: React.ReactNode\r\n Loading?: React.ComponentType\r\n}\r\n\r\nexport function TernSecureClientProvider({ \r\n children,\r\n Loading = () => <div>Loading...</div>\r\n}: TernSecureClientProviderProps) {\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\n useEffect(() => {\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 <Loading />\r\n }\r\n\r\n return (\r\n <TernSecureCtx.Provider value={contextValue}>\r\n {children}\r\n </TernSecureCtx.Provider>\r\n )\r\n}\r\n\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAckB;AAZlB,mBAAoD;AACpD,yBAA+B;AAC/B,kBAAmC;AACnC,2BAAmE;AAO5D,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA,UAAU,MAAM,4CAAC,SAAI,wBAAU;AACjC,GAAmC;AACjC,QAAM,CAAC,WAAW,YAAY,QAAI,uBAA0B;AAAA,IAC1D,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,OAAO;AAAA,IACP,YAAY;AAAA,EACd,CAAC;AAED,8BAAU,MAAM;AACd,UAAM,WAAO,mCAAe;AAC5B,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,WAAO,4CAAC,WAAQ;AAAA,EAClB;AAEA,SACE,4CAAC,mCAAc,UAAd,EAAuB,OAAO,cAC5B,UACH;AAEJ;","names":[]}
|
|
@@ -19,32 +19,25 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
20
|
var TernSecureCtx_exports = {};
|
|
21
21
|
__export(TernSecureCtx_exports, {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
TernSecureCtx: () => TernSecureCtx,
|
|
23
|
+
useTernSecure: () => useTernSecure
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(TernSecureCtx_exports);
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const useInternalContext = (hookname) => {
|
|
32
|
-
const context = (0, import_react2.useContext)(TernSecureContext);
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
const TernSecureCtx = (0, import_react.createContext)(null);
|
|
28
|
+
TernSecureCtx.displayName = "TernSecureCtx";
|
|
29
|
+
const useTernSecure = (hookName) => {
|
|
30
|
+
const context = (0, import_react.useContext)(TernSecureCtx);
|
|
33
31
|
if (!context) {
|
|
34
32
|
throw new Error(
|
|
35
|
-
`${
|
|
33
|
+
`${hookName} must be used within TernSecureProvider`
|
|
36
34
|
);
|
|
37
35
|
}
|
|
38
36
|
return context;
|
|
39
37
|
};
|
|
40
|
-
function TernSecureCtxProvider({ children }) {
|
|
41
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TernSecureContext.Provider, { value: {
|
|
42
|
-
_contextKey: INTERNAL_CONTEXT_KEY
|
|
43
|
-
}, children });
|
|
44
|
-
}
|
|
45
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
46
39
|
0 && (module.exports = {
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
TernSecureCtx,
|
|
41
|
+
useTernSecure
|
|
49
42
|
});
|
|
50
43
|
//# sourceMappingURL=TernSecureCtx.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/boundary/TernSecureCtx.tsx"],"sourcesContent":["'use client'\r\n\r\nimport
|
|
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: string | 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":[]}
|
|
@@ -22,15 +22,9 @@ __export(useAuth_exports, {
|
|
|
22
22
|
useAuth: () => useAuth
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(useAuth_exports);
|
|
25
|
-
var
|
|
26
|
-
var import_TernSecureCtx = require("../../boundary/TernSecureCtx");
|
|
27
|
-
var import_TernSecureProvider = require("../../app-router/client/TernSecureProvider");
|
|
25
|
+
var import_TernSecureCtx = require("../TernSecureCtx");
|
|
28
26
|
function useAuth() {
|
|
29
|
-
(0, import_TernSecureCtx.
|
|
30
|
-
const authState = (0, import_react.useContext)(import_TernSecureProvider.AuthStateContext);
|
|
31
|
-
if (!authState) {
|
|
32
|
-
throw new Error("Auth state not found");
|
|
33
|
-
}
|
|
27
|
+
const authState = (0, import_TernSecureCtx.useTernSecure)("useAuth");
|
|
34
28
|
return {
|
|
35
29
|
userId: authState.userId,
|
|
36
30
|
isLoaded: authState.isLoaded,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/boundary/hooks/useAuth.ts"],"sourcesContent":["'use client'\r\n\r\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/boundary/hooks/useAuth.ts"],"sourcesContent":["'use client'\r\n\r\nimport { useTernSecure } from '../TernSecureCtx'\r\n\r\nexport function useAuth() {\r\n const authState = useTernSecure('useAuth')\r\n\r\n return {\r\n userId: authState.userId,\r\n isLoaded: authState.isLoaded,\r\n error: authState.error,\r\n isSignedIn: authState.isSignedIn\r\n }\r\n}\r\n\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,2BAA8B;AAEvB,SAAS,UAAU;AACxB,QAAM,gBAAY,oCAAc,SAAS;AAEzC,SAAO;AAAA,IACL,QAAQ,UAAU;AAAA,IAClB,UAAU,UAAU;AAAA,IACpB,OAAO,UAAU;AAAA,IACjB,YAAY,UAAU;AAAA,EACxB;AACF;","names":[]}
|
|
@@ -24,7 +24,7 @@ __export(sign_in_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(sign_in_exports);
|
|
25
25
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
26
|
var import_react2 = require("react");
|
|
27
|
-
var import_auth = require("../app-router/
|
|
27
|
+
var import_auth = require("../app-router/client/auth");
|
|
28
28
|
var import_create_styles = require("../utils/create-styles");
|
|
29
29
|
var import_navigation = require("next/navigation");
|
|
30
30
|
function SignIn({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/sign-in.tsx"],"sourcesContent":["'use client'\r\n\r\nimport React from 'react'\r\nimport { useState } from 'react'\r\nimport { signInWithEmail } from '../app-router/
|
|
1
|
+
{"version":3,"sources":["../../../src/components/sign-in.tsx"],"sourcesContent":["'use client'\r\n\r\nimport React from 'react'\r\nimport { useState } from 'react'\r\nimport { signInWithEmail } from '../app-router/client/auth'\r\nimport { styles } from '../utils/create-styles'\r\nimport { useRouter } from 'next/navigation'\r\n\r\nexport interface SignInProps {\r\n onError?: (error: Error) => void\r\n className?: string\r\n style?: React.CSSProperties\r\n customStyles?: {\r\n container?: string\r\n header?: string\r\n title?: string\r\n formWrapper?: string\r\n formContainer?: string\r\n form?: string\r\n input?: string\r\n button?: string\r\n errorText?: string\r\n label?: string\r\n }\r\n}\r\n\r\nexport function SignIn({ \r\n onError, \r\n className,\r\n style,\r\n customStyles = {}\r\n}: SignInProps) {\r\n\r\n const [loading, setLoading] = useState(false)\r\n const [error, setError] = useState('')\r\n const [email, setEmail] = useState('')\r\n const [password, setPassword] = useState('')\r\n const router = useRouter()\r\n\r\n const handleSubmit = async (e: React.FormEvent) => {\r\n e.preventDefault()\r\n setLoading(true)\r\n try {\r\n const user = await signInWithEmail(email, password)\r\n if (user) {\r\n router.push('/')\r\n }\r\n } catch (err) {\r\n const errorMessage = err instanceof Error ? err.message : 'Failed to sign in'\r\n setError(errorMessage)\r\n onError?.(err instanceof Error ? err : new Error('Failed to sign in'))\r\n } finally {\r\n setLoading(false)\r\n }\r\n }\r\n\r\n return (\r\n <div className={`${styles.container} ${customStyles.container || ''}`} style={style}>\r\n <div className={`${styles.header} ${customStyles.header || ''}`}>\r\n <h2 className={`${styles.title} ${customStyles.title || ''}`}>\r\n Sign in to your account\r\n </h2>\r\n </div>\r\n \r\n <div className={`${styles.formWrapper} ${customStyles.formWrapper || ''}`}>\r\n <div className={`${styles.formContainer} ${customStyles.formContainer || ''}`}>\r\n <form \r\n onSubmit={handleSubmit} \r\n className={`${styles.form} ${customStyles.form || ''} ${className}`}\r\n role=\"form\"\r\n aria-label=\"Sign in form\"\r\n >\r\n {error && (\r\n <div \r\n className={`${styles.error} ${customStyles.errorText || ''}`}\r\n role=\"alert\"\r\n aria-live=\"polite\"\r\n >\r\n {error}\r\n </div>\r\n )}\r\n <div>\r\n <label htmlFor=\"email\" className={`${styles.label} ${customStyles.label || ''}`}>\r\n Email\r\n </label>\r\n <input\r\n id=\"email\"\r\n name=\"email\"\r\n type=\"email\"\r\n placeholder=\"Enter your email\"\r\n required\r\n value={email}\r\n onChange={(e) => setEmail(e.target.value)}\r\n className={`${styles.input} ${customStyles.input || ''}`}\r\n disabled={loading}\r\n aria-required=\"true\"\r\n aria-invalid={!!error}\r\n />\r\n </div>\r\n <div>\r\n <label htmlFor=\"password\" className={`${styles.label} ${customStyles.label || ''}`}>\r\n Password\r\n </label>\r\n <input\r\n id=\"password\"\r\n name=\"password\"\r\n type=\"password\"\r\n placeholder=\"Enter your password\"\r\n required\r\n value={password}\r\n onChange={(e) => setPassword(e.target.value)}\r\n className={`${styles.input} ${customStyles.input || ''}`}\r\n disabled={loading}\r\n aria-required=\"true\"\r\n aria-invalid={!!error}\r\n />\r\n </div>\r\n <button \r\n type=\"submit\" \r\n disabled={loading}\r\n className={`${styles.button} ${customStyles.button || ''}`}\r\n data-testid=\"sign-in-submit\"\r\n >\r\n {loading ? 'Signing in...' : 'Sign in'}\r\n </button>\r\n </form>\r\n </div>\r\n </div>\r\n </div>\r\n )\r\n}\r\n\r\n"],"mappings":"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","names":["import_react"]}
|
package/dist/cjs/index.js
CHANGED
|
@@ -21,7 +21,7 @@ __export(src_exports, {
|
|
|
21
21
|
SignIn: () => import_sign_in.SignIn,
|
|
22
22
|
TernSecureAuth: () => import_client_init.TernSecureAuth,
|
|
23
23
|
TernSecureFirestore: () => import_client_init.TernSecureFirestore,
|
|
24
|
-
TernSecureProvider: () =>
|
|
24
|
+
TernSecureProvider: () => import_TernSecureProvider.TernSecureProvider,
|
|
25
25
|
loadFireConfig: () => import_config.loadFireConfig,
|
|
26
26
|
signInWithEmail: () => import_auth.signInWithEmail,
|
|
27
27
|
useAuth: () => import_useAuth.useAuth,
|
|
@@ -30,8 +30,8 @@ __export(src_exports, {
|
|
|
30
30
|
module.exports = __toCommonJS(src_exports);
|
|
31
31
|
var import_client_init = require("./utils/client-init");
|
|
32
32
|
var import_config = require("./utils/config");
|
|
33
|
-
var import_auth = require("./app-router/
|
|
34
|
-
var
|
|
33
|
+
var import_auth = require("./app-router/client/auth");
|
|
34
|
+
var import_TernSecureProvider = require("./app-router/client/TernSecureProvider");
|
|
35
35
|
var import_useAuth = require("./boundary/hooks/useAuth");
|
|
36
36
|
var import_sign_in = require("./components/sign-in");
|
|
37
37
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["//import { TernSecureServerProvider } from './app-router/server/TernSecureServerProvider'\r\n//import type { TernSecureState } from './app-router/client/TernSecureProvider'\r\nexport { TernSecureAuth, TernSecureFirestore } from './utils/client-init'\r\nexport { loadFireConfig, validateConfig } from './utils/config'\r\nexport { signInWithEmail } from './app-router/
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["//import { TernSecureServerProvider } from './app-router/server/TernSecureServerProvider'\r\n//import type { TernSecureState } from './app-router/client/TernSecureProvider'\r\nexport { TernSecureAuth, TernSecureFirestore } from './utils/client-init'\r\nexport { loadFireConfig, validateConfig } from './utils/config'\r\nexport { signInWithEmail } from './app-router/client/auth'\r\n//export { useInternalContext } from './boundary/TernSecureCtx'\r\n//export { TernSecureClientProvider } from './app-router/client/TernSecureProvider'\r\nexport { TernSecureProvider } from './app-router/client/TernSecureProvider'\r\nexport { useAuth } from './boundary/hooks/useAuth' \r\nexport { SignIn } from './components/sign-in'\r\n\r\n//export const TernSecureProvider = TernSecureServerProvider\r\n//export type { TernSecureState }"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,yBAAoD;AACpD,oBAA+C;AAC/C,kBAAgC;AAGhC,gCAAmC;AACnC,qBAAwB;AACxB,qBAAuB;","names":[]}
|
|
@@ -1,46 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
children
|
|
10
|
-
Loading = () => /* @__PURE__ */ jsx("div", { children: "Loading..." })
|
|
11
|
-
}) {
|
|
12
|
-
const [authState, setAuthState] = useState({
|
|
13
|
-
userId: null,
|
|
14
|
-
isLoaded: true,
|
|
15
|
-
error: null,
|
|
16
|
-
isSignedIn: false
|
|
17
|
-
});
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
const auth = TernSecureAuth();
|
|
20
|
-
const unsubscribe = onAuthStateChanged(auth, (user) => {
|
|
21
|
-
if (user) {
|
|
22
|
-
setAuthState({
|
|
23
|
-
isLoaded: false,
|
|
24
|
-
isSignedIn: true,
|
|
25
|
-
userId: user.uid,
|
|
26
|
-
error: null
|
|
27
|
-
});
|
|
28
|
-
} else {
|
|
29
|
-
setAuthState({
|
|
30
|
-
isLoaded: false,
|
|
31
|
-
isSignedIn: false,
|
|
32
|
-
userId: null,
|
|
33
|
-
error: null
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
return () => unsubscribe();
|
|
38
|
-
}, []);
|
|
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 }) });
|
|
3
|
+
import dynamic from "next/dynamic";
|
|
4
|
+
const TernSecureClientProvider = dynamic(
|
|
5
|
+
() => import("../../boundary/TernSecureClientProvider").then((mod) => mod.TernSecureClientProvider),
|
|
6
|
+
{ ssr: false }
|
|
7
|
+
);
|
|
8
|
+
function TernSecureProvider({ children }) {
|
|
9
|
+
return /* @__PURE__ */ jsx(TernSecureClientProvider, { children });
|
|
41
10
|
}
|
|
42
11
|
export {
|
|
43
|
-
|
|
44
|
-
TernSecureClientProvider
|
|
12
|
+
TernSecureProvider
|
|
45
13
|
};
|
|
46
14
|
//# sourceMappingURL=TernSecureProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/app-router/client/TernSecureProvider.tsx"],"sourcesContent":["'use client'\r\n\r\nimport React
|
|
1
|
+
{"version":3,"sources":["../../../../src/app-router/client/TernSecureProvider.tsx"],"sourcesContent":["'use client'\r\n\r\nimport React from \"react\"\r\nimport dynamic from \"next/dynamic\"\r\n\r\nconst TernSecureClientProvider = dynamic(\r\n () => import(\"../../boundary/TernSecureClientProvider\").then(mod => mod.TernSecureClientProvider),\r\n { ssr: false }\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":";AAyCM;AAtCN,OAAO,aAAa;AAEpB,MAAM,2BAA2B;AAAA,EAC/B,MAAM,OAAO,yCAAyC,EAAE,KAAK,SAAO,IAAI,wBAAwB;AAAA,EAChG,EAAE,KAAK,MAAM;AACf;AA+BO,SAAS,mBAAmB,EAAE,SAAS,GAAkC;AAC9E,SACI,oBAAC,4BACI,UACL;AAEN;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/app-router/
|
|
1
|
+
{"version":3,"sources":["../../../../src/app-router/client/auth.ts"],"sourcesContent":["import { TernSecureAuth } from '../../utils/client-init'\r\nimport { signInWithEmailAndPassword } from 'firebase/auth'\r\n\r\n//export interface SignInCredentials {\r\n //email: string\r\n //password: string\r\n//}\r\n\r\nexport async function signInWithEmail(email: string, password: string){\r\n const auth = TernSecureAuth()\r\n const UserCredential = await signInWithEmailAndPassword(auth, email, password)\r\n return UserCredential.user\r\n} "],"mappings":"AAAA,SAAS,sBAAsB;AAC/B,SAAS,kCAAkC;AAO3C,eAAsB,gBAAgB,OAAe,UAAiB;AACpE,QAAM,OAAO,eAAe;AAC5B,QAAM,iBAAiB,MAAM,2BAA2B,MAAM,OAAO,QAAQ;AAC7E,SAAO,eAAe;AACxB;","names":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useEffect, useMemo } from "react";
|
|
4
|
+
import { TernSecureAuth } from "../utils/client-init";
|
|
5
|
+
import { onAuthStateChanged } from "firebase/auth";
|
|
6
|
+
import { TernSecureCtx } from "./TernSecureCtx";
|
|
7
|
+
function TernSecureClientProvider({
|
|
8
|
+
children,
|
|
9
|
+
Loading = () => /* @__PURE__ */ jsx("div", { children: "Loading..." })
|
|
10
|
+
}) {
|
|
11
|
+
const [authState, setAuthState] = useState({
|
|
12
|
+
userId: null,
|
|
13
|
+
isLoaded: false,
|
|
14
|
+
error: null,
|
|
15
|
+
isSignedIn: false
|
|
16
|
+
});
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const auth = TernSecureAuth();
|
|
19
|
+
const unsubscribe = onAuthStateChanged(auth, (user) => {
|
|
20
|
+
if (user) {
|
|
21
|
+
setAuthState({
|
|
22
|
+
isLoaded: true,
|
|
23
|
+
isSignedIn: true,
|
|
24
|
+
userId: user.uid,
|
|
25
|
+
error: null
|
|
26
|
+
});
|
|
27
|
+
} else {
|
|
28
|
+
setAuthState({
|
|
29
|
+
isLoaded: true,
|
|
30
|
+
isSignedIn: false,
|
|
31
|
+
userId: null,
|
|
32
|
+
error: null
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return () => unsubscribe();
|
|
37
|
+
}, []);
|
|
38
|
+
const contextValue = useMemo(() => ({
|
|
39
|
+
...authState
|
|
40
|
+
}), [authState]);
|
|
41
|
+
if (!authState.isLoaded) {
|
|
42
|
+
return /* @__PURE__ */ jsx(Loading, {});
|
|
43
|
+
}
|
|
44
|
+
return /* @__PURE__ */ jsx(TernSecureCtx.Provider, { value: contextValue, children });
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
TernSecureClientProvider
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=TernSecureClientProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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, TernSecureState, TernSecureCtxValue } from './TernSecureCtx'\r\n\r\ninterface TernSecureClientProviderProps {\r\n children: React.ReactNode\r\n Loading?: React.ComponentType\r\n}\r\n\r\nexport function TernSecureClientProvider({ \r\n children,\r\n Loading = () => <div>Loading...</div>\r\n}: TernSecureClientProviderProps) {\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\n useEffect(() => {\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 <Loading />\r\n }\r\n\r\n return (\r\n <TernSecureCtx.Provider value={contextValue}>\r\n {children}\r\n </TernSecureCtx.Provider>\r\n )\r\n}\r\n\r\n"],"mappings":";AAckB;AAZlB,SAAgB,UAAU,WAAW,eAAe;AACpD,SAAS,sBAAsB;AAC/B,SAAS,0BAA0B;AACnC,SAAS,qBAA0D;AAO5D,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA,UAAU,MAAM,oBAAC,SAAI,wBAAU;AACjC,GAAmC;AACjC,QAAM,CAAC,WAAW,YAAY,IAAI,SAA0B;AAAA,IAC1D,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,OAAO;AAAA,IACP,YAAY;AAAA,EACd,CAAC;AAED,YAAU,MAAM;AACd,UAAM,OAAO,eAAe;AAC5B,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,WAAO,oBAAC,WAAQ;AAAA,EAClB;AAEA,SACE,oBAAC,cAAc,UAAd,EAAuB,OAAO,cAC5B,UACH;AAEJ;","names":[]}
|
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
2
|
import { createContext, useContext } from "react";
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const context = useContext(TernSecureContext);
|
|
3
|
+
const TernSecureCtx = createContext(null);
|
|
4
|
+
TernSecureCtx.displayName = "TernSecureCtx";
|
|
5
|
+
const useTernSecure = (hookName) => {
|
|
6
|
+
const context = useContext(TernSecureCtx);
|
|
9
7
|
if (!context) {
|
|
10
8
|
throw new Error(
|
|
11
|
-
`${
|
|
9
|
+
`${hookName} must be used within TernSecureProvider`
|
|
12
10
|
);
|
|
13
11
|
}
|
|
14
12
|
return context;
|
|
15
13
|
};
|
|
16
|
-
function TernSecureCtxProvider({ children }) {
|
|
17
|
-
return /* @__PURE__ */ jsx(TernSecureContext.Provider, { value: {
|
|
18
|
-
_contextKey: INTERNAL_CONTEXT_KEY
|
|
19
|
-
}, children });
|
|
20
|
-
}
|
|
21
14
|
export {
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
TernSecureCtx,
|
|
16
|
+
useTernSecure
|
|
24
17
|
};
|
|
25
18
|
//# sourceMappingURL=TernSecureCtx.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/boundary/TernSecureCtx.tsx"],"sourcesContent":["'use client'\r\n\r\nimport
|
|
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: string | 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,13 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { useInternalContext } from "../../boundary/TernSecureCtx";
|
|
4
|
-
import { AuthStateContext } from "../../app-router/client/TernSecureProvider";
|
|
2
|
+
import { useTernSecure } from "../TernSecureCtx";
|
|
5
3
|
function useAuth() {
|
|
6
|
-
|
|
7
|
-
const authState = useContext(AuthStateContext);
|
|
8
|
-
if (!authState) {
|
|
9
|
-
throw new Error("Auth state not found");
|
|
10
|
-
}
|
|
4
|
+
const authState = useTernSecure("useAuth");
|
|
11
5
|
return {
|
|
12
6
|
userId: authState.userId,
|
|
13
7
|
isLoaded: authState.isLoaded,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/boundary/hooks/useAuth.ts"],"sourcesContent":["'use client'\r\n\r\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/boundary/hooks/useAuth.ts"],"sourcesContent":["'use client'\r\n\r\nimport { useTernSecure } from '../TernSecureCtx'\r\n\r\nexport function useAuth() {\r\n const authState = useTernSecure('useAuth')\r\n\r\n return {\r\n userId: authState.userId,\r\n isLoaded: authState.isLoaded,\r\n error: authState.error,\r\n isSignedIn: authState.isSignedIn\r\n }\r\n}\r\n\r\n"],"mappings":";AAEA,SAAS,qBAAqB;AAEvB,SAAS,UAAU;AACxB,QAAM,YAAY,cAAc,SAAS;AAEzC,SAAO;AAAA,IACL,QAAQ,UAAU;AAAA,IAClB,UAAU,UAAU;AAAA,IACpB,OAAO,UAAU;AAAA,IACjB,YAAY,UAAU;AAAA,EACxB;AACF;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from "react";
|
|
4
|
-
import { signInWithEmail } from "../app-router/
|
|
4
|
+
import { signInWithEmail } from "../app-router/client/auth";
|
|
5
5
|
import { styles } from "../utils/create-styles";
|
|
6
6
|
import { useRouter } from "next/navigation";
|
|
7
7
|
function SignIn({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/sign-in.tsx"],"sourcesContent":["'use client'\r\n\r\nimport React from 'react'\r\nimport { useState } from 'react'\r\nimport { signInWithEmail } from '../app-router/
|
|
1
|
+
{"version":3,"sources":["../../../src/components/sign-in.tsx"],"sourcesContent":["'use client'\r\n\r\nimport React from 'react'\r\nimport { useState } from 'react'\r\nimport { signInWithEmail } from '../app-router/client/auth'\r\nimport { styles } from '../utils/create-styles'\r\nimport { useRouter } from 'next/navigation'\r\n\r\nexport interface SignInProps {\r\n onError?: (error: Error) => void\r\n className?: string\r\n style?: React.CSSProperties\r\n customStyles?: {\r\n container?: string\r\n header?: string\r\n title?: string\r\n formWrapper?: string\r\n formContainer?: string\r\n form?: string\r\n input?: string\r\n button?: string\r\n errorText?: string\r\n label?: string\r\n }\r\n}\r\n\r\nexport function SignIn({ \r\n onError, \r\n className,\r\n style,\r\n customStyles = {}\r\n}: SignInProps) {\r\n\r\n const [loading, setLoading] = useState(false)\r\n const [error, setError] = useState('')\r\n const [email, setEmail] = useState('')\r\n const [password, setPassword] = useState('')\r\n const router = useRouter()\r\n\r\n const handleSubmit = async (e: React.FormEvent) => {\r\n e.preventDefault()\r\n setLoading(true)\r\n try {\r\n const user = await signInWithEmail(email, password)\r\n if (user) {\r\n router.push('/')\r\n }\r\n } catch (err) {\r\n const errorMessage = err instanceof Error ? err.message : 'Failed to sign in'\r\n setError(errorMessage)\r\n onError?.(err instanceof Error ? err : new Error('Failed to sign in'))\r\n } finally {\r\n setLoading(false)\r\n }\r\n }\r\n\r\n return (\r\n <div className={`${styles.container} ${customStyles.container || ''}`} style={style}>\r\n <div className={`${styles.header} ${customStyles.header || ''}`}>\r\n <h2 className={`${styles.title} ${customStyles.title || ''}`}>\r\n Sign in to your account\r\n </h2>\r\n </div>\r\n \r\n <div className={`${styles.formWrapper} ${customStyles.formWrapper || ''}`}>\r\n <div className={`${styles.formContainer} ${customStyles.formContainer || ''}`}>\r\n <form \r\n onSubmit={handleSubmit} \r\n className={`${styles.form} ${customStyles.form || ''} ${className}`}\r\n role=\"form\"\r\n aria-label=\"Sign in form\"\r\n >\r\n {error && (\r\n <div \r\n className={`${styles.error} ${customStyles.errorText || ''}`}\r\n role=\"alert\"\r\n aria-live=\"polite\"\r\n >\r\n {error}\r\n </div>\r\n )}\r\n <div>\r\n <label htmlFor=\"email\" className={`${styles.label} ${customStyles.label || ''}`}>\r\n Email\r\n </label>\r\n <input\r\n id=\"email\"\r\n name=\"email\"\r\n type=\"email\"\r\n placeholder=\"Enter your email\"\r\n required\r\n value={email}\r\n onChange={(e) => setEmail(e.target.value)}\r\n className={`${styles.input} ${customStyles.input || ''}`}\r\n disabled={loading}\r\n aria-required=\"true\"\r\n aria-invalid={!!error}\r\n />\r\n </div>\r\n <div>\r\n <label htmlFor=\"password\" className={`${styles.label} ${customStyles.label || ''}`}>\r\n Password\r\n </label>\r\n <input\r\n id=\"password\"\r\n name=\"password\"\r\n type=\"password\"\r\n placeholder=\"Enter your password\"\r\n required\r\n value={password}\r\n onChange={(e) => setPassword(e.target.value)}\r\n className={`${styles.input} ${customStyles.input || ''}`}\r\n disabled={loading}\r\n aria-required=\"true\"\r\n aria-invalid={!!error}\r\n />\r\n </div>\r\n <button \r\n type=\"submit\" \r\n disabled={loading}\r\n className={`${styles.button} ${customStyles.button || ''}`}\r\n data-testid=\"sign-in-submit\"\r\n >\r\n {loading ? 'Signing in...' : 'Sign in'}\r\n </button>\r\n </form>\r\n </div>\r\n </div>\r\n </div>\r\n )\r\n}\r\n\r\n"],"mappings":"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","names":[]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TernSecureAuth, TernSecureFirestore } from "./utils/client-init";
|
|
2
2
|
import { loadFireConfig, validateConfig } from "./utils/config";
|
|
3
|
-
import { signInWithEmail } from "./app-router/
|
|
4
|
-
import { TernSecureProvider } from "./app-router/
|
|
3
|
+
import { signInWithEmail } from "./app-router/client/auth";
|
|
4
|
+
import { TernSecureProvider } from "./app-router/client/TernSecureProvider";
|
|
5
5
|
import { useAuth } from "./boundary/hooks/useAuth";
|
|
6
6
|
import { SignIn } from "./components/sign-in";
|
|
7
7
|
export {
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["//import { TernSecureServerProvider } from './app-router/server/TernSecureServerProvider'\r\n//import type { TernSecureState } from './app-router/client/TernSecureProvider'\r\nexport { TernSecureAuth, TernSecureFirestore } from './utils/client-init'\r\nexport { loadFireConfig, validateConfig } from './utils/config'\r\nexport { signInWithEmail } from './app-router/
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["//import { TernSecureServerProvider } from './app-router/server/TernSecureServerProvider'\r\n//import type { TernSecureState } from './app-router/client/TernSecureProvider'\r\nexport { TernSecureAuth, TernSecureFirestore } from './utils/client-init'\r\nexport { loadFireConfig, validateConfig } from './utils/config'\r\nexport { signInWithEmail } from './app-router/client/auth'\r\n//export { useInternalContext } from './boundary/TernSecureCtx'\r\n//export { TernSecureClientProvider } from './app-router/client/TernSecureProvider'\r\nexport { TernSecureProvider } from './app-router/client/TernSecureProvider'\r\nexport { useAuth } from './boundary/hooks/useAuth' \r\nexport { SignIn } from './components/sign-in'\r\n\r\n//export const TernSecureProvider = TernSecureServerProvider\r\n//export type { TernSecureState }"],"mappings":"AAEA,SAAS,gBAAgB,2BAA2B;AACpD,SAAS,gBAAgB,sBAAsB;AAC/C,SAAS,uBAAuB;AAGhC,SAAS,0BAA0B;AACnC,SAAS,eAAe;AACxB,SAAS,cAAc;","names":[]}
|
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Root Provider for TernSecure
|
|
4
|
+
* Use this in your Next.js App Router root layout
|
|
5
|
+
* Automatically handles client/server boundary and authentication state
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // app/layout.tsx
|
|
9
|
+
* import { TernSecureProvider } from '@tern/secure'
|
|
10
|
+
*
|
|
11
|
+
* export default function RootLayout({ children }) {
|
|
12
|
+
* return (
|
|
13
|
+
* <html>
|
|
14
|
+
* <body>
|
|
15
|
+
* <TernSecureProvider>
|
|
16
|
+
* {children}
|
|
17
|
+
* </TernSecureProvider>
|
|
18
|
+
* </body>
|
|
19
|
+
* </html>
|
|
20
|
+
* )
|
|
21
|
+
* }
|
|
22
|
+
*/
|
|
23
|
+
export declare function TernSecureProvider({ children }: {
|
|
10
24
|
children: React.ReactNode;
|
|
11
|
-
Loading?: React.ComponentType;
|
|
12
25
|
}): import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
export {};
|
|
14
26
|
//# 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,
|
|
1
|
+
{"version":3,"file":"TernSecureProvider.d.ts","sourceRoot":"","sources":["../../../../src/app-router/client/TernSecureProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAgBzB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CAM7E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/app-router/
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/app-router/client/auth.ts"],"names":[],"mappings":"AAQA,wBAAsB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,0CAIpE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface TernSecureClientProviderProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
Loading?: React.ComponentType;
|
|
5
|
+
}
|
|
6
|
+
export declare function TernSecureClientProvider({ children, Loading }: TernSecureClientProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=TernSecureClientProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TernSecureClientProvider.d.ts","sourceRoot":"","sources":["../../../src/boundary/TernSecureClientProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAuC,MAAM,OAAO,CAAA;AAK3D,UAAU,6BAA6B;IACrC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,OAAO,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC9B;AAED,wBAAgB,wBAAwB,CAAC,EACvC,QAAQ,EACR,OAAqC,EACtC,EAAE,6BAA6B,2CA4C/B"}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare function TernSecureCtxProvider({ children }: {
|
|
11
|
-
children: React.ReactNode;
|
|
12
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
export interface TernSecureState {
|
|
2
|
+
userId: string | null;
|
|
3
|
+
isLoaded: boolean;
|
|
4
|
+
error: string | null;
|
|
5
|
+
isSignedIn: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type TernSecureCtxValue = TernSecureState;
|
|
8
|
+
export declare const TernSecureCtx: import("react").Context<TernSecureState | null>;
|
|
9
|
+
export declare const useTernSecure: (hookName: string) => TernSecureState;
|
|
13
10
|
//# sourceMappingURL=TernSecureCtx.d.ts.map
|
|
@@ -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,MAAM,GAAG,IAAI,CAAA;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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../../../src/boundary/hooks/useAuth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../../../src/boundary/hooks/useAuth.ts"],"names":[],"mappings":"AAIA,wBAAgB,OAAO;;;;;EAStB"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { TernSecureAuth, TernSecureFirestore } from './utils/client-init';
|
|
2
2
|
export { loadFireConfig, validateConfig } from './utils/config';
|
|
3
|
-
export { signInWithEmail } from './app-router/
|
|
4
|
-
export { TernSecureProvider } from './app-router/
|
|
3
|
+
export { signInWithEmail } from './app-router/client/auth';
|
|
4
|
+
export { TernSecureProvider } from './app-router/client/TernSecureProvider';
|
|
5
5
|
export { useAuth } from './boundary/hooks/useAuth';
|
|
6
6
|
export { SignIn } from './components/sign-in';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAG1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAG1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAA;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
var TernSecureServerProvider_exports = {};
|
|
31
|
-
__export(TernSecureServerProvider_exports, {
|
|
32
|
-
TernSecureProvider: () => TernSecureProvider
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(TernSecureServerProvider_exports);
|
|
35
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
-
var import_dynamic = __toESM(require("next/dynamic"));
|
|
37
|
-
const TernSecureClientProvider = (0, import_dynamic.default)(
|
|
38
|
-
() => import("../client/TernSecureProvider").then((mod) => mod.TernSecureClientProvider),
|
|
39
|
-
{ ssr: false }
|
|
40
|
-
);
|
|
41
|
-
function TernSecureProvider({ children }) {
|
|
42
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TernSecureClientProvider, { children });
|
|
43
|
-
}
|
|
44
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
-
0 && (module.exports = {
|
|
46
|
-
TernSecureProvider
|
|
47
|
-
});
|
|
48
|
-
//# sourceMappingURL=TernSecureServerProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/app-router/server/TernSecureServerProvider.tsx"],"sourcesContent":["'use client'\r\n\r\nimport React from \"react\"\r\nimport dynamic from \"next/dynamic\"\r\n\r\nconst TernSecureClientProvider = dynamic(\r\n () => import(\"../client/TernSecureProvider\").then(mod => mod.TernSecureClientProvider),\r\n { ssr: false }\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;AAyCM;AAtCN,qBAAoB;AAEpB,MAAM,+BAA2B,eAAAA;AAAA,EAC/B,MAAM,OAAO,8BAA8B,EAAE,KAAK,SAAO,IAAI,wBAAwB;AAAA,EACrF,EAAE,KAAK,MAAM;AACf;AA+BO,SAAS,mBAAmB,EAAE,SAAS,GAAkC;AAC9E,SACI,4CAAC,4BACI,UACL;AAEN;","names":["dynamic"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import dynamic from "next/dynamic";
|
|
4
|
-
const TernSecureClientProvider = dynamic(
|
|
5
|
-
() => import("../client/TernSecureProvider").then((mod) => mod.TernSecureClientProvider),
|
|
6
|
-
{ ssr: false }
|
|
7
|
-
);
|
|
8
|
-
function TernSecureProvider({ children }) {
|
|
9
|
-
return /* @__PURE__ */ jsx(TernSecureClientProvider, { children });
|
|
10
|
-
}
|
|
11
|
-
export {
|
|
12
|
-
TernSecureProvider
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=TernSecureServerProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/app-router/server/TernSecureServerProvider.tsx"],"sourcesContent":["'use client'\r\n\r\nimport React from \"react\"\r\nimport dynamic from \"next/dynamic\"\r\n\r\nconst TernSecureClientProvider = dynamic(\r\n () => import(\"../client/TernSecureProvider\").then(mod => mod.TernSecureClientProvider),\r\n { ssr: false }\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":";AAyCM;AAtCN,OAAO,aAAa;AAEpB,MAAM,2BAA2B;AAAA,EAC/B,MAAM,OAAO,8BAA8B,EAAE,KAAK,SAAO,IAAI,wBAAwB;AAAA,EACrF,EAAE,KAAK,MAAM;AACf;AA+BO,SAAS,mBAAmB,EAAE,SAAS,GAAkC;AAC9E,SACI,oBAAC,4BACI,UACL;AAEN;","names":[]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
/**
|
|
3
|
-
* Root Provider for TernSecure
|
|
4
|
-
* Use this in your Next.js App Router root layout
|
|
5
|
-
* Automatically handles client/server boundary and authentication state
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* // app/layout.tsx
|
|
9
|
-
* import { TernSecureProvider } from '@tern/secure'
|
|
10
|
-
*
|
|
11
|
-
* export default function RootLayout({ children }) {
|
|
12
|
-
* return (
|
|
13
|
-
* <html>
|
|
14
|
-
* <body>
|
|
15
|
-
* <TernSecureProvider>
|
|
16
|
-
* {children}
|
|
17
|
-
* </TernSecureProvider>
|
|
18
|
-
* </body>
|
|
19
|
-
* </html>
|
|
20
|
-
* )
|
|
21
|
-
* }
|
|
22
|
-
*/
|
|
23
|
-
export declare function TernSecureProvider({ children }: {
|
|
24
|
-
children: React.ReactNode;
|
|
25
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
26
|
-
//# sourceMappingURL=TernSecureServerProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TernSecureServerProvider.d.ts","sourceRoot":"","sources":["../../../../src/app-router/server/TernSecureServerProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAgBzB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CAM7E"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|