@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.js
CHANGED
|
@@ -20,22 +20,22 @@ function useInsforge() {
|
|
|
20
20
|
}
|
|
21
21
|
function usePublicAuthConfig() {
|
|
22
22
|
const { getPublicAuthConfig } = useInsforge();
|
|
23
|
-
const [
|
|
23
|
+
const [authConfig, setAuthConfig] = react.useState(null);
|
|
24
24
|
const [isLoaded, setIsLoaded] = react.useState(false);
|
|
25
25
|
react.useEffect(() => {
|
|
26
26
|
async function fetchConfig() {
|
|
27
27
|
const result = await getPublicAuthConfig();
|
|
28
28
|
if (result) {
|
|
29
|
-
|
|
29
|
+
setAuthConfig(result);
|
|
30
30
|
} else {
|
|
31
31
|
console.error("[usePublicAuthConfig] Failed to get public auth config");
|
|
32
|
-
|
|
32
|
+
setAuthConfig(null);
|
|
33
33
|
}
|
|
34
34
|
setIsLoaded(true);
|
|
35
35
|
}
|
|
36
36
|
fetchConfig();
|
|
37
37
|
}, [getPublicAuthConfig]);
|
|
38
|
-
return {
|
|
38
|
+
return { authConfig, isLoaded };
|
|
39
39
|
}
|
|
40
40
|
function AuthBranding() {
|
|
41
41
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-[#FAFAFA] px-2 py-4 flex flex-row justify-center items-center gap-1", children: [
|
|
@@ -272,7 +272,7 @@ function AuthPasswordField({
|
|
|
272
272
|
label,
|
|
273
273
|
id,
|
|
274
274
|
showStrengthIndicator = false,
|
|
275
|
-
|
|
275
|
+
authConfig,
|
|
276
276
|
forgotPasswordLink,
|
|
277
277
|
value,
|
|
278
278
|
appearance = {},
|
|
@@ -350,7 +350,7 @@ function AuthPasswordField({
|
|
|
350
350
|
AuthPasswordStrengthIndicator,
|
|
351
351
|
{
|
|
352
352
|
password: String(value || ""),
|
|
353
|
-
config:
|
|
353
|
+
config: authConfig
|
|
354
354
|
}
|
|
355
355
|
)
|
|
356
356
|
]
|
|
@@ -784,11 +784,7 @@ function AuthEmailVerificationStep({
|
|
|
784
784
|
react.useEffect(() => {
|
|
785
785
|
const sendInitialEmail = async () => {
|
|
786
786
|
try {
|
|
787
|
-
|
|
788
|
-
await insforge.auth.sendVerificationCode({ email });
|
|
789
|
-
} else {
|
|
790
|
-
await insforge.auth.sendVerificationLink({ email });
|
|
791
|
-
}
|
|
787
|
+
await insforge.auth.sendVerificationEmail({ email });
|
|
792
788
|
} catch {
|
|
793
789
|
}
|
|
794
790
|
};
|
|
@@ -814,11 +810,7 @@ function AuthEmailVerificationStep({
|
|
|
814
810
|
setIsSending(true);
|
|
815
811
|
setVerificationError("");
|
|
816
812
|
try {
|
|
817
|
-
|
|
818
|
-
await insforge.auth.sendVerificationCode({ email });
|
|
819
|
-
} else {
|
|
820
|
-
await insforge.auth.sendVerificationLink({ email });
|
|
821
|
-
}
|
|
813
|
+
await insforge.auth.sendVerificationEmail({ email });
|
|
822
814
|
} catch {
|
|
823
815
|
setResendDisabled(false);
|
|
824
816
|
setResendCountdown(0);
|
|
@@ -896,7 +888,7 @@ function SignInForm({
|
|
|
896
888
|
oauthLoading = null,
|
|
897
889
|
availableProviders = [],
|
|
898
890
|
onOAuthClick,
|
|
899
|
-
|
|
891
|
+
authConfig,
|
|
900
892
|
appearance = {},
|
|
901
893
|
title = "Welcome Back",
|
|
902
894
|
subtitle = "Login to your account",
|
|
@@ -986,7 +978,7 @@ function SignInForm({
|
|
|
986
978
|
onChange: (e) => onPasswordChange(e.target.value),
|
|
987
979
|
required: true,
|
|
988
980
|
autoComplete: "current-password",
|
|
989
|
-
|
|
981
|
+
authConfig,
|
|
990
982
|
forgotPasswordLink: forgotPasswordUrl ? {
|
|
991
983
|
href: forgotPasswordUrl,
|
|
992
984
|
text: forgotPasswordText
|
|
@@ -1057,7 +1049,7 @@ function SignIn({
|
|
|
1057
1049
|
...uiProps
|
|
1058
1050
|
}) {
|
|
1059
1051
|
const { signIn, baseUrl } = useInsforge();
|
|
1060
|
-
const {
|
|
1052
|
+
const { authConfig } = usePublicAuthConfig();
|
|
1061
1053
|
const [email, setEmail] = react.useState("");
|
|
1062
1054
|
const [password, setPassword] = react.useState("");
|
|
1063
1055
|
const [error, setError] = react.useState("");
|
|
@@ -1123,7 +1115,7 @@ function SignIn({
|
|
|
1123
1115
|
setOauthLoading(null);
|
|
1124
1116
|
}
|
|
1125
1117
|
}
|
|
1126
|
-
if (!
|
|
1118
|
+
if (!authConfig) {
|
|
1127
1119
|
return null;
|
|
1128
1120
|
}
|
|
1129
1121
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1137,9 +1129,9 @@ function SignIn({
|
|
|
1137
1129
|
error,
|
|
1138
1130
|
loading,
|
|
1139
1131
|
oauthLoading,
|
|
1140
|
-
availableProviders:
|
|
1132
|
+
availableProviders: authConfig?.oAuthProviders || [],
|
|
1141
1133
|
onOAuthClick: handleOAuth,
|
|
1142
|
-
|
|
1134
|
+
authConfig,
|
|
1143
1135
|
showVerificationStep: step === "awaiting-verification",
|
|
1144
1136
|
onVerifyCode: handleVerifyCode,
|
|
1145
1137
|
...uiProps
|
|
@@ -1157,7 +1149,7 @@ function SignUpForm({
|
|
|
1157
1149
|
oauthLoading = null,
|
|
1158
1150
|
availableProviders = [],
|
|
1159
1151
|
onOAuthClick,
|
|
1160
|
-
|
|
1152
|
+
authConfig,
|
|
1161
1153
|
appearance = {},
|
|
1162
1154
|
title = "Get Started",
|
|
1163
1155
|
subtitle = "Create your account",
|
|
@@ -1244,10 +1236,10 @@ function SignUpForm({
|
|
|
1244
1236
|
value: password,
|
|
1245
1237
|
onChange: (e) => onPasswordChange(e.target.value),
|
|
1246
1238
|
required: true,
|
|
1247
|
-
minLength:
|
|
1239
|
+
minLength: authConfig.passwordMinLength,
|
|
1248
1240
|
autoComplete: "new-password",
|
|
1249
1241
|
showStrengthIndicator: true,
|
|
1250
|
-
|
|
1242
|
+
authConfig,
|
|
1251
1243
|
appearance: {
|
|
1252
1244
|
containerClassName: appearance.form?.passwordField?.container,
|
|
1253
1245
|
labelClassName: appearance.form?.passwordField?.label,
|
|
@@ -1342,7 +1334,7 @@ function SignUp({
|
|
|
1342
1334
|
...uiProps
|
|
1343
1335
|
}) {
|
|
1344
1336
|
const { signUp, baseUrl } = useInsforge();
|
|
1345
|
-
const {
|
|
1337
|
+
const { authConfig } = usePublicAuthConfig();
|
|
1346
1338
|
const [email, setEmail] = react.useState("");
|
|
1347
1339
|
const [password, setPassword] = react.useState("");
|
|
1348
1340
|
const [error, setError] = react.useState("");
|
|
@@ -1356,7 +1348,7 @@ function SignUp({
|
|
|
1356
1348
|
e.preventDefault();
|
|
1357
1349
|
setLoading(true);
|
|
1358
1350
|
setError("");
|
|
1359
|
-
if (!
|
|
1351
|
+
if (!authConfig) {
|
|
1360
1352
|
setError("Configuration not loaded. Please refresh the page.");
|
|
1361
1353
|
setLoading(false);
|
|
1362
1354
|
return;
|
|
@@ -1369,11 +1361,11 @@ function SignUp({
|
|
|
1369
1361
|
return;
|
|
1370
1362
|
}
|
|
1371
1363
|
const passwordZodSchema = createPasswordSchema({
|
|
1372
|
-
minLength:
|
|
1373
|
-
requireUppercase:
|
|
1374
|
-
requireLowercase:
|
|
1375
|
-
requireNumber:
|
|
1376
|
-
requireSpecialChar:
|
|
1364
|
+
minLength: authConfig.passwordMinLength,
|
|
1365
|
+
requireUppercase: authConfig.requireUppercase,
|
|
1366
|
+
requireLowercase: authConfig.requireLowercase,
|
|
1367
|
+
requireNumber: authConfig.requireNumber,
|
|
1368
|
+
requireSpecialChar: authConfig.requireSpecialChar
|
|
1377
1369
|
});
|
|
1378
1370
|
const passwordValidation = passwordZodSchema.safeParse(password);
|
|
1379
1371
|
if (!passwordValidation.success) {
|
|
@@ -1435,7 +1427,7 @@ function SignUp({
|
|
|
1435
1427
|
setOauthLoading(null);
|
|
1436
1428
|
}
|
|
1437
1429
|
}
|
|
1438
|
-
if (!
|
|
1430
|
+
if (!authConfig) {
|
|
1439
1431
|
return null;
|
|
1440
1432
|
}
|
|
1441
1433
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1449,9 +1441,9 @@ function SignUp({
|
|
|
1449
1441
|
error,
|
|
1450
1442
|
loading,
|
|
1451
1443
|
oauthLoading,
|
|
1452
|
-
availableProviders:
|
|
1444
|
+
availableProviders: authConfig?.oAuthProviders || [],
|
|
1453
1445
|
onOAuthClick: handleOAuth,
|
|
1454
|
-
|
|
1446
|
+
authConfig,
|
|
1455
1447
|
showVerificationStep: step === "awaiting-verification",
|
|
1456
1448
|
onVerifyCode: handleVerifyCode,
|
|
1457
1449
|
...uiProps
|
|
@@ -1583,7 +1575,7 @@ function ResetPasswordForm({
|
|
|
1583
1575
|
error,
|
|
1584
1576
|
loading = false,
|
|
1585
1577
|
success = false,
|
|
1586
|
-
|
|
1578
|
+
authConfig,
|
|
1587
1579
|
appearance = {},
|
|
1588
1580
|
title = "Reset Password",
|
|
1589
1581
|
subtitle = "Enter your new password below.",
|
|
@@ -1660,7 +1652,7 @@ function ResetPasswordForm({
|
|
|
1660
1652
|
required: true,
|
|
1661
1653
|
autoComplete: "new-password",
|
|
1662
1654
|
showStrengthIndicator: true,
|
|
1663
|
-
|
|
1655
|
+
authConfig,
|
|
1664
1656
|
appearance: {
|
|
1665
1657
|
containerClassName: appearance.form?.newPasswordField?.container,
|
|
1666
1658
|
labelClassName: appearance.form?.newPasswordField?.label,
|
|
@@ -1678,7 +1670,7 @@ function ResetPasswordForm({
|
|
|
1678
1670
|
onChange: (e) => onConfirmPasswordChange(e.target.value),
|
|
1679
1671
|
required: true,
|
|
1680
1672
|
autoComplete: "new-password",
|
|
1681
|
-
|
|
1673
|
+
authConfig,
|
|
1682
1674
|
appearance: {
|
|
1683
1675
|
containerClassName: appearance.form?.confirmPasswordField?.container,
|
|
1684
1676
|
labelClassName: appearance.form?.confirmPasswordField?.label,
|
|
@@ -1722,7 +1714,7 @@ function ResetPassword({
|
|
|
1722
1714
|
...uiProps
|
|
1723
1715
|
}) {
|
|
1724
1716
|
const { resetPassword } = useInsforge();
|
|
1725
|
-
const {
|
|
1717
|
+
const { authConfig } = usePublicAuthConfig();
|
|
1726
1718
|
const [newPassword, setNewPassword] = react.useState("");
|
|
1727
1719
|
const [confirmPassword, setConfirmPassword] = react.useState("");
|
|
1728
1720
|
const [error, setError] = react.useState("");
|
|
@@ -1732,7 +1724,7 @@ function ResetPassword({
|
|
|
1732
1724
|
e.preventDefault();
|
|
1733
1725
|
setLoading(true);
|
|
1734
1726
|
setError("");
|
|
1735
|
-
if (!
|
|
1727
|
+
if (!authConfig) {
|
|
1736
1728
|
setError("Configuration not loaded. Please refresh the page.");
|
|
1737
1729
|
setLoading(false);
|
|
1738
1730
|
return;
|
|
@@ -1748,11 +1740,11 @@ function ResetPassword({
|
|
|
1748
1740
|
return;
|
|
1749
1741
|
}
|
|
1750
1742
|
const passwordZodSchema = createPasswordSchema({
|
|
1751
|
-
minLength:
|
|
1752
|
-
requireUppercase:
|
|
1753
|
-
requireLowercase:
|
|
1754
|
-
requireNumber:
|
|
1755
|
-
requireSpecialChar:
|
|
1743
|
+
minLength: authConfig.passwordMinLength,
|
|
1744
|
+
requireUppercase: authConfig.requireUppercase,
|
|
1745
|
+
requireLowercase: authConfig.requireLowercase,
|
|
1746
|
+
requireNumber: authConfig.requireNumber,
|
|
1747
|
+
requireSpecialChar: authConfig.requireSpecialChar
|
|
1756
1748
|
});
|
|
1757
1749
|
const passwordValidation = passwordZodSchema.safeParse(newPassword);
|
|
1758
1750
|
if (!passwordValidation.success) {
|
|
@@ -1785,7 +1777,7 @@ function ResetPassword({
|
|
|
1785
1777
|
setLoading(false);
|
|
1786
1778
|
}
|
|
1787
1779
|
}
|
|
1788
|
-
if (!
|
|
1780
|
+
if (!authConfig) {
|
|
1789
1781
|
return null;
|
|
1790
1782
|
}
|
|
1791
1783
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1799,7 +1791,7 @@ function ResetPassword({
|
|
|
1799
1791
|
error,
|
|
1800
1792
|
loading,
|
|
1801
1793
|
success,
|
|
1802
|
-
|
|
1794
|
+
authConfig,
|
|
1803
1795
|
backToSignInUrl,
|
|
1804
1796
|
...uiProps
|
|
1805
1797
|
}
|
|
@@ -1811,8 +1803,8 @@ function ForgotPassword({
|
|
|
1811
1803
|
onError,
|
|
1812
1804
|
...uiProps
|
|
1813
1805
|
}) {
|
|
1814
|
-
const {
|
|
1815
|
-
const {
|
|
1806
|
+
const { sendResetPasswordEmail, baseUrl } = useInsforge();
|
|
1807
|
+
const { authConfig } = usePublicAuthConfig();
|
|
1816
1808
|
const [insforge] = react.useState(() => sdk.createClient({ baseUrl }));
|
|
1817
1809
|
const [step, setStep] = react.useState("email");
|
|
1818
1810
|
const [email, setEmail] = react.useState("");
|
|
@@ -1851,9 +1843,9 @@ function ForgotPassword({
|
|
|
1851
1843
|
return;
|
|
1852
1844
|
}
|
|
1853
1845
|
try {
|
|
1854
|
-
const result = await
|
|
1846
|
+
const result = await sendResetPasswordEmail(emailValidation.data);
|
|
1855
1847
|
if (result?.success) {
|
|
1856
|
-
if (
|
|
1848
|
+
if (authConfig?.resetPasswordMethod === "link") {
|
|
1857
1849
|
setSuccess(true);
|
|
1858
1850
|
if (onSuccess) {
|
|
1859
1851
|
onSuccess();
|
|
@@ -1906,7 +1898,7 @@ function ForgotPassword({
|
|
|
1906
1898
|
setIsSendingCode(true);
|
|
1907
1899
|
setError("");
|
|
1908
1900
|
try {
|
|
1909
|
-
await
|
|
1901
|
+
await sendResetPasswordEmail(email);
|
|
1910
1902
|
} catch (err) {
|
|
1911
1903
|
setError(err.message || "Failed to resend code");
|
|
1912
1904
|
setResendDisabled(false);
|
|
@@ -1914,7 +1906,7 @@ function ForgotPassword({
|
|
|
1914
1906
|
} finally {
|
|
1915
1907
|
setIsSendingCode(false);
|
|
1916
1908
|
}
|
|
1917
|
-
}, [email,
|
|
1909
|
+
}, [email, sendResetPasswordEmail]);
|
|
1918
1910
|
function handlePasswordResetSuccess(redirectTo) {
|
|
1919
1911
|
const targetUrl = redirectTo || backToSignInUrl;
|
|
1920
1912
|
if (onSuccess) {
|
|
@@ -1924,7 +1916,7 @@ function ForgotPassword({
|
|
|
1924
1916
|
window.location.href = targetUrl;
|
|
1925
1917
|
}, 1500);
|
|
1926
1918
|
}
|
|
1927
|
-
if (!
|
|
1919
|
+
if (!authConfig) {
|
|
1928
1920
|
return null;
|
|
1929
1921
|
}
|
|
1930
1922
|
if (step === "email") {
|