@insforge/nextjs 0.6.7 → 0.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +116 -244
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +113 -241
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/api.d.mts +0 -50
- package/dist/api.d.ts +0 -50
- package/dist/index.d.mts +0 -258
- package/dist/index.d.ts +0 -258
- package/dist/middleware.d.mts +0 -20
- package/dist/middleware.d.ts +0 -20
package/dist/index.js
CHANGED
|
@@ -70,20 +70,6 @@ var import_react = require("react");
|
|
|
70
70
|
var import_sdk = require("@insforge/sdk");
|
|
71
71
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
72
72
|
var InsforgeContext = (0, import_react.createContext)(void 0);
|
|
73
|
-
async function fetchOAuthProviders(baseUrl) {
|
|
74
|
-
try {
|
|
75
|
-
const response = await fetch(`${baseUrl}/api/auth/oauth/configs`);
|
|
76
|
-
if (!response.ok) return [];
|
|
77
|
-
const result = await response.json();
|
|
78
|
-
if (result?.data && Array.isArray(result.data)) {
|
|
79
|
-
return result.data.map((config) => config.provider);
|
|
80
|
-
}
|
|
81
|
-
return [];
|
|
82
|
-
} catch (error) {
|
|
83
|
-
console.warn("Failed to fetch OAuth configs:", error);
|
|
84
|
-
return [];
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
73
|
function getTokenFromSDK() {
|
|
88
74
|
console.log("[InsforgeProvider] Getting token from SDK");
|
|
89
75
|
if (typeof window === "undefined") return null;
|
|
@@ -127,18 +113,8 @@ function InsforgeProvider({
|
|
|
127
113
|
const [user, setUser] = (0, import_react.useState)(null);
|
|
128
114
|
const [session, setSession] = (0, import_react.useState)(null);
|
|
129
115
|
const [isLoaded, setIsLoaded] = (0, import_react.useState)(false);
|
|
130
|
-
const [oauthProviders, setOauthProviders] = (0, import_react.useState)([]);
|
|
131
|
-
const [isConfigLoaded, setIsConfigLoaded] = (0, import_react.useState)(false);
|
|
132
116
|
const refreshIntervalRef = (0, import_react.useRef)();
|
|
133
117
|
const [insforge] = (0, import_react.useState)(() => (0, import_sdk.createClient)({ baseUrl }));
|
|
134
|
-
(0, import_react.useEffect)(() => {
|
|
135
|
-
async function loadConfig() {
|
|
136
|
-
const providers = await fetchOAuthProviders(baseUrl);
|
|
137
|
-
setOauthProviders(providers);
|
|
138
|
-
setIsConfigLoaded(true);
|
|
139
|
-
}
|
|
140
|
-
loadConfig();
|
|
141
|
-
}, [baseUrl]);
|
|
142
118
|
const loadAuthState = (0, import_react.useCallback)(async () => {
|
|
143
119
|
try {
|
|
144
120
|
const token = getTokenFromSDK();
|
|
@@ -338,59 +314,6 @@ function InsforgeProvider({
|
|
|
338
314
|
},
|
|
339
315
|
[user, onAuthChange, insforge]
|
|
340
316
|
);
|
|
341
|
-
const sendVerificationCode = (0, import_react.useCallback)(
|
|
342
|
-
async (email, type) => {
|
|
343
|
-
console.log(`[Verification] Sending ${type} code to ${email}`);
|
|
344
|
-
console.log("[Verification] Dummy code: 123456");
|
|
345
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
346
|
-
},
|
|
347
|
-
[insforge]
|
|
348
|
-
);
|
|
349
|
-
const verifySignUpCode = (0, import_react.useCallback)(
|
|
350
|
-
async (email, password, code) => {
|
|
351
|
-
if (code !== "123456") {
|
|
352
|
-
throw new Error("Invalid verification code");
|
|
353
|
-
}
|
|
354
|
-
const sdkResult = await insforge.auth.signUp({ email, password });
|
|
355
|
-
if (sdkResult.data) {
|
|
356
|
-
const userData = {
|
|
357
|
-
id: sdkResult.data.user.id,
|
|
358
|
-
email: sdkResult.data.user.email,
|
|
359
|
-
name: sdkResult.data.user.name || void 0,
|
|
360
|
-
createdAt: sdkResult.data.user.createdAt,
|
|
361
|
-
updatedAt: sdkResult.data.user.updatedAt
|
|
362
|
-
};
|
|
363
|
-
const sessionData = {
|
|
364
|
-
userId: sdkResult.data.user.id,
|
|
365
|
-
token: sdkResult.data.accessToken,
|
|
366
|
-
expiresAt: "",
|
|
367
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
368
|
-
};
|
|
369
|
-
setUser(userData);
|
|
370
|
-
setSession(sessionData);
|
|
371
|
-
if (onAuthChange) {
|
|
372
|
-
onAuthChange(userData);
|
|
373
|
-
}
|
|
374
|
-
try {
|
|
375
|
-
await syncTokenToCookie(sdkResult.data.accessToken);
|
|
376
|
-
} catch (error) {
|
|
377
|
-
}
|
|
378
|
-
} else {
|
|
379
|
-
const errorMessage = sdkResult.error?.message || "Sign up failed";
|
|
380
|
-
throw new Error(errorMessage);
|
|
381
|
-
}
|
|
382
|
-
},
|
|
383
|
-
[insforge, onAuthChange]
|
|
384
|
-
);
|
|
385
|
-
const verifySignInCode = (0, import_react.useCallback)(
|
|
386
|
-
async (email, code) => {
|
|
387
|
-
if (code !== "123456") {
|
|
388
|
-
throw new Error("Invalid verification code");
|
|
389
|
-
}
|
|
390
|
-
throw new Error("Passwordless sign in via verification code is not yet implemented in the backend");
|
|
391
|
-
},
|
|
392
|
-
[insforge, onAuthChange]
|
|
393
|
-
);
|
|
394
317
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
395
318
|
InsforgeContext.Provider,
|
|
396
319
|
{
|
|
@@ -405,13 +328,10 @@ function InsforgeProvider({
|
|
|
405
328
|
signUp,
|
|
406
329
|
signOut,
|
|
407
330
|
updateUser,
|
|
408
|
-
//
|
|
409
|
-
sendVerificationCode,
|
|
410
|
-
verifySignUpCode,
|
|
411
|
-
verifySignInCode,
|
|
412
|
-
// Config
|
|
413
|
-
oauthProviders,
|
|
414
|
-
isConfigLoaded,
|
|
331
|
+
// Email verification (commented out - verification disabled for now)
|
|
332
|
+
// sendVerificationCode,
|
|
333
|
+
// verifySignUpCode,
|
|
334
|
+
// verifySignInCode,
|
|
415
335
|
// Base
|
|
416
336
|
baseUrl
|
|
417
337
|
},
|
|
@@ -446,14 +366,47 @@ function useSession() {
|
|
|
446
366
|
}
|
|
447
367
|
|
|
448
368
|
// src/hooks/useOAuthProviders.ts
|
|
369
|
+
var import_react2 = require("react");
|
|
370
|
+
var import_sdk2 = require("@insforge/sdk");
|
|
449
371
|
function useOAuthProviders() {
|
|
450
|
-
const {
|
|
451
|
-
|
|
372
|
+
const { baseUrl } = useInsforge();
|
|
373
|
+
const [providers, setProviders] = (0, import_react2.useState)([]);
|
|
374
|
+
const [isLoaded, setIsLoaded] = (0, import_react2.useState)(false);
|
|
375
|
+
(0, import_react2.useEffect)(() => {
|
|
376
|
+
let mounted = true;
|
|
377
|
+
async function fetchProviders() {
|
|
378
|
+
try {
|
|
379
|
+
const insforge = (0, import_sdk2.createClient)({ baseUrl });
|
|
380
|
+
const { data, error } = await insforge.auth.getOAuthProviders();
|
|
381
|
+
if (!mounted) return;
|
|
382
|
+
if (error) {
|
|
383
|
+
console.warn("[useOAuthProviders] Failed to fetch OAuth providers:", error);
|
|
384
|
+
setProviders([]);
|
|
385
|
+
} else if (data) {
|
|
386
|
+
setProviders(data);
|
|
387
|
+
} else {
|
|
388
|
+
setProviders([]);
|
|
389
|
+
}
|
|
390
|
+
setIsLoaded(true);
|
|
391
|
+
} catch (error) {
|
|
392
|
+
console.warn("[useOAuthProviders] Unexpected error:", error);
|
|
393
|
+
if (mounted) {
|
|
394
|
+
setProviders([]);
|
|
395
|
+
setIsLoaded(true);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
fetchProviders();
|
|
400
|
+
return () => {
|
|
401
|
+
mounted = false;
|
|
402
|
+
};
|
|
403
|
+
}, [baseUrl]);
|
|
404
|
+
return { providers, isLoaded };
|
|
452
405
|
}
|
|
453
406
|
|
|
454
407
|
// src/components/SignIn.tsx
|
|
455
|
-
var
|
|
456
|
-
var
|
|
408
|
+
var import_react5 = require("react");
|
|
409
|
+
var import_sdk3 = require("@insforge/sdk");
|
|
457
410
|
|
|
458
411
|
// src/components/auth/AuthBranding.tsx
|
|
459
412
|
var import_link = __toESM(require("next/link"));
|
|
@@ -565,7 +518,7 @@ function AuthFormField({ label, id, className = "", ...props }) {
|
|
|
565
518
|
}
|
|
566
519
|
|
|
567
520
|
// src/components/auth/AuthPasswordField.tsx
|
|
568
|
-
var
|
|
521
|
+
var import_react3 = require("react");
|
|
569
522
|
var import_lucide_react3 = require("lucide-react");
|
|
570
523
|
|
|
571
524
|
// src/components/auth/AuthPasswordStrengthIndicator.tsx
|
|
@@ -621,8 +574,8 @@ function AuthPasswordField({
|
|
|
621
574
|
onFocus,
|
|
622
575
|
...props
|
|
623
576
|
}) {
|
|
624
|
-
const [showPassword, setShowPassword] = (0,
|
|
625
|
-
const [showStrength, setShowStrength] = (0,
|
|
577
|
+
const [showPassword, setShowPassword] = (0, import_react3.useState)(false);
|
|
578
|
+
const [showStrength, setShowStrength] = (0, import_react3.useState)(false);
|
|
626
579
|
const handleFocus = (e) => {
|
|
627
580
|
if (showStrengthIndicator) {
|
|
628
581
|
setShowStrength(true);
|
|
@@ -949,7 +902,7 @@ function AuthOAuthProviders({
|
|
|
949
902
|
}
|
|
950
903
|
|
|
951
904
|
// src/components/auth/AuthVerificationCodeInput.tsx
|
|
952
|
-
var
|
|
905
|
+
var import_react4 = require("react");
|
|
953
906
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
954
907
|
function AuthVerificationCodeInput({
|
|
955
908
|
length = 6,
|
|
@@ -958,7 +911,7 @@ function AuthVerificationCodeInput({
|
|
|
958
911
|
onChange,
|
|
959
912
|
disabled = false
|
|
960
913
|
}) {
|
|
961
|
-
const inputRefs = (0,
|
|
914
|
+
const inputRefs = (0, import_react4.useRef)([]);
|
|
962
915
|
const handleChange = (index, digit) => {
|
|
963
916
|
if (digit.length > 1) return;
|
|
964
917
|
if (digit && !/^\d$/.test(digit)) return;
|
|
@@ -1040,13 +993,14 @@ function SignIn({
|
|
|
1040
993
|
onSuccess,
|
|
1041
994
|
onError
|
|
1042
995
|
}) {
|
|
1043
|
-
const { signIn,
|
|
1044
|
-
const
|
|
1045
|
-
const [
|
|
1046
|
-
const [
|
|
1047
|
-
const [
|
|
1048
|
-
const [
|
|
1049
|
-
const
|
|
996
|
+
const { signIn, baseUrl } = useInsforge();
|
|
997
|
+
const { providers: oauthProviders } = useOAuthProviders();
|
|
998
|
+
const [email, setEmail] = (0, import_react5.useState)("");
|
|
999
|
+
const [password, setPassword] = (0, import_react5.useState)("");
|
|
1000
|
+
const [error, setError] = (0, import_react5.useState)("");
|
|
1001
|
+
const [loading, setLoading] = (0, import_react5.useState)(false);
|
|
1002
|
+
const [oauthLoading, setOauthLoading] = (0, import_react5.useState)(null);
|
|
1003
|
+
const insforge = (0, import_react5.useState)(() => (0, import_sdk3.createClient)({ baseUrl }))[0];
|
|
1050
1004
|
async function handleSubmit(e) {
|
|
1051
1005
|
e.preventDefault();
|
|
1052
1006
|
setLoading(true);
|
|
@@ -1109,11 +1063,7 @@ function SignIn({
|
|
|
1109
1063
|
value: password,
|
|
1110
1064
|
onChange: (e) => setPassword(e.target.value),
|
|
1111
1065
|
required: true,
|
|
1112
|
-
autoComplete: "current-password"
|
|
1113
|
-
forgotPasswordLink: {
|
|
1114
|
-
href: "#",
|
|
1115
|
-
text: forgotPasswordText
|
|
1116
|
-
}
|
|
1066
|
+
autoComplete: "current-password"
|
|
1117
1067
|
}
|
|
1118
1068
|
),
|
|
1119
1069
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
@@ -1143,8 +1093,8 @@ function SignIn({
|
|
|
1143
1093
|
}
|
|
1144
1094
|
|
|
1145
1095
|
// src/components/SignUp.tsx
|
|
1146
|
-
var
|
|
1147
|
-
var
|
|
1096
|
+
var import_react6 = require("react");
|
|
1097
|
+
var import_sdk4 = require("@insforge/sdk");
|
|
1148
1098
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1149
1099
|
function SignUp({
|
|
1150
1100
|
afterSignUpUrl = "/",
|
|
@@ -1157,9 +1107,9 @@ function SignUp({
|
|
|
1157
1107
|
passwordPlaceholder = "\u2022\u2022\u2022\u2022\u2022\u2022",
|
|
1158
1108
|
submitButtonText = "Sign Up",
|
|
1159
1109
|
loadingButtonText = "Creating account...",
|
|
1160
|
-
verifyButtonText = "Continue",
|
|
1161
|
-
loadingVerifyButtonText = "Verifying...",
|
|
1162
|
-
verifiedButtonText = "Verified",
|
|
1110
|
+
// verifyButtonText = "Continue", // Commented out - email verification disabled for now
|
|
1111
|
+
// loadingVerifyButtonText = "Verifying...", // Commented out - email verification disabled for now
|
|
1112
|
+
// verifiedButtonText = "Verified", // Commented out - email verification disabled for now
|
|
1163
1113
|
signInText = "Already have an account?",
|
|
1164
1114
|
signInLinkText = "Login Now",
|
|
1165
1115
|
signInUrl = "/sign-in",
|
|
@@ -1167,18 +1117,14 @@ function SignUp({
|
|
|
1167
1117
|
onSuccess,
|
|
1168
1118
|
onError
|
|
1169
1119
|
}) {
|
|
1170
|
-
const {
|
|
1171
|
-
const
|
|
1172
|
-
const [
|
|
1173
|
-
const [
|
|
1174
|
-
const [error, setError] = (0,
|
|
1175
|
-
const [loading, setLoading] = (0,
|
|
1176
|
-
const [oauthLoading, setOauthLoading] = (0,
|
|
1177
|
-
const
|
|
1178
|
-
const [step, setStep] = (0, import_react5.useState)(
|
|
1179
|
-
"credentials"
|
|
1180
|
-
);
|
|
1181
|
-
const insforge = (0, import_react5.useState)(() => (0, import_sdk3.createClient)({ baseUrl }))[0];
|
|
1120
|
+
const { signUp, baseUrl } = useInsforge();
|
|
1121
|
+
const { providers: oauthProviders } = useOAuthProviders();
|
|
1122
|
+
const [email, setEmail] = (0, import_react6.useState)("");
|
|
1123
|
+
const [password, setPassword] = (0, import_react6.useState)("");
|
|
1124
|
+
const [error, setError] = (0, import_react6.useState)("");
|
|
1125
|
+
const [loading, setLoading] = (0, import_react6.useState)(false);
|
|
1126
|
+
const [oauthLoading, setOauthLoading] = (0, import_react6.useState)(null);
|
|
1127
|
+
const insforge = (0, import_react6.useState)(() => (0, import_sdk4.createClient)({ baseUrl }))[0];
|
|
1182
1128
|
async function handleCredentialsSubmit(e) {
|
|
1183
1129
|
e.preventDefault();
|
|
1184
1130
|
setLoading(true);
|
|
@@ -1189,53 +1135,20 @@ function SignUp({
|
|
|
1189
1135
|
return;
|
|
1190
1136
|
}
|
|
1191
1137
|
try {
|
|
1192
|
-
await
|
|
1193
|
-
setStep("verification");
|
|
1194
|
-
} catch (err) {
|
|
1195
|
-
const errorMessage = err.message || "Failed to send verification code";
|
|
1196
|
-
setError(errorMessage);
|
|
1197
|
-
if (onError) onError(new Error(errorMessage));
|
|
1198
|
-
} finally {
|
|
1199
|
-
setLoading(false);
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
async function handleVerificationSubmit(e) {
|
|
1203
|
-
e.preventDefault();
|
|
1204
|
-
setLoading(true);
|
|
1205
|
-
setError("");
|
|
1206
|
-
if (verificationCode.length !== 6) {
|
|
1207
|
-
setError("Please enter the complete verification code");
|
|
1208
|
-
setLoading(false);
|
|
1209
|
-
return;
|
|
1210
|
-
}
|
|
1211
|
-
try {
|
|
1212
|
-
await verifySignUpCode(email, password, verificationCode);
|
|
1138
|
+
await signUp(email, password);
|
|
1213
1139
|
if (onSuccess) {
|
|
1214
|
-
setVerified(true);
|
|
1215
1140
|
const userResult = await insforge.auth.getCurrentUser();
|
|
1216
1141
|
if (userResult.data) onSuccess(userResult.data);
|
|
1217
1142
|
}
|
|
1218
1143
|
window.location.href = afterSignUpUrl;
|
|
1219
1144
|
} catch (err) {
|
|
1220
|
-
const errorMessage = err.message || "
|
|
1145
|
+
const errorMessage = err.message || "Sign up failed";
|
|
1221
1146
|
setError(errorMessage);
|
|
1222
1147
|
if (onError) onError(new Error(errorMessage));
|
|
1223
1148
|
} finally {
|
|
1224
1149
|
setLoading(false);
|
|
1225
1150
|
}
|
|
1226
1151
|
}
|
|
1227
|
-
async function handleResendCode() {
|
|
1228
|
-
setLoading(true);
|
|
1229
|
-
setError("");
|
|
1230
|
-
try {
|
|
1231
|
-
await sendVerificationCode(email, "signup");
|
|
1232
|
-
} catch (err) {
|
|
1233
|
-
const errorMessage = err.message || "Failed to resend code";
|
|
1234
|
-
setError(errorMessage);
|
|
1235
|
-
} finally {
|
|
1236
|
-
setLoading(false);
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
1152
|
async function handleOAuth(provider) {
|
|
1240
1153
|
try {
|
|
1241
1154
|
setOauthLoading(provider);
|
|
@@ -1255,105 +1168,64 @@ function SignUp({
|
|
|
1255
1168
|
setOauthLoading(null);
|
|
1256
1169
|
}
|
|
1257
1170
|
}
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("form", { onSubmit: handleCredentialsSubmit, className: "insforge-form", children: [
|
|
1263
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1264
|
-
AuthFormField,
|
|
1265
|
-
{
|
|
1266
|
-
id: "email",
|
|
1267
|
-
type: "email",
|
|
1268
|
-
label: emailLabel,
|
|
1269
|
-
placeholder: emailPlaceholder,
|
|
1270
|
-
value: email,
|
|
1271
|
-
onChange: (e) => setEmail(e.target.value),
|
|
1272
|
-
required: true,
|
|
1273
|
-
autoComplete: "email"
|
|
1274
|
-
}
|
|
1275
|
-
),
|
|
1276
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1277
|
-
AuthPasswordField,
|
|
1278
|
-
{
|
|
1279
|
-
id: "password",
|
|
1280
|
-
label: passwordLabel,
|
|
1281
|
-
placeholder: passwordPlaceholder,
|
|
1282
|
-
value: password,
|
|
1283
|
-
onChange: (e) => setPassword(e.target.value),
|
|
1284
|
-
required: true,
|
|
1285
|
-
minLength: 8,
|
|
1286
|
-
autoComplete: "new-password",
|
|
1287
|
-
showStrengthIndicator: true
|
|
1288
|
-
}
|
|
1289
|
-
),
|
|
1290
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1291
|
-
AuthSubmitButton,
|
|
1292
|
-
{
|
|
1293
|
-
isLoading: loading,
|
|
1294
|
-
disabled: loading || oauthLoading !== null,
|
|
1295
|
-
style: appearance.button,
|
|
1296
|
-
children: loading ? loadingButtonText : submitButtonText
|
|
1297
|
-
}
|
|
1298
|
-
)
|
|
1299
|
-
] }),
|
|
1171
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(AuthContainer, { style: appearance.container, children: [
|
|
1172
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(AuthHeader, { title, subtitle }),
|
|
1173
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(AuthErrorBanner, { error }),
|
|
1174
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("form", { onSubmit: handleCredentialsSubmit, className: "insforge-form", children: [
|
|
1300
1175
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1301
|
-
|
|
1176
|
+
AuthFormField,
|
|
1302
1177
|
{
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1178
|
+
id: "email",
|
|
1179
|
+
type: "email",
|
|
1180
|
+
label: emailLabel,
|
|
1181
|
+
placeholder: emailPlaceholder,
|
|
1182
|
+
value: email,
|
|
1183
|
+
onChange: (e) => setEmail(e.target.value),
|
|
1184
|
+
required: true,
|
|
1185
|
+
autoComplete: "email"
|
|
1306
1186
|
}
|
|
1307
1187
|
),
|
|
1308
|
-
oauthProviders.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
1309
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(AuthDivider, { text: dividerText }),
|
|
1310
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1311
|
-
AuthOAuthProviders,
|
|
1312
|
-
{
|
|
1313
|
-
providers: oauthProviders,
|
|
1314
|
-
onClick: handleOAuth,
|
|
1315
|
-
disabled: loading || oauthLoading !== null,
|
|
1316
|
-
loading: oauthLoading
|
|
1317
|
-
}
|
|
1318
|
-
)
|
|
1319
|
-
] })
|
|
1320
|
-
] });
|
|
1321
|
-
}
|
|
1322
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(AuthContainer, { style: appearance.container, children: [
|
|
1323
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(AuthHeader, { title, subtitle }),
|
|
1324
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(AuthErrorBanner, { error }),
|
|
1325
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("form", { onSubmit: handleVerificationSubmit, className: "insforge-form", children: [
|
|
1326
1188
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1327
|
-
|
|
1189
|
+
AuthPasswordField,
|
|
1328
1190
|
{
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1191
|
+
id: "password",
|
|
1192
|
+
label: passwordLabel,
|
|
1193
|
+
placeholder: passwordPlaceholder,
|
|
1194
|
+
value: password,
|
|
1195
|
+
onChange: (e) => setPassword(e.target.value),
|
|
1196
|
+
required: true,
|
|
1197
|
+
minLength: 8,
|
|
1198
|
+
autoComplete: "new-password",
|
|
1199
|
+
showStrengthIndicator: true
|
|
1333
1200
|
}
|
|
1334
1201
|
),
|
|
1335
1202
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1336
1203
|
AuthSubmitButton,
|
|
1337
1204
|
{
|
|
1338
1205
|
isLoading: loading,
|
|
1339
|
-
disabled: loading,
|
|
1206
|
+
disabled: loading || oauthLoading !== null,
|
|
1340
1207
|
style: appearance.button,
|
|
1341
|
-
|
|
1342
|
-
children: verified ? verifiedButtonText : loading ? loadingVerifyButtonText : verifyButtonText
|
|
1208
|
+
children: loading ? loadingButtonText : submitButtonText
|
|
1343
1209
|
}
|
|
1344
1210
|
)
|
|
1345
1211
|
] }),
|
|
1346
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.
|
|
1347
|
-
|
|
1348
|
-
|
|
1212
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1213
|
+
AuthLink,
|
|
1214
|
+
{
|
|
1215
|
+
text: signInText,
|
|
1216
|
+
linkText: signInLinkText,
|
|
1217
|
+
href: signInUrl
|
|
1218
|
+
}
|
|
1219
|
+
),
|
|
1220
|
+
oauthProviders.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
1221
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(AuthDivider, { text: dividerText }),
|
|
1349
1222
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1350
|
-
|
|
1223
|
+
AuthOAuthProviders,
|
|
1351
1224
|
{
|
|
1352
|
-
|
|
1353
|
-
onClick:
|
|
1354
|
-
disabled: loading,
|
|
1355
|
-
|
|
1356
|
-
children: "Click to resend"
|
|
1225
|
+
providers: oauthProviders,
|
|
1226
|
+
onClick: handleOAuth,
|
|
1227
|
+
disabled: loading || oauthLoading !== null,
|
|
1228
|
+
loading: oauthLoading
|
|
1357
1229
|
}
|
|
1358
1230
|
)
|
|
1359
1231
|
] })
|
|
@@ -1361,7 +1233,7 @@ function SignUp({
|
|
|
1361
1233
|
}
|
|
1362
1234
|
|
|
1363
1235
|
// src/components/UserButton.tsx
|
|
1364
|
-
var
|
|
1236
|
+
var import_react7 = require("react");
|
|
1365
1237
|
var import_lucide_react6 = require("lucide-react");
|
|
1366
1238
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1367
1239
|
function UserButton({
|
|
@@ -1370,9 +1242,9 @@ function UserButton({
|
|
|
1370
1242
|
appearance = {}
|
|
1371
1243
|
}) {
|
|
1372
1244
|
const { user, signOut } = useInsforge();
|
|
1373
|
-
const [isOpen, setIsOpen] = (0,
|
|
1374
|
-
const dropdownRef = (0,
|
|
1375
|
-
(0,
|
|
1245
|
+
const [isOpen, setIsOpen] = (0, import_react7.useState)(false);
|
|
1246
|
+
const dropdownRef = (0, import_react7.useRef)(null);
|
|
1247
|
+
(0, import_react7.useEffect)(() => {
|
|
1376
1248
|
function handleClickOutside(event) {
|
|
1377
1249
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
1378
1250
|
setIsOpen(false);
|
|
@@ -1437,7 +1309,7 @@ function SignedOut({ children }) {
|
|
|
1437
1309
|
}
|
|
1438
1310
|
|
|
1439
1311
|
// src/components/Protect.tsx
|
|
1440
|
-
var
|
|
1312
|
+
var import_react8 = require("react");
|
|
1441
1313
|
var import_navigation = require("next/navigation");
|
|
1442
1314
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1443
1315
|
function Protect({
|
|
@@ -1448,7 +1320,7 @@ function Protect({
|
|
|
1448
1320
|
}) {
|
|
1449
1321
|
const { isSignedIn, isLoaded, user } = useInsforge();
|
|
1450
1322
|
const router = (0, import_navigation.useRouter)();
|
|
1451
|
-
(0,
|
|
1323
|
+
(0, import_react8.useEffect)(() => {
|
|
1452
1324
|
if (isLoaded && !isSignedIn) {
|
|
1453
1325
|
router.push(redirectTo);
|
|
1454
1326
|
} else if (isLoaded && isSignedIn && condition && user) {
|