@insforge/nextjs 0.4.0 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,10 +1,24 @@
1
1
  "use client";
2
2
 
3
- // src/provider/AuthProvider.tsx
3
+ // src/provider/InsforgeProvider.tsx
4
4
  import { createContext, useContext, useEffect, useState, useCallback, useRef } from "react";
5
5
  import { createClient } from "@insforge/sdk";
6
6
  import { jsx } from "react/jsx-runtime";
7
- var AuthContext = createContext(void 0);
7
+ var InsforgeContext = createContext(void 0);
8
+ async function fetchOAuthProviders(baseUrl) {
9
+ try {
10
+ const response = await fetch(`${baseUrl}/api/auth/oauth/configs`);
11
+ if (!response.ok) return [];
12
+ const result = await response.json();
13
+ if (result?.data && Array.isArray(result.data)) {
14
+ return result.data.map((config) => config.provider);
15
+ }
16
+ return [];
17
+ } catch (error) {
18
+ console.warn("Failed to fetch OAuth configs:", error);
19
+ return [];
20
+ }
21
+ }
8
22
  function getTokenFromSDK() {
9
23
  if (typeof window === "undefined") return null;
10
24
  try {
@@ -34,12 +48,26 @@ async function syncTokenToCookie(token) {
34
48
  return false;
35
49
  }
36
50
  }
37
- function AuthProvider({ children, baseUrl, onAuthChange }) {
51
+ function InsforgeProvider({
52
+ children,
53
+ baseUrl,
54
+ onAuthChange
55
+ }) {
38
56
  const [user, setUser] = useState(null);
39
57
  const [session, setSession] = useState(null);
40
58
  const [isLoaded, setIsLoaded] = useState(false);
59
+ const [oauthProviders, setOauthProviders] = useState([]);
60
+ const [isConfigLoaded, setIsConfigLoaded] = useState(false);
41
61
  const refreshIntervalRef = useRef();
42
- const insforge = useRef(createClient({ baseUrl })).current;
62
+ const [insforge] = useState(() => createClient({ baseUrl }));
63
+ useEffect(() => {
64
+ async function loadConfig() {
65
+ const providers = await fetchOAuthProviders(baseUrl);
66
+ setOauthProviders(providers);
67
+ setIsConfigLoaded(true);
68
+ }
69
+ loadConfig();
70
+ }, [baseUrl]);
43
71
  const loadAuthState = useCallback(async () => {
44
72
  try {
45
73
  const token = getTokenFromSDK();
@@ -137,10 +165,14 @@ function AuthProvider({ children, baseUrl, onAuthChange }) {
137
165
  try {
138
166
  await syncTokenToCookie(sdkResult.data.accessToken);
139
167
  } catch (error) {
168
+ console.error("Please add /api/auth route to your server to sync token to cookie:", error);
140
169
  }
170
+ } else {
171
+ const errorMessage = sdkResult.error?.message || "Invalid email or password";
172
+ throw new Error(errorMessage);
141
173
  }
142
174
  },
143
- [baseUrl, onAuthChange, insforge]
175
+ [insforge, onAuthChange]
144
176
  );
145
177
  const signUp = useCallback(
146
178
  async (email, password) => {
@@ -168,9 +200,12 @@ function AuthProvider({ children, baseUrl, onAuthChange }) {
168
200
  await syncTokenToCookie(sdkResult.data.accessToken);
169
201
  } catch (error) {
170
202
  }
203
+ } else {
204
+ const errorMessage = sdkResult.error?.message || "Sign up failed";
205
+ throw new Error(errorMessage);
171
206
  }
172
207
  },
173
- [baseUrl, onAuthChange, insforge]
208
+ [insforge, onAuthChange]
174
209
  );
175
210
  const signOut = useCallback(async () => {
176
211
  await insforge.auth.signOut();
@@ -184,7 +219,7 @@ function AuthProvider({ children, baseUrl, onAuthChange }) {
184
219
  if (onAuthChange) {
185
220
  onAuthChange(null);
186
221
  }
187
- }, [baseUrl, onAuthChange, insforge]);
222
+ }, [insforge, onAuthChange]);
188
223
  const updateUser = useCallback(
189
224
  async (data) => {
190
225
  if (!user) throw new Error("No user signed in");
@@ -199,10 +234,64 @@ function AuthProvider({ children, baseUrl, onAuthChange }) {
199
234
  },
200
235
  [user, onAuthChange, insforge]
201
236
  );
237
+ const sendVerificationCode = useCallback(
238
+ async (email, type) => {
239
+ console.log(`[Verification] Sending ${type} code to ${email}`);
240
+ console.log("[Verification] Dummy code: 123456");
241
+ await new Promise((resolve) => setTimeout(resolve, 500));
242
+ },
243
+ [insforge]
244
+ );
245
+ const verifySignUpCode = useCallback(
246
+ async (email, password, code) => {
247
+ if (code !== "123456") {
248
+ throw new Error("Invalid verification code");
249
+ }
250
+ const sdkResult = await insforge.auth.signUp({ email, password });
251
+ if (sdkResult.data) {
252
+ const userData = {
253
+ id: sdkResult.data.user.id,
254
+ email: sdkResult.data.user.email,
255
+ name: sdkResult.data.user.name || void 0,
256
+ createdAt: sdkResult.data.user.createdAt,
257
+ updatedAt: sdkResult.data.user.updatedAt
258
+ };
259
+ const sessionData = {
260
+ userId: sdkResult.data.user.id,
261
+ token: sdkResult.data.accessToken,
262
+ expiresAt: "",
263
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
264
+ };
265
+ setUser(userData);
266
+ setSession(sessionData);
267
+ if (onAuthChange) {
268
+ onAuthChange(userData);
269
+ }
270
+ try {
271
+ await syncTokenToCookie(sdkResult.data.accessToken);
272
+ } catch (error) {
273
+ }
274
+ } else {
275
+ const errorMessage = sdkResult.error?.message || "Sign up failed";
276
+ throw new Error(errorMessage);
277
+ }
278
+ },
279
+ [insforge, onAuthChange]
280
+ );
281
+ const verifySignInCode = useCallback(
282
+ async (email, code) => {
283
+ if (code !== "123456") {
284
+ throw new Error("Invalid verification code");
285
+ }
286
+ throw new Error("Passwordless sign in via verification code is not yet implemented in the backend");
287
+ },
288
+ [insforge, onAuthChange]
289
+ );
202
290
  return /* @__PURE__ */ jsx(
203
- AuthContext.Provider,
291
+ InsforgeContext.Provider,
204
292
  {
205
293
  value: {
294
+ // Auth
206
295
  user,
207
296
  session,
208
297
  isLoaded,
@@ -210,132 +299,338 @@ function AuthProvider({ children, baseUrl, onAuthChange }) {
210
299
  signIn,
211
300
  signUp,
212
301
  signOut,
213
- updateUser
214
- },
215
- children
216
- }
217
- );
218
- }
219
- function useAuthContext() {
220
- const context = useContext(AuthContext);
221
- if (!context) {
222
- throw new Error("useAuthContext must be used within AuthProvider");
223
- }
224
- return context;
225
- }
226
-
227
- // src/provider/InsforgeConfigProvider.tsx
228
- import { createContext as createContext2, useContext as useContext2, useEffect as useEffect2, useState as useState2 } from "react";
229
- import { jsx as jsx2 } from "react/jsx-runtime";
230
- var InsforgeConfigContext = createContext2(void 0);
231
- async function fetchBackendConfig(baseUrl) {
232
- try {
233
- const response = await fetch(`${baseUrl}/api/auth/config`);
234
- if (!response.ok) {
235
- return [];
236
- }
237
- const config = await response.json();
238
- if (config?.oauth?.providers && Array.isArray(config.oauth.providers)) {
239
- return config.oauth.providers.filter((p) => p.enabled).map((p) => p.provider);
240
- }
241
- return [];
242
- } catch (error) {
243
- return [];
244
- }
245
- }
246
- function InsforgeConfigProvider({ children, baseUrl }) {
247
- const [oauthProviders, setOauthProviders] = useState2([]);
248
- const [isLoaded, setIsLoaded] = useState2(false);
249
- const fetchConfig = async () => {
250
- const providers = await fetchBackendConfig(baseUrl);
251
- setOauthProviders(providers);
252
- setIsLoaded(true);
253
- };
254
- useEffect2(() => {
255
- fetchConfig();
256
- }, [baseUrl]);
257
- const refetch = async () => {
258
- setIsLoaded(false);
259
- await fetchConfig();
260
- };
261
- return /* @__PURE__ */ jsx2(
262
- InsforgeConfigContext.Provider,
263
- {
264
- value: {
302
+ updateUser,
303
+ // Verification
304
+ sendVerificationCode,
305
+ verifySignUpCode,
306
+ verifySignInCode,
307
+ // Config
265
308
  oauthProviders,
266
- isLoaded,
267
- refetch
309
+ isConfigLoaded,
310
+ // Base
311
+ baseUrl
268
312
  },
269
313
  children
270
314
  }
271
315
  );
272
316
  }
273
- function useInsforgeConfig() {
274
- const context = useContext2(InsforgeConfigContext);
317
+ function useInsforge() {
318
+ const context = useContext(InsforgeContext);
275
319
  if (!context) {
276
- throw new Error("useInsforgeConfig must be used within InsforgeConfigProvider");
320
+ throw new Error("useInsforge must be used within InsforgeProvider");
277
321
  }
278
322
  return context;
279
323
  }
280
324
 
281
325
  // src/hooks/useAuth.ts
282
326
  function useAuth() {
283
- return useAuthContext();
327
+ const { signIn, signUp, signOut, isLoaded, isSignedIn } = useInsforge();
328
+ return { signIn, signUp, signOut, isLoaded, isSignedIn };
284
329
  }
285
330
 
286
331
  // src/hooks/useUser.ts
287
332
  function useUser() {
288
- const { user, isLoaded } = useAuthContext();
289
- return { user, isLoaded };
333
+ const { user, isLoaded, updateUser } = useInsforge();
334
+ return { user, isLoaded, updateUser };
290
335
  }
291
336
 
292
337
  // src/hooks/useSession.ts
293
338
  function useSession() {
294
- const { session, isLoaded, isSignedIn } = useAuthContext();
295
- return { session, isLoaded, isSignedIn };
339
+ const { session, isLoaded } = useInsforge();
340
+ return { session, isLoaded };
296
341
  }
297
342
 
298
343
  // src/hooks/useOAuthProviders.ts
299
344
  function useOAuthProviders() {
300
- const { oauthProviders } = useInsforgeConfig();
301
- return oauthProviders;
345
+ const { oauthProviders, isConfigLoaded } = useInsforge();
346
+ return { providers: oauthProviders, isLoaded: isConfigLoaded };
302
347
  }
303
348
 
304
349
  // src/components/SignIn.tsx
305
350
  import { useState as useState3 } from "react";
306
- import Link from "next/link";
307
351
  import { createClient as createClient2 } from "@insforge/sdk";
308
- import { AlertTriangle, Eye, EyeOff, Loader2 as Loader22 } from "lucide-react";
309
352
 
310
- // src/components/OAuthButton.tsx
311
- import { Loader2 } from "lucide-react";
312
- import { jsx as jsx3, jsxs } from "react/jsx-runtime";
313
- var providerConfig = {
353
+ // src/components/auth/AuthBranding.tsx
354
+ import Link from "next/link";
355
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
356
+ function AuthBranding({ text = "Secured by", href = "https://insforge.dev" }) {
357
+ return /* @__PURE__ */ jsxs("div", { className: "insforge-branding", children: [
358
+ /* @__PURE__ */ jsx2("p", { className: "insforge-branding-text", children: text }),
359
+ /* @__PURE__ */ jsx2(Link, { href, target: "_blank", rel: "noopener noreferrer", children: /* @__PURE__ */ jsxs("svg", { width: "83", height: "20", viewBox: "0 0 83 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
360
+ /* @__PURE__ */ jsx2(
361
+ "path",
362
+ {
363
+ d: "M2.16783 8.46797C1.9334 8.23325 1.9334 7.85269 2.16783 7.61797L8.11049 1.66797L16.6 1.66797L6.41259 11.868C6.17815 12.1027 5.79807 12.1027 5.56363 11.868L2.16783 8.46797Z",
364
+ fill: "url(#paint0_linear_2976_9475)"
365
+ }
366
+ ),
367
+ /* @__PURE__ */ jsx2(
368
+ "path",
369
+ {
370
+ d: "M12.8858 6.44922L16.6 10.168V18.668L8.64108 10.6992L12.8858 6.44922Z",
371
+ fill: "url(#paint1_linear_2976_9475)"
372
+ }
373
+ ),
374
+ /* @__PURE__ */ jsx2(
375
+ "path",
376
+ {
377
+ d: "M67.5439 6.48828C68.2894 6.48828 68.9145 6.67064 69.418 7.03516C69.5229 7.10943 69.6214 7.1907 69.7158 7.27637V6.70703H71.248V14.959C71.248 15.1583 71.2381 15.3485 71.2188 15.5283C71.2042 15.7129 71.1774 15.8925 71.1387 16.0674C71.0225 16.5776 70.7998 16.9957 70.4707 17.3213C70.1415 17.6518 69.7321 17.8972 69.2432 18.0576C68.7592 18.2179 68.2222 18.2988 67.6318 18.2988C67.1962 18.2988 66.7768 18.2308 66.375 18.0947C65.9782 17.9587 65.6202 17.7614 65.3008 17.5039C64.9813 17.2512 64.7199 16.9446 64.5166 16.585L66.1289 15.7832C66.2789 16.0698 66.4888 16.2819 66.7598 16.418C67.0356 16.5589 67.3289 16.6289 67.6387 16.6289C68.0016 16.6289 68.3258 16.5628 68.6113 16.4316C68.8969 16.3053 69.1176 16.116 69.2725 15.8633C69.4321 15.6155 69.5077 15.3047 69.498 14.9307V14.1797C69.4665 14.2037 69.4359 14.229 69.4033 14.252C68.8855 14.6164 68.2441 14.7988 67.4795 14.7988C66.7582 14.7988 66.1281 14.6165 65.5908 14.252C65.0537 13.8875 64.637 13.3915 64.3418 12.7646C64.0467 12.1378 63.8994 11.4307 63.8994 10.6436C63.8994 9.84651 64.0465 9.13673 64.3418 8.51465C64.6419 7.88768 65.0663 7.39481 65.6133 7.03516C66.1601 6.67077 66.8036 6.48836 67.5439 6.48828ZM37.5 6.48828C38.1099 6.48828 38.6496 6.58294 39.1191 6.77246C39.5935 6.96201 39.9762 7.2321 40.2666 7.58203C40.5569 7.93184 40.7359 8.34227 40.8037 8.81348L39.0176 9.13477C38.974 8.79951 38.8218 8.53424 38.5605 8.33984C38.304 8.14547 37.96 8.03605 37.5293 8.01172C37.1178 7.98742 36.7859 8.05051 36.5342 8.20117C36.2825 8.34698 36.1562 8.55398 36.1562 8.82129C36.1563 8.97184 36.208 9.10017 36.3096 9.20703C36.4112 9.31394 36.614 9.42141 36.9189 9.52832C37.2288 9.63524 37.6889 9.76635 38.2988 9.92188C38.9232 10.0823 39.4222 10.2666 39.7949 10.4756C40.1722 10.6796 40.4428 10.9254 40.6074 11.2119C40.7768 11.4987 40.8623 11.8466 40.8623 12.2549C40.8623 13.047 40.574 13.6691 39.998 14.1211C39.4268 14.5731 38.6348 14.7988 37.623 14.7988C36.6551 14.7988 35.8687 14.5799 35.2637 14.1426C34.6587 13.7052 34.2909 13.0908 34.1602 12.2988L35.9463 12.0215C36.0383 12.4102 36.2411 12.7169 36.5557 12.9404C36.8703 13.164 37.2678 13.2754 37.7471 13.2754C38.1681 13.2754 38.4922 13.1926 38.7197 13.0273C38.9521 12.8572 39.0684 12.6266 39.0684 12.335C39.0684 12.1552 39.0245 12.0122 38.9375 11.9053C38.8552 11.7935 38.6713 11.686 38.3857 11.584C38.1001 11.4819 37.6618 11.3528 37.0713 11.1973C36.4131 11.0223 35.8901 10.8359 35.5029 10.6367C35.1158 10.4327 34.8374 10.192 34.668 9.91504C34.4985 9.63801 34.4141 9.30188 34.4141 8.9082C34.4141 8.41746 34.5423 7.98943 34.7988 7.625C35.0553 7.26073 35.4135 6.98146 35.873 6.78711C36.3329 6.58784 36.8755 6.48828 37.5 6.48828ZM53.3047 6.48828C54.0937 6.48828 54.7815 6.66572 55.3672 7.02051C55.9527 7.37528 56.4072 7.86634 56.7314 8.49316C57.0558 9.11525 57.2187 9.83193 57.2188 10.6436C57.2188 11.46 57.0537 12.1817 56.7246 12.8086C56.4003 13.4307 55.9451 13.9196 55.3594 14.2744C54.7737 14.6242 54.0888 14.7988 53.3047 14.7988C52.5205 14.7988 51.8357 14.6214 51.25 14.2666C50.6643 13.9118 50.2091 13.4238 49.8848 12.8018C49.5653 12.1748 49.4053 11.4552 49.4053 10.6436C49.4053 9.81735 49.5703 9.09279 49.8994 8.4707C50.2286 7.8488 50.6859 7.36255 51.2715 7.0127C51.8572 6.66281 52.5351 6.48828 53.3047 6.48828ZM76.7471 6.48828C77.5603 6.48828 78.25 6.68053 78.8164 7.06445C79.3876 7.44351 79.812 7.97991 80.0879 8.6748C80.3638 9.36976 80.4672 10.189 80.3994 11.1318H74.7256C74.7843 11.6972 74.949 12.1516 75.2227 12.4951C75.5711 12.9325 76.0792 13.1513 76.7471 13.1514C77.1779 13.1514 77.5486 13.0567 77.8584 12.8672C78.173 12.6728 78.4146 12.3928 78.584 12.0283L80.3125 12.5537C80.0124 13.2633 79.5473 13.8153 78.918 14.209C78.2936 14.6025 77.6036 14.7988 76.8486 14.7988C76.0549 14.7988 75.358 14.6263 74.7578 14.2812C74.1576 13.9362 73.6875 13.458 73.3486 12.8457C73.0147 12.2334 72.8477 11.5284 72.8477 10.7314C72.8477 9.87126 73.0127 9.12495 73.3418 8.49316C73.671 7.85651 74.1282 7.36263 74.7139 7.0127C75.2995 6.6628 75.9775 6.48832 76.7471 6.48828ZM23.3301 14.5801H21.5801V4.08203H23.3301V14.5801ZM29.6152 6.48047C30.1959 6.48052 30.6753 6.5781 31.0527 6.77246C31.4301 6.96681 31.7305 7.21443 31.9531 7.51562C32.1758 7.81695 32.3398 8.13831 32.4463 8.47852C32.5528 8.81873 32.6213 9.14205 32.6504 9.44824C32.6843 9.74946 32.7012 9.99508 32.7012 10.1846V14.5801H30.9287V10.7891C30.9287 10.5413 30.9118 10.2669 30.8779 9.96582C30.844 9.66449 30.7645 9.37469 30.6387 9.09766C30.5177 8.81592 30.3337 8.58503 30.0869 8.40527C29.8449 8.22551 29.5157 8.13579 29.0996 8.13574C28.8769 8.13574 28.6563 8.17221 28.4385 8.24512C28.2206 8.31802 28.0219 8.4442 27.8428 8.62402C27.6685 8.79899 27.5284 9.04249 27.4219 9.35352C27.3154 9.65965 27.2617 10.0532 27.2617 10.5342V14.5801H25.4902V6.70703H27.0518V7.58301C27.2521 7.34675 27.486 7.14172 27.7559 6.96973C28.2593 6.64409 28.8794 6.48047 29.6152 6.48047ZM48.748 5.83887H44.2021V8.45605H47.876V10.2061H44.2021V14.5801H42.4521V4.08203H48.748V5.83887ZM62.5137 6.67773C62.7606 6.65829 63.001 6.66815 63.2334 6.70703V8.34766C63.001 8.27961 62.7317 8.25695 62.4268 8.28125C62.1267 8.30557 61.8553 8.39134 61.6133 8.53711C61.3715 8.66829 61.1733 8.83606 61.0186 9.04004C60.8686 9.24404 60.7572 9.47701 60.6846 9.73926C60.612 9.99685 60.5752 10.2768 60.5752 10.5781V14.5801H58.8184V6.70703H60.3652V7.96582C60.4243 7.85986 60.4888 7.75824 60.5605 7.66211C60.7251 7.4434 60.9219 7.26302 61.1494 7.12207C61.3429 6.99098 61.5559 6.88926 61.7881 6.81641C62.0251 6.73869 62.267 6.69235 62.5137 6.67773ZM67.8057 8.0625C67.3362 8.06252 66.9485 8.17982 66.6436 8.41309C66.3389 8.64144 66.1139 8.95232 65.9688 9.3457C65.8235 9.7345 65.751 10.1673 65.751 10.6436C65.751 11.1247 65.8215 11.5624 65.9619 11.9561C66.1071 12.3447 66.3269 12.6535 66.6221 12.8818C66.9174 13.1103 67.293 13.2246 67.748 13.2246C68.2174 13.2246 68.5953 13.1171 68.8809 12.9033C69.1711 12.6846 69.3811 12.3808 69.5117 11.9922C69.6473 11.6034 69.7158 11.1539 69.7158 10.6436C69.7158 10.1284 69.6473 9.67886 69.5117 9.29492C69.381 8.90617 69.1753 8.60445 68.8945 8.39062C68.6138 8.17213 68.2508 8.0625 67.8057 8.0625ZM53.3047 8.13574C52.8351 8.13574 52.4475 8.24222 52.1426 8.45605C51.8425 8.66504 51.6198 8.95977 51.4746 9.33887C51.3295 9.71303 51.2568 10.148 51.2568 10.6436C51.2568 11.4066 51.4288 12.0168 51.7725 12.4736C52.121 12.9256 52.6318 13.1514 53.3047 13.1514C54.0017 13.1514 54.5196 12.9177 54.8584 12.4512C55.1971 11.9846 55.3672 11.3822 55.3672 10.6436C55.3672 9.8807 55.1951 9.27324 54.8516 8.82129C54.5079 8.36444 53.9921 8.13575 53.3047 8.13574ZM76.8203 8.02637C76.1039 8.02637 75.5712 8.25013 75.2227 8.69727C74.9987 8.98144 74.8476 9.35094 74.7676 9.80566H78.6221C78.5589 9.29301 78.4236 8.89686 78.2139 8.61719C77.9186 8.22359 77.4543 8.02645 76.8203 8.02637Z",
378
+ fill: "black"
379
+ }
380
+ ),
381
+ /* @__PURE__ */ jsxs("defs", { children: [
382
+ /* @__PURE__ */ jsxs(
383
+ "linearGradient",
384
+ {
385
+ id: "paint0_linear_2976_9475",
386
+ x1: "1.85883",
387
+ y1: "1.92425",
388
+ x2: "24.3072",
389
+ y2: "9.64016",
390
+ gradientUnits: "userSpaceOnUse",
391
+ children: [
392
+ /* @__PURE__ */ jsx2("stop", {}),
393
+ /* @__PURE__ */ jsx2("stop", { offset: "1", stopOpacity: "0.4" })
394
+ ]
395
+ }
396
+ ),
397
+ /* @__PURE__ */ jsxs(
398
+ "linearGradient",
399
+ {
400
+ id: "paint1_linear_2976_9475",
401
+ x1: "25.6475",
402
+ y1: "8.65468",
403
+ x2: "10.7901",
404
+ y2: "8.65468",
405
+ gradientUnits: "userSpaceOnUse",
406
+ children: [
407
+ /* @__PURE__ */ jsx2("stop", {}),
408
+ /* @__PURE__ */ jsx2("stop", { offset: "1", stopOpacity: "0.4" })
409
+ ]
410
+ }
411
+ )
412
+ ] })
413
+ ] }) })
414
+ ] });
415
+ }
416
+
417
+ // src/components/auth/AuthContainer.tsx
418
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
419
+ function AuthContainer({ children, style }) {
420
+ return /* @__PURE__ */ jsx3("div", { className: "insforge-auth-container", style, children: /* @__PURE__ */ jsxs2("div", { className: "insforge-auth-card", children: [
421
+ /* @__PURE__ */ jsx3("div", { className: "insforge-auth-content", children }),
422
+ /* @__PURE__ */ jsx3(AuthBranding, {})
423
+ ] }) });
424
+ }
425
+
426
+ // src/components/auth/AuthHeader.tsx
427
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
428
+ function AuthHeader({ title, subtitle }) {
429
+ return /* @__PURE__ */ jsxs3("div", { className: "insforge-auth-header", children: [
430
+ /* @__PURE__ */ jsx4("h1", { className: "insforge-auth-title", children: title }),
431
+ subtitle && /* @__PURE__ */ jsx4("p", { className: "insforge-auth-subtitle", children: subtitle })
432
+ ] });
433
+ }
434
+
435
+ // src/components/auth/AuthErrorBanner.tsx
436
+ import { AlertTriangle } from "lucide-react";
437
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
438
+ function AuthErrorBanner({ error }) {
439
+ if (!error) return null;
440
+ return /* @__PURE__ */ jsxs4("div", { className: "insforge-error-banner", children: [
441
+ /* @__PURE__ */ jsx5(AlertTriangle, { className: "insforge-error-icon" }),
442
+ /* @__PURE__ */ jsx5("span", { children: error })
443
+ ] });
444
+ }
445
+
446
+ // src/components/auth/AuthFormField.tsx
447
+ import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
448
+ function AuthFormField({ label, id, className = "", ...props }) {
449
+ return /* @__PURE__ */ jsxs5("div", { className: "insforge-form-group", children: [
450
+ /* @__PURE__ */ jsx6("label", { htmlFor: id, className: "insforge-form-label", children: label }),
451
+ /* @__PURE__ */ jsx6(
452
+ "input",
453
+ {
454
+ id,
455
+ className: `insforge-input ${className}`,
456
+ ...props
457
+ }
458
+ )
459
+ ] });
460
+ }
461
+
462
+ // src/components/auth/AuthPasswordField.tsx
463
+ import { useState as useState2 } from "react";
464
+ import { Eye, EyeOff } from "lucide-react";
465
+
466
+ // src/components/auth/AuthPasswordStrengthIndicator.tsx
467
+ import { Check } from "lucide-react";
468
+ import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
469
+ var requirements = [
470
+ {
471
+ label: "At least 1 Uppercase letter",
472
+ test: (pwd) => /[A-Z]/.test(pwd)
473
+ },
474
+ {
475
+ label: "At least 1 Number",
476
+ test: (pwd) => /\d/.test(pwd)
477
+ },
478
+ {
479
+ label: "Special character (e.g. !?<>@#$%)",
480
+ test: (pwd) => /[!@#$%^&*()_+\-=[\]{};\\|,.<>/?]/.test(pwd)
481
+ },
482
+ {
483
+ label: "8 characters or more",
484
+ test: (pwd) => pwd.length >= 8
485
+ }
486
+ ];
487
+ function validatePasswordStrength(password) {
488
+ if (!password) return false;
489
+ return requirements.every((req) => req.test(password));
490
+ }
491
+ function AuthPasswordStrengthIndicator({ password }) {
492
+ return /* @__PURE__ */ jsx7("div", { className: "insforge-password-strength", children: requirements.map((requirement, index) => {
493
+ const isValid = requirement.test(password);
494
+ return /* @__PURE__ */ jsxs6("div", { className: "insforge-password-requirement", children: [
495
+ /* @__PURE__ */ jsx7(
496
+ "div",
497
+ {
498
+ className: `insforge-password-check ${isValid ? "insforge-password-check-valid" : ""}`,
499
+ children: isValid && /* @__PURE__ */ jsx7(Check, { className: "insforge-password-check-icon", size: 12 })
500
+ }
501
+ ),
502
+ /* @__PURE__ */ jsx7("span", { className: "insforge-password-requirement-label", children: requirement.label })
503
+ ] }, index);
504
+ }) });
505
+ }
506
+
507
+ // src/components/auth/AuthPasswordField.tsx
508
+ import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
509
+ function AuthPasswordField({
510
+ label,
511
+ id,
512
+ showStrengthIndicator = false,
513
+ forgotPasswordLink,
514
+ value,
515
+ className = "",
516
+ onFocus,
517
+ ...props
518
+ }) {
519
+ const [showPassword, setShowPassword] = useState2(false);
520
+ const [showStrength, setShowStrength] = useState2(false);
521
+ const handleFocus = (e) => {
522
+ if (showStrengthIndicator) {
523
+ setShowStrength(true);
524
+ }
525
+ onFocus?.(e);
526
+ };
527
+ return /* @__PURE__ */ jsxs7("div", { className: "insforge-form-group", children: [
528
+ (label || forgotPasswordLink) && /* @__PURE__ */ jsxs7("div", { className: "insforge-form-label-row", children: [
529
+ /* @__PURE__ */ jsx8("label", { htmlFor: id, className: "insforge-form-label", style: { margin: 0 }, children: label }),
530
+ forgotPasswordLink && /* @__PURE__ */ jsx8("a", { href: forgotPasswordLink.href, className: "insforge-form-link", children: forgotPasswordLink.text || "Forget Password?" })
531
+ ] }),
532
+ /* @__PURE__ */ jsxs7("div", { className: "insforge-input-wrapper", children: [
533
+ /* @__PURE__ */ jsx8(
534
+ "input",
535
+ {
536
+ id,
537
+ type: showPassword ? "text" : "password",
538
+ className: `insforge-input insforge-input-with-icon ${className}`,
539
+ value,
540
+ onFocus: handleFocus,
541
+ ...props
542
+ }
543
+ ),
544
+ /* @__PURE__ */ jsx8(
545
+ "button",
546
+ {
547
+ type: "button",
548
+ onClick: () => setShowPassword(!showPassword),
549
+ className: "insforge-input-icon-btn",
550
+ "aria-label": showPassword ? "Hide password" : "Show password",
551
+ children: showPassword ? /* @__PURE__ */ jsx8(EyeOff, { size: 20 }) : /* @__PURE__ */ jsx8(Eye, { size: 20 })
552
+ }
553
+ )
554
+ ] }),
555
+ showStrengthIndicator && showStrength && /* @__PURE__ */ jsx8(AuthPasswordStrengthIndicator, { password: String(value || "") })
556
+ ] });
557
+ }
558
+
559
+ // src/components/auth/AuthSubmitButton.tsx
560
+ import { CircleCheck, Loader2 } from "lucide-react";
561
+ import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
562
+ function AuthSubmitButton({
563
+ children,
564
+ isLoading = false,
565
+ confirmed = false,
566
+ disabled = false,
567
+ style
568
+ }) {
569
+ return /* @__PURE__ */ jsxs8(
570
+ "button",
571
+ {
572
+ type: "submit",
573
+ className: "insforge-btn-primary",
574
+ style,
575
+ disabled: disabled || isLoading || confirmed,
576
+ "data-loading": isLoading || void 0,
577
+ "data-confirmed": confirmed || void 0,
578
+ children: [
579
+ isLoading && /* @__PURE__ */ jsx9(Loader2, { className: "insforge-btn-loader", size: 20 }),
580
+ confirmed && /* @__PURE__ */ jsx9(CircleCheck, { className: "insforge-btn-check", size: 20 }),
581
+ children
582
+ ]
583
+ }
584
+ );
585
+ }
586
+
587
+ // src/components/auth/AuthDivider.tsx
588
+ import { jsx as jsx10 } from "react/jsx-runtime";
589
+ function AuthDivider({ text = "or" }) {
590
+ return /* @__PURE__ */ jsx10("div", { className: "insforge-divider", children: /* @__PURE__ */ jsx10("span", { className: "insforge-divider-text", children: text }) });
591
+ }
592
+
593
+ // src/components/auth/AuthLink.tsx
594
+ import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
595
+ function AuthLink({ text, linkText, href }) {
596
+ return /* @__PURE__ */ jsxs9("p", { className: "insforge-text-center", children: [
597
+ text,
598
+ " ",
599
+ /* @__PURE__ */ jsx11("a", { href, className: "insforge-link-primary", children: linkText })
600
+ ] });
601
+ }
602
+
603
+ // src/components/auth/AuthOAuthButton.tsx
604
+ import { Loader2 as Loader22 } from "lucide-react";
605
+
606
+ // src/config/oauth-providers.tsx
607
+ import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
608
+ var OAUTH_PROVIDER_CONFIG = {
314
609
  google: {
315
610
  name: "Google",
316
- svg: /* @__PURE__ */ jsxs("svg", { width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", children: [
317
- /* @__PURE__ */ jsx3(
611
+ svg: /* @__PURE__ */ jsxs10("svg", { width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", children: [
612
+ /* @__PURE__ */ jsx12(
318
613
  "path",
319
614
  {
320
615
  d: "M17.64 9.2c0-.637-.057-1.251-.164-1.84H9v3.481h4.844c-.209 1.125-.843 2.078-1.796 2.717v2.258h2.908c1.702-1.567 2.684-3.874 2.684-6.615z",
321
616
  fill: "#4285F4"
322
617
  }
323
618
  ),
324
- /* @__PURE__ */ jsx3(
619
+ /* @__PURE__ */ jsx12(
325
620
  "path",
326
621
  {
327
622
  d: "M9 18c2.43 0 4.467-.806 5.956-2.184l-2.908-2.258c-.806.54-1.837.86-3.048.86-2.344 0-4.328-1.584-5.036-3.711H.957v2.332C2.438 15.983 5.482 18 9 18z",
328
623
  fill: "#34A853"
329
624
  }
330
625
  ),
331
- /* @__PURE__ */ jsx3(
626
+ /* @__PURE__ */ jsx12(
332
627
  "path",
333
628
  {
334
629
  d: "M3.964 10.707c-.18-.54-.282-1.117-.282-1.707 0-.593.102-1.17.282-1.709V4.958H.957C.347 6.173 0 7.548 0 9c0 1.452.348 2.827.957 4.042l3.007-2.335z",
335
630
  fill: "#FBBC05"
336
631
  }
337
632
  ),
338
- /* @__PURE__ */ jsx3(
633
+ /* @__PURE__ */ jsx12(
339
634
  "path",
340
635
  {
341
636
  d: "M9 3.58c1.321 0 2.508.454 3.44 1.345l2.582-2.58C13.463.891 11.426 0 9 0 5.482 0 2.438 2.017.957 4.958L3.964 7.29C4.672 5.163 6.656 3.58 9 3.58z",
@@ -347,16 +642,134 @@ var providerConfig = {
347
642
  },
348
643
  github: {
349
644
  name: "GitHub",
350
- svg: /* @__PURE__ */ jsx3("svg", { width: "18", height: "18", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ jsx3("path", { d: "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z" }) }),
645
+ svg: /* @__PURE__ */ jsx12("svg", { width: "18", height: "18", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ jsx12("path", { d: "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z" }) }),
351
646
  className: "insforge-oauth-github"
647
+ },
648
+ discord: {
649
+ name: "Discord",
650
+ svg: /* @__PURE__ */ jsx12("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx12(
651
+ "path",
652
+ {
653
+ d: "M20.317 4.37a19.791 19.791 0 00-4.885-1.515.074.074 0 00-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 00-5.487 0 12.64 12.64 0 00-.617-1.25.077.077 0 00-.079-.037A19.736 19.736 0 003.677 4.37a.07.07 0 00-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 00.031.057 19.9 19.9 0 005.993 3.03.078.078 0 00.084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 00-.041-.106 13.107 13.107 0 01-1.872-.892.077.077 0 01-.008-.128 10.2 10.2 0 00.372-.292.074.074 0 01.077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 01.078.01c.12.098.246.198.373.292a.077.077 0 01-.006.127 12.299 12.299 0 01-1.873.892.077.077 0 00-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 00.084.028 19.839 19.839 0 006.002-3.03.077.077 0 00.032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 00-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z",
654
+ fill: "#5865F2"
655
+ }
656
+ ) }),
657
+ className: "insforge-oauth-discord"
658
+ },
659
+ facebook: {
660
+ name: "Facebook",
661
+ svg: /* @__PURE__ */ jsx12("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx12(
662
+ "path",
663
+ {
664
+ d: "M24 12.073C24 5.405 18.627 0 12 0S0 5.405 0 12.073C0 18.1 4.388 23.094 10.125 24v-8.437H7.078v-3.49h3.047v-2.66c0-3.025 1.792-4.697 4.533-4.697 1.312 0 2.686.236 2.686.236v2.971H15.83c-1.49 0-1.955.93-1.955 1.886v2.264h3.328l-.532 3.49h-2.796V24C19.612 23.094 24 18.1 24 12.073z",
665
+ fill: "#1877F2"
666
+ }
667
+ ) }),
668
+ className: "insforge-oauth-facebook"
669
+ },
670
+ linkedin: {
671
+ name: "LinkedIn",
672
+ svg: /* @__PURE__ */ jsx12("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx12(
673
+ "path",
674
+ {
675
+ d: "M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 01-2.063-2.065 2.064 2.064 0 112.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z",
676
+ fill: "#0A66C2"
677
+ }
678
+ ) }),
679
+ className: "insforge-oauth-linkedin"
680
+ },
681
+ microsoft: {
682
+ name: "Microsoft",
683
+ svg: /* @__PURE__ */ jsxs10("svg", { width: "18", height: "18", viewBox: "0 0 23 23", fill: "none", children: [
684
+ /* @__PURE__ */ jsx12("path", { d: "M0 0h11v11H0z", fill: "#F25022" }),
685
+ /* @__PURE__ */ jsx12("path", { d: "M12 0h11v11H12z", fill: "#7FBA00" }),
686
+ /* @__PURE__ */ jsx12("path", { d: "M0 12h11v11H0z", fill: "#00A4EF" }),
687
+ /* @__PURE__ */ jsx12("path", { d: "M12 12h11v11H12z", fill: "#FFB900" })
688
+ ] }),
689
+ className: "insforge-oauth-microsoft"
690
+ },
691
+ apple: {
692
+ name: "Apple",
693
+ svg: /* @__PURE__ */ jsx12("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx12("path", { d: "M17.05 20.28c-.98.95-2.05.8-3.08.35-1.09-.46-2.09-.48-3.24 0-1.44.62-2.2.44-3.06-.35C2.79 15.25 3.51 7.59 9.05 7.31c1.35.07 2.29.74 3.08.8 1.18-.24 2.31-.93 3.57-.84 1.51.12 2.65.72 3.4 1.8-3.12 1.87-2.38 5.98.48 7.13-.57 1.5-1.31 2.99-2.54 4.09l.01-.01zM12.03 7.25c-.15-2.23 1.66-4.07 3.74-4.25.29 2.58-2.34 4.5-3.74 4.25z" }) }),
694
+ className: "insforge-oauth-apple"
695
+ },
696
+ x: {
697
+ name: "X",
698
+ svg: /* @__PURE__ */ jsx12("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx12("path", { d: "M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z" }) }),
699
+ className: "insforge-oauth-x"
700
+ },
701
+ instagram: {
702
+ name: "Instagram",
703
+ svg: /* @__PURE__ */ jsxs10("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: [
704
+ /* @__PURE__ */ jsx12(
705
+ "path",
706
+ {
707
+ d: "M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z",
708
+ fill: "url(#instagram-gradient)"
709
+ }
710
+ ),
711
+ /* @__PURE__ */ jsx12("defs", { children: /* @__PURE__ */ jsxs10("linearGradient", { id: "instagram-gradient", x1: "0%", y1: "100%", x2: "100%", y2: "0%", children: [
712
+ /* @__PURE__ */ jsx12("stop", { offset: "0%", stopColor: "#FD5949" }),
713
+ /* @__PURE__ */ jsx12("stop", { offset: "50%", stopColor: "#D6249F" }),
714
+ /* @__PURE__ */ jsx12("stop", { offset: "100%", stopColor: "#285AEB" })
715
+ ] }) })
716
+ ] }),
717
+ className: "insforge-oauth-instagram"
718
+ },
719
+ tiktok: {
720
+ name: "TikTok",
721
+ svg: /* @__PURE__ */ jsx12("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx12(
722
+ "path",
723
+ {
724
+ d: "M19.589 6.686a4.793 4.793 0 01-3.77-4.245V2h-3.445v13.672a2.896 2.896 0 01-5.201 1.743l-.002-.001.002.001a2.895 2.895 0 013.183-4.51v-3.5a6.329 6.329 0 00-5.394 10.692 6.33 6.33 0 0010.857-4.424V8.687a8.182 8.182 0 004.773 1.526V6.79a4.831 4.831 0 01-1.003-.104z",
725
+ fill: "currentColor"
726
+ }
727
+ ) }),
728
+ className: "insforge-oauth-tiktok"
729
+ },
730
+ spotify: {
731
+ name: "Spotify",
732
+ svg: /* @__PURE__ */ jsx12("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx12(
733
+ "path",
734
+ {
735
+ d: "M12 0C5.4 0 0 5.4 0 12s5.4 12 12 12 12-5.4 12-12S18.66 0 12 0zm5.521 17.34c-.24.359-.66.48-1.021.24-2.82-1.74-6.36-2.101-10.561-1.141-.418.122-.779-.179-.899-.539-.12-.421.18-.78.54-.9 4.56-1.021 8.52-.6 11.64 1.32.42.18.479.659.301 1.02zm1.44-3.3c-.301.42-.841.6-1.262.3-3.239-1.98-8.159-2.58-11.939-1.38-.479.12-1.02-.12-1.14-.6-.12-.48.12-1.021.6-1.141C9.6 9.9 15 10.561 18.72 12.84c.361.181.54.78.241 1.2zm.12-3.36C15.24 8.4 8.82 8.16 5.16 9.301c-.6.179-1.2-.181-1.38-.721-.18-.601.18-1.2.72-1.381 4.26-1.26 11.28-1.02 15.721 1.621.539.3.719 1.02.419 1.56-.299.421-1.02.599-1.559.3z",
736
+ fill: "#1DB954"
737
+ }
738
+ ) }),
739
+ className: "insforge-oauth-spotify"
352
740
  }
353
741
  };
354
- function OAuthButton({ provider, onClick, disabled, loading }) {
355
- const config = providerConfig[provider];
742
+ function getProviderConfig(provider) {
743
+ return OAUTH_PROVIDER_CONFIG[provider] || null;
744
+ }
745
+ function getProviderName(provider) {
746
+ return OAUTH_PROVIDER_CONFIG[provider]?.name || provider;
747
+ }
748
+ function isProviderSupported(provider) {
749
+ return provider in OAUTH_PROVIDER_CONFIG;
750
+ }
751
+
752
+ // src/components/auth/AuthOAuthButton.tsx
753
+ import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
754
+ function AuthOAuthButton({
755
+ provider,
756
+ onClick,
757
+ disabled,
758
+ loading,
759
+ displayMode = "full",
760
+ style
761
+ }) {
762
+ const config = getProviderConfig(provider);
356
763
  if (!config) {
357
764
  return null;
358
765
  }
359
- return /* @__PURE__ */ jsxs(
766
+ const getButtonText = () => {
767
+ if (loading) return "Authenticating...";
768
+ if (displayMode === "full") return `Continue with ${config.name}`;
769
+ if (displayMode === "short") return config.name;
770
+ return "";
771
+ };
772
+ return /* @__PURE__ */ jsxs11(
360
773
  "button",
361
774
  {
362
775
  type: "button",
@@ -364,21 +777,149 @@ function OAuthButton({ provider, onClick, disabled, loading }) {
364
777
  className: "insforge-oauth-btn",
365
778
  disabled: disabled || loading,
366
779
  "data-loading": loading || void 0,
780
+ "data-display-mode": displayMode,
781
+ style,
367
782
  children: [
368
- /* @__PURE__ */ jsx3(Loader2, { className: "insforge-oauth-loader", size: 18 }),
369
- /* @__PURE__ */ jsx3("span", { className: "insforge-oauth-icon", children: config.svg }),
370
- loading ? "Authenticating..." : `Continue with ${config.name}`
783
+ /* @__PURE__ */ jsx13(Loader22, { className: "insforge-oauth-loader", size: 18 }),
784
+ /* @__PURE__ */ jsx13("span", { className: "insforge-oauth-icon", children: config.svg }),
785
+ getButtonText() && /* @__PURE__ */ jsx13("span", { className: "insforge-oauth-text", children: getButtonText() })
371
786
  ]
372
787
  }
373
788
  );
374
789
  }
375
790
 
791
+ // src/components/auth/AuthOAuthProviders.tsx
792
+ import { jsx as jsx14 } from "react/jsx-runtime";
793
+ function AuthOAuthProviders({
794
+ providers,
795
+ onClick,
796
+ disabled,
797
+ loading
798
+ }) {
799
+ if (!providers || providers.length === 0) {
800
+ return null;
801
+ }
802
+ const count = providers.length;
803
+ const getDisplayMode = () => {
804
+ if (count === 1) return "full";
805
+ if (count === 2 || count === 4) return "short";
806
+ return "icon";
807
+ };
808
+ const getGridColumnStyle = (index) => {
809
+ if (count <= 4) {
810
+ return {};
811
+ }
812
+ const totalRows = Math.ceil(count / 3);
813
+ const lastRowStartIndex = (totalRows - 1) * 3;
814
+ const isInLastRow = index >= lastRowStartIndex;
815
+ if (!isInLastRow) {
816
+ return { gridColumn: "span 2" };
817
+ }
818
+ const positionInLastRow = index - lastRowStartIndex;
819
+ const itemsInLastRow = count - lastRowStartIndex;
820
+ if (itemsInLastRow === 1) {
821
+ return { gridColumn: "3 / 5" };
822
+ } else if (itemsInLastRow === 2) {
823
+ if (positionInLastRow === 0) {
824
+ return { gridColumn: "2 / 4" };
825
+ } else {
826
+ return { gridColumn: "4 / 6" };
827
+ }
828
+ } else {
829
+ return { gridColumn: "span 2" };
830
+ }
831
+ };
832
+ return /* @__PURE__ */ jsx14("div", { className: "insforge-oauth-container", "data-provider-count": count, children: providers.map((provider, index) => /* @__PURE__ */ jsx14(
833
+ AuthOAuthButton,
834
+ {
835
+ provider,
836
+ onClick,
837
+ disabled,
838
+ loading: loading === provider,
839
+ displayMode: getDisplayMode(),
840
+ style: getGridColumnStyle(index)
841
+ },
842
+ provider
843
+ )) });
844
+ }
845
+
846
+ // src/components/auth/AuthVerificationCodeInput.tsx
847
+ import {
848
+ useRef as useRef2
849
+ } from "react";
850
+ import { jsx as jsx15, jsxs as jsxs12 } from "react/jsx-runtime";
851
+ function AuthVerificationCodeInput({
852
+ length = 6,
853
+ value,
854
+ email,
855
+ onChange,
856
+ disabled = false
857
+ }) {
858
+ const inputRefs = useRef2([]);
859
+ const handleChange = (index, digit) => {
860
+ if (digit.length > 1) return;
861
+ if (digit && !/^\d$/.test(digit)) return;
862
+ const newValue = value.split("");
863
+ newValue[index] = digit;
864
+ const updatedValue = newValue.join("");
865
+ onChange(updatedValue);
866
+ if (digit && index < length - 1) {
867
+ inputRefs.current[index + 1]?.focus();
868
+ }
869
+ };
870
+ const handleKeyDown = (index, e) => {
871
+ if (e.key === "Backspace") {
872
+ if (!value[index] && index > 0) {
873
+ inputRefs.current[index - 1]?.focus();
874
+ } else {
875
+ handleChange(index, "");
876
+ }
877
+ } else if (e.key === "ArrowLeft" && index > 0) {
878
+ inputRefs.current[index - 1]?.focus();
879
+ } else if (e.key === "ArrowRight" && index < length - 1) {
880
+ inputRefs.current[index + 1]?.focus();
881
+ }
882
+ };
883
+ const handlePaste = (e) => {
884
+ e.preventDefault();
885
+ const pastedData = e.clipboardData.getData("text/plain").trim();
886
+ if (/^\d+$/.test(pastedData) && pastedData.length === length) {
887
+ onChange(pastedData);
888
+ inputRefs.current[length - 1]?.focus();
889
+ }
890
+ };
891
+ return /* @__PURE__ */ jsxs12("div", { className: "insforge-verification-code-container", children: [
892
+ /* @__PURE__ */ jsxs12("p", { className: "insforge-verification-instructions", children: [
893
+ "We've sent a verification code to your inbox at ",
894
+ /* @__PURE__ */ jsx15("span", { children: email }),
895
+ ". Enter it below to proceed."
896
+ ] }),
897
+ /* @__PURE__ */ jsx15("div", { className: "insforge-verification-code-inputs", children: Array.from({ length }).map((_, index) => /* @__PURE__ */ jsx15(
898
+ "input",
899
+ {
900
+ ref: (el) => {
901
+ inputRefs.current[index] = el;
902
+ },
903
+ type: "text",
904
+ inputMode: "numeric",
905
+ maxLength: 1,
906
+ value: value[index] || "",
907
+ onChange: (e) => handleChange(index, e.target.value),
908
+ onKeyDown: (e) => handleKeyDown(index, e),
909
+ onPaste: handlePaste,
910
+ disabled,
911
+ className: "insforge-verification-code-input",
912
+ autoComplete: "one-time-code"
913
+ },
914
+ index
915
+ )) })
916
+ ] });
917
+ }
918
+
376
919
  // src/components/SignIn.tsx
377
- import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
920
+ import { Fragment, jsx as jsx16, jsxs as jsxs13 } from "react/jsx-runtime";
378
921
  function SignIn({
379
- baseUrl,
380
922
  afterSignInUrl = "/",
381
- providers = [],
382
923
  appearance = {},
383
924
  title = "Welcome Back",
384
925
  subtitle = "Login to your account",
@@ -396,12 +937,11 @@ function SignIn({
396
937
  onSuccess,
397
938
  onError
398
939
  }) {
399
- const { signIn } = useAuth();
940
+ const { signIn, oauthProviders, baseUrl } = useInsforge();
400
941
  const [email, setEmail] = useState3("");
401
942
  const [password, setPassword] = useState3("");
402
943
  const [error, setError] = useState3("");
403
944
  const [loading, setLoading] = useState3(false);
404
- const [showPassword, setShowPassword] = useState3(false);
405
945
  const [oauthLoading, setOauthLoading] = useState3(null);
406
946
  const insforge = useState3(() => createClient2({ baseUrl }))[0];
407
947
  async function handleSubmit(e) {
@@ -432,9 +972,7 @@ function SignIn({
432
972
  provider,
433
973
  redirectTo
434
974
  });
435
- if (result.data?.url) {
436
- window.location.href = result.data.url;
437
- }
975
+ console.log("handleOAuth result", result);
438
976
  } catch (err) {
439
977
  const errorMessage = err.message || `${provider} sign in failed`;
440
978
  setError(errorMessage);
@@ -442,238 +980,71 @@ function SignIn({
442
980
  setOauthLoading(null);
443
981
  }
444
982
  }
445
- return /* @__PURE__ */ jsx4("div", { className: "insforge-auth-container", style: appearance.container, children: /* @__PURE__ */ jsxs2("div", { className: "insforge-auth-card", style: appearance.form, children: [
446
- /* @__PURE__ */ jsxs2("div", { className: "insforge-auth-content", children: [
447
- /* @__PURE__ */ jsxs2("div", { className: "insforge-auth-header", children: [
448
- /* @__PURE__ */ jsx4("h1", { className: "insforge-auth-title", children: title }),
449
- /* @__PURE__ */ jsx4("p", { className: "insforge-auth-subtitle", children: subtitle })
450
- ] }),
451
- error && /* @__PURE__ */ jsxs2("div", { className: "insforge-error-banner", children: [
452
- /* @__PURE__ */ jsx4(AlertTriangle, { className: "insforge-error-icon" }),
453
- /* @__PURE__ */ jsx4("span", { children: error })
454
- ] }),
455
- /* @__PURE__ */ jsxs2("form", { onSubmit: handleSubmit, className: "insforge-form", children: [
456
- /* @__PURE__ */ jsxs2("div", { className: "insforge-form-group", children: [
457
- /* @__PURE__ */ jsx4("label", { htmlFor: "email", className: "insforge-form-label", children: emailLabel }),
458
- /* @__PURE__ */ jsx4(
459
- "input",
460
- {
461
- id: "email",
462
- type: "email",
463
- className: "insforge-input",
464
- placeholder: emailPlaceholder,
465
- value: email,
466
- onChange: (e) => setEmail(e.target.value),
467
- required: true,
468
- autoComplete: "email"
469
- }
470
- )
471
- ] }),
472
- /* @__PURE__ */ jsxs2("div", { className: "insforge-form-group", children: [
473
- /* @__PURE__ */ jsxs2("div", { className: "insforge-form-label-row", children: [
474
- /* @__PURE__ */ jsx4(
475
- "label",
476
- {
477
- htmlFor: "password",
478
- className: "insforge-form-label",
479
- style: { margin: 0 },
480
- children: passwordLabel
481
- }
482
- ),
483
- /* @__PURE__ */ jsx4("a", { href: "#", className: "insforge-form-link", children: forgotPasswordText })
484
- ] }),
485
- /* @__PURE__ */ jsxs2("div", { className: "insforge-input-wrapper", children: [
486
- /* @__PURE__ */ jsx4(
487
- "input",
488
- {
489
- id: "password",
490
- type: showPassword ? "text" : "password",
491
- className: "insforge-input insforge-input-with-icon",
492
- placeholder: passwordPlaceholder,
493
- value: password,
494
- onChange: (e) => setPassword(e.target.value),
495
- required: true,
496
- autoComplete: "current-password"
497
- }
498
- ),
499
- /* @__PURE__ */ jsx4(
500
- "button",
501
- {
502
- type: "button",
503
- onClick: () => setShowPassword(!showPassword),
504
- className: "insforge-input-icon-btn",
505
- "aria-label": showPassword ? "Hide password" : "Show password",
506
- children: showPassword ? /* @__PURE__ */ jsx4(EyeOff, { size: 20 }) : /* @__PURE__ */ jsx4(Eye, { size: 20 })
507
- }
508
- )
509
- ] })
510
- ] }),
511
- /* @__PURE__ */ jsxs2(
512
- "button",
513
- {
514
- type: "submit",
515
- className: "insforge-btn-primary",
516
- style: appearance.button,
517
- disabled: loading || oauthLoading !== null,
518
- "data-loading": loading || void 0,
519
- children: [
520
- loading && /* @__PURE__ */ jsx4(Loader22, { className: "insforge-btn-loader", size: 20 }),
521
- loading ? loadingButtonText : submitButtonText
522
- ]
983
+ return /* @__PURE__ */ jsxs13(AuthContainer, { style: appearance.container, children: [
984
+ /* @__PURE__ */ jsx16(AuthHeader, { title, subtitle }),
985
+ /* @__PURE__ */ jsx16(AuthErrorBanner, { error }),
986
+ /* @__PURE__ */ jsxs13("form", { onSubmit: handleSubmit, className: "insforge-form", children: [
987
+ /* @__PURE__ */ jsx16(
988
+ AuthFormField,
989
+ {
990
+ id: "email",
991
+ type: "email",
992
+ label: emailLabel,
993
+ placeholder: emailPlaceholder,
994
+ value: email,
995
+ onChange: (e) => setEmail(e.target.value),
996
+ required: true,
997
+ autoComplete: "email"
998
+ }
999
+ ),
1000
+ /* @__PURE__ */ jsx16(
1001
+ AuthPasswordField,
1002
+ {
1003
+ id: "password",
1004
+ label: passwordLabel,
1005
+ placeholder: passwordPlaceholder,
1006
+ value: password,
1007
+ onChange: (e) => setPassword(e.target.value),
1008
+ required: true,
1009
+ autoComplete: "current-password",
1010
+ forgotPasswordLink: {
1011
+ href: "#",
1012
+ text: forgotPasswordText
523
1013
  }
524
- )
525
- ] }),
526
- /* @__PURE__ */ jsxs2("p", { className: "insforge-text-center", children: [
527
- signUpText,
528
- " ",
529
- /* @__PURE__ */ jsx4("a", { href: signUpUrl, className: "insforge-link-primary", children: signUpLinkText })
530
- ] }),
531
- providers.length > 0 && /* @__PURE__ */ jsxs2(Fragment, { children: [
532
- /* @__PURE__ */ jsx4("div", { className: "insforge-divider", children: /* @__PURE__ */ jsx4("span", { className: "insforge-divider-text", children: dividerText }) }),
533
- /* @__PURE__ */ jsx4("div", { className: "insforge-oauth-container", children: providers.map((provider) => /* @__PURE__ */ jsx4(
534
- OAuthButton,
535
- {
536
- provider,
537
- onClick: handleOAuth,
538
- disabled: loading || oauthLoading !== null,
539
- loading: oauthLoading === provider
540
- },
541
- provider
542
- )) })
543
- ] })
1014
+ }
1015
+ ),
1016
+ /* @__PURE__ */ jsx16(
1017
+ AuthSubmitButton,
1018
+ {
1019
+ isLoading: loading,
1020
+ disabled: loading || oauthLoading !== null,
1021
+ style: appearance.button,
1022
+ children: loading ? loadingButtonText : submitButtonText
1023
+ }
1024
+ )
544
1025
  ] }),
545
- /* @__PURE__ */ jsxs2("div", { className: "insforge-branding", children: [
546
- /* @__PURE__ */ jsx4("p", { className: "insforge-branding-text", children: "Powered by" }),
547
- /* @__PURE__ */ jsx4(
548
- Link,
1026
+ /* @__PURE__ */ jsx16(AuthLink, { text: signUpText, linkText: signUpLinkText, href: signUpUrl }),
1027
+ oauthProviders.length > 0 && /* @__PURE__ */ jsxs13(Fragment, { children: [
1028
+ /* @__PURE__ */ jsx16(AuthDivider, { text: dividerText }),
1029
+ /* @__PURE__ */ jsx16(
1030
+ AuthOAuthProviders,
549
1031
  {
550
- href: "https://insforge.dev",
551
- target: "_blank",
552
- rel: "noopener noreferrer",
553
- children: /* @__PURE__ */ jsxs2(
554
- "svg",
555
- {
556
- width: "83",
557
- height: "20",
558
- viewBox: "0 0 83 20",
559
- fill: "none",
560
- xmlns: "http://www.w3.org/2000/svg",
561
- children: [
562
- /* @__PURE__ */ jsx4(
563
- "path",
564
- {
565
- d: "M2.16783 8.46797C1.9334 8.23325 1.9334 7.85269 2.16783 7.61797L8.11049 1.66797L16.6 1.66797L6.41259 11.868C6.17815 12.1027 5.79807 12.1027 5.56363 11.868L2.16783 8.46797Z",
566
- fill: "url(#paint0_linear_2976_9475)"
567
- }
568
- ),
569
- /* @__PURE__ */ jsx4(
570
- "path",
571
- {
572
- d: "M12.8858 6.44922L16.6 10.168V18.668L8.64108 10.6992L12.8858 6.44922Z",
573
- fill: "url(#paint1_linear_2976_9475)"
574
- }
575
- ),
576
- /* @__PURE__ */ jsx4(
577
- "path",
578
- {
579
- d: "M67.5439 6.48828C68.2894 6.48828 68.9145 6.67064 69.418 7.03516C69.5229 7.10943 69.6214 7.1907 69.7158 7.27637V6.70703H71.248V14.959C71.248 15.1583 71.2381 15.3485 71.2188 15.5283C71.2042 15.7129 71.1774 15.8925 71.1387 16.0674C71.0225 16.5776 70.7998 16.9957 70.4707 17.3213C70.1415 17.6518 69.7321 17.8972 69.2432 18.0576C68.7592 18.2179 68.2222 18.2988 67.6318 18.2988C67.1962 18.2988 66.7768 18.2308 66.375 18.0947C65.9782 17.9587 65.6202 17.7614 65.3008 17.5039C64.9813 17.2512 64.7199 16.9446 64.5166 16.585L66.1289 15.7832C66.2789 16.0698 66.4888 16.2819 66.7598 16.418C67.0356 16.5589 67.3289 16.6289 67.6387 16.6289C68.0016 16.6289 68.3258 16.5628 68.6113 16.4316C68.8969 16.3053 69.1176 16.116 69.2725 15.8633C69.4321 15.6155 69.5077 15.3047 69.498 14.9307V14.1797C69.4665 14.2037 69.4359 14.229 69.4033 14.252C68.8855 14.6164 68.2441 14.7988 67.4795 14.7988C66.7582 14.7988 66.1281 14.6165 65.5908 14.252C65.0537 13.8875 64.637 13.3915 64.3418 12.7646C64.0467 12.1378 63.8994 11.4307 63.8994 10.6436C63.8994 9.84651 64.0465 9.13673 64.3418 8.51465C64.6419 7.88768 65.0663 7.39481 65.6133 7.03516C66.1601 6.67077 66.8036 6.48836 67.5439 6.48828ZM37.5 6.48828C38.1099 6.48828 38.6496 6.58294 39.1191 6.77246C39.5935 6.96201 39.9762 7.2321 40.2666 7.58203C40.5569 7.93184 40.7359 8.34227 40.8037 8.81348L39.0176 9.13477C38.974 8.79951 38.8218 8.53424 38.5605 8.33984C38.304 8.14547 37.96 8.03605 37.5293 8.01172C37.1178 7.98742 36.7859 8.05051 36.5342 8.20117C36.2825 8.34698 36.1562 8.55398 36.1562 8.82129C36.1563 8.97184 36.208 9.10017 36.3096 9.20703C36.4112 9.31394 36.614 9.42141 36.9189 9.52832C37.2288 9.63524 37.6889 9.76635 38.2988 9.92188C38.9232 10.0823 39.4222 10.2666 39.7949 10.4756C40.1722 10.6796 40.4428 10.9254 40.6074 11.2119C40.7768 11.4987 40.8623 11.8466 40.8623 12.2549C40.8623 13.047 40.574 13.6691 39.998 14.1211C39.4268 14.5731 38.6348 14.7988 37.623 14.7988C36.6551 14.7988 35.8687 14.5799 35.2637 14.1426C34.6587 13.7052 34.2909 13.0908 34.1602 12.2988L35.9463 12.0215C36.0383 12.4102 36.2411 12.7169 36.5557 12.9404C36.8703 13.164 37.2678 13.2754 37.7471 13.2754C38.1681 13.2754 38.4922 13.1926 38.7197 13.0273C38.9521 12.8572 39.0684 12.6266 39.0684 12.335C39.0684 12.1552 39.0245 12.0122 38.9375 11.9053C38.8552 11.7935 38.6713 11.686 38.3857 11.584C38.1001 11.4819 37.6618 11.3528 37.0713 11.1973C36.4131 11.0223 35.8901 10.8359 35.5029 10.6367C35.1158 10.4327 34.8374 10.192 34.668 9.91504C34.4985 9.63801 34.4141 9.30188 34.4141 8.9082C34.4141 8.41746 34.5423 7.98943 34.7988 7.625C35.0553 7.26073 35.4135 6.98146 35.873 6.78711C36.3329 6.58784 36.8755 6.48828 37.5 6.48828ZM53.3047 6.48828C54.0937 6.48828 54.7815 6.66572 55.3672 7.02051C55.9527 7.37528 56.4072 7.86634 56.7314 8.49316C57.0558 9.11525 57.2187 9.83193 57.2188 10.6436C57.2188 11.46 57.0537 12.1817 56.7246 12.8086C56.4003 13.4307 55.9451 13.9196 55.3594 14.2744C54.7737 14.6242 54.0888 14.7988 53.3047 14.7988C52.5205 14.7988 51.8357 14.6214 51.25 14.2666C50.6643 13.9118 50.2091 13.4238 49.8848 12.8018C49.5653 12.1748 49.4053 11.4552 49.4053 10.6436C49.4053 9.81735 49.5703 9.09279 49.8994 8.4707C50.2286 7.8488 50.6859 7.36255 51.2715 7.0127C51.8572 6.66281 52.5351 6.48828 53.3047 6.48828ZM76.7471 6.48828C77.5603 6.48828 78.25 6.68053 78.8164 7.06445C79.3876 7.44351 79.812 7.97991 80.0879 8.6748C80.3638 9.36976 80.4672 10.189 80.3994 11.1318H74.7256C74.7843 11.6972 74.949 12.1516 75.2227 12.4951C75.5711 12.9325 76.0792 13.1513 76.7471 13.1514C77.1779 13.1514 77.5486 13.0567 77.8584 12.8672C78.173 12.6728 78.4146 12.3928 78.584 12.0283L80.3125 12.5537C80.0124 13.2633 79.5473 13.8153 78.918 14.209C78.2936 14.6025 77.6036 14.7988 76.8486 14.7988C76.0549 14.7988 75.358 14.6263 74.7578 14.2812C74.1576 13.9362 73.6875 13.458 73.3486 12.8457C73.0147 12.2334 72.8477 11.5284 72.8477 10.7314C72.8477 9.87126 73.0127 9.12495 73.3418 8.49316C73.671 7.85651 74.1282 7.36263 74.7139 7.0127C75.2995 6.6628 75.9775 6.48832 76.7471 6.48828ZM23.3301 14.5801H21.5801V4.08203H23.3301V14.5801ZM29.6152 6.48047C30.1959 6.48052 30.6753 6.5781 31.0527 6.77246C31.4301 6.96681 31.7305 7.21443 31.9531 7.51562C32.1758 7.81695 32.3398 8.13831 32.4463 8.47852C32.5528 8.81873 32.6213 9.14205 32.6504 9.44824C32.6843 9.74946 32.7012 9.99508 32.7012 10.1846V14.5801H30.9287V10.7891C30.9287 10.5413 30.9118 10.2669 30.8779 9.96582C30.844 9.66449 30.7645 9.37469 30.6387 9.09766C30.5177 8.81592 30.3337 8.58503 30.0869 8.40527C29.8449 8.22551 29.5157 8.13579 29.0996 8.13574C28.8769 8.13574 28.6563 8.17221 28.4385 8.24512C28.2206 8.31802 28.0219 8.4442 27.8428 8.62402C27.6685 8.79899 27.5284 9.04249 27.4219 9.35352C27.3154 9.65965 27.2617 10.0532 27.2617 10.5342V14.5801H25.4902V6.70703H27.0518V7.58301C27.2521 7.34675 27.486 7.14172 27.7559 6.96973C28.2593 6.64409 28.8794 6.48047 29.6152 6.48047ZM48.748 5.83887H44.2021V8.45605H47.876V10.2061H44.2021V14.5801H42.4521V4.08203H48.748V5.83887ZM62.5137 6.67773C62.7606 6.65829 63.001 6.66815 63.2334 6.70703V8.34766C63.001 8.27961 62.7317 8.25695 62.4268 8.28125C62.1267 8.30557 61.8553 8.39134 61.6133 8.53711C61.3715 8.66829 61.1733 8.83606 61.0186 9.04004C60.8686 9.24404 60.7572 9.47701 60.6846 9.73926C60.612 9.99685 60.5752 10.2768 60.5752 10.5781V14.5801H58.8184V6.70703H60.3652V7.96582C60.4243 7.85986 60.4888 7.75824 60.5605 7.66211C60.7251 7.4434 60.9219 7.26302 61.1494 7.12207C61.3429 6.99098 61.5559 6.88926 61.7881 6.81641C62.0251 6.73869 62.267 6.69235 62.5137 6.67773ZM67.8057 8.0625C67.3362 8.06252 66.9485 8.17982 66.6436 8.41309C66.3389 8.64144 66.1139 8.95232 65.9688 9.3457C65.8235 9.7345 65.751 10.1673 65.751 10.6436C65.751 11.1247 65.8215 11.5624 65.9619 11.9561C66.1071 12.3447 66.3269 12.6535 66.6221 12.8818C66.9174 13.1103 67.293 13.2246 67.748 13.2246C68.2174 13.2246 68.5953 13.1171 68.8809 12.9033C69.1711 12.6846 69.3811 12.3808 69.5117 11.9922C69.6473 11.6034 69.7158 11.1539 69.7158 10.6436C69.7158 10.1284 69.6473 9.67886 69.5117 9.29492C69.381 8.90617 69.1753 8.60445 68.8945 8.39062C68.6138 8.17213 68.2508 8.0625 67.8057 8.0625ZM53.3047 8.13574C52.8351 8.13574 52.4475 8.24222 52.1426 8.45605C51.8425 8.66504 51.6198 8.95977 51.4746 9.33887C51.3295 9.71303 51.2568 10.148 51.2568 10.6436C51.2568 11.4066 51.4288 12.0168 51.7725 12.4736C52.121 12.9256 52.6318 13.1514 53.3047 13.1514C54.0017 13.1514 54.5196 12.9177 54.8584 12.4512C55.1971 11.9846 55.3672 11.3822 55.3672 10.6436C55.3672 9.8807 55.1951 9.27324 54.8516 8.82129C54.5079 8.36444 53.9921 8.13575 53.3047 8.13574ZM76.8203 8.02637C76.1039 8.02637 75.5712 8.25013 75.2227 8.69727C74.9987 8.98144 74.8476 9.35094 74.7676 9.80566H78.6221C78.5589 9.29301 78.4236 8.89686 78.2139 8.61719C77.9186 8.22359 77.4543 8.02645 76.8203 8.02637Z",
580
- fill: "black"
581
- }
582
- ),
583
- /* @__PURE__ */ jsxs2("defs", { children: [
584
- /* @__PURE__ */ jsxs2(
585
- "linearGradient",
586
- {
587
- id: "paint0_linear_2976_9475",
588
- x1: "1.85883",
589
- y1: "1.92425",
590
- x2: "24.3072",
591
- y2: "9.64016",
592
- gradientUnits: "userSpaceOnUse",
593
- children: [
594
- /* @__PURE__ */ jsx4("stop", {}),
595
- /* @__PURE__ */ jsx4("stop", { offset: "1", stopOpacity: "0.4" })
596
- ]
597
- }
598
- ),
599
- /* @__PURE__ */ jsxs2(
600
- "linearGradient",
601
- {
602
- id: "paint1_linear_2976_9475",
603
- x1: "25.6475",
604
- y1: "8.65468",
605
- x2: "10.7901",
606
- y2: "8.65468",
607
- gradientUnits: "userSpaceOnUse",
608
- children: [
609
- /* @__PURE__ */ jsx4("stop", {}),
610
- /* @__PURE__ */ jsx4("stop", { offset: "1", stopOpacity: "0.4" })
611
- ]
612
- }
613
- )
614
- ] })
615
- ]
616
- }
617
- )
1032
+ providers: oauthProviders,
1033
+ onClick: handleOAuth,
1034
+ disabled: loading || oauthLoading !== null,
1035
+ loading: oauthLoading
618
1036
  }
619
1037
  )
620
1038
  ] })
621
- ] }) });
1039
+ ] });
622
1040
  }
623
1041
 
624
1042
  // src/components/SignUp.tsx
625
1043
  import { useState as useState4 } from "react";
626
- import Link2 from "next/link";
627
1044
  import { createClient as createClient3 } from "@insforge/sdk";
628
- import { AlertTriangle as AlertTriangle2, Eye as Eye2, EyeOff as EyeOff2, Loader2 as Loader23 } from "lucide-react";
629
-
630
- // src/components/PasswordStrengthIndicator.tsx
631
- import { Check } from "lucide-react";
632
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
633
- var requirements = [
634
- {
635
- label: "At least 1 Uppercase letter",
636
- test: (pwd) => /[A-Z]/.test(pwd)
637
- },
638
- {
639
- label: "At least 1 Number",
640
- test: (pwd) => /\d/.test(pwd)
641
- },
642
- {
643
- label: "Special character (e.g. !?<>@#$%)",
644
- test: (pwd) => /[!@#$%^&*()_+\-=[\]{};\\|,.<>/?]/.test(pwd)
645
- },
646
- {
647
- label: "8 characters or more",
648
- test: (pwd) => pwd.length >= 8
649
- }
650
- ];
651
- function validatePasswordStrength(password) {
652
- if (!password) return false;
653
- return requirements.every((req) => req.test(password));
654
- }
655
- function PasswordStrengthIndicator({ password }) {
656
- return /* @__PURE__ */ jsx5("div", { className: "insforge-password-strength", children: requirements.map((requirement, index) => {
657
- const isValid = requirement.test(password);
658
- return /* @__PURE__ */ jsxs3("div", { className: "insforge-password-requirement", children: [
659
- /* @__PURE__ */ jsx5(
660
- "div",
661
- {
662
- className: `insforge-password-check ${isValid ? "insforge-password-check-valid" : ""}`,
663
- children: isValid && /* @__PURE__ */ jsx5(Check, { className: "insforge-password-check-icon", size: 12 })
664
- }
665
- ),
666
- /* @__PURE__ */ jsx5("span", { className: "insforge-password-requirement-label", children: requirement.label })
667
- ] }, index);
668
- }) });
669
- }
670
-
671
- // src/components/SignUp.tsx
672
- import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
1045
+ import { Fragment as Fragment2, jsx as jsx17, jsxs as jsxs14 } from "react/jsx-runtime";
673
1046
  function SignUp({
674
- baseUrl,
675
1047
  afterSignUpUrl = "/",
676
- providers = [],
677
1048
  appearance = {},
678
1049
  title = "Get Started",
679
1050
  subtitle = "Create account",
@@ -683,6 +1054,9 @@ function SignUp({
683
1054
  passwordPlaceholder = "\u2022\u2022\u2022\u2022\u2022\u2022",
684
1055
  submitButtonText = "Sign Up",
685
1056
  loadingButtonText = "Creating account...",
1057
+ verifyButtonText = "Continue",
1058
+ loadingVerifyButtonText = "Verifying...",
1059
+ verifiedButtonText = "Verified",
686
1060
  signInText = "Already have an account?",
687
1061
  signInLinkText = "Login Now",
688
1062
  signInUrl = "/sign-in",
@@ -690,16 +1064,19 @@ function SignUp({
690
1064
  onSuccess,
691
1065
  onError
692
1066
  }) {
693
- const { signUp } = useAuth();
1067
+ const { sendVerificationCode, verifySignUpCode, oauthProviders, baseUrl } = useInsforge();
694
1068
  const [email, setEmail] = useState4("");
695
1069
  const [password, setPassword] = useState4("");
1070
+ const [verificationCode, setVerificationCode] = useState4("");
696
1071
  const [error, setError] = useState4("");
697
1072
  const [loading, setLoading] = useState4(false);
698
- const [showPassword, setShowPassword] = useState4(false);
699
1073
  const [oauthLoading, setOauthLoading] = useState4(null);
700
- const [showPasswordStrength, setShowPasswordStrength] = useState4(false);
1074
+ const [verified, setVerified] = useState4(false);
1075
+ const [step, setStep] = useState4(
1076
+ "credentials"
1077
+ );
701
1078
  const insforge = useState4(() => createClient3({ baseUrl }))[0];
702
- async function handleSubmit(e) {
1079
+ async function handleCredentialsSubmit(e) {
703
1080
  e.preventDefault();
704
1081
  setLoading(true);
705
1082
  setError("");
@@ -709,20 +1086,53 @@ function SignUp({
709
1086
  return;
710
1087
  }
711
1088
  try {
712
- await signUp(email, password);
1089
+ await sendVerificationCode(email, "signup");
1090
+ setStep("verification");
1091
+ } catch (err) {
1092
+ const errorMessage = err.message || "Failed to send verification code";
1093
+ setError(errorMessage);
1094
+ if (onError) onError(new Error(errorMessage));
1095
+ } finally {
1096
+ setLoading(false);
1097
+ }
1098
+ }
1099
+ async function handleVerificationSubmit(e) {
1100
+ e.preventDefault();
1101
+ setLoading(true);
1102
+ setError("");
1103
+ if (verificationCode.length !== 6) {
1104
+ setError("Please enter the complete verification code");
1105
+ setLoading(false);
1106
+ return;
1107
+ }
1108
+ try {
1109
+ await verifySignUpCode(email, password, verificationCode);
713
1110
  if (onSuccess) {
1111
+ setVerified(true);
714
1112
  const userResult = await insforge.auth.getCurrentUser();
715
1113
  if (userResult.data) onSuccess(userResult.data);
716
1114
  }
717
1115
  window.location.href = afterSignUpUrl;
718
1116
  } catch (err) {
719
- const errorMessage = err.message || "Sign up failed";
1117
+ const errorMessage = err.message || "Invalid verification code";
720
1118
  setError(errorMessage);
721
1119
  if (onError) onError(new Error(errorMessage));
722
1120
  } finally {
723
1121
  setLoading(false);
724
1122
  }
725
1123
  }
1124
+ async function handleResendCode() {
1125
+ setLoading(true);
1126
+ setError("");
1127
+ try {
1128
+ await sendVerificationCode(email, "signup");
1129
+ } catch (err) {
1130
+ const errorMessage = err.message || "Failed to resend code";
1131
+ setError(errorMessage);
1132
+ } finally {
1133
+ setLoading(false);
1134
+ }
1135
+ }
726
1136
  async function handleOAuth(provider) {
727
1137
  try {
728
1138
  setOauthLoading(provider);
@@ -742,188 +1152,124 @@ function SignUp({
742
1152
  setOauthLoading(null);
743
1153
  }
744
1154
  }
745
- return /* @__PURE__ */ jsx6("div", { className: "insforge-auth-container", style: appearance.container, children: /* @__PURE__ */ jsx6("div", { className: "insforge-auth-card", style: appearance.form, children: /* @__PURE__ */ jsxs4("div", { className: "insforge-auth-content", children: [
746
- /* @__PURE__ */ jsxs4("div", { className: "insforge-auth-header", children: [
747
- /* @__PURE__ */ jsx6("h1", { className: "insforge-auth-title", children: title }),
748
- /* @__PURE__ */ jsx6("p", { className: "insforge-auth-subtitle", children: subtitle })
749
- ] }),
750
- error && /* @__PURE__ */ jsxs4("div", { className: "insforge-error-banner", children: [
751
- /* @__PURE__ */ jsx6(AlertTriangle2, { className: "insforge-error-icon" }),
752
- /* @__PURE__ */ jsx6("span", { children: error })
753
- ] }),
754
- /* @__PURE__ */ jsxs4("form", { onSubmit: handleSubmit, className: "insforge-form", children: [
755
- /* @__PURE__ */ jsxs4("div", { className: "insforge-form-group", children: [
756
- /* @__PURE__ */ jsx6("label", { htmlFor: "email", className: "insforge-form-label", children: emailLabel }),
757
- /* @__PURE__ */ jsx6(
758
- "input",
1155
+ if (step === "credentials") {
1156
+ return /* @__PURE__ */ jsxs14(AuthContainer, { style: appearance.container, children: [
1157
+ /* @__PURE__ */ jsx17(AuthHeader, { title, subtitle }),
1158
+ /* @__PURE__ */ jsx17(AuthErrorBanner, { error }),
1159
+ /* @__PURE__ */ jsxs14("form", { onSubmit: handleCredentialsSubmit, className: "insforge-form", children: [
1160
+ /* @__PURE__ */ jsx17(
1161
+ AuthFormField,
759
1162
  {
760
1163
  id: "email",
761
1164
  type: "email",
762
- className: "insforge-input",
1165
+ label: emailLabel,
763
1166
  placeholder: emailPlaceholder,
764
1167
  value: email,
765
1168
  onChange: (e) => setEmail(e.target.value),
766
1169
  required: true,
767
1170
  autoComplete: "email"
768
1171
  }
1172
+ ),
1173
+ /* @__PURE__ */ jsx17(
1174
+ AuthPasswordField,
1175
+ {
1176
+ id: "password",
1177
+ label: passwordLabel,
1178
+ placeholder: passwordPlaceholder,
1179
+ value: password,
1180
+ onChange: (e) => setPassword(e.target.value),
1181
+ required: true,
1182
+ minLength: 8,
1183
+ autoComplete: "new-password",
1184
+ showStrengthIndicator: true
1185
+ }
1186
+ ),
1187
+ /* @__PURE__ */ jsx17(
1188
+ AuthSubmitButton,
1189
+ {
1190
+ isLoading: loading,
1191
+ disabled: loading || oauthLoading !== null,
1192
+ style: appearance.button,
1193
+ children: loading ? loadingButtonText : submitButtonText
1194
+ }
769
1195
  )
770
1196
  ] }),
771
- /* @__PURE__ */ jsxs4("div", { className: "insforge-form-group", children: [
772
- /* @__PURE__ */ jsx6("label", { htmlFor: "password", className: "insforge-form-label", children: passwordLabel }),
773
- /* @__PURE__ */ jsxs4("div", { className: "insforge-input-wrapper", children: [
774
- /* @__PURE__ */ jsx6(
775
- "input",
776
- {
777
- id: "password",
778
- type: showPassword ? "text" : "password",
779
- className: "insforge-input insforge-input-with-icon",
780
- placeholder: passwordPlaceholder,
781
- value: password,
782
- onChange: (e) => setPassword(e.target.value),
783
- onFocus: () => setShowPasswordStrength(true),
784
- required: true,
785
- minLength: 8,
786
- autoComplete: "new-password"
787
- }
788
- ),
789
- /* @__PURE__ */ jsx6(
790
- "button",
791
- {
792
- type: "button",
793
- onClick: () => setShowPassword(!showPassword),
794
- className: "insforge-input-icon-btn",
795
- "aria-label": showPassword ? "Hide password" : "Show password",
796
- children: showPassword ? /* @__PURE__ */ jsx6(EyeOff2, { size: 20 }) : /* @__PURE__ */ jsx6(Eye2, { size: 20 })
797
- }
798
- )
799
- ] }),
800
- showPasswordStrength && /* @__PURE__ */ jsx6(PasswordStrengthIndicator, { password })
801
- ] }),
802
- /* @__PURE__ */ jsxs4(
803
- "button",
1197
+ /* @__PURE__ */ jsx17(
1198
+ AuthLink,
804
1199
  {
805
- type: "submit",
806
- className: "insforge-btn-primary",
1200
+ text: signInText,
1201
+ linkText: signInLinkText,
1202
+ href: signInUrl
1203
+ }
1204
+ ),
1205
+ oauthProviders.length > 0 && /* @__PURE__ */ jsxs14(Fragment2, { children: [
1206
+ /* @__PURE__ */ jsx17(AuthDivider, { text: dividerText }),
1207
+ /* @__PURE__ */ jsx17(
1208
+ AuthOAuthProviders,
1209
+ {
1210
+ providers: oauthProviders,
1211
+ onClick: handleOAuth,
1212
+ disabled: loading || oauthLoading !== null,
1213
+ loading: oauthLoading
1214
+ }
1215
+ )
1216
+ ] })
1217
+ ] });
1218
+ }
1219
+ return /* @__PURE__ */ jsxs14(AuthContainer, { style: appearance.container, children: [
1220
+ /* @__PURE__ */ jsx17(AuthHeader, { title, subtitle }),
1221
+ /* @__PURE__ */ jsx17(AuthErrorBanner, { error }),
1222
+ /* @__PURE__ */ jsxs14("form", { onSubmit: handleVerificationSubmit, className: "insforge-form", children: [
1223
+ /* @__PURE__ */ jsx17(
1224
+ AuthVerificationCodeInput,
1225
+ {
1226
+ email,
1227
+ value: verificationCode,
1228
+ onChange: setVerificationCode,
1229
+ disabled: loading
1230
+ }
1231
+ ),
1232
+ /* @__PURE__ */ jsx17(
1233
+ AuthSubmitButton,
1234
+ {
1235
+ isLoading: loading,
1236
+ disabled: loading,
807
1237
  style: appearance.button,
808
- disabled: loading || oauthLoading !== null,
809
- "data-loading": loading || void 0,
810
- children: [
811
- loading && /* @__PURE__ */ jsx6(Loader23, { className: "insforge-btn-loader", size: 20 }),
812
- loading ? loadingButtonText : submitButtonText
813
- ]
1238
+ confirmed: verified,
1239
+ children: verified ? verifiedButtonText : loading ? loadingVerifyButtonText : verifyButtonText
814
1240
  }
815
1241
  )
816
1242
  ] }),
817
- /* @__PURE__ */ jsxs4("p", { className: "insforge-text-center", children: [
818
- signInText,
1243
+ /* @__PURE__ */ jsxs14("div", { className: "insforge-resend-code", children: [
1244
+ "Did not received the code?",
819
1245
  " ",
820
- /* @__PURE__ */ jsx6("a", { href: signInUrl, className: "insforge-link-primary", children: signInLinkText })
821
- ] }),
822
- providers.length > 0 && /* @__PURE__ */ jsxs4(Fragment2, { children: [
823
- /* @__PURE__ */ jsx6("div", { className: "insforge-divider", children: /* @__PURE__ */ jsx6("span", { className: "insforge-divider-text", children: dividerText }) }),
824
- /* @__PURE__ */ jsx6("div", { className: "insforge-oauth-container", children: providers.map((provider) => /* @__PURE__ */ jsx6(
825
- OAuthButton,
826
- {
827
- provider,
828
- onClick: handleOAuth,
829
- disabled: loading || oauthLoading !== null,
830
- loading: oauthLoading === provider
831
- },
832
- provider
833
- )) })
834
- ] }),
835
- /* @__PURE__ */ jsxs4("div", { className: "insforge-branding", children: [
836
- /* @__PURE__ */ jsx6("p", { className: "insforge-branding-text", children: "Powered by" }),
837
- /* @__PURE__ */ jsx6(
838
- Link2,
1246
+ /* @__PURE__ */ jsx17(
1247
+ "button",
839
1248
  {
840
- href: "https://insforge.dev",
841
- target: "_blank",
842
- rel: "noopener noreferrer",
843
- children: /* @__PURE__ */ jsxs4(
844
- "svg",
845
- {
846
- width: "83",
847
- height: "20",
848
- viewBox: "0 0 83 20",
849
- fill: "none",
850
- xmlns: "http://www.w3.org/2000/svg",
851
- children: [
852
- /* @__PURE__ */ jsx6(
853
- "path",
854
- {
855
- d: "M2.16783 8.46797C1.9334 8.23325 1.9334 7.85269 2.16783 7.61797L8.11049 1.66797L16.6 1.66797L6.41259 11.868C6.17815 12.1027 5.79807 12.1027 5.56363 11.868L2.16783 8.46797Z",
856
- fill: "url(#paint0_linear_2976_9475)"
857
- }
858
- ),
859
- /* @__PURE__ */ jsx6(
860
- "path",
861
- {
862
- d: "M12.8858 6.44922L16.6 10.168V18.668L8.64108 10.6992L12.8858 6.44922Z",
863
- fill: "url(#paint1_linear_2976_9475)"
864
- }
865
- ),
866
- /* @__PURE__ */ jsx6(
867
- "path",
868
- {
869
- d: "M67.5439 6.48828C68.2894 6.48828 68.9145 6.67064 69.418 7.03516C69.5229 7.10943 69.6214 7.1907 69.7158 7.27637V6.70703H71.248V14.959C71.248 15.1583 71.2381 15.3485 71.2188 15.5283C71.2042 15.7129 71.1774 15.8925 71.1387 16.0674C71.0225 16.5776 70.7998 16.9957 70.4707 17.3213C70.1415 17.6518 69.7321 17.8972 69.2432 18.0576C68.7592 18.2179 68.2222 18.2988 67.6318 18.2988C67.1962 18.2988 66.7768 18.2308 66.375 18.0947C65.9782 17.9587 65.6202 17.7614 65.3008 17.5039C64.9813 17.2512 64.7199 16.9446 64.5166 16.585L66.1289 15.7832C66.2789 16.0698 66.4888 16.2819 66.7598 16.418C67.0356 16.5589 67.3289 16.6289 67.6387 16.6289C68.0016 16.6289 68.3258 16.5628 68.6113 16.4316C68.8969 16.3053 69.1176 16.116 69.2725 15.8633C69.4321 15.6155 69.5077 15.3047 69.498 14.9307V14.1797C69.4665 14.2037 69.4359 14.229 69.4033 14.252C68.8855 14.6164 68.2441 14.7988 67.4795 14.7988C66.7582 14.7988 66.1281 14.6165 65.5908 14.252C65.0537 13.8875 64.637 13.3915 64.3418 12.7646C64.0467 12.1378 63.8994 11.4307 63.8994 10.6436C63.8994 9.84651 64.0465 9.13673 64.3418 8.51465C64.6419 7.88768 65.0663 7.39481 65.6133 7.03516C66.1601 6.67077 66.8036 6.48836 67.5439 6.48828ZM37.5 6.48828C38.1099 6.48828 38.6496 6.58294 39.1191 6.77246C39.5935 6.96201 39.9762 7.2321 40.2666 7.58203C40.5569 7.93184 40.7359 8.34227 40.8037 8.81348L39.0176 9.13477C38.974 8.79951 38.8218 8.53424 38.5605 8.33984C38.304 8.14547 37.96 8.03605 37.5293 8.01172C37.1178 7.98742 36.7859 8.05051 36.5342 8.20117C36.2825 8.34698 36.1562 8.55398 36.1562 8.82129C36.1563 8.97184 36.208 9.10017 36.3096 9.20703C36.4112 9.31394 36.614 9.42141 36.9189 9.52832C37.2288 9.63524 37.6889 9.76635 38.2988 9.92188C38.9232 10.0823 39.4222 10.2666 39.7949 10.4756C40.1722 10.6796 40.4428 10.9254 40.6074 11.2119C40.7768 11.4987 40.8623 11.8466 40.8623 12.2549C40.8623 13.047 40.574 13.6691 39.998 14.1211C39.4268 14.5731 38.6348 14.7988 37.623 14.7988C36.6551 14.7988 35.8687 14.5799 35.2637 14.1426C34.6587 13.7052 34.2909 13.0908 34.1602 12.2988L35.9463 12.0215C36.0383 12.4102 36.2411 12.7169 36.5557 12.9404C36.8703 13.164 37.2678 13.2754 37.7471 13.2754C38.1681 13.2754 38.4922 13.1926 38.7197 13.0273C38.9521 12.8572 39.0684 12.6266 39.0684 12.335C39.0684 12.1552 39.0245 12.0122 38.9375 11.9053C38.8552 11.7935 38.6713 11.686 38.3857 11.584C38.1001 11.4819 37.6618 11.3528 37.0713 11.1973C36.4131 11.0223 35.8901 10.8359 35.5029 10.6367C35.1158 10.4327 34.8374 10.192 34.668 9.91504C34.4985 9.63801 34.4141 9.30188 34.4141 8.9082C34.4141 8.41746 34.5423 7.98943 34.7988 7.625C35.0553 7.26073 35.4135 6.98146 35.873 6.78711C36.3329 6.58784 36.8755 6.48828 37.5 6.48828ZM53.3047 6.48828C54.0937 6.48828 54.7815 6.66572 55.3672 7.02051C55.9527 7.37528 56.4072 7.86634 56.7314 8.49316C57.0558 9.11525 57.2187 9.83193 57.2188 10.6436C57.2188 11.46 57.0537 12.1817 56.7246 12.8086C56.4003 13.4307 55.9451 13.9196 55.3594 14.2744C54.7737 14.6242 54.0888 14.7988 53.3047 14.7988C52.5205 14.7988 51.8357 14.6214 51.25 14.2666C50.6643 13.9118 50.2091 13.4238 49.8848 12.8018C49.5653 12.1748 49.4053 11.4552 49.4053 10.6436C49.4053 9.81735 49.5703 9.09279 49.8994 8.4707C50.2286 7.8488 50.6859 7.36255 51.2715 7.0127C51.8572 6.66281 52.5351 6.48828 53.3047 6.48828ZM76.7471 6.48828C77.5603 6.48828 78.25 6.68053 78.8164 7.06445C79.3876 7.44351 79.812 7.97991 80.0879 8.6748C80.3638 9.36976 80.4672 10.189 80.3994 11.1318H74.7256C74.7843 11.6972 74.949 12.1516 75.2227 12.4951C75.5711 12.9325 76.0792 13.1513 76.7471 13.1514C77.1779 13.1514 77.5486 13.0567 77.8584 12.8672C78.173 12.6728 78.4146 12.3928 78.584 12.0283L80.3125 12.5537C80.0124 13.2633 79.5473 13.8153 78.918 14.209C78.2936 14.6025 77.6036 14.7988 76.8486 14.7988C76.0549 14.7988 75.358 14.6263 74.7578 14.2812C74.1576 13.9362 73.6875 13.458 73.3486 12.8457C73.0147 12.2334 72.8477 11.5284 72.8477 10.7314C72.8477 9.87126 73.0127 9.12495 73.3418 8.49316C73.671 7.85651 74.1282 7.36263 74.7139 7.0127C75.2995 6.6628 75.9775 6.48832 76.7471 6.48828ZM23.3301 14.5801H21.5801V4.08203H23.3301V14.5801ZM29.6152 6.48047C30.1959 6.48052 30.6753 6.5781 31.0527 6.77246C31.4301 6.96681 31.7305 7.21443 31.9531 7.51562C32.1758 7.81695 32.3398 8.13831 32.4463 8.47852C32.5528 8.81873 32.6213 9.14205 32.6504 9.44824C32.6843 9.74946 32.7012 9.99508 32.7012 10.1846V14.5801H30.9287V10.7891C30.9287 10.5413 30.9118 10.2669 30.8779 9.96582C30.844 9.66449 30.7645 9.37469 30.6387 9.09766C30.5177 8.81592 30.3337 8.58503 30.0869 8.40527C29.8449 8.22551 29.5157 8.13579 29.0996 8.13574C28.8769 8.13574 28.6563 8.17221 28.4385 8.24512C28.2206 8.31802 28.0219 8.4442 27.8428 8.62402C27.6685 8.79899 27.5284 9.04249 27.4219 9.35352C27.3154 9.65965 27.2617 10.0532 27.2617 10.5342V14.5801H25.4902V6.70703H27.0518V7.58301C27.2521 7.34675 27.486 7.14172 27.7559 6.96973C28.2593 6.64409 28.8794 6.48047 29.6152 6.48047ZM48.748 5.83887H44.2021V8.45605H47.876V10.2061H44.2021V14.5801H42.4521V4.08203H48.748V5.83887ZM62.5137 6.67773C62.7606 6.65829 63.001 6.66815 63.2334 6.70703V8.34766C63.001 8.27961 62.7317 8.25695 62.4268 8.28125C62.1267 8.30557 61.8553 8.39134 61.6133 8.53711C61.3715 8.66829 61.1733 8.83606 61.0186 9.04004C60.8686 9.24404 60.7572 9.47701 60.6846 9.73926C60.612 9.99685 60.5752 10.2768 60.5752 10.5781V14.5801H58.8184V6.70703H60.3652V7.96582C60.4243 7.85986 60.4888 7.75824 60.5605 7.66211C60.7251 7.4434 60.9219 7.26302 61.1494 7.12207C61.3429 6.99098 61.5559 6.88926 61.7881 6.81641C62.0251 6.73869 62.267 6.69235 62.5137 6.67773ZM67.8057 8.0625C67.3362 8.06252 66.9485 8.17982 66.6436 8.41309C66.3389 8.64144 66.1139 8.95232 65.9688 9.3457C65.8235 9.7345 65.751 10.1673 65.751 10.6436C65.751 11.1247 65.8215 11.5624 65.9619 11.9561C66.1071 12.3447 66.3269 12.6535 66.6221 12.8818C66.9174 13.1103 67.293 13.2246 67.748 13.2246C68.2174 13.2246 68.5953 13.1171 68.8809 12.9033C69.1711 12.6846 69.3811 12.3808 69.5117 11.9922C69.6473 11.6034 69.7158 11.1539 69.7158 10.6436C69.7158 10.1284 69.6473 9.67886 69.5117 9.29492C69.381 8.90617 69.1753 8.60445 68.8945 8.39062C68.6138 8.17213 68.2508 8.0625 67.8057 8.0625ZM53.3047 8.13574C52.8351 8.13574 52.4475 8.24222 52.1426 8.45605C51.8425 8.66504 51.6198 8.95977 51.4746 9.33887C51.3295 9.71303 51.2568 10.148 51.2568 10.6436C51.2568 11.4066 51.4288 12.0168 51.7725 12.4736C52.121 12.9256 52.6318 13.1514 53.3047 13.1514C54.0017 13.1514 54.5196 12.9177 54.8584 12.4512C55.1971 11.9846 55.3672 11.3822 55.3672 10.6436C55.3672 9.8807 55.1951 9.27324 54.8516 8.82129C54.5079 8.36444 53.9921 8.13575 53.3047 8.13574ZM76.8203 8.02637C76.1039 8.02637 75.5712 8.25013 75.2227 8.69727C74.9987 8.98144 74.8476 9.35094 74.7676 9.80566H78.6221C78.5589 9.29301 78.4236 8.89686 78.2139 8.61719C77.9186 8.22359 77.4543 8.02645 76.8203 8.02637Z",
870
- fill: "black"
871
- }
872
- ),
873
- /* @__PURE__ */ jsxs4("defs", { children: [
874
- /* @__PURE__ */ jsxs4(
875
- "linearGradient",
876
- {
877
- id: "paint0_linear_2976_9475",
878
- x1: "1.85883",
879
- y1: "1.92425",
880
- x2: "24.3072",
881
- y2: "9.64016",
882
- gradientUnits: "userSpaceOnUse",
883
- children: [
884
- /* @__PURE__ */ jsx6("stop", {}),
885
- /* @__PURE__ */ jsx6("stop", { offset: "1", stopOpacity: "0.4" })
886
- ]
887
- }
888
- ),
889
- /* @__PURE__ */ jsxs4(
890
- "linearGradient",
891
- {
892
- id: "paint1_linear_2976_9475",
893
- x1: "25.6475",
894
- y1: "8.65468",
895
- x2: "10.7901",
896
- y2: "8.65468",
897
- gradientUnits: "userSpaceOnUse",
898
- children: [
899
- /* @__PURE__ */ jsx6("stop", {}),
900
- /* @__PURE__ */ jsx6("stop", { offset: "1", stopOpacity: "0.4" })
901
- ]
902
- }
903
- )
904
- ] })
905
- ]
906
- }
907
- )
1249
+ type: "button",
1250
+ onClick: handleResendCode,
1251
+ disabled: loading,
1252
+ className: "insforge-resend-link",
1253
+ children: "Click to resend"
908
1254
  }
909
1255
  )
910
1256
  ] })
911
- ] }) }) });
1257
+ ] });
912
1258
  }
913
1259
 
914
1260
  // src/components/UserButton.tsx
915
- import { useState as useState5, useRef as useRef2, useEffect as useEffect3 } from "react";
1261
+ import { useState as useState5, useRef as useRef3, useEffect as useEffect2 } from "react";
916
1262
  import { LogOut } from "lucide-react";
917
- import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
1263
+ import { jsx as jsx18, jsxs as jsxs15 } from "react/jsx-runtime";
918
1264
  function UserButton({
919
1265
  afterSignOutUrl = "/",
920
1266
  mode = "detailed",
921
1267
  appearance = {}
922
1268
  }) {
923
- const { user, signOut } = useAuth();
1269
+ const { user, signOut } = useInsforge();
924
1270
  const [isOpen, setIsOpen] = useState5(false);
925
- const dropdownRef = useRef2(null);
926
- useEffect3(() => {
1271
+ const dropdownRef = useRef3(null);
1272
+ useEffect2(() => {
927
1273
  function handleClickOutside(event) {
928
1274
  if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
929
1275
  setIsOpen(false);
@@ -944,8 +1290,8 @@ function UserButton({
944
1290
  if (!user) return null;
945
1291
  const initials = user.nickname ? user.nickname.charAt(0).toUpperCase() : user.email.split("@")[0].slice(0, 2).toUpperCase();
946
1292
  const avatarUrl = user.avatar_url;
947
- return /* @__PURE__ */ jsxs5("div", { className: "insforge-user-button-container", ref: dropdownRef, children: [
948
- /* @__PURE__ */ jsxs5(
1293
+ return /* @__PURE__ */ jsxs15("div", { className: "insforge-user-button-container", ref: dropdownRef, children: [
1294
+ /* @__PURE__ */ jsxs15(
949
1295
  "button",
950
1296
  {
951
1297
  className: `insforge-user-button ${mode === "detailed" ? "insforge-user-button-detailed" : ""}`,
@@ -954,52 +1300,52 @@ function UserButton({
954
1300
  "aria-expanded": isOpen,
955
1301
  "aria-haspopup": "true",
956
1302
  children: [
957
- avatarUrl ? /* @__PURE__ */ jsx7("img", { src: avatarUrl, alt: user.email, className: "insforge-user-avatar" }) : /* @__PURE__ */ jsx7("div", { className: "insforge-user-avatar-placeholder", children: initials }),
958
- mode === "detailed" && /* @__PURE__ */ jsxs5("div", { className: "insforge-user-button-info", children: [
959
- user.nickname && /* @__PURE__ */ jsx7("div", { className: "insforge-user-button-name", children: user.nickname }),
960
- /* @__PURE__ */ jsx7("div", { className: "insforge-user-button-email", children: user.email })
1303
+ avatarUrl ? /* @__PURE__ */ jsx18("img", { src: avatarUrl, alt: user.email, className: "insforge-user-avatar" }) : /* @__PURE__ */ jsx18("div", { className: "insforge-user-avatar-placeholder", children: initials }),
1304
+ mode === "detailed" && /* @__PURE__ */ jsxs15("div", { className: "insforge-user-button-info", children: [
1305
+ user.nickname && /* @__PURE__ */ jsx18("div", { className: "insforge-user-button-name", children: user.nickname }),
1306
+ /* @__PURE__ */ jsx18("div", { className: "insforge-user-button-email", children: user.email })
961
1307
  ] })
962
1308
  ]
963
1309
  }
964
1310
  ),
965
- isOpen && /* @__PURE__ */ jsx7("div", { className: "insforge-user-dropdown", style: appearance.dropdown, children: /* @__PURE__ */ jsxs5("button", { onClick: handleSignOut, className: "insforge-sign-out-button", children: [
966
- /* @__PURE__ */ jsx7(LogOut, { className: "w-5 h-5" }),
1311
+ isOpen && /* @__PURE__ */ jsx18("div", { className: "insforge-user-dropdown", style: appearance.dropdown, children: /* @__PURE__ */ jsxs15("button", { onClick: handleSignOut, className: "insforge-sign-out-button", children: [
1312
+ /* @__PURE__ */ jsx18(LogOut, { className: "w-5 h-5" }),
967
1313
  "Sign out"
968
1314
  ] }) })
969
1315
  ] });
970
1316
  }
971
1317
 
972
1318
  // src/components/SignedIn.tsx
973
- import { Fragment as Fragment3, jsx as jsx8 } from "react/jsx-runtime";
1319
+ import { Fragment as Fragment3, jsx as jsx19 } from "react/jsx-runtime";
974
1320
  function SignedIn({ children }) {
975
- const { isSignedIn, isLoaded } = useAuth();
1321
+ const { isSignedIn, isLoaded } = useInsforge();
976
1322
  if (!isLoaded) return null;
977
1323
  if (!isSignedIn) return null;
978
- return /* @__PURE__ */ jsx8(Fragment3, { children });
1324
+ return /* @__PURE__ */ jsx19(Fragment3, { children });
979
1325
  }
980
1326
 
981
1327
  // src/components/SignedOut.tsx
982
- import { Fragment as Fragment4, jsx as jsx9 } from "react/jsx-runtime";
1328
+ import { Fragment as Fragment4, jsx as jsx20 } from "react/jsx-runtime";
983
1329
  function SignedOut({ children }) {
984
- const { isSignedIn, isLoaded } = useAuth();
1330
+ const { isSignedIn, isLoaded } = useInsforge();
985
1331
  if (!isLoaded) return null;
986
1332
  if (isSignedIn) return null;
987
- return /* @__PURE__ */ jsx9(Fragment4, { children });
1333
+ return /* @__PURE__ */ jsx20(Fragment4, { children });
988
1334
  }
989
1335
 
990
1336
  // src/components/Protect.tsx
991
- import { useEffect as useEffect4 } from "react";
1337
+ import { useEffect as useEffect3 } from "react";
992
1338
  import { useRouter } from "next/navigation";
993
- import { Fragment as Fragment5, jsx as jsx10 } from "react/jsx-runtime";
1339
+ import { Fragment as Fragment5, jsx as jsx21 } from "react/jsx-runtime";
994
1340
  function Protect({
995
1341
  children,
996
1342
  fallback,
997
1343
  redirectTo = "/sign-in",
998
1344
  condition
999
1345
  }) {
1000
- const { isSignedIn, isLoaded, user } = useAuth();
1346
+ const { isSignedIn, isLoaded, user } = useInsforge();
1001
1347
  const router = useRouter();
1002
- useEffect4(() => {
1348
+ useEffect3(() => {
1003
1349
  if (isLoaded && !isSignedIn) {
1004
1350
  router.push(redirectTo);
1005
1351
  } else if (isLoaded && isSignedIn && condition && user) {
@@ -1009,7 +1355,7 @@ function Protect({
1009
1355
  }
1010
1356
  }, [isLoaded, isSignedIn, redirectTo, router, condition, user]);
1011
1357
  if (!isLoaded) {
1012
- return fallback || /* @__PURE__ */ jsx10("div", { className: "insforge-loading", children: "Loading..." });
1358
+ return fallback || /* @__PURE__ */ jsx21("div", { className: "insforge-loading", children: "Loading..." });
1013
1359
  }
1014
1360
  if (!isSignedIn) {
1015
1361
  return fallback || null;
@@ -1017,21 +1363,38 @@ function Protect({
1017
1363
  if (condition && user && !condition(user)) {
1018
1364
  return fallback || null;
1019
1365
  }
1020
- return /* @__PURE__ */ jsx10(Fragment5, { children });
1366
+ return /* @__PURE__ */ jsx21(Fragment5, { children });
1021
1367
  }
1022
1368
  export {
1023
- AuthProvider,
1024
- InsforgeConfigProvider,
1369
+ AuthBranding,
1370
+ AuthContainer,
1371
+ AuthDivider,
1372
+ AuthErrorBanner,
1373
+ AuthFormField,
1374
+ AuthHeader,
1375
+ AuthLink,
1376
+ AuthOAuthButton,
1377
+ AuthOAuthProviders,
1378
+ AuthPasswordField,
1379
+ AuthPasswordStrengthIndicator,
1380
+ AuthSubmitButton,
1381
+ AuthVerificationCodeInput,
1382
+ InsforgeProvider,
1383
+ OAUTH_PROVIDER_CONFIG,
1025
1384
  Protect,
1026
1385
  SignIn,
1027
1386
  SignUp,
1028
1387
  SignedIn,
1029
1388
  SignedOut,
1030
1389
  UserButton,
1390
+ getProviderConfig,
1391
+ getProviderName,
1392
+ isProviderSupported,
1031
1393
  useAuth,
1032
- useInsforgeConfig,
1394
+ useInsforge,
1033
1395
  useOAuthProviders,
1034
1396
  useSession,
1035
- useUser
1397
+ useUser,
1398
+ validatePasswordStrength
1036
1399
  };
1037
1400
  //# sourceMappingURL=index.mjs.map