@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/components.mjs
CHANGED
|
@@ -909,6 +909,7 @@ function SignInForm({
|
|
|
909
909
|
);
|
|
910
910
|
}
|
|
911
911
|
function SignIn({
|
|
912
|
+
afterSignInUrl,
|
|
912
913
|
onSuccess,
|
|
913
914
|
onError,
|
|
914
915
|
...uiProps
|
|
@@ -948,10 +949,9 @@ function SignIn({
|
|
|
948
949
|
try {
|
|
949
950
|
setOauthLoading(provider);
|
|
950
951
|
setError("");
|
|
951
|
-
const redirectTo = `${window.location.origin}/auth/callback`;
|
|
952
952
|
await insforge.auth.signInWithOAuth({
|
|
953
953
|
provider,
|
|
954
|
-
redirectTo
|
|
954
|
+
redirectTo: afterSignInUrl
|
|
955
955
|
});
|
|
956
956
|
} catch (err) {
|
|
957
957
|
const errorMessage = err.message || `${provider} sign in failed`;
|
|
@@ -1130,6 +1130,7 @@ function SignUpForm({
|
|
|
1130
1130
|
);
|
|
1131
1131
|
}
|
|
1132
1132
|
function SignUp({
|
|
1133
|
+
afterSignUpUrl,
|
|
1133
1134
|
onSuccess,
|
|
1134
1135
|
onError,
|
|
1135
1136
|
...uiProps
|
|
@@ -1174,10 +1175,9 @@ function SignUp({
|
|
|
1174
1175
|
try {
|
|
1175
1176
|
setOauthLoading(provider);
|
|
1176
1177
|
setError("");
|
|
1177
|
-
const redirectTo = `${window.location.origin}/auth/callback`;
|
|
1178
1178
|
await insforge.auth.signInWithOAuth({
|
|
1179
1179
|
provider,
|
|
1180
|
-
redirectTo
|
|
1180
|
+
redirectTo: afterSignUpUrl
|
|
1181
1181
|
});
|
|
1182
1182
|
} catch (err) {
|
|
1183
1183
|
const errorMessage = err.message || `${provider} sign up failed`;
|
|
@@ -1384,18 +1384,19 @@ function SignedOut({ children }) {
|
|
|
1384
1384
|
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
1385
1385
|
}
|
|
1386
1386
|
function InsforgeCallback({
|
|
1387
|
-
redirectTo,
|
|
1387
|
+
redirectTo = "/",
|
|
1388
1388
|
onSuccess,
|
|
1389
1389
|
onError,
|
|
1390
1390
|
loadingComponent,
|
|
1391
1391
|
onRedirect
|
|
1392
1392
|
}) {
|
|
1393
1393
|
const isProcessingRef = useRef(false);
|
|
1394
|
-
const {
|
|
1394
|
+
const { isLoaded, isSignedIn } = useInsforge();
|
|
1395
1395
|
useEffect(() => {
|
|
1396
|
+
if (!isLoaded) return;
|
|
1397
|
+
if (isProcessingRef.current) return;
|
|
1398
|
+
isProcessingRef.current = true;
|
|
1396
1399
|
const processCallback = async () => {
|
|
1397
|
-
if (isProcessingRef.current) return;
|
|
1398
|
-
isProcessingRef.current = true;
|
|
1399
1400
|
const searchParams = new URLSearchParams(window.location.search);
|
|
1400
1401
|
const error = searchParams.get("error");
|
|
1401
1402
|
if (error) {
|
|
@@ -1411,26 +1412,8 @@ function InsforgeCallback({
|
|
|
1411
1412
|
}
|
|
1412
1413
|
return;
|
|
1413
1414
|
}
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
const errorMsg = "no_token";
|
|
1417
|
-
if (onError) {
|
|
1418
|
-
onError(errorMsg);
|
|
1419
|
-
} else {
|
|
1420
|
-
const errorUrl = "/?error=" + encodeURIComponent(errorMsg);
|
|
1421
|
-
if (onRedirect) {
|
|
1422
|
-
onRedirect(errorUrl);
|
|
1423
|
-
} else {
|
|
1424
|
-
window.location.href = errorUrl;
|
|
1425
|
-
}
|
|
1426
|
-
}
|
|
1427
|
-
return;
|
|
1428
|
-
}
|
|
1429
|
-
const result = await handleAuthCallback({
|
|
1430
|
-
accessToken
|
|
1431
|
-
});
|
|
1432
|
-
if (!result.success) {
|
|
1433
|
-
const errorMsg = result.error || "authentication_failed";
|
|
1415
|
+
if (!isSignedIn) {
|
|
1416
|
+
const errorMsg = "authentication_failed";
|
|
1434
1417
|
if (onError) {
|
|
1435
1418
|
onError(errorMsg);
|
|
1436
1419
|
} else {
|
|
@@ -1447,17 +1430,14 @@ function InsforgeCallback({
|
|
|
1447
1430
|
if (onSuccess) {
|
|
1448
1431
|
onSuccess();
|
|
1449
1432
|
}
|
|
1450
|
-
const destination = redirectTo || sessionStorage.getItem("auth_destination") || sessionStorage.getItem("oauth_final_destination") || "/";
|
|
1451
|
-
sessionStorage.removeItem("auth_destination");
|
|
1452
|
-
sessionStorage.removeItem("oauth_final_destination");
|
|
1453
1433
|
if (onRedirect) {
|
|
1454
|
-
onRedirect(
|
|
1434
|
+
onRedirect(redirectTo);
|
|
1455
1435
|
} else {
|
|
1456
|
-
window.location.href =
|
|
1436
|
+
window.location.href = redirectTo;
|
|
1457
1437
|
}
|
|
1458
1438
|
};
|
|
1459
1439
|
processCallback();
|
|
1460
|
-
}, [
|
|
1440
|
+
}, [isLoaded, isSignedIn, redirectTo, onSuccess, onError, onRedirect]);
|
|
1461
1441
|
const defaultLoading = /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
|
|
1462
1442
|
/* @__PURE__ */ jsx("h2", { className: "text-2xl font-semibold mb-4", children: "Completing authentication..." }),
|
|
1463
1443
|
/* @__PURE__ */ jsx("div", { className: "animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto" })
|