@tern-secure/nextjs 3.3.3 → 3.4.0
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/README.md +33 -33
- package/dist/types/index.d.ts +1 -0
- package/package.json +79 -79
- package/dist/cjs/app-router/client/TernSecureProvider.js +0 -33
- package/dist/cjs/app-router/client/TernSecureProvider.js.map +0 -1
- package/dist/cjs/app-router/client/actions.js +0 -97
- package/dist/cjs/app-router/client/actions.js.map +0 -1
- package/dist/cjs/app-router/server/auth.js +0 -71
- package/dist/cjs/app-router/server/auth.js.map +0 -1
- package/dist/cjs/app-router/server/index.js +0 -42
- package/dist/cjs/app-router/server/index.js.map +0 -1
- package/dist/cjs/app-router/server/sessionTernSecure.js +0 -159
- package/dist/cjs/app-router/server/sessionTernSecure.js.map +0 -1
- package/dist/cjs/app-router/server/ternSecureMiddleware.js +0 -50
- package/dist/cjs/app-router/server/ternSecureMiddleware.js.map +0 -1
- package/dist/cjs/boundary/TernSecureClientProvider.js +0 -94
- package/dist/cjs/boundary/TernSecureClientProvider.js.map +0 -1
- package/dist/cjs/boundary/TernSecureCtx.js +0 -49
- package/dist/cjs/boundary/TernSecureCtx.js.map +0 -1
- package/dist/cjs/boundary/hooks/useAuth.js +0 -51
- package/dist/cjs/boundary/hooks/useAuth.js.map +0 -1
- package/dist/cjs/boundary/hooks/useUser.js +0 -44
- package/dist/cjs/boundary/hooks/useUser.js.map +0 -1
- package/dist/cjs/components/background.js +0 -65
- package/dist/cjs/components/background.js.map +0 -1
- package/dist/cjs/components/sign-in.js +0 -243
- package/dist/cjs/components/sign-in.js.map +0 -1
- package/dist/cjs/components/sign-out.js +0 -69
- package/dist/cjs/components/sign-out.js.map +0 -1
- package/dist/cjs/components/ui/alert.js +0 -88
- package/dist/cjs/components/ui/alert.js.map +0 -1
- package/dist/cjs/components/ui/button.js +0 -84
- package/dist/cjs/components/ui/button.js.map +0 -1
- package/dist/cjs/components/ui/card.js +0 -101
- package/dist/cjs/components/ui/card.js.map +0 -1
- package/dist/cjs/components/ui/input.js +0 -58
- package/dist/cjs/components/ui/input.js.map +0 -1
- package/dist/cjs/components/ui/label.js +0 -55
- package/dist/cjs/components/ui/label.js.map +0 -1
- package/dist/cjs/components/ui/separator.js +0 -59
- package/dist/cjs/components/ui/separator.js.map +0 -1
- package/dist/cjs/errors.js +0 -41
- package/dist/cjs/errors.js.map +0 -1
- package/dist/cjs/index.js +0 -56
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/lib/utils.d.js +0 -17
- package/dist/cjs/lib/utils.d.js.map +0 -1
- package/dist/cjs/lib/utils.js +0 -33
- package/dist/cjs/lib/utils.js.map +0 -1
- package/dist/cjs/types.js +0 -17
- package/dist/cjs/types.js.map +0 -1
- package/dist/cjs/utils/admin-init.js +0 -57
- package/dist/cjs/utils/admin-init.js.map +0 -1
- package/dist/cjs/utils/client-init.js +0 -49
- package/dist/cjs/utils/client-init.js.map +0 -1
- package/dist/cjs/utils/config.js +0 -113
- package/dist/cjs/utils/config.js.map +0 -1
- package/dist/cjs/utils/construct.js +0 -63
- package/dist/cjs/utils/construct.js.map +0 -1
- package/dist/cjs/utils/create-styles.js +0 -149
- package/dist/cjs/utils/create-styles.js.map +0 -1
- package/dist/esm/app-router/client/TernSecureProvider.js +0 -9
- package/dist/esm/app-router/client/TernSecureProvider.js.map +0 -1
- package/dist/esm/app-router/client/actions.js +0 -70
- package/dist/esm/app-router/client/actions.js.map +0 -1
- package/dist/esm/app-router/server/auth.js +0 -47
- package/dist/esm/app-router/server/auth.js.map +0 -1
- package/dist/esm/app-router/server/index.js +0 -13
- package/dist/esm/app-router/server/index.js.map +0 -1
- package/dist/esm/app-router/server/sessionTernSecure.js +0 -129
- package/dist/esm/app-router/server/sessionTernSecure.js.map +0 -1
- package/dist/esm/app-router/server/ternSecureMiddleware.js +0 -26
- package/dist/esm/app-router/server/ternSecureMiddleware.js.map +0 -1
- package/dist/esm/boundary/TernSecureClientProvider.js +0 -70
- package/dist/esm/boundary/TernSecureClientProvider.js.map +0 -1
- package/dist/esm/boundary/TernSecureCtx.js +0 -23
- package/dist/esm/boundary/TernSecureCtx.js.map +0 -1
- package/dist/esm/boundary/hooks/useAuth.js +0 -27
- package/dist/esm/boundary/hooks/useAuth.js.map +0 -1
- package/dist/esm/boundary/hooks/useUser.js +0 -20
- package/dist/esm/boundary/hooks/useUser.js.map +0 -1
- package/dist/esm/components/background.js +0 -41
- package/dist/esm/components/background.js.map +0 -1
- package/dist/esm/components/sign-in.js +0 -219
- package/dist/esm/components/sign-in.js.map +0 -1
- package/dist/esm/components/sign-out.js +0 -45
- package/dist/esm/components/sign-out.js.map +0 -1
- package/dist/esm/components/ui/alert.js +0 -52
- package/dist/esm/components/ui/alert.js.map +0 -1
- package/dist/esm/components/ui/button.js +0 -49
- package/dist/esm/components/ui/button.js.map +0 -1
- package/dist/esm/components/ui/card.js +0 -62
- package/dist/esm/components/ui/card.js.map +0 -1
- package/dist/esm/components/ui/input.js +0 -24
- package/dist/esm/components/ui/input.js.map +0 -1
- package/dist/esm/components/ui/label.js +0 -21
- package/dist/esm/components/ui/label.js.map +0 -1
- package/dist/esm/components/ui/separator.js +0 -25
- package/dist/esm/components/ui/separator.js.map +0 -1
- package/dist/esm/errors.js +0 -16
- package/dist/esm/errors.js.map +0 -1
- package/dist/esm/index.js +0 -22
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lib/utils.d.js +0 -1
- package/dist/esm/lib/utils.d.js.map +0 -1
- package/dist/esm/lib/utils.js +0 -9
- package/dist/esm/lib/utils.js.map +0 -1
- package/dist/esm/types.js +0 -1
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/utils/admin-init.js +0 -22
- package/dist/esm/utils/admin-init.js.map +0 -1
- package/dist/esm/utils/client-init.js +0 -22
- package/dist/esm/utils/client-init.js.map +0 -1
- package/dist/esm/utils/config.js +0 -84
- package/dist/esm/utils/config.js.map +0 -1
- package/dist/esm/utils/construct.js +0 -37
- package/dist/esm/utils/construct.js.map +0 -1
- package/dist/esm/utils/create-styles.js +0 -123
- package/dist/esm/utils/create-styles.js.map +0 -1
- package/dist/types/app-router/client/TernSecureProvider.d.ts +0 -26
- package/dist/types/app-router/client/TernSecureProvider.d.ts.map +0 -1
- package/dist/types/app-router/client/actions.d.ts +0 -39
- package/dist/types/app-router/client/actions.d.ts.map +0 -1
- package/dist/types/app-router/server/auth.d.ts +0 -7
- package/dist/types/app-router/server/auth.d.ts.map +0 -1
- package/dist/types/app-router/server/index.d.ts +0 -5
- package/dist/types/app-router/server/index.d.ts.map +0 -1
- package/dist/types/app-router/server/sessionTernSecure.d.ts +0 -37
- package/dist/types/app-router/server/sessionTernSecure.d.ts.map +0 -1
- package/dist/types/app-router/server/ternSecureMiddleware.d.ts +0 -7
- package/dist/types/app-router/server/ternSecureMiddleware.d.ts.map +0 -1
- package/dist/types/boundary/TernSecureClientProvider.d.ts +0 -11
- package/dist/types/boundary/TernSecureClientProvider.d.ts.map +0 -1
- package/dist/types/boundary/TernSecureCtx.d.ts +0 -15
- package/dist/types/boundary/TernSecureCtx.d.ts.map +0 -1
- package/dist/types/boundary/hooks/useAuth.d.ts +0 -11
- package/dist/types/boundary/hooks/useAuth.d.ts.map +0 -1
- package/dist/types/boundary/hooks/useUser.d.ts +0 -7
- package/dist/types/boundary/hooks/useUser.d.ts.map +0 -1
- package/dist/types/components/background.d.ts +0 -2
- package/dist/types/components/background.d.ts.map +0 -1
- package/dist/types/components/sign-in.d.ts +0 -18
- package/dist/types/components/sign-in.d.ts.map +0 -1
- package/dist/types/components/sign-out.d.ts +0 -10
- package/dist/types/components/sign-out.d.ts.map +0 -1
- package/dist/types/components/ui/alert.d.ts +0 -9
- package/dist/types/components/ui/alert.d.ts.map +0 -1
- package/dist/types/components/ui/button.d.ts +0 -12
- package/dist/types/components/ui/button.d.ts.map +0 -1
- package/dist/types/components/ui/card.d.ts +0 -9
- package/dist/types/components/ui/card.d.ts.map +0 -1
- package/dist/types/components/ui/input.d.ts +0 -4
- package/dist/types/components/ui/input.d.ts.map +0 -1
- package/dist/types/components/ui/label.d.ts +0 -6
- package/dist/types/components/ui/label.d.ts.map +0 -1
- package/dist/types/components/ui/separator.d.ts +0 -5
- package/dist/types/components/ui/separator.d.ts.map +0 -1
- package/dist/types/errors.d.ts +0 -9
- package/dist/types/errors.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/lib/utils.d.ts +0 -3
- package/dist/types/lib/utils.d.ts.map +0 -1
- package/dist/types/types.d.ts +0 -63
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/utils/admin-init.d.ts +0 -4
- package/dist/types/utils/admin-init.d.ts.map +0 -1
- package/dist/types/utils/client-init.d.ts +0 -5
- package/dist/types/utils/client-init.d.ts.map +0 -1
- package/dist/types/utils/config.d.ts +0 -35
- package/dist/types/utils/config.d.ts.map +0 -1
- package/dist/types/utils/construct.d.ts +0 -22
- package/dist/types/utils/construct.d.ts.map +0 -1
- package/dist/types/utils/create-styles.d.ts +0 -99
- package/dist/types/utils/create-styles.d.ts.map +0 -1
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useState, useEffect, useMemo, useCallback } from "react";
|
|
4
|
-
import { ternSecureAuth } from "../utils/client-init";
|
|
5
|
-
import { onAuthStateChanged } from "firebase/auth";
|
|
6
|
-
import { TernSecureCtx } from "./TernSecureCtx";
|
|
7
|
-
import { useRouter } from "next/navigation";
|
|
8
|
-
function TernSecureClientProvider({
|
|
9
|
-
children,
|
|
10
|
-
loginPath = "/sign-in",
|
|
11
|
-
loadingComponent
|
|
12
|
-
}) {
|
|
13
|
-
const auth = useMemo(() => ternSecureAuth, []);
|
|
14
|
-
const router = useRouter();
|
|
15
|
-
const [authState, setAuthState] = useState(() => ({
|
|
16
|
-
userId: null,
|
|
17
|
-
isLoaded: false,
|
|
18
|
-
error: null,
|
|
19
|
-
isValid: false,
|
|
20
|
-
token: null
|
|
21
|
-
}));
|
|
22
|
-
const handleSignOut = useCallback(async (error) => {
|
|
23
|
-
await auth.signOut();
|
|
24
|
-
setAuthState({
|
|
25
|
-
isLoaded: true,
|
|
26
|
-
userId: null,
|
|
27
|
-
error: error || null,
|
|
28
|
-
isValid: false,
|
|
29
|
-
token: null
|
|
30
|
-
});
|
|
31
|
-
router.push(loginPath);
|
|
32
|
-
}, [auth, router, loginPath]);
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
const unsubscribe = onAuthStateChanged(auth, async (user) => {
|
|
35
|
-
if (user) {
|
|
36
|
-
setAuthState({
|
|
37
|
-
isLoaded: true,
|
|
38
|
-
userId: user.uid,
|
|
39
|
-
isValid: true,
|
|
40
|
-
token: user.getIdToken(),
|
|
41
|
-
error: null
|
|
42
|
-
});
|
|
43
|
-
} else {
|
|
44
|
-
setAuthState({
|
|
45
|
-
isLoaded: true,
|
|
46
|
-
userId: null,
|
|
47
|
-
isValid: false,
|
|
48
|
-
token: null,
|
|
49
|
-
error: new Error("User is not authenticated")
|
|
50
|
-
});
|
|
51
|
-
router.push(loginPath);
|
|
52
|
-
}
|
|
53
|
-
}, (error) => {
|
|
54
|
-
handleSignOut(error instanceof Error ? error : new Error("Authentication error occurred"));
|
|
55
|
-
});
|
|
56
|
-
return () => unsubscribe();
|
|
57
|
-
}, [auth, handleSignOut, router, loginPath]);
|
|
58
|
-
const contextValue = useMemo(() => ({
|
|
59
|
-
...authState,
|
|
60
|
-
signOut: handleSignOut
|
|
61
|
-
}), [authState, auth, handleSignOut]);
|
|
62
|
-
if (!authState.isLoaded) {
|
|
63
|
-
return /* @__PURE__ */ jsx(TernSecureCtx.Provider, { value: contextValue, children: loadingComponent || /* @__PURE__ */ jsx("div", { "aria-live": "polite", "aria-busy": "true", children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading authentication state..." }) }) });
|
|
64
|
-
}
|
|
65
|
-
return /* @__PURE__ */ jsx(TernSecureCtx.Provider, { value: contextValue, children });
|
|
66
|
-
}
|
|
67
|
-
export {
|
|
68
|
-
TernSecureClientProvider
|
|
69
|
-
};
|
|
70
|
-
//# sourceMappingURL=TernSecureClientProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/boundary/TernSecureClientProvider.tsx"],"sourcesContent":["\"use client\"\r\n\r\nimport React, { useState, useEffect, useMemo, useCallback } from 'react'\r\nimport { ternSecureAuth } from '../utils/client-init'\r\nimport { onAuthStateChanged, User } from \"firebase/auth\"\r\nimport { TernSecureCtx, TernSecureCtxValue, TernSecureState } from './TernSecureCtx'\r\nimport { useRouter } from 'next/navigation'\r\n\r\ninterface TernSecureClientProviderProps {\r\n children: React.ReactNode;\r\n onUserChanged?: (user: User | null) => Promise<void>;\r\n loginPath?: string;\r\n loadingComponent?: React.ReactNode;\r\n}\r\n\r\nexport function TernSecureClientProvider({ \r\n children, \r\n loginPath = '/sign-in',\r\n loadingComponent\r\n}: TernSecureClientProviderProps) {\r\n const auth = useMemo(() => ternSecureAuth, []);\r\n const router = useRouter();\r\n const [authState, setAuthState] = useState<TernSecureState>(() => ({\r\n userId: null,\r\n isLoaded: false,\r\n error: null,\r\n isValid: false,\r\n token: null\r\n }));\r\n\r\n const handleSignOut = useCallback(async (error?: Error) => {\r\n await auth.signOut();\r\n setAuthState({\r\n isLoaded: true,\r\n userId: null,\r\n error: error || null,\r\n isValid: false,\r\n token: null\r\n });\r\n router.push(loginPath);\r\n }, [auth, router, loginPath]);\r\n\r\nuseEffect(() => {\r\n const unsubscribe = onAuthStateChanged(auth, async (user: User | null) => {\r\n if (user) {\r\n setAuthState({\r\n isLoaded: true,\r\n userId: user.uid,\r\n isValid: true,\r\n token: user.getIdToken(),\r\n error: null\r\n })\r\n } else {\r\n setAuthState({\r\n isLoaded: true,\r\n userId: null,\r\n isValid: false,\r\n token: null,\r\n error: new Error('User is not authenticated')\r\n })\r\n router.push(loginPath);\r\n }\r\n }, (error) => {\r\n handleSignOut(error instanceof Error ? error : new Error('Authentication error occurred'));\r\n })\r\n \r\n return () => unsubscribe()\r\n }, [auth, handleSignOut, router, loginPath])\r\n\r\n const contextValue: TernSecureCtxValue = useMemo(() => ({\r\n ...authState,\r\n signOut: handleSignOut,\r\n }), [authState, auth, handleSignOut]);\r\n\r\n if (!authState.isLoaded) {\r\n return (\r\n <TernSecureCtx.Provider value={contextValue}>\r\n {loadingComponent || (\r\n <div aria-live=\"polite\" aria-busy=\"true\">\r\n <span className=\"sr-only\">Loading authentication state...</span>\r\n </div>\r\n )}\r\n </TernSecureCtx.Provider>\r\n );\r\n }\r\n\r\n return (\r\n <TernSecureCtx.Provider value={contextValue}>\r\n {children}\r\n </TernSecureCtx.Provider>\r\n )\r\n}"],"mappings":";AA+EY;AA7EZ,SAAgB,UAAU,WAAW,SAAS,mBAAmB;AACjE,SAAS,sBAAsB;AAC/B,SAAS,0BAAgC;AACzC,SAAS,qBAA0D;AACnE,SAAS,iBAAiB;AASnB,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA,YAAY;AAAA,EACZ;AACF,GAAkC;AAChC,QAAM,OAAO,QAAQ,MAAM,gBAAgB,CAAC,CAAC;AAC7C,QAAM,SAAS,UAAU;AACzB,QAAM,CAAC,WAAW,YAAY,IAAI,SAA0B,OAAO;AAAA,IACjE,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,OAAO;AAAA,IACP,SAAS;AAAA,IACT,OAAO;AAAA,EACT,EAAE;AAEF,QAAM,gBAAgB,YAAY,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,IACT,CAAC;AACD,WAAO,KAAK,SAAS;AAAA,EACvB,GAAG,CAAC,MAAM,QAAQ,SAAS,CAAC;AAE9B,YAAU,MAAM;AACZ,UAAM,cAAc,mBAAmB,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,QACT,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,QAC9C,CAAC;AACD,eAAO,KAAK,SAAS;AAAA,MACvB;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,eAAmC,QAAQ,OAAO;AAAA,IACtD,GAAG;AAAA,IACH,SAAS;AAAA,EACX,IAAI,CAAC,WAAW,MAAM,aAAa,CAAC;AAEpC,MAAI,CAAC,UAAU,UAAU;AACvB,WACE,oBAAC,cAAc,UAAd,EAAuB,OAAO,cAC5B,8BACC,oBAAC,SAAI,aAAU,UAAS,aAAU,QAChC,8BAAC,UAAK,WAAU,WAAU,6CAA+B,GAC3D,GAEJ;AAAA,EAEJ;AAEA,SACI,oBAAC,cAAc,UAAd,EAAuB,OAAO,cAC7B,UACF;AAEN;","names":[]}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { createContext, useContext } from "react";
|
|
3
|
-
import { ternSecureAuth } from "../utils/client-init";
|
|
4
|
-
const TernSecureUser = () => {
|
|
5
|
-
return ternSecureAuth.currentUser;
|
|
6
|
-
};
|
|
7
|
-
const TernSecureCtx = createContext(null);
|
|
8
|
-
TernSecureCtx.displayName = "TernSecureCtx";
|
|
9
|
-
const useTernSecure = (hookName) => {
|
|
10
|
-
const context = useContext(TernSecureCtx);
|
|
11
|
-
if (!context) {
|
|
12
|
-
throw new Error(
|
|
13
|
-
`${hookName} must be used within TernSecureProvider`
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
return context;
|
|
17
|
-
};
|
|
18
|
-
export {
|
|
19
|
-
TernSecureCtx,
|
|
20
|
-
TernSecureUser,
|
|
21
|
-
useTernSecure
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=TernSecureCtx.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/boundary/TernSecureCtx.tsx"],"sourcesContent":["\"use client\"\r\n\r\nimport { createContext, useContext } from 'react'\r\nimport { ternSecureAuth } from '../utils/client-init';\r\nimport { User } from 'firebase/auth';\r\n\r\nexport const TernSecureUser = (): User | null => {\r\n return ternSecureAuth.currentUser;\r\n}\r\n\r\nexport interface TernSecureState {\r\n userId: string | null\r\n isLoaded: boolean\r\n error: Error | null\r\n isValid: boolean\r\n token: any | null\r\n}\r\n\r\nexport interface TernSecureCtxValue extends TernSecureState {\r\n //checkTokenValidity: () => Promise<void>;\r\n signOut: () => Promise<void>;\r\n}\r\n\r\nexport const TernSecureCtx = createContext<TernSecureCtxValue | null>(null)\r\n\r\nTernSecureCtx.displayName = 'TernSecureCtx'\r\n\r\nexport const useTernSecure = (hookName: string) => {\r\n const context = useContext(TernSecureCtx)\r\n \r\n if (!context) {\r\n throw new Error(\r\n `${hookName} must be used within TernSecureProvider`\r\n )\r\n }\r\n\r\n return context\r\n}\r\n\r\n"],"mappings":";AAEA,SAAS,eAAe,kBAAkB;AAC1C,SAAS,sBAAsB;AAGxB,MAAM,iBAAiB,MAAmB;AAC/C,SAAO,eAAe;AACxB;AAeO,MAAM,gBAAgB,cAAyC,IAAI;AAE1E,cAAc,cAAc;AAErB,MAAM,gBAAgB,CAAC,aAAqB;AACjD,QAAM,UAAU,WAAW,aAAa;AAExC,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR,GAAG,QAAQ;AAAA,IACb;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useTernSecure } from "../TernSecureCtx";
|
|
3
|
-
import { TernSecureUser } from "../TernSecureCtx";
|
|
4
|
-
function useAuth() {
|
|
5
|
-
const {
|
|
6
|
-
userId,
|
|
7
|
-
isLoaded,
|
|
8
|
-
error,
|
|
9
|
-
isValid,
|
|
10
|
-
token,
|
|
11
|
-
signOut
|
|
12
|
-
} = useTernSecure("useAuth");
|
|
13
|
-
const user = TernSecureUser();
|
|
14
|
-
return {
|
|
15
|
-
user,
|
|
16
|
-
userId,
|
|
17
|
-
isLoaded,
|
|
18
|
-
error,
|
|
19
|
-
isAuthenticated: isValid,
|
|
20
|
-
token,
|
|
21
|
-
signOut
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export {
|
|
25
|
-
useAuth
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=useAuth.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/boundary/hooks/useAuth.ts"],"sourcesContent":["\"use client\"\r\n\r\nimport { useTernSecure } from '../TernSecureCtx'\r\nimport { User } from 'firebase/auth'\r\nimport { TernSecureUser } from '../TernSecureCtx'\r\n\r\nexport function useAuth() {\r\n const {\r\n userId,\r\n isLoaded,\r\n error,\r\n isValid,\r\n token,\r\n signOut\r\n } = useTernSecure('useAuth')\r\n\r\n const user: User | null = TernSecureUser()\r\n\r\n return {\r\n user,\r\n userId,\r\n isLoaded,\r\n error,\r\n isAuthenticated: isValid,\r\n token,\r\n signOut\r\n }\r\n}\r\n"],"mappings":";AAEA,SAAS,qBAAqB;AAE9B,SAAS,sBAAsB;AAExB,SAAS,UAAU;AACxB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,cAAc,SAAS;AAE3B,QAAM,OAAoB,eAAe;AAEzC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { onAuthStateChanged } from "firebase/auth";
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
4
|
-
import { ternSecureAuth } from "../../utils/client-init";
|
|
5
|
-
function useUser() {
|
|
6
|
-
const [user, setUser] = useState(null);
|
|
7
|
-
const [loading, setLoading] = useState(true);
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
const unsubscribe = onAuthStateChanged(ternSecureAuth, (authUser) => {
|
|
10
|
-
setUser(authUser);
|
|
11
|
-
setLoading(false);
|
|
12
|
-
});
|
|
13
|
-
return () => unsubscribe();
|
|
14
|
-
}, []);
|
|
15
|
-
return { user, loading };
|
|
16
|
-
}
|
|
17
|
-
export {
|
|
18
|
-
useUser
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=useUser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/boundary/hooks/useUser.ts"],"sourcesContent":["\"use client\";\r\n\r\nimport { onAuthStateChanged } from \"firebase/auth\";\r\nimport { useEffect, useState } from \"react\";\r\n\r\nimport { ternSecureAuth} from \"../../utils/client-init\";\r\n\r\ninterface UseUserReturn {\r\n user: any | null;\r\n loading: boolean;\r\n }\r\n\r\nexport function useUser(): UseUserReturn {\r\n const [user, setUser] = useState<any| null>(null);\r\n const [loading, setLoading] = useState(true);\r\n\r\n useEffect(() => {\r\n const unsubscribe = onAuthStateChanged(ternSecureAuth, (authUser) => {\r\n setUser(authUser);\r\n setLoading(false);\r\n });\r\n\r\n return () => unsubscribe();\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, []);\r\n\r\n return {user, loading};\r\n}\r\n"],"mappings":";AAEA,SAAS,0BAA0B;AACnC,SAAS,WAAW,gBAAgB;AAEpC,SAAS,sBAAqB;AAOvB,SAAS,UAAyB;AACvC,QAAM,CAAC,MAAM,OAAO,IAAI,SAAoB,IAAI;AAChD,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,IAAI;AAE3C,YAAU,MAAM;AACd,UAAM,cAAc,mBAAmB,gBAAgB,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":[]}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
function AuthBackground() {
|
|
3
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4
|
-
/* @__PURE__ */ jsx(
|
|
5
|
-
"div",
|
|
6
|
-
{
|
|
7
|
-
className: "absolute inset-x-0 -top-40 -z-10 transform-gpu overflow-hidden blur-3xl sm:-top-80",
|
|
8
|
-
"aria-hidden": "true",
|
|
9
|
-
children: /* @__PURE__ */ jsx(
|
|
10
|
-
"div",
|
|
11
|
-
{
|
|
12
|
-
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]",
|
|
13
|
-
style: {
|
|
14
|
-
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%)"
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
)
|
|
18
|
-
}
|
|
19
|
-
),
|
|
20
|
-
/* @__PURE__ */ jsx(
|
|
21
|
-
"div",
|
|
22
|
-
{
|
|
23
|
-
className: "absolute inset-x-0 top-[calc(100%-13rem)] -z-10 transform-gpu overflow-hidden blur-3xl sm:top-[calc(100%-30rem)]",
|
|
24
|
-
"aria-hidden": "true",
|
|
25
|
-
children: /* @__PURE__ */ jsx(
|
|
26
|
-
"div",
|
|
27
|
-
{
|
|
28
|
-
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]",
|
|
29
|
-
style: {
|
|
30
|
-
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%)"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
)
|
|
36
|
-
] });
|
|
37
|
-
}
|
|
38
|
-
export {
|
|
39
|
-
AuthBackground
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=background.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/background.tsx"],"sourcesContent":["export function AuthBackground() {\r\n return (\r\n <>\r\n {/* Primary gradient blob */}\r\n <div\r\n className=\"absolute inset-x-0 -top-40 -z-10 transform-gpu overflow-hidden blur-3xl sm:-top-80\"\r\n aria-hidden=\"true\"\r\n >\r\n <div\r\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]\"\r\n style={{\r\n clipPath:\r\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%)',\r\n }}\r\n />\r\n </div>\r\n \r\n {/* Secondary gradient blob */}\r\n <div\r\n className=\"absolute inset-x-0 top-[calc(100%-13rem)] -z-10 transform-gpu overflow-hidden blur-3xl sm:top-[calc(100%-30rem)]\"\r\n aria-hidden=\"true\"\r\n >\r\n <div\r\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]\"\r\n style={{\r\n clipPath:\r\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%)',\r\n }}\r\n />\r\n </div>\r\n </>\r\n )\r\n }\r\n \r\n "],"mappings":"AAEM,mBAMM,KANN;AAFC,SAAS,iBAAiB;AAC7B,SACE,iCAEE;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":[]}
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useState, useCallback, useEffect } from "react";
|
|
4
|
-
import { useSearchParams } from "next/navigation";
|
|
5
|
-
import { signInWithEmail, signInWithRedirectGoogle, signInWithMicrosoft } from "../app-router/client/actions";
|
|
6
|
-
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "./ui/card";
|
|
7
|
-
import { Input } from "./ui/input";
|
|
8
|
-
import { Label } from "./ui/label";
|
|
9
|
-
import { Button } from "./ui/button";
|
|
10
|
-
import { Alert, AlertDescription } from "./ui/alert";
|
|
11
|
-
import { Separator } from "./ui/separator";
|
|
12
|
-
import { cn } from "../lib/utils";
|
|
13
|
-
import { Loader2 } from "lucide-react";
|
|
14
|
-
import { getRedirectResult } from "firebase/auth";
|
|
15
|
-
import { ternSecureAuth } from "../utils/client-init";
|
|
16
|
-
import { createSessionCookie } from "../app-router/server/sessionTernSecure";
|
|
17
|
-
import { AuthBackground } from "./background";
|
|
18
|
-
import { getValidRedirectUrl } from "../utils/construct";
|
|
19
|
-
const isLocalhost = typeof window !== "undefined" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1");
|
|
20
|
-
const authDomain = process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN;
|
|
21
|
-
const appName = process.env.NEXT_PUBLIC_FIREBASE_APP_NAME || "TernSecure";
|
|
22
|
-
function SignIn({
|
|
23
|
-
redirectUrl,
|
|
24
|
-
onError,
|
|
25
|
-
onSuccess,
|
|
26
|
-
className,
|
|
27
|
-
customStyles = {}
|
|
28
|
-
}) {
|
|
29
|
-
const [loading, setLoading] = useState(false);
|
|
30
|
-
const [checkingRedirect, setCheckingRedirect] = useState(true);
|
|
31
|
-
const [error, setError] = useState("");
|
|
32
|
-
const [email, setEmail] = useState("");
|
|
33
|
-
const [password, setPassword] = useState("");
|
|
34
|
-
const searchParams = useSearchParams();
|
|
35
|
-
const isRedirectSignIn = searchParams.get("signInRedirect") === "true";
|
|
36
|
-
const handleRedirectResult = useCallback(async () => {
|
|
37
|
-
if (!isRedirectSignIn) return false;
|
|
38
|
-
setCheckingRedirect(true);
|
|
39
|
-
try {
|
|
40
|
-
console.log("Checking redirect result...");
|
|
41
|
-
console.log("Current hostname:", window.location.hostname);
|
|
42
|
-
console.log("Auth domain hostname:", authDomain);
|
|
43
|
-
const isOnAuth = authDomain && window.location.hostname === authDomain.replace(/https?:\/\//, "");
|
|
44
|
-
console.log("Is on AuthDomain:", isOnAuth);
|
|
45
|
-
const result = await getRedirectResult(ternSecureAuth);
|
|
46
|
-
console.log("Redirect result:", result);
|
|
47
|
-
if (result) {
|
|
48
|
-
const idToken = await result.user.getIdToken();
|
|
49
|
-
const sessionResult = await createSessionCookie(idToken);
|
|
50
|
-
if (!sessionResult.success) {
|
|
51
|
-
throw new Error("Failed to create session");
|
|
52
|
-
}
|
|
53
|
-
const storedRedirectUrl = sessionStorage.getItem("auth_return_url");
|
|
54
|
-
sessionStorage.removeItem("auth_redirect_url");
|
|
55
|
-
onSuccess == null ? void 0 : onSuccess();
|
|
56
|
-
window.location.href = storedRedirectUrl || getValidRedirectUrl(redirectUrl, searchParams);
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
setCheckingRedirect(false);
|
|
60
|
-
} catch (err) {
|
|
61
|
-
console.error("Redirect result error:", err);
|
|
62
|
-
const errorMessage = err instanceof Error ? err.message : "Authentication failed";
|
|
63
|
-
setError(errorMessage);
|
|
64
|
-
onError == null ? void 0 : onError(err instanceof Error ? err : new Error(errorMessage));
|
|
65
|
-
sessionStorage.removeItem("auth_redirect_url");
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
}, [isRedirectSignIn, redirectUrl, searchParams, onSuccess, onError]);
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
if (isRedirectSignIn) {
|
|
71
|
-
handleRedirectResult();
|
|
72
|
-
}
|
|
73
|
-
;
|
|
74
|
-
}, [handleRedirectResult, isRedirectSignIn]);
|
|
75
|
-
const handleSubmit = async (e) => {
|
|
76
|
-
e.preventDefault();
|
|
77
|
-
setLoading(true);
|
|
78
|
-
try {
|
|
79
|
-
const user = await signInWithEmail(email, password);
|
|
80
|
-
if (user.success) {
|
|
81
|
-
onSuccess == null ? void 0 : onSuccess();
|
|
82
|
-
window.location.href = getValidRedirectUrl(redirectUrl, searchParams);
|
|
83
|
-
}
|
|
84
|
-
} catch (err) {
|
|
85
|
-
const errorMessage = err instanceof Error ? err.message : "Failed to sign in";
|
|
86
|
-
setError(errorMessage);
|
|
87
|
-
onError == null ? void 0 : onError(err instanceof Error ? err : new Error("Failed to sign in"));
|
|
88
|
-
} finally {
|
|
89
|
-
setLoading(false);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
const handleSocialSignIn = async (provider) => {
|
|
93
|
-
setLoading(true);
|
|
94
|
-
try {
|
|
95
|
-
const validRedirectUrl = getValidRedirectUrl(redirectUrl, searchParams);
|
|
96
|
-
sessionStorage.setItem("auth_redirect_url", validRedirectUrl);
|
|
97
|
-
const currentUrl = new URL(window.location.href);
|
|
98
|
-
currentUrl.searchParams.set("signInRedirect", "true");
|
|
99
|
-
window.history.replaceState({}, "", currentUrl.toString());
|
|
100
|
-
const result = provider === "google" ? await signInWithRedirectGoogle() : await signInWithMicrosoft();
|
|
101
|
-
if (!result.success) {
|
|
102
|
-
throw new Error(result.error);
|
|
103
|
-
}
|
|
104
|
-
} catch (err) {
|
|
105
|
-
const errorMessage = err instanceof Error ? err.message : `Failed to sign in with ${provider}`;
|
|
106
|
-
setError(errorMessage);
|
|
107
|
-
onError == null ? void 0 : onError(err instanceof Error ? err : new Error(`Failed to sign in with ${provider}`));
|
|
108
|
-
setLoading(false);
|
|
109
|
-
sessionStorage.removeItem("auth_redirect_url");
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
if (checkingRedirect && isRedirectSignIn) {
|
|
113
|
-
return /* @__PURE__ */ jsx("div", { className: "flex min-h-screen items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "text-center space-y-4", children: /* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto" }) }) });
|
|
114
|
-
}
|
|
115
|
-
return /* @__PURE__ */ jsxs("div", { className: "relative flex items-center justify-center", children: [
|
|
116
|
-
/* @__PURE__ */ jsx(AuthBackground, {}),
|
|
117
|
-
/* @__PURE__ */ jsxs(Card, { className: cn("w-full max-w-md mx-auto mt-8", className, customStyles.card), children: [
|
|
118
|
-
/* @__PURE__ */ jsxs(CardHeader, { className: "space-y-1 text-center", children: [
|
|
119
|
-
/* @__PURE__ */ jsxs(CardTitle, { className: cn("font-bold", customStyles.title), children: [
|
|
120
|
-
"Sign in to ",
|
|
121
|
-
`${appName}`
|
|
122
|
-
] }),
|
|
123
|
-
/* @__PURE__ */ jsx(CardDescription, { className: cn("text-muted-foreground", customStyles.description), children: "Please sign in to continue" })
|
|
124
|
-
] }),
|
|
125
|
-
/* @__PURE__ */ jsxs(CardContent, { className: "space-y-4", children: [
|
|
126
|
-
/* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "space-y-4", children: [
|
|
127
|
-
error && /* @__PURE__ */ jsx(Alert, { variant: "destructive", children: /* @__PURE__ */ jsx(AlertDescription, { children: error }) }),
|
|
128
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
129
|
-
/* @__PURE__ */ jsx(Label, { htmlFor: "email", className: cn(customStyles.label), children: "Email" }),
|
|
130
|
-
/* @__PURE__ */ jsx(
|
|
131
|
-
Input,
|
|
132
|
-
{
|
|
133
|
-
id: "email",
|
|
134
|
-
type: "email",
|
|
135
|
-
placeholder: "m@example.com",
|
|
136
|
-
value: email,
|
|
137
|
-
onChange: (e) => setEmail(e.target.value),
|
|
138
|
-
disabled: loading,
|
|
139
|
-
className: cn(customStyles.input),
|
|
140
|
-
required: true
|
|
141
|
-
}
|
|
142
|
-
)
|
|
143
|
-
] }),
|
|
144
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
145
|
-
/* @__PURE__ */ jsx(Label, { htmlFor: "password", className: cn(customStyles.label), children: "Password" }),
|
|
146
|
-
/* @__PURE__ */ jsx(
|
|
147
|
-
Input,
|
|
148
|
-
{
|
|
149
|
-
id: "password",
|
|
150
|
-
type: "password",
|
|
151
|
-
value: password,
|
|
152
|
-
onChange: (e) => setPassword(e.target.value),
|
|
153
|
-
disabled: loading,
|
|
154
|
-
className: cn(customStyles.input),
|
|
155
|
-
required: true
|
|
156
|
-
}
|
|
157
|
-
)
|
|
158
|
-
] }),
|
|
159
|
-
/* @__PURE__ */ jsx(Button, { type: "submit", disabled: loading, className: cn("w-full", customStyles.button), children: loading ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
160
|
-
/* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
161
|
-
"Signing in..."
|
|
162
|
-
] }) : "Sign in" })
|
|
163
|
-
] }),
|
|
164
|
-
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
165
|
-
/* @__PURE__ */ jsx(Separator, { className: cn(customStyles.separator) }),
|
|
166
|
-
/* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsx("span", { className: "bg-background px-2 text-muted-foreground text-sm", children: "Or continue with" }) })
|
|
167
|
-
] }),
|
|
168
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
169
|
-
/* @__PURE__ */ jsxs(
|
|
170
|
-
Button,
|
|
171
|
-
{
|
|
172
|
-
variant: "outline",
|
|
173
|
-
disabled: loading,
|
|
174
|
-
onClick: () => handleSocialSignIn("google"),
|
|
175
|
-
className: cn("flex items-center justify-center", customStyles.socialButton),
|
|
176
|
-
children: [
|
|
177
|
-
/* @__PURE__ */ jsxs("svg", { className: "w-5 h-5 mr-2", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
178
|
-
/* @__PURE__ */ 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" }),
|
|
179
|
-
/* @__PURE__ */ 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" }),
|
|
180
|
-
/* @__PURE__ */ 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" }),
|
|
181
|
-
/* @__PURE__ */ 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" })
|
|
182
|
-
] }),
|
|
183
|
-
"Google"
|
|
184
|
-
]
|
|
185
|
-
}
|
|
186
|
-
),
|
|
187
|
-
/* @__PURE__ */ jsxs(
|
|
188
|
-
Button,
|
|
189
|
-
{
|
|
190
|
-
variant: "outline",
|
|
191
|
-
disabled: loading,
|
|
192
|
-
onClick: () => handleSocialSignIn("microsoft"),
|
|
193
|
-
className: cn("flex items-center justify-center", customStyles.socialButton),
|
|
194
|
-
children: [
|
|
195
|
-
/* @__PURE__ */ jsxs("svg", { className: "w-5 h-5 mr-2", viewBox: "0 0 23 23", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
196
|
-
/* @__PURE__ */ jsx("path", { fill: "#f3f3f3", d: "M0 0h23v23H0z" }),
|
|
197
|
-
/* @__PURE__ */ jsx("path", { fill: "#f35325", d: "M1 1h10v10H1z" }),
|
|
198
|
-
/* @__PURE__ */ jsx("path", { fill: "#81bc06", d: "M12 1h10v10H12z" }),
|
|
199
|
-
/* @__PURE__ */ jsx("path", { fill: "#05a6f0", d: "M1 12h10v10H1z" }),
|
|
200
|
-
/* @__PURE__ */ jsx("path", { fill: "#ffba08", d: "M12 12h10v10H12z" })
|
|
201
|
-
] }),
|
|
202
|
-
"Microsoft"
|
|
203
|
-
]
|
|
204
|
-
}
|
|
205
|
-
)
|
|
206
|
-
] })
|
|
207
|
-
] }),
|
|
208
|
-
/* @__PURE__ */ jsx(CardFooter, { className: "flex justify-center", children: /* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground", children: [
|
|
209
|
-
"Don't have an account?",
|
|
210
|
-
" ",
|
|
211
|
-
/* @__PURE__ */ jsx("a", { href: "/signup", className: "text-primary hover:underline", children: "Sign up" })
|
|
212
|
-
] }) })
|
|
213
|
-
] })
|
|
214
|
-
] });
|
|
215
|
-
}
|
|
216
|
-
export {
|
|
217
|
-
SignIn
|
|
218
|
-
};
|
|
219
|
-
//# sourceMappingURL=sign-in.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/sign-in.tsx"],"sourcesContent":["'use client'\r\n\r\nimport React, { useState, useCallback, useEffect } from 'react'\r\nimport { useSearchParams } from 'next/navigation'\r\nimport { signInWithEmail, signInWithRedirectGoogle, signInWithMicrosoft } from '../app-router/client/actions'\r\nimport { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from \"./ui/card\"\r\nimport { Input } from \"./ui/input\"\r\nimport { Label } from \"./ui/label\"\r\nimport { Button } from \"./ui/button\"\r\nimport { Alert, AlertDescription } from \"./ui/alert\"\r\nimport { Separator } from \"./ui/separator\"\r\nimport { cn } from \"../lib/utils\"\r\nimport { Loader2 } from 'lucide-react'\r\nimport { getRedirectResult } from 'firebase/auth'\r\nimport { ternSecureAuth } from '../utils/client-init'\r\nimport { createSessionCookie } from '../app-router/server/sessionTernSecure'\r\nimport { AuthBackground } from './background'\r\nimport { getValidRedirectUrl } from '../utils/construct'\r\n\r\nconst isLocalhost = typeof window !== 'undefined' && \r\n (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1');\r\n\r\nconst authDomain = process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN;\r\nconst appName = process.env.NEXT_PUBLIC_FIREBASE_APP_NAME || 'TernSecure';\r\n\r\n\r\nexport interface SignInProps {\r\n redirectUrl?: string\r\n onError?: (error: Error) => void\r\n onSuccess?: () => void\r\n className?: string\r\n customStyles?: {\r\n card?: string\r\n input?: string\r\n button?: string\r\n label?: string\r\n separator?: string\r\n title?: string\r\n description?: string\r\n socialButton?: string\r\n }\r\n}\r\n\r\nexport function SignIn({\r\n redirectUrl,\r\n onError,\r\n onSuccess,\r\n className,\r\n customStyles = {}\r\n}: SignInProps) {\r\n const [loading, setLoading] = useState(false)\r\n const [checkingRedirect, setCheckingRedirect] = useState(true)\r\n const [error, setError] = useState('')\r\n const [email, setEmail] = useState('')\r\n const [password, setPassword] = useState('')\r\n const searchParams = useSearchParams()\r\n const isRedirectSignIn = searchParams.get('signInRedirect') === 'true'\r\n\r\n\r\n const handleRedirectResult = useCallback(async () => {\r\n if (!isRedirectSignIn) return false\r\n setCheckingRedirect(true)\r\n try {\r\n console.log('Checking redirect result...');\r\n console.log('Current hostname:', window.location.hostname);\r\n console.log('Auth domain hostname:', authDomain);\r\n\r\n const isOnAuth = authDomain && \r\n window.location.hostname === authDomain.replace(/https?:\\/\\//, '');\r\n console.log('Is on AuthDomain:', isOnAuth);\r\n\r\n\r\n const result = await getRedirectResult(ternSecureAuth)\r\n console.log('Redirect result:', result);\r\n if (result) {\r\n const idToken = await result.user.getIdToken()\r\n const sessionResult = await createSessionCookie(idToken)\r\n if (!sessionResult.success) {\r\n throw new Error('Failed to create session')\r\n }\r\n const storedRedirectUrl = sessionStorage.getItem('auth_return_url')\r\n sessionStorage.removeItem('auth_redirect_url') \r\n onSuccess?.()\r\n window.location.href = storedRedirectUrl || getValidRedirectUrl(redirectUrl, searchParams)\r\n return true\r\n }\r\n setCheckingRedirect(false)\r\n } catch (err) {\r\n console.error('Redirect result error:', err)\r\n const errorMessage = err instanceof Error ? err.message : 'Authentication failed'\r\n setError(errorMessage)\r\n onError?.(err instanceof Error ? err : new Error(errorMessage))\r\n sessionStorage.removeItem('auth_redirect_url')\r\n return false\r\n }\r\n }, [isRedirectSignIn, redirectUrl, searchParams, onSuccess, onError])\r\n\r\n ///const REDIRECT_TIMEOUT = 5000;\r\n\r\n useEffect(() => {\r\n //let timeoutId: NodeJS.Timeout;\r\n\r\n if (isRedirectSignIn) {\r\n handleRedirectResult();\r\n\r\n /*timeoutId = setTimeout(() => {\r\n console.warn('Redirect check timed out');\r\n setCheckingRedirect(false);\r\n setError('Sign in took too long. Please try again.');\r\n \r\n }, REDIRECT_TIMEOUT);\r\n }\r\n\r\n return () => {\r\n if (timeoutId) {\r\n clearTimeout(timeoutId);\r\n }*/\r\n };\r\n }, [handleRedirectResult, isRedirectSignIn])\r\n\r\n const handleSubmit = async (e: React.FormEvent) => {\r\n e.preventDefault()\r\n setLoading(true)\r\n try {\r\n const user = await signInWithEmail(email, password)\r\n if (user.success) {\r\n onSuccess?.()\r\n window.location.href = getValidRedirectUrl(redirectUrl, searchParams)\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 const handleSocialSignIn = async (provider: 'google' | 'microsoft') => {\r\n setLoading(true)\r\n try {\r\n\r\n const validRedirectUrl = getValidRedirectUrl(redirectUrl, searchParams)\r\n sessionStorage.setItem('auth_redirect_url', validRedirectUrl)\r\n\r\n const currentUrl = new URL(window.location.href)\r\n currentUrl.searchParams.set('signInRedirect', 'true')\r\n window.history.replaceState({}, '', currentUrl.toString())\r\n\r\n const result = provider === 'google' ? await signInWithRedirectGoogle() : await signInWithMicrosoft()\r\n if (!result.success) {\r\n throw new Error(result.error)\r\n }\r\n } catch (err) {\r\n const errorMessage = err instanceof Error ? err.message : `Failed to sign in with ${provider}`\r\n setError(errorMessage)\r\n onError?.(err instanceof Error ? err : new Error(`Failed to sign in with ${provider}`))\r\n setLoading(false)\r\n sessionStorage.removeItem('auth_redirect_url')\r\n }\r\n }\r\n\r\n if (checkingRedirect && isRedirectSignIn) {\r\n return (\r\n <div className=\"flex min-h-screen items-center justify-center\">\r\n <div className=\"text-center space-y-4\">\r\n <div className=\"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto\" />\r\n \r\n </div>\r\n </div>\r\n )\r\n }\r\n\r\n return (\r\n <div className=\"relative flex items-center justify-center\">\r\n <AuthBackground />\r\n <Card className={cn(\"w-full max-w-md mx-auto mt-8\", className, customStyles.card)}>\r\n <CardHeader className=\"space-y-1 text-center\">\r\n <CardTitle className={cn(\"font-bold\", customStyles.title)}>Sign in to {`${appName}`}</CardTitle>\r\n <CardDescription className={cn(\"text-muted-foreground\", customStyles.description)}>\r\n Please sign in to continue\r\n </CardDescription>\r\n </CardHeader>\r\n <CardContent className=\"space-y-4\">\r\n <form onSubmit={handleSubmit} className=\"space-y-4\">\r\n {error && (\r\n <Alert variant=\"destructive\">\r\n <AlertDescription>{error}</AlertDescription>\r\n </Alert>\r\n )}\r\n <div className=\"space-y-2\">\r\n <Label htmlFor=\"email\" className={cn(customStyles.label)}>Email</Label>\r\n <Input\r\n id=\"email\"\r\n type=\"email\"\r\n placeholder=\"m@example.com\"\r\n value={email}\r\n onChange={(e) => setEmail(e.target.value)}\r\n disabled={loading}\r\n className={cn(customStyles.input)}\r\n required\r\n />\r\n </div>\r\n <div className=\"space-y-2\">\r\n <Label htmlFor=\"password\" className={cn(customStyles.label)}>Password</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 disabled={loading}\r\n className={cn(customStyles.input)}\r\n required\r\n />\r\n </div>\r\n <Button type=\"submit\" disabled={loading} className={cn(\"w-full\", customStyles.button)}>\r\n {loading ? (\r\n <>\r\n <Loader2 className=\"mr-2 h-4 w-4 animate-spin\" />\r\n Signing in...\r\n </>\r\n ) : (\r\n 'Sign in'\r\n )}\r\n </Button>\r\n </form>\r\n <div className=\"relative\">\r\n <Separator className={cn(customStyles.separator)} />\r\n <div className=\"absolute inset-0 flex items-center justify-center\">\r\n <span className=\"bg-background px-2 text-muted-foreground text-sm\">Or continue with</span>\r\n </div>\r\n </div>\r\n <div className=\"grid grid-cols-2 gap-4\">\r\n <Button \r\n variant=\"outline\" \r\n disabled={loading} \r\n onClick={() => handleSocialSignIn('google')} \r\n className={cn(\"flex items-center justify-center\", customStyles.socialButton)}\r\n >\r\n <svg className=\"w-5 h-5 mr-2\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <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\"/>\r\n <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\"/>\r\n <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\"/>\r\n <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\"/>\r\n </svg>\r\n Google\r\n </Button>\r\n <Button \r\n variant=\"outline\" \r\n disabled={loading} \r\n onClick={() => handleSocialSignIn('microsoft')} \r\n className={cn(\"flex items-center justify-center\", customStyles.socialButton)}\r\n >\r\n <svg className=\"w-5 h-5 mr-2\" viewBox=\"0 0 23 23\" xmlns=\"http://www.w3.org/2000/svg\">\r\n <path fill=\"#f3f3f3\" d=\"M0 0h23v23H0z\"/>\r\n <path fill=\"#f35325\" d=\"M1 1h10v10H1z\"/>\r\n <path fill=\"#81bc06\" d=\"M12 1h10v10H12z\"/>\r\n <path fill=\"#05a6f0\" d=\"M1 12h10v10H1z\"/>\r\n <path fill=\"#ffba08\" d=\"M12 12h10v10H12z\"/>\r\n </svg>\r\n Microsoft\r\n </Button>\r\n </div>\r\n </CardContent>\r\n <CardFooter className=\"flex justify-center\">\r\n <p className=\"text-sm text-muted-foreground\">\r\n Don't have an account?{' '}\r\n <a href=\"/signup\" className=\"text-primary hover:underline\">\r\n Sign up\r\n </a>\r\n </p>\r\n </CardFooter>\r\n </Card>\r\n </div>\r\n )\r\n}\r\n\r\n"],"mappings":";AAsKU,SAmDI,UAnDJ,KAYF,YAZE;AApKV,SAAgB,UAAU,aAAa,iBAAiB;AACxD,SAAS,uBAAuB;AAChC,SAAS,iBAAiB,0BAA0B,2BAA2B;AAC/E,SAAS,MAAM,aAAa,iBAAiB,YAAY,YAAY,iBAAiB;AACtF,SAAS,aAAa;AACtB,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,OAAO,wBAAwB;AACxC,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AACnB,SAAS,eAAe;AACxB,SAAS,yBAAyB;AAClC,SAAS,sBAAsB;AAC/B,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAAS,2BAA2B;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oBAAC,UAAK,GAAE,uIAAsI,MAAK,WAAS;AAAA,mBAC9J;AAAA,gBAAM;AAAA;AAAA;AAAA,UAER;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,SAAQ;AAAA,cACR,UAAU;AAAA,cACV,SAAS,MAAM,mBAAmB,WAAW;AAAA,cAC7C,WAAW,GAAG,oCAAoC,aAAa,YAAY;AAAA,cAE3E;AAAA,qCAAC,SAAI,WAAU,gBAAe,SAAQ,aAAY,OAAM,8BACtD;AAAA,sCAAC,UAAK,MAAK,WAAU,GAAE,iBAAe;AAAA,kBACtC,oBAAC,UAAK,MAAK,WAAU,GAAE,iBAAe;AAAA,kBACtC,oBAAC,UAAK,MAAK,WAAU,GAAE,mBAAiB;AAAA,kBACxC,oBAAC,UAAK,MAAK,WAAU,GAAE,kBAAgB;AAAA,kBACvC,oBAAC,UAAK,MAAK,WAAU,GAAE,oBAAkB;AAAA,mBAC3C;AAAA,gBAAM;AAAA;AAAA;AAAA,UAER;AAAA,WACF;AAAA,SACF;AAAA,MACA,oBAAC,cAAW,WAAU,uBACpB,+BAAC,OAAE,WAAU,iCAAgC;AAAA;AAAA,QACjB;AAAA,QAC1B,oBAAC,OAAE,MAAK,WAAU,WAAU,gCAA+B,qBAE3D;AAAA,SACF,GACF;AAAA,OACF;AAAA,KACA;AAEJ;","names":[]}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
import { useRouter } from "next/navigation";
|
|
5
|
-
import { signOut } from "firebase/auth";
|
|
6
|
-
import { Button } from "./ui/button";
|
|
7
|
-
import { ternSecureAuth } from "../utils/client-init";
|
|
8
|
-
import { clearSessionCookie } from "../app-router/server/sessionTernSecure";
|
|
9
|
-
function SignOut({
|
|
10
|
-
children = "Sign out",
|
|
11
|
-
onError,
|
|
12
|
-
onSignOutSuccess,
|
|
13
|
-
...buttonProps
|
|
14
|
-
}) {
|
|
15
|
-
const router = useRouter();
|
|
16
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
17
|
-
const handleSignOut = async () => {
|
|
18
|
-
setIsLoading(true);
|
|
19
|
-
try {
|
|
20
|
-
await signOut(ternSecureAuth);
|
|
21
|
-
await clearSessionCookie();
|
|
22
|
-
onSignOutSuccess == null ? void 0 : onSignOutSuccess();
|
|
23
|
-
router.push("/sign-in");
|
|
24
|
-
} catch (error) {
|
|
25
|
-
console.error("Sign out error:", error);
|
|
26
|
-
onError == null ? void 0 : onError(error instanceof Error ? error : new Error("Failed to sign out"));
|
|
27
|
-
} finally {
|
|
28
|
-
setIsLoading(false);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
return /* @__PURE__ */ jsx(
|
|
32
|
-
Button,
|
|
33
|
-
{
|
|
34
|
-
variant: "outline",
|
|
35
|
-
onClick: handleSignOut,
|
|
36
|
-
disabled: isLoading,
|
|
37
|
-
...buttonProps,
|
|
38
|
-
children: isLoading ? "Signing out..." : children
|
|
39
|
-
}
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
export {
|
|
43
|
-
SignOut
|
|
44
|
-
};
|
|
45
|
-
//# sourceMappingURL=sign-out.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/sign-out.tsx"],"sourcesContent":["'use client'\r\n\r\nimport { useState } from 'react'\r\nimport { useRouter } from 'next/navigation'\r\nimport { signOut } from 'firebase/auth'\r\nimport { Button, type ButtonProps } from './ui/button'\r\nimport { ternSecureAuth } from '../utils/client-init'\r\nimport { clearSessionCookie } from '../app-router/server/sessionTernSecure'\r\n\r\ntype SignOutCustomProps = {\r\n children?: React.ReactNode\r\n onError?: (error: Error) => void\r\n onSignOutSuccess?: () => void\r\n}\r\n\r\ntype SignOutProps = Omit<ButtonProps, 'onClick'> & SignOutCustomProps\r\n\r\nexport function SignOut({ \r\n children = 'Sign out', \r\n onError,\r\n onSignOutSuccess,\r\n ...buttonProps \r\n}: SignOutProps) {\r\n const router = useRouter()\r\n const [isLoading, setIsLoading] = useState(false)\r\n\r\n const handleSignOut = async () => {\r\n setIsLoading(true)\r\n try {\r\n // Sign out from Firebase\r\n await signOut(ternSecureAuth)\r\n \r\n await clearSessionCookie()\r\n \r\n // Call success callback if provided\r\n onSignOutSuccess?.()\r\n \r\n // Redirect to sign-in page\r\n router.push('/sign-in')\r\n } catch (error) {\r\n console.error('Sign out error:', error)\r\n onError?.(error instanceof Error ? error : new Error('Failed to sign out'))\r\n } finally {\r\n setIsLoading(false)\r\n }\r\n }\r\n\r\n return (\r\n <Button\r\n variant=\"outline\"\r\n onClick={handleSignOut}\r\n disabled={isLoading}\r\n {...buttonProps}\r\n >\r\n {isLoading ? 'Signing out...' : children}\r\n </Button>\r\n )\r\n}\r\n\r\n"],"mappings":";AAgDI;AA9CJ,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,cAAgC;AACzC,SAAS,sBAAsB;AAC/B,SAAS,0BAA0B;AAU5B,SAAS,QAAQ;AAAA,EACtB,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAiB;AACf,QAAM,SAAS,UAAU;AACzB,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAEhD,QAAM,gBAAgB,YAAY;AAChC,iBAAa,IAAI;AACjB,QAAI;AAEF,YAAM,QAAQ,cAAc;AAE5B,YAAM,mBAAmB;AAGzB;AAGA,aAAO,KAAK,UAAU;AAAA,IACxB,SAAS,OAAO;AACd,cAAQ,MAAM,mBAAmB,KAAK;AACtC,yCAAU,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,oBAAoB;AAAA,IAC3E,UAAE;AACA,mBAAa,KAAK;AAAA,IACpB;AAAA,EACF;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,SAAQ;AAAA,MACR,SAAS;AAAA,MACT,UAAU;AAAA,MACT,GAAG;AAAA,MAEH,sBAAY,mBAAmB;AAAA;AAAA,EAClC;AAEJ;","names":[]}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { cva } from "class-variance-authority";
|
|
4
|
-
import { cn } from "../../lib/utils";
|
|
5
|
-
const alertVariants = cva(
|
|
6
|
-
"relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",
|
|
7
|
-
{
|
|
8
|
-
variants: {
|
|
9
|
-
variant: {
|
|
10
|
-
default: "bg-background text-foreground",
|
|
11
|
-
destructive: "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
defaultVariants: {
|
|
15
|
-
variant: "default"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
);
|
|
19
|
-
const Alert = React.forwardRef(({ className, variant, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
20
|
-
"div",
|
|
21
|
-
{
|
|
22
|
-
ref,
|
|
23
|
-
role: "alert",
|
|
24
|
-
className: cn(alertVariants({ variant }), className),
|
|
25
|
-
...props
|
|
26
|
-
}
|
|
27
|
-
));
|
|
28
|
-
Alert.displayName = "Alert";
|
|
29
|
-
const AlertTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
30
|
-
"h5",
|
|
31
|
-
{
|
|
32
|
-
ref,
|
|
33
|
-
className: cn("mb-1 font-medium leading-none tracking-tight", className),
|
|
34
|
-
...props
|
|
35
|
-
}
|
|
36
|
-
));
|
|
37
|
-
AlertTitle.displayName = "AlertTitle";
|
|
38
|
-
const AlertDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
39
|
-
"div",
|
|
40
|
-
{
|
|
41
|
-
ref,
|
|
42
|
-
className: cn("text-sm [&_p]:leading-relaxed", className),
|
|
43
|
-
...props
|
|
44
|
-
}
|
|
45
|
-
));
|
|
46
|
-
AlertDescription.displayName = "AlertDescription";
|
|
47
|
-
export {
|
|
48
|
-
Alert,
|
|
49
|
-
AlertDescription,
|
|
50
|
-
AlertTitle
|
|
51
|
-
};
|
|
52
|
-
//# sourceMappingURL=alert.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ui/alert.tsx"],"sourcesContent":["import * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"../../lib/utils\"\n\nconst alertVariants = cva(\n \"relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7\",\n {\n variants: {\n variant: {\n default: \"bg-background text-foreground\",\n destructive:\n \"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n }\n)\n\nconst Alert = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>\n>(({ className, variant, ...props }, ref) => (\n <div\n ref={ref}\n role=\"alert\"\n className={cn(alertVariants({ variant }), className)}\n {...props}\n />\n))\nAlert.displayName = \"Alert\"\n\nconst AlertTitle = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLHeadingElement>\n>(({ className, ...props }, ref) => (\n <h5\n ref={ref}\n className={cn(\"mb-1 font-medium leading-none tracking-tight\", className)}\n {...props}\n />\n))\nAlertTitle.displayName = \"AlertTitle\"\n\nconst AlertDescription = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, ...props }, ref) => (\n <div\n ref={ref}\n className={cn(\"text-sm [&_p]:leading-relaxed\", className)}\n {...props}\n />\n))\nAlertDescription.displayName = \"AlertDescription\"\n\nexport { Alert, AlertTitle, AlertDescription }\n"],"mappings":"AAyBE;AAzBF,YAAY,WAAW;AACvB,SAAS,WAA8B;AAEvC,SAAS,UAAU;AAEnB,MAAM,gBAAgB;AAAA,EACpB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,SAAS;AAAA,QACT,aACE;AAAA,MACJ;AAAA,IACF;AAAA,IACA,iBAAiB;AAAA,MACf,SAAS;AAAA,IACX;AAAA,EACF;AACF;AAEA,MAAM,QAAQ,MAAM,WAGlB,CAAC,EAAE,WAAW,SAAS,GAAG,MAAM,GAAG,QACnC;AAAA,EAAC;AAAA;AAAA,IACC;AAAA,IACA,MAAK;AAAA,IACL,WAAW,GAAG,cAAc,EAAE,QAAQ,CAAC,GAAG,SAAS;AAAA,IAClD,GAAG;AAAA;AACN,CACD;AACD,MAAM,cAAc;AAEpB,MAAM,aAAa,MAAM,WAGvB,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,QAC1B;AAAA,EAAC;AAAA;AAAA,IACC;AAAA,IACA,WAAW,GAAG,gDAAgD,SAAS;AAAA,IACtE,GAAG;AAAA;AACN,CACD;AACD,WAAW,cAAc;AAEzB,MAAM,mBAAmB,MAAM,WAG7B,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,QAC1B;AAAA,EAAC;AAAA;AAAA,IACC;AAAA,IACA,WAAW,GAAG,iCAAiC,SAAS;AAAA,IACvD,GAAG;AAAA;AACN,CACD;AACD,iBAAiB,cAAc;","names":[]}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
-
import { cva } from "class-variance-authority";
|
|
5
|
-
import { cn } from "../../lib/utils";
|
|
6
|
-
const buttonVariants = cva(
|
|
7
|
-
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
8
|
-
{
|
|
9
|
-
variants: {
|
|
10
|
-
variant: {
|
|
11
|
-
default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
12
|
-
destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
|
|
13
|
-
outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
14
|
-
secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
|
15
|
-
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
16
|
-
link: "text-primary underline-offset-4 hover:underline"
|
|
17
|
-
},
|
|
18
|
-
size: {
|
|
19
|
-
default: "h-9 px-4 py-2",
|
|
20
|
-
sm: "h-8 rounded-md px-3 text-xs",
|
|
21
|
-
lg: "h-10 rounded-md px-8",
|
|
22
|
-
icon: "h-9 w-9"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
defaultVariants: {
|
|
26
|
-
variant: "default",
|
|
27
|
-
size: "default"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
const Button = React.forwardRef(
|
|
32
|
-
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
33
|
-
const Comp = asChild ? Slot : "button";
|
|
34
|
-
return /* @__PURE__ */ jsx(
|
|
35
|
-
Comp,
|
|
36
|
-
{
|
|
37
|
-
className: cn(buttonVariants({ variant, size, className })),
|
|
38
|
-
ref,
|
|
39
|
-
...props
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
);
|
|
44
|
-
Button.displayName = "Button";
|
|
45
|
-
export {
|
|
46
|
-
Button,
|
|
47
|
-
buttonVariants
|
|
48
|
-
};
|
|
49
|
-
//# sourceMappingURL=button.js.map
|