@arbidocs/sdk 0.3.109 → 0.3.110
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/{browser-C4gqnXaX.d.cts → browser-DgApY8QV.d.cts} +29 -2
- package/dist/{browser-C4gqnXaX.d.ts → browser-DgApY8QV.d.ts} +29 -2
- package/dist/browser.cjs +27 -3
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +27 -3
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +27 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +27 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -4465,7 +4465,7 @@ var WebSocketAuthError = class extends Error {
|
|
|
4465
4465
|
}
|
|
4466
4466
|
};
|
|
4467
4467
|
function connectWebSocket(options) {
|
|
4468
|
-
const { baseUrl, accessToken, onMessage, onClose } = options;
|
|
4468
|
+
const { baseUrl, accessToken, onMessage, onClose, onAuthenticated } = options;
|
|
4469
4469
|
const url = client.buildWebSocketUrl(baseUrl);
|
|
4470
4470
|
return new Promise((resolve2, reject) => {
|
|
4471
4471
|
const ws = new WebSocket(url);
|
|
@@ -4488,6 +4488,7 @@ function connectWebSocket(options) {
|
|
|
4488
4488
|
clearTimeout(timeout);
|
|
4489
4489
|
if (msg.success) {
|
|
4490
4490
|
authenticated = true;
|
|
4491
|
+
onAuthenticated?.(msg);
|
|
4491
4492
|
resolve2({ close: () => ws.close() });
|
|
4492
4493
|
} else {
|
|
4493
4494
|
ws.close();
|
|
@@ -4521,6 +4522,8 @@ async function connectWithReconnect(options) {
|
|
|
4521
4522
|
onReconnectFailed,
|
|
4522
4523
|
onClose,
|
|
4523
4524
|
onMessage,
|
|
4525
|
+
onAuthenticated,
|
|
4526
|
+
shouldReconnect,
|
|
4524
4527
|
baseUrl,
|
|
4525
4528
|
accessToken
|
|
4526
4529
|
} = options;
|
|
@@ -4535,10 +4538,11 @@ async function connectWithReconnect(options) {
|
|
|
4535
4538
|
baseUrl,
|
|
4536
4539
|
accessToken: token,
|
|
4537
4540
|
onMessage,
|
|
4541
|
+
onAuthenticated,
|
|
4538
4542
|
onClose: (code, reason) => {
|
|
4539
4543
|
currentConnection = null;
|
|
4540
4544
|
onClose?.(code, reason);
|
|
4541
|
-
if (!closed) void scheduleReconnect();
|
|
4545
|
+
if (!closed && (shouldReconnect?.(code, reason) ?? true)) void scheduleReconnect();
|
|
4542
4546
|
}
|
|
4543
4547
|
});
|
|
4544
4548
|
};
|
|
@@ -4569,7 +4573,14 @@ async function connectWithReconnect(options) {
|
|
|
4569
4573
|
}
|
|
4570
4574
|
if (!closed) onReconnectFailed?.();
|
|
4571
4575
|
};
|
|
4572
|
-
|
|
4576
|
+
try {
|
|
4577
|
+
currentConnection = await connectOnce();
|
|
4578
|
+
} catch (err) {
|
|
4579
|
+
if (!(err instanceof WebSocketAuthError) || !refreshAuth) throw err;
|
|
4580
|
+
await refreshAuth().catch(() => {
|
|
4581
|
+
});
|
|
4582
|
+
currentConnection = await connectOnce();
|
|
4583
|
+
}
|
|
4573
4584
|
return {
|
|
4574
4585
|
close: () => {
|
|
4575
4586
|
closed = true;
|
|
@@ -6102,6 +6113,19 @@ var Arbi = class {
|
|
|
6102
6113
|
get hasWorkspace() {
|
|
6103
6114
|
return this.currentWorkspaceId !== null;
|
|
6104
6115
|
}
|
|
6116
|
+
/**
|
|
6117
|
+
* Live connection info for opening a raw transport (e.g. a WebSocket).
|
|
6118
|
+
*
|
|
6119
|
+
* Reads the access token from the session on each call, so a token refreshed
|
|
6120
|
+
* elsewhere is reflected on the next (re)connect. Returns `null` when there is
|
|
6121
|
+
* no client/token yet (not logged in) rather than throwing, so callers can
|
|
6122
|
+
* poll for readiness instead of guarding against exceptions.
|
|
6123
|
+
*/
|
|
6124
|
+
getConnectionInfo() {
|
|
6125
|
+
const accessToken = this.client?.session.getState().accessToken;
|
|
6126
|
+
if (!accessToken) return null;
|
|
6127
|
+
return { baseUrl: this.options.url, accessToken };
|
|
6128
|
+
}
|
|
6105
6129
|
// ── Auth headers (for raw fetch operations) ───────────────────────────
|
|
6106
6130
|
getAuthHeaders() {
|
|
6107
6131
|
const client = this.requireClient();
|