@insforge/react 0.2.8 → 0.2.10
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.d.mts +12 -10
- package/dist/components.d.ts +12 -10
- package/dist/components.js +14 -34
- package/dist/components.js.map +1 -1
- package/dist/components.mjs +14 -34
- package/dist/components.mjs.map +1 -1
- package/dist/index.js +14 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -34
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.mts +2 -0
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1262,6 +1262,7 @@ function SignInForm({
|
|
|
1262
1262
|
);
|
|
1263
1263
|
}
|
|
1264
1264
|
function SignIn({
|
|
1265
|
+
afterSignInUrl,
|
|
1265
1266
|
onSuccess,
|
|
1266
1267
|
onError,
|
|
1267
1268
|
...uiProps
|
|
@@ -1301,10 +1302,9 @@ function SignIn({
|
|
|
1301
1302
|
try {
|
|
1302
1303
|
setOauthLoading(provider);
|
|
1303
1304
|
setError("");
|
|
1304
|
-
const redirectTo = `${window.location.origin}/auth/callback`;
|
|
1305
1305
|
await insforge.auth.signInWithOAuth({
|
|
1306
1306
|
provider,
|
|
1307
|
-
redirectTo
|
|
1307
|
+
redirectTo: afterSignInUrl
|
|
1308
1308
|
});
|
|
1309
1309
|
} catch (err) {
|
|
1310
1310
|
const errorMessage = err.message || `${provider} sign in failed`;
|
|
@@ -1483,6 +1483,7 @@ function SignUpForm({
|
|
|
1483
1483
|
);
|
|
1484
1484
|
}
|
|
1485
1485
|
function SignUp({
|
|
1486
|
+
afterSignUpUrl,
|
|
1486
1487
|
onSuccess,
|
|
1487
1488
|
onError,
|
|
1488
1489
|
...uiProps
|
|
@@ -1527,10 +1528,9 @@ function SignUp({
|
|
|
1527
1528
|
try {
|
|
1528
1529
|
setOauthLoading(provider);
|
|
1529
1530
|
setError("");
|
|
1530
|
-
const redirectTo = `${window.location.origin}/auth/callback`;
|
|
1531
1531
|
await insforge.auth.signInWithOAuth({
|
|
1532
1532
|
provider,
|
|
1533
|
-
redirectTo
|
|
1533
|
+
redirectTo: afterSignUpUrl
|
|
1534
1534
|
});
|
|
1535
1535
|
} catch (err) {
|
|
1536
1536
|
const errorMessage = err.message || `${provider} sign up failed`;
|
|
@@ -1737,18 +1737,19 @@ function SignedOut({ children }) {
|
|
|
1737
1737
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
1738
1738
|
}
|
|
1739
1739
|
function InsforgeCallback({
|
|
1740
|
-
redirectTo,
|
|
1740
|
+
redirectTo = "/",
|
|
1741
1741
|
onSuccess,
|
|
1742
1742
|
onError,
|
|
1743
1743
|
loadingComponent,
|
|
1744
1744
|
onRedirect
|
|
1745
1745
|
}) {
|
|
1746
1746
|
const isProcessingRef = react.useRef(false);
|
|
1747
|
-
const {
|
|
1747
|
+
const { isLoaded, isSignedIn } = useInsforge();
|
|
1748
1748
|
react.useEffect(() => {
|
|
1749
|
+
if (!isLoaded) return;
|
|
1750
|
+
if (isProcessingRef.current) return;
|
|
1751
|
+
isProcessingRef.current = true;
|
|
1749
1752
|
const processCallback = async () => {
|
|
1750
|
-
if (isProcessingRef.current) return;
|
|
1751
|
-
isProcessingRef.current = true;
|
|
1752
1753
|
const searchParams = new URLSearchParams(window.location.search);
|
|
1753
1754
|
const error = searchParams.get("error");
|
|
1754
1755
|
if (error) {
|
|
@@ -1764,26 +1765,8 @@ function InsforgeCallback({
|
|
|
1764
1765
|
}
|
|
1765
1766
|
return;
|
|
1766
1767
|
}
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
const errorMsg = "no_token";
|
|
1770
|
-
if (onError) {
|
|
1771
|
-
onError(errorMsg);
|
|
1772
|
-
} else {
|
|
1773
|
-
const errorUrl = "/?error=" + encodeURIComponent(errorMsg);
|
|
1774
|
-
if (onRedirect) {
|
|
1775
|
-
onRedirect(errorUrl);
|
|
1776
|
-
} else {
|
|
1777
|
-
window.location.href = errorUrl;
|
|
1778
|
-
}
|
|
1779
|
-
}
|
|
1780
|
-
return;
|
|
1781
|
-
}
|
|
1782
|
-
const result = await handleAuthCallback({
|
|
1783
|
-
accessToken
|
|
1784
|
-
});
|
|
1785
|
-
if (!result.success) {
|
|
1786
|
-
const errorMsg = result.error || "authentication_failed";
|
|
1768
|
+
if (!isSignedIn) {
|
|
1769
|
+
const errorMsg = "authentication_failed";
|
|
1787
1770
|
if (onError) {
|
|
1788
1771
|
onError(errorMsg);
|
|
1789
1772
|
} else {
|
|
@@ -1800,17 +1783,14 @@ function InsforgeCallback({
|
|
|
1800
1783
|
if (onSuccess) {
|
|
1801
1784
|
onSuccess();
|
|
1802
1785
|
}
|
|
1803
|
-
const destination = redirectTo || sessionStorage.getItem("auth_destination") || sessionStorage.getItem("oauth_final_destination") || "/";
|
|
1804
|
-
sessionStorage.removeItem("auth_destination");
|
|
1805
|
-
sessionStorage.removeItem("oauth_final_destination");
|
|
1806
1786
|
if (onRedirect) {
|
|
1807
|
-
onRedirect(
|
|
1787
|
+
onRedirect(redirectTo);
|
|
1808
1788
|
} else {
|
|
1809
|
-
window.location.href =
|
|
1789
|
+
window.location.href = redirectTo;
|
|
1810
1790
|
}
|
|
1811
1791
|
};
|
|
1812
1792
|
processCallback();
|
|
1813
|
-
}, [
|
|
1793
|
+
}, [isLoaded, isSignedIn, redirectTo, onSuccess, onError, onRedirect]);
|
|
1814
1794
|
const defaultLoading = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
|
|
1815
1795
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-2xl font-semibold mb-4", children: "Completing authentication..." }),
|
|
1816
1796
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto" })
|