@spidy092/auth-client 3.2.0 → 3.2.2
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/api.cjs +8 -1
- package/dist/api.cjs.map +1 -1
- package/dist/api.js +8 -1
- package/dist/api.js.map +1 -1
- package/dist/index.cjs +32 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -2
- package/dist/index.js.map +1 -1
- package/dist/preferences.cjs +8 -1
- package/dist/preferences.cjs.map +1 -1
- package/dist/preferences.js +8 -1
- package/dist/preferences.js.map +1 -1
- package/dist/react/AuthProvider.cjs +32 -2
- package/dist/react/AuthProvider.cjs.map +1 -1
- package/dist/react/AuthProvider.js +32 -2
- package/dist/react/AuthProvider.js.map +1 -1
- package/dist/react/PreferencesProvider.cjs +8 -1
- package/dist/react/PreferencesProvider.cjs.map +1 -1
- package/dist/react/PreferencesProvider.js +8 -1
- package/dist/react/PreferencesProvider.js.map +1 -1
- package/dist/react/useAuth.cjs +8 -1
- package/dist/react/useAuth.cjs.map +1 -1
- package/dist/react/useAuth.js +8 -1
- package/dist/react/useAuth.js.map +1 -1
- package/dist/react/useSessionMonitor.cjs +32 -2
- package/dist/react/useSessionMonitor.cjs.map +1 -1
- package/dist/react/useSessionMonitor.js +32 -2
- package/dist/react/useSessionMonitor.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -243,7 +243,14 @@ var config = {
|
|
|
243
243
|
// Required for local dev with mkcert/self-signed certs where httpOnly cookies
|
|
244
244
|
// may not work reliably across origins
|
|
245
245
|
// ⚠️ In true production, set to false and rely on httpOnly cookies
|
|
246
|
-
persistRefreshToken: false
|
|
246
|
+
persistRefreshToken: false,
|
|
247
|
+
// ========== CROSS-TAB LOGOUT BROADCAST ==========
|
|
248
|
+
// Name of the BroadcastChannel the SDK posts a {type:'LOGOUT', reason}
|
|
249
|
+
// message on when logout() runs, so sibling tabs of the same app react
|
|
250
|
+
// immediately instead of waiting for a storage event or a validation poll.
|
|
251
|
+
// All company browser clients share one channel so the receiver wiring is
|
|
252
|
+
// identical everywhere. Apps may override per deployment.
|
|
253
|
+
logoutChannelName: "auth_platform_sso_channel"
|
|
247
254
|
};
|
|
248
255
|
var RUNTIME_POLICY_DEFAULTS = {
|
|
249
256
|
tokenRefreshBuffer: 60,
|
|
@@ -412,6 +419,19 @@ async function emitAuthDiagnostic(event, outcome, reasonCode, details = {}) {
|
|
|
412
419
|
|
|
413
420
|
// core.js
|
|
414
421
|
var callbackProcessed = false;
|
|
422
|
+
var LOGOUT_REQUEST_TIMEOUT_MS = 8e3;
|
|
423
|
+
function broadcastLogoutToTabs(clientKey, reason = "user_logout") {
|
|
424
|
+
try {
|
|
425
|
+
if (typeof BroadcastChannel === "undefined") return;
|
|
426
|
+
const { logoutChannelName } = getConfig();
|
|
427
|
+
if (!logoutChannelName) return;
|
|
428
|
+
const channel = new BroadcastChannel(logoutChannelName);
|
|
429
|
+
channel.postMessage({ type: "LOGOUT", reason, clientKey });
|
|
430
|
+
channel.close();
|
|
431
|
+
} catch (err) {
|
|
432
|
+
console.warn("\u26A0\uFE0F Cross-tab logout broadcast failed (non-fatal):", (err == null ? void 0 : err.message) || err);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
415
435
|
function login(clientKeyArg, redirectUriArg, options = {}) {
|
|
416
436
|
resetCallbackState();
|
|
417
437
|
const {
|
|
@@ -482,7 +502,9 @@ async function logout(options = {}) {
|
|
|
482
502
|
clearRefreshToken();
|
|
483
503
|
sessionStorage.removeItem("originalApp");
|
|
484
504
|
sessionStorage.removeItem("returnUrl");
|
|
505
|
+
broadcastLogoutToTabs(clientKey);
|
|
485
506
|
try {
|
|
507
|
+
const logoutSignal = typeof AbortSignal !== "undefined" && typeof AbortSignal.timeout === "function" ? AbortSignal.timeout(LOGOUT_REQUEST_TIMEOUT_MS) : void 0;
|
|
486
508
|
const response = await fetch(`${authBaseUrl}/logout/${clientKey}`, {
|
|
487
509
|
method: "POST",
|
|
488
510
|
credentials: "include",
|
|
@@ -491,7 +513,8 @@ async function logout(options = {}) {
|
|
|
491
513
|
"Authorization": token ? `Bearer ${token}` : "",
|
|
492
514
|
"Content-Type": "application/json"
|
|
493
515
|
},
|
|
494
|
-
body: JSON.stringify({ refreshToken: refreshToken2, idToken: idToken2, scope })
|
|
516
|
+
body: JSON.stringify({ refreshToken: refreshToken2, idToken: idToken2, scope }),
|
|
517
|
+
...logoutSignal ? { signal: logoutSignal } : {}
|
|
495
518
|
});
|
|
496
519
|
if (!response.ok) {
|
|
497
520
|
throw new Error(`Logout failed: ${response.status}`);
|
|
@@ -516,6 +539,13 @@ async function logout(options = {}) {
|
|
|
516
539
|
clientKey
|
|
517
540
|
});
|
|
518
541
|
}
|
|
542
|
+
if (scope === "sso" && authBaseUrl && clientKey) {
|
|
543
|
+
const frontChannelLogoutUrl = new URL(
|
|
544
|
+
`${authBaseUrl.replace(/\/+$/, "")}/logout/${encodeURIComponent(clientKey)}`
|
|
545
|
+
);
|
|
546
|
+
window.location.replace(frontChannelLogoutUrl.toString());
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
519
549
|
const fallbackUrl = isRouterMode() ? new URL("/login", window.location.origin) : new URL("/login", accountUiUrl);
|
|
520
550
|
fallbackUrl.searchParams.set("logged_out", "true");
|
|
521
551
|
fallbackUrl.searchParams.set("client", clientKey);
|