@insforge/react 0.2.4 → 0.2.5
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 +26 -3
- package/dist/components.js.map +1 -1
- package/dist/components.mjs +26 -3
- package/dist/components.mjs.map +1 -1
- package/dist/hooks.js.map +1 -1
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +91 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +91 -3
- package/dist/index.mjs.map +1 -1
- package/dist/router.js +26 -3
- package/dist/router.js.map +1 -1
- package/dist/router.mjs +26 -3
- package/dist/router.mjs.map +1 -1
- package/package.json +2 -2
package/dist/components.js
CHANGED
|
@@ -1409,7 +1409,7 @@ function InsforgeCallback({
|
|
|
1409
1409
|
onRedirect
|
|
1410
1410
|
}) {
|
|
1411
1411
|
const isProcessingRef = react.useRef(false);
|
|
1412
|
-
const {
|
|
1412
|
+
const { handleAuthCallback } = useInsforge();
|
|
1413
1413
|
react.useEffect(() => {
|
|
1414
1414
|
const processCallback = async () => {
|
|
1415
1415
|
if (isProcessingRef.current) return;
|
|
@@ -1429,7 +1429,30 @@ function InsforgeCallback({
|
|
|
1429
1429
|
}
|
|
1430
1430
|
return;
|
|
1431
1431
|
}
|
|
1432
|
-
const
|
|
1432
|
+
const accessToken = searchParams.get("access_token") || searchParams.get("auth_token");
|
|
1433
|
+
const userId = searchParams.get("user_id");
|
|
1434
|
+
const email = searchParams.get("email");
|
|
1435
|
+
const name = searchParams.get("name");
|
|
1436
|
+
if (!accessToken) {
|
|
1437
|
+
const errorMsg = "no_token";
|
|
1438
|
+
if (onError) {
|
|
1439
|
+
onError(errorMsg);
|
|
1440
|
+
} else {
|
|
1441
|
+
const errorUrl = "/?error=" + encodeURIComponent(errorMsg);
|
|
1442
|
+
if (onRedirect) {
|
|
1443
|
+
onRedirect(errorUrl);
|
|
1444
|
+
} else {
|
|
1445
|
+
window.location.href = errorUrl;
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
return;
|
|
1449
|
+
}
|
|
1450
|
+
const result = await handleAuthCallback({
|
|
1451
|
+
accessToken,
|
|
1452
|
+
userId: userId || void 0,
|
|
1453
|
+
email: email || void 0,
|
|
1454
|
+
name: name || void 0
|
|
1455
|
+
});
|
|
1433
1456
|
if (!result.success) {
|
|
1434
1457
|
const errorMsg = result.error || "authentication_failed";
|
|
1435
1458
|
if (onError) {
|
|
@@ -1458,7 +1481,7 @@ function InsforgeCallback({
|
|
|
1458
1481
|
}
|
|
1459
1482
|
};
|
|
1460
1483
|
processCallback();
|
|
1461
|
-
}, []);
|
|
1484
|
+
}, [handleAuthCallback, redirectTo, onSuccess, onError, onRedirect]);
|
|
1462
1485
|
const defaultLoading = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
|
|
1463
1486
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-2xl font-semibold mb-4", children: "Completing authentication..." }),
|
|
1464
1487
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto" })
|