@insforge/react 0.2.3 → 0.2.4
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/components.js +20 -35
- package/dist/components.js.map +1 -1
- package/dist/components.mjs +20 -35
- package/dist/components.mjs.map +1 -1
- package/dist/hooks.d.mts +5 -3
- package/dist/hooks.d.ts +5 -3
- package/dist/hooks.js +10 -29
- package/dist/hooks.js.map +1 -1
- package/dist/hooks.mjs +10 -29
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +43 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -37
- package/dist/index.mjs.map +1 -1
- package/dist/router.js.map +1 -1
- package/dist/router.mjs.map +1 -1
- package/dist/types.d.mts +2 -2
- package/dist/types.d.ts +2 -2
- package/package.json +3 -3
package/dist/components.js
CHANGED
|
@@ -18,42 +18,23 @@ function useInsforge() {
|
|
|
18
18
|
return context;
|
|
19
19
|
}
|
|
20
20
|
function usePublicAuthConfig() {
|
|
21
|
-
const {
|
|
22
|
-
const [oauthProviders, setOAuthProviders] = react.useState([]);
|
|
21
|
+
const { getPublicAuthConfig } = useInsforge();
|
|
23
22
|
const [emailConfig, setEmailConfig] = react.useState(null);
|
|
24
23
|
const [isLoaded, setIsLoaded] = react.useState(false);
|
|
25
24
|
react.useEffect(() => {
|
|
26
|
-
let mounted = true;
|
|
27
25
|
async function fetchConfig() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
setEmailConfig(null);
|
|
35
|
-
} else {
|
|
36
|
-
const data = await response.json();
|
|
37
|
-
const providerNames = data.providers?.map((p) => p.provider) || [];
|
|
38
|
-
setOAuthProviders(providerNames);
|
|
39
|
-
setEmailConfig(data.email || null);
|
|
40
|
-
}
|
|
41
|
-
setIsLoaded(true);
|
|
42
|
-
} catch (error) {
|
|
43
|
-
console.warn("[usePublicAuthConfig] Unexpected error:", error);
|
|
44
|
-
if (mounted) {
|
|
45
|
-
setOAuthProviders([]);
|
|
46
|
-
setEmailConfig(null);
|
|
47
|
-
setIsLoaded(true);
|
|
48
|
-
}
|
|
26
|
+
const result = await getPublicAuthConfig();
|
|
27
|
+
if (result) {
|
|
28
|
+
setEmailConfig(result);
|
|
29
|
+
} else {
|
|
30
|
+
console.error("[usePublicAuthConfig] Failed to get public auth config");
|
|
31
|
+
setEmailConfig(null);
|
|
49
32
|
}
|
|
33
|
+
setIsLoaded(true);
|
|
50
34
|
}
|
|
51
35
|
fetchConfig();
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
};
|
|
55
|
-
}, [baseUrl]);
|
|
56
|
-
return { oauthProviders, emailConfig, isLoaded };
|
|
36
|
+
}, [getPublicAuthConfig]);
|
|
37
|
+
return { emailConfig, isLoaded };
|
|
57
38
|
}
|
|
58
39
|
function AuthBranding() {
|
|
59
40
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-[#FAFAFA] px-2 py-4 flex flex-row justify-center items-center gap-1", children: [
|
|
@@ -937,7 +918,7 @@ function SignIn({
|
|
|
937
918
|
...uiProps
|
|
938
919
|
}) {
|
|
939
920
|
const { signIn, baseUrl } = useInsforge();
|
|
940
|
-
const {
|
|
921
|
+
const { emailConfig } = usePublicAuthConfig();
|
|
941
922
|
const [email, setEmail] = react.useState("");
|
|
942
923
|
const [password, setPassword] = react.useState("");
|
|
943
924
|
const [error, setError] = react.useState("");
|
|
@@ -989,7 +970,9 @@ function SignIn({
|
|
|
989
970
|
setOauthLoading(null);
|
|
990
971
|
}
|
|
991
972
|
}
|
|
992
|
-
if (!emailConfig)
|
|
973
|
+
if (!emailConfig) {
|
|
974
|
+
return null;
|
|
975
|
+
}
|
|
993
976
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
994
977
|
SignInForm,
|
|
995
978
|
{
|
|
@@ -1001,7 +984,7 @@ function SignIn({
|
|
|
1001
984
|
error,
|
|
1002
985
|
loading,
|
|
1003
986
|
oauthLoading,
|
|
1004
|
-
availableProviders:
|
|
987
|
+
availableProviders: emailConfig?.oAuthProviders || [],
|
|
1005
988
|
onOAuthClick: handleOAuth,
|
|
1006
989
|
emailAuthConfig: emailConfig,
|
|
1007
990
|
...uiProps
|
|
@@ -1164,7 +1147,7 @@ function SignUp({
|
|
|
1164
1147
|
...uiProps
|
|
1165
1148
|
}) {
|
|
1166
1149
|
const { signUp, baseUrl } = useInsforge();
|
|
1167
|
-
const {
|
|
1150
|
+
const { emailConfig } = usePublicAuthConfig();
|
|
1168
1151
|
const [email, setEmail] = react.useState("");
|
|
1169
1152
|
const [password, setPassword] = react.useState("");
|
|
1170
1153
|
const [error, setError] = react.useState("");
|
|
@@ -1221,7 +1204,9 @@ function SignUp({
|
|
|
1221
1204
|
setOauthLoading(null);
|
|
1222
1205
|
}
|
|
1223
1206
|
}
|
|
1224
|
-
if (!emailConfig)
|
|
1207
|
+
if (!emailConfig) {
|
|
1208
|
+
return null;
|
|
1209
|
+
}
|
|
1225
1210
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1226
1211
|
SignUpForm,
|
|
1227
1212
|
{
|
|
@@ -1233,7 +1218,7 @@ function SignUp({
|
|
|
1233
1218
|
error,
|
|
1234
1219
|
loading,
|
|
1235
1220
|
oauthLoading,
|
|
1236
|
-
availableProviders:
|
|
1221
|
+
availableProviders: emailConfig?.oAuthProviders || [],
|
|
1237
1222
|
onOAuthClick: handleOAuth,
|
|
1238
1223
|
emailAuthConfig: emailConfig,
|
|
1239
1224
|
...uiProps
|