@arbidocs/client 0.5.146 → 0.5.148
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.cjs +40 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1041 -88
- package/dist/index.d.ts +1041 -88
- package/dist/index.js +40 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2149,7 +2149,7 @@ function readBaseUrlPerRequest(fetchClient, base) {
|
|
|
2149
2149
|
}
|
|
2150
2150
|
var deploymentDomainOf = ({ deploymentDomain }) => typeof deploymentDomain === "function" ? deploymentDomain() : deploymentDomain;
|
|
2151
2151
|
function createArbiClient(options) {
|
|
2152
|
-
const { fetch, http, session, persistence, workspaceKeys, workspaceOpens, auth } = createTransport(options);
|
|
2152
|
+
const { fetch, http, session, persistence, workspaceKeys, workspaceOpens, auth, signedOut } = createTransport(options);
|
|
2153
2153
|
const authDeps = {
|
|
2154
2154
|
fetchClient: fetch,
|
|
2155
2155
|
session,
|
|
@@ -2166,9 +2166,11 @@ function createArbiClient(options) {
|
|
|
2166
2166
|
workspaceOpens,
|
|
2167
2167
|
session,
|
|
2168
2168
|
auth: {
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2169
|
+
// A sign-in straight after a sign-out (the login page shows at once) waits for it to end:
|
|
2170
|
+
// until then its gate is closed and the login request would fail.
|
|
2171
|
+
register: async (params) => (await signedOut(), register(params, authDeps)),
|
|
2172
|
+
login: async (params) => (await signedOut(), login(params, authDeps)),
|
|
2173
|
+
loginWithKey: async (params) => (await signedOut(), loginWithKey(params, authDeps)),
|
|
2172
2174
|
changePassword: (params) => changePassword(params, authDeps),
|
|
2173
2175
|
...auth
|
|
2174
2176
|
},
|
|
@@ -2215,6 +2217,7 @@ function createTransport(options) {
|
|
|
2215
2217
|
const guardedFetch = createSettingsWriteBreakerFetch(createDedupFetch(transport.fetch));
|
|
2216
2218
|
const retryFetch = createRetryFetch(guardedFetch);
|
|
2217
2219
|
const gate = createSessionGate();
|
|
2220
|
+
let signingOut = null;
|
|
2218
2221
|
const sessionFetch = gatedFetch(gate, retryFetch);
|
|
2219
2222
|
const http = {
|
|
2220
2223
|
fetch: gatedFetch(gate, guardedFetch),
|
|
@@ -2438,6 +2441,9 @@ function createTransport(options) {
|
|
|
2438
2441
|
persistence,
|
|
2439
2442
|
workspaceKeys,
|
|
2440
2443
|
workspaceOpens,
|
|
2444
|
+
signedOut: async () => {
|
|
2445
|
+
await signingOut;
|
|
2446
|
+
},
|
|
2441
2447
|
auth: {
|
|
2442
2448
|
relogin,
|
|
2443
2449
|
reopenWorkspace,
|
|
@@ -2451,32 +2457,40 @@ function createTransport(options) {
|
|
|
2451
2457
|
isSigningOut: () => gate.closed,
|
|
2452
2458
|
sessionSignal: () => gate.signal,
|
|
2453
2459
|
async logout({ everywhere = false } = {}) {
|
|
2454
|
-
|
|
2455
|
-
|
|
2460
|
+
const done = (async () => {
|
|
2461
|
+
gate.close();
|
|
2462
|
+
for (const listener of [...signingOutListeners]) {
|
|
2463
|
+
try {
|
|
2464
|
+
listener();
|
|
2465
|
+
} catch (error) {
|
|
2466
|
+
console.warn("[API] A sign-out listener failed:", error);
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
2469
|
+
gate.abort();
|
|
2456
2470
|
try {
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2471
|
+
const accessToken = session.getState().accessToken;
|
|
2472
|
+
if (accessToken) {
|
|
2473
|
+
const query = `?all_sessions=${everywhere}`;
|
|
2474
|
+
await retryFetch(`${base()}${API_PREFIX}/user/logout${query}`, {
|
|
2475
|
+
method: "POST",
|
|
2476
|
+
headers: { Authorization: `Bearer ${accessToken}` },
|
|
2477
|
+
credentials
|
|
2478
|
+
}).catch((error) => console.warn("[API] Server logout failed:", error));
|
|
2479
|
+
}
|
|
2480
|
+
session.clear();
|
|
2481
|
+
if (everywhere) {
|
|
2482
|
+
if (persistence.clearSession) await persistence.clearSession();
|
|
2483
|
+
else if (typeof indexedDB !== "undefined") await clearAllData();
|
|
2484
|
+
}
|
|
2485
|
+
} finally {
|
|
2486
|
+
gate.reopen();
|
|
2460
2487
|
}
|
|
2461
|
-
}
|
|
2462
|
-
|
|
2488
|
+
})();
|
|
2489
|
+
signingOut = done;
|
|
2463
2490
|
try {
|
|
2464
|
-
|
|
2465
|
-
if (accessToken) {
|
|
2466
|
-
const query = `?all_sessions=${everywhere}`;
|
|
2467
|
-
await retryFetch(`${base()}${API_PREFIX}/user/logout${query}`, {
|
|
2468
|
-
method: "POST",
|
|
2469
|
-
headers: { Authorization: `Bearer ${accessToken}` },
|
|
2470
|
-
credentials
|
|
2471
|
-
}).catch((error) => console.warn("[API] Server logout failed:", error));
|
|
2472
|
-
}
|
|
2473
|
-
session.clear();
|
|
2474
|
-
if (everywhere) {
|
|
2475
|
-
if (persistence.clearSession) await persistence.clearSession();
|
|
2476
|
-
else if (typeof indexedDB !== "undefined") await clearAllData();
|
|
2477
|
-
}
|
|
2491
|
+
await done;
|
|
2478
2492
|
} finally {
|
|
2479
|
-
|
|
2493
|
+
if (signingOut === done) signingOut = null;
|
|
2480
2494
|
}
|
|
2481
2495
|
},
|
|
2482
2496
|
async unlock({ email, password }) {
|