@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.js
CHANGED
|
@@ -2142,7 +2142,7 @@ function readBaseUrlPerRequest(fetchClient, base) {
|
|
|
2142
2142
|
}
|
|
2143
2143
|
var deploymentDomainOf = ({ deploymentDomain }) => typeof deploymentDomain === "function" ? deploymentDomain() : deploymentDomain;
|
|
2144
2144
|
function createArbiClient(options) {
|
|
2145
|
-
const { fetch, http, session, persistence, workspaceKeys, workspaceOpens, auth } = createTransport(options);
|
|
2145
|
+
const { fetch, http, session, persistence, workspaceKeys, workspaceOpens, auth, signedOut } = createTransport(options);
|
|
2146
2146
|
const authDeps = {
|
|
2147
2147
|
fetchClient: fetch,
|
|
2148
2148
|
session,
|
|
@@ -2159,9 +2159,11 @@ function createArbiClient(options) {
|
|
|
2159
2159
|
workspaceOpens,
|
|
2160
2160
|
session,
|
|
2161
2161
|
auth: {
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2162
|
+
// A sign-in straight after a sign-out (the login page shows at once) waits for it to end:
|
|
2163
|
+
// until then its gate is closed and the login request would fail.
|
|
2164
|
+
register: async (params) => (await signedOut(), register(params, authDeps)),
|
|
2165
|
+
login: async (params) => (await signedOut(), login(params, authDeps)),
|
|
2166
|
+
loginWithKey: async (params) => (await signedOut(), loginWithKey(params, authDeps)),
|
|
2165
2167
|
changePassword: (params) => changePassword(params, authDeps),
|
|
2166
2168
|
...auth
|
|
2167
2169
|
},
|
|
@@ -2208,6 +2210,7 @@ function createTransport(options) {
|
|
|
2208
2210
|
const guardedFetch = createSettingsWriteBreakerFetch(createDedupFetch(transport.fetch));
|
|
2209
2211
|
const retryFetch = createRetryFetch(guardedFetch);
|
|
2210
2212
|
const gate = createSessionGate();
|
|
2213
|
+
let signingOut = null;
|
|
2211
2214
|
const sessionFetch = gatedFetch(gate, retryFetch);
|
|
2212
2215
|
const http = {
|
|
2213
2216
|
fetch: gatedFetch(gate, guardedFetch),
|
|
@@ -2431,6 +2434,9 @@ function createTransport(options) {
|
|
|
2431
2434
|
persistence,
|
|
2432
2435
|
workspaceKeys,
|
|
2433
2436
|
workspaceOpens,
|
|
2437
|
+
signedOut: async () => {
|
|
2438
|
+
await signingOut;
|
|
2439
|
+
},
|
|
2434
2440
|
auth: {
|
|
2435
2441
|
relogin,
|
|
2436
2442
|
reopenWorkspace,
|
|
@@ -2444,32 +2450,40 @@ function createTransport(options) {
|
|
|
2444
2450
|
isSigningOut: () => gate.closed,
|
|
2445
2451
|
sessionSignal: () => gate.signal,
|
|
2446
2452
|
async logout({ everywhere = false } = {}) {
|
|
2447
|
-
|
|
2448
|
-
|
|
2453
|
+
const done = (async () => {
|
|
2454
|
+
gate.close();
|
|
2455
|
+
for (const listener of [...signingOutListeners]) {
|
|
2456
|
+
try {
|
|
2457
|
+
listener();
|
|
2458
|
+
} catch (error) {
|
|
2459
|
+
console.warn("[API] A sign-out listener failed:", error);
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
gate.abort();
|
|
2449
2463
|
try {
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2464
|
+
const accessToken = session.getState().accessToken;
|
|
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
|
+
}
|
|
2478
|
+
} finally {
|
|
2479
|
+
gate.reopen();
|
|
2453
2480
|
}
|
|
2454
|
-
}
|
|
2455
|
-
|
|
2481
|
+
})();
|
|
2482
|
+
signingOut = done;
|
|
2456
2483
|
try {
|
|
2457
|
-
|
|
2458
|
-
if (accessToken) {
|
|
2459
|
-
const query = `?all_sessions=${everywhere}`;
|
|
2460
|
-
await retryFetch(`${base()}${API_PREFIX}/user/logout${query}`, {
|
|
2461
|
-
method: "POST",
|
|
2462
|
-
headers: { Authorization: `Bearer ${accessToken}` },
|
|
2463
|
-
credentials
|
|
2464
|
-
}).catch((error) => console.warn("[API] Server logout failed:", error));
|
|
2465
|
-
}
|
|
2466
|
-
session.clear();
|
|
2467
|
-
if (everywhere) {
|
|
2468
|
-
if (persistence.clearSession) await persistence.clearSession();
|
|
2469
|
-
else if (typeof indexedDB !== "undefined") await clearAllData();
|
|
2470
|
-
}
|
|
2484
|
+
await done;
|
|
2471
2485
|
} finally {
|
|
2472
|
-
|
|
2486
|
+
if (signingOut === done) signingOut = null;
|
|
2473
2487
|
}
|
|
2474
2488
|
},
|
|
2475
2489
|
async unlock({ email, password }) {
|