@insforge/react 0.2.2 → 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/atoms.js +17 -1
- package/dist/atoms.js.map +1 -1
- package/dist/atoms.mjs +17 -1
- package/dist/atoms.mjs.map +1 -1
- package/dist/components.js +37 -36
- package/dist/components.js.map +1 -1
- package/dist/components.mjs +37 -36
- package/dist/components.mjs.map +1 -1
- package/dist/forms.js +17 -1
- package/dist/forms.js.map +1 -1
- package/dist/forms.mjs +17 -1
- package/dist/forms.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 +60 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -38
- 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.mjs
CHANGED
|
@@ -16,42 +16,23 @@ function useInsforge() {
|
|
|
16
16
|
return context;
|
|
17
17
|
}
|
|
18
18
|
function usePublicAuthConfig() {
|
|
19
|
-
const {
|
|
20
|
-
const [oauthProviders, setOAuthProviders] = useState([]);
|
|
19
|
+
const { getPublicAuthConfig } = useInsforge();
|
|
21
20
|
const [emailConfig, setEmailConfig] = useState(null);
|
|
22
21
|
const [isLoaded, setIsLoaded] = useState(false);
|
|
23
22
|
useEffect(() => {
|
|
24
|
-
let mounted = true;
|
|
25
23
|
async function fetchConfig() {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
setEmailConfig(null);
|
|
33
|
-
} else {
|
|
34
|
-
const data = await response.json();
|
|
35
|
-
const providerNames = data.providers?.map((p) => p.provider) || [];
|
|
36
|
-
setOAuthProviders(providerNames);
|
|
37
|
-
setEmailConfig(data.email || null);
|
|
38
|
-
}
|
|
39
|
-
setIsLoaded(true);
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.warn("[usePublicAuthConfig] Unexpected error:", error);
|
|
42
|
-
if (mounted) {
|
|
43
|
-
setOAuthProviders([]);
|
|
44
|
-
setEmailConfig(null);
|
|
45
|
-
setIsLoaded(true);
|
|
46
|
-
}
|
|
24
|
+
const result = await getPublicAuthConfig();
|
|
25
|
+
if (result) {
|
|
26
|
+
setEmailConfig(result);
|
|
27
|
+
} else {
|
|
28
|
+
console.error("[usePublicAuthConfig] Failed to get public auth config");
|
|
29
|
+
setEmailConfig(null);
|
|
47
30
|
}
|
|
31
|
+
setIsLoaded(true);
|
|
48
32
|
}
|
|
49
33
|
fetchConfig();
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
53
|
-
}, [baseUrl]);
|
|
54
|
-
return { oauthProviders, emailConfig, isLoaded };
|
|
34
|
+
}, [getPublicAuthConfig]);
|
|
35
|
+
return { emailConfig, isLoaded };
|
|
55
36
|
}
|
|
56
37
|
function AuthBranding() {
|
|
57
38
|
return /* @__PURE__ */ jsxs("div", { className: "bg-[#FAFAFA] px-2 py-4 flex flex-row justify-center items-center gap-1", children: [
|
|
@@ -403,6 +384,22 @@ function AuthSubmitButton({
|
|
|
403
384
|
);
|
|
404
385
|
}
|
|
405
386
|
function AuthLink({ text, linkText, href, appearance = {} }) {
|
|
387
|
+
const currentSearch = typeof window !== "undefined" ? window.location.search : "";
|
|
388
|
+
const finalHref = (() => {
|
|
389
|
+
if (!currentSearch) return href;
|
|
390
|
+
try {
|
|
391
|
+
const url = new URL(href, window.location.origin);
|
|
392
|
+
const currentParams = new URLSearchParams(currentSearch);
|
|
393
|
+
currentParams.forEach((value, key) => {
|
|
394
|
+
if (!url.searchParams.has(key)) {
|
|
395
|
+
url.searchParams.set(key, value);
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
return url.pathname + url.search;
|
|
399
|
+
} catch {
|
|
400
|
+
return href;
|
|
401
|
+
}
|
|
402
|
+
})();
|
|
406
403
|
return /* @__PURE__ */ jsxs("p", { className: cn(
|
|
407
404
|
"text-center text-sm font-normal text-[#828282] leading-6",
|
|
408
405
|
appearance.containerClassName
|
|
@@ -412,7 +409,7 @@ function AuthLink({ text, linkText, href, appearance = {} }) {
|
|
|
412
409
|
/* @__PURE__ */ jsx(
|
|
413
410
|
"a",
|
|
414
411
|
{
|
|
415
|
-
href,
|
|
412
|
+
href: finalHref,
|
|
416
413
|
className: cn(
|
|
417
414
|
"text-sm font-medium text-black leading-6",
|
|
418
415
|
appearance.linkClassName
|
|
@@ -919,7 +916,7 @@ function SignIn({
|
|
|
919
916
|
...uiProps
|
|
920
917
|
}) {
|
|
921
918
|
const { signIn, baseUrl } = useInsforge();
|
|
922
|
-
const {
|
|
919
|
+
const { emailConfig } = usePublicAuthConfig();
|
|
923
920
|
const [email, setEmail] = useState("");
|
|
924
921
|
const [password, setPassword] = useState("");
|
|
925
922
|
const [error, setError] = useState("");
|
|
@@ -971,7 +968,9 @@ function SignIn({
|
|
|
971
968
|
setOauthLoading(null);
|
|
972
969
|
}
|
|
973
970
|
}
|
|
974
|
-
if (!emailConfig)
|
|
971
|
+
if (!emailConfig) {
|
|
972
|
+
return null;
|
|
973
|
+
}
|
|
975
974
|
return /* @__PURE__ */ jsx(
|
|
976
975
|
SignInForm,
|
|
977
976
|
{
|
|
@@ -983,7 +982,7 @@ function SignIn({
|
|
|
983
982
|
error,
|
|
984
983
|
loading,
|
|
985
984
|
oauthLoading,
|
|
986
|
-
availableProviders:
|
|
985
|
+
availableProviders: emailConfig?.oAuthProviders || [],
|
|
987
986
|
onOAuthClick: handleOAuth,
|
|
988
987
|
emailAuthConfig: emailConfig,
|
|
989
988
|
...uiProps
|
|
@@ -1146,7 +1145,7 @@ function SignUp({
|
|
|
1146
1145
|
...uiProps
|
|
1147
1146
|
}) {
|
|
1148
1147
|
const { signUp, baseUrl } = useInsforge();
|
|
1149
|
-
const {
|
|
1148
|
+
const { emailConfig } = usePublicAuthConfig();
|
|
1150
1149
|
const [email, setEmail] = useState("");
|
|
1151
1150
|
const [password, setPassword] = useState("");
|
|
1152
1151
|
const [error, setError] = useState("");
|
|
@@ -1203,7 +1202,9 @@ function SignUp({
|
|
|
1203
1202
|
setOauthLoading(null);
|
|
1204
1203
|
}
|
|
1205
1204
|
}
|
|
1206
|
-
if (!emailConfig)
|
|
1205
|
+
if (!emailConfig) {
|
|
1206
|
+
return null;
|
|
1207
|
+
}
|
|
1207
1208
|
return /* @__PURE__ */ jsx(
|
|
1208
1209
|
SignUpForm,
|
|
1209
1210
|
{
|
|
@@ -1215,7 +1216,7 @@ function SignUp({
|
|
|
1215
1216
|
error,
|
|
1216
1217
|
loading,
|
|
1217
1218
|
oauthLoading,
|
|
1218
|
-
availableProviders:
|
|
1219
|
+
availableProviders: emailConfig?.oAuthProviders || [],
|
|
1219
1220
|
onOAuthClick: handleOAuth,
|
|
1220
1221
|
emailAuthConfig: emailConfig,
|
|
1221
1222
|
...uiProps
|