@spidy092/auth-client 3.2.1 → 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 +25 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -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 +25 -2
- package/dist/react/AuthProvider.cjs.map +1 -1
- package/dist/react/AuthProvider.js +25 -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 +25 -2
- package/dist/react/useSessionMonitor.cjs.map +1 -1
- package/dist/react/useSessionMonitor.js +25 -2
- package/dist/react/useSessionMonitor.js.map +1 -1
- package/package.json +1 -1
|
@@ -247,7 +247,14 @@ var config = {
|
|
|
247
247
|
// Required for local dev with mkcert/self-signed certs where httpOnly cookies
|
|
248
248
|
// may not work reliably across origins
|
|
249
249
|
// ⚠️ In true production, set to false and rely on httpOnly cookies
|
|
250
|
-
persistRefreshToken: false
|
|
250
|
+
persistRefreshToken: false,
|
|
251
|
+
// ========== CROSS-TAB LOGOUT BROADCAST ==========
|
|
252
|
+
// Name of the BroadcastChannel the SDK posts a {type:'LOGOUT', reason}
|
|
253
|
+
// message on when logout() runs, so sibling tabs of the same app react
|
|
254
|
+
// immediately instead of waiting for a storage event or a validation poll.
|
|
255
|
+
// All company browser clients share one channel so the receiver wiring is
|
|
256
|
+
// identical everywhere. Apps may override per deployment.
|
|
257
|
+
logoutChannelName: "auth_platform_sso_channel"
|
|
251
258
|
};
|
|
252
259
|
var RUNTIME_POLICY_DEFAULTS = {
|
|
253
260
|
tokenRefreshBuffer: 60,
|
|
@@ -416,6 +423,19 @@ async function emitAuthDiagnostic(event, outcome, reasonCode, details = {}) {
|
|
|
416
423
|
|
|
417
424
|
// core.js
|
|
418
425
|
var callbackProcessed = false;
|
|
426
|
+
var LOGOUT_REQUEST_TIMEOUT_MS = 8e3;
|
|
427
|
+
function broadcastLogoutToTabs(clientKey, reason = "user_logout") {
|
|
428
|
+
try {
|
|
429
|
+
if (typeof BroadcastChannel === "undefined") return;
|
|
430
|
+
const { logoutChannelName } = getConfig();
|
|
431
|
+
if (!logoutChannelName) return;
|
|
432
|
+
const channel = new BroadcastChannel(logoutChannelName);
|
|
433
|
+
channel.postMessage({ type: "LOGOUT", reason, clientKey });
|
|
434
|
+
channel.close();
|
|
435
|
+
} catch (err) {
|
|
436
|
+
console.warn("\u26A0\uFE0F Cross-tab logout broadcast failed (non-fatal):", (err == null ? void 0 : err.message) || err);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
419
439
|
function login(clientKeyArg, redirectUriArg, options = {}) {
|
|
420
440
|
resetCallbackState();
|
|
421
441
|
const {
|
|
@@ -486,7 +506,9 @@ async function logout(options = {}) {
|
|
|
486
506
|
clearRefreshToken();
|
|
487
507
|
sessionStorage.removeItem("originalApp");
|
|
488
508
|
sessionStorage.removeItem("returnUrl");
|
|
509
|
+
broadcastLogoutToTabs(clientKey);
|
|
489
510
|
try {
|
|
511
|
+
const logoutSignal = typeof AbortSignal !== "undefined" && typeof AbortSignal.timeout === "function" ? AbortSignal.timeout(LOGOUT_REQUEST_TIMEOUT_MS) : void 0;
|
|
490
512
|
const response = await fetch(`${authBaseUrl}/logout/${clientKey}`, {
|
|
491
513
|
method: "POST",
|
|
492
514
|
credentials: "include",
|
|
@@ -495,7 +517,8 @@ async function logout(options = {}) {
|
|
|
495
517
|
"Authorization": token ? `Bearer ${token}` : "",
|
|
496
518
|
"Content-Type": "application/json"
|
|
497
519
|
},
|
|
498
|
-
body: JSON.stringify({ refreshToken: refreshToken2, idToken: idToken2, scope })
|
|
520
|
+
body: JSON.stringify({ refreshToken: refreshToken2, idToken: idToken2, scope }),
|
|
521
|
+
...logoutSignal ? { signal: logoutSignal } : {}
|
|
499
522
|
});
|
|
500
523
|
if (!response.ok) {
|
|
501
524
|
throw new Error(`Logout failed: ${response.status}`);
|