@tern-secure/nextjs 3.1.43 → 3.1.45
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/index.js +57 -32
- package/dist/cjs/index.js.map +3 -3
- package/dist/esm/TernSecureProvider-7KNRQUY2.js +8 -0
- package/dist/esm/app-router/client/{providers/ternSecureClientProvider.d.ts → TernSecureProvider.d.ts} +1 -1
- package/dist/esm/app-router/client/TernSecureProvider.d.ts.map +1 -0
- package/dist/esm/app-router/server/TernSecureServerProvider.d.ts.map +1 -0
- package/dist/esm/app-router/{client → server}/auth.d.ts.map +1 -1
- package/dist/esm/{app-router/client/providers/ternSecureContext.d.ts → boundary/TernSecureCtx.d.ts} +1 -1
- package/dist/esm/boundary/TernSecureCtx.d.ts.map +1 -0
- package/dist/esm/boundary/hooks/useAuth.d.ts.map +1 -0
- package/dist/esm/{chunk-DLYDLPO5.js → chunk-Q7WUJODD.js} +4 -4
- package/dist/esm/chunk-Q7WUJODD.js.map +7 -0
- package/dist/esm/{errors/index.d.ts → errors.d.ts} +1 -1
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/index.d.ts +7 -3
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +348 -23
- package/dist/esm/index.js.map +4 -4
- package/dist/esm/types.d.ts +47 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/utils/client-init.d.ts.map +1 -0
- package/dist/esm/utils/config.d.ts +19 -0
- package/dist/esm/utils/config.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/cjs/app-router/client/client-init.js +0 -68
- package/dist/cjs/app-router/client/client-init.js.map +0 -7
- package/dist/cjs/app-router/client/config.js +0 -49
- package/dist/cjs/app-router/client/config.js.map +0 -7
- package/dist/cjs/app-router/client/index.js +0 -129
- package/dist/cjs/app-router/client/index.js.map +0 -7
- package/dist/cjs/app-router/server/index.js +0 -128
- package/dist/cjs/app-router/server/index.js.map +0 -7
- package/dist/cjs/components/index.js +0 -298
- package/dist/cjs/components/index.js.map +0 -7
- package/dist/esm/app-router/client/client-init.d.ts.map +0 -1
- package/dist/esm/app-router/client/client-init.js +0 -12
- package/dist/esm/app-router/client/config.d.ts +0 -4
- package/dist/esm/app-router/client/config.d.ts.map +0 -1
- package/dist/esm/app-router/client/config.js +0 -9
- package/dist/esm/app-router/client/config.js.map +0 -7
- package/dist/esm/app-router/client/index.d.ts +0 -7
- package/dist/esm/app-router/client/index.d.ts.map +0 -1
- package/dist/esm/app-router/client/index.js +0 -30
- package/dist/esm/app-router/client/index.js.map +0 -7
- package/dist/esm/app-router/client/providers/ternSecureClientProvider.d.ts.map +0 -1
- package/dist/esm/app-router/client/providers/ternSecureContext.d.ts.map +0 -1
- package/dist/esm/app-router/server/index.d.ts +0 -2
- package/dist/esm/app-router/server/index.d.ts.map +0 -1
- package/dist/esm/app-router/server/index.js +0 -7
- package/dist/esm/app-router/server/index.js.map +0 -7
- package/dist/esm/app-router/server/providers/TernSecureServerProvider.d.ts.map +0 -1
- package/dist/esm/chunk-5DISHXED.js +0 -24
- package/dist/esm/chunk-5DISHXED.js.map +0 -7
- package/dist/esm/chunk-DLYDLPO5.js.map +0 -7
- package/dist/esm/chunk-MFZTPXU5.js +0 -53
- package/dist/esm/chunk-MFZTPXU5.js.map +0 -7
- package/dist/esm/chunk-VEDAIBAS.js +0 -26
- package/dist/esm/chunk-VEDAIBAS.js.map +0 -7
- package/dist/esm/chunk-VXRNAJSQ.js +0 -18
- package/dist/esm/chunk-VXRNAJSQ.js.map +0 -7
- package/dist/esm/chunk-ZEHPVICV.js +0 -232
- package/dist/esm/chunk-ZEHPVICV.js.map +0 -7
- package/dist/esm/components/index.d.ts +0 -2
- package/dist/esm/components/index.d.ts.map +0 -1
- package/dist/esm/components/index.js +0 -11
- package/dist/esm/components/index.js.map +0 -7
- package/dist/esm/errors/index.d.ts.map +0 -1
- package/dist/esm/hooks/index.d.ts +0 -2
- package/dist/esm/hooks/index.d.ts.map +0 -1
- package/dist/esm/hooks/useAuth.d.ts.map +0 -1
- package/dist/esm/ternSecureClientProvider-AFCR7MAX.js +0 -8
- package/dist/esm/ternSecureClientProvider-AFCR7MAX.js.map +0 -7
- package/dist/esm/types/index.d.ts +0 -18
- package/dist/esm/types/index.d.ts.map +0 -1
- /package/dist/esm/{app-router/client/client-init.js.map → TernSecureProvider-7KNRQUY2.js.map} +0 -0
- /package/dist/esm/app-router/server/{providers/TernSecureServerProvider.d.ts → TernSecureServerProvider.d.ts} +0 -0
- /package/dist/esm/app-router/{client → server}/auth.d.ts +0 -0
- /package/dist/esm/{hooks → boundary/hooks}/useAuth.d.ts +0 -0
- /package/dist/esm/{app-router/client → utils}/client-init.d.ts +0 -0
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/app-router/client/config.ts
|
|
21
|
-
var config_exports = {};
|
|
22
|
-
__export(config_exports, {
|
|
23
|
-
loadFireConfig: () => loadFireConfig,
|
|
24
|
-
validateConfig: () => validateConfig
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(config_exports);
|
|
27
|
-
var loadFireConfig = () => ({
|
|
28
|
-
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
|
|
29
|
-
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
|
|
30
|
-
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
|
|
31
|
-
storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
|
|
32
|
-
messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
|
|
33
|
-
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
|
|
34
|
-
measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
|
|
35
|
-
});
|
|
36
|
-
var validateConfig = (config) => {
|
|
37
|
-
Object.entries(config).forEach(([key, value]) => {
|
|
38
|
-
if (!value) {
|
|
39
|
-
throw new Error(`Missing environment variable: NEXT_PUBLIC_FIREBASE_${key.toUpperCase()}`);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
return config;
|
|
43
|
-
};
|
|
44
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
-
0 && (module.exports = {
|
|
46
|
-
loadFireConfig,
|
|
47
|
-
validateConfig
|
|
48
|
-
});
|
|
49
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/app-router/client/config.ts"],
|
|
4
|
-
"sourcesContent": ["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};"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAM,iBAAiB,OAAyB;AAAA,EACrD,QAAQ,QAAQ,IAAI;AAAA,EACpB,YAAY,QAAQ,IAAI;AAAA,EACxB,WAAW,QAAQ,IAAI;AAAA,EACvB,eAAe,QAAQ,IAAI;AAAA,EAC3B,mBAAmB,QAAQ,IAAI;AAAA,EAC/B,OAAO,QAAQ,IAAI;AAAA,EACnB,eAAe,QAAQ,IAAI;AAC7B;AAEO,IAAM,iBAAiB,CAAC,WAA+C;AAC5E,SAAO,QAAQ,MAAM,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAC/C,QAAI,CAAC,OAAO;AACV,YAAM,IAAI,MAAM,sDAAsD,IAAI,YAAY,CAAC,EAAE;AAAA,IAC3F;AAAA,EACF,CAAC;AACD,SAAO;AACT;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
|
|
31
|
-
// src/app-router/client/index.ts
|
|
32
|
-
var client_exports = {};
|
|
33
|
-
__export(client_exports, {
|
|
34
|
-
TernSecureAuth: () => TernSecureAuth,
|
|
35
|
-
TernSecureClientProvider: () => TernSecureClientProvider,
|
|
36
|
-
TernSecureContext: () => TernSecureContext,
|
|
37
|
-
TernSecureFirestore: () => TernSecureFirestore,
|
|
38
|
-
TernSecureStorage: () => TernSecureStorage,
|
|
39
|
-
loadFireConfig: () => loadFireConfig,
|
|
40
|
-
signInWithEmail: () => signInWithEmail,
|
|
41
|
-
useInternalContext: () => useInternalContext,
|
|
42
|
-
validateConfig: () => validateConfig
|
|
43
|
-
});
|
|
44
|
-
module.exports = __toCommonJS(client_exports);
|
|
45
|
-
|
|
46
|
-
// src/app-router/client/client-init.ts
|
|
47
|
-
var import_app = require("firebase/app");
|
|
48
|
-
var import_auth = require("firebase/auth");
|
|
49
|
-
var import_firestore = require("firebase/firestore");
|
|
50
|
-
var import_storage = require("firebase/storage");
|
|
51
|
-
|
|
52
|
-
// src/app-router/client/config.ts
|
|
53
|
-
var loadFireConfig = () => ({
|
|
54
|
-
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
|
|
55
|
-
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
|
|
56
|
-
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
|
|
57
|
-
storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
|
|
58
|
-
messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
|
|
59
|
-
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
|
|
60
|
-
measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
|
|
61
|
-
});
|
|
62
|
-
var validateConfig = (config2) => {
|
|
63
|
-
Object.entries(config2).forEach(([key, value]) => {
|
|
64
|
-
if (!value) {
|
|
65
|
-
throw new Error(`Missing environment variable: NEXT_PUBLIC_FIREBASE_${key.toUpperCase()}`);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
return config2;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
// src/app-router/client/client-init.ts
|
|
72
|
-
var config = validateConfig(loadFireConfig());
|
|
73
|
-
var clientApp = (0, import_app.initializeApp)(config);
|
|
74
|
-
var auth = (0, import_auth.getAuth)(clientApp);
|
|
75
|
-
(0, import_auth.setPersistence)(auth, import_auth.browserSessionPersistence);
|
|
76
|
-
var firestore = (0, import_firestore.getFirestore)(clientApp);
|
|
77
|
-
var storage = (0, import_storage.getStorage)(clientApp);
|
|
78
|
-
var TernSecureAuth = () => auth;
|
|
79
|
-
var TernSecureFirestore = () => firestore;
|
|
80
|
-
var TernSecureStorage = () => storage;
|
|
81
|
-
|
|
82
|
-
// src/app-router/client/auth.ts
|
|
83
|
-
var import_auth2 = require("firebase/auth");
|
|
84
|
-
async function signInWithEmail({
|
|
85
|
-
email,
|
|
86
|
-
password
|
|
87
|
-
}) {
|
|
88
|
-
const auth2 = TernSecureAuth();
|
|
89
|
-
return (0, import_auth2.signInWithEmailAndPassword)(auth2, email, password);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// src/app-router/client/providers/ternSecureContext.tsx
|
|
93
|
-
var import_react = require("react");
|
|
94
|
-
var INTERNAL_CONTEXT_KEY = Symbol("TERN_SECURE_CONTEXT");
|
|
95
|
-
var TernSecureContext = (0, import_react.createContext)(null);
|
|
96
|
-
var useInternalContext = (hookName) => {
|
|
97
|
-
const context = (0, import_react.useContext)(TernSecureContext);
|
|
98
|
-
if (!context || context._contextKey !== INTERNAL_CONTEXT_KEY) {
|
|
99
|
-
throw new Error(
|
|
100
|
-
`${hookName || "Hook"} must be used within TernSecureProvider. Please wrap your component with TernSecureProvider.`
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
return context;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
// src/app-router/client/providers/ternSecureClientProvider.tsx
|
|
107
|
-
var import_react2 = __toESM(require("react"), 1);
|
|
108
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
109
|
-
function TernSecureClientProvider({ children }) {
|
|
110
|
-
const contextValue = import_react2.default.useMemo(
|
|
111
|
-
() => ({ _contextKey: INTERNAL_CONTEXT_KEY }),
|
|
112
|
-
[]
|
|
113
|
-
);
|
|
114
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TernSecureContext.Provider, { value: contextValue, children });
|
|
115
|
-
}
|
|
116
|
-
TernSecureClientProvider.displayName = "TernSecureClientProvider";
|
|
117
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
118
|
-
0 && (module.exports = {
|
|
119
|
-
TernSecureAuth,
|
|
120
|
-
TernSecureClientProvider,
|
|
121
|
-
TernSecureContext,
|
|
122
|
-
TernSecureFirestore,
|
|
123
|
-
TernSecureStorage,
|
|
124
|
-
loadFireConfig,
|
|
125
|
-
signInWithEmail,
|
|
126
|
-
useInternalContext,
|
|
127
|
-
validateConfig
|
|
128
|
-
});
|
|
129
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 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 config = validateConfig(loadFireConfig());\r\nconst clientApp = initializeApp(config)\r\nconst auth = getAuth(clientApp);\r\nsetPersistence(auth, browserSessionPersistence); //to change later user should be able to choose persistance\r\nconst firestore = getFirestore(clientApp);\r\nconst storage = getStorage(clientApp);\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,CAACA,YAA+C;AAC5E,SAAO,QAAQA,OAAM,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAC/C,QAAI,CAAC,OAAO;AACV,YAAM,IAAI,MAAM,sDAAsD,IAAI,YAAY,CAAC,EAAE;AAAA,IAC3F;AAAA,EACF,CAAC;AACD,SAAOA;AACT;;;ADZA,IAAM,SAAS,eAAe,eAAe,CAAC;AAC9C,IAAM,gBAAY,0BAAc,MAAM;AACtC,IAAM,WAAO,qBAAQ,SAAS;AAAA,IAC9B,4BAAe,MAAM,qCAAyB;AAC9C,IAAM,gBAAY,+BAAa,SAAS;AACxC,IAAM,cAAU,2BAAW,SAAS;AAE7B,IAAM,iBAAiB,MAAM;AAC7B,IAAM,sBAAsB,MAAM;AAClC,IAAM,oBAAoB,MAAM;;;AEfvC,IAAAC,eAAgE;AAOhE,eAAsB,gBAAgB;AAAA,EACpC;AAAA,EACA;AACF,GAA+C;AAC7C,QAAMC,QAAO,eAAe;AAC5B,aAAO,yCAA2BA,OAAM,OAAO,QAAQ;AACzD;;;ACZA,mBAA0C;AAc1C,IAAM,uBAAuB,OAAO,qBAAqB;AAMzD,IAAM,wBAAoB,4BAA4C,IAAI;AAQ1E,IAAM,qBAAqB,CAAC,aAA6C;AACvE,QAAM,cAAU,yBAAW,iBAAiB;AAE5C,MAAI,CAAC,WAAW,QAAQ,gBAAgB,sBAAsB;AAC5D,UAAM,IAAI;AAAA,MACR,GAAG,YAAY,MAAM;AAAA,IAEvB;AAAA,EACF;AAEA,SAAO;AACT;;;ACvCA,IAAAC,gBAAkB;AAkCd;AARG,SAAS,yBAAyB,EAAE,SAAS,GAA+C;AAEjG,QAAM,eAAe,cAAAC,QAAM;AAAA,IACzB,OAAO,EAAE,aAAa,qBAAqB;AAAA,IAC3C,CAAC;AAAA,EACH;AAEA,SACE,4CAAC,kBAAkB,UAAlB,EAA2B,OAAO,cAChC,UACH;AAEJ;AAGA,yBAAyB,cAAc;",
|
|
6
|
-
"names": ["config", "import_auth", "auth", "import_react", "React"]
|
|
7
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __esm = (fn, res) => function __init() {
|
|
9
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
-
};
|
|
11
|
-
var __export = (target, all) => {
|
|
12
|
-
for (var name in all)
|
|
13
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
-
};
|
|
15
|
-
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
-
for (let key of __getOwnPropNames(from))
|
|
18
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
-
}
|
|
21
|
-
return to;
|
|
22
|
-
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
-
mod
|
|
30
|
-
));
|
|
31
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
-
|
|
33
|
-
// src/app-router/client/providers/ternSecureContext.tsx
|
|
34
|
-
var import_react, INTERNAL_CONTEXT_KEY, TernSecureContext;
|
|
35
|
-
var init_ternSecureContext = __esm({
|
|
36
|
-
"src/app-router/client/providers/ternSecureContext.tsx"() {
|
|
37
|
-
"use strict";
|
|
38
|
-
"use client";
|
|
39
|
-
import_react = require("react");
|
|
40
|
-
INTERNAL_CONTEXT_KEY = Symbol("TERN_SECURE_CONTEXT");
|
|
41
|
-
TernSecureContext = (0, import_react.createContext)(null);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
// src/app-router/client/providers/ternSecureClientProvider.tsx
|
|
46
|
-
var ternSecureClientProvider_exports = {};
|
|
47
|
-
__export(ternSecureClientProvider_exports, {
|
|
48
|
-
TernSecureClientProvider: () => TernSecureClientProvider
|
|
49
|
-
});
|
|
50
|
-
function TernSecureClientProvider({ children }) {
|
|
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 });
|
|
56
|
-
}
|
|
57
|
-
var import_react2, import_jsx_runtime;
|
|
58
|
-
var init_ternSecureClientProvider = __esm({
|
|
59
|
-
"src/app-router/client/providers/ternSecureClientProvider.tsx"() {
|
|
60
|
-
"use strict";
|
|
61
|
-
"use client";
|
|
62
|
-
import_react2 = __toESM(require("react"), 1);
|
|
63
|
-
init_ternSecureContext();
|
|
64
|
-
import_jsx_runtime = require("react/jsx-runtime");
|
|
65
|
-
TernSecureClientProvider.displayName = "TernSecureClientProvider";
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
// src/app-router/server/index.ts
|
|
70
|
-
var server_exports = {};
|
|
71
|
-
__export(server_exports, {
|
|
72
|
-
TernSecureProvider: () => TernSecureProvider
|
|
73
|
-
});
|
|
74
|
-
module.exports = __toCommonJS(server_exports);
|
|
75
|
-
|
|
76
|
-
// src/app-router/server/providers/TernSecureServerProvider.tsx
|
|
77
|
-
var import_react3 = __toESM(require("react"), 1);
|
|
78
|
-
var import_dynamic = __toESM(require("next/dynamic"), 1);
|
|
79
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
80
|
-
var LoadingProvider = () => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
81
|
-
"div",
|
|
82
|
-
{
|
|
83
|
-
"aria-label": "Loading authentication provider...",
|
|
84
|
-
role: "status",
|
|
85
|
-
style: { display: "none" }
|
|
86
|
-
}
|
|
87
|
-
);
|
|
88
|
-
var TernSecureClientProvider2 = (0, import_dynamic.default)(
|
|
89
|
-
() => Promise.resolve().then(() => (init_ternSecureClientProvider(), ternSecureClientProvider_exports)).then((mod) => mod.TernSecureClientProvider),
|
|
90
|
-
{
|
|
91
|
-
//ssr: false,
|
|
92
|
-
loading: LoadingProvider
|
|
93
|
-
// Return null or a loading indicator
|
|
94
|
-
}
|
|
95
|
-
);
|
|
96
|
-
function TernSecureProvider({ children }) {
|
|
97
|
-
const isRootLayout = import_react3.default.Children.toArray(children).some(
|
|
98
|
-
(child) => import_react3.default.isValidElement(child) && child.type === "html"
|
|
99
|
-
);
|
|
100
|
-
if (isRootLayout) {
|
|
101
|
-
return import_react3.default.Children.map(children, (child) => {
|
|
102
|
-
if (import_react3.default.isValidElement(child) && child.type === "html") {
|
|
103
|
-
return import_react3.default.cloneElement(
|
|
104
|
-
child,
|
|
105
|
-
{},
|
|
106
|
-
import_react3.default.Children.map(child.props.children, (bodyChild) => {
|
|
107
|
-
if (import_react3.default.isValidElement(bodyChild) && bodyChild.type === "body") {
|
|
108
|
-
const bodyProps = bodyChild.props;
|
|
109
|
-
return import_react3.default.cloneElement(
|
|
110
|
-
bodyChild,
|
|
111
|
-
{},
|
|
112
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TernSecureClientProvider2, { children: bodyProps.children })
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
return bodyChild;
|
|
116
|
-
})
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
return child;
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TernSecureClientProvider2, { children });
|
|
123
|
-
}
|
|
124
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
125
|
-
0 && (module.exports = {
|
|
126
|
-
TernSecureProvider
|
|
127
|
-
});
|
|
128
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 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\n/**\r\n * Internal context type for TernSecure authentication\r\n * @internal\r\n */\r\ninterface TernSecureContextType {\r\n readonly _contextKey: symbol\r\n}\r\n\r\n/**\r\n * Internal symbol used for context validation\r\n * @internal\r\n */\r\nconst INTERNAL_CONTEXT_KEY = Symbol('TERN_SECURE_CONTEXT')\r\n\r\n/**\r\n * Context for TernSecure authentication\r\n * @internal\r\n */\r\nconst TernSecureContext = createContext<TernSecureContextType | null>(null)\r\n\r\n/**\r\n * Hook to verify that components are rendered within the TernSecure provider\r\n * @param hookName - Name of the hook being used (for better error messages)\r\n * @throws {Error} When used outside of TernSecureProvider\r\n * @internal\r\n */\r\nconst useInternalContext = (hookName?: string): TernSecureContextType => {\r\n const context = useContext(TernSecureContext)\r\n \r\n if (!context || context._contextKey !== INTERNAL_CONTEXT_KEY) {\r\n throw new Error(\r\n `${hookName || 'Hook'} must be used within TernSecureProvider. ` +\r\n 'Please wrap your component with TernSecureProvider.'\r\n )\r\n }\r\n \r\n return context\r\n}\r\n\r\nexport {\r\n type TernSecureContextType,\r\n TernSecureContext,\r\n useInternalContext,\r\n INTERNAL_CONTEXT_KEY\r\n}", "'use client'\r\n\r\nimport React from 'react'\r\nimport { INTERNAL_CONTEXT_KEY, TernSecureContext, TernSecureContextType } from './ternSecureContext'\r\n\r\n/**\r\n * Props for the TernSecureClientProvider component\r\n */\r\ninterface TernSecureClientProviderProps {\r\n /** React child elements to be wrapped by the provider */\r\n children: React.ReactNode\r\n}\r\n\r\n/**\r\n * Provider component for TernSecure authentication\r\n * Must be used to wrap any components that use TernSecure hooks\r\n * \r\n * @example\r\n * ```tsx\r\n * function App() {\r\n * return (\r\n * <TernSecureClientProvider>\r\n * <YourApp />\r\n * </TernSecureClientProvider>\r\n * )\r\n * }\r\n * ```\r\n */\r\nexport function TernSecureClientProvider({ children }: TernSecureClientProviderProps): JSX.Element {\r\n // Memoize the context value to prevent unnecessary re-renders\r\n const contextValue = React.useMemo<TernSecureContextType>(\r\n () => ({ _contextKey: INTERNAL_CONTEXT_KEY }),\r\n []\r\n )\r\n\r\n return (\r\n <TernSecureContext.Provider value={contextValue}>\r\n {children}\r\n </TernSecureContext.Provider>\r\n )\r\n}\r\n\r\n// Add display name for better debugging\r\nTernSecureClientProvider.displayName = 'TernSecureClientProvider'", "export { TernSecureProvider } from './providers/TernSecureServerProvider';", "import React, { ReactNode } from 'react';\r\nimport dynamic from 'next/dynamic'\r\n\r\ninterface TernSecureProviderProps {\r\n children: ReactNode;\r\n}\r\n\r\n// Lightweight loading component\r\nconst LoadingProvider = () => (\r\n <div \r\n aria-label=\"Loading authentication provider...\" \r\n role=\"status\"\r\n style={{ display: 'none' }}\r\n />\r\n)\r\n\r\n// Dynamically import the client provider with no SSR\r\nconst TernSecureClientProvider = dynamic(\r\n () => import('../../client/providers/ternSecureClientProvider').then(mod => mod.TernSecureClientProvider),\r\n { \r\n //ssr: false,\r\n loading: LoadingProvider // Return null or a loading indicator\r\n }\r\n)\r\n\r\nexport function TernSecureProvider({ children }: TernSecureProviderProps) {\r\n // Check if the children contain html/body tags\r\n const isRootLayout = React.Children.toArray(children).some(\r\n child => React.isValidElement(child) && child.type === 'html'\r\n );\r\n\r\n if (isRootLayout) {\r\n // If this is the root layout, inject our provider after the body tag\r\n return React.Children.map(children, child => {\r\n if (React.isValidElement(child) && child.type === 'html') {\r\n return React.cloneElement(child, {}, \r\n React.Children.map(child.props.children, bodyChild => {\r\n if (React.isValidElement(bodyChild) && bodyChild.type === 'body') {\r\n // Type assertion to access props safely\r\n const bodyProps = bodyChild.props as { children: ReactNode };\r\n return React.cloneElement(bodyChild, {}, \r\n <TernSecureClientProvider>\r\n {bodyProps.children}\r\n </TernSecureClientProvider>\r\n );\r\n }\r\n return bodyChild;\r\n })\r\n );\r\n }\r\n return child;\r\n });\r\n }\r\n\r\n // For non-root layouts, wrap normally\r\n return <TernSecureClientProvider>{children}</TernSecureClientProvider>;\r\n}"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAEA,cAcM,sBAMA;AAtBN;AAAA;AAAA;AAAA;AAEA,mBAA0C;AAc1C,IAAM,uBAAuB,OAAO,qBAAqB;AAMzD,IAAM,wBAAoB,4BAA4C,IAAI;AAAA;AAAA;;;ACtB1E;AAAA;AAAA;AAAA;AA4BO,SAAS,yBAAyB,EAAE,SAAS,GAA+C;AAEjG,QAAM,eAAe,cAAAA,QAAM;AAAA,IACzB,OAAO,EAAE,aAAa,qBAAqB;AAAA,IAC3C,CAAC;AAAA,EACH;AAEA,SACE,4CAAC,kBAAkB,UAAlB,EAA2B,OAAO,cAChC,UACH;AAEJ;AAxCA,IAEAC,eAkCI;AApCJ;AAAA;AAAA;AAAA;AAEA,IAAAA,gBAAkB;AAClB;AAiCI;AAOJ,6BAAyB,cAAc;AAAA;AAAA;;;AC3CvC;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAC,gBAAiC;AACjC,qBAAoB;AAQlB,IAAAC,sBAAA;AADF,IAAM,kBAAkB,MACtB;AAAA,EAAC;AAAA;AAAA,IACC,cAAW;AAAA,IACX,MAAK;AAAA,IACL,OAAO,EAAE,SAAS,OAAO;AAAA;AAC3B;AAIF,IAAMC,gCAA2B,eAAAC;AAAA,EAC/B,MAAM,kGAA0D,KAAK,SAAO,IAAI,wBAAwB;AAAA,EACxG;AAAA;AAAA,IAEE,SAAS;AAAA;AAAA,EACX;AACF;AAEO,SAAS,mBAAmB,EAAE,SAAS,GAA4B;AAExE,QAAM,eAAe,cAAAC,QAAM,SAAS,QAAQ,QAAQ,EAAE;AAAA,IACpD,WAAS,cAAAA,QAAM,eAAe,KAAK,KAAK,MAAM,SAAS;AAAA,EACzD;AAEA,MAAI,cAAc;AAEhB,WAAO,cAAAA,QAAM,SAAS,IAAI,UAAU,WAAS;AAC3C,UAAI,cAAAA,QAAM,eAAe,KAAK,KAAK,MAAM,SAAS,QAAQ;AACxD,eAAO,cAAAA,QAAM;AAAA,UAAa;AAAA,UAAO,CAAC;AAAA,UAChC,cAAAA,QAAM,SAAS,IAAI,MAAM,MAAM,UAAU,eAAa;AACpD,gBAAI,cAAAA,QAAM,eAAe,SAAS,KAAK,UAAU,SAAS,QAAQ;AAEhE,oBAAM,YAAY,UAAU;AAC5B,qBAAO,cAAAA,QAAM;AAAA,gBAAa;AAAA,gBAAW,CAAC;AAAA,gBACpC,6CAACF,2BAAA,EACE,oBAAU,UACb;AAAA,cACF;AAAA,YACF;AACA,mBAAO;AAAA,UACT,CAAC;AAAA,QACH;AAAA,MACF;AACA,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AAGA,SAAO,6CAACA,2BAAA,EAA0B,UAAS;AAC7C;",
|
|
6
|
-
"names": ["React", "import_react", "import_react", "import_jsx_runtime", "TernSecureClientProvider", "dynamic", "React"]
|
|
7
|
-
}
|
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/components/index.ts
|
|
21
|
-
var components_exports = {};
|
|
22
|
-
__export(components_exports, {
|
|
23
|
-
SignIn: () => SignIn
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(components_exports);
|
|
26
|
-
|
|
27
|
-
// src/components/sign-in.tsx
|
|
28
|
-
var import_react = require("react");
|
|
29
|
-
|
|
30
|
-
// src/app-router/client/client-init.ts
|
|
31
|
-
var import_app = require("firebase/app");
|
|
32
|
-
var import_auth = require("firebase/auth");
|
|
33
|
-
var import_firestore = require("firebase/firestore");
|
|
34
|
-
var import_storage = require("firebase/storage");
|
|
35
|
-
|
|
36
|
-
// src/app-router/client/config.ts
|
|
37
|
-
var loadFireConfig = () => ({
|
|
38
|
-
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
|
|
39
|
-
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
|
|
40
|
-
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
|
|
41
|
-
storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
|
|
42
|
-
messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
|
|
43
|
-
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
|
|
44
|
-
measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
|
|
45
|
-
});
|
|
46
|
-
var validateConfig = (config2) => {
|
|
47
|
-
Object.entries(config2).forEach(([key, value]) => {
|
|
48
|
-
if (!value) {
|
|
49
|
-
throw new Error(`Missing environment variable: NEXT_PUBLIC_FIREBASE_${key.toUpperCase()}`);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
return config2;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
// src/app-router/client/client-init.ts
|
|
56
|
-
var config = validateConfig(loadFireConfig());
|
|
57
|
-
var clientApp = (0, import_app.initializeApp)(config);
|
|
58
|
-
var auth = (0, import_auth.getAuth)(clientApp);
|
|
59
|
-
(0, import_auth.setPersistence)(auth, import_auth.browserSessionPersistence);
|
|
60
|
-
var firestore = (0, import_firestore.getFirestore)(clientApp);
|
|
61
|
-
var storage = (0, import_storage.getStorage)(clientApp);
|
|
62
|
-
var TernSecureAuth = () => auth;
|
|
63
|
-
|
|
64
|
-
// src/app-router/client/auth.ts
|
|
65
|
-
var import_auth2 = require("firebase/auth");
|
|
66
|
-
async function signInWithEmail({
|
|
67
|
-
email,
|
|
68
|
-
password
|
|
69
|
-
}) {
|
|
70
|
-
const auth2 = TernSecureAuth();
|
|
71
|
-
return (0, import_auth2.signInWithEmailAndPassword)(auth2, email, password);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// src/utils/create-styles.ts
|
|
75
|
-
var PREFIX = "tern";
|
|
76
|
-
var styleInjection = {
|
|
77
|
-
isInjected: false,
|
|
78
|
-
styleElement: null
|
|
79
|
-
};
|
|
80
|
-
var defaultClassNames = {
|
|
81
|
-
container: `${PREFIX}-container`,
|
|
82
|
-
header: `${PREFIX}-header`,
|
|
83
|
-
title: `${PREFIX}-title`,
|
|
84
|
-
formWrapper: `${PREFIX}-formWrapper`,
|
|
85
|
-
formContainer: `${PREFIX}-formContainer`,
|
|
86
|
-
form: `${PREFIX}-form`,
|
|
87
|
-
label: `${PREFIX}-label`,
|
|
88
|
-
input: `${PREFIX}-input`,
|
|
89
|
-
button: `${PREFIX}-button`,
|
|
90
|
-
error: `${PREFIX}-error`
|
|
91
|
-
};
|
|
92
|
-
function createStyleSheet(styles2) {
|
|
93
|
-
if (typeof window === "undefined") return defaultClassNames;
|
|
94
|
-
if (styleInjection.isInjected) {
|
|
95
|
-
return defaultClassNames;
|
|
96
|
-
}
|
|
97
|
-
let styleElement = document.querySelector("[data-tern-secure]");
|
|
98
|
-
if (!styleElement) {
|
|
99
|
-
styleElement = document.createElement("style");
|
|
100
|
-
styleElement.setAttribute("data-tern-secure", "");
|
|
101
|
-
document.head.appendChild(styleElement);
|
|
102
|
-
styleInjection.styleElement = styleElement;
|
|
103
|
-
}
|
|
104
|
-
const cssRules = Object.entries(styles2).map(([key, rules]) => {
|
|
105
|
-
const className = defaultClassNames[key];
|
|
106
|
-
const cssProperties = Object.entries(rules).map(([prop, value]) => {
|
|
107
|
-
const cssProperty = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
108
|
-
return `${cssProperty}: ${value};`;
|
|
109
|
-
}).join(" ");
|
|
110
|
-
return `.${className} { ${cssProperties} }`;
|
|
111
|
-
}).join("\n");
|
|
112
|
-
styleElement.textContent = cssRules;
|
|
113
|
-
styleInjection.isInjected = true;
|
|
114
|
-
return defaultClassNames;
|
|
115
|
-
}
|
|
116
|
-
var styleConfig = {
|
|
117
|
-
container: {
|
|
118
|
-
display: "flex",
|
|
119
|
-
minHeight: "100%",
|
|
120
|
-
flex: "1",
|
|
121
|
-
flexDirection: "column",
|
|
122
|
-
justifyContent: "center",
|
|
123
|
-
padding: "3rem 1.5rem"
|
|
124
|
-
},
|
|
125
|
-
header: {
|
|
126
|
-
margin: "0 auto",
|
|
127
|
-
width: "100%",
|
|
128
|
-
maxWidth: "28rem"
|
|
129
|
-
},
|
|
130
|
-
title: {
|
|
131
|
-
marginTop: "1.5rem",
|
|
132
|
-
textAlign: "center",
|
|
133
|
-
fontSize: "1.875rem",
|
|
134
|
-
fontWeight: "700",
|
|
135
|
-
lineHeight: "2.25rem",
|
|
136
|
-
letterSpacing: "-0.025em",
|
|
137
|
-
color: "var(--tern-text-primary, #111827)"
|
|
138
|
-
},
|
|
139
|
-
formWrapper: {
|
|
140
|
-
marginTop: "2.5rem",
|
|
141
|
-
margin: "0 auto",
|
|
142
|
-
width: "100%",
|
|
143
|
-
maxWidth: "30rem"
|
|
144
|
-
},
|
|
145
|
-
formContainer: {
|
|
146
|
-
padding: "3rem 1.5rem",
|
|
147
|
-
boxShadow: "0 1px 3px 0 rgb(0 0 0 / 0.1)",
|
|
148
|
-
borderRadius: "0.5rem",
|
|
149
|
-
backgroundColor: "var(--tern-background, white)"
|
|
150
|
-
},
|
|
151
|
-
form: {
|
|
152
|
-
display: "flex",
|
|
153
|
-
flexDirection: "column",
|
|
154
|
-
gap: "1rem"
|
|
155
|
-
},
|
|
156
|
-
label: {
|
|
157
|
-
display: "block",
|
|
158
|
-
fontSize: "0.875rem",
|
|
159
|
-
fontWeight: "500",
|
|
160
|
-
color: "var(--tern-text-secondary, #374151)"
|
|
161
|
-
},
|
|
162
|
-
input: {
|
|
163
|
-
marginTop: "0.25rem",
|
|
164
|
-
display: "block",
|
|
165
|
-
width: "100%",
|
|
166
|
-
padding: "0.5rem 0.75rem",
|
|
167
|
-
borderRadius: "0.375rem",
|
|
168
|
-
border: "1px solid var(--tern-border, #D1D5DB)",
|
|
169
|
-
backgroundColor: "var(--tern-input-background, white)",
|
|
170
|
-
color: "var(--tern-text-primary, #111827)"
|
|
171
|
-
},
|
|
172
|
-
button: {
|
|
173
|
-
display: "flex",
|
|
174
|
-
width: "100%",
|
|
175
|
-
justifyContent: "center",
|
|
176
|
-
padding: "0.5rem 1rem",
|
|
177
|
-
fontSize: "0.875rem",
|
|
178
|
-
fontWeight: "500",
|
|
179
|
-
color: "white",
|
|
180
|
-
backgroundColor: "var(--tern-primary, #2563EB)",
|
|
181
|
-
border: "none",
|
|
182
|
-
borderRadius: "0.375rem",
|
|
183
|
-
cursor: "pointer"
|
|
184
|
-
},
|
|
185
|
-
error: {
|
|
186
|
-
color: "var(--tern-error, #DC2626)",
|
|
187
|
-
fontSize: "0.875rem"
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
var styles = createStyleSheet(styleConfig);
|
|
191
|
-
|
|
192
|
-
// src/components/sign-in.tsx
|
|
193
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
194
|
-
function SignIn({
|
|
195
|
-
onSuccess,
|
|
196
|
-
onError,
|
|
197
|
-
redirectUrl,
|
|
198
|
-
className = "",
|
|
199
|
-
style,
|
|
200
|
-
customStyles = {}
|
|
201
|
-
}) {
|
|
202
|
-
const [email, setEmail] = (0, import_react.useState)("");
|
|
203
|
-
const [password, setPassword] = (0, import_react.useState)("");
|
|
204
|
-
const [loading, setLoading] = (0, import_react.useState)(false);
|
|
205
|
-
const [error, setError] = (0, import_react.useState)("");
|
|
206
|
-
const handleSubmit = async (e) => {
|
|
207
|
-
e.preventDefault();
|
|
208
|
-
setLoading(true);
|
|
209
|
-
setError("");
|
|
210
|
-
try {
|
|
211
|
-
await signInWithEmail({ email, password });
|
|
212
|
-
onSuccess?.();
|
|
213
|
-
if (redirectUrl) {
|
|
214
|
-
window.location.href = redirectUrl;
|
|
215
|
-
}
|
|
216
|
-
} catch (err) {
|
|
217
|
-
const errorMessage = err instanceof Error ? err.message : "Failed to sign in";
|
|
218
|
-
setError(errorMessage);
|
|
219
|
-
onError?.(err instanceof Error ? err : new Error("Failed to sign in"));
|
|
220
|
-
} finally {
|
|
221
|
-
setLoading(false);
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: `${styles.container} ${customStyles.container || ""}`, style, children: [
|
|
225
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `${styles.header} ${customStyles.header || ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: `${styles.title} ${customStyles.title || ""}`, children: "Sign in to your account" }) }),
|
|
226
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `${styles.formWrapper} ${customStyles.formWrapper || ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: `${styles.formContainer} ${customStyles.formContainer || ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
227
|
-
"form",
|
|
228
|
-
{
|
|
229
|
-
onSubmit: handleSubmit,
|
|
230
|
-
className: `${styles.form} ${customStyles.form || ""} ${className}`,
|
|
231
|
-
role: "form",
|
|
232
|
-
"aria-label": "Sign in form",
|
|
233
|
-
children: [
|
|
234
|
-
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
235
|
-
"div",
|
|
236
|
-
{
|
|
237
|
-
className: `${styles.error} ${customStyles.errorText || ""}`,
|
|
238
|
-
role: "alert",
|
|
239
|
-
"aria-live": "polite",
|
|
240
|
-
children: error
|
|
241
|
-
}
|
|
242
|
-
),
|
|
243
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
244
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: "email", className: `${styles.label} ${customStyles.label || ""}`, children: "Email" }),
|
|
245
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
246
|
-
"input",
|
|
247
|
-
{
|
|
248
|
-
id: "email",
|
|
249
|
-
type: "email",
|
|
250
|
-
value: email,
|
|
251
|
-
onChange: (e) => setEmail(e.target.value),
|
|
252
|
-
placeholder: "Enter your email",
|
|
253
|
-
required: true,
|
|
254
|
-
className: `${styles.input} ${customStyles.input || ""}`,
|
|
255
|
-
disabled: loading,
|
|
256
|
-
"aria-required": "true",
|
|
257
|
-
"aria-invalid": !!error
|
|
258
|
-
}
|
|
259
|
-
)
|
|
260
|
-
] }),
|
|
261
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
262
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: "password", className: `${styles.label} ${customStyles.label || ""}`, children: "Password" }),
|
|
263
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
264
|
-
"input",
|
|
265
|
-
{
|
|
266
|
-
id: "password",
|
|
267
|
-
type: "password",
|
|
268
|
-
value: password,
|
|
269
|
-
onChange: (e) => setPassword(e.target.value),
|
|
270
|
-
placeholder: "Enter your password",
|
|
271
|
-
required: true,
|
|
272
|
-
className: `${styles.input} ${customStyles.input || ""}`,
|
|
273
|
-
disabled: loading,
|
|
274
|
-
"aria-required": "true",
|
|
275
|
-
"aria-invalid": !!error
|
|
276
|
-
}
|
|
277
|
-
)
|
|
278
|
-
] }),
|
|
279
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
280
|
-
"button",
|
|
281
|
-
{
|
|
282
|
-
type: "submit",
|
|
283
|
-
disabled: loading,
|
|
284
|
-
className: `${styles.button} ${customStyles.button || ""}`,
|
|
285
|
-
"data-testid": "sign-in-submit",
|
|
286
|
-
children: loading ? "Signing in..." : "Sign in"
|
|
287
|
-
}
|
|
288
|
-
)
|
|
289
|
-
]
|
|
290
|
-
}
|
|
291
|
-
) }) })
|
|
292
|
-
] });
|
|
293
|
-
}
|
|
294
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
295
|
-
0 && (module.exports = {
|
|
296
|
-
SignIn
|
|
297
|
-
});
|
|
298
|
-
//# sourceMappingURL=index.js.map
|