@tern-secure/nextjs 3.1.36 → 3.1.38
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/index.js +20 -4
- package/dist/cjs/app-router/client/index.js.map +3 -3
- package/dist/cjs/app-router/server/index.js +36 -14
- package/dist/cjs/app-router/server/index.js.map +3 -3
- package/dist/cjs/components/index.js +17 -25
- package/dist/cjs/components/index.js.map +4 -4
- package/dist/cjs/index.js +53 -26
- package/dist/cjs/index.js.map +3 -3
- package/dist/esm/app-router/client/index.js +1 -1
- package/dist/esm/app-router/client/providers/ternSecureClientProvider.d.ts +26 -2
- package/dist/esm/app-router/client/providers/ternSecureClientProvider.d.ts.map +1 -1
- package/dist/esm/app-router/client/providers/ternSecureContext.d.ts +21 -3
- package/dist/esm/app-router/client/providers/ternSecureContext.d.ts.map +1 -1
- package/dist/esm/app-router/server/index.js +1 -1
- package/dist/esm/app-router/server/providers/TernSecureServerProvider.d.ts.map +1 -1
- package/dist/esm/{chunk-HUJ3EKGN.js → chunk-DLYDLPO5.js} +13 -5
- package/dist/esm/chunk-DLYDLPO5.js.map +7 -0
- package/dist/esm/{chunk-MDMNIKQP.js → chunk-RTEDIKQU.js} +20 -4
- package/dist/esm/chunk-RTEDIKQU.js.map +7 -0
- package/dist/esm/components/index.js +1 -1
- package/dist/esm/hooks/useAuth.d.ts +4 -1
- package/dist/esm/hooks/useAuth.d.ts.map +1 -1
- package/dist/esm/index.js +8 -3
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/ternSecureClientProvider-AFCR7MAX.js +8 -0
- package/package.json +5 -1
- package/dist/esm/chunk-HUJ3EKGN.js.map +0 -7
- package/dist/esm/chunk-MDMNIKQP.js.map +0 -7
- package/dist/esm/ternSecureClientProvider-T4QUTB3T.js +0 -8
- /package/dist/esm/{ternSecureClientProvider-T4QUTB3T.js.map → ternSecureClientProvider-AFCR7MAX.js.map} +0 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
9
|
var __export = (target, all) => {
|
|
8
10
|
for (var name in all)
|
|
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
18
|
}
|
|
17
19
|
return to;
|
|
18
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
|
+
));
|
|
19
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
30
|
|
|
21
31
|
// src/app-router/client/index.ts
|
|
@@ -83,23 +93,29 @@ async function signInWithEmail({
|
|
|
83
93
|
|
|
84
94
|
// src/app-router/client/providers/ternSecureContext.tsx
|
|
85
95
|
var import_react = require("react");
|
|
86
|
-
var INTERNAL_CONTEXT_KEY = Symbol("
|
|
96
|
+
var INTERNAL_CONTEXT_KEY = Symbol("TERN_SECURE_CONTEXT");
|
|
87
97
|
var TernSecureContext = (0, import_react.createContext)(null);
|
|
88
|
-
var useInternalContext = (
|
|
98
|
+
var useInternalContext = (hookName) => {
|
|
89
99
|
const context = (0, import_react.useContext)(TernSecureContext);
|
|
90
100
|
if (!context || context._contextKey !== INTERNAL_CONTEXT_KEY) {
|
|
91
101
|
throw new Error(
|
|
92
|
-
`${
|
|
102
|
+
`${hookName || "Hook"} must be used within TernSecureProvider. Please wrap your component with TernSecureProvider.`
|
|
93
103
|
);
|
|
94
104
|
}
|
|
95
105
|
return context;
|
|
96
106
|
};
|
|
97
107
|
|
|
98
108
|
// src/app-router/client/providers/ternSecureClientProvider.tsx
|
|
109
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
99
110
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
100
111
|
function TernSecureClientProvider({ children }) {
|
|
101
|
-
|
|
112
|
+
const contextValue = import_react2.default.useMemo(
|
|
113
|
+
() => ({ _contextKey: INTERNAL_CONTEXT_KEY }),
|
|
114
|
+
[]
|
|
115
|
+
);
|
|
116
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TernSecureContext.Provider, { value: contextValue, children });
|
|
102
117
|
}
|
|
118
|
+
TernSecureClientProvider.displayName = "TernSecureClientProvider";
|
|
103
119
|
// Annotate the CommonJS export names for ESM import in node:
|
|
104
120
|
0 && (module.exports = {
|
|
105
121
|
TernSecureAuth,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/app-router/client/index.ts", "../../../../src/app-router/client/client-init.ts", "../../../../src/app-router/client/config.ts", "../../../../src/app-router/client/auth.ts", "../../../../src/app-router/client/providers/ternSecureContext.tsx", "../../../../src/app-router/client/providers/ternSecureClientProvider.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\r\nexport { \r\n TernSecureAuth,\r\n TernSecureFirestore,\r\n TernSecureStorage \r\n } from './client-init';\r\n\r\n export type { SignInCredentials } from './auth'\r\n\r\n export { signInWithEmail} from './auth'\r\n export { loadFireConfig, validateConfig } from './config';\r\n export { TernSecureContext, useInternalContext } from './providers/ternSecureContext';\r\n export { TernSecureClientProvider } from './providers/ternSecureClientProvider'", "import { getApps, initializeApp } from 'firebase/app';\r\nimport { getAuth, setPersistence, browserSessionPersistence } from 'firebase/auth';\r\nimport { getFirestore } from 'firebase/firestore';\r\nimport { getStorage } from 'firebase/storage';\r\nimport { loadFireConfig, validateConfig } from './config';\r\n\r\n// Initialize immediately\r\nconst app = (() => {\r\n const config = validateConfig(loadFireConfig());\r\n return getApps().length ? getApps()[0] : initializeApp(config);\r\n})();\r\n\r\nconst auth = getAuth(app);\r\nsetPersistence(auth, browserSessionPersistence); //to change later user should be able to choose persistance\r\nconst firestore = getFirestore(app);\r\nconst storage = getStorage(app);\r\n\r\nexport const TernSecureAuth = () => auth;\r\nexport const TernSecureFirestore = () => firestore;\r\nexport const TernSecureStorage = () => storage;", "import { TernSecureConfig } from \"../../types\";\r\n\r\nexport const loadFireConfig = (): TernSecureConfig => ({\r\n apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY as string,\r\n authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN as string,\r\n projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID as string,\r\n storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET as string,\r\n messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID as string,\r\n appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID as string,\r\n measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID as string,\r\n});\r\n\r\nexport const validateConfig = (config: TernSecureConfig): TernSecureConfig => {\r\n Object.entries(config).forEach(([key, value]) => {\r\n if (!value) {\r\n throw new Error(`Missing environment variable: NEXT_PUBLIC_FIREBASE_${key.toUpperCase()}`);\r\n }\r\n });\r\n return config;\r\n};", "import { TernSecureAuth } from './index'\r\nimport { signInWithEmailAndPassword, type UserCredential } from 'firebase/auth'\r\n\r\nexport interface SignInCredentials {\r\n email: string\r\n password: string\r\n}\r\n\r\nexport async function signInWithEmail({ \r\n email, \r\n password \r\n}: SignInCredentials): Promise<UserCredential> {\r\n const auth = TernSecureAuth()\r\n return signInWithEmailAndPassword(auth, email, password)\r\n} ", "'use client'\r\n\r\nimport { createContext, useContext} from 'react'\r\n\r\ninterface TernSecureContextType {\r\n _contextKey:
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["import_auth", "auth"]
|
|
4
|
+
"sourcesContent": ["'use client'\r\nexport { \r\n TernSecureAuth,\r\n TernSecureFirestore,\r\n TernSecureStorage \r\n } from './client-init';\r\n\r\n export type { SignInCredentials } from './auth'\r\n\r\n export { signInWithEmail} from './auth'\r\n export { loadFireConfig, validateConfig } from './config';\r\n export { TernSecureContext, useInternalContext } from './providers/ternSecureContext';\r\n export { TernSecureClientProvider } from './providers/ternSecureClientProvider'", "import { getApps, initializeApp } from 'firebase/app';\r\nimport { getAuth, setPersistence, browserSessionPersistence } from 'firebase/auth';\r\nimport { getFirestore } from 'firebase/firestore';\r\nimport { getStorage } from 'firebase/storage';\r\nimport { loadFireConfig, validateConfig } from './config';\r\n\r\n// Initialize immediately\r\nconst app = (() => {\r\n const config = validateConfig(loadFireConfig());\r\n return getApps().length ? getApps()[0] : initializeApp(config);\r\n})();\r\n\r\nconst auth = getAuth(app);\r\nsetPersistence(auth, browserSessionPersistence); //to change later user should be able to choose persistance\r\nconst firestore = getFirestore(app);\r\nconst storage = getStorage(app);\r\n\r\nexport const TernSecureAuth = () => auth;\r\nexport const TernSecureFirestore = () => firestore;\r\nexport const TernSecureStorage = () => storage;", "import { TernSecureConfig } from \"../../types\";\r\n\r\nexport const loadFireConfig = (): TernSecureConfig => ({\r\n apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY as string,\r\n authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN as string,\r\n projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID as string,\r\n storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET as string,\r\n messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID as string,\r\n appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID as string,\r\n measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID as string,\r\n});\r\n\r\nexport const validateConfig = (config: TernSecureConfig): TernSecureConfig => {\r\n Object.entries(config).forEach(([key, value]) => {\r\n if (!value) {\r\n throw new Error(`Missing environment variable: NEXT_PUBLIC_FIREBASE_${key.toUpperCase()}`);\r\n }\r\n });\r\n return config;\r\n};", "import { TernSecureAuth } from './index'\r\nimport { signInWithEmailAndPassword, type UserCredential } from 'firebase/auth'\r\n\r\nexport interface SignInCredentials {\r\n email: string\r\n password: string\r\n}\r\n\r\nexport async function signInWithEmail({ \r\n email, \r\n password \r\n}: SignInCredentials): Promise<UserCredential> {\r\n const auth = TernSecureAuth()\r\n return signInWithEmailAndPassword(auth, email, password)\r\n} ", "'use client'\r\n\r\nimport { createContext, useContext } from 'react'\r\n\r\n/**\r\n * Internal context type for TernSecure authentication\r\n * @internal\r\n */\r\ninterface TernSecureContextType {\r\n readonly _contextKey: symbol\r\n}\r\n\r\n/**\r\n * Internal symbol used for context validation\r\n * @internal\r\n */\r\nconst INTERNAL_CONTEXT_KEY = Symbol('TERN_SECURE_CONTEXT')\r\n\r\n/**\r\n * Context for TernSecure authentication\r\n * @internal\r\n */\r\nconst TernSecureContext = createContext<TernSecureContextType | null>(null)\r\n\r\n/**\r\n * Hook to verify that components are rendered within the TernSecure provider\r\n * @param hookName - Name of the hook being used (for better error messages)\r\n * @throws {Error} When used outside of TernSecureProvider\r\n * @internal\r\n */\r\nconst useInternalContext = (hookName?: string): TernSecureContextType => {\r\n const context = useContext(TernSecureContext)\r\n \r\n if (!context || context._contextKey !== INTERNAL_CONTEXT_KEY) {\r\n throw new Error(\r\n `${hookName || 'Hook'} must be used within TernSecureProvider. ` +\r\n 'Please wrap your component with TernSecureProvider.'\r\n )\r\n }\r\n \r\n return context\r\n}\r\n\r\nexport {\r\n type TernSecureContextType,\r\n TernSecureContext,\r\n useInternalContext,\r\n INTERNAL_CONTEXT_KEY\r\n}", "'use client'\r\n\r\nimport React from 'react'\r\nimport { INTERNAL_CONTEXT_KEY, TernSecureContext, TernSecureContextType } from './ternSecureContext'\r\n\r\n/**\r\n * Props for the TernSecureClientProvider component\r\n */\r\ninterface TernSecureClientProviderProps {\r\n /** React child elements to be wrapped by the provider */\r\n children: React.ReactNode\r\n}\r\n\r\n/**\r\n * Provider component for TernSecure authentication\r\n * Must be used to wrap any components that use TernSecure hooks\r\n * \r\n * @example\r\n * ```tsx\r\n * function App() {\r\n * return (\r\n * <TernSecureClientProvider>\r\n * <YourApp />\r\n * </TernSecureClientProvider>\r\n * )\r\n * }\r\n * ```\r\n */\r\nexport function TernSecureClientProvider({ children }: TernSecureClientProviderProps): JSX.Element {\r\n // Memoize the context value to prevent unnecessary re-renders\r\n const contextValue = React.useMemo<TernSecureContextType>(\r\n () => ({ _contextKey: INTERNAL_CONTEXT_KEY }),\r\n []\r\n )\r\n\r\n return (\r\n <TernSecureContext.Provider value={contextValue}>\r\n {children}\r\n </TernSecureContext.Provider>\r\n )\r\n}\r\n\r\n// Add display name for better debugging\r\nTernSecureClientProvider.displayName = 'TernSecureClientProvider'"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAuC;AACvC,kBAAmE;AACnE,uBAA6B;AAC7B,qBAA2B;;;ACDpB,IAAM,iBAAiB,OAAyB;AAAA,EACrD,QAAQ,QAAQ,IAAI;AAAA,EACpB,YAAY,QAAQ,IAAI;AAAA,EACxB,WAAW,QAAQ,IAAI;AAAA,EACvB,eAAe,QAAQ,IAAI;AAAA,EAC3B,mBAAmB,QAAQ,IAAI;AAAA,EAC/B,OAAO,QAAQ,IAAI;AAAA,EACnB,eAAe,QAAQ,IAAI;AAC7B;AAEO,IAAM,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UAAlB,EAA2B,OAAO,cAChC,UACH;AAEJ;AAGA,yBAAyB,cAAc;",
|
|
6
|
+
"names": ["import_auth", "auth", "import_react", "React"]
|
|
7
7
|
}
|
|
@@ -37,7 +37,7 @@ var init_ternSecureContext = __esm({
|
|
|
37
37
|
"use strict";
|
|
38
38
|
"use client";
|
|
39
39
|
import_react = require("react");
|
|
40
|
-
INTERNAL_CONTEXT_KEY = Symbol("
|
|
40
|
+
INTERNAL_CONTEXT_KEY = Symbol("TERN_SECURE_CONTEXT");
|
|
41
41
|
TernSecureContext = (0, import_react.createContext)(null);
|
|
42
42
|
}
|
|
43
43
|
});
|
|
@@ -48,15 +48,21 @@ __export(ternSecureClientProvider_exports, {
|
|
|
48
48
|
TernSecureClientProvider: () => TernSecureClientProvider
|
|
49
49
|
});
|
|
50
50
|
function TernSecureClientProvider({ children }) {
|
|
51
|
-
|
|
51
|
+
const contextValue = import_react2.default.useMemo(
|
|
52
|
+
() => ({ _contextKey: INTERNAL_CONTEXT_KEY }),
|
|
53
|
+
[]
|
|
54
|
+
);
|
|
55
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TernSecureContext.Provider, { value: contextValue, children });
|
|
52
56
|
}
|
|
53
|
-
var import_jsx_runtime;
|
|
57
|
+
var import_react2, import_jsx_runtime;
|
|
54
58
|
var init_ternSecureClientProvider = __esm({
|
|
55
59
|
"src/app-router/client/providers/ternSecureClientProvider.tsx"() {
|
|
56
60
|
"use strict";
|
|
57
61
|
"use client";
|
|
62
|
+
import_react2 = __toESM(require("react"), 1);
|
|
58
63
|
init_ternSecureContext();
|
|
59
64
|
import_jsx_runtime = require("react/jsx-runtime");
|
|
65
|
+
TernSecureClientProvider.displayName = "TernSecureClientProvider";
|
|
60
66
|
}
|
|
61
67
|
});
|
|
62
68
|
|
|
@@ -68,30 +74,46 @@ __export(server_exports, {
|
|
|
68
74
|
module.exports = __toCommonJS(server_exports);
|
|
69
75
|
|
|
70
76
|
// src/app-router/server/providers/TernSecureServerProvider.tsx
|
|
71
|
-
var
|
|
77
|
+
var import_react3 = __toESM(require("react"), 1);
|
|
72
78
|
var import_dynamic = __toESM(require("next/dynamic"), 1);
|
|
73
79
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
80
|
+
var LoadingProvider = () => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
81
|
+
"div",
|
|
82
|
+
{
|
|
83
|
+
"aria-label": "Loading authentication provider...",
|
|
84
|
+
role: "status",
|
|
85
|
+
style: { display: "none" }
|
|
86
|
+
}
|
|
87
|
+
);
|
|
74
88
|
var TernSecureClientProvider2 = (0, import_dynamic.default)(
|
|
75
89
|
() => Promise.resolve().then(() => (init_ternSecureClientProvider(), ternSecureClientProvider_exports)).then((mod) => mod.TernSecureClientProvider),
|
|
76
90
|
{
|
|
77
|
-
ssr: false
|
|
78
|
-
|
|
91
|
+
ssr: false,
|
|
92
|
+
loading: LoadingProvider
|
|
93
|
+
// Return null or a loading indicator
|
|
79
94
|
}
|
|
80
95
|
);
|
|
81
96
|
function TernSecureProvider({ children }) {
|
|
82
|
-
const
|
|
83
|
-
|
|
97
|
+
const startTime = process.env.NODE_ENV === "development" ? performance.now() : 0;
|
|
98
|
+
const isRootLayout = import_react3.default.Children.toArray(children).some(
|
|
99
|
+
(child) => import_react3.default.isValidElement(child) && child.type === "html"
|
|
84
100
|
);
|
|
101
|
+
import_react3.default.useEffect(() => {
|
|
102
|
+
if (process.env.NODE_ENV === "development") {
|
|
103
|
+
const endTime = performance.now();
|
|
104
|
+
console.debug(`TernSecure provider mounted in ${endTime - startTime}ms`);
|
|
105
|
+
}
|
|
106
|
+
}, [startTime]);
|
|
85
107
|
if (isRootLayout) {
|
|
86
|
-
return
|
|
87
|
-
if (
|
|
88
|
-
return
|
|
108
|
+
return import_react3.default.Children.map(children, (child) => {
|
|
109
|
+
if (import_react3.default.isValidElement(child) && child.type === "html") {
|
|
110
|
+
return import_react3.default.cloneElement(
|
|
89
111
|
child,
|
|
90
112
|
{},
|
|
91
|
-
|
|
92
|
-
if (
|
|
113
|
+
import_react3.default.Children.map(child.props.children, (bodyChild) => {
|
|
114
|
+
if (import_react3.default.isValidElement(bodyChild) && bodyChild.type === "body") {
|
|
93
115
|
const bodyProps = bodyChild.props;
|
|
94
|
-
return
|
|
116
|
+
return import_react3.default.cloneElement(
|
|
95
117
|
bodyChild,
|
|
96
118
|
{},
|
|
97
119
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TernSecureClientProvider2, { children: bodyProps.children })
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/app-router/client/providers/ternSecureContext.tsx", "../../../../src/app-router/client/providers/ternSecureClientProvider.tsx", "../../../../src/app-router/server/index.ts", "../../../../src/app-router/server/providers/TernSecureServerProvider.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\r\n\r\nimport { createContext, useContext} from 'react'\r\n\r\ninterface TernSecureContextType {\r\n _contextKey:
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAEA,
|
|
6
|
-
"names": ["import_react", "import_jsx_runtime", "TernSecureClientProvider", "dynamic", "React"]
|
|
4
|
+
"sourcesContent": ["'use client'\r\n\r\nimport { createContext, useContext } from 'react'\r\n\r\n/**\r\n * Internal context type for TernSecure authentication\r\n * @internal\r\n */\r\ninterface TernSecureContextType {\r\n readonly _contextKey: symbol\r\n}\r\n\r\n/**\r\n * Internal symbol used for context validation\r\n * @internal\r\n */\r\nconst INTERNAL_CONTEXT_KEY = Symbol('TERN_SECURE_CONTEXT')\r\n\r\n/**\r\n * Context for TernSecure authentication\r\n * @internal\r\n */\r\nconst TernSecureContext = createContext<TernSecureContextType | null>(null)\r\n\r\n/**\r\n * Hook to verify that components are rendered within the TernSecure provider\r\n * @param hookName - Name of the hook being used (for better error messages)\r\n * @throws {Error} When used outside of TernSecureProvider\r\n * @internal\r\n */\r\nconst useInternalContext = (hookName?: string): TernSecureContextType => {\r\n const context = useContext(TernSecureContext)\r\n \r\n if (!context || context._contextKey !== INTERNAL_CONTEXT_KEY) {\r\n throw new Error(\r\n `${hookName || 'Hook'} must be used within TernSecureProvider. ` +\r\n 'Please wrap your component with TernSecureProvider.'\r\n )\r\n }\r\n \r\n return context\r\n}\r\n\r\nexport {\r\n type TernSecureContextType,\r\n TernSecureContext,\r\n useInternalContext,\r\n INTERNAL_CONTEXT_KEY\r\n}", "'use client'\r\n\r\nimport React from 'react'\r\nimport { INTERNAL_CONTEXT_KEY, TernSecureContext, TernSecureContextType } from './ternSecureContext'\r\n\r\n/**\r\n * Props for the TernSecureClientProvider component\r\n */\r\ninterface TernSecureClientProviderProps {\r\n /** React child elements to be wrapped by the provider */\r\n children: React.ReactNode\r\n}\r\n\r\n/**\r\n * Provider component for TernSecure authentication\r\n * Must be used to wrap any components that use TernSecure hooks\r\n * \r\n * @example\r\n * ```tsx\r\n * function App() {\r\n * return (\r\n * <TernSecureClientProvider>\r\n * <YourApp />\r\n * </TernSecureClientProvider>\r\n * )\r\n * }\r\n * ```\r\n */\r\nexport function TernSecureClientProvider({ children }: TernSecureClientProviderProps): JSX.Element {\r\n // Memoize the context value to prevent unnecessary re-renders\r\n const contextValue = React.useMemo<TernSecureContextType>(\r\n () => ({ _contextKey: INTERNAL_CONTEXT_KEY }),\r\n []\r\n )\r\n\r\n return (\r\n <TernSecureContext.Provider value={contextValue}>\r\n {children}\r\n </TernSecureContext.Provider>\r\n )\r\n}\r\n\r\n// Add display name for better debugging\r\nTernSecureClientProvider.displayName = 'TernSecureClientProvider'", "export { TernSecureProvider } from './providers/TernSecureServerProvider';", "import React, { ReactNode } from 'react';\r\nimport dynamic from 'next/dynamic'\r\n\r\ninterface TernSecureProviderProps {\r\n children: ReactNode;\r\n}\r\n\r\n// Lightweight loading component\r\nconst LoadingProvider = () => (\r\n <div \r\n aria-label=\"Loading authentication provider...\" \r\n role=\"status\"\r\n style={{ display: 'none' }}\r\n />\r\n)\r\n\r\n// Dynamically import the client provider with no SSR\r\nconst TernSecureClientProvider = dynamic(\r\n () => import('../../client/providers/ternSecureClientProvider').then(mod => mod.TernSecureClientProvider),\r\n { \r\n ssr: false,\r\n loading: LoadingProvider // Return null or a loading indicator\r\n }\r\n)\r\n\r\nexport function TernSecureProvider({ children }: TernSecureProviderProps) {\r\n const startTime = process.env.NODE_ENV === 'development' ? performance.now() : 0\r\n\r\n // Check if the children contain html/body tags\r\n const isRootLayout = React.Children.toArray(children).some(\r\n child => React.isValidElement(child) && child.type === 'html'\r\n );\r\n\r\n // Log performance in development\r\n React.useEffect(() => {\r\n if (process.env.NODE_ENV === 'development') {\r\n const endTime = performance.now()\r\n console.debug(`TernSecure provider mounted in ${endTime - startTime}ms`)\r\n }\r\n }, [startTime])\r\n\r\n if (isRootLayout) {\r\n // If this is the root layout, inject our provider after the body tag\r\n return React.Children.map(children, child => {\r\n if (React.isValidElement(child) && child.type === 'html') {\r\n return React.cloneElement(child, {}, \r\n React.Children.map(child.props.children, bodyChild => {\r\n if (React.isValidElement(bodyChild) && bodyChild.type === 'body') {\r\n // Type assertion to access props safely\r\n const bodyProps = bodyChild.props as { children: ReactNode };\r\n return React.cloneElement(bodyChild, {}, \r\n <TernSecureClientProvider>\r\n {bodyProps.children}\r\n </TernSecureClientProvider>\r\n );\r\n }\r\n return bodyChild;\r\n })\r\n );\r\n }\r\n return child;\r\n });\r\n }\r\n\r\n // For non-root layouts, wrap normally\r\n return <TernSecureClientProvider>{children}</TernSecureClientProvider>;\r\n}"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAEA,cAcM,sBAMA;AAtBN;AAAA;AAAA;AAAA;AAEA,mBAA0C;AAc1C,IAAM,uBAAuB,OAAO,qBAAqB;AAMzD,IAAM,wBAAoB,4BAA4C,IAAI;AAAA;AAAA;;;ACtB1E;AAAA;AAAA;AAAA;AA4BO,SAAS,yBAAyB,EAA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ACxD,eAAO,cAAAA,QAAM;AAAA,UAAa;AAAA,UAAO,CAAC;AAAA,UAChC,cAAAA,QAAM,SAAS,IAAI,MAAM,MAAM,UAAU,eAAa;AACpD,gBAAI,cAAAA,QAAM,eAAe,SAAS,KAAK,UAAU,SAAS,QAAQ;AAEhE,oBAAM,YAAY,UAAU;AAC5B,qBAAO,cAAAA,QAAM;AAAA,gBAAa;AAAA,gBAAW,CAAC;AAAA,gBACpC,6CAACF,2BAAA,EACE,oBAAU,UACb;AAAA,cACF;AAAA,YACF;AACA,mBAAO;AAAA,UACT,CAAC;AAAA,QACH;AAAA,MACF;AACA,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAGA,SAAO,6CAACA,2BAAA,EAA0B,UAAS;AAC7C;",
|
|
6
|
+
"names": ["React", "import_react", "import_react", "import_jsx_runtime", "TernSecureClientProvider", "dynamic", "React"]
|
|
7
7
|
}
|
|
@@ -25,7 +25,7 @@ __export(components_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(components_exports);
|
|
26
26
|
|
|
27
27
|
// src/components/sign-in.tsx
|
|
28
|
-
var
|
|
28
|
+
var import_react = require("react");
|
|
29
29
|
|
|
30
30
|
// src/app-router/client/client-init.ts
|
|
31
31
|
var import_app = require("firebase/app");
|
|
@@ -73,14 +73,6 @@ async function signInWithEmail({
|
|
|
73
73
|
return (0, import_auth2.signInWithEmailAndPassword)(auth2, email, password);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
// src/app-router/client/providers/ternSecureContext.tsx
|
|
77
|
-
var import_react = require("react");
|
|
78
|
-
var INTERNAL_CONTEXT_KEY = Symbol("INTERNAL_CONTEXT_KEY");
|
|
79
|
-
var TernSecureContext = (0, import_react.createContext)(null);
|
|
80
|
-
|
|
81
|
-
// src/app-router/client/providers/ternSecureClientProvider.tsx
|
|
82
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
83
|
-
|
|
84
76
|
// src/utils/create-styles.ts
|
|
85
77
|
var PREFIX = "tern";
|
|
86
78
|
var styleInjection = {
|
|
@@ -200,7 +192,7 @@ var styleConfig = {
|
|
|
200
192
|
var styles = createStyleSheet(styleConfig);
|
|
201
193
|
|
|
202
194
|
// src/components/sign-in.tsx
|
|
203
|
-
var
|
|
195
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
204
196
|
function SignIn({
|
|
205
197
|
onSuccess,
|
|
206
198
|
onError,
|
|
@@ -209,10 +201,10 @@ function SignIn({
|
|
|
209
201
|
style,
|
|
210
202
|
customStyles = {}
|
|
211
203
|
}) {
|
|
212
|
-
const [email, setEmail] = (0,
|
|
213
|
-
const [password, setPassword] = (0,
|
|
214
|
-
const [loading, setLoading] = (0,
|
|
215
|
-
const [error, setError] = (0,
|
|
204
|
+
const [email, setEmail] = (0, import_react.useState)("");
|
|
205
|
+
const [password, setPassword] = (0, import_react.useState)("");
|
|
206
|
+
const [loading, setLoading] = (0, import_react.useState)(false);
|
|
207
|
+
const [error, setError] = (0, import_react.useState)("");
|
|
216
208
|
const handleSubmit = async (e) => {
|
|
217
209
|
e.preventDefault();
|
|
218
210
|
setLoading(true);
|
|
@@ -231,9 +223,9 @@ function SignIn({
|
|
|
231
223
|
setLoading(false);
|
|
232
224
|
}
|
|
233
225
|
};
|
|
234
|
-
return /* @__PURE__ */ (0,
|
|
235
|
-
/* @__PURE__ */ (0,
|
|
236
|
-
/* @__PURE__ */ (0,
|
|
226
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: `${styles.container} ${customStyles.container || ""}`, style, children: [
|
|
227
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `${styles.header} ${customStyles.header || ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: `${styles.title} ${customStyles.title || ""}`, children: "Sign in to your account" }) }),
|
|
228
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `${styles.formWrapper} ${customStyles.formWrapper || ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `${styles.formContainer} ${customStyles.formContainer || ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
237
229
|
"form",
|
|
238
230
|
{
|
|
239
231
|
onSubmit: handleSubmit,
|
|
@@ -241,7 +233,7 @@ function SignIn({
|
|
|
241
233
|
role: "form",
|
|
242
234
|
"aria-label": "Sign in form",
|
|
243
235
|
children: [
|
|
244
|
-
error && /* @__PURE__ */ (0,
|
|
236
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
245
237
|
"div",
|
|
246
238
|
{
|
|
247
239
|
className: `${styles.error} ${customStyles.errorText || ""}`,
|
|
@@ -250,9 +242,9 @@ function SignIn({
|
|
|
250
242
|
children: error
|
|
251
243
|
}
|
|
252
244
|
),
|
|
253
|
-
/* @__PURE__ */ (0,
|
|
254
|
-
/* @__PURE__ */ (0,
|
|
255
|
-
/* @__PURE__ */ (0,
|
|
245
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
246
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: "email", className: `${styles.label} ${customStyles.label || ""}`, children: "Email" }),
|
|
247
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
256
248
|
"input",
|
|
257
249
|
{
|
|
258
250
|
id: "email",
|
|
@@ -268,9 +260,9 @@ function SignIn({
|
|
|
268
260
|
}
|
|
269
261
|
)
|
|
270
262
|
] }),
|
|
271
|
-
/* @__PURE__ */ (0,
|
|
272
|
-
/* @__PURE__ */ (0,
|
|
273
|
-
/* @__PURE__ */ (0,
|
|
263
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
264
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: "password", className: `${styles.label} ${customStyles.label || ""}`, children: "Password" }),
|
|
265
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
274
266
|
"input",
|
|
275
267
|
{
|
|
276
268
|
id: "password",
|
|
@@ -286,7 +278,7 @@ function SignIn({
|
|
|
286
278
|
}
|
|
287
279
|
)
|
|
288
280
|
] }),
|
|
289
|
-
/* @__PURE__ */ (0,
|
|
281
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
290
282
|
"button",
|
|
291
283
|
{
|
|
292
284
|
type: "submit",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/index.ts", "../../../src/components/sign-in.tsx", "../../../src/app-router/client/client-init.ts", "../../../src/app-router/client/config.ts", "../../../src/app-router/client/auth.ts", "../../../src/
|
|
4
|
-
"sourcesContent": ["export { SignIn } from './sign-in';", "import * as React from 'react'\r\nimport { useState } from 'react'\r\nimport { signInWithEmail } from '../app-router/client'\r\nimport { styles } from '../utils/create-styles'\r\n\r\nexport interface SignInProps {\r\n onSuccess?: () => void\r\n onError?: (error: Error) => void\r\n redirectUrl?: string\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 onSuccess, \r\n onError, \r\n redirectUrl,\r\n className = '',\r\n style,\r\n customStyles = {}\r\n}: SignInProps) {\r\n const [email, setEmail] = useState('')\r\n const [password, setPassword] = useState('')\r\n const [loading, setLoading] = useState(false)\r\n const [error, setError] = useState('')\r\n\r\n const handleSubmit = async (e: React.FormEvent) => {\r\n e.preventDefault()\r\n setLoading(true)\r\n setError('')\r\n\r\n try {\r\n await signInWithEmail({ email, password })\r\n onSuccess?.()\r\n \r\n if (redirectUrl) {\r\n window.location.href = redirectUrl\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 type=\"email\"\r\n value={email}\r\n onChange={(e) => setEmail(e.target.value)}\r\n placeholder=\"Enter your email\"\r\n required\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 type=\"password\"\r\n value={password}\r\n onChange={(e) => setPassword(e.target.value)}\r\n placeholder=\"Enter your password\"\r\n required\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", "import { getApps, initializeApp } from 'firebase/app';\r\nimport { getAuth, setPersistence, browserSessionPersistence } from 'firebase/auth';\r\nimport { getFirestore } from 'firebase/firestore';\r\nimport { getStorage } from 'firebase/storage';\r\nimport { loadFireConfig, validateConfig } from './config';\r\n\r\n// Initialize immediately\r\nconst app = (() => {\r\n const config = validateConfig(loadFireConfig());\r\n return getApps().length ? getApps()[0] : initializeApp(config);\r\n})();\r\n\r\nconst auth = getAuth(app);\r\nsetPersistence(auth, browserSessionPersistence); //to change later user should be able to choose persistance\r\nconst firestore = getFirestore(app);\r\nconst storage = getStorage(app);\r\n\r\nexport const TernSecureAuth = () => auth;\r\nexport const TernSecureFirestore = () => firestore;\r\nexport const TernSecureStorage = () => storage;", "import { TernSecureConfig } from \"../../types\";\r\n\r\nexport const loadFireConfig = (): TernSecureConfig => ({\r\n apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY as string,\r\n authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN as string,\r\n projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID as string,\r\n storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET as string,\r\n messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID as string,\r\n appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID as string,\r\n measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID as string,\r\n});\r\n\r\nexport const validateConfig = (config: TernSecureConfig): TernSecureConfig => {\r\n Object.entries(config).forEach(([key, value]) => {\r\n if (!value) {\r\n throw new Error(`Missing environment variable: NEXT_PUBLIC_FIREBASE_${key.toUpperCase()}`);\r\n }\r\n });\r\n return config;\r\n};", "import { TernSecureAuth } from './index'\r\nimport { signInWithEmailAndPassword, type UserCredential } from 'firebase/auth'\r\n\r\nexport interface SignInCredentials {\r\n email: string\r\n password: string\r\n}\r\n\r\nexport async function signInWithEmail({ \r\n email, \r\n password \r\n}: SignInCredentials): Promise<UserCredential> {\r\n const auth = TernSecureAuth()\r\n return signInWithEmailAndPassword(auth, email, password)\r\n} ", "'use client'\r\n\r\nimport { createContext, useContext} from 'react'\r\n\r\ninterface TernSecureContextType {\r\n _contextKey: Symbol\r\n}\r\n\r\nconst INTERNAL_CONTEXT_KEY = Symbol('INTERNAL_CONTEXT_KEY')\r\nconst TernSecureContext = createContext<TernSecureContextType | null>(null)\r\n\r\nconst useInternalContext = (hookname?: string) => {\r\n const context = useContext(TernSecureContext)\r\n if (!context || context._contextKey !== INTERNAL_CONTEXT_KEY) {\r\n throw new Error(\r\n `${hookname} must be used within TernSecureProvider`)\r\n }\r\n return context\r\n}\r\n\r\nexport {\r\n TernSecureContext,\r\n useInternalContext,\r\n INTERNAL_CONTEXT_KEY\r\n}", "'use client'\r\n\r\nimport React, { useState } from 'react'\r\nimport { INTERNAL_CONTEXT_KEY, TernSecureContext } from './ternSecureContext'\r\n\r\nexport function TernSecureClientProvider({ children }: { children: React.ReactNode }) {\r\n\r\n return (\r\n <TernSecureContext.Provider value={{ _contextKey: INTERNAL_CONTEXT_KEY }}>\r\n {children}\r\n </TernSecureContext.Provider>\r\n )\r\n}", "'use client'\r\n\r\nconst PREFIX = 'tern'\r\n\r\n// Singleton to track style injection\r\nconst styleInjection = {\r\n isInjected: false,\r\n styleElement: null as HTMLStyleElement | null\r\n}\r\n\r\nexport const defaultClassNames = {\r\n container: `${PREFIX}-container`,\r\n header: `${PREFIX}-header`,\r\n title: `${PREFIX}-title`,\r\n formWrapper: `${PREFIX}-formWrapper`,\r\n formContainer: `${PREFIX}-formContainer`,\r\n form: `${PREFIX}-form`,\r\n label: `${PREFIX}-label`,\r\n input: `${PREFIX}-input`,\r\n button: `${PREFIX}-button`,\r\n error: `${PREFIX}-error`\r\n} as const\r\n\r\n// Create styles once and cache them\r\nfunction createStyleSheet(styles: Record<string, React.CSSProperties>) {\r\n if (typeof window === 'undefined') return defaultClassNames\r\n\r\n // Return early if styles are already injected\r\n if (styleInjection.isInjected) {\r\n return defaultClassNames\r\n }\r\n\r\n // Find existing style element or create new one\r\n let styleElement = document.querySelector<HTMLStyleElement>('[data-tern-secure]')\r\n \r\n if (!styleElement) {\r\n styleElement = document.createElement('style')\r\n styleElement.setAttribute('data-tern-secure', '')\r\n document.head.appendChild(styleElement)\r\n styleInjection.styleElement = styleElement\r\n }\r\n\r\n // Create CSS rules\r\n const cssRules = Object.entries(styles).map(([key, rules]) => {\r\n const className = defaultClassNames[key as keyof typeof defaultClassNames]\r\n const cssProperties = Object.entries(rules).map(([prop, value]) => {\r\n const cssProperty = prop.replace(/([A-Z])/g, '-$1').toLowerCase()\r\n return `${cssProperty}: ${value};`\r\n }).join(' ')\r\n\r\n return `.${className} { ${cssProperties} }`\r\n }).join('\\n')\r\n\r\n // Insert styles only once\r\n styleElement.textContent = cssRules\r\n styleInjection.isInjected = true\r\n\r\n return defaultClassNames\r\n}\r\n\r\n// Style configuration\r\nexport const styleConfig = {\r\n container: {\r\n display: 'flex',\r\n minHeight: '100%',\r\n flex: '1',\r\n flexDirection: 'column',\r\n justifyContent: 'center',\r\n padding: '3rem 1.5rem'\r\n },\r\n header: {\r\n margin: '0 auto',\r\n width: '100%',\r\n maxWidth: '28rem'\r\n },\r\n title: {\r\n marginTop: '1.5rem',\r\n textAlign: 'center',\r\n fontSize: '1.875rem',\r\n fontWeight: '700',\r\n lineHeight: '2.25rem',\r\n letterSpacing: '-0.025em',\r\n color: 'var(--tern-text-primary, #111827)'\r\n },\r\n formWrapper: {\r\n marginTop: '2.5rem',\r\n margin: '0 auto',\r\n width: '100%',\r\n maxWidth: '30rem'\r\n },\r\n formContainer: {\r\n padding: '3rem 1.5rem',\r\n boxShadow: '0 1px 3px 0 rgb(0 0 0 / 0.1)',\r\n borderRadius: '0.5rem',\r\n backgroundColor: 'var(--tern-background, white)'\r\n },\r\n form: {\r\n display: 'flex',\r\n flexDirection: 'column',\r\n gap: '1rem'\r\n },\r\n label: {\r\n display: 'block',\r\n fontSize: '0.875rem',\r\n fontWeight: '500',\r\n color: 'var(--tern-text-secondary, #374151)'\r\n },\r\n input: {\r\n marginTop: '0.25rem',\r\n display: 'block',\r\n width: '100%',\r\n padding: '0.5rem 0.75rem',\r\n borderRadius: '0.375rem',\r\n border: '1px solid var(--tern-border, #D1D5DB)',\r\n backgroundColor: 'var(--tern-input-background, white)',\r\n color: 'var(--tern-text-primary, #111827)'\r\n },\r\n button: {\r\n display: 'flex',\r\n width: '100%',\r\n justifyContent: 'center',\r\n padding: '0.5rem 1rem',\r\n fontSize: '0.875rem',\r\n fontWeight: '500',\r\n color: 'white',\r\n backgroundColor: 'var(--tern-primary, #2563EB)',\r\n border: 'none',\r\n borderRadius: '0.375rem',\r\n cursor: 'pointer'\r\n },\r\n error: {\r\n color: 'var(--tern-error, #DC2626)',\r\n fontSize: '0.875rem'\r\n }\r\n} as const\r\n\r\n// Export pre-created styles\r\nexport const styles = createStyleSheet(styleConfig)\r\n\r\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../../../src/components/index.ts", "../../../src/components/sign-in.tsx", "../../../src/app-router/client/client-init.ts", "../../../src/app-router/client/config.ts", "../../../src/app-router/client/auth.ts", "../../../src/utils/create-styles.ts"],
|
|
4
|
+
"sourcesContent": ["export { SignIn } from './sign-in';", "import * as React from 'react'\r\nimport { useState } from 'react'\r\nimport { signInWithEmail } from '../app-router/client'\r\nimport { styles } from '../utils/create-styles'\r\n\r\nexport interface SignInProps {\r\n onSuccess?: () => void\r\n onError?: (error: Error) => void\r\n redirectUrl?: string\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 onSuccess, \r\n onError, \r\n redirectUrl,\r\n className = '',\r\n style,\r\n customStyles = {}\r\n}: SignInProps) {\r\n const [email, setEmail] = useState('')\r\n const [password, setPassword] = useState('')\r\n const [loading, setLoading] = useState(false)\r\n const [error, setError] = useState('')\r\n\r\n const handleSubmit = async (e: React.FormEvent) => {\r\n e.preventDefault()\r\n setLoading(true)\r\n setError('')\r\n\r\n try {\r\n await signInWithEmail({ email, password })\r\n onSuccess?.()\r\n \r\n if (redirectUrl) {\r\n window.location.href = redirectUrl\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 type=\"email\"\r\n value={email}\r\n onChange={(e) => setEmail(e.target.value)}\r\n placeholder=\"Enter your email\"\r\n required\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 type=\"password\"\r\n value={password}\r\n onChange={(e) => setPassword(e.target.value)}\r\n placeholder=\"Enter your password\"\r\n required\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", "import { getApps, initializeApp } from 'firebase/app';\r\nimport { getAuth, setPersistence, browserSessionPersistence } from 'firebase/auth';\r\nimport { getFirestore } from 'firebase/firestore';\r\nimport { getStorage } from 'firebase/storage';\r\nimport { loadFireConfig, validateConfig } from './config';\r\n\r\n// Initialize immediately\r\nconst app = (() => {\r\n const config = validateConfig(loadFireConfig());\r\n return getApps().length ? getApps()[0] : initializeApp(config);\r\n})();\r\n\r\nconst auth = getAuth(app);\r\nsetPersistence(auth, browserSessionPersistence); //to change later user should be able to choose persistance\r\nconst firestore = getFirestore(app);\r\nconst storage = getStorage(app);\r\n\r\nexport const TernSecureAuth = () => auth;\r\nexport const TernSecureFirestore = () => firestore;\r\nexport const TernSecureStorage = () => storage;", "import { TernSecureConfig } from \"../../types\";\r\n\r\nexport const loadFireConfig = (): TernSecureConfig => ({\r\n apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY as string,\r\n authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN as string,\r\n projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID as string,\r\n storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET as string,\r\n messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID as string,\r\n appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID as string,\r\n measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID as string,\r\n});\r\n\r\nexport const validateConfig = (config: TernSecureConfig): TernSecureConfig => {\r\n Object.entries(config).forEach(([key, value]) => {\r\n if (!value) {\r\n throw new Error(`Missing environment variable: NEXT_PUBLIC_FIREBASE_${key.toUpperCase()}`);\r\n }\r\n });\r\n return config;\r\n};", "import { TernSecureAuth } from './index'\r\nimport { signInWithEmailAndPassword, type UserCredential } from 'firebase/auth'\r\n\r\nexport interface SignInCredentials {\r\n email: string\r\n password: string\r\n}\r\n\r\nexport async function signInWithEmail({ \r\n email, \r\n password \r\n}: SignInCredentials): Promise<UserCredential> {\r\n const auth = TernSecureAuth()\r\n return signInWithEmailAndPassword(auth, email, password)\r\n} ", "'use client'\r\n\r\nconst PREFIX = 'tern'\r\n\r\n// Singleton to track style injection\r\nconst styleInjection = {\r\n isInjected: false,\r\n styleElement: null as HTMLStyleElement | null\r\n}\r\n\r\nexport const defaultClassNames = {\r\n container: `${PREFIX}-container`,\r\n header: `${PREFIX}-header`,\r\n title: `${PREFIX}-title`,\r\n formWrapper: `${PREFIX}-formWrapper`,\r\n formContainer: `${PREFIX}-formContainer`,\r\n form: `${PREFIX}-form`,\r\n label: `${PREFIX}-label`,\r\n input: `${PREFIX}-input`,\r\n button: `${PREFIX}-button`,\r\n error: `${PREFIX}-error`\r\n} as const\r\n\r\n// Create styles once and cache them\r\nfunction createStyleSheet(styles: Record<string, React.CSSProperties>) {\r\n if (typeof window === 'undefined') return defaultClassNames\r\n\r\n // Return early if styles are already injected\r\n if (styleInjection.isInjected) {\r\n return defaultClassNames\r\n }\r\n\r\n // Find existing style element or create new one\r\n let styleElement = document.querySelector<HTMLStyleElement>('[data-tern-secure]')\r\n \r\n if (!styleElement) {\r\n styleElement = document.createElement('style')\r\n styleElement.setAttribute('data-tern-secure', '')\r\n document.head.appendChild(styleElement)\r\n styleInjection.styleElement = styleElement\r\n }\r\n\r\n // Create CSS rules\r\n const cssRules = Object.entries(styles).map(([key, rules]) => {\r\n const className = defaultClassNames[key as keyof typeof defaultClassNames]\r\n const cssProperties = Object.entries(rules).map(([prop, value]) => {\r\n const cssProperty = prop.replace(/([A-Z])/g, '-$1').toLowerCase()\r\n return `${cssProperty}: ${value};`\r\n }).join(' ')\r\n\r\n return `.${className} { ${cssProperties} }`\r\n }).join('\\n')\r\n\r\n // Insert styles only once\r\n styleElement.textContent = cssRules\r\n styleInjection.isInjected = true\r\n\r\n return defaultClassNames\r\n}\r\n\r\n// Style configuration\r\nexport const styleConfig = {\r\n container: {\r\n display: 'flex',\r\n minHeight: '100%',\r\n flex: '1',\r\n flexDirection: 'column',\r\n justifyContent: 'center',\r\n padding: '3rem 1.5rem'\r\n },\r\n header: {\r\n margin: '0 auto',\r\n width: '100%',\r\n maxWidth: '28rem'\r\n },\r\n title: {\r\n marginTop: '1.5rem',\r\n textAlign: 'center',\r\n fontSize: '1.875rem',\r\n fontWeight: '700',\r\n lineHeight: '2.25rem',\r\n letterSpacing: '-0.025em',\r\n color: 'var(--tern-text-primary, #111827)'\r\n },\r\n formWrapper: {\r\n marginTop: '2.5rem',\r\n margin: '0 auto',\r\n width: '100%',\r\n maxWidth: '30rem'\r\n },\r\n formContainer: {\r\n padding: '3rem 1.5rem',\r\n boxShadow: '0 1px 3px 0 rgb(0 0 0 / 0.1)',\r\n borderRadius: '0.5rem',\r\n backgroundColor: 'var(--tern-background, white)'\r\n },\r\n form: {\r\n display: 'flex',\r\n flexDirection: 'column',\r\n gap: '1rem'\r\n },\r\n label: {\r\n display: 'block',\r\n fontSize: '0.875rem',\r\n fontWeight: '500',\r\n color: 'var(--tern-text-secondary, #374151)'\r\n },\r\n input: {\r\n marginTop: '0.25rem',\r\n display: 'block',\r\n width: '100%',\r\n padding: '0.5rem 0.75rem',\r\n borderRadius: '0.375rem',\r\n border: '1px solid var(--tern-border, #D1D5DB)',\r\n backgroundColor: 'var(--tern-input-background, white)',\r\n color: 'var(--tern-text-primary, #111827)'\r\n },\r\n button: {\r\n display: 'flex',\r\n width: '100%',\r\n justifyContent: 'center',\r\n padding: '0.5rem 1rem',\r\n fontSize: '0.875rem',\r\n fontWeight: '500',\r\n color: 'white',\r\n backgroundColor: 'var(--tern-primary, #2563EB)',\r\n border: 'none',\r\n borderRadius: '0.375rem',\r\n cursor: 'pointer'\r\n },\r\n error: {\r\n color: 'var(--tern-error, #DC2626)',\r\n fontSize: '0.875rem'\r\n }\r\n} as const\r\n\r\n// Export pre-created styles\r\nexport const styles = createStyleSheet(styleConfig)\r\n\r\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,mBAAyB;;;ACDzB,iBAAuC;AACvC,kBAAmE;AACnE,uBAA6B;AAC7B,qBAA2B;;;ACDpB,IAAM,iBAAiB,OAAyB;AAAA,EACrD,QAAQ,QAAQ,IAAI;AAAA,EACpB,YAAY,QAAQ,IAAI;AAAA,EACxB,WAAW,QAAQ,IAAI;AAAA,EACvB,eAAe,QAAQ,IAAI;AAAA,EAC3B,mBAAmB,QAAQ,IAAI;AAAA,EAC/B,OAAO,QAAQ,IAAI;AAAA,EACnB,eAAe,QAAQ,IAAI;AAC7B;AAEO,IAAM,iBAAiB,CAAC,WAA+C;AAC5E,SAAO,QAAQ,MAAM,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAC/C,QAAI,CAAC,OAAO;AACV,YAAM,IAAI,MAAM,sDAAsD,IAAI,YAAY,CAAC,EAAE;AAAA,IAC3F;AAAA,EACF,CAAC;AACD,SAAO;AACT;;;ADZA,IAAM,OAAO,MAAM;AACjB,QAAM,SAAS,eAAe,eAAe,CAAC;AAC9C,aAAO,oBAAQ,EAAE,aAAS,oBAAQ,EAAE,CAAC,QAAI,0BAAc,MAAM;AAC/D,GAAG;AAEH,IAAM,WA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AG,OAAO,KAAK,IAAI,aAAa,SAAS,EAAE;AAAA,gBACtD,UAAU;AAAA,gBACV,iBAAc;AAAA,gBACd,gBAAc,CAAC,CAAC;AAAA;AAAA,YAClB;AAAA,aACF;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,UAAU;AAAA,cACV,WAAW,GAAG,OAAO,MAAM,IAAI,aAAa,UAAU,EAAE;AAAA,cACxD,eAAY;AAAA,cAEX,oBAAU,kBAAkB;AAAA;AAAA,UAC/B;AAAA;AAAA;AAAA,IACF,GACF,GACF;AAAA,KACF;AAEJ;",
|
|
6
|
+
"names": ["import_auth", "auth", "styles"]
|
|
7
7
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -37,13 +37,13 @@ var init_ternSecureContext = __esm({
|
|
|
37
37
|
"use strict";
|
|
38
38
|
"use client";
|
|
39
39
|
import_react = require("react");
|
|
40
|
-
INTERNAL_CONTEXT_KEY = Symbol("
|
|
40
|
+
INTERNAL_CONTEXT_KEY = Symbol("TERN_SECURE_CONTEXT");
|
|
41
41
|
TernSecureContext = (0, import_react.createContext)(null);
|
|
42
|
-
useInternalContext = (
|
|
42
|
+
useInternalContext = (hookName) => {
|
|
43
43
|
const context = (0, import_react.useContext)(TernSecureContext);
|
|
44
44
|
if (!context || context._contextKey !== INTERNAL_CONTEXT_KEY) {
|
|
45
45
|
throw new Error(
|
|
46
|
-
`${
|
|
46
|
+
`${hookName || "Hook"} must be used within TernSecureProvider. Please wrap your component with TernSecureProvider.`
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
49
|
return context;
|
|
@@ -57,15 +57,21 @@ __export(ternSecureClientProvider_exports, {
|
|
|
57
57
|
TernSecureClientProvider: () => TernSecureClientProvider
|
|
58
58
|
});
|
|
59
59
|
function TernSecureClientProvider({ children }) {
|
|
60
|
-
|
|
60
|
+
const contextValue = import_react2.default.useMemo(
|
|
61
|
+
() => ({ _contextKey: INTERNAL_CONTEXT_KEY }),
|
|
62
|
+
[]
|
|
63
|
+
);
|
|
64
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TernSecureContext.Provider, { value: contextValue, children });
|
|
61
65
|
}
|
|
62
|
-
var import_jsx_runtime;
|
|
66
|
+
var import_react2, import_jsx_runtime;
|
|
63
67
|
var init_ternSecureClientProvider = __esm({
|
|
64
68
|
"src/app-router/client/providers/ternSecureClientProvider.tsx"() {
|
|
65
69
|
"use strict";
|
|
66
70
|
"use client";
|
|
71
|
+
import_react2 = __toESM(require("react"), 1);
|
|
67
72
|
init_ternSecureContext();
|
|
68
73
|
import_jsx_runtime = require("react/jsx-runtime");
|
|
74
|
+
TernSecureClientProvider.displayName = "TernSecureClientProvider";
|
|
69
75
|
}
|
|
70
76
|
});
|
|
71
77
|
|
|
@@ -140,30 +146,46 @@ init_ternSecureContext();
|
|
|
140
146
|
init_ternSecureClientProvider();
|
|
141
147
|
|
|
142
148
|
// src/app-router/server/providers/TernSecureServerProvider.tsx
|
|
143
|
-
var
|
|
149
|
+
var import_react3 = __toESM(require("react"), 1);
|
|
144
150
|
var import_dynamic = __toESM(require("next/dynamic"), 1);
|
|
145
151
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
152
|
+
var LoadingProvider = () => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
153
|
+
"div",
|
|
154
|
+
{
|
|
155
|
+
"aria-label": "Loading authentication provider...",
|
|
156
|
+
role: "status",
|
|
157
|
+
style: { display: "none" }
|
|
158
|
+
}
|
|
159
|
+
);
|
|
146
160
|
var TernSecureClientProvider2 = (0, import_dynamic.default)(
|
|
147
161
|
() => Promise.resolve().then(() => (init_ternSecureClientProvider(), ternSecureClientProvider_exports)).then((mod) => mod.TernSecureClientProvider),
|
|
148
162
|
{
|
|
149
|
-
ssr: false
|
|
150
|
-
|
|
163
|
+
ssr: false,
|
|
164
|
+
loading: LoadingProvider
|
|
165
|
+
// Return null or a loading indicator
|
|
151
166
|
}
|
|
152
167
|
);
|
|
153
168
|
function TernSecureProvider({ children }) {
|
|
154
|
-
const
|
|
155
|
-
|
|
169
|
+
const startTime = process.env.NODE_ENV === "development" ? performance.now() : 0;
|
|
170
|
+
const isRootLayout = import_react3.default.Children.toArray(children).some(
|
|
171
|
+
(child) => import_react3.default.isValidElement(child) && child.type === "html"
|
|
156
172
|
);
|
|
173
|
+
import_react3.default.useEffect(() => {
|
|
174
|
+
if (process.env.NODE_ENV === "development") {
|
|
175
|
+
const endTime = performance.now();
|
|
176
|
+
console.debug(`TernSecure provider mounted in ${endTime - startTime}ms`);
|
|
177
|
+
}
|
|
178
|
+
}, [startTime]);
|
|
157
179
|
if (isRootLayout) {
|
|
158
|
-
return
|
|
159
|
-
if (
|
|
160
|
-
return
|
|
180
|
+
return import_react3.default.Children.map(children, (child) => {
|
|
181
|
+
if (import_react3.default.isValidElement(child) && child.type === "html") {
|
|
182
|
+
return import_react3.default.cloneElement(
|
|
161
183
|
child,
|
|
162
184
|
{},
|
|
163
|
-
|
|
164
|
-
if (
|
|
185
|
+
import_react3.default.Children.map(child.props.children, (bodyChild) => {
|
|
186
|
+
if (import_react3.default.isValidElement(bodyChild) && bodyChild.type === "body") {
|
|
165
187
|
const bodyProps = bodyChild.props;
|
|
166
|
-
return
|
|
188
|
+
return import_react3.default.cloneElement(
|
|
167
189
|
bodyChild,
|
|
168
190
|
{},
|
|
169
191
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TernSecureClientProvider2, { children: bodyProps.children })
|
|
@@ -180,17 +202,17 @@ function TernSecureProvider({ children }) {
|
|
|
180
202
|
}
|
|
181
203
|
|
|
182
204
|
// src/hooks/useAuth.ts
|
|
183
|
-
var
|
|
205
|
+
var import_react4 = require("react");
|
|
184
206
|
var import_auth4 = require("firebase/auth");
|
|
185
207
|
function useAuth() {
|
|
186
|
-
const auth2 = (0,
|
|
187
|
-
const [authState, setAuthState] = (0,
|
|
208
|
+
const auth2 = (0, import_react4.useMemo)(() => TernSecureAuth(), []);
|
|
209
|
+
const [authState, setAuthState] = (0, import_react4.useState)({
|
|
188
210
|
loading: true,
|
|
189
211
|
isSignedIn: false,
|
|
190
212
|
userId: null,
|
|
191
213
|
error: null
|
|
192
214
|
});
|
|
193
|
-
(0,
|
|
215
|
+
(0, import_react4.useEffect)(() => {
|
|
194
216
|
const unsubscribe = (0, import_auth4.onAuthStateChanged)(auth2, (user) => {
|
|
195
217
|
if (user) {
|
|
196
218
|
setAuthState({
|
|
@@ -211,11 +233,16 @@ function useAuth() {
|
|
|
211
233
|
return () => unsubscribe();
|
|
212
234
|
}, [auth2]);
|
|
213
235
|
useInternalContext("useAuth");
|
|
214
|
-
return {
|
|
236
|
+
return {
|
|
237
|
+
loading: authState.loading,
|
|
238
|
+
isSignedIn: authState.isSignedIn,
|
|
239
|
+
userId: authState.userId,
|
|
240
|
+
error: authState.error
|
|
241
|
+
};
|
|
215
242
|
}
|
|
216
243
|
|
|
217
244
|
// src/components/sign-in.tsx
|
|
218
|
-
var
|
|
245
|
+
var import_react5 = require("react");
|
|
219
246
|
|
|
220
247
|
// src/utils/create-styles.ts
|
|
221
248
|
var PREFIX = "tern";
|
|
@@ -345,10 +372,10 @@ function SignIn({
|
|
|
345
372
|
style,
|
|
346
373
|
customStyles = {}
|
|
347
374
|
}) {
|
|
348
|
-
const [email, setEmail] = (0,
|
|
349
|
-
const [password, setPassword] = (0,
|
|
350
|
-
const [loading, setLoading] = (0,
|
|
351
|
-
const [error, setError] = (0,
|
|
375
|
+
const [email, setEmail] = (0, import_react5.useState)("");
|
|
376
|
+
const [password, setPassword] = (0, import_react5.useState)("");
|
|
377
|
+
const [loading, setLoading] = (0, import_react5.useState)(false);
|
|
378
|
+
const [error, setError] = (0, import_react5.useState)("");
|
|
352
379
|
const handleSubmit = async (e) => {
|
|
353
380
|
e.preventDefault();
|
|
354
381
|
setLoading(true);
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/app-router/client/providers/ternSecureContext.tsx", "../../src/app-router/client/providers/ternSecureClientProvider.tsx", "../../src/index.ts", "../../src/app-router/client/client-init.ts", "../../src/app-router/client/config.ts", "../../src/app-router/client/auth.ts", "../../src/app-router/client/index.ts", "../../src/app-router/server/providers/TernSecureServerProvider.tsx", "../../src/hooks/useAuth.ts", "../../src/components/sign-in.tsx", "../../src/utils/create-styles.ts"],
|
|
4
|
-
"sourcesContent": ["'use client'\r\n\r\nimport { createContext, useContext} from 'react'\r\n\r\ninterface TernSecureContextType {\r\n _contextKey: Symbol\r\n}\r\n\r\nconst INTERNAL_CONTEXT_KEY = Symbol('INTERNAL_CONTEXT_KEY')\r\nconst TernSecureContext = createContext<TernSecureContextType | null>(null)\r\n\r\nconst useInternalContext = (hookname?: string) => {\r\n const context = useContext(TernSecureContext)\r\n if (!context || context._contextKey !== INTERNAL_CONTEXT_KEY) {\r\n throw new Error(\r\n `${hookname} must be used within TernSecureProvider`)\r\n }\r\n return context\r\n}\r\n\r\nexport {\r\n TernSecureContext,\r\n useInternalContext,\r\n INTERNAL_CONTEXT_KEY\r\n}", "'use client'\r\n\r\nimport React, { useState } from 'react'\r\nimport { INTERNAL_CONTEXT_KEY, TernSecureContext } from './ternSecureContext'\r\n\r\nexport function TernSecureClientProvider({ children }: { children: React.ReactNode }) {\r\n\r\n return (\r\n <TernSecureContext.Provider value={{ _contextKey: INTERNAL_CONTEXT_KEY }}>\r\n {children}\r\n </TernSecureContext.Provider>\r\n )\r\n}", "export { TernSecureAuth, TernSecureFirestore, TernSecureStorage, signInWithEmail, loadFireConfig, validateConfig, TernSecureContext, useInternalContext, TernSecureClientProvider } from './app-router/client'\r\nexport { TernSecureProvider } from './app-router/server'\r\nexport { useAuth } from './hooks/useAuth' \r\nexport { SignIn } from './components/sign-in'", "import { getApps, initializeApp } from 'firebase/app';\r\nimport { getAuth, setPersistence, browserSessionPersistence } from 'firebase/auth';\r\nimport { getFirestore } from 'firebase/firestore';\r\nimport { getStorage } from 'firebase/storage';\r\nimport { loadFireConfig, validateConfig } from './config';\r\n\r\n// Initialize immediately\r\nconst app = (() => {\r\n const config = validateConfig(loadFireConfig());\r\n return getApps().length ? getApps()[0] : initializeApp(config);\r\n})();\r\n\r\nconst auth = getAuth(app);\r\nsetPersistence(auth, browserSessionPersistence); //to change later user should be able to choose persistance\r\nconst firestore = getFirestore(app);\r\nconst storage = getStorage(app);\r\n\r\nexport const TernSecureAuth = () => auth;\r\nexport const TernSecureFirestore = () => firestore;\r\nexport const TernSecureStorage = () => storage;", "import { TernSecureConfig } from \"../../types\";\r\n\r\nexport const loadFireConfig = (): TernSecureConfig => ({\r\n apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY as string,\r\n authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN as string,\r\n projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID as string,\r\n storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET as string,\r\n messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID as string,\r\n appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID as string,\r\n measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID as string,\r\n});\r\n\r\nexport const validateConfig = (config: TernSecureConfig): TernSecureConfig => {\r\n Object.entries(config).forEach(([key, value]) => {\r\n if (!value) {\r\n throw new Error(`Missing environment variable: NEXT_PUBLIC_FIREBASE_${key.toUpperCase()}`);\r\n }\r\n });\r\n return config;\r\n};", "import { TernSecureAuth } from './index'\r\nimport { signInWithEmailAndPassword, type UserCredential } from 'firebase/auth'\r\n\r\nexport interface SignInCredentials {\r\n email: string\r\n password: string\r\n}\r\n\r\nexport async function signInWithEmail({ \r\n email, \r\n password \r\n}: SignInCredentials): Promise<UserCredential> {\r\n const auth = TernSecureAuth()\r\n return signInWithEmailAndPassword(auth, email, password)\r\n} ", "'use client'\r\nexport { \r\n TernSecureAuth,\r\n TernSecureFirestore,\r\n TernSecureStorage \r\n } from './client-init';\r\n\r\n export type { SignInCredentials } from './auth'\r\n\r\n export { signInWithEmail} from './auth'\r\n export { loadFireConfig, validateConfig } from './config';\r\n export { TernSecureContext, useInternalContext } from './providers/ternSecureContext';\r\n export { TernSecureClientProvider } from './providers/ternSecureClientProvider'", "import React, { ReactNode } from 'react';\r\nimport dynamic from 'next/dynamic'\r\n\r\ninterface TernSecureProviderProps {\r\n children: ReactNode;\r\n}\r\n\r\n// Dynamically import the client provider with no SSR\r\nconst TernSecureClientProvider = dynamic(\r\n () => import('../../client/providers/ternSecureClientProvider').then(mod => mod.TernSecureClientProvider),\r\n { \r\n ssr: false\r\n //loading: () => null // Return null or a loading indicator\r\n }\r\n)\r\n\r\nexport function TernSecureProvider({ children }: TernSecureProviderProps) {\r\n // Check if the children contain html/body tags\r\n const isRootLayout = React.Children.toArray(children).some(\r\n child => React.isValidElement(child) && child.type === 'html'\r\n );\r\n\r\n if (isRootLayout) {\r\n // If this is the root layout, inject our provider after the body tag\r\n return React.Children.map(children, child => {\r\n if (React.isValidElement(child) && child.type === 'html') {\r\n return React.cloneElement(child, {}, \r\n React.Children.map(child.props.children, bodyChild => {\r\n if (React.isValidElement(bodyChild) && bodyChild.type === 'body') {\r\n // Type assertion to access props safely\r\n const bodyProps = bodyChild.props as { children: ReactNode };\r\n return React.cloneElement(bodyChild, {}, \r\n <TernSecureClientProvider>\r\n {bodyProps.children}\r\n </TernSecureClientProvider>\r\n );\r\n }\r\n return bodyChild;\r\n })\r\n );\r\n }\r\n return child;\r\n });\r\n }\r\n\r\n // For non-root layouts, wrap normally\r\n return <TernSecureClientProvider>{children}</TernSecureClientProvider>;\r\n}", "'use client'\r\n\r\nimport { useEffect, useState, useMemo } from 'react'\r\nimport { onAuthStateChanged } from 'firebase/auth'\r\nimport { TernSecureAuth } from '../app-router/client'\r\nimport { useInternalContext } from '../app-router/client'\r\n\r\nexport interface AuthState {\r\n userId: string | null\r\n loading: boolean;\r\n error: Error | null;\r\n isSignedIn: boolean;\r\n}\r\n\r\nexport function useAuth() {\r\n const auth = useMemo(() => TernSecureAuth(), [])\r\n const [authState, setAuthState] = useState<AuthState>({\r\n loading: true,\r\n isSignedIn: false,\r\n userId: null,\r\n error: null\r\n })\r\n\r\n\r\n useEffect(() => {\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 }, [auth])\r\n\r\n useInternalContext('useAuth')\r\n return { authState }\r\n}", "import * as React from 'react'\r\nimport { useState } from 'react'\r\nimport { signInWithEmail } from '../app-router/client'\r\nimport { styles } from '../utils/create-styles'\r\n\r\nexport interface SignInProps {\r\n onSuccess?: () => void\r\n onError?: (error: Error) => void\r\n redirectUrl?: string\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 onSuccess, \r\n onError, \r\n redirectUrl,\r\n className = '',\r\n style,\r\n customStyles = {}\r\n}: SignInProps) {\r\n const [email, setEmail] = useState('')\r\n const [password, setPassword] = useState('')\r\n const [loading, setLoading] = useState(false)\r\n const [error, setError] = useState('')\r\n\r\n const handleSubmit = async (e: React.FormEvent) => {\r\n e.preventDefault()\r\n setLoading(true)\r\n setError('')\r\n\r\n try {\r\n await signInWithEmail({ email, password })\r\n onSuccess?.()\r\n \r\n if (redirectUrl) {\r\n window.location.href = redirectUrl\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 type=\"email\"\r\n value={email}\r\n onChange={(e) => setEmail(e.target.value)}\r\n placeholder=\"Enter your email\"\r\n required\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 type=\"password\"\r\n value={password}\r\n onChange={(e) => setPassword(e.target.value)}\r\n placeholder=\"Enter your password\"\r\n required\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", "'use client'\r\n\r\nconst PREFIX = 'tern'\r\n\r\n// Singleton to track style injection\r\nconst styleInjection = {\r\n isInjected: false,\r\n styleElement: null as HTMLStyleElement | null\r\n}\r\n\r\nexport const defaultClassNames = {\r\n container: `${PREFIX}-container`,\r\n header: `${PREFIX}-header`,\r\n title: `${PREFIX}-title`,\r\n formWrapper: `${PREFIX}-formWrapper`,\r\n formContainer: `${PREFIX}-formContainer`,\r\n form: `${PREFIX}-form`,\r\n label: `${PREFIX}-label`,\r\n input: `${PREFIX}-input`,\r\n button: `${PREFIX}-button`,\r\n error: `${PREFIX}-error`\r\n} as const\r\n\r\n// Create styles once and cache them\r\nfunction createStyleSheet(styles: Record<string, React.CSSProperties>) {\r\n if (typeof window === 'undefined') return defaultClassNames\r\n\r\n // Return early if styles are already injected\r\n if (styleInjection.isInjected) {\r\n return defaultClassNames\r\n }\r\n\r\n // Find existing style element or create new one\r\n let styleElement = document.querySelector<HTMLStyleElement>('[data-tern-secure]')\r\n \r\n if (!styleElement) {\r\n styleElement = document.createElement('style')\r\n styleElement.setAttribute('data-tern-secure', '')\r\n document.head.appendChild(styleElement)\r\n styleInjection.styleElement = styleElement\r\n }\r\n\r\n // Create CSS rules\r\n const cssRules = Object.entries(styles).map(([key, rules]) => {\r\n const className = defaultClassNames[key as keyof typeof defaultClassNames]\r\n const cssProperties = Object.entries(rules).map(([prop, value]) => {\r\n const cssProperty = prop.replace(/([A-Z])/g, '-$1').toLowerCase()\r\n return `${cssProperty}: ${value};`\r\n }).join(' ')\r\n\r\n return `.${className} { ${cssProperties} }`\r\n }).join('\\n')\r\n\r\n // Insert styles only once\r\n styleElement.textContent = cssRules\r\n styleInjection.isInjected = true\r\n\r\n return defaultClassNames\r\n}\r\n\r\n// Style configuration\r\nexport const styleConfig = {\r\n container: {\r\n display: 'flex',\r\n minHeight: '100%',\r\n flex: '1',\r\n flexDirection: 'column',\r\n justifyContent: 'center',\r\n padding: '3rem 1.5rem'\r\n },\r\n header: {\r\n margin: '0 auto',\r\n width: '100%',\r\n maxWidth: '28rem'\r\n },\r\n title: {\r\n marginTop: '1.5rem',\r\n textAlign: 'center',\r\n fontSize: '1.875rem',\r\n fontWeight: '700',\r\n lineHeight: '2.25rem',\r\n letterSpacing: '-0.025em',\r\n color: 'var(--tern-text-primary, #111827)'\r\n },\r\n formWrapper: {\r\n marginTop: '2.5rem',\r\n margin: '0 auto',\r\n width: '100%',\r\n maxWidth: '30rem'\r\n },\r\n formContainer: {\r\n padding: '3rem 1.5rem',\r\n boxShadow: '0 1px 3px 0 rgb(0 0 0 / 0.1)',\r\n borderRadius: '0.5rem',\r\n backgroundColor: 'var(--tern-background, white)'\r\n },\r\n form: {\r\n display: 'flex',\r\n flexDirection: 'column',\r\n gap: '1rem'\r\n },\r\n label: {\r\n display: 'block',\r\n fontSize: '0.875rem',\r\n fontWeight: '500',\r\n color: 'var(--tern-text-secondary, #374151)'\r\n },\r\n input: {\r\n marginTop: '0.25rem',\r\n display: 'block',\r\n width: '100%',\r\n padding: '0.5rem 0.75rem',\r\n borderRadius: '0.375rem',\r\n border: '1px solid var(--tern-border, #D1D5DB)',\r\n backgroundColor: 'var(--tern-input-background, white)',\r\n color: 'var(--tern-text-primary, #111827)'\r\n },\r\n button: {\r\n display: 'flex',\r\n width: '100%',\r\n justifyContent: 'center',\r\n padding: '0.5rem 1rem',\r\n fontSize: '0.875rem',\r\n fontWeight: '500',\r\n color: 'white',\r\n backgroundColor: 'var(--tern-primary, #2563EB)',\r\n border: 'none',\r\n borderRadius: '0.375rem',\r\n cursor: 'pointer'\r\n },\r\n error: {\r\n color: 'var(--tern-error, #DC2626)',\r\n fontSize: '0.875rem'\r\n }\r\n} as const\r\n\r\n// Export pre-created styles\r\nexport const styles = createStyleSheet(styleConfig)\r\n\r\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAEA,
|
|
6
|
-
"names": ["import_auth", "auth", "import_react", "import_jsx_runtime", "TernSecureClientProvider", "dynamic", "React", "import_react", "import_auth", "auth", "import_react", "styles", "import_jsx_runtime"]
|
|
4
|
+
"sourcesContent": ["'use client'\r\n\r\nimport { createContext, useContext } from 'react'\r\n\r\n/**\r\n * Internal context type for TernSecure authentication\r\n * @internal\r\n */\r\ninterface TernSecureContextType {\r\n readonly _contextKey: symbol\r\n}\r\n\r\n/**\r\n * Internal symbol used for context validation\r\n * @internal\r\n */\r\nconst INTERNAL_CONTEXT_KEY = Symbol('TERN_SECURE_CONTEXT')\r\n\r\n/**\r\n * Context for TernSecure authentication\r\n * @internal\r\n */\r\nconst TernSecureContext = createContext<TernSecureContextType | null>(null)\r\n\r\n/**\r\n * Hook to verify that components are rendered within the TernSecure provider\r\n * @param hookName - Name of the hook being used (for better error messages)\r\n * @throws {Error} When used outside of TernSecureProvider\r\n * @internal\r\n */\r\nconst useInternalContext = (hookName?: string): TernSecureContextType => {\r\n const context = useContext(TernSecureContext)\r\n \r\n if (!context || context._contextKey !== INTERNAL_CONTEXT_KEY) {\r\n throw new Error(\r\n `${hookName || 'Hook'} must be used within TernSecureProvider. ` +\r\n 'Please wrap your component with TernSecureProvider.'\r\n )\r\n }\r\n \r\n return context\r\n}\r\n\r\nexport {\r\n type TernSecureContextType,\r\n TernSecureContext,\r\n useInternalContext,\r\n INTERNAL_CONTEXT_KEY\r\n}", "'use client'\r\n\r\nimport React from 'react'\r\nimport { INTERNAL_CONTEXT_KEY, TernSecureContext, TernSecureContextType } from './ternSecureContext'\r\n\r\n/**\r\n * Props for the TernSecureClientProvider component\r\n */\r\ninterface TernSecureClientProviderProps {\r\n /** React child elements to be wrapped by the provider */\r\n children: React.ReactNode\r\n}\r\n\r\n/**\r\n * Provider component for TernSecure authentication\r\n * Must be used to wrap any components that use TernSecure hooks\r\n * \r\n * @example\r\n * ```tsx\r\n * function App() {\r\n * return (\r\n * <TernSecureClientProvider>\r\n * <YourApp />\r\n * </TernSecureClientProvider>\r\n * )\r\n * }\r\n * ```\r\n */\r\nexport function TernSecureClientProvider({ children }: TernSecureClientProviderProps): JSX.Element {\r\n // Memoize the context value to prevent unnecessary re-renders\r\n const contextValue = React.useMemo<TernSecureContextType>(\r\n () => ({ _contextKey: INTERNAL_CONTEXT_KEY }),\r\n []\r\n )\r\n\r\n return (\r\n <TernSecureContext.Provider value={contextValue}>\r\n {children}\r\n </TernSecureContext.Provider>\r\n )\r\n}\r\n\r\n// Add display name for better debugging\r\nTernSecureClientProvider.displayName = 'TernSecureClientProvider'", "export { TernSecureAuth, TernSecureFirestore, TernSecureStorage, signInWithEmail, loadFireConfig, validateConfig, TernSecureContext, useInternalContext, TernSecureClientProvider } from './app-router/client'\r\nexport { TernSecureProvider } from './app-router/server'\r\nexport { useAuth } from './hooks/useAuth' \r\nexport { SignIn } from './components/sign-in'", "import { getApps, initializeApp } from 'firebase/app';\r\nimport { getAuth, setPersistence, browserSessionPersistence } from 'firebase/auth';\r\nimport { getFirestore } from 'firebase/firestore';\r\nimport { getStorage } from 'firebase/storage';\r\nimport { loadFireConfig, validateConfig } from './config';\r\n\r\n// Initialize immediately\r\nconst app = (() => {\r\n const config = validateConfig(loadFireConfig());\r\n return getApps().length ? getApps()[0] : initializeApp(config);\r\n})();\r\n\r\nconst auth = getAuth(app);\r\nsetPersistence(auth, browserSessionPersistence); //to change later user should be able to choose persistance\r\nconst firestore = getFirestore(app);\r\nconst storage = getStorage(app);\r\n\r\nexport const TernSecureAuth = () => auth;\r\nexport const TernSecureFirestore = () => firestore;\r\nexport const TernSecureStorage = () => storage;", "import { TernSecureConfig } from \"../../types\";\r\n\r\nexport const loadFireConfig = (): TernSecureConfig => ({\r\n apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY as string,\r\n authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN as string,\r\n projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID as string,\r\n storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET as string,\r\n messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID as string,\r\n appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID as string,\r\n measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID as string,\r\n});\r\n\r\nexport const validateConfig = (config: TernSecureConfig): TernSecureConfig => {\r\n Object.entries(config).forEach(([key, value]) => {\r\n if (!value) {\r\n throw new Error(`Missing environment variable: NEXT_PUBLIC_FIREBASE_${key.toUpperCase()}`);\r\n }\r\n });\r\n return config;\r\n};", "import { TernSecureAuth } from './index'\r\nimport { signInWithEmailAndPassword, type UserCredential } from 'firebase/auth'\r\n\r\nexport interface SignInCredentials {\r\n email: string\r\n password: string\r\n}\r\n\r\nexport async function signInWithEmail({ \r\n email, \r\n password \r\n}: SignInCredentials): Promise<UserCredential> {\r\n const auth = TernSecureAuth()\r\n return signInWithEmailAndPassword(auth, email, password)\r\n} ", "'use client'\r\nexport { \r\n TernSecureAuth,\r\n TernSecureFirestore,\r\n TernSecureStorage \r\n } from './client-init';\r\n\r\n export type { SignInCredentials } from './auth'\r\n\r\n export { signInWithEmail} from './auth'\r\n export { loadFireConfig, validateConfig } from './config';\r\n export { TernSecureContext, useInternalContext } from './providers/ternSecureContext';\r\n export { TernSecureClientProvider } from './providers/ternSecureClientProvider'", "import React, { ReactNode } from 'react';\r\nimport dynamic from 'next/dynamic'\r\n\r\ninterface TernSecureProviderProps {\r\n children: ReactNode;\r\n}\r\n\r\n// Lightweight loading component\r\nconst LoadingProvider = () => (\r\n <div \r\n aria-label=\"Loading authentication provider...\" \r\n role=\"status\"\r\n style={{ display: 'none' }}\r\n />\r\n)\r\n\r\n// Dynamically import the client provider with no SSR\r\nconst TernSecureClientProvider = dynamic(\r\n () => import('../../client/providers/ternSecureClientProvider').then(mod => mod.TernSecureClientProvider),\r\n { \r\n ssr: false,\r\n loading: LoadingProvider // Return null or a loading indicator\r\n }\r\n)\r\n\r\nexport function TernSecureProvider({ children }: TernSecureProviderProps) {\r\n const startTime = process.env.NODE_ENV === 'development' ? performance.now() : 0\r\n\r\n // Check if the children contain html/body tags\r\n const isRootLayout = React.Children.toArray(children).some(\r\n child => React.isValidElement(child) && child.type === 'html'\r\n );\r\n\r\n // Log performance in development\r\n React.useEffect(() => {\r\n if (process.env.NODE_ENV === 'development') {\r\n const endTime = performance.now()\r\n console.debug(`TernSecure provider mounted in ${endTime - startTime}ms`)\r\n }\r\n }, [startTime])\r\n\r\n if (isRootLayout) {\r\n // If this is the root layout, inject our provider after the body tag\r\n return React.Children.map(children, child => {\r\n if (React.isValidElement(child) && child.type === 'html') {\r\n return React.cloneElement(child, {}, \r\n React.Children.map(child.props.children, bodyChild => {\r\n if (React.isValidElement(bodyChild) && bodyChild.type === 'body') {\r\n // Type assertion to access props safely\r\n const bodyProps = bodyChild.props as { children: ReactNode };\r\n return React.cloneElement(bodyChild, {}, \r\n <TernSecureClientProvider>\r\n {bodyProps.children}\r\n </TernSecureClientProvider>\r\n );\r\n }\r\n return bodyChild;\r\n })\r\n );\r\n }\r\n return child;\r\n });\r\n }\r\n\r\n // For non-root layouts, wrap normally\r\n return <TernSecureClientProvider>{children}</TernSecureClientProvider>;\r\n}", "'use client'\r\n\r\nimport { useEffect, useState, useMemo } from 'react'\r\nimport { onAuthStateChanged } from 'firebase/auth'\r\nimport { TernSecureAuth } from '../app-router/client'\r\nimport { useInternalContext } from '../app-router/client'\r\n\r\nexport interface AuthState {\r\n userId: string | null\r\n loading: boolean;\r\n error: Error | null;\r\n isSignedIn: boolean;\r\n}\r\n\r\nexport function useAuth() {\r\n const auth = useMemo(() => TernSecureAuth(), [])\r\n const [authState, setAuthState] = useState<AuthState>({\r\n loading: true,\r\n isSignedIn: false,\r\n userId: null,\r\n error: null\r\n })\r\n\r\n\r\n useEffect(() => {\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 }, [auth])\r\n\r\n useInternalContext('useAuth')\r\n return {\r\n loading: authState.loading,\r\n isSignedIn: authState.isSignedIn,\r\n userId: authState.userId,\r\n error: authState.error\r\n }\r\n}", "import * as React from 'react'\r\nimport { useState } from 'react'\r\nimport { signInWithEmail } from '../app-router/client'\r\nimport { styles } from '../utils/create-styles'\r\n\r\nexport interface SignInProps {\r\n onSuccess?: () => void\r\n onError?: (error: Error) => void\r\n redirectUrl?: string\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 onSuccess, \r\n onError, \r\n redirectUrl,\r\n className = '',\r\n style,\r\n customStyles = {}\r\n}: SignInProps) {\r\n const [email, setEmail] = useState('')\r\n const [password, setPassword] = useState('')\r\n const [loading, setLoading] = useState(false)\r\n const [error, setError] = useState('')\r\n\r\n const handleSubmit = async (e: React.FormEvent) => {\r\n e.preventDefault()\r\n setLoading(true)\r\n setError('')\r\n\r\n try {\r\n await signInWithEmail({ email, password })\r\n onSuccess?.()\r\n \r\n if (redirectUrl) {\r\n window.location.href = redirectUrl\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 type=\"email\"\r\n value={email}\r\n onChange={(e) => setEmail(e.target.value)}\r\n placeholder=\"Enter your email\"\r\n required\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 type=\"password\"\r\n value={password}\r\n onChange={(e) => setPassword(e.target.value)}\r\n placeholder=\"Enter your password\"\r\n required\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", "'use client'\r\n\r\nconst PREFIX = 'tern'\r\n\r\n// Singleton to track style injection\r\nconst styleInjection = {\r\n isInjected: false,\r\n styleElement: null as HTMLStyleElement | null\r\n}\r\n\r\nexport const defaultClassNames = {\r\n container: `${PREFIX}-container`,\r\n header: `${PREFIX}-header`,\r\n title: `${PREFIX}-title`,\r\n formWrapper: `${PREFIX}-formWrapper`,\r\n formContainer: `${PREFIX}-formContainer`,\r\n form: `${PREFIX}-form`,\r\n label: `${PREFIX}-label`,\r\n input: `${PREFIX}-input`,\r\n button: `${PREFIX}-button`,\r\n error: `${PREFIX}-error`\r\n} as const\r\n\r\n// Create styles once and cache them\r\nfunction createStyleSheet(styles: Record<string, React.CSSProperties>) {\r\n if (typeof window === 'undefined') return defaultClassNames\r\n\r\n // Return early if styles are already injected\r\n if (styleInjection.isInjected) {\r\n return defaultClassNames\r\n }\r\n\r\n // Find existing style element or create new one\r\n let styleElement = document.querySelector<HTMLStyleElement>('[data-tern-secure]')\r\n \r\n if (!styleElement) {\r\n styleElement = document.createElement('style')\r\n styleElement.setAttribute('data-tern-secure', '')\r\n document.head.appendChild(styleElement)\r\n styleInjection.styleElement = styleElement\r\n }\r\n\r\n // Create CSS rules\r\n const cssRules = Object.entries(styles).map(([key, rules]) => {\r\n const className = defaultClassNames[key as keyof typeof defaultClassNames]\r\n const cssProperties = Object.entries(rules).map(([prop, value]) => {\r\n const cssProperty = prop.replace(/([A-Z])/g, '-$1').toLowerCase()\r\n return `${cssProperty}: ${value};`\r\n }).join(' ')\r\n\r\n return `.${className} { ${cssProperties} }`\r\n }).join('\\n')\r\n\r\n // Insert styles only once\r\n styleElement.textContent = cssRules\r\n styleInjection.isInjected = true\r\n\r\n return defaultClassNames\r\n}\r\n\r\n// Style configuration\r\nexport const styleConfig = {\r\n container: {\r\n display: 'flex',\r\n minHeight: '100%',\r\n flex: '1',\r\n flexDirection: 'column',\r\n justifyContent: 'center',\r\n padding: '3rem 1.5rem'\r\n },\r\n header: {\r\n margin: '0 auto',\r\n width: '100%',\r\n maxWidth: '28rem'\r\n },\r\n title: {\r\n marginTop: '1.5rem',\r\n textAlign: 'center',\r\n fontSize: '1.875rem',\r\n fontWeight: '700',\r\n lineHeight: '2.25rem',\r\n letterSpacing: '-0.025em',\r\n color: 'var(--tern-text-primary, #111827)'\r\n },\r\n formWrapper: {\r\n marginTop: '2.5rem',\r\n margin: '0 auto',\r\n width: '100%',\r\n maxWidth: '30rem'\r\n },\r\n formContainer: {\r\n padding: '3rem 1.5rem',\r\n boxShadow: '0 1px 3px 0 rgb(0 0 0 / 0.1)',\r\n borderRadius: '0.5rem',\r\n backgroundColor: 'var(--tern-background, white)'\r\n },\r\n form: {\r\n display: 'flex',\r\n flexDirection: 'column',\r\n gap: '1rem'\r\n },\r\n label: {\r\n display: 'block',\r\n fontSize: '0.875rem',\r\n fontWeight: '500',\r\n color: 'var(--tern-text-secondary, #374151)'\r\n },\r\n input: {\r\n marginTop: '0.25rem',\r\n display: 'block',\r\n width: '100%',\r\n padding: '0.5rem 0.75rem',\r\n borderRadius: '0.375rem',\r\n border: '1px solid var(--tern-border, #D1D5DB)',\r\n backgroundColor: 'var(--tern-input-background, white)',\r\n color: 'var(--tern-text-primary, #111827)'\r\n },\r\n button: {\r\n display: 'flex',\r\n width: '100%',\r\n justifyContent: 'center',\r\n padding: '0.5rem 1rem',\r\n fontSize: '0.875rem',\r\n fontWeight: '500',\r\n color: 'white',\r\n backgroundColor: 'var(--tern-primary, #2563EB)',\r\n border: 'none',\r\n borderRadius: '0.375rem',\r\n cursor: 'pointer'\r\n },\r\n error: {\r\n color: 'var(--tern-error, #DC2626)',\r\n fontSize: '0.875rem'\r\n }\r\n} as const\r\n\r\n// Export pre-created styles\r\nexport const styles = createStyleSheet(styleConfig)\r\n\r\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAEA,cAcM,sBAMA,mBAQA;AA9BN;AAAA;AAAA;AAAA;AAEA,mBAA0C;AAc1C,IAAM,uBAAuB,OAAO,qBAAqB;AAMzD,IAAM,wBAAoB,4BAA4C,IAAI;AAQ1E,IAAM,qBAAqB,CAAC,aAA6C;AACvE,YAAM,cAAU,yBAAW,iBAAiB;AAE5C,UAAI,CAAC,WAAW,QAAQ,gBAAg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A,UACA;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,UAAU;AAAA,cACV,WAAW,GAAG,OAAO,MAAM,IAAI,aAAa,UAAU,EAAE;AAAA,cACxD,eAAY;AAAA,cAEX,oBAAU,kBAAkB;AAAA;AAAA,UAC/B;AAAA;AAAA;AAAA,IACF,GACF,GACF;AAAA,KACF;AAEJ;",
|
|
6
|
+
"names": ["React", "import_react", "import_auth", "auth", "import_react", "import_jsx_runtime", "TernSecureClientProvider", "dynamic", "React", "import_react", "import_auth", "auth", "import_react", "styles", "import_jsx_runtime"]
|
|
7
7
|
}
|
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Props for the TernSecureClientProvider component
|
|
4
|
+
*/
|
|
5
|
+
interface TernSecureClientProviderProps {
|
|
6
|
+
/** React child elements to be wrapped by the provider */
|
|
3
7
|
children: React.ReactNode;
|
|
4
|
-
}
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Provider component for TernSecure authentication
|
|
11
|
+
* Must be used to wrap any components that use TernSecure hooks
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* function App() {
|
|
16
|
+
* return (
|
|
17
|
+
* <TernSecureClientProvider>
|
|
18
|
+
* <YourApp />
|
|
19
|
+
* </TernSecureClientProvider>
|
|
20
|
+
* )
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function TernSecureClientProvider({ children }: TernSecureClientProviderProps): JSX.Element;
|
|
25
|
+
export declare namespace TernSecureClientProvider {
|
|
26
|
+
var displayName: string;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
5
29
|
//# sourceMappingURL=ternSecureClientProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ternSecureClientProvider.d.ts","sourceRoot":"","sources":["../../../../../src/app-router/client/providers/ternSecureClientProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"ternSecureClientProvider.d.ts","sourceRoot":"","sources":["../../../../../src/app-router/client/providers/ternSecureClientProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB;;GAEG;AACH,UAAU,6BAA6B;IACrC,yDAAyD;IACzD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,QAAQ,EAAE,EAAE,6BAA6B,GAAG,GAAG,CAAC,OAAO,CAYjG;yBAZe,wBAAwB"}
|
|
@@ -1,8 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal context type for TernSecure authentication
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
1
5
|
interface TernSecureContextType {
|
|
2
|
-
_contextKey:
|
|
6
|
+
readonly _contextKey: symbol;
|
|
3
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Internal symbol used for context validation
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
4
12
|
declare const INTERNAL_CONTEXT_KEY: unique symbol;
|
|
13
|
+
/**
|
|
14
|
+
* Context for TernSecure authentication
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
5
17
|
declare const TernSecureContext: import("react").Context<TernSecureContextType | null>;
|
|
6
|
-
|
|
7
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Hook to verify that components are rendered within the TernSecure provider
|
|
20
|
+
* @param hookName - Name of the hook being used (for better error messages)
|
|
21
|
+
* @throws {Error} When used outside of TernSecureProvider
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
declare const useInternalContext: (hookName?: string) => TernSecureContextType;
|
|
25
|
+
export { type TernSecureContextType, TernSecureContext, useInternalContext, INTERNAL_CONTEXT_KEY };
|
|
8
26
|
//# sourceMappingURL=ternSecureContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ternSecureContext.d.ts","sourceRoot":"","sources":["../../../../../src/app-router/client/providers/ternSecureContext.tsx"],"names":[],"mappings":"AAIA,UAAU,qBAAqB;IAC7B,WAAW,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"ternSecureContext.d.ts","sourceRoot":"","sources":["../../../../../src/app-router/client/providers/ternSecureContext.tsx"],"names":[],"mappings":"AAIA;;;GAGG;AACH,UAAU,qBAAqB;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B;AAED;;;GAGG;AACH,QAAA,MAAM,oBAAoB,eAAgC,CAAA;AAE1D;;;GAGG;AACH,QAAA,MAAM,iBAAiB,uDAAoD,CAAA;AAE3E;;;;;GAKG;AACH,QAAA,MAAM,kBAAkB,cAAe,MAAM,KAAG,qBAW/C,CAAA;AAED,OAAO,EACL,KAAK,qBAAqB,EAC1B,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACrB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TernSecureServerProvider.d.ts","sourceRoot":"","sources":["../../../../../src/app-router/server/providers/TernSecureServerProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGzC,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,SAAS,CAAC;CACrB;
|
|
1
|
+
{"version":3,"file":"TernSecureServerProvider.d.ts","sourceRoot":"","sources":["../../../../../src/app-router/server/providers/TernSecureServerProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGzC,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAoBD,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,EAAE,uBAAuB,qLAyCvE"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
// src/app-router/client/providers/ternSecureClientProvider.tsx
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
1
4
|
// src/app-router/client/providers/ternSecureContext.tsx
|
|
2
5
|
import { createContext, useContext } from "react";
|
|
3
|
-
var INTERNAL_CONTEXT_KEY = Symbol("
|
|
6
|
+
var INTERNAL_CONTEXT_KEY = Symbol("TERN_SECURE_CONTEXT");
|
|
4
7
|
var TernSecureContext = createContext(null);
|
|
5
|
-
var useInternalContext = (
|
|
8
|
+
var useInternalContext = (hookName) => {
|
|
6
9
|
const context = useContext(TernSecureContext);
|
|
7
10
|
if (!context || context._contextKey !== INTERNAL_CONTEXT_KEY) {
|
|
8
11
|
throw new Error(
|
|
9
|
-
`${
|
|
12
|
+
`${hookName || "Hook"} must be used within TernSecureProvider. Please wrap your component with TernSecureProvider.`
|
|
10
13
|
);
|
|
11
14
|
}
|
|
12
15
|
return context;
|
|
@@ -15,12 +18,17 @@ var useInternalContext = (hookname) => {
|
|
|
15
18
|
// src/app-router/client/providers/ternSecureClientProvider.tsx
|
|
16
19
|
import { jsx } from "react/jsx-runtime";
|
|
17
20
|
function TernSecureClientProvider({ children }) {
|
|
18
|
-
|
|
21
|
+
const contextValue = React.useMemo(
|
|
22
|
+
() => ({ _contextKey: INTERNAL_CONTEXT_KEY }),
|
|
23
|
+
[]
|
|
24
|
+
);
|
|
25
|
+
return /* @__PURE__ */ jsx(TernSecureContext.Provider, { value: contextValue, children });
|
|
19
26
|
}
|
|
27
|
+
TernSecureClientProvider.displayName = "TernSecureClientProvider";
|
|
20
28
|
|
|
21
29
|
export {
|
|
22
30
|
TernSecureContext,
|
|
23
31
|
useInternalContext,
|
|
24
32
|
TernSecureClientProvider
|
|
25
33
|
};
|
|
26
|
-
//# sourceMappingURL=chunk-
|
|
34
|
+
//# sourceMappingURL=chunk-DLYDLPO5.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/app-router/client/providers/ternSecureClientProvider.tsx", "../../src/app-router/client/providers/ternSecureContext.tsx"],
|
|
4
|
+
"sourcesContent": ["'use client'\r\n\r\nimport React from 'react'\r\nimport { INTERNAL_CONTEXT_KEY, TernSecureContext, TernSecureContextType } from './ternSecureContext'\r\n\r\n/**\r\n * Props for the TernSecureClientProvider component\r\n */\r\ninterface TernSecureClientProviderProps {\r\n /** React child elements to be wrapped by the provider */\r\n children: React.ReactNode\r\n}\r\n\r\n/**\r\n * Provider component for TernSecure authentication\r\n * Must be used to wrap any components that use TernSecure hooks\r\n * \r\n * @example\r\n * ```tsx\r\n * function App() {\r\n * return (\r\n * <TernSecureClientProvider>\r\n * <YourApp />\r\n * </TernSecureClientProvider>\r\n * )\r\n * }\r\n * ```\r\n */\r\nexport function TernSecureClientProvider({ children }: TernSecureClientProviderProps): JSX.Element {\r\n // Memoize the context value to prevent unnecessary re-renders\r\n const contextValue = React.useMemo<TernSecureContextType>(\r\n () => ({ _contextKey: INTERNAL_CONTEXT_KEY }),\r\n []\r\n )\r\n\r\n return (\r\n <TernSecureContext.Provider value={contextValue}>\r\n {children}\r\n </TernSecureContext.Provider>\r\n )\r\n}\r\n\r\n// Add display name for better debugging\r\nTernSecureClientProvider.displayName = 'TernSecureClientProvider'", "'use client'\r\n\r\nimport { createContext, useContext } from 'react'\r\n\r\n/**\r\n * Internal context type for TernSecure authentication\r\n * @internal\r\n */\r\ninterface TernSecureContextType {\r\n readonly _contextKey: symbol\r\n}\r\n\r\n/**\r\n * Internal symbol used for context validation\r\n * @internal\r\n */\r\nconst INTERNAL_CONTEXT_KEY = Symbol('TERN_SECURE_CONTEXT')\r\n\r\n/**\r\n * Context for TernSecure authentication\r\n * @internal\r\n */\r\nconst TernSecureContext = createContext<TernSecureContextType | null>(null)\r\n\r\n/**\r\n * Hook to verify that components are rendered within the TernSecure provider\r\n * @param hookName - Name of the hook being used (for better error messages)\r\n * @throws {Error} When used outside of TernSecureProvider\r\n * @internal\r\n */\r\nconst useInternalContext = (hookName?: string): TernSecureContextType => {\r\n const context = useContext(TernSecureContext)\r\n \r\n if (!context || context._contextKey !== INTERNAL_CONTEXT_KEY) {\r\n throw new Error(\r\n `${hookName || 'Hook'} must be used within TernSecureProvider. ` +\r\n 'Please wrap your component with TernSecureProvider.'\r\n )\r\n }\r\n \r\n return context\r\n}\r\n\r\nexport {\r\n type TernSecureContextType,\r\n TernSecureContext,\r\n useInternalContext,\r\n INTERNAL_CONTEXT_KEY\r\n}"],
|
|
5
|
+
"mappings": ";AAEA,OAAO,WAAW;;;ACAlB,SAAS,eAAe,kBAAkB;AAc1C,IAAM,uBAAuB,OAAO,qBAAqB;AAMzD,IAAM,oBAAoB,cAA4C,IAAI;AAQ1E,IAAM,qBAAqB,CAAC,aAA6C;AACvE,QAAM,UAAU,WAAW,iBAAiB;AAE5C,MAAI,CAAC,WAAW,QAAQ,gBAAgB,sBAAsB;AAC5D,UAAM,IAAI;AAAA,MACR,GAAG,YAAY,MAAM;AAAA,IAEvB;AAAA,EACF;AAEA,SAAO;AACT;;;ADLI;AARG,SAAS,yBAAyB,EAAE,SAAS,GAA+C;AAEjG,QAAM,eAAe,MAAM;AAAA,IACzB,OAAO,EAAE,aAAa,qBAAqB;AAAA,IAC3C,CAAC;AAAA,EACH;AAEA,SACE,oBAAC,kBAAkB,UAAlB,EAA2B,OAAO,cAChC,UACH;AAEJ;AAGA,yBAAyB,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -2,17 +2,33 @@
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import dynamic from "next/dynamic";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
var LoadingProvider = () => /* @__PURE__ */ jsx(
|
|
6
|
+
"div",
|
|
7
|
+
{
|
|
8
|
+
"aria-label": "Loading authentication provider...",
|
|
9
|
+
role: "status",
|
|
10
|
+
style: { display: "none" }
|
|
11
|
+
}
|
|
12
|
+
);
|
|
5
13
|
var TernSecureClientProvider = dynamic(
|
|
6
|
-
() => import("./ternSecureClientProvider-
|
|
14
|
+
() => import("./ternSecureClientProvider-AFCR7MAX.js").then((mod) => mod.TernSecureClientProvider),
|
|
7
15
|
{
|
|
8
|
-
ssr: false
|
|
9
|
-
|
|
16
|
+
ssr: false,
|
|
17
|
+
loading: LoadingProvider
|
|
18
|
+
// Return null or a loading indicator
|
|
10
19
|
}
|
|
11
20
|
);
|
|
12
21
|
function TernSecureProvider({ children }) {
|
|
22
|
+
const startTime = process.env.NODE_ENV === "development" ? performance.now() : 0;
|
|
13
23
|
const isRootLayout = React.Children.toArray(children).some(
|
|
14
24
|
(child) => React.isValidElement(child) && child.type === "html"
|
|
15
25
|
);
|
|
26
|
+
React.useEffect(() => {
|
|
27
|
+
if (process.env.NODE_ENV === "development") {
|
|
28
|
+
const endTime = performance.now();
|
|
29
|
+
console.debug(`TernSecure provider mounted in ${endTime - startTime}ms`);
|
|
30
|
+
}
|
|
31
|
+
}, [startTime]);
|
|
16
32
|
if (isRootLayout) {
|
|
17
33
|
return React.Children.map(children, (child) => {
|
|
18
34
|
if (React.isValidElement(child) && child.type === "html") {
|
|
@@ -41,4 +57,4 @@ function TernSecureProvider({ children }) {
|
|
|
41
57
|
export {
|
|
42
58
|
TernSecureProvider
|
|
43
59
|
};
|
|
44
|
-
//# sourceMappingURL=chunk-
|
|
60
|
+
//# sourceMappingURL=chunk-RTEDIKQU.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/app-router/server/providers/TernSecureServerProvider.tsx"],
|
|
4
|
+
"sourcesContent": ["import React, { ReactNode } from 'react';\r\nimport dynamic from 'next/dynamic'\r\n\r\ninterface TernSecureProviderProps {\r\n children: ReactNode;\r\n}\r\n\r\n// Lightweight loading component\r\nconst LoadingProvider = () => (\r\n <div \r\n aria-label=\"Loading authentication provider...\" \r\n role=\"status\"\r\n style={{ display: 'none' }}\r\n />\r\n)\r\n\r\n// Dynamically import the client provider with no SSR\r\nconst TernSecureClientProvider = dynamic(\r\n () => import('../../client/providers/ternSecureClientProvider').then(mod => mod.TernSecureClientProvider),\r\n { \r\n ssr: false,\r\n loading: LoadingProvider // Return null or a loading indicator\r\n }\r\n)\r\n\r\nexport function TernSecureProvider({ children }: TernSecureProviderProps) {\r\n const startTime = process.env.NODE_ENV === 'development' ? performance.now() : 0\r\n\r\n // Check if the children contain html/body tags\r\n const isRootLayout = React.Children.toArray(children).some(\r\n child => React.isValidElement(child) && child.type === 'html'\r\n );\r\n\r\n // Log performance in development\r\n React.useEffect(() => {\r\n if (process.env.NODE_ENV === 'development') {\r\n const endTime = performance.now()\r\n console.debug(`TernSecure provider mounted in ${endTime - startTime}ms`)\r\n }\r\n }, [startTime])\r\n\r\n if (isRootLayout) {\r\n // If this is the root layout, inject our provider after the body tag\r\n return React.Children.map(children, child => {\r\n if (React.isValidElement(child) && child.type === 'html') {\r\n return React.cloneElement(child, {}, \r\n React.Children.map(child.props.children, bodyChild => {\r\n if (React.isValidElement(bodyChild) && bodyChild.type === 'body') {\r\n // Type assertion to access props safely\r\n const bodyProps = bodyChild.props as { children: ReactNode };\r\n return React.cloneElement(bodyChild, {}, \r\n <TernSecureClientProvider>\r\n {bodyProps.children}\r\n </TernSecureClientProvider>\r\n );\r\n }\r\n return bodyChild;\r\n })\r\n );\r\n }\r\n return child;\r\n });\r\n }\r\n\r\n // For non-root layouts, wrap normally\r\n return <TernSecureClientProvider>{children}</TernSecureClientProvider>;\r\n}"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,WAA0B;AACjC,OAAO,aAAa;AAQlB;AADF,IAAM,kBAAkB,MACtB;AAAA,EAAC;AAAA;AAAA,IACC,cAAW;AAAA,IACX,MAAK;AAAA,IACL,OAAO,EAAE,SAAS,OAAO;AAAA;AAC3B;AAIF,IAAM,2BAA2B;AAAA,EAC/B,MAAM,OAAO,wCAAiD,EAAE,KAAK,SAAO,IAAI,wBAAwB;AAAA,EACxG;AAAA,IAC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O,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,OAAO
|
|
1
|
+
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,OAAO;;;;;EAuCtB"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TernSecureProvider
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RTEDIKQU.js";
|
|
4
4
|
import {
|
|
5
5
|
SignIn
|
|
6
6
|
} from "./chunk-XPP2LEPF.js";
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
TernSecureClientProvider,
|
|
21
21
|
TernSecureContext,
|
|
22
22
|
useInternalContext
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-DLYDLPO5.js";
|
|
24
24
|
|
|
25
25
|
// src/hooks/useAuth.ts
|
|
26
26
|
import { useEffect, useState, useMemo } from "react";
|
|
@@ -54,7 +54,12 @@ function useAuth() {
|
|
|
54
54
|
return () => unsubscribe();
|
|
55
55
|
}, [auth]);
|
|
56
56
|
useInternalContext("useAuth");
|
|
57
|
-
return {
|
|
57
|
+
return {
|
|
58
|
+
loading: authState.loading,
|
|
59
|
+
isSignedIn: authState.isSignedIn,
|
|
60
|
+
userId: authState.userId,
|
|
61
|
+
error: authState.error
|
|
62
|
+
};
|
|
58
63
|
}
|
|
59
64
|
export {
|
|
60
65
|
SignIn,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/useAuth.ts"],
|
|
4
|
-
"sourcesContent": ["'use client'\r\n\r\nimport { useEffect, useState, useMemo } from 'react'\r\nimport { onAuthStateChanged } from 'firebase/auth'\r\nimport { TernSecureAuth } from '../app-router/client'\r\nimport { useInternalContext } from '../app-router/client'\r\n\r\nexport interface AuthState {\r\n userId: string | null\r\n loading: boolean;\r\n error: Error | null;\r\n isSignedIn: boolean;\r\n}\r\n\r\nexport function useAuth() {\r\n const auth = useMemo(() => TernSecureAuth(), [])\r\n const [authState, setAuthState] = useState<AuthState>({\r\n loading: true,\r\n isSignedIn: false,\r\n userId: null,\r\n error: null\r\n })\r\n\r\n\r\n useEffect(() => {\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 }, [auth])\r\n\r\n useInternalContext('useAuth')\r\n return { authState }\r\n}"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,WAAW,UAAU,eAAe;AAC7C,SAAS,0BAA0B;AAW5B,SAAS,UAAU;AACxB,QAAM,OAAO,QAAQ,MAAM,eAAe,GAAG,CAAC,CAAC;AAC/C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAoB;AAAA,IACpD,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,OAAO;AAAA,EACT,CAAC;AAGD,YAAU,MAAM;AACd,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,IAAI,CAAC;AAET,qBAAmB,SAAS;AAC5B,SAAO,
|
|
4
|
+
"sourcesContent": ["'use client'\r\n\r\nimport { useEffect, useState, useMemo } from 'react'\r\nimport { onAuthStateChanged } from 'firebase/auth'\r\nimport { TernSecureAuth } from '../app-router/client'\r\nimport { useInternalContext } from '../app-router/client'\r\n\r\nexport interface AuthState {\r\n userId: string | null\r\n loading: boolean;\r\n error: Error | null;\r\n isSignedIn: boolean;\r\n}\r\n\r\nexport function useAuth() {\r\n const auth = useMemo(() => TernSecureAuth(), [])\r\n const [authState, setAuthState] = useState<AuthState>({\r\n loading: true,\r\n isSignedIn: false,\r\n userId: null,\r\n error: null\r\n })\r\n\r\n\r\n useEffect(() => {\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 }, [auth])\r\n\r\n useInternalContext('useAuth')\r\n return {\r\n loading: authState.loading,\r\n isSignedIn: authState.isSignedIn,\r\n userId: authState.userId,\r\n error: authState.error\r\n }\r\n}"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,WAAW,UAAU,eAAe;AAC7C,SAAS,0BAA0B;AAW5B,SAAS,UAAU;AACxB,QAAM,OAAO,QAAQ,MAAM,eAAe,GAAG,CAAC,CAAC;AAC/C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAoB;AAAA,IACpD,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,OAAO;AAAA,EACT,CAAC;AAGD,YAAU,MAAM;AACd,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,IAAI,CAAC;AAET,qBAAmB,SAAS;AAC5B,SAAO;AAAA,IACL,SAAS,UAAU;AAAA,IACnB,YAAY,UAAU;AAAA,IACtB,QAAQ,UAAU;AAAA,IAClB,OAAO,UAAU;AAAA,EACnB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tern-secure/nextjs",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.38",
|
|
4
4
|
"packageManager": "npm@10.9.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
"files": [
|
|
78
78
|
"dist"
|
|
79
79
|
],
|
|
80
|
+
"sideEffects": false,
|
|
80
81
|
"peerDependencies": {
|
|
81
82
|
"firebase": "^10.0.0",
|
|
82
83
|
"next": "^13.0.0 || ^14.0.0 || ^15.0.0",
|
|
@@ -115,5 +116,8 @@
|
|
|
115
116
|
"import": "./dist/esm/components/index.js",
|
|
116
117
|
"require": "./dist/cjs/components/index.js"
|
|
117
118
|
}
|
|
119
|
+
},
|
|
120
|
+
"engines": {
|
|
121
|
+
"node": ">=18.17.0"
|
|
118
122
|
}
|
|
119
123
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/app-router/client/providers/ternSecureContext.tsx", "../../src/app-router/client/providers/ternSecureClientProvider.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\r\n\r\nimport { createContext, useContext} from 'react'\r\n\r\ninterface TernSecureContextType {\r\n _contextKey: Symbol\r\n}\r\n\r\nconst INTERNAL_CONTEXT_KEY = Symbol('INTERNAL_CONTEXT_KEY')\r\nconst TernSecureContext = createContext<TernSecureContextType | null>(null)\r\n\r\nconst useInternalContext = (hookname?: string) => {\r\n const context = useContext(TernSecureContext)\r\n if (!context || context._contextKey !== INTERNAL_CONTEXT_KEY) {\r\n throw new Error(\r\n `${hookname} must be used within TernSecureProvider`)\r\n }\r\n return context\r\n}\r\n\r\nexport {\r\n TernSecureContext,\r\n useInternalContext,\r\n INTERNAL_CONTEXT_KEY\r\n}", "'use client'\r\n\r\nimport React, { useState } from 'react'\r\nimport { INTERNAL_CONTEXT_KEY, TernSecureContext } from './ternSecureContext'\r\n\r\nexport function TernSecureClientProvider({ children }: { children: React.ReactNode }) {\r\n\r\n return (\r\n <TernSecureContext.Provider value={{ _contextKey: INTERNAL_CONTEXT_KEY }}>\r\n {children}\r\n </TernSecureContext.Provider>\r\n )\r\n}"],
|
|
5
|
-
"mappings": ";AAEA,SAAS,eAAe,kBAAiB;AAMzC,IAAM,uBAAuB,OAAO,sBAAsB;AAC1D,IAAM,oBAAoB,cAA4C,IAAI;AAE1E,IAAM,qBAAqB,CAAC,aAAsB;AAChD,QAAM,UAAU,WAAW,iBAAiB;AAC5C,MAAI,CAAC,WAAW,QAAQ,gBAAgB,sBAAsB;AAC5D,UAAM,IAAI;AAAA,MACR,GAAG,QAAQ;AAAA,IAAyC;AAAA,EACxD;AACA,SAAO;AACT;;;ACVI;AAHG,SAAS,yBAAyB,EAAE,SAAS,GAAkC;AAEpF,SACE,oBAAC,kBAAkB,UAAlB,EAA2B,OAAO,EAAE,aAAa,qBAAqB,GACpE,UACH;AAEJ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/app-router/server/providers/TernSecureServerProvider.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { ReactNode } from 'react';\r\nimport dynamic from 'next/dynamic'\r\n\r\ninterface TernSecureProviderProps {\r\n children: ReactNode;\r\n}\r\n\r\n// Dynamically import the client provider with no SSR\r\nconst TernSecureClientProvider = dynamic(\r\n () => import('../../client/providers/ternSecureClientProvider').then(mod => mod.TernSecureClientProvider),\r\n { \r\n ssr: false\r\n //loading: () => null // Return null or a loading indicator\r\n }\r\n)\r\n\r\nexport function TernSecureProvider({ children }: TernSecureProviderProps) {\r\n // Check if the children contain html/body tags\r\n const isRootLayout = React.Children.toArray(children).some(\r\n child => React.isValidElement(child) && child.type === 'html'\r\n );\r\n\r\n if (isRootLayout) {\r\n // If this is the root layout, inject our provider after the body tag\r\n return React.Children.map(children, child => {\r\n if (React.isValidElement(child) && child.type === 'html') {\r\n return React.cloneElement(child, {}, \r\n React.Children.map(child.props.children, bodyChild => {\r\n if (React.isValidElement(bodyChild) && bodyChild.type === 'body') {\r\n // Type assertion to access props safely\r\n const bodyProps = bodyChild.props as { children: ReactNode };\r\n return React.cloneElement(bodyChild, {}, \r\n <TernSecureClientProvider>\r\n {bodyProps.children}\r\n </TernSecureClientProvider>\r\n );\r\n }\r\n return bodyChild;\r\n })\r\n );\r\n }\r\n return child;\r\n });\r\n }\r\n\r\n // For non-root layouts, wrap normally\r\n return <TernSecureClientProvider>{children}</TernSecureClientProvider>;\r\n}"],
|
|
5
|
-
"mappings": ";AAAA,OAAO,WAA0B;AACjC,OAAO,aAAa;AA+BJ;AAxBhB,IAAM,2BAA2B;AAAA,EAC/B,MAAM,OAAO,wCAAiD,EAAE,KAAK,SAAO,IAAI,wBAAwB;AAAA,EACxG;AAAA,IACE,KAAK;AAAA;AAAA,EAEP;AACF;AAEO,SAAS,mBAAmB,EAAE,SAAS,GAA4B;AAExE,QAAM,eAAe,MAAM,SAAS,QAAQ,QAAQ,EAAE;AAAA,IACpD,WAAS,MAAM,eAAe,KAAK,KAAK,MAAM,SAAS;AAAA,EACzD;AAEA,MAAI,cAAc;AAEhB,WAAO,MAAM,SAAS,IAAI,UAAU,WAAS;AAC3C,UAAI,MAAM,eAAe,KAAK,KAAK,MAAM,SAAS,QAAQ;AACxD,eAAO,MAAM;AAAA,UAAa;AAAA,UAAO,CAAC;AAAA,UAChC,MAAM,SAAS,IAAI,MAAM,MAAM,UAAU,eAAa;AACpD,gBAAI,MAAM,eAAe,SAAS,KAAK,UAAU,SAAS,QAAQ;AAEhE,oBAAM,YAAY,UAAU;AAC5B,qBAAO,MAAM;AAAA,gBAAa;AAAA,gBAAW,CAAC;AAAA,gBACpC,oBAAC,4BACE,oBAAU,UACb;AAAA,cACF;AAAA,YACF;AACA,mBAAO;AAAA,UACT,CAAC;AAAA,QACH;AAAA,MACF;AACA,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAGA,SAAO,oBAAC,4BAA0B,UAAS;AAC7C;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
File without changes
|