@openclaw/nostr 2026.7.2-beta.2 → 2026.7.2-beta.4
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.js +20 -6
- package/dist/{channel-B51rExHD.js → channel-DqbdMXMg.js} +810 -428
- package/dist/channel-plugin-api.js +1 -1
- package/dist/inbound-direct-dm-runtime-DHn9NoYN.js +2 -0
- package/dist/{setup-adapter-DEU3o8MF.js → setup-adapter-BjKmSwdW.js} +31 -1
- package/dist/setup-api.js +1 -1
- package/dist/setup-plugin-api.js +5 -3
- package/dist/{setup-surface-B52P4uo2.js → setup-surface-ChtM-WSY.js} +6 -4
- package/node_modules/nostr-tools/lib/cjs/abstract-pool.js +35 -3
- package/node_modules/nostr-tools/lib/cjs/abstract-pool.js.map +2 -2
- package/node_modules/nostr-tools/lib/cjs/abstract-relay.js +30 -2
- package/node_modules/nostr-tools/lib/cjs/abstract-relay.js.map +2 -2
- package/node_modules/nostr-tools/lib/cjs/index.js +35 -3
- package/node_modules/nostr-tools/lib/cjs/index.js.map +2 -2
- package/node_modules/nostr-tools/lib/cjs/nip46.js +35 -3
- package/node_modules/nostr-tools/lib/cjs/nip46.js.map +2 -2
- package/node_modules/nostr-tools/lib/cjs/nipb0.js +4 -1
- package/node_modules/nostr-tools/lib/cjs/nipb0.js.map +2 -2
- package/node_modules/nostr-tools/lib/cjs/pool.js +35 -3
- package/node_modules/nostr-tools/lib/cjs/pool.js.map +2 -2
- package/node_modules/nostr-tools/lib/cjs/relay.js +30 -2
- package/node_modules/nostr-tools/lib/cjs/relay.js.map +2 -2
- package/node_modules/nostr-tools/lib/esm/abstract-pool.js +35 -3
- package/node_modules/nostr-tools/lib/esm/abstract-pool.js.map +2 -2
- package/node_modules/nostr-tools/lib/esm/abstract-relay.js +30 -2
- package/node_modules/nostr-tools/lib/esm/abstract-relay.js.map +2 -2
- package/node_modules/nostr-tools/lib/esm/index.js +35 -3
- package/node_modules/nostr-tools/lib/esm/index.js.map +2 -2
- package/node_modules/nostr-tools/lib/esm/nip46.js +35 -3
- package/node_modules/nostr-tools/lib/esm/nip46.js.map +2 -2
- package/node_modules/nostr-tools/lib/esm/nipb0.js +4 -1
- package/node_modules/nostr-tools/lib/esm/nipb0.js.map +2 -2
- package/node_modules/nostr-tools/lib/esm/pool.js +35 -3
- package/node_modules/nostr-tools/lib/esm/pool.js.map +2 -2
- package/node_modules/nostr-tools/lib/esm/relay.js +30 -2
- package/node_modules/nostr-tools/lib/esm/relay.js.map +2 -2
- package/node_modules/nostr-tools/lib/nostr.bundle.js +35 -3
- package/node_modules/nostr-tools/lib/nostr.bundle.js.map +2 -2
- package/node_modules/nostr-tools/lib/types/abstract-pool.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/abstract-relay.d.ts +5 -0
- package/node_modules/nostr-tools/lib/types/relay.d.ts +2 -2
- package/node_modules/nostr-tools/package.json +1 -1
- package/npm-shrinkwrap.json +7 -7
- package/openclaw.plugin.json +0 -5
- package/package.json +41 -15
- package/dist/inbound-direct-dm-runtime-EdLLVtkh.js +0 -2
|
@@ -338,12 +338,14 @@ var AbstractRelay = class {
|
|
|
338
338
|
openSubs = /* @__PURE__ */ new Map();
|
|
339
339
|
enablePing;
|
|
340
340
|
enableReconnect;
|
|
341
|
+
idleTimeout = 0;
|
|
341
342
|
idleSince = Date.now();
|
|
342
343
|
ongoingOperations = 0;
|
|
343
344
|
reconnectTimeoutHandle;
|
|
344
345
|
pingIntervalHandle;
|
|
345
346
|
reconnectAttempts = 0;
|
|
346
347
|
skipReconnection = false;
|
|
348
|
+
idleTimeoutHandle;
|
|
347
349
|
connectionPromise;
|
|
348
350
|
openCountRequests = /* @__PURE__ */ new Map();
|
|
349
351
|
openEventPublishes = /* @__PURE__ */ new Map();
|
|
@@ -359,6 +361,8 @@ var AbstractRelay = class {
|
|
|
359
361
|
this._WebSocket = opts.websocketImplementation || WebSocket;
|
|
360
362
|
this.enablePing = opts.enablePing;
|
|
361
363
|
this.enableReconnect = opts.enableReconnect || false;
|
|
364
|
+
if (opts.idleTimeout)
|
|
365
|
+
this.idleTimeout = opts.idleTimeout;
|
|
362
366
|
}
|
|
363
367
|
static async connect(url, opts) {
|
|
364
368
|
const relay = new AbstractRelay(url, opts);
|
|
@@ -382,6 +386,22 @@ var AbstractRelay = class {
|
|
|
382
386
|
get connected() {
|
|
383
387
|
return this._connected;
|
|
384
388
|
}
|
|
389
|
+
clearIdleTimeout() {
|
|
390
|
+
if (this.idleTimeoutHandle) {
|
|
391
|
+
clearTimeout(this.idleTimeoutHandle);
|
|
392
|
+
this.idleTimeoutHandle = void 0;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
scheduleIdleClose() {
|
|
396
|
+
this.clearIdleTimeout();
|
|
397
|
+
if (this.idleTimeout > 0) {
|
|
398
|
+
this.idleTimeoutHandle = setTimeout(() => {
|
|
399
|
+
if (this.ongoingOperations === 0 && this.idleSince) {
|
|
400
|
+
this.close();
|
|
401
|
+
}
|
|
402
|
+
}, this.idleTimeout);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
385
405
|
async reconnect() {
|
|
386
406
|
const backoff = this.resubscribeBackoff[Math.min(this.reconnectAttempts, this.resubscribeBackoff.length - 1)];
|
|
387
407
|
this.reconnectAttempts++;
|
|
@@ -400,6 +420,7 @@ var AbstractRelay = class {
|
|
|
400
420
|
this._connected = false;
|
|
401
421
|
this.connectionPromise = void 0;
|
|
402
422
|
this.idleSince = void 0;
|
|
423
|
+
this.clearIdleTimeout();
|
|
403
424
|
if (this.enableReconnect && !this.skipReconnection) {
|
|
404
425
|
this.reconnect();
|
|
405
426
|
} else {
|
|
@@ -557,6 +578,7 @@ var AbstractRelay = class {
|
|
|
557
578
|
}
|
|
558
579
|
async publish(event) {
|
|
559
580
|
this.idleSince = void 0;
|
|
581
|
+
this.clearIdleTimeout();
|
|
560
582
|
this.ongoingOperations++;
|
|
561
583
|
const ret = new Promise((resolve, reject) => {
|
|
562
584
|
const timeout = setTimeout(() => {
|
|
@@ -578,8 +600,10 @@ var AbstractRelay = class {
|
|
|
578
600
|
}
|
|
579
601
|
}
|
|
580
602
|
this.ongoingOperations--;
|
|
581
|
-
if (this.ongoingOperations === 0)
|
|
603
|
+
if (this.ongoingOperations === 0) {
|
|
582
604
|
this.idleSince = Date.now();
|
|
605
|
+
this.scheduleIdleClose();
|
|
606
|
+
}
|
|
583
607
|
return ret;
|
|
584
608
|
}
|
|
585
609
|
async count(filters, params) {
|
|
@@ -605,6 +629,7 @@ var AbstractRelay = class {
|
|
|
605
629
|
subscribe(filters, params) {
|
|
606
630
|
if (params.label !== "<forced-ping>") {
|
|
607
631
|
this.idleSince = void 0;
|
|
632
|
+
this.clearIdleTimeout();
|
|
608
633
|
this.ongoingOperations++;
|
|
609
634
|
}
|
|
610
635
|
const sub = this.prepareSubscription(filters, params);
|
|
@@ -634,6 +659,7 @@ var AbstractRelay = class {
|
|
|
634
659
|
this.closeAllSubscriptions("relay connection closed by us");
|
|
635
660
|
this._connected = false;
|
|
636
661
|
this.idleSince = void 0;
|
|
662
|
+
this.clearIdleTimeout();
|
|
637
663
|
this.onclose?.();
|
|
638
664
|
if (this.ws?.readyState === this._WebSocket.OPEN) {
|
|
639
665
|
this.ws?.close();
|
|
@@ -811,8 +837,10 @@ var Subscription = class {
|
|
|
811
837
|
}
|
|
812
838
|
this.relay.openSubs.delete(this.id);
|
|
813
839
|
this.relay.ongoingOperations--;
|
|
814
|
-
if (this.relay.ongoingOperations === 0)
|
|
840
|
+
if (this.relay.ongoingOperations === 0) {
|
|
815
841
|
this.relay.idleSince = Date.now();
|
|
842
|
+
this.relay.scheduleIdleClose();
|
|
843
|
+
}
|
|
816
844
|
this.onclose?.(reason);
|
|
817
845
|
}
|
|
818
846
|
};
|
|
@@ -888,6 +916,7 @@ var AbstractSimplePool = class {
|
|
|
888
916
|
verifyEvent;
|
|
889
917
|
enablePing;
|
|
890
918
|
enableReconnect;
|
|
919
|
+
idleTimeout = 2e4;
|
|
891
920
|
automaticallyAuth;
|
|
892
921
|
trustedRelayURLs = /* @__PURE__ */ new Set();
|
|
893
922
|
onRelayConnectionFailure;
|
|
@@ -900,6 +929,8 @@ var AbstractSimplePool = class {
|
|
|
900
929
|
this._WebSocket = opts.websocketImplementation;
|
|
901
930
|
this.enablePing = opts.enablePing;
|
|
902
931
|
this.enableReconnect = opts.enableReconnect || false;
|
|
932
|
+
if (opts.idleTimeout)
|
|
933
|
+
this.idleTimeout = opts.idleTimeout;
|
|
903
934
|
this.automaticallyAuth = opts.automaticallyAuth;
|
|
904
935
|
this.onRelayConnectionFailure = opts.onRelayConnectionFailure;
|
|
905
936
|
this.onRelayConnectionSuccess = opts.onRelayConnectionSuccess;
|
|
@@ -914,7 +945,8 @@ var AbstractSimplePool = class {
|
|
|
914
945
|
verifyEvent: this.trustedRelayURLs.has(url) ? alwaysTrue : this.verifyEvent,
|
|
915
946
|
websocketImplementation: this._WebSocket,
|
|
916
947
|
enablePing: this.enablePing,
|
|
917
|
-
enableReconnect: this.enableReconnect
|
|
948
|
+
enableReconnect: this.enableReconnect,
|
|
949
|
+
idleTimeout: this.idleTimeout
|
|
918
950
|
});
|
|
919
951
|
relay.onclose = () => {
|
|
920
952
|
this.relays.delete(url);
|