@tern-secure/nextjs 3.1.35 → 3.1.37
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 +18 -12
- package/dist/cjs/app-router/server/index.js.map +3 -3
- package/dist/cjs/components/index.js +25 -6
- package/dist/cjs/components/index.js.map +3 -3
- package/dist/cjs/index.js +35 -24
- 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/{chunk-HUJ3EKGN.js → chunk-DLYDLPO5.js} +13 -5
- package/dist/esm/chunk-DLYDLPO5.js.map +7 -0
- package/dist/esm/{chunk-MDMNIKQP.js → chunk-VQBYO2G6.js} +2 -2
- package/dist/esm/components/index.js +1 -1
- package/dist/esm/hooks/useAuth.d.ts +5 -3
- 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 +1 -1
- package/dist/esm/chunk-HUJ3EKGN.js.map +0 -7
- package/dist/esm/ternSecureClientProvider-T4QUTB3T.js +0 -8
- /package/dist/esm/{chunk-MDMNIKQP.js.map → chunk-VQBYO2G6.js.map} +0 -0
- /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,iBAAiB,CAAC,WAA+C;AAC5E,SAAO,QAAQ,MAAM,EAAE,QAAQ,C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
|
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,7 +74,7 @@ __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");
|
|
74
80
|
var TernSecureClientProvider2 = (0, import_dynamic.default)(
|
|
@@ -79,19 +85,19 @@ var TernSecureClientProvider2 = (0, import_dynamic.default)(
|
|
|
79
85
|
}
|
|
80
86
|
);
|
|
81
87
|
function TernSecureProvider({ children }) {
|
|
82
|
-
const isRootLayout =
|
|
83
|
-
(child) =>
|
|
88
|
+
const isRootLayout = import_react3.default.Children.toArray(children).some(
|
|
89
|
+
(child) => import_react3.default.isValidElement(child) && child.type === "html"
|
|
84
90
|
);
|
|
85
91
|
if (isRootLayout) {
|
|
86
|
-
return
|
|
87
|
-
if (
|
|
88
|
-
return
|
|
92
|
+
return import_react3.default.Children.map(children, (child) => {
|
|
93
|
+
if (import_react3.default.isValidElement(child) && child.type === "html") {
|
|
94
|
+
return import_react3.default.cloneElement(
|
|
89
95
|
child,
|
|
90
96
|
{},
|
|
91
|
-
|
|
92
|
-
if (
|
|
97
|
+
import_react3.default.Children.map(child.props.children, (bodyChild) => {
|
|
98
|
+
if (import_react3.default.isValidElement(bodyChild) && bodyChild.type === "body") {
|
|
93
99
|
const bodyProps = bodyChild.props;
|
|
94
|
-
return
|
|
100
|
+
return import_react3.default.cloneElement(
|
|
95
101
|
bodyChild,
|
|
96
102
|
{},
|
|
97
103
|
/* @__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// 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 <TernSecureClient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M,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
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/components/index.ts
|
|
@@ -25,7 +35,7 @@ __export(components_exports, {
|
|
|
25
35
|
module.exports = __toCommonJS(components_exports);
|
|
26
36
|
|
|
27
37
|
// src/components/sign-in.tsx
|
|
28
|
-
var
|
|
38
|
+
var import_react3 = require("react");
|
|
29
39
|
|
|
30
40
|
// src/app-router/client/client-init.ts
|
|
31
41
|
var import_app = require("firebase/app");
|
|
@@ -75,11 +85,20 @@ async function signInWithEmail({
|
|
|
75
85
|
|
|
76
86
|
// src/app-router/client/providers/ternSecureContext.tsx
|
|
77
87
|
var import_react = require("react");
|
|
78
|
-
var INTERNAL_CONTEXT_KEY = Symbol("
|
|
88
|
+
var INTERNAL_CONTEXT_KEY = Symbol("TERN_SECURE_CONTEXT");
|
|
79
89
|
var TernSecureContext = (0, import_react.createContext)(null);
|
|
80
90
|
|
|
81
91
|
// src/app-router/client/providers/ternSecureClientProvider.tsx
|
|
92
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
82
93
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
94
|
+
function TernSecureClientProvider({ children }) {
|
|
95
|
+
const contextValue = import_react2.default.useMemo(
|
|
96
|
+
() => ({ _contextKey: INTERNAL_CONTEXT_KEY }),
|
|
97
|
+
[]
|
|
98
|
+
);
|
|
99
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TernSecureContext.Provider, { value: contextValue, children });
|
|
100
|
+
}
|
|
101
|
+
TernSecureClientProvider.displayName = "TernSecureClientProvider";
|
|
83
102
|
|
|
84
103
|
// src/utils/create-styles.ts
|
|
85
104
|
var PREFIX = "tern";
|
|
@@ -209,10 +228,10 @@ function SignIn({
|
|
|
209
228
|
style,
|
|
210
229
|
customStyles = {}
|
|
211
230
|
}) {
|
|
212
|
-
const [email, setEmail] = (0,
|
|
213
|
-
const [password, setPassword] = (0,
|
|
214
|
-
const [loading, setLoading] = (0,
|
|
215
|
-
const [error, setError] = (0,
|
|
231
|
+
const [email, setEmail] = (0, import_react3.useState)("");
|
|
232
|
+
const [password, setPassword] = (0, import_react3.useState)("");
|
|
233
|
+
const [loading, setLoading] = (0, import_react3.useState)(false);
|
|
234
|
+
const [error, setError] = (0, import_react3.useState)("");
|
|
216
235
|
const handleSubmit = async (e) => {
|
|
217
236
|
e.preventDefault();
|
|
218
237
|
setLoading(true);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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/app-router/client/providers/ternSecureContext.tsx", "../../../src/app-router/client/providers/ternSecureClientProvider.tsx", "../../../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\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": "
|
|
6
|
-
"names": ["import_react", "import_auth", "auth", "styles", "import_jsx_runtime"]
|
|
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\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'", "'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,IAAAA,gBAAyB;;;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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AAM,SAAS,EAAE,OAAO,KAAK;AAAA,gBACxC,aAAY;AAAA,gBACZ,UAAQ;AAAA,gBACR,WAAW,GAAG,OAAO,KAAK,IAAI,aAAa,SAAS,EAAE;AAAA,gBACtD,UAAU;AAAA,gBACV,iBAAc;AAAA,gBACd,gBAAc,CAAC,CAAC;AAAA;AAAA,YAClB;AAAA,aACF;AAAA,UACA,8CAAC,SACC;AAAA,yDAAC,WAAM,SAAQ,YAAW,WAAW,GAAG,OAAO,KAAK,IAAI,aAAa,SAAS,EAAE,IAAI,sBAEpF;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACC,IAAG;AAAA,gBACH,MAAK;AAAA,gBACL,OAAO;AAAA,gBACP,UAAU,CAAC,MAAM,YAAY,EAAE,OAAO,KAAK;AAAA,gBAC3C,aAAY;AAAA,gBACZ,UAAQ;AAAA,gBACR,WAAW,GAAG,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_react", "import_auth", "auth", "import_react", "React", "styles", "import_jsx_runtime"]
|
|
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,7 +146,7 @@ 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");
|
|
146
152
|
var TernSecureClientProvider2 = (0, import_dynamic.default)(
|
|
@@ -151,19 +157,19 @@ var TernSecureClientProvider2 = (0, import_dynamic.default)(
|
|
|
151
157
|
}
|
|
152
158
|
);
|
|
153
159
|
function TernSecureProvider({ children }) {
|
|
154
|
-
const isRootLayout =
|
|
155
|
-
(child) =>
|
|
160
|
+
const isRootLayout = import_react3.default.Children.toArray(children).some(
|
|
161
|
+
(child) => import_react3.default.isValidElement(child) && child.type === "html"
|
|
156
162
|
);
|
|
157
163
|
if (isRootLayout) {
|
|
158
|
-
return
|
|
159
|
-
if (
|
|
160
|
-
return
|
|
164
|
+
return import_react3.default.Children.map(children, (child) => {
|
|
165
|
+
if (import_react3.default.isValidElement(child) && child.type === "html") {
|
|
166
|
+
return import_react3.default.cloneElement(
|
|
161
167
|
child,
|
|
162
168
|
{},
|
|
163
|
-
|
|
164
|
-
if (
|
|
169
|
+
import_react3.default.Children.map(child.props.children, (bodyChild) => {
|
|
170
|
+
if (import_react3.default.isValidElement(bodyChild) && bodyChild.type === "body") {
|
|
165
171
|
const bodyProps = bodyChild.props;
|
|
166
|
-
return
|
|
172
|
+
return import_react3.default.cloneElement(
|
|
167
173
|
bodyChild,
|
|
168
174
|
{},
|
|
169
175
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TernSecureClientProvider2, { children: bodyProps.children })
|
|
@@ -180,17 +186,17 @@ function TernSecureProvider({ children }) {
|
|
|
180
186
|
}
|
|
181
187
|
|
|
182
188
|
// src/hooks/useAuth.ts
|
|
183
|
-
var
|
|
189
|
+
var import_react4 = require("react");
|
|
184
190
|
var import_auth4 = require("firebase/auth");
|
|
185
191
|
function useAuth() {
|
|
186
|
-
const auth2 = (0,
|
|
187
|
-
const [authState, setAuthState] = (0,
|
|
192
|
+
const auth2 = (0, import_react4.useMemo)(() => TernSecureAuth(), []);
|
|
193
|
+
const [authState, setAuthState] = (0, import_react4.useState)({
|
|
188
194
|
loading: true,
|
|
189
195
|
isSignedIn: false,
|
|
190
196
|
userId: null,
|
|
191
197
|
error: null
|
|
192
198
|
});
|
|
193
|
-
(0,
|
|
199
|
+
(0, import_react4.useEffect)(() => {
|
|
194
200
|
const unsubscribe = (0, import_auth4.onAuthStateChanged)(auth2, (user) => {
|
|
195
201
|
if (user) {
|
|
196
202
|
setAuthState({
|
|
@@ -211,11 +217,16 @@ function useAuth() {
|
|
|
211
217
|
return () => unsubscribe();
|
|
212
218
|
}, [auth2]);
|
|
213
219
|
useInternalContext("useAuth");
|
|
214
|
-
return {
|
|
220
|
+
return {
|
|
221
|
+
loading: authState.loading,
|
|
222
|
+
isSignedIn: authState.isSignedIn,
|
|
223
|
+
userId: authState.userId,
|
|
224
|
+
error: authState.error
|
|
225
|
+
};
|
|
215
226
|
}
|
|
216
227
|
|
|
217
228
|
// src/components/sign-in.tsx
|
|
218
|
-
var
|
|
229
|
+
var import_react5 = require("react");
|
|
219
230
|
|
|
220
231
|
// src/utils/create-styles.ts
|
|
221
232
|
var PREFIX = "tern";
|
|
@@ -345,10 +356,10 @@ function SignIn({
|
|
|
345
356
|
style,
|
|
346
357
|
customStyles = {}
|
|
347
358
|
}) {
|
|
348
|
-
const [email, setEmail] = (0,
|
|
349
|
-
const [password, setPassword] = (0,
|
|
350
|
-
const [loading, setLoading] = (0,
|
|
351
|
-
const [error, setError] = (0,
|
|
359
|
+
const [email, setEmail] = (0, import_react5.useState)("");
|
|
360
|
+
const [password, setPassword] = (0, import_react5.useState)("");
|
|
361
|
+
const [loading, setLoading] = (0, import_react5.useState)(false);
|
|
362
|
+
const [error, setError] = (0, import_react5.useState)("");
|
|
352
363
|
const handleSubmit = async (e) => {
|
|
353
364
|
e.preventDefault();
|
|
354
365
|
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\ninterface 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// 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 {\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,gBAAgB,sBAAsB;AAC5D,cAAM,IAAI;AAAA,UACR,GAAG,YAAY,MAAM;AAAA,QAEvB;AAAA,MACF;AAEA,aAAO;AAAA,IACT;AAAA;AAAA;;;ACzCA;AAAA;AAAA;AAAA;AA4BO,SAAS,yBAAyB,EAAE,SAAS,GAA+C;AAEjG,QAAM,eAAe,cAAAA,QAAM;AAAA,IACzB,OAAO,EAAE,aAAa,qBAAqB;AAAA,IAC3C,CAAC;AAAA,EACH;AAEA,SACE,4CA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A,gBACV,iBAAc;AAAA,gBACd,gBAAc,CAAC,CAAC;AAAA;AAAA,YAClB;AAAA,aACF;AAAA,UACA,8CAAC,SACC;AAAA,yDAAC,WAAM,SAAQ,YAAW,WAAW,GAAG,OAAO,KAAK,IAAI,aAAa,SAAS,EAAE,IAAI,sBAEpF;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACC,IAAG;AAAA,gBACH,MAAK;AAAA,gBACL,OAAO;AAAA,gBACP,UAAU,CAAC,MAAM,YAAY,EAAE,OAAO,KAAK;AAAA,gBAC3C,aAAY;AAAA,gBACZ,UAAQ;AAAA,gBACR,WAAW,GAAG,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": ["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,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
|
+
}
|
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
import dynamic from "next/dynamic";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
var TernSecureClientProvider = dynamic(
|
|
6
|
-
() => import("./ternSecureClientProvider-
|
|
6
|
+
() => import("./ternSecureClientProvider-AFCR7MAX.js").then((mod) => mod.TernSecureClientProvider),
|
|
7
7
|
{
|
|
8
8
|
ssr: false
|
|
9
9
|
//loading: () => null // Return null or a loading indicator
|
|
@@ -41,4 +41,4 @@ function TernSecureProvider({ children }) {
|
|
|
41
41
|
export {
|
|
42
42
|
TernSecureProvider
|
|
43
43
|
};
|
|
44
|
-
//# sourceMappingURL=chunk-
|
|
44
|
+
//# sourceMappingURL=chunk-VQBYO2G6.js.map
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
interface AuthState {
|
|
1
|
+
export interface AuthState {
|
|
2
2
|
userId: string | null;
|
|
3
3
|
loading: boolean;
|
|
4
4
|
error: Error | null;
|
|
5
5
|
isSignedIn: boolean;
|
|
6
6
|
}
|
|
7
7
|
export declare function useAuth(): {
|
|
8
|
-
|
|
8
|
+
loading: boolean;
|
|
9
|
+
isSignedIn: boolean;
|
|
10
|
+
userId: string | null;
|
|
11
|
+
error: Error | null;
|
|
9
12
|
};
|
|
10
|
-
export {};
|
|
11
13
|
//# sourceMappingURL=useAuth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAOA,
|
|
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-VQBYO2G6.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\
|
|
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,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
|
-
}
|
|
File without changes
|
|
File without changes
|