@tern-secure/nextjs 3.1.31 → 3.1.32
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/client-init.js +70 -0
- package/dist/cjs/app-router/client/client-init.js.map +7 -0
- package/dist/cjs/app-router/client/config.js +49 -0
- package/dist/cjs/app-router/client/config.js.map +7 -0
- package/dist/cjs/app-router/client/index.js +144 -0
- package/dist/cjs/app-router/client/index.js.map +7 -0
- package/dist/cjs/app-router/server/index.js +142 -0
- package/dist/cjs/app-router/server/index.js.map +7 -0
- package/dist/{esm/index.cjs → cjs/components/index.js} +85 -149
- package/dist/cjs/components/index.js.map +7 -0
- package/dist/cjs/index.js +148 -59
- package/dist/cjs/index.js.map +7 -1
- package/dist/esm/app-router/client/auth.d.ts +7 -0
- package/dist/esm/app-router/client/auth.d.ts.map +1 -0
- package/dist/esm/app-router/client/client-init.d.ts +4 -0
- package/dist/esm/app-router/client/client-init.d.ts.map +1 -0
- package/dist/esm/app-router/client/client-init.js +12 -0
- package/dist/esm/app-router/client/client-init.js.map +7 -0
- package/dist/esm/app-router/client/config.d.ts +4 -0
- package/dist/esm/app-router/client/config.d.ts.map +1 -0
- package/dist/esm/app-router/client/config.js +9 -0
- package/dist/esm/app-router/client/config.js.map +7 -0
- package/dist/esm/app-router/client/index.d.ts +7 -0
- package/dist/esm/app-router/client/index.d.ts.map +1 -0
- package/dist/esm/app-router/client/index.js +30 -0
- package/dist/esm/app-router/client/index.js.map +7 -0
- package/dist/esm/app-router/client/providers/ternSecureClientProvider.d.ts +5 -0
- package/dist/esm/app-router/client/providers/ternSecureClientProvider.d.ts.map +1 -0
- package/dist/esm/app-router/client/providers/ternSecureContext.d.ts +7 -0
- package/dist/esm/app-router/client/providers/ternSecureContext.d.ts.map +1 -0
- package/dist/esm/app-router/server/index.d.ts +2 -0
- package/dist/esm/app-router/server/index.d.ts.map +1 -0
- package/dist/esm/app-router/server/index.js +7 -0
- package/dist/esm/app-router/server/index.js.map +7 -0
- package/dist/esm/app-router/server/providers/TernSecureServerProvider.d.ts +7 -0
- package/dist/esm/app-router/server/providers/TernSecureServerProvider.d.ts.map +1 -0
- package/dist/esm/chunk-5DISHXED.js +24 -0
- package/dist/esm/chunk-5DISHXED.js.map +7 -0
- package/dist/esm/chunk-CGWE73OH.js +18 -0
- package/dist/esm/chunk-CGWE73OH.js.map +7 -0
- package/dist/esm/chunk-HXT5FXLI.js +44 -0
- package/dist/esm/chunk-HXT5FXLI.js.map +7 -0
- package/dist/esm/chunk-RHUIR5LX.js +28 -0
- package/dist/esm/chunk-RHUIR5LX.js.map +7 -0
- package/dist/esm/chunk-XPP2LEPF.js +232 -0
- package/dist/esm/chunk-XPP2LEPF.js.map +7 -0
- package/dist/esm/chunk-ZOPSCDBD.js +57 -0
- package/dist/esm/chunk-ZOPSCDBD.js.map +7 -0
- package/dist/esm/components/index.d.ts +2 -0
- package/dist/esm/components/index.d.ts.map +1 -0
- package/dist/esm/components/index.js +11 -0
- package/dist/esm/components/index.js.map +7 -0
- package/dist/esm/components/sign-in.d.ts +22 -0
- package/dist/esm/components/sign-in.d.ts.map +1 -0
- package/dist/esm/errors/index.d.ts +9 -0
- package/dist/esm/errors/index.d.ts.map +1 -0
- package/dist/esm/hooks/index.d.ts +2 -0
- package/dist/esm/hooks/index.d.ts.map +1 -0
- package/dist/esm/hooks/useAuth.d.ts +2 -0
- package/dist/esm/hooks/useAuth.d.ts.map +1 -0
- package/dist/esm/index.d.ts +5 -81
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +40 -306
- package/dist/esm/index.js.map +7 -1
- package/dist/esm/ternSecureClientProvider-JVILZFAW.js +8 -0
- package/dist/esm/ternSecureClientProvider-JVILZFAW.js.map +7 -0
- package/dist/esm/types/index.d.ts +41 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/esm/utils/create-styles.d.ts +99 -0
- package/dist/esm/utils/create-styles.d.ts.map +1 -0
- package/package.json +15 -8
- package/dist/cjs/index.cjs +0 -434
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/index.d.cts +0 -81
- package/dist/cjs/index.d.ts +0 -81
- package/dist/esm/chunk-IPJTMTN4.cjs +0 -44
- package/dist/esm/chunk-IPJTMTN4.cjs.map +0 -1
- package/dist/esm/chunk-KIR6XUJX.js +0 -36
- package/dist/esm/chunk-KIR6XUJX.js.map +0 -1
- package/dist/esm/index.cjs.map +0 -1
- package/dist/esm/index.d.cts +0 -81
- package/dist/esm/ternSecureClientProvider-FOKWIA4L.cjs +0 -12
- package/dist/esm/ternSecureClientProvider-FOKWIA4L.cjs.map +0 -1
- package/dist/esm/ternSecureClientProvider-WBLGPYYR.js +0 -3
- package/dist/esm/ternSecureClientProvider-WBLGPYYR.js.map +0 -1
|
@@ -1,20 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
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);
|
|
11
19
|
|
|
12
|
-
|
|
20
|
+
// src/components/index.ts
|
|
21
|
+
var components_exports = {};
|
|
22
|
+
__export(components_exports, {
|
|
23
|
+
SignIn: () => SignIn
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(components_exports);
|
|
13
26
|
|
|
14
|
-
|
|
15
|
-
var
|
|
27
|
+
// src/components/sign-in.tsx
|
|
28
|
+
var import_react3 = require("react");
|
|
16
29
|
|
|
17
|
-
|
|
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");
|
|
18
35
|
|
|
19
36
|
// src/app-router/client/config.ts
|
|
20
37
|
var loadFireConfig = () => ({
|
|
@@ -38,112 +55,47 @@ var validateConfig = (config) => {
|
|
|
38
55
|
// src/app-router/client/client-init.ts
|
|
39
56
|
var app = (() => {
|
|
40
57
|
const config = validateConfig(loadFireConfig());
|
|
41
|
-
return
|
|
58
|
+
return (0, import_app.getApps)().length ? (0, import_app.getApps)()[0] : (0, import_app.initializeApp)(config);
|
|
42
59
|
})();
|
|
43
|
-
var auth =
|
|
44
|
-
|
|
45
|
-
var firestore =
|
|
46
|
-
var storage =
|
|
60
|
+
var auth = (0, import_auth.getAuth)(app);
|
|
61
|
+
(0, import_auth.setPersistence)(auth, import_auth.browserSessionPersistence);
|
|
62
|
+
var firestore = (0, import_firestore.getFirestore)(app);
|
|
63
|
+
var storage = (0, import_storage.getStorage)(app);
|
|
47
64
|
var TernSecureAuth = () => auth;
|
|
48
|
-
|
|
49
|
-
|
|
65
|
+
|
|
66
|
+
// src/app-router/client/auth.ts
|
|
67
|
+
var import_auth2 = require("firebase/auth");
|
|
50
68
|
async function signInWithEmail({
|
|
51
69
|
email,
|
|
52
70
|
password
|
|
53
71
|
}) {
|
|
54
72
|
const auth2 = TernSecureAuth();
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
var TernSecureClientProvider2 = dynamic__default.default(
|
|
58
|
-
() => import('./ternSecureClientProvider-FOKWIA4L.cjs').then((mod) => mod.TernSecureClientProvider),
|
|
59
|
-
{
|
|
60
|
-
ssr: false
|
|
61
|
-
//loading: () => null // Return null or a loading indicator
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
function TernSecureProvider({ children }) {
|
|
65
|
-
const isRootLayout = React__default.default.Children.toArray(children).some(
|
|
66
|
-
(child) => React__default.default.isValidElement(child) && child.type === "html"
|
|
67
|
-
);
|
|
68
|
-
if (isRootLayout) {
|
|
69
|
-
return React__default.default.Children.map(children, (child) => {
|
|
70
|
-
if (React__default.default.isValidElement(child) && child.type === "html") {
|
|
71
|
-
return React__default.default.cloneElement(
|
|
72
|
-
child,
|
|
73
|
-
{},
|
|
74
|
-
React__default.default.Children.map(child.props.children, (bodyChild) => {
|
|
75
|
-
if (React__default.default.isValidElement(bodyChild) && bodyChild.type === "body") {
|
|
76
|
-
const bodyProps = bodyChild.props;
|
|
77
|
-
return React__default.default.cloneElement(
|
|
78
|
-
bodyChild,
|
|
79
|
-
{},
|
|
80
|
-
/* @__PURE__ */ jsxRuntime.jsx(TernSecureClientProvider2, { children: bodyProps.children })
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
return bodyChild;
|
|
84
|
-
})
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
return child;
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
return /* @__PURE__ */ jsxRuntime.jsx(TernSecureClientProvider2, { children });
|
|
73
|
+
return (0, import_auth2.signInWithEmailAndPassword)(auth2, email, password);
|
|
91
74
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
setState((prev) => ({
|
|
107
|
-
...prev,
|
|
108
|
-
auth: {
|
|
109
|
-
user,
|
|
110
|
-
loading: false,
|
|
111
|
-
error: null,
|
|
112
|
-
isSignedIn: !!user
|
|
113
|
-
}
|
|
114
|
-
}));
|
|
115
|
-
},
|
|
116
|
-
(error) => {
|
|
117
|
-
setState((prev) => ({
|
|
118
|
-
...prev,
|
|
119
|
-
auth: {
|
|
120
|
-
user: null,
|
|
121
|
-
loading: false,
|
|
122
|
-
error,
|
|
123
|
-
isSignedIn: false
|
|
124
|
-
}
|
|
125
|
-
}));
|
|
126
|
-
}
|
|
127
|
-
);
|
|
128
|
-
return () => unsubscribe();
|
|
129
|
-
} catch (error) {
|
|
130
|
-
setState((prev) => ({
|
|
131
|
-
...prev,
|
|
132
|
-
firebase: {
|
|
133
|
-
initialized: false,
|
|
134
|
-
error
|
|
135
|
-
},
|
|
136
|
-
auth: {
|
|
137
|
-
user: null,
|
|
138
|
-
loading: false,
|
|
139
|
-
error,
|
|
140
|
-
isSignedIn: false
|
|
141
|
-
}
|
|
142
|
-
}));
|
|
75
|
+
|
|
76
|
+
// src/app-router/client/providers/ternSecureContext.tsx
|
|
77
|
+
var import_react = require("react");
|
|
78
|
+
var createTernSecureContext = () => {
|
|
79
|
+
const initialState2 = {
|
|
80
|
+
firebase: {
|
|
81
|
+
initialized: false,
|
|
82
|
+
error: null
|
|
83
|
+
},
|
|
84
|
+
auth: {
|
|
85
|
+
user: null,
|
|
86
|
+
loading: true,
|
|
87
|
+
error: null,
|
|
88
|
+
isSignedIn: false
|
|
143
89
|
}
|
|
144
|
-
}
|
|
145
|
-
return
|
|
146
|
-
}
|
|
90
|
+
};
|
|
91
|
+
return (0, import_react.createContext)([initialState2, () => {
|
|
92
|
+
}]);
|
|
93
|
+
};
|
|
94
|
+
var TernSecureContext = createTernSecureContext();
|
|
95
|
+
|
|
96
|
+
// src/app-router/client/providers/ternSecureClientProvider.tsx
|
|
97
|
+
var import_react2 = require("react");
|
|
98
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
147
99
|
|
|
148
100
|
// src/utils/create-styles.ts
|
|
149
101
|
var PREFIX = "tern";
|
|
@@ -262,6 +214,9 @@ var styleConfig = {
|
|
|
262
214
|
}
|
|
263
215
|
};
|
|
264
216
|
var styles = createStyleSheet(styleConfig);
|
|
217
|
+
|
|
218
|
+
// src/components/sign-in.tsx
|
|
219
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
265
220
|
function SignIn({
|
|
266
221
|
onSuccess,
|
|
267
222
|
onError,
|
|
@@ -270,10 +225,10 @@ function SignIn({
|
|
|
270
225
|
style,
|
|
271
226
|
customStyles = {}
|
|
272
227
|
}) {
|
|
273
|
-
const [email, setEmail] =
|
|
274
|
-
const [password, setPassword] =
|
|
275
|
-
const [loading, setLoading] =
|
|
276
|
-
const [error, setError] =
|
|
228
|
+
const [email, setEmail] = (0, import_react3.useState)("");
|
|
229
|
+
const [password, setPassword] = (0, import_react3.useState)("");
|
|
230
|
+
const [loading, setLoading] = (0, import_react3.useState)(false);
|
|
231
|
+
const [error, setError] = (0, import_react3.useState)("");
|
|
277
232
|
const handleSubmit = async (e) => {
|
|
278
233
|
e.preventDefault();
|
|
279
234
|
setLoading(true);
|
|
@@ -292,9 +247,9 @@ function SignIn({
|
|
|
292
247
|
setLoading(false);
|
|
293
248
|
}
|
|
294
249
|
};
|
|
295
|
-
return /* @__PURE__ */
|
|
296
|
-
/* @__PURE__ */
|
|
297
|
-
/* @__PURE__ */
|
|
250
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `${styles.container} ${customStyles.container || ""}`, style, children: [
|
|
251
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: `${styles.header} ${customStyles.header || ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { className: `${styles.title} ${customStyles.title || ""}`, children: "Sign in to your account" }) }),
|
|
252
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: `${styles.formWrapper} ${customStyles.formWrapper || ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: `${styles.formContainer} ${customStyles.formContainer || ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
298
253
|
"form",
|
|
299
254
|
{
|
|
300
255
|
onSubmit: handleSubmit,
|
|
@@ -302,7 +257,7 @@ function SignIn({
|
|
|
302
257
|
role: "form",
|
|
303
258
|
"aria-label": "Sign in form",
|
|
304
259
|
children: [
|
|
305
|
-
error && /* @__PURE__ */
|
|
260
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
306
261
|
"div",
|
|
307
262
|
{
|
|
308
263
|
className: `${styles.error} ${customStyles.errorText || ""}`,
|
|
@@ -311,9 +266,9 @@ function SignIn({
|
|
|
311
266
|
children: error
|
|
312
267
|
}
|
|
313
268
|
),
|
|
314
|
-
/* @__PURE__ */
|
|
315
|
-
/* @__PURE__ */
|
|
316
|
-
/* @__PURE__ */
|
|
269
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
270
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { htmlFor: "email", className: `${styles.label} ${customStyles.label || ""}`, children: "Email" }),
|
|
271
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
317
272
|
"input",
|
|
318
273
|
{
|
|
319
274
|
id: "email",
|
|
@@ -329,9 +284,9 @@ function SignIn({
|
|
|
329
284
|
}
|
|
330
285
|
)
|
|
331
286
|
] }),
|
|
332
|
-
/* @__PURE__ */
|
|
333
|
-
/* @__PURE__ */
|
|
334
|
-
/* @__PURE__ */
|
|
287
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
288
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { htmlFor: "password", className: `${styles.label} ${customStyles.label || ""}`, children: "Password" }),
|
|
289
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
335
290
|
"input",
|
|
336
291
|
{
|
|
337
292
|
id: "password",
|
|
@@ -347,7 +302,7 @@ function SignIn({
|
|
|
347
302
|
}
|
|
348
303
|
)
|
|
349
304
|
] }),
|
|
350
|
-
/* @__PURE__ */
|
|
305
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
351
306
|
"button",
|
|
352
307
|
{
|
|
353
308
|
type: "submit",
|
|
@@ -362,27 +317,8 @@ function SignIn({
|
|
|
362
317
|
) }) })
|
|
363
318
|
] });
|
|
364
319
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
get: function () { return chunkIPJTMTN4_cjs.TernSecureClientProvider; }
|
|
369
|
-
});
|
|
370
|
-
Object.defineProperty(exports, "TernSecureContext", {
|
|
371
|
-
enumerable: true,
|
|
372
|
-
get: function () { return chunkIPJTMTN4_cjs.TernSecureContext; }
|
|
373
|
-
});
|
|
374
|
-
Object.defineProperty(exports, "useTernSecure", {
|
|
375
|
-
enumerable: true,
|
|
376
|
-
get: function () { return chunkIPJTMTN4_cjs.useTernSecure; }
|
|
320
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
321
|
+
0 && (module.exports = {
|
|
322
|
+
SignIn
|
|
377
323
|
});
|
|
378
|
-
|
|
379
|
-
exports.TernSecureAuth = TernSecureAuth;
|
|
380
|
-
exports.TernSecureFirestore = TernSecureFirestore;
|
|
381
|
-
exports.TernSecureProvider = TernSecureProvider;
|
|
382
|
-
exports.TernSecureStorage = TernSecureStorage;
|
|
383
|
-
exports.loadFireConfig = loadFireConfig;
|
|
384
|
-
exports.signInWithEmail = signInWithEmail;
|
|
385
|
-
exports.useAuth = useAuth;
|
|
386
|
-
exports.validateConfig = validateConfig;
|
|
387
|
-
//# sourceMappingURL=index.cjs.map
|
|
388
|
-
//# sourceMappingURL=index.cjs.map
|
|
324
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/index.ts", "../../../src/components/sign-in.tsx", "../../../src/app-router/client/client-init.ts", "../../../src/app-router/client/config.ts", "../../../src/app-router/client/auth.ts", "../../../src/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 React, { createContext, useContext } from 'react'\r\nimport { TernSecureState } from '../../../types'\r\n\r\nconst createTernSecureContext = () => {\r\n const initialState: TernSecureState = {\r\n firebase: {\r\n initialized: false,\r\n error: null\r\n },\r\n auth: {\r\n user: null,\r\n loading: true,\r\n error: null,\r\n isSignedIn: false\r\n }\r\n }\r\n \r\n return createContext<[TernSecureState, React.Dispatch<React.SetStateAction<TernSecureState>>]>([initialState, () => {}])\r\n}\r\n\r\n// Create context instance only when imported on client\r\nconst TernSecureContext = createTernSecureContext()\r\n\r\nconst useTernSecure = (hookname?: string) => {\r\n const context = useContext(TernSecureContext)\r\n if (!context) {\r\n throw new Error(\r\n `${hookname} must be used within TernSecureProvider`)\r\n }\r\n return context\r\n}\r\n\r\n// Export initial state for reuse\r\nexport const initialState: TernSecureState = {\r\n firebase: {\r\n initialized: false,\r\n error: null\r\n },\r\n auth: {\r\n user: null,\r\n loading: true,\r\n error: null,\r\n isSignedIn: false\r\n }\r\n}\r\n\r\nexport {\r\n TernSecureContext,\r\n useTernSecure\r\n}", "'use client'\r\n\r\nimport React, { useState } from 'react'\r\nimport { TernSecureContext, initialState } from './ternSecureContext'\r\n\r\nexport function TernSecureClientProvider({ children }: { children: React.ReactNode }) {\r\n const stateAndUpdater = useState(initialState)\r\n\r\n return (\r\n <TernSecureContext.Provider value={stateAndUpdater}>\r\n {children}\r\n </TernSecureContext.Provider>\r\n )\r\n}", "'use client'\r\n\r\nconst PREFIX = 'tern'\r\n\r\n// Singleton to track style injection\r\nconst styleInjection = {\r\n isInjected: false,\r\n styleElement: null as HTMLStyleElement | null\r\n}\r\n\r\nexport const defaultClassNames = {\r\n container: `${PREFIX}-container`,\r\n header: `${PREFIX}-header`,\r\n title: `${PREFIX}-title`,\r\n formWrapper: `${PREFIX}-formWrapper`,\r\n formContainer: `${PREFIX}-formContainer`,\r\n form: `${PREFIX}-form`,\r\n label: `${PREFIX}-label`,\r\n input: `${PREFIX}-input`,\r\n button: `${PREFIX}-button`,\r\n error: `${PREFIX}-error`\r\n} as const\r\n\r\n// Create styles once and cache them\r\nfunction createStyleSheet(styles: Record<string, React.CSSProperties>) {\r\n if (typeof window === 'undefined') return defaultClassNames\r\n\r\n // Return early if styles are already injected\r\n if (styleInjection.isInjected) {\r\n return defaultClassNames\r\n }\r\n\r\n // Find existing style element or create new one\r\n let styleElement = document.querySelector<HTMLStyleElement>('[data-tern-secure]')\r\n \r\n if (!styleElement) {\r\n styleElement = document.createElement('style')\r\n styleElement.setAttribute('data-tern-secure', '')\r\n document.head.appendChild(styleElement)\r\n styleInjection.styleElement = styleElement\r\n }\r\n\r\n // Create CSS rules\r\n const cssRules = Object.entries(styles).map(([key, rules]) => {\r\n const className = defaultClassNames[key as keyof typeof defaultClassNames]\r\n const cssProperties = Object.entries(rules).map(([prop, value]) => {\r\n const cssProperty = prop.replace(/([A-Z])/g, '-$1').toLowerCase()\r\n return `${cssProperty}: ${value};`\r\n }).join(' ')\r\n\r\n return `.${className} { ${cssProperties} }`\r\n }).join('\\n')\r\n\r\n // Insert styles only once\r\n styleElement.textContent = cssRules\r\n styleInjection.isInjected = true\r\n\r\n return defaultClassNames\r\n}\r\n\r\n// Style configuration\r\nexport const styleConfig = {\r\n container: {\r\n display: 'flex',\r\n minHeight: '100%',\r\n flex: '1',\r\n flexDirection: 'column',\r\n justifyContent: 'center',\r\n padding: '3rem 1.5rem'\r\n },\r\n header: {\r\n margin: '0 auto',\r\n width: '100%',\r\n maxWidth: '28rem'\r\n },\r\n title: {\r\n marginTop: '1.5rem',\r\n textAlign: 'center',\r\n fontSize: '1.875rem',\r\n fontWeight: '700',\r\n lineHeight: '2.25rem',\r\n letterSpacing: '-0.025em',\r\n color: 'var(--tern-text-primary, #111827)'\r\n },\r\n formWrapper: {\r\n marginTop: '2.5rem',\r\n margin: '0 auto',\r\n width: '100%',\r\n maxWidth: '30rem'\r\n },\r\n formContainer: {\r\n padding: '3rem 1.5rem',\r\n boxShadow: '0 1px 3px 0 rgb(0 0 0 / 0.1)',\r\n borderRadius: '0.5rem',\r\n backgroundColor: 'var(--tern-background, white)'\r\n },\r\n form: {\r\n display: 'flex',\r\n flexDirection: 'column',\r\n gap: '1rem'\r\n },\r\n label: {\r\n display: 'block',\r\n fontSize: '0.875rem',\r\n fontWeight: '500',\r\n color: 'var(--tern-text-secondary, #374151)'\r\n },\r\n input: {\r\n marginTop: '0.25rem',\r\n display: 'block',\r\n width: '100%',\r\n padding: '0.5rem 0.75rem',\r\n borderRadius: '0.375rem',\r\n border: '1px solid var(--tern-border, #D1D5DB)',\r\n backgroundColor: 'var(--tern-input-background, white)',\r\n color: 'var(--tern-text-primary, #111827)'\r\n },\r\n button: {\r\n display: 'flex',\r\n width: '100%',\r\n justifyContent: 'center',\r\n padding: '0.5rem 1rem',\r\n fontSize: '0.875rem',\r\n fontWeight: '500',\r\n color: 'white',\r\n backgroundColor: 'var(--tern-primary, #2563EB)',\r\n border: 'none',\r\n borderRadius: '0.375rem',\r\n cursor: 'pointer'\r\n },\r\n error: {\r\n color: 'var(--tern-error, #DC2626)',\r\n fontSize: '0.875rem'\r\n }\r\n} as const\r\n\r\n// Export pre-created styles\r\nexport const styles = createStyleSheet(styleConfig)\r\n\r\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,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,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