@insforge/react 0.3.2 → 0.3.3
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 +604 -604
- package/dist/atoms.d.mts +5 -5
- package/dist/atoms.d.ts +5 -5
- package/dist/atoms.js +4 -12
- package/dist/atoms.js.map +1 -1
- package/dist/atoms.mjs +4 -12
- package/dist/atoms.mjs.map +1 -1
- package/dist/components.js +46 -54
- package/dist/components.js.map +1 -1
- package/dist/components.mjs +46 -54
- package/dist/components.mjs.map +1 -1
- package/dist/forms.d.mts +4 -4
- package/dist/forms.d.ts +4 -4
- package/dist/forms.js +12 -20
- package/dist/forms.js.map +1 -1
- package/dist/forms.mjs +12 -20
- package/dist/forms.mjs.map +1 -1
- package/dist/hooks.d.mts +4 -4
- package/dist/hooks.d.ts +4 -4
- package/dist/hooks.js +4 -4
- package/dist/hooks.js.map +1 -1
- package/dist/hooks.mjs +4 -4
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +49 -57
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -57
- package/dist/index.mjs.map +1 -1
- package/dist/lib.js.map +1 -1
- package/dist/lib.mjs.map +1 -1
- package/dist/router.js.map +1 -1
- package/dist/router.mjs.map +1 -1
- package/dist/types.d.mts +4 -4
- package/dist/types.d.ts +4 -4
- package/package.json +98 -98
- package/src/styles.css +15 -15
package/dist/components.mjs
CHANGED
|
@@ -18,22 +18,22 @@ function useInsforge() {
|
|
|
18
18
|
}
|
|
19
19
|
function usePublicAuthConfig() {
|
|
20
20
|
const { getPublicAuthConfig } = useInsforge();
|
|
21
|
-
const [
|
|
21
|
+
const [authConfig, setAuthConfig] = useState(null);
|
|
22
22
|
const [isLoaded, setIsLoaded] = useState(false);
|
|
23
23
|
useEffect(() => {
|
|
24
24
|
async function fetchConfig() {
|
|
25
25
|
const result = await getPublicAuthConfig();
|
|
26
26
|
if (result) {
|
|
27
|
-
|
|
27
|
+
setAuthConfig(result);
|
|
28
28
|
} else {
|
|
29
29
|
console.error("[usePublicAuthConfig] Failed to get public auth config");
|
|
30
|
-
|
|
30
|
+
setAuthConfig(null);
|
|
31
31
|
}
|
|
32
32
|
setIsLoaded(true);
|
|
33
33
|
}
|
|
34
34
|
fetchConfig();
|
|
35
35
|
}, [getPublicAuthConfig]);
|
|
36
|
-
return {
|
|
36
|
+
return { authConfig, isLoaded };
|
|
37
37
|
}
|
|
38
38
|
function AuthBranding() {
|
|
39
39
|
return /* @__PURE__ */ jsxs("div", { className: "bg-[#FAFAFA] px-2 py-4 flex flex-row justify-center items-center gap-1", children: [
|
|
@@ -270,7 +270,7 @@ function AuthPasswordField({
|
|
|
270
270
|
label,
|
|
271
271
|
id,
|
|
272
272
|
showStrengthIndicator = false,
|
|
273
|
-
|
|
273
|
+
authConfig,
|
|
274
274
|
forgotPasswordLink,
|
|
275
275
|
value,
|
|
276
276
|
appearance = {},
|
|
@@ -348,7 +348,7 @@ function AuthPasswordField({
|
|
|
348
348
|
AuthPasswordStrengthIndicator,
|
|
349
349
|
{
|
|
350
350
|
password: String(value || ""),
|
|
351
|
-
config:
|
|
351
|
+
config: authConfig
|
|
352
352
|
}
|
|
353
353
|
)
|
|
354
354
|
]
|
|
@@ -782,11 +782,7 @@ function AuthEmailVerificationStep({
|
|
|
782
782
|
useEffect(() => {
|
|
783
783
|
const sendInitialEmail = async () => {
|
|
784
784
|
try {
|
|
785
|
-
|
|
786
|
-
await insforge.auth.sendVerificationCode({ email });
|
|
787
|
-
} else {
|
|
788
|
-
await insforge.auth.sendVerificationLink({ email });
|
|
789
|
-
}
|
|
785
|
+
await insforge.auth.sendVerificationEmail({ email });
|
|
790
786
|
} catch {
|
|
791
787
|
}
|
|
792
788
|
};
|
|
@@ -812,11 +808,7 @@ function AuthEmailVerificationStep({
|
|
|
812
808
|
setIsSending(true);
|
|
813
809
|
setVerificationError("");
|
|
814
810
|
try {
|
|
815
|
-
|
|
816
|
-
await insforge.auth.sendVerificationCode({ email });
|
|
817
|
-
} else {
|
|
818
|
-
await insforge.auth.sendVerificationLink({ email });
|
|
819
|
-
}
|
|
811
|
+
await insforge.auth.sendVerificationEmail({ email });
|
|
820
812
|
} catch {
|
|
821
813
|
setResendDisabled(false);
|
|
822
814
|
setResendCountdown(0);
|
|
@@ -894,7 +886,7 @@ function SignInForm({
|
|
|
894
886
|
oauthLoading = null,
|
|
895
887
|
availableProviders = [],
|
|
896
888
|
onOAuthClick,
|
|
897
|
-
|
|
889
|
+
authConfig,
|
|
898
890
|
appearance = {},
|
|
899
891
|
title = "Welcome Back",
|
|
900
892
|
subtitle = "Login to your account",
|
|
@@ -984,7 +976,7 @@ function SignInForm({
|
|
|
984
976
|
onChange: (e) => onPasswordChange(e.target.value),
|
|
985
977
|
required: true,
|
|
986
978
|
autoComplete: "current-password",
|
|
987
|
-
|
|
979
|
+
authConfig,
|
|
988
980
|
forgotPasswordLink: forgotPasswordUrl ? {
|
|
989
981
|
href: forgotPasswordUrl,
|
|
990
982
|
text: forgotPasswordText
|
|
@@ -1055,7 +1047,7 @@ function SignIn({
|
|
|
1055
1047
|
...uiProps
|
|
1056
1048
|
}) {
|
|
1057
1049
|
const { signIn, baseUrl } = useInsforge();
|
|
1058
|
-
const {
|
|
1050
|
+
const { authConfig } = usePublicAuthConfig();
|
|
1059
1051
|
const [email, setEmail] = useState("");
|
|
1060
1052
|
const [password, setPassword] = useState("");
|
|
1061
1053
|
const [error, setError] = useState("");
|
|
@@ -1121,7 +1113,7 @@ function SignIn({
|
|
|
1121
1113
|
setOauthLoading(null);
|
|
1122
1114
|
}
|
|
1123
1115
|
}
|
|
1124
|
-
if (!
|
|
1116
|
+
if (!authConfig) {
|
|
1125
1117
|
return null;
|
|
1126
1118
|
}
|
|
1127
1119
|
return /* @__PURE__ */ jsx(
|
|
@@ -1135,9 +1127,9 @@ function SignIn({
|
|
|
1135
1127
|
error,
|
|
1136
1128
|
loading,
|
|
1137
1129
|
oauthLoading,
|
|
1138
|
-
availableProviders:
|
|
1130
|
+
availableProviders: authConfig?.oAuthProviders || [],
|
|
1139
1131
|
onOAuthClick: handleOAuth,
|
|
1140
|
-
|
|
1132
|
+
authConfig,
|
|
1141
1133
|
showVerificationStep: step === "awaiting-verification",
|
|
1142
1134
|
onVerifyCode: handleVerifyCode,
|
|
1143
1135
|
...uiProps
|
|
@@ -1155,7 +1147,7 @@ function SignUpForm({
|
|
|
1155
1147
|
oauthLoading = null,
|
|
1156
1148
|
availableProviders = [],
|
|
1157
1149
|
onOAuthClick,
|
|
1158
|
-
|
|
1150
|
+
authConfig,
|
|
1159
1151
|
appearance = {},
|
|
1160
1152
|
title = "Get Started",
|
|
1161
1153
|
subtitle = "Create your account",
|
|
@@ -1242,10 +1234,10 @@ function SignUpForm({
|
|
|
1242
1234
|
value: password,
|
|
1243
1235
|
onChange: (e) => onPasswordChange(e.target.value),
|
|
1244
1236
|
required: true,
|
|
1245
|
-
minLength:
|
|
1237
|
+
minLength: authConfig.passwordMinLength,
|
|
1246
1238
|
autoComplete: "new-password",
|
|
1247
1239
|
showStrengthIndicator: true,
|
|
1248
|
-
|
|
1240
|
+
authConfig,
|
|
1249
1241
|
appearance: {
|
|
1250
1242
|
containerClassName: appearance.form?.passwordField?.container,
|
|
1251
1243
|
labelClassName: appearance.form?.passwordField?.label,
|
|
@@ -1340,7 +1332,7 @@ function SignUp({
|
|
|
1340
1332
|
...uiProps
|
|
1341
1333
|
}) {
|
|
1342
1334
|
const { signUp, baseUrl } = useInsforge();
|
|
1343
|
-
const {
|
|
1335
|
+
const { authConfig } = usePublicAuthConfig();
|
|
1344
1336
|
const [email, setEmail] = useState("");
|
|
1345
1337
|
const [password, setPassword] = useState("");
|
|
1346
1338
|
const [error, setError] = useState("");
|
|
@@ -1354,7 +1346,7 @@ function SignUp({
|
|
|
1354
1346
|
e.preventDefault();
|
|
1355
1347
|
setLoading(true);
|
|
1356
1348
|
setError("");
|
|
1357
|
-
if (!
|
|
1349
|
+
if (!authConfig) {
|
|
1358
1350
|
setError("Configuration not loaded. Please refresh the page.");
|
|
1359
1351
|
setLoading(false);
|
|
1360
1352
|
return;
|
|
@@ -1367,11 +1359,11 @@ function SignUp({
|
|
|
1367
1359
|
return;
|
|
1368
1360
|
}
|
|
1369
1361
|
const passwordZodSchema = createPasswordSchema({
|
|
1370
|
-
minLength:
|
|
1371
|
-
requireUppercase:
|
|
1372
|
-
requireLowercase:
|
|
1373
|
-
requireNumber:
|
|
1374
|
-
requireSpecialChar:
|
|
1362
|
+
minLength: authConfig.passwordMinLength,
|
|
1363
|
+
requireUppercase: authConfig.requireUppercase,
|
|
1364
|
+
requireLowercase: authConfig.requireLowercase,
|
|
1365
|
+
requireNumber: authConfig.requireNumber,
|
|
1366
|
+
requireSpecialChar: authConfig.requireSpecialChar
|
|
1375
1367
|
});
|
|
1376
1368
|
const passwordValidation = passwordZodSchema.safeParse(password);
|
|
1377
1369
|
if (!passwordValidation.success) {
|
|
@@ -1433,7 +1425,7 @@ function SignUp({
|
|
|
1433
1425
|
setOauthLoading(null);
|
|
1434
1426
|
}
|
|
1435
1427
|
}
|
|
1436
|
-
if (!
|
|
1428
|
+
if (!authConfig) {
|
|
1437
1429
|
return null;
|
|
1438
1430
|
}
|
|
1439
1431
|
return /* @__PURE__ */ jsx(
|
|
@@ -1447,9 +1439,9 @@ function SignUp({
|
|
|
1447
1439
|
error,
|
|
1448
1440
|
loading,
|
|
1449
1441
|
oauthLoading,
|
|
1450
|
-
availableProviders:
|
|
1442
|
+
availableProviders: authConfig?.oAuthProviders || [],
|
|
1451
1443
|
onOAuthClick: handleOAuth,
|
|
1452
|
-
|
|
1444
|
+
authConfig,
|
|
1453
1445
|
showVerificationStep: step === "awaiting-verification",
|
|
1454
1446
|
onVerifyCode: handleVerifyCode,
|
|
1455
1447
|
...uiProps
|
|
@@ -1581,7 +1573,7 @@ function ResetPasswordForm({
|
|
|
1581
1573
|
error,
|
|
1582
1574
|
loading = false,
|
|
1583
1575
|
success = false,
|
|
1584
|
-
|
|
1576
|
+
authConfig,
|
|
1585
1577
|
appearance = {},
|
|
1586
1578
|
title = "Reset Password",
|
|
1587
1579
|
subtitle = "Enter your new password below.",
|
|
@@ -1658,7 +1650,7 @@ function ResetPasswordForm({
|
|
|
1658
1650
|
required: true,
|
|
1659
1651
|
autoComplete: "new-password",
|
|
1660
1652
|
showStrengthIndicator: true,
|
|
1661
|
-
|
|
1653
|
+
authConfig,
|
|
1662
1654
|
appearance: {
|
|
1663
1655
|
containerClassName: appearance.form?.newPasswordField?.container,
|
|
1664
1656
|
labelClassName: appearance.form?.newPasswordField?.label,
|
|
@@ -1676,7 +1668,7 @@ function ResetPasswordForm({
|
|
|
1676
1668
|
onChange: (e) => onConfirmPasswordChange(e.target.value),
|
|
1677
1669
|
required: true,
|
|
1678
1670
|
autoComplete: "new-password",
|
|
1679
|
-
|
|
1671
|
+
authConfig,
|
|
1680
1672
|
appearance: {
|
|
1681
1673
|
containerClassName: appearance.form?.confirmPasswordField?.container,
|
|
1682
1674
|
labelClassName: appearance.form?.confirmPasswordField?.label,
|
|
@@ -1720,7 +1712,7 @@ function ResetPassword({
|
|
|
1720
1712
|
...uiProps
|
|
1721
1713
|
}) {
|
|
1722
1714
|
const { resetPassword } = useInsforge();
|
|
1723
|
-
const {
|
|
1715
|
+
const { authConfig } = usePublicAuthConfig();
|
|
1724
1716
|
const [newPassword, setNewPassword] = useState("");
|
|
1725
1717
|
const [confirmPassword, setConfirmPassword] = useState("");
|
|
1726
1718
|
const [error, setError] = useState("");
|
|
@@ -1730,7 +1722,7 @@ function ResetPassword({
|
|
|
1730
1722
|
e.preventDefault();
|
|
1731
1723
|
setLoading(true);
|
|
1732
1724
|
setError("");
|
|
1733
|
-
if (!
|
|
1725
|
+
if (!authConfig) {
|
|
1734
1726
|
setError("Configuration not loaded. Please refresh the page.");
|
|
1735
1727
|
setLoading(false);
|
|
1736
1728
|
return;
|
|
@@ -1746,11 +1738,11 @@ function ResetPassword({
|
|
|
1746
1738
|
return;
|
|
1747
1739
|
}
|
|
1748
1740
|
const passwordZodSchema = createPasswordSchema({
|
|
1749
|
-
minLength:
|
|
1750
|
-
requireUppercase:
|
|
1751
|
-
requireLowercase:
|
|
1752
|
-
requireNumber:
|
|
1753
|
-
requireSpecialChar:
|
|
1741
|
+
minLength: authConfig.passwordMinLength,
|
|
1742
|
+
requireUppercase: authConfig.requireUppercase,
|
|
1743
|
+
requireLowercase: authConfig.requireLowercase,
|
|
1744
|
+
requireNumber: authConfig.requireNumber,
|
|
1745
|
+
requireSpecialChar: authConfig.requireSpecialChar
|
|
1754
1746
|
});
|
|
1755
1747
|
const passwordValidation = passwordZodSchema.safeParse(newPassword);
|
|
1756
1748
|
if (!passwordValidation.success) {
|
|
@@ -1783,7 +1775,7 @@ function ResetPassword({
|
|
|
1783
1775
|
setLoading(false);
|
|
1784
1776
|
}
|
|
1785
1777
|
}
|
|
1786
|
-
if (!
|
|
1778
|
+
if (!authConfig) {
|
|
1787
1779
|
return null;
|
|
1788
1780
|
}
|
|
1789
1781
|
return /* @__PURE__ */ jsx(
|
|
@@ -1797,7 +1789,7 @@ function ResetPassword({
|
|
|
1797
1789
|
error,
|
|
1798
1790
|
loading,
|
|
1799
1791
|
success,
|
|
1800
|
-
|
|
1792
|
+
authConfig,
|
|
1801
1793
|
backToSignInUrl,
|
|
1802
1794
|
...uiProps
|
|
1803
1795
|
}
|
|
@@ -1809,8 +1801,8 @@ function ForgotPassword({
|
|
|
1809
1801
|
onError,
|
|
1810
1802
|
...uiProps
|
|
1811
1803
|
}) {
|
|
1812
|
-
const {
|
|
1813
|
-
const {
|
|
1804
|
+
const { sendResetPasswordEmail, baseUrl } = useInsforge();
|
|
1805
|
+
const { authConfig } = usePublicAuthConfig();
|
|
1814
1806
|
const [insforge] = useState(() => createClient({ baseUrl }));
|
|
1815
1807
|
const [step, setStep] = useState("email");
|
|
1816
1808
|
const [email, setEmail] = useState("");
|
|
@@ -1849,9 +1841,9 @@ function ForgotPassword({
|
|
|
1849
1841
|
return;
|
|
1850
1842
|
}
|
|
1851
1843
|
try {
|
|
1852
|
-
const result = await
|
|
1844
|
+
const result = await sendResetPasswordEmail(emailValidation.data);
|
|
1853
1845
|
if (result?.success) {
|
|
1854
|
-
if (
|
|
1846
|
+
if (authConfig?.resetPasswordMethod === "link") {
|
|
1855
1847
|
setSuccess(true);
|
|
1856
1848
|
if (onSuccess) {
|
|
1857
1849
|
onSuccess();
|
|
@@ -1904,7 +1896,7 @@ function ForgotPassword({
|
|
|
1904
1896
|
setIsSendingCode(true);
|
|
1905
1897
|
setError("");
|
|
1906
1898
|
try {
|
|
1907
|
-
await
|
|
1899
|
+
await sendResetPasswordEmail(email);
|
|
1908
1900
|
} catch (err) {
|
|
1909
1901
|
setError(err.message || "Failed to resend code");
|
|
1910
1902
|
setResendDisabled(false);
|
|
@@ -1912,7 +1904,7 @@ function ForgotPassword({
|
|
|
1912
1904
|
} finally {
|
|
1913
1905
|
setIsSendingCode(false);
|
|
1914
1906
|
}
|
|
1915
|
-
}, [email,
|
|
1907
|
+
}, [email, sendResetPasswordEmail]);
|
|
1916
1908
|
function handlePasswordResetSuccess(redirectTo) {
|
|
1917
1909
|
const targetUrl = redirectTo || backToSignInUrl;
|
|
1918
1910
|
if (onSuccess) {
|
|
@@ -1922,7 +1914,7 @@ function ForgotPassword({
|
|
|
1922
1914
|
window.location.href = targetUrl;
|
|
1923
1915
|
}, 1500);
|
|
1924
1916
|
}
|
|
1925
|
-
if (!
|
|
1917
|
+
if (!authConfig) {
|
|
1926
1918
|
return null;
|
|
1927
1919
|
}
|
|
1928
1920
|
if (step === "email") {
|