@tern-secure/nextjs 3.4.0 → 3.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/app-router/client/TernSecureProvider.js +33 -0
- package/dist/cjs/app-router/client/TernSecureProvider.js.map +1 -0
- package/dist/cjs/app-router/client/actions.js +180 -0
- package/dist/cjs/app-router/client/actions.js.map +1 -0
- package/dist/cjs/app-router/route-handler/internal-route.js +45 -0
- package/dist/cjs/app-router/route-handler/internal-route.js.map +1 -0
- package/dist/cjs/app-router/server/auth.js +71 -0
- package/dist/cjs/app-router/server/auth.js.map +1 -0
- package/dist/cjs/app-router/server/index.js +42 -0
- package/dist/cjs/app-router/server/index.js.map +1 -0
- package/dist/cjs/app-router/server/sessionTernSecure.js +159 -0
- package/dist/cjs/app-router/server/sessionTernSecure.js.map +1 -0
- package/dist/cjs/app-router/server/ternSecureMiddleware.js +50 -0
- package/dist/cjs/app-router/server/ternSecureMiddleware.js.map +1 -0
- package/dist/cjs/boundary/TernSecureClientProvider.js +107 -0
- package/dist/cjs/boundary/TernSecureClientProvider.js.map +1 -0
- package/dist/cjs/boundary/TernSecureCtx.js +49 -0
- package/dist/cjs/boundary/TernSecureCtx.js.map +1 -0
- package/dist/cjs/boundary/hooks/useAuth.js +51 -0
- package/dist/cjs/boundary/hooks/useAuth.js.map +1 -0
- package/dist/cjs/boundary/hooks/useSignUp.js +40 -0
- package/dist/cjs/boundary/hooks/useSignUp.js.map +1 -0
- package/dist/cjs/boundary/hooks/useUser.js +44 -0
- package/dist/cjs/boundary/hooks/useUser.js.map +1 -0
- package/dist/cjs/components/background.js +65 -0
- package/dist/cjs/components/background.js.map +1 -0
- package/dist/cjs/components/sign-in.js +242 -0
- package/dist/cjs/components/sign-in.js.map +1 -0
- package/dist/cjs/components/sign-out.js +69 -0
- package/dist/cjs/components/sign-out.js.map +1 -0
- package/dist/cjs/components/sign-up.js +327 -0
- package/dist/cjs/components/sign-up.js.map +1 -0
- package/dist/cjs/components/ui/alert.js +88 -0
- package/dist/cjs/components/ui/alert.js.map +1 -0
- package/dist/cjs/components/ui/button.js +84 -0
- package/dist/cjs/components/ui/button.js.map +1 -0
- package/dist/cjs/components/ui/card.js +101 -0
- package/dist/cjs/components/ui/card.js.map +1 -0
- package/dist/cjs/components/ui/input.js +58 -0
- package/dist/cjs/components/ui/input.js.map +1 -0
- package/dist/cjs/components/ui/label.js +55 -0
- package/dist/cjs/components/ui/label.js.map +1 -0
- package/dist/cjs/components/ui/separator.js +59 -0
- package/dist/cjs/components/ui/separator.js.map +1 -0
- package/dist/cjs/components/verify.js +195 -0
- package/dist/cjs/components/verify.js.map +1 -0
- package/dist/cjs/errors.js +41 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/index.js +59 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/lib/utils.d.js +17 -0
- package/dist/cjs/lib/utils.d.js.map +1 -0
- package/dist/cjs/lib/utils.js +33 -0
- package/dist/cjs/lib/utils.js.map +1 -0
- package/dist/cjs/types.js +17 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils/admin-init.js +57 -0
- package/dist/cjs/utils/admin-init.js.map +1 -0
- package/dist/cjs/utils/client-init.js +49 -0
- package/dist/cjs/utils/client-init.js.map +1 -0
- package/dist/cjs/utils/config.js +113 -0
- package/dist/cjs/utils/config.js.map +1 -0
- package/dist/cjs/utils/construct.js +63 -0
- package/dist/cjs/utils/construct.js.map +1 -0
- package/dist/cjs/utils/create-styles.js +149 -0
- package/dist/cjs/utils/create-styles.js.map +1 -0
- package/dist/esm/app-router/client/TernSecureProvider.js +9 -0
- package/dist/esm/app-router/client/TernSecureProvider.js.map +1 -0
- package/dist/esm/app-router/client/actions.js +151 -0
- package/dist/esm/app-router/client/actions.js.map +1 -0
- package/dist/esm/app-router/route-handler/internal-route.js +20 -0
- package/dist/esm/app-router/route-handler/internal-route.js.map +1 -0
- package/dist/esm/app-router/server/auth.js +47 -0
- package/dist/esm/app-router/server/auth.js.map +1 -0
- package/dist/esm/app-router/server/index.js +13 -0
- package/dist/esm/app-router/server/index.js.map +1 -0
- package/dist/esm/app-router/server/sessionTernSecure.js +129 -0
- package/dist/esm/app-router/server/sessionTernSecure.js.map +1 -0
- package/dist/esm/app-router/server/ternSecureMiddleware.js +26 -0
- package/dist/esm/app-router/server/ternSecureMiddleware.js.map +1 -0
- package/dist/esm/boundary/TernSecureClientProvider.js +83 -0
- package/dist/esm/boundary/TernSecureClientProvider.js.map +1 -0
- package/dist/esm/boundary/TernSecureCtx.js +23 -0
- package/dist/esm/boundary/TernSecureCtx.js.map +1 -0
- package/dist/esm/boundary/hooks/useAuth.js +27 -0
- package/dist/esm/boundary/hooks/useAuth.js.map +1 -0
- package/dist/esm/boundary/hooks/useSignUp.js +16 -0
- package/dist/esm/boundary/hooks/useSignUp.js.map +1 -0
- package/dist/esm/boundary/hooks/useUser.js +20 -0
- package/dist/esm/boundary/hooks/useUser.js.map +1 -0
- package/dist/esm/components/background.js +41 -0
- package/dist/esm/components/background.js.map +1 -0
- package/dist/esm/components/sign-in.js +218 -0
- package/dist/esm/components/sign-in.js.map +1 -0
- package/dist/esm/components/sign-out.js +45 -0
- package/dist/esm/components/sign-out.js.map +1 -0
- package/dist/esm/components/sign-up.js +293 -0
- package/dist/esm/components/sign-up.js.map +1 -0
- package/dist/esm/components/ui/alert.js +52 -0
- package/dist/esm/components/ui/alert.js.map +1 -0
- package/dist/esm/components/ui/button.js +49 -0
- package/dist/esm/components/ui/button.js.map +1 -0
- package/dist/esm/components/ui/card.js +62 -0
- package/dist/esm/components/ui/card.js.map +1 -0
- package/dist/esm/components/ui/input.js +24 -0
- package/dist/esm/components/ui/input.js.map +1 -0
- package/dist/esm/components/ui/label.js +21 -0
- package/dist/esm/components/ui/label.js.map +1 -0
- package/dist/esm/components/ui/separator.js +25 -0
- package/dist/esm/components/ui/separator.js.map +1 -0
- package/dist/esm/components/verify.js +161 -0
- package/dist/esm/components/verify.js.map +1 -0
- package/dist/esm/errors.js +16 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/index.js +24 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/utils.d.js +1 -0
- package/dist/esm/lib/utils.d.js.map +1 -0
- package/dist/esm/lib/utils.js +9 -0
- package/dist/esm/lib/utils.js.map +1 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils/admin-init.js +22 -0
- package/dist/esm/utils/admin-init.js.map +1 -0
- package/dist/esm/utils/client-init.js +22 -0
- package/dist/esm/utils/client-init.js.map +1 -0
- package/dist/esm/utils/config.js +84 -0
- package/dist/esm/utils/config.js.map +1 -0
- package/dist/esm/utils/construct.js +37 -0
- package/dist/esm/utils/construct.js.map +1 -0
- package/dist/esm/utils/create-styles.js +123 -0
- package/dist/esm/utils/create-styles.js.map +1 -0
- package/dist/types/app-router/client/TernSecureProvider.d.ts +26 -0
- package/dist/types/app-router/client/TernSecureProvider.d.ts.map +1 -0
- package/dist/types/app-router/client/actions.d.ts +49 -0
- package/dist/types/app-router/client/actions.d.ts.map +1 -0
- package/dist/types/app-router/route-handler/internal-route.d.ts +9 -0
- package/dist/types/app-router/route-handler/internal-route.d.ts.map +1 -0
- package/dist/types/app-router/server/auth.d.ts +7 -0
- package/dist/types/app-router/server/auth.d.ts.map +1 -0
- package/dist/types/app-router/server/index.d.ts +5 -0
- package/dist/types/app-router/server/index.d.ts.map +1 -0
- package/dist/types/app-router/server/sessionTernSecure.d.ts +37 -0
- package/dist/types/app-router/server/sessionTernSecure.d.ts.map +1 -0
- package/dist/types/app-router/server/ternSecureMiddleware.d.ts +7 -0
- package/dist/types/app-router/server/ternSecureMiddleware.d.ts.map +1 -0
- package/dist/types/boundary/TernSecureClientProvider.d.ts +11 -0
- package/dist/types/boundary/TernSecureClientProvider.d.ts.map +1 -0
- package/dist/types/boundary/TernSecureCtx.d.ts +17 -0
- package/dist/types/boundary/TernSecureCtx.d.ts.map +1 -0
- package/dist/types/boundary/hooks/useAuth.d.ts +11 -0
- package/dist/types/boundary/hooks/useAuth.d.ts.map +1 -0
- package/dist/types/boundary/hooks/useSignUp.d.ts +5 -0
- package/dist/types/boundary/hooks/useSignUp.d.ts.map +1 -0
- package/dist/types/boundary/hooks/useUser.d.ts +7 -0
- package/dist/types/boundary/hooks/useUser.d.ts.map +1 -0
- package/dist/types/components/background.d.ts +2 -0
- package/dist/types/components/background.d.ts.map +1 -0
- package/dist/types/components/sign-in.d.ts +18 -0
- package/dist/types/components/sign-in.d.ts.map +1 -0
- package/dist/types/components/sign-out.d.ts +10 -0
- package/dist/types/components/sign-out.d.ts.map +1 -0
- package/dist/types/components/sign-up.d.ts +7 -0
- package/dist/types/components/sign-up.d.ts.map +1 -0
- package/dist/types/components/ui/alert.d.ts +9 -0
- package/dist/types/components/ui/alert.d.ts.map +1 -0
- package/dist/types/components/ui/button.d.ts +12 -0
- package/dist/types/components/ui/button.d.ts.map +1 -0
- package/dist/types/components/ui/card.d.ts +9 -0
- package/dist/types/components/ui/card.d.ts.map +1 -0
- package/dist/types/components/ui/input.d.ts +4 -0
- package/dist/types/components/ui/input.d.ts.map +1 -0
- package/dist/types/components/ui/label.d.ts +6 -0
- package/dist/types/components/ui/label.d.ts.map +1 -0
- package/dist/types/components/ui/separator.d.ts +5 -0
- package/dist/types/components/ui/separator.d.ts.map +1 -0
- package/dist/types/components/verify.d.ts +2 -0
- package/dist/types/components/verify.d.ts.map +1 -0
- package/dist/types/errors.d.ts +9 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/lib/utils.d.ts +3 -0
- package/dist/types/lib/utils.d.ts.map +1 -0
- package/dist/types/types.d.ts +63 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/utils/admin-init.d.ts +4 -0
- package/dist/types/utils/admin-init.d.ts.map +1 -0
- package/dist/types/utils/client-init.d.ts +5 -0
- package/dist/types/utils/client-init.d.ts.map +1 -0
- package/dist/types/utils/config.d.ts +35 -0
- package/dist/types/utils/config.d.ts.map +1 -0
- package/dist/types/utils/construct.d.ts +22 -0
- package/dist/types/utils/construct.d.ts.map +1 -0
- package/dist/types/utils/create-styles.d.ts +99 -0
- package/dist/types/utils/create-styles.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var TernSecureClientProvider_exports = {};
|
|
21
|
+
__export(TernSecureClientProvider_exports, {
|
|
22
|
+
TernSecureClientProvider: () => TernSecureClientProvider
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(TernSecureClientProvider_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_client_init = require("../utils/client-init");
|
|
28
|
+
var import_auth = require("firebase/auth");
|
|
29
|
+
var import_TernSecureCtx = require("./TernSecureCtx");
|
|
30
|
+
var import_navigation = require("next/navigation");
|
|
31
|
+
function TernSecureClientProvider({
|
|
32
|
+
children,
|
|
33
|
+
loginPath = "/sign-in",
|
|
34
|
+
loadingComponent
|
|
35
|
+
}) {
|
|
36
|
+
const auth = (0, import_react.useMemo)(() => import_client_init.ternSecureAuth, []);
|
|
37
|
+
const router = (0, import_navigation.useRouter)();
|
|
38
|
+
const [authState, setAuthState] = (0, import_react.useState)(() => ({
|
|
39
|
+
userId: null,
|
|
40
|
+
isLoaded: false,
|
|
41
|
+
error: null,
|
|
42
|
+
isValid: false,
|
|
43
|
+
token: null,
|
|
44
|
+
email: null
|
|
45
|
+
}));
|
|
46
|
+
const handleSignOut = (0, import_react.useCallback)(async (error) => {
|
|
47
|
+
await auth.signOut();
|
|
48
|
+
setAuthState({
|
|
49
|
+
isLoaded: true,
|
|
50
|
+
userId: null,
|
|
51
|
+
error: error || null,
|
|
52
|
+
isValid: false,
|
|
53
|
+
token: null,
|
|
54
|
+
email: null
|
|
55
|
+
});
|
|
56
|
+
router.push(loginPath);
|
|
57
|
+
}, [auth, router, loginPath]);
|
|
58
|
+
const setEmail = (0, import_react.useCallback)((email) => {
|
|
59
|
+
setAuthState((prev) => ({
|
|
60
|
+
...prev,
|
|
61
|
+
email
|
|
62
|
+
}));
|
|
63
|
+
}, []);
|
|
64
|
+
(0, import_react.useEffect)(() => {
|
|
65
|
+
const unsubscribe = (0, import_auth.onAuthStateChanged)(auth, async (user) => {
|
|
66
|
+
if (user) {
|
|
67
|
+
setAuthState({
|
|
68
|
+
isLoaded: true,
|
|
69
|
+
userId: user.uid,
|
|
70
|
+
isValid: true,
|
|
71
|
+
token: user.getIdToken(),
|
|
72
|
+
error: null,
|
|
73
|
+
email: user.email
|
|
74
|
+
});
|
|
75
|
+
} else {
|
|
76
|
+
setAuthState({
|
|
77
|
+
isLoaded: true,
|
|
78
|
+
userId: null,
|
|
79
|
+
isValid: false,
|
|
80
|
+
token: null,
|
|
81
|
+
error: new Error("User is not authenticated"),
|
|
82
|
+
email: null
|
|
83
|
+
});
|
|
84
|
+
if (!window.location.pathname.includes("/sign-up")) {
|
|
85
|
+
router.push(loginPath);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}, (error) => {
|
|
89
|
+
handleSignOut(error instanceof Error ? error : new Error("Authentication error occurred"));
|
|
90
|
+
});
|
|
91
|
+
return () => unsubscribe();
|
|
92
|
+
}, [auth, handleSignOut, router, loginPath]);
|
|
93
|
+
const contextValue = (0, import_react.useMemo)(() => ({
|
|
94
|
+
...authState,
|
|
95
|
+
signOut: handleSignOut,
|
|
96
|
+
setEmail
|
|
97
|
+
}), [authState, auth, handleSignOut, setEmail]);
|
|
98
|
+
if (!authState.isLoaded) {
|
|
99
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TernSecureCtx.TernSecureCtx.Provider, { value: contextValue, children: loadingComponent || /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "aria-live": "polite", "aria-busy": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only", children: "Loading authentication state..." }) }) });
|
|
100
|
+
}
|
|
101
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TernSecureCtx.TernSecureCtx.Provider, { value: contextValue, children });
|
|
102
|
+
}
|
|
103
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
104
|
+
0 && (module.exports = {
|
|
105
|
+
TernSecureClientProvider
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=TernSecureClientProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/boundary/TernSecureClientProvider.tsx"],"sourcesContent":["\"use client\"\n\nimport React, { useState, useEffect, useMemo, useCallback } from 'react'\nimport { ternSecureAuth } from '../utils/client-init'\nimport { onAuthStateChanged, User } from \"firebase/auth\"\nimport { TernSecureCtx, TernSecureCtxValue, TernSecureState } from './TernSecureCtx'\nimport { useRouter } from 'next/navigation'\n\ninterface TernSecureClientProviderProps {\n children: React.ReactNode;\n onUserChanged?: (user: User | null) => Promise<void>;\n loginPath?: string;\n loadingComponent?: React.ReactNode;\n}\n\nexport function TernSecureClientProvider({ \n children, \n loginPath = '/sign-in',\n loadingComponent\n}: TernSecureClientProviderProps) {\n const auth = useMemo(() => ternSecureAuth, []);\n const router = useRouter();\n const [authState, setAuthState] = useState<TernSecureState>(() => ({\n userId: null,\n isLoaded: false,\n error: null,\n isValid: false,\n token: null,\n email: null\n }));\n\n const handleSignOut = useCallback(async (error?: Error) => {\n await auth.signOut();\n setAuthState({\n isLoaded: true,\n userId: null,\n error: error || null,\n isValid: false,\n token: null,\n email: null\n });\n router.push(loginPath);\n }, [auth, router, loginPath]);\n\n const setEmail = useCallback((email: string) => {\n setAuthState((prev) => ({\n ...prev,\n email,\n }))\n }, [])\n\nuseEffect(() => {\n const unsubscribe = onAuthStateChanged(auth, async (user: User | null) => {\n if (user) {\n setAuthState({\n isLoaded: true,\n userId: user.uid,\n isValid: true,\n token: user.getIdToken(),\n error: null,\n email: user.email,\n })\n } else {\n setAuthState({\n isLoaded: true,\n userId: null,\n isValid: false,\n token: null,\n error: new Error('User is not authenticated'),\n email: null\n })\n if (!window.location.pathname.includes(\"/sign-up\")) {\n router.push(loginPath)\n }\n }\n }, (error) => {\n handleSignOut(error instanceof Error ? error : new Error('Authentication error occurred'));\n })\n \n return () => unsubscribe()\n }, [auth, handleSignOut, router, loginPath])\n\n const contextValue: TernSecureCtxValue = useMemo(() => ({\n ...authState,\n signOut: handleSignOut,\n setEmail\n }), [authState, auth, handleSignOut, setEmail]);\n\n if (!authState.isLoaded) {\n return (\n <TernSecureCtx.Provider value={contextValue}>\n {loadingComponent || (\n <div aria-live=\"polite\" aria-busy=\"true\">\n <span className=\"sr-only\">Loading authentication state...</span>\n </div>\n )}\n </TernSecureCtx.Provider>\n );\n }\n\n return (\n <TernSecureCtx.Provider value={contextValue}>\n {children}\n </TernSecureCtx.Provider>\n )\n}"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6FY;AA3FZ,mBAAiE;AACjE,yBAA+B;AAC/B,kBAAyC;AACzC,2BAAmE;AACnE,wBAA0B;AASnB,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA,YAAY;AAAA,EACZ;AACF,GAAkC;AAChC,QAAM,WAAO,sBAAQ,MAAM,mCAAgB,CAAC,CAAC;AAC7C,QAAM,aAAS,6BAAU;AACzB,QAAM,CAAC,WAAW,YAAY,QAAI,uBAA0B,OAAO;AAAA,IACjE,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,OAAO;AAAA,IACP,SAAS;AAAA,IACT,OAAO;AAAA,IACP,OAAO;AAAA,EACT,EAAE;AAEF,QAAM,oBAAgB,0BAAY,OAAO,UAAkB;AACzD,UAAM,KAAK,QAAQ;AACnB,iBAAa;AAAA,MACX,UAAU;AAAA,MACV,QAAQ;AAAA,MACR,OAAO,SAAS;AAAA,MAChB,SAAS;AAAA,MACT,OAAO;AAAA,MACP,OAAO;AAAA,IACT,CAAC;AACD,WAAO,KAAK,SAAS;AAAA,EACvB,GAAG,CAAC,MAAM,QAAQ,SAAS,CAAC;AAE5B,QAAM,eAAW,0BAAY,CAAC,UAAkB;AAC9C,iBAAa,CAAC,UAAU;AAAA,MACtB,GAAG;AAAA,MACH;AAAA,IACF,EAAE;AAAA,EACJ,GAAG,CAAC,CAAC;AAEP,8BAAU,MAAM;AACZ,UAAM,kBAAc,gCAAmB,MAAM,OAAO,SAAsB;AACxE,UAAI,MAAM;AACR,qBAAa;AAAA,UACX,UAAU;AAAA,UACV,QAAQ,KAAK;AAAA,UACb,SAAS;AAAA,UACT,OAAO,KAAK,WAAW;AAAA,UACvB,OAAO;AAAA,UACP,OAAO,KAAK;AAAA,QACd,CAAC;AAAA,MACH,OAAO;AACL,qBAAa;AAAA,UACX,UAAU;AAAA,UACV,QAAQ;AAAA,UACR,SAAS;AAAA,UACT,OAAO;AAAA,UACP,OAAO,IAAI,MAAM,2BAA2B;AAAA,UAC5C,OAAO;AAAA,QACT,CAAC;AACD,YAAI,CAAC,OAAO,SAAS,SAAS,SAAS,UAAU,GAAG;AAClD,iBAAO,KAAK,SAAS;AAAA,QACvB;AAAA,MACF;AAAA,IACF,GAAG,CAAC,UAAU;AACZ,oBAAc,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,+BAA+B,CAAC;AAAA,IAC3F,CAAC;AAED,WAAO,MAAM,YAAY;AAAA,EAC3B,GAAG,CAAC,MAAM,eAAe,QAAQ,SAAS,CAAC;AAE3C,QAAM,mBAAmC,sBAAQ,OAAO;AAAA,IACtD,GAAG;AAAA,IACH,SAAS;AAAA,IACT;AAAA,EACF,IAAI,CAAC,WAAW,MAAM,eAAe,QAAQ,CAAC;AAE9C,MAAI,CAAC,UAAU,UAAU;AACvB,WACE,4CAAC,mCAAc,UAAd,EAAuB,OAAO,cAC5B,8BACC,4CAAC,SAAI,aAAU,UAAS,aAAU,QAChC,sDAAC,UAAK,WAAU,WAAU,6CAA+B,GAC3D,GAEJ;AAAA,EAEJ;AAEA,SACI,4CAAC,mCAAc,UAAd,EAAuB,OAAO,cAC7B,UACF;AAEN;","names":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var TernSecureCtx_exports = {};
|
|
21
|
+
__export(TernSecureCtx_exports, {
|
|
22
|
+
TernSecureCtx: () => TernSecureCtx,
|
|
23
|
+
TernSecureUser: () => TernSecureUser,
|
|
24
|
+
useTernSecure: () => useTernSecure
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(TernSecureCtx_exports);
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var import_client_init = require("../utils/client-init");
|
|
29
|
+
const TernSecureUser = () => {
|
|
30
|
+
return import_client_init.ternSecureAuth.currentUser;
|
|
31
|
+
};
|
|
32
|
+
const TernSecureCtx = (0, import_react.createContext)(null);
|
|
33
|
+
TernSecureCtx.displayName = "TernSecureCtx";
|
|
34
|
+
const useTernSecure = (hookName) => {
|
|
35
|
+
const context = (0, import_react.useContext)(TernSecureCtx);
|
|
36
|
+
if (!context) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
`${hookName} must be used within TernSecureProvider`
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
return context;
|
|
42
|
+
};
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
TernSecureCtx,
|
|
46
|
+
TernSecureUser,
|
|
47
|
+
useTernSecure
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=TernSecureCtx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/boundary/TernSecureCtx.tsx"],"sourcesContent":["\"use client\"\n\nimport { createContext, useContext } from 'react'\nimport { ternSecureAuth } from '../utils/client-init';\nimport { User } from 'firebase/auth';\n\nexport const TernSecureUser = (): User | null => {\n return ternSecureAuth.currentUser;\n}\n\nexport interface TernSecureState {\n userId: string | null\n isLoaded: boolean\n error: Error | null\n isValid: boolean\n token: any | null\n email: string | null\n}\n\nexport interface TernSecureCtxValue extends TernSecureState {\n signOut: () => Promise<void>\n setEmail: (email: string) => void\n}\n\nexport const TernSecureCtx = createContext<TernSecureCtxValue | null>(null)\n\nTernSecureCtx.displayName = 'TernSecureCtx'\n\nexport const useTernSecure = (hookName: string) => {\n const context = useContext(TernSecureCtx)\n \n if (!context) {\n throw new Error(\n `${hookName} must be used within TernSecureProvider`\n )\n }\n\n return context\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA0C;AAC1C,yBAA+B;AAGxB,MAAM,iBAAiB,MAAmB;AAC/C,SAAO,kCAAe;AACxB;AAgBO,MAAM,oBAAgB,4BAAyC,IAAI;AAE1E,cAAc,cAAc;AAErB,MAAM,gBAAgB,CAAC,aAAqB;AACjD,QAAM,cAAU,yBAAW,aAAa;AAExC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR,GAAG,QAAQ;AAAA,IACb;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var useAuth_exports = {};
|
|
21
|
+
__export(useAuth_exports, {
|
|
22
|
+
useAuth: () => useAuth
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useAuth_exports);
|
|
25
|
+
var import_TernSecureCtx = require("../TernSecureCtx");
|
|
26
|
+
var import_TernSecureCtx2 = require("../TernSecureCtx");
|
|
27
|
+
function useAuth() {
|
|
28
|
+
const {
|
|
29
|
+
userId,
|
|
30
|
+
isLoaded,
|
|
31
|
+
error,
|
|
32
|
+
isValid,
|
|
33
|
+
token,
|
|
34
|
+
signOut
|
|
35
|
+
} = (0, import_TernSecureCtx.useTernSecure)("useAuth");
|
|
36
|
+
const user = (0, import_TernSecureCtx2.TernSecureUser)();
|
|
37
|
+
return {
|
|
38
|
+
user,
|
|
39
|
+
userId,
|
|
40
|
+
isLoaded,
|
|
41
|
+
error,
|
|
42
|
+
isAuthenticated: isValid,
|
|
43
|
+
token,
|
|
44
|
+
signOut
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
useAuth
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=useAuth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/boundary/hooks/useAuth.ts"],"sourcesContent":["\"use client\"\n\nimport { useTernSecure } from '../TernSecureCtx'\nimport { User } from 'firebase/auth'\nimport { TernSecureUser } from '../TernSecureCtx'\n\nexport function useAuth() {\n const {\n userId,\n isLoaded,\n error,\n isValid,\n token,\n signOut\n } = useTernSecure('useAuth')\n\n const user: User | null = TernSecureUser()\n\n return {\n user,\n userId,\n isLoaded,\n error,\n isAuthenticated: isValid,\n token,\n signOut\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,2BAA8B;AAE9B,IAAAA,wBAA+B;AAExB,SAAS,UAAU;AACxB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,oCAAc,SAAS;AAE3B,QAAM,WAAoB,sCAAe;AAEzC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,EACF;AACF;","names":["import_TernSecureCtx"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var useSignUp_exports = {};
|
|
21
|
+
__export(useSignUp_exports, {
|
|
22
|
+
useSignUp: () => useSignUp
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useSignUp_exports);
|
|
25
|
+
var import_TernSecureCtx = require("../TernSecureCtx");
|
|
26
|
+
function useSignUp() {
|
|
27
|
+
const {
|
|
28
|
+
email,
|
|
29
|
+
setEmail
|
|
30
|
+
} = (0, import_TernSecureCtx.useTernSecure)("useSignUp");
|
|
31
|
+
return {
|
|
32
|
+
email,
|
|
33
|
+
setEmail
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
useSignUp
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=useSignUp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/boundary/hooks/useSignUp.ts"],"sourcesContent":["\"use client\"\n\nimport { useTernSecure } from '../TernSecureCtx'\n\nexport function useSignUp() {\n const {\n email,\n setEmail\n } = useTernSecure('useSignUp')\n\n return {\n email, \n setEmail\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,2BAA8B;AAEvB,SAAS,YAAY;AAC1B,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,EACF,QAAI,oCAAc,WAAW;AAE7B,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var useUser_exports = {};
|
|
21
|
+
__export(useUser_exports, {
|
|
22
|
+
useUser: () => useUser
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useUser_exports);
|
|
25
|
+
var import_auth = require("firebase/auth");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_client_init = require("../../utils/client-init");
|
|
28
|
+
function useUser() {
|
|
29
|
+
const [user, setUser] = (0, import_react.useState)(null);
|
|
30
|
+
const [loading, setLoading] = (0, import_react.useState)(true);
|
|
31
|
+
(0, import_react.useEffect)(() => {
|
|
32
|
+
const unsubscribe = (0, import_auth.onAuthStateChanged)(import_client_init.ternSecureAuth, (authUser) => {
|
|
33
|
+
setUser(authUser);
|
|
34
|
+
setLoading(false);
|
|
35
|
+
});
|
|
36
|
+
return () => unsubscribe();
|
|
37
|
+
}, []);
|
|
38
|
+
return { user, loading };
|
|
39
|
+
}
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
useUser
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=useUser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/boundary/hooks/useUser.ts"],"sourcesContent":["\"use client\";\n\nimport { onAuthStateChanged } from \"firebase/auth\";\nimport { useEffect, useState } from \"react\";\n\nimport { ternSecureAuth} from \"../../utils/client-init\";\n\ninterface UseUserReturn {\n user: any | null;\n loading: boolean;\n }\n\nexport function useUser(): UseUserReturn {\n const [user, setUser] = useState<any| null>(null);\n const [loading, setLoading] = useState(true);\n\n useEffect(() => {\n const unsubscribe = onAuthStateChanged(ternSecureAuth, (authUser) => {\n setUser(authUser);\n setLoading(false);\n });\n\n return () => unsubscribe();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return {user, loading};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAAmC;AACnC,mBAAoC;AAEpC,yBAA8B;AAOvB,SAAS,UAAyB;AACvC,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAoB,IAAI;AAChD,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,IAAI;AAE3C,8BAAU,MAAM;AACd,UAAM,kBAAc,gCAAmB,mCAAgB,CAAC,aAAa;AACnE,cAAQ,QAAQ;AAChB,iBAAW,KAAK;AAAA,IAClB,CAAC;AAED,WAAO,MAAM,YAAY;AAAA,EAE3B,GAAG,CAAC,CAAC;AAEL,SAAO,EAAC,MAAM,QAAO;AACvB;","names":[]}
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
var background_exports = {};
|
|
20
|
+
__export(background_exports, {
|
|
21
|
+
AuthBackground: () => AuthBackground
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(background_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
function AuthBackground() {
|
|
26
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
27
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
28
|
+
"div",
|
|
29
|
+
{
|
|
30
|
+
className: "absolute inset-x-0 -top-40 -z-10 transform-gpu overflow-hidden blur-3xl sm:-top-80",
|
|
31
|
+
"aria-hidden": "true",
|
|
32
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
33
|
+
"div",
|
|
34
|
+
{
|
|
35
|
+
className: "relative left-[calc(50%-11rem)] aspect-[1155/678] w-[36.125rem] -translate-x-1/2 rotate-[30deg] bg-gradient-to-tr from-[#ff80b5] to-[#9089fc] opacity-30 sm:left-[calc(50%-30rem)] sm:w-[72.1875rem]",
|
|
36
|
+
style: {
|
|
37
|
+
clipPath: "polygon(74.1% 44.1%, 100% 61.6%, 97.5% 26.9%, 85.5% 0.1%, 80.7% 2%, 72.5% 32.5%, 60.2% 62.4%, 52.4% 68.1%, 47.5% 58.3%, 45.2% 34.5%, 27.5% 76.7%, 0.1% 64.9%, 17.9% 100%, 27.6% 76.8%, 76.1% 97.7%, 74.1% 44.1%)"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
),
|
|
43
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
44
|
+
"div",
|
|
45
|
+
{
|
|
46
|
+
className: "absolute inset-x-0 top-[calc(100%-13rem)] -z-10 transform-gpu overflow-hidden blur-3xl sm:top-[calc(100%-30rem)]",
|
|
47
|
+
"aria-hidden": "true",
|
|
48
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
49
|
+
"div",
|
|
50
|
+
{
|
|
51
|
+
className: "relative left-[calc(50%+3rem)] aspect-[1155/678] w-[36.125rem] -translate-x-1/2 bg-gradient-to-tr from-[hsl(var(--secondary)_/_0.3)] to-[hsl(var(--primary)_/_0.3)] opacity-30 sm:left-[calc(50%+36rem)] sm:w-[72.1875rem]",
|
|
52
|
+
style: {
|
|
53
|
+
clipPath: "polygon(74.1% 44.1%, 100% 61.6%, 97.5% 26.9%, 85.5% 0.1%, 80.7% 2%, 72.5% 32.5%, 60.2% 62.4%, 52.4% 68.1%, 47.5% 58.3%, 45.2% 34.5%, 27.5% 76.7%, 0.1% 64.9%, 17.9% 100%, 27.6% 76.8%, 76.1% 97.7%, 74.1% 44.1%)"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
] });
|
|
60
|
+
}
|
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
+
0 && (module.exports = {
|
|
63
|
+
AuthBackground
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=background.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/background.tsx"],"sourcesContent":["export function AuthBackground() {\n return (\n <>\n {/* Primary gradient blob */}\n <div\n className=\"absolute inset-x-0 -top-40 -z-10 transform-gpu overflow-hidden blur-3xl sm:-top-80\"\n aria-hidden=\"true\"\n >\n <div\n className=\"relative left-[calc(50%-11rem)] aspect-[1155/678] w-[36.125rem] -translate-x-1/2 rotate-[30deg] bg-gradient-to-tr from-[#ff80b5] to-[#9089fc] opacity-30 sm:left-[calc(50%-30rem)] sm:w-[72.1875rem]\"\n style={{\n clipPath:\n 'polygon(74.1% 44.1%, 100% 61.6%, 97.5% 26.9%, 85.5% 0.1%, 80.7% 2%, 72.5% 32.5%, 60.2% 62.4%, 52.4% 68.1%, 47.5% 58.3%, 45.2% 34.5%, 27.5% 76.7%, 0.1% 64.9%, 17.9% 100%, 27.6% 76.8%, 76.1% 97.7%, 74.1% 44.1%)',\n }}\n />\n </div>\n \n {/* Secondary gradient blob */}\n <div\n className=\"absolute inset-x-0 top-[calc(100%-13rem)] -z-10 transform-gpu overflow-hidden blur-3xl sm:top-[calc(100%-30rem)]\"\n aria-hidden=\"true\"\n >\n <div\n className=\"relative left-[calc(50%+3rem)] aspect-[1155/678] w-[36.125rem] -translate-x-1/2 bg-gradient-to-tr from-[hsl(var(--secondary)_/_0.3)] to-[hsl(var(--primary)_/_0.3)] opacity-30 sm:left-[calc(50%+36rem)] sm:w-[72.1875rem]\"\n style={{\n clipPath:\n 'polygon(74.1% 44.1%, 100% 61.6%, 97.5% 26.9%, 85.5% 0.1%, 80.7% 2%, 72.5% 32.5%, 60.2% 62.4%, 52.4% 68.1%, 47.5% 58.3%, 45.2% 34.5%, 27.5% 76.7%, 0.1% 64.9%, 17.9% 100%, 27.6% 76.8%, 76.1% 97.7%, 74.1% 44.1%)',\n }}\n />\n </div>\n </>\n )\n }\n \n "],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEM;AAFC,SAAS,iBAAiB;AAC7B,SACE,4EAEE;AAAA;AAAA,MAAC;AAAA;AAAA,QACG,WAAU;AAAA,QACV,eAAY;AAAA,QAEZ;AAAA,UAAC;AAAA;AAAA,YACC,WAAU;AAAA,YACV,OAAO;AAAA,cACL,UACE;AAAA,YACJ;AAAA;AAAA,QACF;AAAA;AAAA,IACF;AAAA,IAGF;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACV,eAAY;AAAA,QAEZ;AAAA,UAAC;AAAA;AAAA,YACC,WAAU;AAAA,YACV,OAAO;AAAA,cACL,UACE;AAAA,YACJ;AAAA;AAAA,QACF;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var sign_in_exports = {};
|
|
21
|
+
__export(sign_in_exports, {
|
|
22
|
+
SignIn: () => SignIn
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(sign_in_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_navigation = require("next/navigation");
|
|
28
|
+
var import_actions = require("../app-router/client/actions");
|
|
29
|
+
var import_card = require("./ui/card");
|
|
30
|
+
var import_input = require("./ui/input");
|
|
31
|
+
var import_label = require("./ui/label");
|
|
32
|
+
var import_button = require("./ui/button");
|
|
33
|
+
var import_alert = require("./ui/alert");
|
|
34
|
+
var import_separator = require("./ui/separator");
|
|
35
|
+
var import_utils = require("../lib/utils");
|
|
36
|
+
var import_lucide_react = require("lucide-react");
|
|
37
|
+
var import_auth = require("firebase/auth");
|
|
38
|
+
var import_client_init = require("../utils/client-init");
|
|
39
|
+
var import_sessionTernSecure = require("../app-router/server/sessionTernSecure");
|
|
40
|
+
var import_background = require("./background");
|
|
41
|
+
var import_construct = require("../utils/construct");
|
|
42
|
+
const authDomain = process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN;
|
|
43
|
+
const appName = process.env.NEXT_PUBLIC_FIREBASE_APP_NAME || "TernSecure";
|
|
44
|
+
function SignIn({
|
|
45
|
+
redirectUrl,
|
|
46
|
+
onError,
|
|
47
|
+
onSuccess,
|
|
48
|
+
className,
|
|
49
|
+
customStyles = {}
|
|
50
|
+
}) {
|
|
51
|
+
const [loading, setLoading] = (0, import_react.useState)(false);
|
|
52
|
+
const [checkingRedirect, setCheckingRedirect] = (0, import_react.useState)(true);
|
|
53
|
+
const [error, setError] = (0, import_react.useState)("");
|
|
54
|
+
const [email, setEmail] = (0, import_react.useState)("");
|
|
55
|
+
const [password, setPassword] = (0, import_react.useState)("");
|
|
56
|
+
const searchParams = (0, import_navigation.useSearchParams)();
|
|
57
|
+
const isRedirectSignIn = searchParams.get("signInRedirect") === "true";
|
|
58
|
+
const handleRedirectResult = (0, import_react.useCallback)(async () => {
|
|
59
|
+
if (!isRedirectSignIn) return false;
|
|
60
|
+
setCheckingRedirect(true);
|
|
61
|
+
try {
|
|
62
|
+
console.log("Checking redirect result...");
|
|
63
|
+
console.log("Current hostname:", window.location.hostname);
|
|
64
|
+
console.log("Auth domain hostname:", authDomain);
|
|
65
|
+
const isOnAuth = authDomain && window.location.hostname === authDomain.replace(/https?:\/\//, "");
|
|
66
|
+
console.log("Is on AuthDomain:", isOnAuth);
|
|
67
|
+
const result = await (0, import_auth.getRedirectResult)(import_client_init.ternSecureAuth);
|
|
68
|
+
console.log("Redirect result:", result);
|
|
69
|
+
if (result) {
|
|
70
|
+
const idToken = await result.user.getIdToken();
|
|
71
|
+
const sessionResult = await (0, import_sessionTernSecure.createSessionCookie)(idToken);
|
|
72
|
+
if (!sessionResult.success) {
|
|
73
|
+
throw new Error("Failed to create session");
|
|
74
|
+
}
|
|
75
|
+
const storedRedirectUrl = sessionStorage.getItem("auth_return_url");
|
|
76
|
+
sessionStorage.removeItem("auth_redirect_url");
|
|
77
|
+
onSuccess == null ? void 0 : onSuccess();
|
|
78
|
+
window.location.href = storedRedirectUrl || (0, import_construct.getValidRedirectUrl)(redirectUrl, searchParams);
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
setCheckingRedirect(false);
|
|
82
|
+
} catch (err) {
|
|
83
|
+
console.error("Redirect result error:", err);
|
|
84
|
+
const errorMessage = err instanceof Error ? err.message : "Authentication failed";
|
|
85
|
+
setError(errorMessage);
|
|
86
|
+
onError == null ? void 0 : onError(err instanceof Error ? err : new Error(errorMessage));
|
|
87
|
+
sessionStorage.removeItem("auth_redirect_url");
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}, [isRedirectSignIn, redirectUrl, searchParams, onSuccess, onError]);
|
|
91
|
+
(0, import_react.useEffect)(() => {
|
|
92
|
+
if (isRedirectSignIn) {
|
|
93
|
+
handleRedirectResult();
|
|
94
|
+
}
|
|
95
|
+
;
|
|
96
|
+
}, [handleRedirectResult, isRedirectSignIn]);
|
|
97
|
+
const handleSubmit = async (e) => {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
setLoading(true);
|
|
100
|
+
try {
|
|
101
|
+
const user = await (0, import_actions.signInWithEmail)(email, password);
|
|
102
|
+
if (user.success) {
|
|
103
|
+
onSuccess == null ? void 0 : onSuccess();
|
|
104
|
+
window.location.href = (0, import_construct.getValidRedirectUrl)(redirectUrl, searchParams);
|
|
105
|
+
}
|
|
106
|
+
} catch (err) {
|
|
107
|
+
const errorMessage = err instanceof Error ? err.message : "Failed to sign in";
|
|
108
|
+
setError(errorMessage);
|
|
109
|
+
onError == null ? void 0 : onError(err instanceof Error ? err : new Error("Failed to sign in"));
|
|
110
|
+
} finally {
|
|
111
|
+
setLoading(false);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const handleSocialSignIn = async (provider) => {
|
|
115
|
+
setLoading(true);
|
|
116
|
+
try {
|
|
117
|
+
const validRedirectUrl = (0, import_construct.getValidRedirectUrl)(redirectUrl, searchParams);
|
|
118
|
+
sessionStorage.setItem("auth_redirect_url", validRedirectUrl);
|
|
119
|
+
const currentUrl = new URL(window.location.href);
|
|
120
|
+
currentUrl.searchParams.set("signInRedirect", "true");
|
|
121
|
+
window.history.replaceState({}, "", currentUrl.toString());
|
|
122
|
+
const result = provider === "google" ? await (0, import_actions.signInWithRedirectGoogle)() : await (0, import_actions.signInWithMicrosoft)();
|
|
123
|
+
if (!result.success) {
|
|
124
|
+
throw new Error(result.error);
|
|
125
|
+
}
|
|
126
|
+
} catch (err) {
|
|
127
|
+
const errorMessage = err instanceof Error ? err.message : `Failed to sign in with ${provider}`;
|
|
128
|
+
setError(errorMessage);
|
|
129
|
+
onError == null ? void 0 : onError(err instanceof Error ? err : new Error(`Failed to sign in with ${provider}`));
|
|
130
|
+
setLoading(false);
|
|
131
|
+
sessionStorage.removeItem("auth_redirect_url");
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
if (checkingRedirect && isRedirectSignIn) {
|
|
135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex min-h-screen items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-center space-y-4", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto" }) }) });
|
|
136
|
+
}
|
|
137
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "relative flex items-center justify-center", children: [
|
|
138
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_background.AuthBackground, {}),
|
|
139
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_card.Card, { className: (0, import_utils.cn)("w-full max-w-md mx-auto mt-8", className, customStyles.card), children: [
|
|
140
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_card.CardHeader, { className: "space-y-1 text-center", children: [
|
|
141
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_card.CardTitle, { className: (0, import_utils.cn)("font-bold", customStyles.title), children: [
|
|
142
|
+
"Sign in to ",
|
|
143
|
+
`${appName}`
|
|
144
|
+
] }),
|
|
145
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_card.CardDescription, { className: (0, import_utils.cn)("text-muted-foreground", customStyles.description), children: "Please sign in to continue" })
|
|
146
|
+
] }),
|
|
147
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_card.CardContent, { className: "space-y-4", children: [
|
|
148
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { onSubmit: handleSubmit, className: "space-y-4", children: [
|
|
149
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_alert.Alert, { variant: "destructive", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_alert.AlertDescription, { children: error }) }),
|
|
150
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-2", children: [
|
|
151
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_label.Label, { htmlFor: "email", className: (0, import_utils.cn)(customStyles.label), children: "Email" }),
|
|
152
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
153
|
+
import_input.Input,
|
|
154
|
+
{
|
|
155
|
+
id: "email",
|
|
156
|
+
type: "email",
|
|
157
|
+
placeholder: "m@example.com",
|
|
158
|
+
value: email,
|
|
159
|
+
onChange: (e) => setEmail(e.target.value),
|
|
160
|
+
disabled: loading,
|
|
161
|
+
className: (0, import_utils.cn)(customStyles.input),
|
|
162
|
+
required: true
|
|
163
|
+
}
|
|
164
|
+
)
|
|
165
|
+
] }),
|
|
166
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-2", children: [
|
|
167
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_label.Label, { htmlFor: "password", className: (0, import_utils.cn)(customStyles.label), children: "Password" }),
|
|
168
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
169
|
+
import_input.Input,
|
|
170
|
+
{
|
|
171
|
+
id: "password",
|
|
172
|
+
type: "password",
|
|
173
|
+
value: password,
|
|
174
|
+
onChange: (e) => setPassword(e.target.value),
|
|
175
|
+
disabled: loading,
|
|
176
|
+
className: (0, import_utils.cn)(customStyles.input),
|
|
177
|
+
required: true
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
] }),
|
|
181
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { type: "submit", disabled: loading, className: (0, import_utils.cn)("w-full", customStyles.button), children: loading ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
182
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
183
|
+
"Signing in..."
|
|
184
|
+
] }) : "Sign in" })
|
|
185
|
+
] }),
|
|
186
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "relative", children: [
|
|
187
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "absolute inset-0 flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_separator.Separator, { className: (0, import_utils.cn)(customStyles.separator) }) }),
|
|
188
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "relative flex justify-center text-xs uppercase", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "bg-background px-2 text-muted-foreground", children: "Or continue with" }) })
|
|
189
|
+
] }),
|
|
190
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
191
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
192
|
+
import_button.Button,
|
|
193
|
+
{
|
|
194
|
+
variant: "outline",
|
|
195
|
+
disabled: loading,
|
|
196
|
+
onClick: () => handleSocialSignIn("google"),
|
|
197
|
+
className: (0, import_utils.cn)("flex items-center justify-center", customStyles.socialButton),
|
|
198
|
+
children: [
|
|
199
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { className: "w-5 h-5 mr-2", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
200
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z", fill: "#4285F4" }),
|
|
201
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z", fill: "#34A853" }),
|
|
202
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z", fill: "#FBBC05" }),
|
|
203
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z", fill: "#EA4335" })
|
|
204
|
+
] }),
|
|
205
|
+
"Google"
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
),
|
|
209
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
210
|
+
import_button.Button,
|
|
211
|
+
{
|
|
212
|
+
variant: "outline",
|
|
213
|
+
disabled: loading,
|
|
214
|
+
onClick: () => handleSocialSignIn("microsoft"),
|
|
215
|
+
className: (0, import_utils.cn)("flex items-center justify-center", customStyles.socialButton),
|
|
216
|
+
children: [
|
|
217
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { className: "w-5 h-5 mr-2", viewBox: "0 0 23 23", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
218
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fill: "#f3f3f3", d: "M0 0h23v23H0z" }),
|
|
219
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fill: "#f35325", d: "M1 1h10v10H1z" }),
|
|
220
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fill: "#81bc06", d: "M12 1h10v10H12z" }),
|
|
221
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fill: "#05a6f0", d: "M1 12h10v10H1z" }),
|
|
222
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fill: "#ffba08", d: "M12 12h10v10H12z" })
|
|
223
|
+
] }),
|
|
224
|
+
"Microsoft"
|
|
225
|
+
]
|
|
226
|
+
}
|
|
227
|
+
)
|
|
228
|
+
] })
|
|
229
|
+
] }),
|
|
230
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_card.CardFooter, { className: "flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "text-sm text-muted-foreground", children: [
|
|
231
|
+
"Don't have an account?",
|
|
232
|
+
" ",
|
|
233
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: "/sign-up", className: "text-primary hover:underline", children: "Sign up" })
|
|
234
|
+
] }) })
|
|
235
|
+
] })
|
|
236
|
+
] });
|
|
237
|
+
}
|
|
238
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
239
|
+
0 && (module.exports = {
|
|
240
|
+
SignIn
|
|
241
|
+
});
|
|
242
|
+
//# sourceMappingURL=sign-in.js.map
|