@tern-secure/nextjs 4.2.11 → 5.0.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.
Files changed (232) hide show
  1. package/README.md +33 -33
  2. package/dist/cjs/app-router/admin/index.js +5 -8
  3. package/dist/cjs/app-router/admin/index.js.map +1 -1
  4. package/dist/cjs/app-router/admin/sessionTernSecure.js +3 -6
  5. package/dist/cjs/app-router/admin/sessionTernSecure.js.map +1 -1
  6. package/dist/cjs/app-router/client/TernSecureProvider.js +10 -18
  7. package/dist/cjs/app-router/client/TernSecureProvider.js.map +1 -1
  8. package/dist/cjs/app-router/client/actions.js +1 -177
  9. package/dist/cjs/app-router/client/actions.js.map +1 -1
  10. package/dist/cjs/app-router/route-handler/internal-route.js +4 -35
  11. package/dist/cjs/app-router/route-handler/internal-route.js.map +1 -1
  12. package/dist/cjs/boundary/{hooks/useSignUp.js → components.js} +16 -16
  13. package/dist/cjs/boundary/components.js.map +1 -0
  14. package/dist/cjs/{lib/utils.js → boundary/hooks.js} +9 -11
  15. package/dist/cjs/boundary/hooks.js.map +1 -0
  16. package/dist/cjs/{boundary/TernSecureCtx.js → components/uiComponents.js} +17 -24
  17. package/dist/cjs/components/uiComponents.js.map +1 -0
  18. package/dist/cjs/errors.js +1 -0
  19. package/dist/cjs/errors.js.map +1 -1
  20. package/dist/cjs/index.js +13 -27
  21. package/dist/cjs/index.js.map +1 -1
  22. package/dist/cjs/server/auth.js +4 -5
  23. package/dist/cjs/server/auth.js.map +1 -1
  24. package/dist/cjs/server/crypto.js.map +1 -1
  25. package/dist/cjs/server/ctx-store.js +1 -2
  26. package/dist/cjs/server/ctx-store.js.map +1 -1
  27. package/dist/cjs/server/edge-session.js +6 -7
  28. package/dist/cjs/server/edge-session.js.map +1 -1
  29. package/dist/cjs/server/index.js.map +1 -1
  30. package/dist/cjs/server/jwt-edge.js.map +1 -1
  31. package/dist/cjs/server/jwt.js.map +1 -1
  32. package/dist/cjs/server/session-store.js +3 -1
  33. package/dist/cjs/server/session-store.js.map +1 -1
  34. package/dist/cjs/server/ternSecureMiddleware.js.map +1 -1
  35. package/dist/cjs/server/types.js.map +1 -1
  36. package/dist/cjs/server/utils.js.map +1 -1
  37. package/dist/cjs/types.js.map +1 -1
  38. package/dist/cjs/utils/admin-init.js +3 -0
  39. package/dist/cjs/utils/admin-init.js.map +1 -1
  40. package/dist/cjs/utils/allNextProviderProps.js +108 -0
  41. package/dist/cjs/utils/allNextProviderProps.js.map +1 -0
  42. package/dist/cjs/utils/client-init.js +2 -47
  43. package/dist/cjs/utils/client-init.js.map +1 -1
  44. package/dist/cjs/utils/config.js.map +1 -1
  45. package/dist/cjs/utils/construct.js.map +1 -1
  46. package/dist/cjs/utils/create-styles.js.map +1 -1
  47. package/dist/cjs/utils/redirect.js.map +1 -1
  48. package/dist/cjs/{components/ui/separator.js → utils/tern-ui-script.js} +41 -24
  49. package/dist/cjs/utils/tern-ui-script.js.map +1 -0
  50. package/dist/esm/app-router/admin/index.js +6 -4
  51. package/dist/esm/app-router/admin/index.js.map +1 -1
  52. package/dist/esm/app-router/admin/sessionTernSecure.js +3 -6
  53. package/dist/esm/app-router/admin/sessionTernSecure.js.map +1 -1
  54. package/dist/esm/app-router/client/TernSecureProvider.js +13 -19
  55. package/dist/esm/app-router/client/TernSecureProvider.js.map +1 -1
  56. package/dist/esm/app-router/client/actions.js +1 -157
  57. package/dist/esm/app-router/client/actions.js.map +1 -1
  58. package/dist/esm/app-router/route-handler/internal-route.js +5 -30
  59. package/dist/esm/app-router/route-handler/internal-route.js.map +1 -1
  60. package/dist/esm/boundary/components.js +18 -0
  61. package/dist/esm/boundary/components.js.map +1 -0
  62. package/dist/esm/boundary/hooks.js +9 -0
  63. package/dist/esm/boundary/hooks.js.map +1 -0
  64. package/dist/esm/components/uiComponents.js +21 -0
  65. package/dist/esm/components/uiComponents.js.map +1 -0
  66. package/dist/esm/errors.js +1 -0
  67. package/dist/esm/errors.js.map +1 -1
  68. package/dist/esm/index.js +15 -16
  69. package/dist/esm/index.js.map +1 -1
  70. package/dist/esm/server/auth.js +4 -5
  71. package/dist/esm/server/auth.js.map +1 -1
  72. package/dist/esm/server/crypto.js.map +1 -1
  73. package/dist/esm/server/ctx-store.js +1 -2
  74. package/dist/esm/server/ctx-store.js.map +1 -1
  75. package/dist/esm/server/edge-session.js +6 -7
  76. package/dist/esm/server/edge-session.js.map +1 -1
  77. package/dist/esm/server/index.js.map +1 -1
  78. package/dist/esm/server/jwt-edge.js.map +1 -1
  79. package/dist/esm/server/jwt.js.map +1 -1
  80. package/dist/esm/server/session-store.js +3 -1
  81. package/dist/esm/server/session-store.js.map +1 -1
  82. package/dist/esm/server/ternSecureMiddleware.js.map +1 -1
  83. package/dist/esm/server/utils.js.map +1 -1
  84. package/dist/esm/types.js.map +1 -1
  85. package/dist/esm/utils/admin-init.js +2 -0
  86. package/dist/esm/utils/admin-init.js.map +1 -1
  87. package/dist/esm/utils/allNextProviderProps.js +84 -0
  88. package/dist/esm/utils/allNextProviderProps.js.map +1 -0
  89. package/dist/esm/utils/client-init.js +2 -21
  90. package/dist/esm/utils/client-init.js.map +1 -1
  91. package/dist/esm/utils/config.js.map +1 -1
  92. package/dist/esm/utils/construct.js.map +1 -1
  93. package/dist/esm/utils/create-styles.js.map +1 -1
  94. package/dist/esm/utils/redirect.js.map +1 -1
  95. package/dist/esm/utils/tern-ui-script.js +42 -0
  96. package/dist/esm/utils/tern-ui-script.js.map +1 -0
  97. package/dist/types/app-router/admin/index.d.ts +1 -2
  98. package/dist/types/app-router/admin/index.d.ts.map +1 -1
  99. package/dist/types/app-router/client/TernSecureProvider.d.ts +2 -14
  100. package/dist/types/app-router/client/TernSecureProvider.d.ts.map +1 -1
  101. package/dist/types/app-router/client/actions.d.ts +1 -54
  102. package/dist/types/app-router/client/actions.d.ts.map +1 -1
  103. package/dist/types/app-router/route-handler/internal-route.d.ts +1 -15
  104. package/dist/types/app-router/route-handler/internal-route.d.ts.map +1 -1
  105. package/dist/types/boundary/components.d.ts +2 -0
  106. package/dist/types/boundary/components.d.ts.map +1 -0
  107. package/dist/types/boundary/hooks.d.ts +2 -0
  108. package/dist/types/boundary/hooks.d.ts.map +1 -0
  109. package/dist/types/components/uiComponents.d.ts +6 -0
  110. package/dist/types/components/uiComponents.d.ts.map +1 -0
  111. package/dist/types/errors.d.ts +1 -1
  112. package/dist/types/errors.d.ts.map +1 -1
  113. package/dist/types/index.d.ts +3 -9
  114. package/dist/types/index.d.ts.map +1 -1
  115. package/dist/types/server/ternSecureMiddleware.d.ts.map +1 -1
  116. package/dist/types/types.d.ts +6 -13
  117. package/dist/types/types.d.ts.map +1 -1
  118. package/dist/types/utils/admin-init.d.ts +2 -1
  119. package/dist/types/utils/admin-init.d.ts.map +1 -1
  120. package/dist/types/utils/allNextProviderProps.d.ts +6 -0
  121. package/dist/types/utils/allNextProviderProps.d.ts.map +1 -0
  122. package/dist/types/utils/client-init.d.ts +1 -4
  123. package/dist/types/utils/client-init.d.ts.map +1 -1
  124. package/dist/types/utils/config.d.ts +1 -1
  125. package/dist/types/utils/config.d.ts.map +1 -1
  126. package/dist/types/utils/construct.d.ts.map +1 -1
  127. package/dist/types/utils/tern-ui-script.d.ts +8 -0
  128. package/dist/types/utils/tern-ui-script.d.ts.map +1 -0
  129. package/package.json +41 -52
  130. package/dist/cjs/boundary/TernSecureClientProvider.js +0 -240
  131. package/dist/cjs/boundary/TernSecureClientProvider.js.map +0 -1
  132. package/dist/cjs/boundary/TernSecureCtx.js.map +0 -1
  133. package/dist/cjs/boundary/hooks/useAuth.js +0 -63
  134. package/dist/cjs/boundary/hooks/useAuth.js.map +0 -1
  135. package/dist/cjs/boundary/hooks/useSignUp.js.map +0 -1
  136. package/dist/cjs/components/background.js +0 -65
  137. package/dist/cjs/components/background.js.map +0 -1
  138. package/dist/cjs/components/sign-in.js +0 -368
  139. package/dist/cjs/components/sign-in.js.map +0 -1
  140. package/dist/cjs/components/sign-out-button.js +0 -84
  141. package/dist/cjs/components/sign-out-button.js.map +0 -1
  142. package/dist/cjs/components/sign-out.js +0 -99
  143. package/dist/cjs/components/sign-out.js.map +0 -1
  144. package/dist/cjs/components/sign-up.js +0 -332
  145. package/dist/cjs/components/sign-up.js.map +0 -1
  146. package/dist/cjs/components/ui/alert.js +0 -88
  147. package/dist/cjs/components/ui/alert.js.map +0 -1
  148. package/dist/cjs/components/ui/button.js +0 -84
  149. package/dist/cjs/components/ui/button.js.map +0 -1
  150. package/dist/cjs/components/ui/card.js +0 -101
  151. package/dist/cjs/components/ui/card.js.map +0 -1
  152. package/dist/cjs/components/ui/input.js +0 -58
  153. package/dist/cjs/components/ui/input.js.map +0 -1
  154. package/dist/cjs/components/ui/label.js +0 -55
  155. package/dist/cjs/components/ui/label.js.map +0 -1
  156. package/dist/cjs/components/ui/separator.js.map +0 -1
  157. package/dist/cjs/components/verify.js +0 -195
  158. package/dist/cjs/components/verify.js.map +0 -1
  159. package/dist/cjs/lib/utils.d.js +0 -17
  160. package/dist/cjs/lib/utils.d.js.map +0 -1
  161. package/dist/cjs/lib/utils.js.map +0 -1
  162. package/dist/esm/boundary/TernSecureClientProvider.js +0 -216
  163. package/dist/esm/boundary/TernSecureClientProvider.js.map +0 -1
  164. package/dist/esm/boundary/TernSecureCtx.js +0 -23
  165. package/dist/esm/boundary/TernSecureCtx.js.map +0 -1
  166. package/dist/esm/boundary/hooks/useAuth.js +0 -39
  167. package/dist/esm/boundary/hooks/useAuth.js.map +0 -1
  168. package/dist/esm/boundary/hooks/useSignUp.js +0 -16
  169. package/dist/esm/boundary/hooks/useSignUp.js.map +0 -1
  170. package/dist/esm/components/background.js +0 -41
  171. package/dist/esm/components/background.js.map +0 -1
  172. package/dist/esm/components/sign-in.js +0 -344
  173. package/dist/esm/components/sign-in.js.map +0 -1
  174. package/dist/esm/components/sign-out-button.js +0 -60
  175. package/dist/esm/components/sign-out-button.js.map +0 -1
  176. package/dist/esm/components/sign-out.js +0 -65
  177. package/dist/esm/components/sign-out.js.map +0 -1
  178. package/dist/esm/components/sign-up.js +0 -298
  179. package/dist/esm/components/sign-up.js.map +0 -1
  180. package/dist/esm/components/ui/alert.js +0 -52
  181. package/dist/esm/components/ui/alert.js.map +0 -1
  182. package/dist/esm/components/ui/button.js +0 -49
  183. package/dist/esm/components/ui/button.js.map +0 -1
  184. package/dist/esm/components/ui/card.js +0 -62
  185. package/dist/esm/components/ui/card.js.map +0 -1
  186. package/dist/esm/components/ui/input.js +0 -24
  187. package/dist/esm/components/ui/input.js.map +0 -1
  188. package/dist/esm/components/ui/label.js +0 -21
  189. package/dist/esm/components/ui/label.js.map +0 -1
  190. package/dist/esm/components/ui/separator.js +0 -25
  191. package/dist/esm/components/ui/separator.js.map +0 -1
  192. package/dist/esm/components/verify.js +0 -161
  193. package/dist/esm/components/verify.js.map +0 -1
  194. package/dist/esm/lib/utils.d.js +0 -1
  195. package/dist/esm/lib/utils.d.js.map +0 -1
  196. package/dist/esm/lib/utils.js +0 -9
  197. package/dist/esm/lib/utils.js.map +0 -1
  198. package/dist/types/boundary/TernSecureClientProvider.d.ts +0 -27
  199. package/dist/types/boundary/TernSecureClientProvider.d.ts.map +0 -1
  200. package/dist/types/boundary/TernSecureCtx.d.ts +0 -11
  201. package/dist/types/boundary/TernSecureCtx.d.ts.map +0 -1
  202. package/dist/types/boundary/hooks/useAuth.d.ts +0 -15
  203. package/dist/types/boundary/hooks/useAuth.d.ts.map +0 -1
  204. package/dist/types/boundary/hooks/useSignUp.d.ts +0 -5
  205. package/dist/types/boundary/hooks/useSignUp.d.ts.map +0 -1
  206. package/dist/types/components/background.d.ts +0 -2
  207. package/dist/types/components/background.d.ts.map +0 -1
  208. package/dist/types/components/sign-in.d.ts +0 -18
  209. package/dist/types/components/sign-in.d.ts.map +0 -1
  210. package/dist/types/components/sign-out-button.d.ts +0 -14
  211. package/dist/types/components/sign-out-button.d.ts.map +0 -1
  212. package/dist/types/components/sign-out.d.ts +0 -12
  213. package/dist/types/components/sign-out.d.ts.map +0 -1
  214. package/dist/types/components/sign-up.d.ts +0 -11
  215. package/dist/types/components/sign-up.d.ts.map +0 -1
  216. package/dist/types/components/ui/alert.d.ts +0 -9
  217. package/dist/types/components/ui/alert.d.ts.map +0 -1
  218. package/dist/types/components/ui/button.d.ts +0 -12
  219. package/dist/types/components/ui/button.d.ts.map +0 -1
  220. package/dist/types/components/ui/card.d.ts +0 -9
  221. package/dist/types/components/ui/card.d.ts.map +0 -1
  222. package/dist/types/components/ui/input.d.ts +0 -4
  223. package/dist/types/components/ui/input.d.ts.map +0 -1
  224. package/dist/types/components/ui/label.d.ts +0 -6
  225. package/dist/types/components/ui/label.d.ts.map +0 -1
  226. package/dist/types/components/ui/separator.d.ts +0 -5
  227. package/dist/types/components/ui/separator.d.ts.map +0 -1
  228. package/dist/types/components/verify.d.ts +0 -2
  229. package/dist/types/components/verify.d.ts.map +0 -1
  230. package/dist/types/lib/utils.d.ts +0 -3
  231. package/dist/types/lib/utils.d.ts.map +0 -1
  232. package/server/package.json +0 -5
@@ -1,368 +0,0 @@
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/admin/sessionTernSecure");
40
- var import_background = require("./background");
41
- var import_construct = require("../utils/construct");
42
- var import_internal_route = require("../app-router/route-handler/internal-route");
43
- var import_useAuth = require("../boundary/hooks/useAuth");
44
- var import_errors = require("../errors");
45
- const authDomain = process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN;
46
- const appName = process.env.NEXT_PUBLIC_FIREBASE_APP_NAME || "TernSecure";
47
- const prefix = (classes) => {
48
- return classes.split(" ").map((cls) => `tern-${cls}`).join(" ");
49
- };
50
- function SignIn({
51
- redirectUrl,
52
- onError,
53
- onSuccess,
54
- className,
55
- customStyles = {}
56
- }) {
57
- const [loading, setLoading] = (0, import_react.useState)(false);
58
- const [checkingRedirect, setCheckingRedirect] = (0, import_react.useState)(true);
59
- const [formError, setFormError] = (0, import_react.useState)(null);
60
- const [error, setError] = (0, import_react.useState)("");
61
- const [email, setEmail] = (0, import_react.useState)("");
62
- const [password, setPassword] = (0, import_react.useState)("");
63
- const [showPassword, setShowPassword] = (0, import_react.useState)(false);
64
- const [passwordFocused, setPasswordFocused] = (0, import_react.useState)(false);
65
- const [authResponse, setAuthResponse] = (0, import_react.useState)(null);
66
- const [authErrorMessage, setAuthErrorMessage] = (0, import_react.useState)(null);
67
- const searchParams = (0, import_navigation.useSearchParams)();
68
- const isRedirectSignIn = searchParams.get("signInRedirect") === "true";
69
- const router = (0, import_navigation.useRouter)();
70
- const pathname = (0, import_navigation.usePathname)();
71
- const InternalComponent = (0, import_internal_route.handleInternalRoute)(pathname || "");
72
- const { requiresVerification, error: authError, status } = (0, import_useAuth.useAuth)();
73
- const validRedirectUrl = (0, import_construct.getValidRedirectUrl)(searchParams, redirectUrl);
74
- if (InternalComponent) {
75
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(InternalComponent, {});
76
- }
77
- (0, import_react.useEffect)(() => {
78
- if (authError && status !== "loading" && status !== "unauthenticated") {
79
- const message = authError.message || "Authentication failed";
80
- setAuthErrorMessage(message);
81
- if (!authResponse || authResponse.message !== message) {
82
- setAuthResponse(authError);
83
- }
84
- } else {
85
- setAuthErrorMessage(null);
86
- }
87
- }, [authError, status, authResponse]);
88
- const handleSuccessfulAuth = (0, import_react.useCallback)(
89
- async (user) => {
90
- try {
91
- const idToken = await user.getIdToken();
92
- const sessionResult = await (0, import_sessionTernSecure.createSessionCookie)(idToken);
93
- if (!sessionResult.success) {
94
- setFormError({
95
- success: false,
96
- message: sessionResult.message || "Failed to create session",
97
- error: "INTERNAL_ERROR",
98
- user: null
99
- });
100
- }
101
- onSuccess == null ? void 0 : onSuccess();
102
- if (process.env.NODE_ENV === "production") {
103
- window.location.href = validRedirectUrl;
104
- } else {
105
- router.push(validRedirectUrl);
106
- }
107
- } catch (err) {
108
- setFormError({
109
- success: false,
110
- message: "Failed to complete authentication",
111
- error: "INTERNAL_ERROR",
112
- user: null
113
- });
114
- }
115
- },
116
- [validRedirectUrl, router, onSuccess]
117
- );
118
- const handleRedirectResult = (0, import_react.useCallback)(async () => {
119
- if (!isRedirectSignIn) return false;
120
- setCheckingRedirect(true);
121
- try {
122
- console.log("Checking redirect result...");
123
- console.log("Current hostname:", window.location.hostname);
124
- console.log("Auth domain hostname:", authDomain);
125
- const isOnAuth = authDomain && window.location.hostname === authDomain.replace(/https?:\/\//, "");
126
- console.log("Is on AuthDomain:", isOnAuth);
127
- const result = await (0, import_auth.getRedirectResult)(import_client_init.ternSecureAuth);
128
- console.log("Redirect result:", result);
129
- if (result) {
130
- const idToken = await result.user.getIdToken();
131
- const sessionResult = await (0, import_sessionTernSecure.createSessionCookie)(idToken);
132
- if (!sessionResult.success) {
133
- throw new Error("Failed to create session");
134
- }
135
- const storedRedirectUrl = sessionStorage.getItem("auth_return_url");
136
- sessionStorage.removeItem("auth_redirect_url");
137
- onSuccess == null ? void 0 : onSuccess();
138
- window.location.href = storedRedirectUrl || (0, import_construct.getValidRedirectUrl)(searchParams, redirectUrl);
139
- return true;
140
- }
141
- setCheckingRedirect(false);
142
- } catch (err) {
143
- const errorMessage = err;
144
- setFormError(errorMessage);
145
- if (onError && err instanceof Error) {
146
- onError(err);
147
- }
148
- sessionStorage.removeItem("auth_redirect_url");
149
- return false;
150
- }
151
- }, [isRedirectSignIn, redirectUrl, searchParams, onSuccess, onError]);
152
- (0, import_react.useEffect)(() => {
153
- if (isRedirectSignIn) {
154
- handleRedirectResult();
155
- }
156
- }, [handleRedirectResult, isRedirectSignIn]);
157
- const handleSubmit = async (e) => {
158
- e.preventDefault();
159
- setLoading(true);
160
- setFormError(null);
161
- setAuthResponse(null);
162
- try {
163
- const response = await (0, import_actions.signInWithEmail)(email, password);
164
- setAuthResponse(response);
165
- if (!response.success) {
166
- setFormError({
167
- success: false,
168
- message: response.message,
169
- error: response.error,
170
- user: null
171
- });
172
- return;
173
- }
174
- if (response.user) {
175
- if (requiresVerification && !response.user.emailVerified) {
176
- setFormError({
177
- success: false,
178
- message: "Email verification required",
179
- error: "REQUIRES_VERIFICATION",
180
- user: response.user
181
- });
182
- return;
183
- }
184
- await handleSuccessfulAuth(response.user);
185
- }
186
- } catch (err) {
187
- const errorMessage = err;
188
- setFormError(errorMessage);
189
- if (onError && err instanceof Error) {
190
- onError(err);
191
- }
192
- } finally {
193
- setLoading(false);
194
- }
195
- };
196
- const handleSocialSignIn = async (provider) => {
197
- setLoading(true);
198
- try {
199
- const validRedirectUrl2 = (0, import_construct.getValidRedirectUrl)(searchParams, redirectUrl);
200
- sessionStorage.setItem("auth_redirect_url", validRedirectUrl2);
201
- const currentUrl = new URL(window.location.href);
202
- currentUrl.searchParams.set("signInRedirect", "true");
203
- window.history.replaceState({}, "", currentUrl.toString());
204
- const result = provider === "google" ? await (0, import_actions.signInWithRedirectGoogle)() : await (0, import_actions.signInWithMicrosoft)();
205
- if (!result.success) {
206
- throw new Error(result.error);
207
- }
208
- } catch (err) {
209
- const errorMessage = err;
210
- setFormError(errorMessage);
211
- if (onError && err instanceof Error) {
212
- onError(err);
213
- }
214
- setLoading(false);
215
- sessionStorage.removeItem("auth_redirect_url");
216
- }
217
- };
218
- const handleVerificationRedirect = (e) => {
219
- e.preventDefault();
220
- router.push("/sign-in/verify");
221
- };
222
- if (checkingRedirect && isRedirectSignIn) {
223
- 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" }) }) });
224
- }
225
- const activeError = formError || authResponse;
226
- const showEmailVerificationButton = (activeError == null ? void 0 : activeError.error) === "EMAIL_NOT_VERIFIED" || (activeError == null ? void 0 : activeError.error) === "REQUIRES_VERIFICATION";
227
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "relative flex items-center justify-center", children: [
228
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_background.AuthBackground, {}),
229
- /* @__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: [
230
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_card.CardHeader, { className: "space-y-1 text-center", children: [
231
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_card.CardTitle, { className: (0, import_utils.cn)("font-bold", customStyles.title), children: [
232
- "Sign in to ",
233
- `${appName}`,
234
- " "
235
- ] }),
236
- /* @__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" })
237
- ] }),
238
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_card.CardContent, { className: "space-y-4", children: [
239
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { onSubmit: handleSubmit, className: "space-y-4", children: [
240
- activeError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_alert.Alert, { variant: (0, import_errors.getErrorAlertVariant)(activeError), className: "animate-in fade-in-50", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_alert.AlertDescription, { children: [
241
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: activeError.message }),
242
- showEmailVerificationButton && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
243
- import_button.Button,
244
- {
245
- type: "button",
246
- variant: "link",
247
- className: "p-0 h-auto font-normal text-sm hover:underline",
248
- onClick: handleVerificationRedirect,
249
- children: "Request new verification email \u2192"
250
- }
251
- )
252
- ] }) }),
253
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-2", children: [
254
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_label.Label, { htmlFor: "email", className: (0, import_utils.cn)(customStyles.label), children: "Email" }),
255
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
256
- import_input.Input,
257
- {
258
- id: "email",
259
- type: "email",
260
- placeholder: "m@example.com",
261
- value: email,
262
- onChange: (e) => setEmail(e.target.value),
263
- disabled: loading,
264
- className: (0, import_utils.cn)(customStyles.input),
265
- required: true,
266
- "aria-invalid": (activeError == null ? void 0 : activeError.error) === "INVALID_EMAIL",
267
- "aria-describedby": activeError ? "error-message" : void 0
268
- }
269
- )
270
- ] }),
271
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-2", children: [
272
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_label.Label, { htmlFor: "password", className: (0, import_utils.cn)(customStyles.label), children: "Password" }),
273
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "relative", children: [
274
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
275
- import_input.Input,
276
- {
277
- id: "password",
278
- name: "password",
279
- type: showPassword ? "text" : "password",
280
- value: password,
281
- onChange: (e) => setPassword(e.target.value),
282
- onFocus: () => setPasswordFocused(true),
283
- onBlur: () => setPasswordFocused(false),
284
- disabled: loading,
285
- className: (0, import_utils.cn)(customStyles.input),
286
- required: true,
287
- "aria-invalid": (activeError == null ? void 0 : activeError.error) === "INVALID_CREDENTIALS",
288
- "aria-describedby": activeError ? "error-message" : void 0
289
- }
290
- ),
291
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
292
- import_button.Button,
293
- {
294
- type: "button",
295
- variant: "ghost",
296
- size: "icon",
297
- className: "absolute right-2 top-1/2 -translate-y-1/2 h-8 w-8 hover:bg-transparent",
298
- onClick: () => setShowPassword(!showPassword),
299
- children: [
300
- showPassword ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.EyeOff, { className: "h-4 w-4 text-muted-foreground hover:text-foreground" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Eye, { className: "h-4 w-4 text-muted-foreground hover:text-foreground" }),
301
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only", children: showPassword ? "Hide password" : "Show password" })
302
- ]
303
- }
304
- )
305
- ] })
306
- ] }),
307
- /* @__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: [
308
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
309
- "Signing in..."
310
- ] }) : "Sign in" })
311
- ] }),
312
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "relative", children: [
313
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_separator.Separator, { className: (0, import_utils.cn)(customStyles.separator) }),
314
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "bg-background px-2 text-muted-foreground text-sm", children: "Or continue with" }) })
315
- ] }),
316
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
317
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
318
- import_button.Button,
319
- {
320
- variant: "outline",
321
- disabled: loading,
322
- onClick: () => handleSocialSignIn("google"),
323
- className: (0, import_utils.cn)("flex items-center justify-center", customStyles.socialButton),
324
- children: [
325
- /* @__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: [
326
- /* @__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" }),
327
- /* @__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" }),
328
- /* @__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" }),
329
- /* @__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" })
330
- ] }),
331
- "Google"
332
- ]
333
- }
334
- ),
335
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
336
- import_button.Button,
337
- {
338
- variant: "outline",
339
- disabled: loading,
340
- onClick: () => handleSocialSignIn("microsoft"),
341
- className: (0, import_utils.cn)("flex items-center justify-center", customStyles.socialButton),
342
- children: [
343
- /* @__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: [
344
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fill: "#f3f3f3", d: "M0 0h23v23H0z" }),
345
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fill: "#f35325", d: "M1 1h10v10H1z" }),
346
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fill: "#81bc06", d: "M12 1h10v10H12z" }),
347
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fill: "#05a6f0", d: "M1 12h10v10H1z" }),
348
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { fill: "#ffba08", d: "M12 12h10v10H12z" })
349
- ] }),
350
- "Microsoft"
351
- ]
352
- }
353
- )
354
- ] })
355
- ] }),
356
- /* @__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: [
357
- "Don't have an account?",
358
- " ",
359
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: "/sign-up", className: "text-primary hover:underline", children: "Sign up" })
360
- ] }) })
361
- ] })
362
- ] });
363
- }
364
- // Annotate the CommonJS export names for ESM import in node:
365
- 0 && (module.exports = {
366
- SignIn
367
- });
368
- //# sourceMappingURL=sign-in.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/components/sign-in.tsx"],"sourcesContent":["'use client'\n\nimport React, { useState, useCallback, useEffect } from 'react'\nimport { useSearchParams, useRouter, usePathname} from 'next/navigation'\nimport { signInWithEmail, signInWithRedirectGoogle, signInWithMicrosoft } from '../app-router/client/actions'\nimport { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from \"./ui/card\"\nimport { Input } from \"./ui/input\"\nimport { Label } from \"./ui/label\"\nimport { Button } from \"./ui/button\"\nimport { Alert, AlertDescription } from \"./ui/alert\"\nimport { Separator } from \"./ui/separator\"\nimport { cn } from \"../lib/utils\"\nimport { Loader2, Eye, EyeOff } from 'lucide-react'\nimport { getRedirectResult, User } from 'firebase/auth'\nimport { ternSecureAuth } from '../utils/client-init'\nimport { createSessionCookie } from '../app-router/admin/sessionTernSecure'\nimport { AuthBackground } from './background'\nimport { getValidRedirectUrl } from '../utils/construct'\nimport { handleInternalRoute } from '../app-router/route-handler/internal-route'\nimport type { SignInResponse } from '../types'\nimport { useAuth } from '../boundary/hooks/useAuth'\nimport { getErrorAlertVariant } from '../errors'\n\n\n\nconst authDomain = process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN;\nconst appName = process.env.NEXT_PUBLIC_FIREBASE_APP_NAME || 'TernSecure';\n\n\nexport interface SignInProps {\n redirectUrl?: string\n onError?: (error: Error) => void\n onSuccess?: () => void\n className?: string\n customStyles?: {\n card?: string\n input?: string\n button?: string\n label?: string\n separator?: string\n title?: string\n description?: string\n socialButton?: string\n }\n}\n\nconst prefix = (classes: string) => {\n return classes.split(' ').map(cls => `tern-${cls}`).join(' ')\n}\n\n\nexport function SignIn({\n redirectUrl,\n onError,\n onSuccess,\n className,\n customStyles = {}\n}: SignInProps) {\n const [loading, setLoading] = useState(false)\n const [checkingRedirect, setCheckingRedirect] = useState(true)\n const [formError, setFormError] = useState<SignInResponse | null>(null)\n const [error, setError] = useState('')\n const [email, setEmail] = useState('')\n const [password, setPassword] = useState('')\n const [showPassword, setShowPassword] = useState(false)\n const [passwordFocused, setPasswordFocused] = useState(false)\n const [authResponse, setAuthResponse] = useState<SignInResponse | null>(null)\n const [authErrorMessage, setAuthErrorMessage] = useState<string | null>(null)\n const searchParams = useSearchParams()\n const isRedirectSignIn = searchParams.get('signInRedirect') === 'true'\n const router = useRouter()\n const pathname = usePathname()\n const InternalComponent = handleInternalRoute(pathname || \"\")\n const { requiresVerification, error: authError, status } = useAuth()\n const validRedirectUrl = getValidRedirectUrl(searchParams, redirectUrl)\n\n\n if (InternalComponent) {\n return <InternalComponent />\n }\n\n useEffect(() => {\n if (authError && status !== \"loading\" && status !== \"unauthenticated\") {\n\n const message = authError.message || \"Authentication failed\"\n setAuthErrorMessage(message)\n\n if(!authResponse || authResponse.message !== message) {\n setAuthResponse(authError as SignInResponse)\n }\n } else {\n setAuthErrorMessage(null)\n }\n }, [authError, status, authResponse])\n\n const handleSuccessfulAuth = useCallback(\n async (user: User) => {\n try {\n const idToken = await user.getIdToken()\n const sessionResult = await createSessionCookie(idToken)\n\n if (!sessionResult.success) {\n setFormError({\n success: false, \n message: sessionResult.message || \"Failed to create session\", \n error: 'INTERNAL_ERROR', \n user: null\n })\n }\n\n onSuccess?.()\n\n // Use the finalRedirectUrl for navigation\n if (process.env.NODE_ENV === \"production\") {\n // Use window.location.href in production for a full page reload\n window.location.href = validRedirectUrl\n } else {\n // Use router.push in development\n router.push(validRedirectUrl)\n }\n } catch (err) {\n setFormError({\n success: false, \n message: \"Failed to complete authentication\", \n error: 'INTERNAL_ERROR', \n user: null\n })\n }\n },\n [validRedirectUrl, router, onSuccess],\n )\n\n\n const handleRedirectResult = useCallback(async () => {\n if (!isRedirectSignIn) return false\n setCheckingRedirect(true)\n try {\n console.log('Checking redirect result...');\n console.log('Current hostname:', window.location.hostname);\n console.log('Auth domain hostname:', authDomain);\n\n const isOnAuth = authDomain && \n window.location.hostname === authDomain.replace(/https?:\\/\\//, '');\n console.log('Is on AuthDomain:', isOnAuth);\n\n\n const result = await getRedirectResult(ternSecureAuth)\n console.log('Redirect result:', result);\n if (result) {\n const idToken = await result.user.getIdToken()\n const sessionResult = await createSessionCookie(idToken)\n if (!sessionResult.success) {\n throw new Error('Failed to create session')\n }\n const storedRedirectUrl = sessionStorage.getItem('auth_return_url')\n sessionStorage.removeItem('auth_redirect_url') \n onSuccess?.()\n window.location.href = storedRedirectUrl || getValidRedirectUrl(searchParams, redirectUrl)\n return true\n }\n setCheckingRedirect(false)\n } catch (err) { \n const errorMessage = err as SignInResponse\n setFormError(errorMessage)\n if (onError && err instanceof Error) {\n onError(err)\n }\n sessionStorage.removeItem('auth_redirect_url')\n return false\n }\n }, [isRedirectSignIn, redirectUrl, searchParams, onSuccess, onError])\n\n //const REDIRECT_TIMEOUT = 5000;\n\n useEffect(() => {\n if (isRedirectSignIn) {\n handleRedirectResult()\n }\n }, [handleRedirectResult, isRedirectSignIn])\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault()\n setLoading(true)\n setFormError(null)\n setAuthResponse(null)\n\n try {\n const response= await signInWithEmail(email, password)\n setAuthResponse(response)\n\n if (!response.success) {\n setFormError({\n success: false, \n message: response.message, \n error: response.error, \n user: null\n })\n return\n }\n\n if (response.user) {\n if(requiresVerification && !response.user.emailVerified) {\n setFormError({\n success: false, \n message: 'Email verification required', \n error: 'REQUIRES_VERIFICATION', \n user: response.user\n })\n return\n }\n\n await handleSuccessfulAuth(response.user)\n }\n } catch (err) {\n const errorMessage = err as SignInResponse\n setFormError(errorMessage)\n if (onError && err instanceof Error) {\n onError(err)\n }\n } finally {\n setLoading(false)\n }\n }\n\n const handleSocialSignIn = async (provider: 'google' | 'microsoft') => {\n setLoading(true)\n try {\n\n const validRedirectUrl = getValidRedirectUrl(searchParams, redirectUrl)\n sessionStorage.setItem('auth_redirect_url', validRedirectUrl)\n\n const currentUrl = new URL(window.location.href)\n currentUrl.searchParams.set('signInRedirect', 'true')\n window.history.replaceState({}, '', currentUrl.toString())\n\n const result = provider === 'google' ? await signInWithRedirectGoogle() : await signInWithMicrosoft()\n if (!result.success) {\n throw new Error(result.error)\n }\n } catch (err) {\n const errorMessage = err as SignInResponse\n setFormError(errorMessage)\n if (onError && err instanceof Error) {\n onError(err)\n }\n setLoading(false)\n sessionStorage.removeItem('auth_redirect_url')\n }\n }\n\n const handleVerificationRedirect = (e: React.MouseEvent) => {\n e.preventDefault()\n router.push(\"/sign-in/verify\")\n }\n\n\n if (checkingRedirect && isRedirectSignIn) {\n return (\n <div className=\"flex min-h-screen items-center justify-center\">\n <div className=\"text-center space-y-4\">\n <div className=\"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto\" />\n \n </div>\n </div>\n )\n }\n\n\nconst activeError = formError || authResponse\nconst showEmailVerificationButton =\n activeError?.error === \"EMAIL_NOT_VERIFIED\" || activeError?.error === \"REQUIRES_VERIFICATION\"\n\n return (\n <div className=\"relative flex items-center justify-center\">\n <AuthBackground />\n <Card className={cn(\"w-full max-w-md mx-auto mt-8\", className, customStyles.card)}>\n <CardHeader className=\"space-y-1 text-center\">\n <CardTitle className={cn(\"font-bold\", customStyles.title)}>Sign in to {`${appName}`} </CardTitle>\n <CardDescription className={cn(\"text-muted-foreground\", customStyles.description)}>\n Please sign in to continue\n </CardDescription>\n </CardHeader>\n <CardContent className=\"space-y-4\">\n <form onSubmit={handleSubmit} className=\"space-y-4\">\n {activeError && (\n <Alert variant={getErrorAlertVariant(activeError)} className=\"animate-in fade-in-50\">\n <AlertDescription>\n <span>{activeError.message}</span>\n {showEmailVerificationButton && (\n <Button\n type='button'\n variant=\"link\"\n className=\"p-0 h-auto font-normal text-sm hover:underline\"\n onClick={handleVerificationRedirect}\n >\n Request new verification email →\n </Button>\n )}\n </AlertDescription>\n </Alert>\n )}\n <div className=\"space-y-2\">\n <Label htmlFor=\"email\" className={cn(customStyles.label)}>Email</Label>\n <Input\n id=\"email\"\n type=\"email\"\n placeholder=\"m@example.com\"\n value={email}\n onChange={(e) => setEmail(e.target.value)}\n disabled={loading}\n className={cn(customStyles.input)}\n required\n aria-invalid={activeError?.error === \"INVALID_EMAIL\"}\n aria-describedby={activeError ? \"error-message\" : undefined}\n />\n </div>\n <div className=\"space-y-2\">\n <Label htmlFor=\"password\" className={cn(customStyles.label)}>Password</Label>\n <div className=\"relative\">\n <Input\n id=\"password\"\n name=\"password\"\n type={showPassword ? \"text\" : \"password\"}\n value={password}\n onChange={(e) => setPassword(e.target.value)}\n onFocus={() => setPasswordFocused(true)}\n onBlur={() => setPasswordFocused(false)}\n disabled={loading}\n className={cn(customStyles.input)}\n required\n aria-invalid={activeError?.error === \"INVALID_CREDENTIALS\"}\n aria-describedby={activeError ? \"error-message\" : undefined}\n />\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n className=\"absolute right-2 top-1/2 -translate-y-1/2 h-8 w-8 hover:bg-transparent\"\n onClick={() => setShowPassword(!showPassword)}\n >\n {showPassword ? (\n <EyeOff className=\"h-4 w-4 text-muted-foreground hover:text-foreground\" />\n ) : (\n <Eye className=\"h-4 w-4 text-muted-foreground hover:text-foreground\" />\n )}\n <span className=\"sr-only\">{showPassword ? \"Hide password\" : \"Show password\"}</span>\n </Button>\n </div>\n </div>\n <Button type=\"submit\" disabled={loading} className={cn(\"w-full\", customStyles.button)}>\n {loading ? (\n <>\n <Loader2 className=\"mr-2 h-4 w-4 animate-spin\" />\n Signing in...\n </>\n ) : (\n 'Sign in'\n )}\n </Button>\n </form>\n <div className=\"relative\">\n <Separator className={cn(customStyles.separator)} />\n <div className=\"absolute inset-0 flex items-center justify-center\">\n <span className=\"bg-background px-2 text-muted-foreground text-sm\">Or continue with</span>\n </div>\n </div>\n <div className=\"grid grid-cols-2 gap-4\">\n <Button \n variant=\"outline\" \n disabled={loading} \n onClick={() => handleSocialSignIn('google')} \n className={cn(\"flex items-center justify-center\", customStyles.socialButton)}\n >\n <svg className=\"w-5 h-5 mr-2\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\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\"/>\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\"/>\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\"/>\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\"/>\n </svg>\n Google\n </Button>\n <Button \n variant=\"outline\" \n disabled={loading} \n onClick={() => handleSocialSignIn('microsoft')} \n className={cn(\"flex items-center justify-center\", customStyles.socialButton)}\n >\n <svg className=\"w-5 h-5 mr-2\" viewBox=\"0 0 23 23\" xmlns=\"http://www.w3.org/2000/svg\">\n <path fill=\"#f3f3f3\" d=\"M0 0h23v23H0z\"/>\n <path fill=\"#f35325\" d=\"M1 1h10v10H1z\"/>\n <path fill=\"#81bc06\" d=\"M12 1h10v10H12z\"/>\n <path fill=\"#05a6f0\" d=\"M1 12h10v10H1z\"/>\n <path fill=\"#ffba08\" d=\"M12 12h10v10H12z\"/>\n </svg>\n Microsoft\n </Button>\n </div>\n </CardContent>\n <CardFooter className=\"flex justify-center\">\n <p className=\"text-sm text-muted-foreground\">\n Don&apos;t have an account?{' '}\n <a href=\"/sign-up\" className=\"text-primary hover:underline\">\n Sign up\n </a>\n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,GAAE,oBAAkB;AAAA,mBAC3C;AAAA,gBAAM;AAAA;AAAA;AAAA,UAER;AAAA,WACF;AAAA,SACF;AAAA,MACA,4CAAC,0BAAW,WAAU,uBACpB,uDAAC,OAAE,WAAU,iCAAgC;AAAA;AAAA,QACjB;AAAA,QAC1B,4CAAC,OAAE,MAAK,YAAW,WAAU,gCAA+B,qBAE5D;AAAA,SACF,GACF;AAAA,OACF;AAAA,KACA;AAEJ;","names":["validRedirectUrl"]}
@@ -1,84 +0,0 @@
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_out_button_exports = {};
21
- __export(sign_out_button_exports, {
22
- SignOutButton: () => SignOutButton
23
- });
24
- module.exports = __toCommonJS(sign_out_button_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_auth = require("firebase/auth");
29
- var import_button = require("./ui/button");
30
- var import_client_init = require("../utils/client-init");
31
- var import_sessionTernSecure = require("../app-router/admin/sessionTernSecure");
32
- var import_utils = require("../lib/utils");
33
- var import_construct = require("../utils/construct");
34
- function SignOutButton({
35
- children = "Sign out",
36
- onError,
37
- onSignOutSuccess,
38
- redirectPath,
39
- className,
40
- variant = "outline",
41
- size = "default",
42
- ...buttonProps
43
- }) {
44
- const pathname = (0, import_navigation.usePathname)();
45
- const router = (0, import_navigation.useRouter)();
46
- const [isLoading, setIsLoading] = (0, import_react.useState)(false);
47
- const loginPath = process.env.NEXT_PUBLIC_LOGIN_PATH || "/sign-in";
48
- const handleSignOut = async () => {
49
- setIsLoading(true);
50
- try {
51
- await (0, import_auth.signOut)(import_client_init.ternSecureAuth);
52
- await (0, import_sessionTernSecure.clearSessionCookie)();
53
- onSignOutSuccess == null ? void 0 : onSignOutSuccess();
54
- const loginUrl = (0, import_construct.constructUrlWithRedirect)(loginPath, pathname);
55
- if (process.env.NODE_ENV === "production") {
56
- window.location.href = loginUrl;
57
- } else {
58
- router.push(loginUrl);
59
- }
60
- } catch (error) {
61
- console.error("Sign out error:", error);
62
- onError == null ? void 0 : onError(error instanceof Error ? error : new Error("Failed to sign out"));
63
- } finally {
64
- setIsLoading(false);
65
- }
66
- };
67
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
68
- import_button.Button,
69
- {
70
- variant,
71
- size,
72
- onClick: handleSignOut,
73
- disabled: isLoading,
74
- className: (0, import_utils.cn)("", className),
75
- ...buttonProps,
76
- children: isLoading ? "Signing out..." : children
77
- }
78
- );
79
- }
80
- // Annotate the CommonJS export names for ESM import in node:
81
- 0 && (module.exports = {
82
- SignOutButton
83
- });
84
- //# sourceMappingURL=sign-out-button.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/components/sign-out-button.tsx"],"sourcesContent":["'use client'\n\nimport { useState } from 'react'\nimport { usePathname, useRouter } from 'next/navigation'\nimport { signOut } from 'firebase/auth'\nimport { Button, type ButtonProps } from './ui/button'\nimport { ternSecureAuth } from '../utils/client-init'\nimport { clearSessionCookie } from '../app-router/admin/sessionTernSecure'\nimport { cn } from '../lib/utils'\nimport { constructUrlWithRedirect } from '../utils/construct'\n\n\ntype SignOutCustomProps = {\n children?: React.ReactNode\n onError?: (error: Error) => void\n onSignOutSuccess?: () => void\n redirectPath?: string\n className?: string\n variant?: ButtonProps['variant']\n size?: ButtonProps['size']\n}\n\ntype SignOutProps = Omit<ButtonProps, 'onClick'> & SignOutCustomProps\n\nexport function SignOutButton({ \n children = 'Sign out', \n onError,\n onSignOutSuccess,\n redirectPath,\n className,\n variant = 'outline',\n size = 'default',\n ...buttonProps \n}: SignOutProps) {\n const pathname = usePathname()\n const router = useRouter()\n const [isLoading, setIsLoading] = useState(false)\n const loginPath = process.env.NEXT_PUBLIC_LOGIN_PATH || '/sign-in'\n\n const handleSignOut = async () => {\n setIsLoading(true)\n try {\n // Sign out from Firebase\n await signOut(ternSecureAuth)\n \n await clearSessionCookie()\n \n // Call success callback if provided\n onSignOutSuccess?.()\n\n // Construct login URL with redirect parameter\n const loginUrl = constructUrlWithRedirect(loginPath, pathname)\n\n // Use router for development and window.location for production\n if (process.env.NODE_ENV === \"production\") {\n window.location.href = loginUrl\n } else {\n router.push(loginUrl)\n }\n } catch (error) {\n console.error('Sign out error:', error)\n onError?.(error instanceof Error ? error : new Error('Failed to sign out'))\n } finally {\n setIsLoading(false)\n }\n }\n\n return (\n <Button\n variant={variant}\n size={size}\n onClick={handleSignOut}\n disabled={isLoading}\n className={cn(\"\", className)}\n {...buttonProps}\n >\n {isLoading ? 'Signing out...' : children}\n </Button>\n )\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoEI;AAlEJ,mBAAyB;AACzB,wBAAuC;AACvC,kBAAwB;AACxB,oBAAyC;AACzC,yBAA+B;AAC/B,+BAAmC;AACnC,mBAAmB;AACnB,uBAAyC;AAelC,SAAS,cAAc;AAAA,EAC5B,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,OAAO;AAAA,EACP,GAAG;AACL,GAAiB;AACf,QAAM,eAAW,+BAAY;AAC7B,QAAM,aAAS,6BAAU;AACzB,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,KAAK;AAChD,QAAM,YAAY,QAAQ,IAAI,0BAA0B;AAExD,QAAM,gBAAgB,YAAY;AAChC,iBAAa,IAAI;AACjB,QAAI;AAEF,gBAAM,qBAAQ,iCAAc;AAE5B,gBAAM,6CAAmB;AAGzB;AAGA,YAAM,eAAW,2CAAyB,WAAW,QAAQ;AAG7D,UAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,eAAO,SAAS,OAAO;AAAA,MACzB,OAAO;AACL,eAAO,KAAK,QAAQ;AAAA,MACtB;AAAA,IACF,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;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT,UAAU;AAAA,MACV,eAAW,iBAAG,IAAI,SAAS;AAAA,MAC1B,GAAG;AAAA,MAEH,sBAAY,mBAAmB;AAAA;AAAA,EAClC;AAEJ;","names":[]}
@@ -1,99 +0,0 @@
1
- "use strict";
2
- "use client";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var sign_out_exports = {};
31
- __export(sign_out_exports, {
32
- SignOut: () => SignOut
33
- });
34
- module.exports = __toCommonJS(sign_out_exports);
35
- var import_jsx_runtime = require("react/jsx-runtime");
36
- var import_react = require("react");
37
- var import_navigation = require("next/navigation");
38
- var import_auth = require("firebase/auth");
39
- var import_client_init = require("../utils/client-init");
40
- var import_sessionTernSecure = require("../app-router/admin/sessionTernSecure");
41
- var import_utils = require("../lib/utils");
42
- var import_link = __toESM(require("next/link"));
43
- var import_construct = require("../utils/construct");
44
- function SignOut({
45
- children = "Sign out",
46
- onError,
47
- onSignOutSuccess,
48
- className,
49
- activeClassName,
50
- disabled = false,
51
- redirectPath
52
- }) {
53
- const [isLoading, setIsLoading] = (0, import_react.useState)(false);
54
- const pathname = (0, import_navigation.usePathname)();
55
- const router = (0, import_navigation.useRouter)();
56
- const loginPath = process.env.NEXT_PUBLIC_LOGIN_PATH || "/sign-in";
57
- const handleSignOut = async (e) => {
58
- e.preventDefault();
59
- if (disabled || isLoading) return;
60
- setIsLoading(true);
61
- try {
62
- await (0, import_auth.signOut)(import_client_init.ternSecureAuth);
63
- await (0, import_sessionTernSecure.clearSessionCookie)();
64
- onSignOutSuccess == null ? void 0 : onSignOutSuccess();
65
- const loginUrl = (0, import_construct.constructUrlWithRedirect)(loginPath, pathname);
66
- if (process.env.NODE_ENV === "production") {
67
- window.location.href = loginUrl;
68
- } else {
69
- router.push(loginUrl);
70
- }
71
- } catch (error) {
72
- console.error("Sign out error:", error);
73
- onError == null ? void 0 : onError(error instanceof Error ? error : new Error("Failed to sign out"));
74
- } finally {
75
- setIsLoading(false);
76
- }
77
- };
78
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
79
- import_link.default,
80
- {
81
- href: "#",
82
- onClick: handleSignOut,
83
- className: (0, import_utils.cn)(
84
- "text-sm font-medium transition-colors hover:text-primary",
85
- disabled && "pointer-events-none opacity-50",
86
- isLoading && "pointer-events-none",
87
- className,
88
- isLoading && activeClassName
89
- ),
90
- "aria-disabled": disabled || isLoading,
91
- children: isLoading ? "Signing out..." : children
92
- }
93
- );
94
- }
95
- // Annotate the CommonJS export names for ESM import in node:
96
- 0 && (module.exports = {
97
- SignOut
98
- });
99
- //# sourceMappingURL=sign-out.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/components/sign-out.tsx"],"sourcesContent":["'use client'\n\nimport { useState } from 'react'\nimport { usePathname, useRouter } from 'next/navigation'\nimport { signOut } from 'firebase/auth'\nimport { ternSecureAuth } from '../utils/client-init'\nimport { clearSessionCookie } from '../app-router/admin/sessionTernSecure'\nimport { cn } from '../lib/utils'\nimport Link from 'next/link'\nimport { constructUrlWithRedirect } from '../utils/construct'\n\n\ninterface SignOutLinkProps {\n children?: React.ReactNode\n onError?: (error: Error) => void\n onSignOutSuccess?: () => void\n className?: string\n activeClassName?: string\n disabled?: boolean\n redirectPath?: string\n}\n\nexport function SignOut({\n children = 'Sign out',\n onError,\n onSignOutSuccess,\n className,\n activeClassName,\n disabled = false,\n redirectPath,\n}: SignOutLinkProps) {\n const [isLoading, setIsLoading] = useState(false)\n const pathname = usePathname()\n const router = useRouter()\n const loginPath = process.env.NEXT_PUBLIC_LOGIN_PATH || \"/sign-in\"\n\n const handleSignOut = async (e: React.MouseEvent<HTMLAnchorElement>) => {\n e.preventDefault()\n if (disabled || isLoading) return\n\n setIsLoading(true)\n try {\n // Sign out from Firebase\n await signOut(ternSecureAuth)\n\n // Clear the session cookie\n await clearSessionCookie()\n\n // Call success callback if provided\n onSignOutSuccess?.()\n\n // Construct login URL with redirect parameter\n const loginUrl = constructUrlWithRedirect(loginPath, pathname)\n\n // Use router for development and window.location for production\n if (process.env.NODE_ENV === \"production\") {\n window.location.href = loginUrl\n } else {\n router.push(loginUrl)\n }\n } catch (error) {\n console.error('Sign out error:', error)\n onError?.(error instanceof Error ? error : new Error('Failed to sign out'))\n } finally {\n setIsLoading(false)\n }\n }\n\n return (\n <Link\n href=\"#\"\n onClick={handleSignOut}\n className={cn(\n 'text-sm font-medium transition-colors hover:text-primary',\n disabled && 'pointer-events-none opacity-50',\n isLoading && 'pointer-events-none',\n className,\n isLoading && activeClassName\n )}\n aria-disabled={disabled || isLoading}\n >\n {isLoading ? 'Signing out...' : children}\n </Link>\n )\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqEI;AAnEJ,mBAAyB;AACzB,wBAAuC;AACvC,kBAAwB;AACxB,yBAA+B;AAC/B,+BAAmC;AACnC,mBAAmB;AACnB,kBAAiB;AACjB,uBAAyC;AAalC,SAAS,QAAQ;AAAA,EACtB,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AACF,GAAqB;AACnB,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,KAAK;AAChD,QAAM,eAAW,+BAAY;AAC7B,QAAM,aAAS,6BAAU;AACzB,QAAM,YAAY,QAAQ,IAAI,0BAA0B;AAExD,QAAM,gBAAgB,OAAO,MAA2C;AACtE,MAAE,eAAe;AACjB,QAAI,YAAY,UAAW;AAE3B,iBAAa,IAAI;AACjB,QAAI;AAEF,gBAAM,qBAAQ,iCAAc;AAG5B,gBAAM,6CAAmB;AAGzB;AAGA,YAAM,eAAW,2CAAyB,WAAW,QAAQ;AAG7D,UAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,eAAO,SAAS,OAAO;AAAA,MACzB,OAAO;AACL,eAAO,KAAK,QAAQ;AAAA,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