@wspc/cli 0.1.8 → 0.1.9
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/cli.js +20 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1520,9 +1520,9 @@ function createConsistencyFetch(opts) {
|
|
|
1520
1520
|
}
|
|
1521
1521
|
|
|
1522
1522
|
// src/version.ts
|
|
1523
|
-
var VERSION = "0.1.
|
|
1523
|
+
var VERSION = "0.1.9";
|
|
1524
1524
|
var SPEC_SHA = "bec760cd";
|
|
1525
|
-
var SPEC_FETCHED_AT = "2026-07-
|
|
1525
|
+
var SPEC_FETCHED_AT = "2026-07-06T07:30:04.295Z";
|
|
1526
1526
|
var API_BASE = "https://api.wspc.ai";
|
|
1527
1527
|
|
|
1528
1528
|
// src/index.ts
|
|
@@ -6331,6 +6331,15 @@ function createDriveRealtimeSource(args) {
|
|
|
6331
6331
|
if (stopped || authFailed) return;
|
|
6332
6332
|
clearReconnectTimer();
|
|
6333
6333
|
const id = ++connectionId;
|
|
6334
|
+
const headers = args.headers;
|
|
6335
|
+
if (typeof headers !== "function") {
|
|
6336
|
+
openSocket(id, headers);
|
|
6337
|
+
return;
|
|
6338
|
+
}
|
|
6339
|
+
void headers().then((resolved) => openSocket(id, resolved)).catch((error) => closeConnection(id, error));
|
|
6340
|
+
}
|
|
6341
|
+
function openSocket(id, headers) {
|
|
6342
|
+
if (id !== connectionId || stopped || authFailed) return;
|
|
6334
6343
|
const url = buildDriveRealtimeUrl(args.baseUrl, args.libraryId, currentRealtime);
|
|
6335
6344
|
activeSocket = connect(url, {
|
|
6336
6345
|
open() {
|
|
@@ -6345,7 +6354,7 @@ function createDriveRealtimeSource(args) {
|
|
|
6345
6354
|
close(error) {
|
|
6346
6355
|
closeConnection(id, error ?? "close");
|
|
6347
6356
|
}
|
|
6348
|
-
},
|
|
6357
|
+
}, headers === void 0 ? void 0 : { headers });
|
|
6349
6358
|
}
|
|
6350
6359
|
function closeConnection(id, error) {
|
|
6351
6360
|
if (id !== connectionId || stopped || authFailed) return;
|
|
@@ -6540,6 +6549,9 @@ function isInvalidCursorReason(reason) {
|
|
|
6540
6549
|
return /\bcursor[_ -]?(invalid|expired|gone|missing|not[_ -]?found)\b|\binvalid[_ -]?cursor\b/i.test(reason);
|
|
6541
6550
|
}
|
|
6542
6551
|
function isRealtimeAuthError(error) {
|
|
6552
|
+
if (typeof error === "object" && error !== null && error.code === "WSPC_AUTH_EXPIRED") {
|
|
6553
|
+
return true;
|
|
6554
|
+
}
|
|
6543
6555
|
return /\b(401|403|auth|authorization|unauthorized|forbidden)\b/i.test(String(error));
|
|
6544
6556
|
}
|
|
6545
6557
|
function nativeWebSocketConnector(url, handlers, init) {
|
|
@@ -6683,16 +6695,17 @@ async function runDriveWatch(root, options = {}) {
|
|
|
6683
6695
|
realtimeSource = options.once ? void 0 : options.realtimeSource;
|
|
6684
6696
|
if (!options.once && realtimeSource === void 0) {
|
|
6685
6697
|
state = await ensureDriveRealtimeState(root);
|
|
6686
|
-
const
|
|
6687
|
-
|
|
6688
|
-
});
|
|
6698
|
+
const verifyPath = `/drive/libraries/${encodeURIComponent(state.library_id)}`;
|
|
6699
|
+
const { baseUrl } = await loadRealtimeAuthHeaders({ verifyPath });
|
|
6689
6700
|
const realtime = state.realtime;
|
|
6690
6701
|
if (realtime === void 0) {
|
|
6691
6702
|
throw new Error("drive realtime state is required");
|
|
6692
6703
|
}
|
|
6693
6704
|
realtimeSource = createDriveRealtimeSource({
|
|
6694
6705
|
baseUrl,
|
|
6695
|
-
headers
|
|
6706
|
+
// Tokens expire while watching; resolve fresh headers on every
|
|
6707
|
+
// (re)connect so an idle drop cannot loop on a stale snapshot.
|
|
6708
|
+
headers: async () => (await loadRealtimeAuthHeaders({ verifyPath })).headers,
|
|
6696
6709
|
libraryId: state.library_id,
|
|
6697
6710
|
realtime,
|
|
6698
6711
|
writeRealtimeState: (next) => writeDriveRealtimeState(root, next)
|