@insforge/nextjs 0.4.0 → 0.6.5

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.js CHANGED
@@ -32,33 +32,68 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
32
32
  // src/index.ts
33
33
  var src_exports = {};
34
34
  __export(src_exports, {
35
- AuthProvider: () => AuthProvider,
36
- InsforgeConfigProvider: () => InsforgeConfigProvider,
35
+ AuthBranding: () => AuthBranding,
36
+ AuthContainer: () => AuthContainer,
37
+ AuthDivider: () => AuthDivider,
38
+ AuthErrorBanner: () => AuthErrorBanner,
39
+ AuthFormField: () => AuthFormField,
40
+ AuthHeader: () => AuthHeader,
41
+ AuthLink: () => AuthLink,
42
+ AuthOAuthButton: () => AuthOAuthButton,
43
+ AuthOAuthProviders: () => AuthOAuthProviders,
44
+ AuthPasswordField: () => AuthPasswordField,
45
+ AuthPasswordStrengthIndicator: () => AuthPasswordStrengthIndicator,
46
+ AuthSubmitButton: () => AuthSubmitButton,
47
+ AuthVerificationCodeInput: () => AuthVerificationCodeInput,
48
+ InsforgeProvider: () => InsforgeProvider,
49
+ OAUTH_PROVIDER_CONFIG: () => OAUTH_PROVIDER_CONFIG,
37
50
  Protect: () => Protect,
38
51
  SignIn: () => SignIn,
39
52
  SignUp: () => SignUp,
40
53
  SignedIn: () => SignedIn,
41
54
  SignedOut: () => SignedOut,
42
55
  UserButton: () => UserButton,
56
+ getProviderConfig: () => getProviderConfig,
57
+ getProviderName: () => getProviderName,
58
+ isProviderSupported: () => isProviderSupported,
43
59
  useAuth: () => useAuth,
44
- useInsforgeConfig: () => useInsforgeConfig,
60
+ useInsforge: () => useInsforge,
45
61
  useOAuthProviders: () => useOAuthProviders,
46
62
  useSession: () => useSession,
47
- useUser: () => useUser
63
+ useUser: () => useUser,
64
+ validatePasswordStrength: () => validatePasswordStrength
48
65
  });
49
66
  module.exports = __toCommonJS(src_exports);
50
67
 
51
- // src/provider/AuthProvider.tsx
68
+ // src/provider/InsforgeProvider.tsx
52
69
  var import_react = require("react");
53
70
  var import_sdk = require("@insforge/sdk");
54
71
  var import_jsx_runtime = require("react/jsx-runtime");
55
- var AuthContext = (0, import_react.createContext)(void 0);
72
+ var InsforgeContext = (0, import_react.createContext)(void 0);
73
+ async function fetchOAuthProviders(baseUrl) {
74
+ try {
75
+ const response = await fetch(`${baseUrl}/api/auth/oauth/configs`);
76
+ if (!response.ok) return [];
77
+ const result = await response.json();
78
+ if (result?.data && Array.isArray(result.data)) {
79
+ return result.data.map((config) => config.provider);
80
+ }
81
+ return [];
82
+ } catch (error) {
83
+ console.warn("Failed to fetch OAuth configs:", error);
84
+ return [];
85
+ }
86
+ }
56
87
  function getTokenFromSDK() {
88
+ console.log("[InsforgeProvider] Getting token from SDK");
57
89
  if (typeof window === "undefined") return null;
90
+ console.log("[InsforgeProvider] Window:", window);
58
91
  try {
59
92
  const token = localStorage.getItem("insforge-auth-token");
93
+ console.log("[InsforgeProvider] Token:", token);
60
94
  return token;
61
95
  } catch (error) {
96
+ console.error("[InsforgeProvider] Error getting token from SDK:", error);
62
97
  return null;
63
98
  }
64
99
  }
@@ -82,12 +117,28 @@ async function syncTokenToCookie(token) {
82
117
  return false;
83
118
  }
84
119
  }
85
- function AuthProvider({ children, baseUrl, onAuthChange }) {
120
+ function InsforgeProvider({
121
+ children,
122
+ baseUrl,
123
+ frontendUrl,
124
+ onAuthChange,
125
+ useBuiltInAuth = true
126
+ }) {
86
127
  const [user, setUser] = (0, import_react.useState)(null);
87
128
  const [session, setSession] = (0, import_react.useState)(null);
88
129
  const [isLoaded, setIsLoaded] = (0, import_react.useState)(false);
130
+ const [oauthProviders, setOauthProviders] = (0, import_react.useState)([]);
131
+ const [isConfigLoaded, setIsConfigLoaded] = (0, import_react.useState)(false);
89
132
  const refreshIntervalRef = (0, import_react.useRef)();
90
- const insforge = (0, import_react.useRef)((0, import_sdk.createClient)({ baseUrl })).current;
133
+ const [insforge] = (0, import_react.useState)(() => (0, import_sdk.createClient)({ baseUrl }));
134
+ (0, import_react.useEffect)(() => {
135
+ async function loadConfig() {
136
+ const providers = await fetchOAuthProviders(baseUrl);
137
+ setOauthProviders(providers);
138
+ setIsConfigLoaded(true);
139
+ }
140
+ loadConfig();
141
+ }, [baseUrl]);
91
142
  const loadAuthState = (0, import_react.useCallback)(async () => {
92
143
  try {
93
144
  const token = getTokenFromSDK();
@@ -100,33 +151,63 @@ function AuthProvider({ children, baseUrl, onAuthChange }) {
100
151
  setIsLoaded(true);
101
152
  return;
102
153
  }
154
+ const cachedUserStr = localStorage.getItem("insforge-user-profile");
155
+ if (cachedUserStr) {
156
+ try {
157
+ const cachedData = JSON.parse(cachedUserStr);
158
+ if (cachedData.user) {
159
+ console.log("[InsforgeProvider] Loading user from cache");
160
+ const userData = {
161
+ id: cachedData.user.id,
162
+ email: cachedData.user.email,
163
+ createdAt: cachedData.user.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
164
+ updatedAt: cachedData.user.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
165
+ ...cachedData.profile
166
+ };
167
+ setUser(userData);
168
+ setSession({
169
+ userId: cachedData.user.id,
170
+ token,
171
+ expiresAt: "",
172
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
173
+ });
174
+ if (onAuthChange) {
175
+ onAuthChange(userData);
176
+ }
177
+ setIsLoaded(true);
178
+ }
179
+ } catch (e) {
180
+ console.warn("[InsforgeProvider] Failed to parse cached user data:", e);
181
+ }
182
+ }
103
183
  try {
104
184
  await syncTokenToCookie(token);
105
185
  } catch (error) {
106
186
  }
107
187
  const userResult = await insforge.auth.getCurrentUser();
108
188
  if (userResult.data) {
189
+ console.log("[InsforgeProvider] User data refreshed from API");
109
190
  const userData = {
110
191
  id: userResult.data.user.id,
111
192
  email: userResult.data.user.email,
112
193
  createdAt: userResult.data.user.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
113
194
  updatedAt: userResult.data.user.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
114
195
  ...userResult.data.profile
115
- // Add profile data if available
116
196
  };
117
197
  setUser(userData);
118
198
  setSession({
119
199
  userId: userResult.data.user.id,
120
200
  token,
121
201
  expiresAt: "",
122
- // Insforge tokens are long-lived
123
202
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
124
203
  });
204
+ localStorage.setItem("insforge-user-profile", JSON.stringify(userResult.data));
125
205
  if (onAuthChange) {
126
206
  onAuthChange(userData);
127
207
  }
128
208
  } else {
129
209
  localStorage.removeItem("insforge-auth-token");
210
+ localStorage.removeItem("insforge-user-profile");
130
211
  try {
131
212
  await fetch("/api/auth", { method: "DELETE" });
132
213
  } catch (error) {
@@ -138,7 +219,9 @@ function AuthProvider({ children, baseUrl, onAuthChange }) {
138
219
  }
139
220
  }
140
221
  } catch (error) {
222
+ console.error("[InsforgeProvider] Token validation failed:", error);
141
223
  localStorage.removeItem("insforge-auth-token");
224
+ localStorage.removeItem("insforge-user-profile");
142
225
  try {
143
226
  await fetch("/api/auth", { method: "DELETE" });
144
227
  } catch (error2) {
@@ -185,10 +268,14 @@ function AuthProvider({ children, baseUrl, onAuthChange }) {
185
268
  try {
186
269
  await syncTokenToCookie(sdkResult.data.accessToken);
187
270
  } catch (error) {
271
+ console.error("Please add /api/auth route to your server to sync token to cookie:", error);
188
272
  }
273
+ } else {
274
+ const errorMessage = sdkResult.error?.message || "Invalid email or password";
275
+ throw new Error(errorMessage);
189
276
  }
190
277
  },
191
- [baseUrl, onAuthChange, insforge]
278
+ [insforge, onAuthChange]
192
279
  );
193
280
  const signUp = (0, import_react.useCallback)(
194
281
  async (email, password) => {
@@ -216,12 +303,16 @@ function AuthProvider({ children, baseUrl, onAuthChange }) {
216
303
  await syncTokenToCookie(sdkResult.data.accessToken);
217
304
  } catch (error) {
218
305
  }
306
+ } else {
307
+ const errorMessage = sdkResult.error?.message || "Sign up failed";
308
+ throw new Error(errorMessage);
219
309
  }
220
310
  },
221
- [baseUrl, onAuthChange, insforge]
311
+ [insforge, onAuthChange]
222
312
  );
223
313
  const signOut = (0, import_react.useCallback)(async () => {
224
314
  await insforge.auth.signOut();
315
+ localStorage.removeItem("insforge-user-profile");
225
316
  await fetch("/api/auth", { method: "DELETE" }).catch(() => {
226
317
  });
227
318
  if (refreshIntervalRef.current) {
@@ -232,7 +323,7 @@ function AuthProvider({ children, baseUrl, onAuthChange }) {
232
323
  if (onAuthChange) {
233
324
  onAuthChange(null);
234
325
  }
235
- }, [baseUrl, onAuthChange, insforge]);
326
+ }, [insforge, onAuthChange]);
236
327
  const updateUser = (0, import_react.useCallback)(
237
328
  async (data) => {
238
329
  if (!user) throw new Error("No user signed in");
@@ -247,143 +338,404 @@ function AuthProvider({ children, baseUrl, onAuthChange }) {
247
338
  },
248
339
  [user, onAuthChange, insforge]
249
340
  );
341
+ const sendVerificationCode = (0, import_react.useCallback)(
342
+ async (email, type) => {
343
+ console.log(`[Verification] Sending ${type} code to ${email}`);
344
+ console.log("[Verification] Dummy code: 123456");
345
+ await new Promise((resolve) => setTimeout(resolve, 500));
346
+ },
347
+ [insforge]
348
+ );
349
+ const verifySignUpCode = (0, import_react.useCallback)(
350
+ async (email, password, code) => {
351
+ if (code !== "123456") {
352
+ throw new Error("Invalid verification code");
353
+ }
354
+ const sdkResult = await insforge.auth.signUp({ email, password });
355
+ if (sdkResult.data) {
356
+ const userData = {
357
+ id: sdkResult.data.user.id,
358
+ email: sdkResult.data.user.email,
359
+ name: sdkResult.data.user.name || void 0,
360
+ createdAt: sdkResult.data.user.createdAt,
361
+ updatedAt: sdkResult.data.user.updatedAt
362
+ };
363
+ const sessionData = {
364
+ userId: sdkResult.data.user.id,
365
+ token: sdkResult.data.accessToken,
366
+ expiresAt: "",
367
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
368
+ };
369
+ setUser(userData);
370
+ setSession(sessionData);
371
+ if (onAuthChange) {
372
+ onAuthChange(userData);
373
+ }
374
+ try {
375
+ await syncTokenToCookie(sdkResult.data.accessToken);
376
+ } catch (error) {
377
+ }
378
+ } else {
379
+ const errorMessage = sdkResult.error?.message || "Sign up failed";
380
+ throw new Error(errorMessage);
381
+ }
382
+ },
383
+ [insforge, onAuthChange]
384
+ );
385
+ const verifySignInCode = (0, import_react.useCallback)(
386
+ async (email, code) => {
387
+ if (code !== "123456") {
388
+ throw new Error("Invalid verification code");
389
+ }
390
+ throw new Error("Passwordless sign in via verification code is not yet implemented in the backend");
391
+ },
392
+ [insforge, onAuthChange]
393
+ );
250
394
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
251
- AuthContext.Provider,
395
+ InsforgeContext.Provider,
252
396
  {
253
397
  value: {
398
+ // Auth
254
399
  user,
255
400
  session,
256
401
  isLoaded,
257
402
  isSignedIn: !!user,
403
+ setUser,
258
404
  signIn,
259
405
  signUp,
260
406
  signOut,
261
- updateUser
262
- },
263
- children
264
- }
265
- );
266
- }
267
- function useAuthContext() {
268
- const context = (0, import_react.useContext)(AuthContext);
269
- if (!context) {
270
- throw new Error("useAuthContext must be used within AuthProvider");
271
- }
272
- return context;
273
- }
274
-
275
- // src/provider/InsforgeConfigProvider.tsx
276
- var import_react2 = require("react");
277
- var import_jsx_runtime2 = require("react/jsx-runtime");
278
- var InsforgeConfigContext = (0, import_react2.createContext)(void 0);
279
- async function fetchBackendConfig(baseUrl) {
280
- try {
281
- const response = await fetch(`${baseUrl}/api/auth/config`);
282
- if (!response.ok) {
283
- return [];
284
- }
285
- const config = await response.json();
286
- if (config?.oauth?.providers && Array.isArray(config.oauth.providers)) {
287
- return config.oauth.providers.filter((p) => p.enabled).map((p) => p.provider);
288
- }
289
- return [];
290
- } catch (error) {
291
- return [];
292
- }
293
- }
294
- function InsforgeConfigProvider({ children, baseUrl }) {
295
- const [oauthProviders, setOauthProviders] = (0, import_react2.useState)([]);
296
- const [isLoaded, setIsLoaded] = (0, import_react2.useState)(false);
297
- const fetchConfig = async () => {
298
- const providers = await fetchBackendConfig(baseUrl);
299
- setOauthProviders(providers);
300
- setIsLoaded(true);
301
- };
302
- (0, import_react2.useEffect)(() => {
303
- fetchConfig();
304
- }, [baseUrl]);
305
- const refetch = async () => {
306
- setIsLoaded(false);
307
- await fetchConfig();
308
- };
309
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
310
- InsforgeConfigContext.Provider,
311
- {
312
- value: {
407
+ updateUser,
408
+ // Verification
409
+ sendVerificationCode,
410
+ verifySignUpCode,
411
+ verifySignInCode,
412
+ // Config
313
413
  oauthProviders,
314
- isLoaded,
315
- refetch
414
+ isConfigLoaded,
415
+ // Base
416
+ baseUrl
316
417
  },
317
418
  children
318
419
  }
319
420
  );
320
421
  }
321
- function useInsforgeConfig() {
322
- const context = (0, import_react2.useContext)(InsforgeConfigContext);
422
+ function useInsforge() {
423
+ const context = (0, import_react.useContext)(InsforgeContext);
323
424
  if (!context) {
324
- throw new Error("useInsforgeConfig must be used within InsforgeConfigProvider");
425
+ throw new Error("useInsforge must be used within InsforgeProvider");
325
426
  }
326
427
  return context;
327
428
  }
328
429
 
329
430
  // src/hooks/useAuth.ts
330
431
  function useAuth() {
331
- return useAuthContext();
432
+ const { signIn, signUp, signOut, isLoaded, isSignedIn } = useInsforge();
433
+ return { signIn, signUp, signOut, isLoaded, isSignedIn };
332
434
  }
333
435
 
334
436
  // src/hooks/useUser.ts
335
437
  function useUser() {
336
- const { user, isLoaded } = useAuthContext();
337
- return { user, isLoaded };
438
+ const { user, isLoaded, updateUser, setUser } = useInsforge();
439
+ return { user, isLoaded, updateUser, setUser };
338
440
  }
339
441
 
340
442
  // src/hooks/useSession.ts
341
443
  function useSession() {
342
- const { session, isLoaded, isSignedIn } = useAuthContext();
343
- return { session, isLoaded, isSignedIn };
444
+ const { session, isLoaded } = useInsforge();
445
+ return { session, isLoaded };
344
446
  }
345
447
 
346
448
  // src/hooks/useOAuthProviders.ts
347
449
  function useOAuthProviders() {
348
- const { oauthProviders } = useInsforgeConfig();
349
- return oauthProviders;
450
+ const { oauthProviders, isConfigLoaded } = useInsforge();
451
+ return { providers: oauthProviders, isLoaded: isConfigLoaded };
350
452
  }
351
453
 
352
454
  // src/components/SignIn.tsx
353
- var import_react3 = require("react");
354
- var import_link = __toESM(require("next/link"));
455
+ var import_react4 = require("react");
355
456
  var import_sdk2 = require("@insforge/sdk");
356
- var import_lucide_react2 = require("lucide-react");
357
457
 
358
- // src/components/OAuthButton.tsx
359
- var import_lucide_react = require("lucide-react");
458
+ // src/components/auth/AuthBranding.tsx
459
+ var import_link = __toESM(require("next/link"));
460
+ var import_jsx_runtime2 = require("react/jsx-runtime");
461
+ function AuthBranding({ text = "Secured by", href = "https://insforge.dev" }) {
462
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "insforge-branding", children: [
463
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "insforge-branding-text", children: text }),
464
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_link.default, { href, target: "_blank", rel: "noopener noreferrer", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { width: "83", height: "20", viewBox: "0 0 83 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
465
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
466
+ "path",
467
+ {
468
+ 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",
469
+ fill: "url(#paint0_linear_2976_9475)"
470
+ }
471
+ ),
472
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
473
+ "path",
474
+ {
475
+ d: "M12.8858 6.44922L16.6 10.168V18.668L8.64108 10.6992L12.8858 6.44922Z",
476
+ fill: "url(#paint1_linear_2976_9475)"
477
+ }
478
+ ),
479
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
480
+ "path",
481
+ {
482
+ 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",
483
+ fill: "black"
484
+ }
485
+ ),
486
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("defs", { children: [
487
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
488
+ "linearGradient",
489
+ {
490
+ id: "paint0_linear_2976_9475",
491
+ x1: "1.85883",
492
+ y1: "1.92425",
493
+ x2: "24.3072",
494
+ y2: "9.64016",
495
+ gradientUnits: "userSpaceOnUse",
496
+ children: [
497
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", {}),
498
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", { offset: "1", stopOpacity: "0.4" })
499
+ ]
500
+ }
501
+ ),
502
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
503
+ "linearGradient",
504
+ {
505
+ id: "paint1_linear_2976_9475",
506
+ x1: "25.6475",
507
+ y1: "8.65468",
508
+ x2: "10.7901",
509
+ y2: "8.65468",
510
+ gradientUnits: "userSpaceOnUse",
511
+ children: [
512
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", {}),
513
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", { offset: "1", stopOpacity: "0.4" })
514
+ ]
515
+ }
516
+ )
517
+ ] })
518
+ ] }) })
519
+ ] });
520
+ }
521
+
522
+ // src/components/auth/AuthContainer.tsx
360
523
  var import_jsx_runtime3 = require("react/jsx-runtime");
361
- var providerConfig = {
524
+ function AuthContainer({ children, style }) {
525
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "insforge-auth-container", style, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "insforge-auth-card", children: [
526
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "insforge-auth-content", children }),
527
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AuthBranding, {})
528
+ ] }) });
529
+ }
530
+
531
+ // src/components/auth/AuthHeader.tsx
532
+ var import_jsx_runtime4 = require("react/jsx-runtime");
533
+ function AuthHeader({ title, subtitle }) {
534
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "insforge-auth-header", children: [
535
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h1", { className: "insforge-auth-title", children: title }),
536
+ subtitle && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "insforge-auth-subtitle", children: subtitle })
537
+ ] });
538
+ }
539
+
540
+ // src/components/auth/AuthErrorBanner.tsx
541
+ var import_lucide_react = require("lucide-react");
542
+ var import_jsx_runtime5 = require("react/jsx-runtime");
543
+ function AuthErrorBanner({ error }) {
544
+ if (!error) return null;
545
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "insforge-error-banner", children: [
546
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react.AlertTriangle, { className: "insforge-error-icon" }),
547
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: error })
548
+ ] });
549
+ }
550
+
551
+ // src/components/auth/AuthFormField.tsx
552
+ var import_jsx_runtime6 = require("react/jsx-runtime");
553
+ function AuthFormField({ label, id, className = "", ...props }) {
554
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "insforge-form-group", children: [
555
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("label", { htmlFor: id, className: "insforge-form-label", children: label }),
556
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
557
+ "input",
558
+ {
559
+ id,
560
+ className: `insforge-input ${className}`,
561
+ ...props
562
+ }
563
+ )
564
+ ] });
565
+ }
566
+
567
+ // src/components/auth/AuthPasswordField.tsx
568
+ var import_react2 = require("react");
569
+ var import_lucide_react3 = require("lucide-react");
570
+
571
+ // src/components/auth/AuthPasswordStrengthIndicator.tsx
572
+ var import_lucide_react2 = require("lucide-react");
573
+ var import_jsx_runtime7 = require("react/jsx-runtime");
574
+ var requirements = [
575
+ {
576
+ label: "At least 1 Uppercase letter",
577
+ test: (pwd) => /[A-Z]/.test(pwd)
578
+ },
579
+ {
580
+ label: "At least 1 Number",
581
+ test: (pwd) => /\d/.test(pwd)
582
+ },
583
+ {
584
+ label: "Special character (e.g. !?<>@#$%)",
585
+ test: (pwd) => /[!@#$%^&*()_+\-=[\]{};\\|,.<>/?]/.test(pwd)
586
+ },
587
+ {
588
+ label: "8 characters or more",
589
+ test: (pwd) => pwd.length >= 8
590
+ }
591
+ ];
592
+ function validatePasswordStrength(password) {
593
+ if (!password) return false;
594
+ return requirements.every((req) => req.test(password));
595
+ }
596
+ function AuthPasswordStrengthIndicator({ password }) {
597
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "insforge-password-strength", children: requirements.map((requirement, index) => {
598
+ const isValid = requirement.test(password);
599
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "insforge-password-requirement", children: [
600
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
601
+ "div",
602
+ {
603
+ className: `insforge-password-check ${isValid ? "insforge-password-check-valid" : ""}`,
604
+ children: isValid && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react2.Check, { className: "insforge-password-check-icon", size: 12 })
605
+ }
606
+ ),
607
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "insforge-password-requirement-label", children: requirement.label })
608
+ ] }, index);
609
+ }) });
610
+ }
611
+
612
+ // src/components/auth/AuthPasswordField.tsx
613
+ var import_jsx_runtime8 = require("react/jsx-runtime");
614
+ function AuthPasswordField({
615
+ label,
616
+ id,
617
+ showStrengthIndicator = false,
618
+ forgotPasswordLink,
619
+ value,
620
+ className = "",
621
+ onFocus,
622
+ ...props
623
+ }) {
624
+ const [showPassword, setShowPassword] = (0, import_react2.useState)(false);
625
+ const [showStrength, setShowStrength] = (0, import_react2.useState)(false);
626
+ const handleFocus = (e) => {
627
+ if (showStrengthIndicator) {
628
+ setShowStrength(true);
629
+ }
630
+ onFocus?.(e);
631
+ };
632
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "insforge-form-group", children: [
633
+ (label || forgotPasswordLink) && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "insforge-form-label-row", children: [
634
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: id, className: "insforge-form-label", style: { margin: 0 }, children: label }),
635
+ forgotPasswordLink && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("a", { href: forgotPasswordLink.href, className: "insforge-form-link", children: forgotPasswordLink.text || "Forget Password?" })
636
+ ] }),
637
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "insforge-input-wrapper", children: [
638
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
639
+ "input",
640
+ {
641
+ id,
642
+ type: showPassword ? "text" : "password",
643
+ className: `insforge-input insforge-input-with-icon ${className}`,
644
+ value,
645
+ onFocus: handleFocus,
646
+ ...props
647
+ }
648
+ ),
649
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
650
+ "button",
651
+ {
652
+ type: "button",
653
+ onClick: () => setShowPassword(!showPassword),
654
+ className: "insforge-input-icon-btn",
655
+ "aria-label": showPassword ? "Hide password" : "Show password",
656
+ children: showPassword ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react3.EyeOff, { size: 20 }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react3.Eye, { size: 20 })
657
+ }
658
+ )
659
+ ] }),
660
+ showStrengthIndicator && showStrength && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AuthPasswordStrengthIndicator, { password: String(value || "") })
661
+ ] });
662
+ }
663
+
664
+ // src/components/auth/AuthSubmitButton.tsx
665
+ var import_lucide_react4 = require("lucide-react");
666
+ var import_jsx_runtime9 = require("react/jsx-runtime");
667
+ function AuthSubmitButton({
668
+ children,
669
+ isLoading = false,
670
+ confirmed = false,
671
+ disabled = false,
672
+ style
673
+ }) {
674
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
675
+ "button",
676
+ {
677
+ type: "submit",
678
+ className: "insforge-btn-primary",
679
+ style,
680
+ disabled: disabled || isLoading || confirmed,
681
+ "data-loading": isLoading || void 0,
682
+ "data-confirmed": confirmed || void 0,
683
+ children: [
684
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.Loader2, { className: "insforge-btn-loader", size: 20 }),
685
+ confirmed && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react4.CircleCheck, { className: "insforge-btn-check", size: 20 }),
686
+ children
687
+ ]
688
+ }
689
+ );
690
+ }
691
+
692
+ // src/components/auth/AuthDivider.tsx
693
+ var import_jsx_runtime10 = require("react/jsx-runtime");
694
+ function AuthDivider({ text = "or" }) {
695
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "insforge-divider", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "insforge-divider-text", children: text }) });
696
+ }
697
+
698
+ // src/components/auth/AuthLink.tsx
699
+ var import_jsx_runtime11 = require("react/jsx-runtime");
700
+ function AuthLink({ text, linkText, href }) {
701
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { className: "insforge-text-center", children: [
702
+ text,
703
+ " ",
704
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("a", { href, className: "insforge-link-primary", children: linkText })
705
+ ] });
706
+ }
707
+
708
+ // src/components/auth/AuthOAuthButton.tsx
709
+ var import_lucide_react5 = require("lucide-react");
710
+
711
+ // src/config/oauth-providers.tsx
712
+ var import_jsx_runtime12 = require("react/jsx-runtime");
713
+ var OAUTH_PROVIDER_CONFIG = {
362
714
  google: {
363
715
  name: "Google",
364
- svg: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", children: [
365
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
716
+ svg: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("svg", { width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", children: [
717
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
366
718
  "path",
367
719
  {
368
720
  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",
369
721
  fill: "#4285F4"
370
722
  }
371
723
  ),
372
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
724
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
373
725
  "path",
374
726
  {
375
727
  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",
376
728
  fill: "#34A853"
377
729
  }
378
730
  ),
379
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
731
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
380
732
  "path",
381
733
  {
382
734
  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",
383
735
  fill: "#FBBC05"
384
736
  }
385
737
  ),
386
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
738
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
387
739
  "path",
388
740
  {
389
741
  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",
@@ -395,16 +747,134 @@ var providerConfig = {
395
747
  },
396
748
  github: {
397
749
  name: "GitHub",
398
- svg: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { width: "18", height: "18", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("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" }) }),
750
+ svg: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", { width: "18", height: "18", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("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" }) }),
399
751
  className: "insforge-oauth-github"
752
+ },
753
+ discord: {
754
+ name: "Discord",
755
+ svg: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
756
+ "path",
757
+ {
758
+ 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",
759
+ fill: "#5865F2"
760
+ }
761
+ ) }),
762
+ className: "insforge-oauth-discord"
763
+ },
764
+ facebook: {
765
+ name: "Facebook",
766
+ svg: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
767
+ "path",
768
+ {
769
+ 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",
770
+ fill: "#1877F2"
771
+ }
772
+ ) }),
773
+ className: "insforge-oauth-facebook"
774
+ },
775
+ linkedin: {
776
+ name: "LinkedIn",
777
+ svg: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
778
+ "path",
779
+ {
780
+ 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",
781
+ fill: "#0A66C2"
782
+ }
783
+ ) }),
784
+ className: "insforge-oauth-linkedin"
785
+ },
786
+ microsoft: {
787
+ name: "Microsoft",
788
+ svg: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("svg", { width: "18", height: "18", viewBox: "0 0 23 23", fill: "none", children: [
789
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M0 0h11v11H0z", fill: "#F25022" }),
790
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M12 0h11v11H12z", fill: "#7FBA00" }),
791
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M0 12h11v11H0z", fill: "#00A4EF" }),
792
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M12 12h11v11H12z", fill: "#FFB900" })
793
+ ] }),
794
+ className: "insforge-oauth-microsoft"
795
+ },
796
+ apple: {
797
+ name: "Apple",
798
+ svg: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("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" }) }),
799
+ className: "insforge-oauth-apple"
800
+ },
801
+ x: {
802
+ name: "X",
803
+ svg: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("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" }) }),
804
+ className: "insforge-oauth-x"
805
+ },
806
+ instagram: {
807
+ name: "Instagram",
808
+ svg: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: [
809
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
810
+ "path",
811
+ {
812
+ 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",
813
+ fill: "url(#instagram-gradient)"
814
+ }
815
+ ),
816
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("linearGradient", { id: "instagram-gradient", x1: "0%", y1: "100%", x2: "100%", y2: "0%", children: [
817
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("stop", { offset: "0%", stopColor: "#FD5949" }),
818
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("stop", { offset: "50%", stopColor: "#D6249F" }),
819
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("stop", { offset: "100%", stopColor: "#285AEB" })
820
+ ] }) })
821
+ ] }),
822
+ className: "insforge-oauth-instagram"
823
+ },
824
+ tiktok: {
825
+ name: "TikTok",
826
+ svg: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
827
+ "path",
828
+ {
829
+ 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",
830
+ fill: "currentColor"
831
+ }
832
+ ) }),
833
+ className: "insforge-oauth-tiktok"
834
+ },
835
+ spotify: {
836
+ name: "Spotify",
837
+ svg: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
838
+ "path",
839
+ {
840
+ 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",
841
+ fill: "#1DB954"
842
+ }
843
+ ) }),
844
+ className: "insforge-oauth-spotify"
400
845
  }
401
846
  };
402
- function OAuthButton({ provider, onClick, disabled, loading }) {
403
- const config = providerConfig[provider];
847
+ function getProviderConfig(provider) {
848
+ return OAUTH_PROVIDER_CONFIG[provider] || null;
849
+ }
850
+ function getProviderName(provider) {
851
+ return OAUTH_PROVIDER_CONFIG[provider]?.name || provider;
852
+ }
853
+ function isProviderSupported(provider) {
854
+ return provider in OAUTH_PROVIDER_CONFIG;
855
+ }
856
+
857
+ // src/components/auth/AuthOAuthButton.tsx
858
+ var import_jsx_runtime13 = require("react/jsx-runtime");
859
+ function AuthOAuthButton({
860
+ provider,
861
+ onClick,
862
+ disabled,
863
+ loading,
864
+ displayMode = "full",
865
+ style
866
+ }) {
867
+ const config = getProviderConfig(provider);
404
868
  if (!config) {
405
869
  return null;
406
870
  }
407
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
871
+ const getButtonText = () => {
872
+ if (loading) return "Authenticating...";
873
+ if (displayMode === "full") return `Continue with ${config.name}`;
874
+ if (displayMode === "short") return config.name;
875
+ return "";
876
+ };
877
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
408
878
  "button",
409
879
  {
410
880
  type: "button",
@@ -412,21 +882,147 @@ function OAuthButton({ provider, onClick, disabled, loading }) {
412
882
  className: "insforge-oauth-btn",
413
883
  disabled: disabled || loading,
414
884
  "data-loading": loading || void 0,
885
+ "data-display-mode": displayMode,
886
+ style,
415
887
  children: [
416
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react.Loader2, { className: "insforge-oauth-loader", size: 18 }),
417
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "insforge-oauth-icon", children: config.svg }),
418
- loading ? "Authenticating..." : `Continue with ${config.name}`
888
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react5.Loader2, { className: "insforge-oauth-loader", size: 18 }),
889
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "insforge-oauth-icon", children: config.svg }),
890
+ getButtonText() && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "insforge-oauth-text", children: getButtonText() })
419
891
  ]
420
892
  }
421
893
  );
422
894
  }
423
895
 
896
+ // src/components/auth/AuthOAuthProviders.tsx
897
+ var import_jsx_runtime14 = require("react/jsx-runtime");
898
+ function AuthOAuthProviders({
899
+ providers,
900
+ onClick,
901
+ disabled,
902
+ loading
903
+ }) {
904
+ if (!providers || providers.length === 0) {
905
+ return null;
906
+ }
907
+ const count = providers.length;
908
+ const getDisplayMode = () => {
909
+ if (count === 1) return "full";
910
+ if (count === 2 || count === 4) return "short";
911
+ return "icon";
912
+ };
913
+ const getGridColumnStyle = (index) => {
914
+ if (count <= 4) {
915
+ return {};
916
+ }
917
+ const totalRows = Math.ceil(count / 3);
918
+ const lastRowStartIndex = (totalRows - 1) * 3;
919
+ const isInLastRow = index >= lastRowStartIndex;
920
+ if (!isInLastRow) {
921
+ return { gridColumn: "span 2" };
922
+ }
923
+ const positionInLastRow = index - lastRowStartIndex;
924
+ const itemsInLastRow = count - lastRowStartIndex;
925
+ if (itemsInLastRow === 1) {
926
+ return { gridColumn: "3 / 5" };
927
+ } else if (itemsInLastRow === 2) {
928
+ if (positionInLastRow === 0) {
929
+ return { gridColumn: "2 / 4" };
930
+ } else {
931
+ return { gridColumn: "4 / 6" };
932
+ }
933
+ } else {
934
+ return { gridColumn: "span 2" };
935
+ }
936
+ };
937
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "insforge-oauth-container", "data-provider-count": count, children: providers.map((provider, index) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
938
+ AuthOAuthButton,
939
+ {
940
+ provider,
941
+ onClick,
942
+ disabled,
943
+ loading: loading === provider,
944
+ displayMode: getDisplayMode(),
945
+ style: getGridColumnStyle(index)
946
+ },
947
+ provider
948
+ )) });
949
+ }
950
+
951
+ // src/components/auth/AuthVerificationCodeInput.tsx
952
+ var import_react3 = require("react");
953
+ var import_jsx_runtime15 = require("react/jsx-runtime");
954
+ function AuthVerificationCodeInput({
955
+ length = 6,
956
+ value,
957
+ email,
958
+ onChange,
959
+ disabled = false
960
+ }) {
961
+ const inputRefs = (0, import_react3.useRef)([]);
962
+ const handleChange = (index, digit) => {
963
+ if (digit.length > 1) return;
964
+ if (digit && !/^\d$/.test(digit)) return;
965
+ const newValue = value.split("");
966
+ newValue[index] = digit;
967
+ const updatedValue = newValue.join("");
968
+ onChange(updatedValue);
969
+ if (digit && index < length - 1) {
970
+ inputRefs.current[index + 1]?.focus();
971
+ }
972
+ };
973
+ const handleKeyDown = (index, e) => {
974
+ if (e.key === "Backspace") {
975
+ if (!value[index] && index > 0) {
976
+ inputRefs.current[index - 1]?.focus();
977
+ } else {
978
+ handleChange(index, "");
979
+ }
980
+ } else if (e.key === "ArrowLeft" && index > 0) {
981
+ inputRefs.current[index - 1]?.focus();
982
+ } else if (e.key === "ArrowRight" && index < length - 1) {
983
+ inputRefs.current[index + 1]?.focus();
984
+ }
985
+ };
986
+ const handlePaste = (e) => {
987
+ e.preventDefault();
988
+ const pastedData = e.clipboardData.getData("text/plain").trim();
989
+ if (/^\d+$/.test(pastedData) && pastedData.length === length) {
990
+ onChange(pastedData);
991
+ inputRefs.current[length - 1]?.focus();
992
+ }
993
+ };
994
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "insforge-verification-code-container", children: [
995
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("p", { className: "insforge-verification-instructions", children: [
996
+ "We've sent a verification code to your inbox at ",
997
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: email }),
998
+ ". Enter it below to proceed."
999
+ ] }),
1000
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "insforge-verification-code-inputs", children: Array.from({ length }).map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1001
+ "input",
1002
+ {
1003
+ ref: (el) => {
1004
+ inputRefs.current[index] = el;
1005
+ },
1006
+ type: "text",
1007
+ inputMode: "numeric",
1008
+ maxLength: 1,
1009
+ value: value[index] || "",
1010
+ onChange: (e) => handleChange(index, e.target.value),
1011
+ onKeyDown: (e) => handleKeyDown(index, e),
1012
+ onPaste: handlePaste,
1013
+ disabled,
1014
+ className: "insforge-verification-code-input",
1015
+ autoComplete: "one-time-code"
1016
+ },
1017
+ index
1018
+ )) })
1019
+ ] });
1020
+ }
1021
+
424
1022
  // src/components/SignIn.tsx
425
- var import_jsx_runtime4 = require("react/jsx-runtime");
1023
+ var import_jsx_runtime16 = require("react/jsx-runtime");
426
1024
  function SignIn({
427
- baseUrl,
428
1025
  afterSignInUrl = "/",
429
- providers = [],
430
1026
  appearance = {},
431
1027
  title = "Welcome Back",
432
1028
  subtitle = "Login to your account",
@@ -444,14 +1040,13 @@ function SignIn({
444
1040
  onSuccess,
445
1041
  onError
446
1042
  }) {
447
- const { signIn } = useAuth();
448
- const [email, setEmail] = (0, import_react3.useState)("");
449
- const [password, setPassword] = (0, import_react3.useState)("");
450
- const [error, setError] = (0, import_react3.useState)("");
451
- const [loading, setLoading] = (0, import_react3.useState)(false);
452
- const [showPassword, setShowPassword] = (0, import_react3.useState)(false);
453
- const [oauthLoading, setOauthLoading] = (0, import_react3.useState)(null);
454
- const insforge = (0, import_react3.useState)(() => (0, import_sdk2.createClient)({ baseUrl }))[0];
1043
+ const { signIn, oauthProviders, baseUrl } = useInsforge();
1044
+ const [email, setEmail] = (0, import_react4.useState)("");
1045
+ const [password, setPassword] = (0, import_react4.useState)("");
1046
+ const [error, setError] = (0, import_react4.useState)("");
1047
+ const [loading, setLoading] = (0, import_react4.useState)(false);
1048
+ const [oauthLoading, setOauthLoading] = (0, import_react4.useState)(null);
1049
+ const insforge = (0, import_react4.useState)(() => (0, import_sdk2.createClient)({ baseUrl }))[0];
455
1050
  async function handleSubmit(e) {
456
1051
  e.preventDefault();
457
1052
  setLoading(true);
@@ -480,9 +1075,7 @@ function SignIn({
480
1075
  provider,
481
1076
  redirectTo
482
1077
  });
483
- if (result.data?.url) {
484
- window.location.href = result.data.url;
485
- }
1078
+ console.log("handleOAuth result", result);
486
1079
  } catch (err) {
487
1080
  const errorMessage = err.message || `${provider} sign in failed`;
488
1081
  setError(errorMessage);
@@ -490,238 +1083,71 @@ function SignIn({
490
1083
  setOauthLoading(null);
491
1084
  }
492
1085
  }
493
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "insforge-auth-container", style: appearance.container, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "insforge-auth-card", style: appearance.form, children: [
494
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "insforge-auth-content", children: [
495
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "insforge-auth-header", children: [
496
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h1", { className: "insforge-auth-title", children: title }),
497
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "insforge-auth-subtitle", children: subtitle })
498
- ] }),
499
- error && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "insforge-error-banner", children: [
500
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react2.AlertTriangle, { className: "insforge-error-icon" }),
501
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: error })
502
- ] }),
503
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("form", { onSubmit: handleSubmit, className: "insforge-form", children: [
504
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "insforge-form-group", children: [
505
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: "email", className: "insforge-form-label", children: emailLabel }),
506
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
507
- "input",
508
- {
509
- id: "email",
510
- type: "email",
511
- className: "insforge-input",
512
- placeholder: emailPlaceholder,
513
- value: email,
514
- onChange: (e) => setEmail(e.target.value),
515
- required: true,
516
- autoComplete: "email"
517
- }
518
- )
519
- ] }),
520
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "insforge-form-group", children: [
521
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "insforge-form-label-row", children: [
522
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
523
- "label",
524
- {
525
- htmlFor: "password",
526
- className: "insforge-form-label",
527
- style: { margin: 0 },
528
- children: passwordLabel
529
- }
530
- ),
531
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { href: "#", className: "insforge-form-link", children: forgotPasswordText })
532
- ] }),
533
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "insforge-input-wrapper", children: [
534
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
535
- "input",
536
- {
537
- id: "password",
538
- type: showPassword ? "text" : "password",
539
- className: "insforge-input insforge-input-with-icon",
540
- placeholder: passwordPlaceholder,
541
- value: password,
542
- onChange: (e) => setPassword(e.target.value),
543
- required: true,
544
- autoComplete: "current-password"
545
- }
546
- ),
547
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
548
- "button",
549
- {
550
- type: "button",
551
- onClick: () => setShowPassword(!showPassword),
552
- className: "insforge-input-icon-btn",
553
- "aria-label": showPassword ? "Hide password" : "Show password",
554
- children: showPassword ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react2.EyeOff, { size: 20 }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react2.Eye, { size: 20 })
555
- }
556
- )
557
- ] })
558
- ] }),
559
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
560
- "button",
561
- {
562
- type: "submit",
563
- className: "insforge-btn-primary",
564
- style: appearance.button,
565
- disabled: loading || oauthLoading !== null,
566
- "data-loading": loading || void 0,
567
- children: [
568
- loading && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react2.Loader2, { className: "insforge-btn-loader", size: 20 }),
569
- loading ? loadingButtonText : submitButtonText
570
- ]
1086
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(AuthContainer, { style: appearance.container, children: [
1087
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(AuthHeader, { title, subtitle }),
1088
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(AuthErrorBanner, { error }),
1089
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("form", { onSubmit: handleSubmit, className: "insforge-form", children: [
1090
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1091
+ AuthFormField,
1092
+ {
1093
+ id: "email",
1094
+ type: "email",
1095
+ label: emailLabel,
1096
+ placeholder: emailPlaceholder,
1097
+ value: email,
1098
+ onChange: (e) => setEmail(e.target.value),
1099
+ required: true,
1100
+ autoComplete: "email"
1101
+ }
1102
+ ),
1103
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1104
+ AuthPasswordField,
1105
+ {
1106
+ id: "password",
1107
+ label: passwordLabel,
1108
+ placeholder: passwordPlaceholder,
1109
+ value: password,
1110
+ onChange: (e) => setPassword(e.target.value),
1111
+ required: true,
1112
+ autoComplete: "current-password",
1113
+ forgotPasswordLink: {
1114
+ href: "#",
1115
+ text: forgotPasswordText
571
1116
  }
572
- )
573
- ] }),
574
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { className: "insforge-text-center", children: [
575
- signUpText,
576
- " ",
577
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { href: signUpUrl, className: "insforge-link-primary", children: signUpLinkText })
578
- ] }),
579
- providers.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
580
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "insforge-divider", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "insforge-divider-text", children: dividerText }) }),
581
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "insforge-oauth-container", children: providers.map((provider) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
582
- OAuthButton,
583
- {
584
- provider,
585
- onClick: handleOAuth,
586
- disabled: loading || oauthLoading !== null,
587
- loading: oauthLoading === provider
588
- },
589
- provider
590
- )) })
591
- ] })
1117
+ }
1118
+ ),
1119
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1120
+ AuthSubmitButton,
1121
+ {
1122
+ isLoading: loading,
1123
+ disabled: loading || oauthLoading !== null,
1124
+ style: appearance.button,
1125
+ children: loading ? loadingButtonText : submitButtonText
1126
+ }
1127
+ )
592
1128
  ] }),
593
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "insforge-branding", children: [
594
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "insforge-branding-text", children: "Powered by" }),
595
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
596
- import_link.default,
1129
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(AuthLink, { text: signUpText, linkText: signUpLinkText, href: signUpUrl }),
1130
+ oauthProviders.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
1131
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(AuthDivider, { text: dividerText }),
1132
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1133
+ AuthOAuthProviders,
597
1134
  {
598
- href: "https://insforge.dev",
599
- target: "_blank",
600
- rel: "noopener noreferrer",
601
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
602
- "svg",
603
- {
604
- width: "83",
605
- height: "20",
606
- viewBox: "0 0 83 20",
607
- fill: "none",
608
- xmlns: "http://www.w3.org/2000/svg",
609
- children: [
610
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
611
- "path",
612
- {
613
- 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",
614
- fill: "url(#paint0_linear_2976_9475)"
615
- }
616
- ),
617
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
618
- "path",
619
- {
620
- d: "M12.8858 6.44922L16.6 10.168V18.668L8.64108 10.6992L12.8858 6.44922Z",
621
- fill: "url(#paint1_linear_2976_9475)"
622
- }
623
- ),
624
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
625
- "path",
626
- {
627
- 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",
628
- fill: "black"
629
- }
630
- ),
631
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("defs", { children: [
632
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
633
- "linearGradient",
634
- {
635
- id: "paint0_linear_2976_9475",
636
- x1: "1.85883",
637
- y1: "1.92425",
638
- x2: "24.3072",
639
- y2: "9.64016",
640
- gradientUnits: "userSpaceOnUse",
641
- children: [
642
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("stop", {}),
643
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("stop", { offset: "1", stopOpacity: "0.4" })
644
- ]
645
- }
646
- ),
647
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
648
- "linearGradient",
649
- {
650
- id: "paint1_linear_2976_9475",
651
- x1: "25.6475",
652
- y1: "8.65468",
653
- x2: "10.7901",
654
- y2: "8.65468",
655
- gradientUnits: "userSpaceOnUse",
656
- children: [
657
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("stop", {}),
658
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("stop", { offset: "1", stopOpacity: "0.4" })
659
- ]
660
- }
661
- )
662
- ] })
663
- ]
664
- }
665
- )
1135
+ providers: oauthProviders,
1136
+ onClick: handleOAuth,
1137
+ disabled: loading || oauthLoading !== null,
1138
+ loading: oauthLoading
666
1139
  }
667
1140
  )
668
1141
  ] })
669
- ] }) });
1142
+ ] });
670
1143
  }
671
1144
 
672
1145
  // src/components/SignUp.tsx
673
- var import_react4 = require("react");
674
- var import_link2 = __toESM(require("next/link"));
1146
+ var import_react5 = require("react");
675
1147
  var import_sdk3 = require("@insforge/sdk");
676
- var import_lucide_react4 = require("lucide-react");
677
-
678
- // src/components/PasswordStrengthIndicator.tsx
679
- var import_lucide_react3 = require("lucide-react");
680
- var import_jsx_runtime5 = require("react/jsx-runtime");
681
- var requirements = [
682
- {
683
- label: "At least 1 Uppercase letter",
684
- test: (pwd) => /[A-Z]/.test(pwd)
685
- },
686
- {
687
- label: "At least 1 Number",
688
- test: (pwd) => /\d/.test(pwd)
689
- },
690
- {
691
- label: "Special character (e.g. !?<>@#$%)",
692
- test: (pwd) => /[!@#$%^&*()_+\-=[\]{};\\|,.<>/?]/.test(pwd)
693
- },
694
- {
695
- label: "8 characters or more",
696
- test: (pwd) => pwd.length >= 8
697
- }
698
- ];
699
- function validatePasswordStrength(password) {
700
- if (!password) return false;
701
- return requirements.every((req) => req.test(password));
702
- }
703
- function PasswordStrengthIndicator({ password }) {
704
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "insforge-password-strength", children: requirements.map((requirement, index) => {
705
- const isValid = requirement.test(password);
706
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "insforge-password-requirement", children: [
707
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
708
- "div",
709
- {
710
- className: `insforge-password-check ${isValid ? "insforge-password-check-valid" : ""}`,
711
- children: isValid && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.Check, { className: "insforge-password-check-icon", size: 12 })
712
- }
713
- ),
714
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "insforge-password-requirement-label", children: requirement.label })
715
- ] }, index);
716
- }) });
717
- }
718
-
719
- // src/components/SignUp.tsx
720
- var import_jsx_runtime6 = require("react/jsx-runtime");
1148
+ var import_jsx_runtime17 = require("react/jsx-runtime");
721
1149
  function SignUp({
722
- baseUrl,
723
1150
  afterSignUpUrl = "/",
724
- providers = [],
725
1151
  appearance = {},
726
1152
  title = "Get Started",
727
1153
  subtitle = "Create account",
@@ -731,6 +1157,9 @@ function SignUp({
731
1157
  passwordPlaceholder = "\u2022\u2022\u2022\u2022\u2022\u2022",
732
1158
  submitButtonText = "Sign Up",
733
1159
  loadingButtonText = "Creating account...",
1160
+ verifyButtonText = "Continue",
1161
+ loadingVerifyButtonText = "Verifying...",
1162
+ verifiedButtonText = "Verified",
734
1163
  signInText = "Already have an account?",
735
1164
  signInLinkText = "Login Now",
736
1165
  signInUrl = "/sign-in",
@@ -738,16 +1167,19 @@ function SignUp({
738
1167
  onSuccess,
739
1168
  onError
740
1169
  }) {
741
- const { signUp } = useAuth();
742
- const [email, setEmail] = (0, import_react4.useState)("");
743
- const [password, setPassword] = (0, import_react4.useState)("");
744
- const [error, setError] = (0, import_react4.useState)("");
745
- const [loading, setLoading] = (0, import_react4.useState)(false);
746
- const [showPassword, setShowPassword] = (0, import_react4.useState)(false);
747
- const [oauthLoading, setOauthLoading] = (0, import_react4.useState)(null);
748
- const [showPasswordStrength, setShowPasswordStrength] = (0, import_react4.useState)(false);
749
- const insforge = (0, import_react4.useState)(() => (0, import_sdk3.createClient)({ baseUrl }))[0];
750
- async function handleSubmit(e) {
1170
+ const { sendVerificationCode, verifySignUpCode, oauthProviders, baseUrl } = useInsforge();
1171
+ const [email, setEmail] = (0, import_react5.useState)("");
1172
+ const [password, setPassword] = (0, import_react5.useState)("");
1173
+ const [verificationCode, setVerificationCode] = (0, import_react5.useState)("");
1174
+ const [error, setError] = (0, import_react5.useState)("");
1175
+ const [loading, setLoading] = (0, import_react5.useState)(false);
1176
+ const [oauthLoading, setOauthLoading] = (0, import_react5.useState)(null);
1177
+ const [verified, setVerified] = (0, import_react5.useState)(false);
1178
+ const [step, setStep] = (0, import_react5.useState)(
1179
+ "credentials"
1180
+ );
1181
+ const insforge = (0, import_react5.useState)(() => (0, import_sdk3.createClient)({ baseUrl }))[0];
1182
+ async function handleCredentialsSubmit(e) {
751
1183
  e.preventDefault();
752
1184
  setLoading(true);
753
1185
  setError("");
@@ -757,20 +1189,53 @@ function SignUp({
757
1189
  return;
758
1190
  }
759
1191
  try {
760
- await signUp(email, password);
1192
+ await sendVerificationCode(email, "signup");
1193
+ setStep("verification");
1194
+ } catch (err) {
1195
+ const errorMessage = err.message || "Failed to send verification code";
1196
+ setError(errorMessage);
1197
+ if (onError) onError(new Error(errorMessage));
1198
+ } finally {
1199
+ setLoading(false);
1200
+ }
1201
+ }
1202
+ async function handleVerificationSubmit(e) {
1203
+ e.preventDefault();
1204
+ setLoading(true);
1205
+ setError("");
1206
+ if (verificationCode.length !== 6) {
1207
+ setError("Please enter the complete verification code");
1208
+ setLoading(false);
1209
+ return;
1210
+ }
1211
+ try {
1212
+ await verifySignUpCode(email, password, verificationCode);
761
1213
  if (onSuccess) {
1214
+ setVerified(true);
762
1215
  const userResult = await insforge.auth.getCurrentUser();
763
1216
  if (userResult.data) onSuccess(userResult.data);
764
1217
  }
765
1218
  window.location.href = afterSignUpUrl;
766
1219
  } catch (err) {
767
- const errorMessage = err.message || "Sign up failed";
1220
+ const errorMessage = err.message || "Invalid verification code";
768
1221
  setError(errorMessage);
769
1222
  if (onError) onError(new Error(errorMessage));
770
1223
  } finally {
771
1224
  setLoading(false);
772
1225
  }
773
1226
  }
1227
+ async function handleResendCode() {
1228
+ setLoading(true);
1229
+ setError("");
1230
+ try {
1231
+ await sendVerificationCode(email, "signup");
1232
+ } catch (err) {
1233
+ const errorMessage = err.message || "Failed to resend code";
1234
+ setError(errorMessage);
1235
+ } finally {
1236
+ setLoading(false);
1237
+ }
1238
+ }
774
1239
  async function handleOAuth(provider) {
775
1240
  try {
776
1241
  setOauthLoading(provider);
@@ -790,188 +1255,124 @@ function SignUp({
790
1255
  setOauthLoading(null);
791
1256
  }
792
1257
  }
793
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "insforge-auth-container", style: appearance.container, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "insforge-auth-card", style: appearance.form, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "insforge-auth-content", children: [
794
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "insforge-auth-header", children: [
795
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h1", { className: "insforge-auth-title", children: title }),
796
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "insforge-auth-subtitle", children: subtitle })
797
- ] }),
798
- error && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "insforge-error-banner", children: [
799
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react4.AlertTriangle, { className: "insforge-error-icon" }),
800
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: error })
801
- ] }),
802
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("form", { onSubmit: handleSubmit, className: "insforge-form", children: [
803
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "insforge-form-group", children: [
804
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("label", { htmlFor: "email", className: "insforge-form-label", children: emailLabel }),
805
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
806
- "input",
1258
+ if (step === "credentials") {
1259
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(AuthContainer, { style: appearance.container, children: [
1260
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(AuthHeader, { title, subtitle }),
1261
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(AuthErrorBanner, { error }),
1262
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("form", { onSubmit: handleCredentialsSubmit, className: "insforge-form", children: [
1263
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1264
+ AuthFormField,
807
1265
  {
808
1266
  id: "email",
809
1267
  type: "email",
810
- className: "insforge-input",
1268
+ label: emailLabel,
811
1269
  placeholder: emailPlaceholder,
812
1270
  value: email,
813
1271
  onChange: (e) => setEmail(e.target.value),
814
1272
  required: true,
815
1273
  autoComplete: "email"
816
1274
  }
1275
+ ),
1276
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1277
+ AuthPasswordField,
1278
+ {
1279
+ id: "password",
1280
+ label: passwordLabel,
1281
+ placeholder: passwordPlaceholder,
1282
+ value: password,
1283
+ onChange: (e) => setPassword(e.target.value),
1284
+ required: true,
1285
+ minLength: 8,
1286
+ autoComplete: "new-password",
1287
+ showStrengthIndicator: true
1288
+ }
1289
+ ),
1290
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1291
+ AuthSubmitButton,
1292
+ {
1293
+ isLoading: loading,
1294
+ disabled: loading || oauthLoading !== null,
1295
+ style: appearance.button,
1296
+ children: loading ? loadingButtonText : submitButtonText
1297
+ }
817
1298
  )
818
1299
  ] }),
819
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "insforge-form-group", children: [
820
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("label", { htmlFor: "password", className: "insforge-form-label", children: passwordLabel }),
821
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "insforge-input-wrapper", children: [
822
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
823
- "input",
824
- {
825
- id: "password",
826
- type: showPassword ? "text" : "password",
827
- className: "insforge-input insforge-input-with-icon",
828
- placeholder: passwordPlaceholder,
829
- value: password,
830
- onChange: (e) => setPassword(e.target.value),
831
- onFocus: () => setShowPasswordStrength(true),
832
- required: true,
833
- minLength: 8,
834
- autoComplete: "new-password"
835
- }
836
- ),
837
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
838
- "button",
839
- {
840
- type: "button",
841
- onClick: () => setShowPassword(!showPassword),
842
- className: "insforge-input-icon-btn",
843
- "aria-label": showPassword ? "Hide password" : "Show password",
844
- children: showPassword ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react4.EyeOff, { size: 20 }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react4.Eye, { size: 20 })
845
- }
846
- )
847
- ] }),
848
- showPasswordStrength && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PasswordStrengthIndicator, { password })
849
- ] }),
850
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
851
- "button",
1300
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1301
+ AuthLink,
852
1302
  {
853
- type: "submit",
854
- className: "insforge-btn-primary",
1303
+ text: signInText,
1304
+ linkText: signInLinkText,
1305
+ href: signInUrl
1306
+ }
1307
+ ),
1308
+ oauthProviders.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
1309
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(AuthDivider, { text: dividerText }),
1310
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1311
+ AuthOAuthProviders,
1312
+ {
1313
+ providers: oauthProviders,
1314
+ onClick: handleOAuth,
1315
+ disabled: loading || oauthLoading !== null,
1316
+ loading: oauthLoading
1317
+ }
1318
+ )
1319
+ ] })
1320
+ ] });
1321
+ }
1322
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(AuthContainer, { style: appearance.container, children: [
1323
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(AuthHeader, { title, subtitle }),
1324
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(AuthErrorBanner, { error }),
1325
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("form", { onSubmit: handleVerificationSubmit, className: "insforge-form", children: [
1326
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1327
+ AuthVerificationCodeInput,
1328
+ {
1329
+ email,
1330
+ value: verificationCode,
1331
+ onChange: setVerificationCode,
1332
+ disabled: loading
1333
+ }
1334
+ ),
1335
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1336
+ AuthSubmitButton,
1337
+ {
1338
+ isLoading: loading,
1339
+ disabled: loading,
855
1340
  style: appearance.button,
856
- disabled: loading || oauthLoading !== null,
857
- "data-loading": loading || void 0,
858
- children: [
859
- loading && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react4.Loader2, { className: "insforge-btn-loader", size: 20 }),
860
- loading ? loadingButtonText : submitButtonText
861
- ]
1341
+ confirmed: verified,
1342
+ children: verified ? verifiedButtonText : loading ? loadingVerifyButtonText : verifyButtonText
862
1343
  }
863
1344
  )
864
1345
  ] }),
865
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("p", { className: "insforge-text-center", children: [
866
- signInText,
1346
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "insforge-resend-code", children: [
1347
+ "Did not received the code?",
867
1348
  " ",
868
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: signInUrl, className: "insforge-link-primary", children: signInLinkText })
869
- ] }),
870
- providers.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
871
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "insforge-divider", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "insforge-divider-text", children: dividerText }) }),
872
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "insforge-oauth-container", children: providers.map((provider) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
873
- OAuthButton,
874
- {
875
- provider,
876
- onClick: handleOAuth,
877
- disabled: loading || oauthLoading !== null,
878
- loading: oauthLoading === provider
879
- },
880
- provider
881
- )) })
882
- ] }),
883
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "insforge-branding", children: [
884
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "insforge-branding-text", children: "Powered by" }),
885
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
886
- import_link2.default,
1349
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1350
+ "button",
887
1351
  {
888
- href: "https://insforge.dev",
889
- target: "_blank",
890
- rel: "noopener noreferrer",
891
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
892
- "svg",
893
- {
894
- width: "83",
895
- height: "20",
896
- viewBox: "0 0 83 20",
897
- fill: "none",
898
- xmlns: "http://www.w3.org/2000/svg",
899
- children: [
900
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
901
- "path",
902
- {
903
- 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",
904
- fill: "url(#paint0_linear_2976_9475)"
905
- }
906
- ),
907
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
908
- "path",
909
- {
910
- d: "M12.8858 6.44922L16.6 10.168V18.668L8.64108 10.6992L12.8858 6.44922Z",
911
- fill: "url(#paint1_linear_2976_9475)"
912
- }
913
- ),
914
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
915
- "path",
916
- {
917
- 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",
918
- fill: "black"
919
- }
920
- ),
921
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("defs", { children: [
922
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
923
- "linearGradient",
924
- {
925
- id: "paint0_linear_2976_9475",
926
- x1: "1.85883",
927
- y1: "1.92425",
928
- x2: "24.3072",
929
- y2: "9.64016",
930
- gradientUnits: "userSpaceOnUse",
931
- children: [
932
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("stop", {}),
933
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("stop", { offset: "1", stopOpacity: "0.4" })
934
- ]
935
- }
936
- ),
937
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
938
- "linearGradient",
939
- {
940
- id: "paint1_linear_2976_9475",
941
- x1: "25.6475",
942
- y1: "8.65468",
943
- x2: "10.7901",
944
- y2: "8.65468",
945
- gradientUnits: "userSpaceOnUse",
946
- children: [
947
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("stop", {}),
948
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("stop", { offset: "1", stopOpacity: "0.4" })
949
- ]
950
- }
951
- )
952
- ] })
953
- ]
954
- }
955
- )
1352
+ type: "button",
1353
+ onClick: handleResendCode,
1354
+ disabled: loading,
1355
+ className: "insforge-resend-link",
1356
+ children: "Click to resend"
956
1357
  }
957
1358
  )
958
1359
  ] })
959
- ] }) }) });
1360
+ ] });
960
1361
  }
961
1362
 
962
1363
  // src/components/UserButton.tsx
963
- var import_react5 = require("react");
964
- var import_lucide_react5 = require("lucide-react");
965
- var import_jsx_runtime7 = require("react/jsx-runtime");
1364
+ var import_react6 = require("react");
1365
+ var import_lucide_react6 = require("lucide-react");
1366
+ var import_jsx_runtime18 = require("react/jsx-runtime");
966
1367
  function UserButton({
967
1368
  afterSignOutUrl = "/",
968
1369
  mode = "detailed",
969
1370
  appearance = {}
970
1371
  }) {
971
- const { user, signOut } = useAuth();
972
- const [isOpen, setIsOpen] = (0, import_react5.useState)(false);
973
- const dropdownRef = (0, import_react5.useRef)(null);
974
- (0, import_react5.useEffect)(() => {
1372
+ const { user, signOut } = useInsforge();
1373
+ const [isOpen, setIsOpen] = (0, import_react6.useState)(false);
1374
+ const dropdownRef = (0, import_react6.useRef)(null);
1375
+ (0, import_react6.useEffect)(() => {
975
1376
  function handleClickOutside(event) {
976
1377
  if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
977
1378
  setIsOpen(false);
@@ -992,8 +1393,8 @@ function UserButton({
992
1393
  if (!user) return null;
993
1394
  const initials = user.nickname ? user.nickname.charAt(0).toUpperCase() : user.email.split("@")[0].slice(0, 2).toUpperCase();
994
1395
  const avatarUrl = user.avatar_url;
995
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "insforge-user-button-container", ref: dropdownRef, children: [
996
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1396
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "insforge-user-button-container", ref: dropdownRef, children: [
1397
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
997
1398
  "button",
998
1399
  {
999
1400
  className: `insforge-user-button ${mode === "detailed" ? "insforge-user-button-detailed" : ""}`,
@@ -1002,52 +1403,52 @@ function UserButton({
1002
1403
  "aria-expanded": isOpen,
1003
1404
  "aria-haspopup": "true",
1004
1405
  children: [
1005
- avatarUrl ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("img", { src: avatarUrl, alt: user.email, className: "insforge-user-avatar" }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "insforge-user-avatar-placeholder", children: initials }),
1006
- mode === "detailed" && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "insforge-user-button-info", children: [
1007
- user.nickname && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "insforge-user-button-name", children: user.nickname }),
1008
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "insforge-user-button-email", children: user.email })
1406
+ avatarUrl ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("img", { src: avatarUrl, alt: user.email, className: "insforge-user-avatar" }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "insforge-user-avatar-placeholder", children: initials }),
1407
+ mode === "detailed" && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "insforge-user-button-info", children: [
1408
+ user.nickname && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "insforge-user-button-name", children: user.nickname }),
1409
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "insforge-user-button-email", children: user.email })
1009
1410
  ] })
1010
1411
  ]
1011
1412
  }
1012
1413
  ),
1013
- isOpen && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "insforge-user-dropdown", style: appearance.dropdown, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("button", { onClick: handleSignOut, className: "insforge-sign-out-button", children: [
1014
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react5.LogOut, { className: "w-5 h-5" }),
1414
+ isOpen && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "insforge-user-dropdown", style: appearance.dropdown, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("button", { onClick: handleSignOut, className: "insforge-sign-out-button", children: [
1415
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react6.LogOut, { className: "w-5 h-5" }),
1015
1416
  "Sign out"
1016
1417
  ] }) })
1017
1418
  ] });
1018
1419
  }
1019
1420
 
1020
1421
  // src/components/SignedIn.tsx
1021
- var import_jsx_runtime8 = require("react/jsx-runtime");
1422
+ var import_jsx_runtime19 = require("react/jsx-runtime");
1022
1423
  function SignedIn({ children }) {
1023
- const { isSignedIn, isLoaded } = useAuth();
1424
+ const { isSignedIn, isLoaded } = useInsforge();
1024
1425
  if (!isLoaded) return null;
1025
1426
  if (!isSignedIn) return null;
1026
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children });
1427
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children });
1027
1428
  }
1028
1429
 
1029
1430
  // src/components/SignedOut.tsx
1030
- var import_jsx_runtime9 = require("react/jsx-runtime");
1431
+ var import_jsx_runtime20 = require("react/jsx-runtime");
1031
1432
  function SignedOut({ children }) {
1032
- const { isSignedIn, isLoaded } = useAuth();
1433
+ const { isSignedIn, isLoaded } = useInsforge();
1033
1434
  if (!isLoaded) return null;
1034
1435
  if (isSignedIn) return null;
1035
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children });
1436
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children });
1036
1437
  }
1037
1438
 
1038
1439
  // src/components/Protect.tsx
1039
- var import_react6 = require("react");
1440
+ var import_react7 = require("react");
1040
1441
  var import_navigation = require("next/navigation");
1041
- var import_jsx_runtime10 = require("react/jsx-runtime");
1442
+ var import_jsx_runtime21 = require("react/jsx-runtime");
1042
1443
  function Protect({
1043
1444
  children,
1044
1445
  fallback,
1045
1446
  redirectTo = "/sign-in",
1046
1447
  condition
1047
1448
  }) {
1048
- const { isSignedIn, isLoaded, user } = useAuth();
1449
+ const { isSignedIn, isLoaded, user } = useInsforge();
1049
1450
  const router = (0, import_navigation.useRouter)();
1050
- (0, import_react6.useEffect)(() => {
1451
+ (0, import_react7.useEffect)(() => {
1051
1452
  if (isLoaded && !isSignedIn) {
1052
1453
  router.push(redirectTo);
1053
1454
  } else if (isLoaded && isSignedIn && condition && user) {
@@ -1057,7 +1458,7 @@ function Protect({
1057
1458
  }
1058
1459
  }, [isLoaded, isSignedIn, redirectTo, router, condition, user]);
1059
1460
  if (!isLoaded) {
1060
- return fallback || /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "insforge-loading", children: "Loading..." });
1461
+ return fallback || /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "insforge-loading", children: "Loading..." });
1061
1462
  }
1062
1463
  if (!isSignedIn) {
1063
1464
  return fallback || null;
@@ -1065,22 +1466,39 @@ function Protect({
1065
1466
  if (condition && user && !condition(user)) {
1066
1467
  return fallback || null;
1067
1468
  }
1068
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children });
1469
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children });
1069
1470
  }
1070
1471
  // Annotate the CommonJS export names for ESM import in node:
1071
1472
  0 && (module.exports = {
1072
- AuthProvider,
1073
- InsforgeConfigProvider,
1473
+ AuthBranding,
1474
+ AuthContainer,
1475
+ AuthDivider,
1476
+ AuthErrorBanner,
1477
+ AuthFormField,
1478
+ AuthHeader,
1479
+ AuthLink,
1480
+ AuthOAuthButton,
1481
+ AuthOAuthProviders,
1482
+ AuthPasswordField,
1483
+ AuthPasswordStrengthIndicator,
1484
+ AuthSubmitButton,
1485
+ AuthVerificationCodeInput,
1486
+ InsforgeProvider,
1487
+ OAUTH_PROVIDER_CONFIG,
1074
1488
  Protect,
1075
1489
  SignIn,
1076
1490
  SignUp,
1077
1491
  SignedIn,
1078
1492
  SignedOut,
1079
1493
  UserButton,
1494
+ getProviderConfig,
1495
+ getProviderName,
1496
+ isProviderSupported,
1080
1497
  useAuth,
1081
- useInsforgeConfig,
1498
+ useInsforge,
1082
1499
  useOAuthProviders,
1083
1500
  useSession,
1084
- useUser
1501
+ useUser,
1502
+ validatePasswordStrength
1085
1503
  });
1086
1504
  //# sourceMappingURL=index.js.map