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