@howone/sdk 0.5.2 → 0.5.3
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/index.js +21 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1332,6 +1332,7 @@ var ElementSelectorProvider = ({ children }) => {
|
|
|
1332
1332
|
init_config();
|
|
1333
1333
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1334
1334
|
var HowoneContext = (0, import_react8.createContext)(null);
|
|
1335
|
+
var consumedTokenCache = /* @__PURE__ */ new Set();
|
|
1335
1336
|
var redirectOverlayStylesInjected = false;
|
|
1336
1337
|
var injectRedirectOverlayStyles = () => {
|
|
1337
1338
|
if (redirectOverlayStylesInjected || typeof document === "undefined") return;
|
|
@@ -1400,16 +1401,30 @@ var HowOneProvider = ({
|
|
|
1400
1401
|
return setEnvironment(env3).AUTH_COOKIE_ROOT_VALUE;
|
|
1401
1402
|
}, []);
|
|
1402
1403
|
const consumeTokenToCookie = (0, import_react8.useCallback)(async (value2) => {
|
|
1404
|
+
if (!value2) return;
|
|
1405
|
+
if (consumedTokenCache.has(value2)) return;
|
|
1406
|
+
consumedTokenCache.add(value2);
|
|
1403
1407
|
try {
|
|
1404
|
-
await fetch(`${authCookieRoot}/consume`, {
|
|
1408
|
+
const response = await fetch(`${authCookieRoot}/consume`, {
|
|
1405
1409
|
method: "POST",
|
|
1406
1410
|
credentials: "include",
|
|
1407
1411
|
headers: {
|
|
1408
1412
|
Authorization: `Bearer ${value2}`
|
|
1409
1413
|
}
|
|
1410
1414
|
});
|
|
1415
|
+
if (!response.ok) {
|
|
1416
|
+
console.info("[HowOneProvider] consume token request failed:", response.status, response.statusText);
|
|
1417
|
+
}
|
|
1411
1418
|
} catch (error) {
|
|
1412
|
-
|
|
1419
|
+
try {
|
|
1420
|
+
const inIframe = typeof window !== "undefined" && window.top !== window.self;
|
|
1421
|
+
if (inIframe) {
|
|
1422
|
+
console.info("[HowOneProvider] consume token skipped in iframe context (likely third-party cookie/CORS policy).");
|
|
1423
|
+
return;
|
|
1424
|
+
}
|
|
1425
|
+
} catch {
|
|
1426
|
+
}
|
|
1427
|
+
console.warn("[HowOneProvider] Failed to consume token:", error);
|
|
1413
1428
|
}
|
|
1414
1429
|
}, [authCookieRoot]);
|
|
1415
1430
|
const logoutFromCookie = (0, import_react8.useCallback)(async () => {
|
|
@@ -1419,7 +1434,7 @@ var HowOneProvider = ({
|
|
|
1419
1434
|
credentials: "include"
|
|
1420
1435
|
});
|
|
1421
1436
|
} catch (error) {
|
|
1422
|
-
console.
|
|
1437
|
+
console.warn("[HowOneProvider] Failed to logout from cookie:", error);
|
|
1423
1438
|
}
|
|
1424
1439
|
}, [authCookieRoot]);
|
|
1425
1440
|
const readAccessTokenCookie = (0, import_react8.useCallback)(() => {
|
|
@@ -1467,7 +1482,7 @@ var HowOneProvider = ({
|
|
|
1467
1482
|
}
|
|
1468
1483
|
}
|
|
1469
1484
|
} catch (e) {
|
|
1470
|
-
console.
|
|
1485
|
+
console.warn("[HowOneProvider] Failed to capture token from URL:", e);
|
|
1471
1486
|
} finally {
|
|
1472
1487
|
setHasCheckedUrlToken(true);
|
|
1473
1488
|
}
|
|
@@ -1489,11 +1504,6 @@ var HowOneProvider = ({
|
|
|
1489
1504
|
injectRedirectOverlayStyles();
|
|
1490
1505
|
}
|
|
1491
1506
|
}, [pendingRedirect]);
|
|
1492
|
-
(0, import_react8.useEffect)(() => {
|
|
1493
|
-
if (pendingRedirect) {
|
|
1494
|
-
injectRedirectOverlayStyles();
|
|
1495
|
-
}
|
|
1496
|
-
}, [pendingRedirect]);
|
|
1497
1507
|
const redirectToAuth = (0, import_react8.useCallback)(() => {
|
|
1498
1508
|
if (!redirectOnUnauthenticated || typeof window === "undefined") return;
|
|
1499
1509
|
const activeProjectId = projectId ?? getDefaultProjectId();
|
|
@@ -1508,7 +1518,7 @@ var HowOneProvider = ({
|
|
|
1508
1518
|
window.location.href = url.toString();
|
|
1509
1519
|
return;
|
|
1510
1520
|
} catch (error) {
|
|
1511
|
-
console.
|
|
1521
|
+
console.warn("[HowOneProvider] Failed to attach project_id to auth URL:", error);
|
|
1512
1522
|
}
|
|
1513
1523
|
}
|
|
1514
1524
|
window.location.href = resolvedAuthUrl;
|
|
@@ -1529,7 +1539,7 @@ var HowOneProvider = ({
|
|
|
1529
1539
|
});
|
|
1530
1540
|
return;
|
|
1531
1541
|
} catch (error) {
|
|
1532
|
-
console.
|
|
1542
|
+
console.warn("[HowOneProvider] Failed to build auth URL:", error);
|
|
1533
1543
|
}
|
|
1534
1544
|
navigateToResolvedAuth();
|
|
1535
1545
|
} catch {
|