@openclaw/nostr 2026.7.2-beta.7 → 2026.7.34
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/{channel-O6-jXoT5.js → .setup/channel-B4SX7Iq6.mjs} +554 -877
- package/dist/{config-schema-CelPzg1N.js → .setup/config-schema-DIiXiBKr.mjs} +1 -1
- package/dist/.setup/inbound-direct-dm-runtime-EdLLVtkh.mjs +2 -0
- package/dist/{setup-adapter-BjKmSwdW.js → .setup/setup-adapter-DEU3o8MF.mjs} +1 -31
- package/dist/.setup/setup-plugin-api-DzlCumkz.mjs +2 -0
- package/dist/.setup/setup-plugin-api-csfJrRxD.mjs +111 -0
- package/dist/{setup-surface-BJCFpe02.js → .setup/setup-surface-DWa6-9ku.mjs} +70 -41
- package/dist/api.js +72 -61
- package/dist/channel-plugin-api.js +1 -1
- package/dist/doctor-contract-api.js +3 -2
- package/dist/setup-api.js +1 -1
- package/dist/setup-entry.js +2 -1
- package/dist/setup-plugin-api.js +1 -112
- package/node_modules/nostr-tools/lib/cjs/abstract-pool.js +28 -59
- package/node_modules/nostr-tools/lib/cjs/abstract-pool.js.map +3 -3
- package/node_modules/nostr-tools/lib/cjs/abstract-relay.js +7 -44
- package/node_modules/nostr-tools/lib/cjs/abstract-relay.js.map +2 -2
- package/node_modules/nostr-tools/lib/cjs/core.js +1 -17
- package/node_modules/nostr-tools/lib/cjs/core.js.map +3 -3
- package/node_modules/nostr-tools/lib/cjs/filter.js.map +1 -1
- package/node_modules/nostr-tools/lib/cjs/index.js +130 -172
- package/node_modules/nostr-tools/lib/cjs/index.js.map +4 -4
- package/node_modules/nostr-tools/lib/cjs/kinds.js +1 -17
- package/node_modules/nostr-tools/lib/cjs/kinds.js.map +3 -3
- package/node_modules/nostr-tools/lib/cjs/nip04.js.map +1 -1
- package/node_modules/nostr-tools/lib/cjs/nip10.js +5 -20
- package/node_modules/nostr-tools/lib/cjs/nip10.js.map +3 -3
- package/node_modules/nostr-tools/lib/cjs/nip13.js.map +1 -1
- package/node_modules/nostr-tools/lib/cjs/nip17.js +23 -30
- package/node_modules/nostr-tools/lib/cjs/nip17.js.map +4 -4
- package/node_modules/nostr-tools/lib/cjs/nip18.js +14 -21
- package/node_modules/nostr-tools/lib/cjs/nip18.js.map +4 -4
- package/node_modules/nostr-tools/lib/cjs/nip19.js.map +1 -1
- package/node_modules/nostr-tools/lib/cjs/nip21.js.map +1 -1
- package/node_modules/nostr-tools/lib/cjs/nip22.js +7 -22
- package/node_modules/nostr-tools/lib/cjs/nip22.js.map +3 -3
- package/node_modules/nostr-tools/lib/cjs/nip25.js +14 -21
- package/node_modules/nostr-tools/lib/cjs/nip25.js.map +4 -4
- package/node_modules/nostr-tools/lib/cjs/nip27.js.map +1 -1
- package/node_modules/nostr-tools/lib/cjs/nip28.js +14 -21
- package/node_modules/nostr-tools/lib/cjs/nip28.js.map +4 -4
- package/node_modules/nostr-tools/lib/cjs/nip29.js.map +1 -1
- package/node_modules/nostr-tools/lib/cjs/nip30.js.map +2 -2
- package/node_modules/nostr-tools/lib/cjs/nip42.js.map +2 -2
- package/node_modules/nostr-tools/lib/cjs/nip44.js.map +1 -1
- package/node_modules/nostr-tools/lib/cjs/nip45.js +9 -22
- package/node_modules/nostr-tools/lib/cjs/nip45.js.map +4 -4
- package/node_modules/nostr-tools/lib/cjs/nip46.js +70 -111
- package/node_modules/nostr-tools/lib/cjs/nip46.js.map +4 -4
- package/node_modules/nostr-tools/lib/cjs/nip47.js +18 -25
- package/node_modules/nostr-tools/lib/cjs/nip47.js.map +4 -4
- package/node_modules/nostr-tools/lib/cjs/nip57.js +16 -23
- package/node_modules/nostr-tools/lib/cjs/nip57.js.map +4 -4
- package/node_modules/nostr-tools/lib/cjs/nip58.js.map +2 -2
- package/node_modules/nostr-tools/lib/cjs/nip59.js +7 -16
- package/node_modules/nostr-tools/lib/cjs/nip59.js.map +3 -3
- package/node_modules/nostr-tools/lib/cjs/nip75.js.map +1 -1
- package/node_modules/nostr-tools/lib/cjs/nip94.js.map +1 -1
- package/node_modules/nostr-tools/lib/cjs/nip98.js +16 -23
- package/node_modules/nostr-tools/lib/cjs/nip98.js.map +4 -4
- package/node_modules/nostr-tools/lib/cjs/nip99.js.map +2 -2
- package/node_modules/nostr-tools/lib/cjs/nipb0.js +17 -38
- package/node_modules/nostr-tools/lib/cjs/nipb0.js.map +4 -4
- package/node_modules/nostr-tools/lib/cjs/nipb7.js +7 -13
- package/node_modules/nostr-tools/lib/cjs/nipb7.js.map +2 -2
- package/node_modules/nostr-tools/lib/cjs/pool.js +61 -102
- package/node_modules/nostr-tools/lib/cjs/pool.js.map +4 -4
- package/node_modules/nostr-tools/lib/cjs/pure.js +14 -21
- package/node_modules/nostr-tools/lib/cjs/pure.js.map +4 -4
- package/node_modules/nostr-tools/lib/cjs/references.js.map +1 -1
- package/node_modules/nostr-tools/lib/cjs/relay.js +42 -86
- package/node_modules/nostr-tools/lib/cjs/relay.js.map +4 -4
- package/node_modules/nostr-tools/lib/cjs/signer.js +14 -21
- package/node_modules/nostr-tools/lib/cjs/signer.js.map +4 -4
- package/node_modules/nostr-tools/lib/cjs/utils.js +0 -10
- package/node_modules/nostr-tools/lib/cjs/utils.js.map +2 -2
- package/node_modules/nostr-tools/lib/cjs/wasm.js +2 -16
- package/node_modules/nostr-tools/lib/cjs/wasm.js.map +4 -4
- package/node_modules/nostr-tools/lib/esm/abstract-pool.js +28 -59
- package/node_modules/nostr-tools/lib/esm/abstract-pool.js.map +3 -3
- package/node_modules/nostr-tools/lib/esm/abstract-relay.js +7 -44
- package/node_modules/nostr-tools/lib/esm/abstract-relay.js.map +2 -2
- package/node_modules/nostr-tools/lib/esm/core.js +1 -15
- package/node_modules/nostr-tools/lib/esm/core.js.map +3 -3
- package/node_modules/nostr-tools/lib/esm/filter.js.map +1 -1
- package/node_modules/nostr-tools/lib/esm/index.js +80 -122
- package/node_modules/nostr-tools/lib/esm/index.js.map +4 -4
- package/node_modules/nostr-tools/lib/esm/kinds.js +1 -17
- package/node_modules/nostr-tools/lib/esm/kinds.js.map +3 -3
- package/node_modules/nostr-tools/lib/esm/nip04.js.map +1 -1
- package/node_modules/nostr-tools/lib/esm/nip10.js +5 -18
- package/node_modules/nostr-tools/lib/esm/nip10.js.map +3 -3
- package/node_modules/nostr-tools/lib/esm/nip13.js.map +1 -1
- package/node_modules/nostr-tools/lib/esm/nip17.js +8 -15
- package/node_modules/nostr-tools/lib/esm/nip17.js.map +4 -4
- package/node_modules/nostr-tools/lib/esm/nip18.js +8 -15
- package/node_modules/nostr-tools/lib/esm/nip18.js.map +4 -4
- package/node_modules/nostr-tools/lib/esm/nip19.js.map +1 -1
- package/node_modules/nostr-tools/lib/esm/nip21.js.map +1 -1
- package/node_modules/nostr-tools/lib/esm/nip22.js +7 -20
- package/node_modules/nostr-tools/lib/esm/nip22.js.map +3 -3
- package/node_modules/nostr-tools/lib/esm/nip25.js +8 -15
- package/node_modules/nostr-tools/lib/esm/nip25.js.map +4 -4
- package/node_modules/nostr-tools/lib/esm/nip27.js.map +1 -1
- package/node_modules/nostr-tools/lib/esm/nip28.js +8 -15
- package/node_modules/nostr-tools/lib/esm/nip28.js.map +4 -4
- package/node_modules/nostr-tools/lib/esm/nip29.js.map +1 -1
- package/node_modules/nostr-tools/lib/esm/nip30.js.map +2 -2
- package/node_modules/nostr-tools/lib/esm/nip42.js.map +2 -2
- package/node_modules/nostr-tools/lib/esm/nip44.js.map +1 -1
- package/node_modules/nostr-tools/lib/esm/nip45.js +10 -23
- package/node_modules/nostr-tools/lib/esm/nip45.js.map +4 -4
- package/node_modules/nostr-tools/lib/esm/nip46.js +54 -95
- package/node_modules/nostr-tools/lib/esm/nip46.js.map +4 -4
- package/node_modules/nostr-tools/lib/esm/nip47.js +8 -15
- package/node_modules/nostr-tools/lib/esm/nip47.js.map +4 -4
- package/node_modules/nostr-tools/lib/esm/nip57.js +10 -17
- package/node_modules/nostr-tools/lib/esm/nip57.js.map +4 -4
- package/node_modules/nostr-tools/lib/esm/nip58.js.map +2 -2
- package/node_modules/nostr-tools/lib/esm/nip59.js +1 -10
- package/node_modules/nostr-tools/lib/esm/nip59.js.map +3 -3
- package/node_modules/nostr-tools/lib/esm/nip75.js.map +1 -1
- package/node_modules/nostr-tools/lib/esm/nip94.js.map +1 -1
- package/node_modules/nostr-tools/lib/esm/nip98.js +8 -15
- package/node_modules/nostr-tools/lib/esm/nip98.js.map +4 -4
- package/node_modules/nostr-tools/lib/esm/nip99.js.map +2 -2
- package/node_modules/nostr-tools/lib/esm/nipb0.js +18 -39
- package/node_modules/nostr-tools/lib/esm/nipb0.js.map +4 -4
- package/node_modules/nostr-tools/lib/esm/nipb7.js +7 -13
- package/node_modules/nostr-tools/lib/esm/nipb7.js.map +2 -2
- package/node_modules/nostr-tools/lib/esm/pool.js +54 -95
- package/node_modules/nostr-tools/lib/esm/pool.js.map +4 -4
- package/node_modules/nostr-tools/lib/esm/pure.js +8 -15
- package/node_modules/nostr-tools/lib/esm/pure.js.map +4 -4
- package/node_modules/nostr-tools/lib/esm/references.js.map +1 -1
- package/node_modules/nostr-tools/lib/esm/relay.js +36 -80
- package/node_modules/nostr-tools/lib/esm/relay.js.map +4 -4
- package/node_modules/nostr-tools/lib/esm/signer.js +8 -15
- package/node_modules/nostr-tools/lib/esm/signer.js.map +4 -4
- package/node_modules/nostr-tools/lib/esm/utils.js +0 -10
- package/node_modules/nostr-tools/lib/esm/utils.js.map +2 -2
- package/node_modules/nostr-tools/lib/esm/wasm.js +3 -17
- package/node_modules/nostr-tools/lib/esm/wasm.js.map +4 -4
- package/node_modules/nostr-tools/lib/nostr.bundle.js +77 -121
- package/node_modules/nostr-tools/lib/nostr.bundle.js.map +4 -4
- package/node_modules/nostr-tools/lib/types/abstract-pool.d.ts +4 -7
- package/node_modules/nostr-tools/lib/types/abstract-relay.d.ts +2 -7
- package/node_modules/nostr-tools/lib/types/helpers.d.ts +2 -0
- package/node_modules/nostr-tools/lib/types/kinds.d.ts +0 -2
- package/node_modules/nostr-tools/lib/types/nipb0.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/nipb7.d.ts +1 -0
- package/node_modules/nostr-tools/lib/types/relay.d.ts +2 -2
- package/node_modules/nostr-tools/lib/types/utils.d.ts +0 -4
- package/node_modules/nostr-tools/package.json +1 -1
- package/openclaw.plugin.json +5 -0
- package/package.json +15 -41
- package/dist/inbound-direct-dm-runtime-DHn9NoYN.js +0 -2
- package/node_modules/nostr-tools/lib/types/nipb0.test.d.ts +0 -1
- /package/dist/{state-account-id-CvBZ9s6P.js → .setup/state-account-id-CvBZ9s6P.mjs} +0 -0
|
@@ -8,6 +8,47 @@ var __export = (target, all) => {
|
|
|
8
8
|
import { schnorr } from "@noble/curves/secp256k1.js";
|
|
9
9
|
import { bytesToHex as bytesToHex2, hexToBytes as hexToBytes2 } from "@noble/hashes/utils.js";
|
|
10
10
|
|
|
11
|
+
// core.ts
|
|
12
|
+
var verifiedSymbol = Symbol("verified");
|
|
13
|
+
var isRecord = (obj) => obj instanceof Object;
|
|
14
|
+
function validateEvent(event) {
|
|
15
|
+
if (!isRecord(event))
|
|
16
|
+
return false;
|
|
17
|
+
if (typeof event.kind !== "number")
|
|
18
|
+
return false;
|
|
19
|
+
if (typeof event.content !== "string")
|
|
20
|
+
return false;
|
|
21
|
+
if (typeof event.created_at !== "number")
|
|
22
|
+
return false;
|
|
23
|
+
if (typeof event.pubkey !== "string")
|
|
24
|
+
return false;
|
|
25
|
+
if (!event.pubkey.match(/^[a-f0-9]{64}$/))
|
|
26
|
+
return false;
|
|
27
|
+
if (!Array.isArray(event.tags))
|
|
28
|
+
return false;
|
|
29
|
+
for (let i2 = 0; i2 < event.tags.length; i2++) {
|
|
30
|
+
let tag = event.tags[i2];
|
|
31
|
+
if (!Array.isArray(tag))
|
|
32
|
+
return false;
|
|
33
|
+
for (let j = 0; j < tag.length; j++) {
|
|
34
|
+
if (typeof tag[j] !== "string")
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
function sortEvents(events) {
|
|
41
|
+
return events.sort((a, b) => {
|
|
42
|
+
if (a.created_at !== b.created_at) {
|
|
43
|
+
return b.created_at - a.created_at;
|
|
44
|
+
}
|
|
45
|
+
return a.id.localeCompare(b.id);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// pure.ts
|
|
50
|
+
import { sha256 } from "@noble/hashes/sha2.js";
|
|
51
|
+
|
|
11
52
|
// utils.ts
|
|
12
53
|
var utils_exports = {};
|
|
13
54
|
__export(utils_exports, {
|
|
@@ -16,7 +57,6 @@ __export(utils_exports, {
|
|
|
16
57
|
hexToBytes: () => hexToBytes,
|
|
17
58
|
insertEventIntoAscendingList: () => insertEventIntoAscendingList,
|
|
18
59
|
insertEventIntoDescendingList: () => insertEventIntoDescendingList,
|
|
19
|
-
isHex32: () => isHex32,
|
|
20
60
|
mergeReverseSortedLists: () => mergeReverseSortedLists,
|
|
21
61
|
normalizeURL: () => normalizeURL,
|
|
22
62
|
utf8Decoder: () => utf8Decoder,
|
|
@@ -139,56 +179,8 @@ function mergeReverseSortedLists(list1, list2) {
|
|
|
139
179
|
}
|
|
140
180
|
return result;
|
|
141
181
|
}
|
|
142
|
-
function isHex32(input) {
|
|
143
|
-
for (let i2 = 0; i2 < 64; i2++) {
|
|
144
|
-
let cc = input.charCodeAt(i2);
|
|
145
|
-
if (isNaN(cc) || cc < 48 || cc > 102 || cc > 57 && cc < 97) {
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return true;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// core.ts
|
|
153
|
-
var verifiedSymbol = Symbol("verified");
|
|
154
|
-
var isRecord = (obj) => obj instanceof Object;
|
|
155
|
-
function validateEvent(event) {
|
|
156
|
-
if (!isRecord(event))
|
|
157
|
-
return false;
|
|
158
|
-
if (typeof event.kind !== "number")
|
|
159
|
-
return false;
|
|
160
|
-
if (typeof event.content !== "string")
|
|
161
|
-
return false;
|
|
162
|
-
if (typeof event.created_at !== "number")
|
|
163
|
-
return false;
|
|
164
|
-
if (typeof event.pubkey !== "string")
|
|
165
|
-
return false;
|
|
166
|
-
if (!isHex32(event.pubkey))
|
|
167
|
-
return false;
|
|
168
|
-
if (!Array.isArray(event.tags))
|
|
169
|
-
return false;
|
|
170
|
-
for (let i2 = 0; i2 < event.tags.length; i2++) {
|
|
171
|
-
let tag = event.tags[i2];
|
|
172
|
-
if (!Array.isArray(tag))
|
|
173
|
-
return false;
|
|
174
|
-
for (let j = 0; j < tag.length; j++) {
|
|
175
|
-
if (typeof tag[j] !== "string")
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return true;
|
|
180
|
-
}
|
|
181
|
-
function sortEvents(events) {
|
|
182
|
-
return events.sort((a, b) => {
|
|
183
|
-
if (a.created_at !== b.created_at) {
|
|
184
|
-
return b.created_at - a.created_at;
|
|
185
|
-
}
|
|
186
|
-
return a.id.localeCompare(b.id);
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
182
|
|
|
190
183
|
// pure.ts
|
|
191
|
-
import { sha256 } from "@noble/hashes/sha2.js";
|
|
192
184
|
var JS = class {
|
|
193
185
|
generateSecretKey() {
|
|
194
186
|
return schnorr.utils.randomSecretKey();
|
|
@@ -291,7 +283,6 @@ __export(kinds_exports, {
|
|
|
291
283
|
Emojisets: () => Emojisets,
|
|
292
284
|
EncryptedDirectMessage: () => EncryptedDirectMessage,
|
|
293
285
|
EventDeletion: () => EventDeletion,
|
|
294
|
-
FavoriteFollowSets: () => FavoriteFollowSets,
|
|
295
286
|
FavoritePodcasts: () => FavoritePodcasts,
|
|
296
287
|
FavoriteRelays: () => FavoriteRelays,
|
|
297
288
|
FedimintAnnouncement: () => FedimintAnnouncement,
|
|
@@ -564,7 +555,6 @@ var PrivateEventRelayList = 10013;
|
|
|
564
555
|
var InterestsList = 10015;
|
|
565
556
|
var NutZapInfo = 10019;
|
|
566
557
|
var MediaFollows = 10020;
|
|
567
|
-
var FavoriteFollowSets = 10021;
|
|
568
558
|
var UserEmojiList = 10030;
|
|
569
559
|
var DecoupledKeyAnnouncement = 10044;
|
|
570
560
|
var DirectMessageRelaysList = 10050;
|
|
@@ -813,14 +803,12 @@ var AbstractRelay = class {
|
|
|
813
803
|
openSubs = /* @__PURE__ */ new Map();
|
|
814
804
|
enablePing;
|
|
815
805
|
enableReconnect;
|
|
816
|
-
idleTimeout = 0;
|
|
817
806
|
idleSince = Date.now();
|
|
818
807
|
ongoingOperations = 0;
|
|
819
808
|
reconnectTimeoutHandle;
|
|
820
809
|
pingIntervalHandle;
|
|
821
810
|
reconnectAttempts = 0;
|
|
822
811
|
skipReconnection = false;
|
|
823
|
-
idleTimeoutHandle;
|
|
824
812
|
connectionPromise;
|
|
825
813
|
openCountRequests = /* @__PURE__ */ new Map();
|
|
826
814
|
openEventPublishes = /* @__PURE__ */ new Map();
|
|
@@ -836,8 +824,6 @@ var AbstractRelay = class {
|
|
|
836
824
|
this._WebSocket = opts.websocketImplementation || WebSocket;
|
|
837
825
|
this.enablePing = opts.enablePing;
|
|
838
826
|
this.enableReconnect = opts.enableReconnect || false;
|
|
839
|
-
if (opts.idleTimeout)
|
|
840
|
-
this.idleTimeout = opts.idleTimeout;
|
|
841
827
|
}
|
|
842
828
|
static async connect(url, opts) {
|
|
843
829
|
const relay = new AbstractRelay(url, opts);
|
|
@@ -861,22 +847,6 @@ var AbstractRelay = class {
|
|
|
861
847
|
get connected() {
|
|
862
848
|
return this._connected;
|
|
863
849
|
}
|
|
864
|
-
clearIdleTimeout() {
|
|
865
|
-
if (this.idleTimeoutHandle) {
|
|
866
|
-
clearTimeout(this.idleTimeoutHandle);
|
|
867
|
-
this.idleTimeoutHandle = void 0;
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
scheduleIdleClose() {
|
|
871
|
-
this.clearIdleTimeout();
|
|
872
|
-
if (this.idleTimeout > 0) {
|
|
873
|
-
this.idleTimeoutHandle = setTimeout(() => {
|
|
874
|
-
if (this.ongoingOperations === 0 && this.idleSince) {
|
|
875
|
-
this.close();
|
|
876
|
-
}
|
|
877
|
-
}, this.idleTimeout);
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
850
|
async reconnect() {
|
|
881
851
|
const backoff = this.resubscribeBackoff[Math.min(this.reconnectAttempts, this.resubscribeBackoff.length - 1)];
|
|
882
852
|
this.reconnectAttempts++;
|
|
@@ -888,11 +858,6 @@ var AbstractRelay = class {
|
|
|
888
858
|
}, backoff);
|
|
889
859
|
}
|
|
890
860
|
handleHardClose(reason) {
|
|
891
|
-
if (this.ws) {
|
|
892
|
-
this.ws.onopen = null;
|
|
893
|
-
this.ws.onerror = null;
|
|
894
|
-
this.ws.onclose = null;
|
|
895
|
-
}
|
|
896
861
|
if (this.pingIntervalHandle) {
|
|
897
862
|
clearInterval(this.pingIntervalHandle);
|
|
898
863
|
this.pingIntervalHandle = void 0;
|
|
@@ -900,7 +865,6 @@ var AbstractRelay = class {
|
|
|
900
865
|
this._connected = false;
|
|
901
866
|
this.connectionPromise = void 0;
|
|
902
867
|
this.idleSince = void 0;
|
|
903
|
-
this.clearIdleTimeout();
|
|
904
868
|
if (this.enableReconnect && !this.skipReconnection) {
|
|
905
869
|
this.reconnect();
|
|
906
870
|
} else {
|
|
@@ -923,6 +887,7 @@ var AbstractRelay = class {
|
|
|
923
887
|
if (this.reconnectAttempts === 0) {
|
|
924
888
|
this.skipReconnection = true;
|
|
925
889
|
}
|
|
890
|
+
this.onclose?.();
|
|
926
891
|
this.handleHardClose("relay connection timed out");
|
|
927
892
|
}, opts.timeout);
|
|
928
893
|
}
|
|
@@ -968,6 +933,7 @@ var AbstractRelay = class {
|
|
|
968
933
|
if (this.reconnectAttempts === 0) {
|
|
969
934
|
this.skipReconnection = true;
|
|
970
935
|
}
|
|
936
|
+
this.onclose?.();
|
|
971
937
|
this.handleHardClose("relay connection failed");
|
|
972
938
|
};
|
|
973
939
|
this.ws.onclose = (ev) => {
|
|
@@ -1056,7 +1022,6 @@ var AbstractRelay = class {
|
|
|
1056
1022
|
}
|
|
1057
1023
|
async publish(event) {
|
|
1058
1024
|
this.idleSince = void 0;
|
|
1059
|
-
this.clearIdleTimeout();
|
|
1060
1025
|
this.ongoingOperations++;
|
|
1061
1026
|
const ret = new Promise((resolve, reject) => {
|
|
1062
1027
|
const timeout = setTimeout(() => {
|
|
@@ -1078,10 +1043,8 @@ var AbstractRelay = class {
|
|
|
1078
1043
|
}
|
|
1079
1044
|
}
|
|
1080
1045
|
this.ongoingOperations--;
|
|
1081
|
-
if (this.ongoingOperations === 0)
|
|
1046
|
+
if (this.ongoingOperations === 0)
|
|
1082
1047
|
this.idleSince = Date.now();
|
|
1083
|
-
this.scheduleIdleClose();
|
|
1084
|
-
}
|
|
1085
1048
|
return ret;
|
|
1086
1049
|
}
|
|
1087
1050
|
async count(filters, params) {
|
|
@@ -1107,7 +1070,6 @@ var AbstractRelay = class {
|
|
|
1107
1070
|
subscribe(filters, params) {
|
|
1108
1071
|
if (params.label !== "<forced-ping>") {
|
|
1109
1072
|
this.idleSince = void 0;
|
|
1110
|
-
this.clearIdleTimeout();
|
|
1111
1073
|
this.ongoingOperations++;
|
|
1112
1074
|
}
|
|
1113
1075
|
const sub = this.prepareSubscription(filters, params);
|
|
@@ -1136,17 +1098,10 @@ var AbstractRelay = class {
|
|
|
1136
1098
|
}
|
|
1137
1099
|
this.closeAllSubscriptions("relay connection closed by us");
|
|
1138
1100
|
this._connected = false;
|
|
1139
|
-
this.connectionPromise = void 0;
|
|
1140
1101
|
this.idleSince = void 0;
|
|
1141
|
-
this.clearIdleTimeout();
|
|
1142
1102
|
this.onclose?.();
|
|
1143
|
-
if (this.ws) {
|
|
1144
|
-
this.ws
|
|
1145
|
-
this.ws.onerror = null;
|
|
1146
|
-
this.ws.onclose = null;
|
|
1147
|
-
if (this.ws.readyState !== this._WebSocket.CLOSING && this.ws.readyState !== this._WebSocket.CLOSED) {
|
|
1148
|
-
this.ws.close();
|
|
1149
|
-
}
|
|
1103
|
+
if (this.ws?.readyState === this._WebSocket.OPEN) {
|
|
1104
|
+
this.ws?.close();
|
|
1150
1105
|
}
|
|
1151
1106
|
}
|
|
1152
1107
|
_onmessage(ev) {
|
|
@@ -1173,7 +1128,7 @@ var AbstractRelay = class {
|
|
|
1173
1128
|
case "EVENT": {
|
|
1174
1129
|
const so = this.openSubs.get(data[1]);
|
|
1175
1130
|
const event = data[2];
|
|
1176
|
-
if (
|
|
1131
|
+
if (this.verifyEvent(event) && matchFilters(so.filters, event)) {
|
|
1177
1132
|
so.onevent(event);
|
|
1178
1133
|
} else {
|
|
1179
1134
|
so.oninvalidevent?.(event);
|
|
@@ -1321,10 +1276,8 @@ var Subscription = class {
|
|
|
1321
1276
|
}
|
|
1322
1277
|
this.relay.openSubs.delete(this.id);
|
|
1323
1278
|
this.relay.ongoingOperations--;
|
|
1324
|
-
if (this.relay.ongoingOperations === 0)
|
|
1279
|
+
if (this.relay.ongoingOperations === 0)
|
|
1325
1280
|
this.relay.idleSince = Date.now();
|
|
1326
|
-
this.relay.scheduleIdleClose();
|
|
1327
|
-
}
|
|
1328
1281
|
this.onclose?.(reason);
|
|
1329
1282
|
}
|
|
1330
1283
|
};
|
|
@@ -1346,6 +1299,12 @@ var Relay = class extends AbstractRelay {
|
|
|
1346
1299
|
}
|
|
1347
1300
|
};
|
|
1348
1301
|
|
|
1302
|
+
// helpers.ts
|
|
1303
|
+
var alwaysTrue = (t) => {
|
|
1304
|
+
t[verifiedSymbol] = true;
|
|
1305
|
+
return true;
|
|
1306
|
+
};
|
|
1307
|
+
|
|
1349
1308
|
// nip45.ts
|
|
1350
1309
|
import { sha256 as sha2562 } from "@noble/hashes/sha2.js";
|
|
1351
1310
|
import { bytesToHex as bytesToHex3 } from "@noble/hashes/utils.js";
|
|
@@ -1372,7 +1331,7 @@ function newHll() {
|
|
|
1372
1331
|
return new Uint8Array(M);
|
|
1373
1332
|
}
|
|
1374
1333
|
function hllDecode(hex) {
|
|
1375
|
-
if (hex.length !== HLL_HEX_LENGTH || !/^[0-9a-
|
|
1334
|
+
if (hex.length !== HLL_HEX_LENGTH || !/^[0-9a-fA-F]+$/.test(hex))
|
|
1376
1335
|
return void 0;
|
|
1377
1336
|
const registers = new Uint8Array(M);
|
|
1378
1337
|
for (let i2 = 0; i2 < M; i2++) {
|
|
@@ -1411,8 +1370,8 @@ var AbstractSimplePool = class {
|
|
|
1411
1370
|
verifyEvent;
|
|
1412
1371
|
enablePing;
|
|
1413
1372
|
enableReconnect;
|
|
1414
|
-
idleTimeout = 2e4;
|
|
1415
1373
|
automaticallyAuth;
|
|
1374
|
+
trustedRelayURLs = /* @__PURE__ */ new Set();
|
|
1416
1375
|
onRelayConnectionFailure;
|
|
1417
1376
|
onRelayConnectionSuccess;
|
|
1418
1377
|
allowConnectingToRelay;
|
|
@@ -1423,8 +1382,6 @@ var AbstractSimplePool = class {
|
|
|
1423
1382
|
this._WebSocket = opts.websocketImplementation;
|
|
1424
1383
|
this.enablePing = opts.enablePing;
|
|
1425
1384
|
this.enableReconnect = opts.enableReconnect || false;
|
|
1426
|
-
if (opts.idleTimeout)
|
|
1427
|
-
this.idleTimeout = opts.idleTimeout;
|
|
1428
1385
|
this.automaticallyAuth = opts.automaticallyAuth;
|
|
1429
1386
|
this.onRelayConnectionFailure = opts.onRelayConnectionFailure;
|
|
1430
1387
|
this.onRelayConnectionSuccess = opts.onRelayConnectionSuccess;
|
|
@@ -1436,11 +1393,10 @@ var AbstractSimplePool = class {
|
|
|
1436
1393
|
let relay = this.relays.get(url);
|
|
1437
1394
|
if (!relay) {
|
|
1438
1395
|
relay = new AbstractRelay(url, {
|
|
1439
|
-
verifyEvent: this.verifyEvent,
|
|
1396
|
+
verifyEvent: this.trustedRelayURLs.has(url) ? alwaysTrue : this.verifyEvent,
|
|
1440
1397
|
websocketImplementation: this._WebSocket,
|
|
1441
1398
|
enablePing: this.enablePing,
|
|
1442
|
-
enableReconnect: this.enableReconnect
|
|
1443
|
-
idleTimeout: this.idleTimeout
|
|
1399
|
+
enableReconnect: this.enableReconnect
|
|
1444
1400
|
});
|
|
1445
1401
|
relay.onclose = () => {
|
|
1446
1402
|
this.relays.delete(url);
|
|
@@ -1520,11 +1476,11 @@ var AbstractSimplePool = class {
|
|
|
1520
1476
|
}
|
|
1521
1477
|
};
|
|
1522
1478
|
const closesReceived = [];
|
|
1523
|
-
let handleClose = (i2,
|
|
1479
|
+
let handleClose = (i2, reason) => {
|
|
1524
1480
|
if (closesReceived[i2])
|
|
1525
1481
|
return;
|
|
1526
1482
|
handleEose(i2);
|
|
1527
|
-
closesReceived[i2] =
|
|
1483
|
+
closesReceived[i2] = reason;
|
|
1528
1484
|
if (closesReceived.filter((a) => a).length === groupedRequests.length) {
|
|
1529
1485
|
params.onclose?.(closesReceived);
|
|
1530
1486
|
handleClose = () => {
|
|
@@ -1542,7 +1498,7 @@ var AbstractSimplePool = class {
|
|
|
1542
1498
|
const allOpened = Promise.all(
|
|
1543
1499
|
groupedRequests.map(async ({ url, filters }, i2) => {
|
|
1544
1500
|
if (this.allowConnectingToRelay?.(url, ["read", filters]) === false) {
|
|
1545
|
-
handleClose(i2,
|
|
1501
|
+
handleClose(i2, "connection skipped by allowConnectingToRelay");
|
|
1546
1502
|
return;
|
|
1547
1503
|
}
|
|
1548
1504
|
let relay;
|
|
@@ -1553,7 +1509,7 @@ var AbstractSimplePool = class {
|
|
|
1553
1509
|
});
|
|
1554
1510
|
} catch (err) {
|
|
1555
1511
|
this.onRelayConnectionFailure?.(url);
|
|
1556
|
-
handleClose(i2,
|
|
1512
|
+
handleClose(i2, err?.message || String(err));
|
|
1557
1513
|
return;
|
|
1558
1514
|
}
|
|
1559
1515
|
this.onRelayConnectionSuccess?.(url);
|
|
@@ -1567,17 +1523,17 @@ var AbstractSimplePool = class {
|
|
|
1567
1523
|
...params,
|
|
1568
1524
|
oneose: () => handleEose(i2),
|
|
1569
1525
|
onclose: (reason2) => {
|
|
1570
|
-
handleClose(i2,
|
|
1526
|
+
handleClose(i2, reason2);
|
|
1571
1527
|
},
|
|
1572
1528
|
alreadyHaveEvent: localAlreadyHaveEventHandler,
|
|
1573
1529
|
eoseTimeout: params.maxWait,
|
|
1574
1530
|
abort: params.abort
|
|
1575
1531
|
});
|
|
1576
1532
|
}).catch((err) => {
|
|
1577
|
-
handleClose(i2,
|
|
1533
|
+
handleClose(i2, `auth was required and attempted, but failed with: ${err}`);
|
|
1578
1534
|
});
|
|
1579
1535
|
} else {
|
|
1580
|
-
handleClose(i2,
|
|
1536
|
+
handleClose(i2, reason);
|
|
1581
1537
|
}
|
|
1582
1538
|
},
|
|
1583
1539
|
alreadyHaveEvent: localAlreadyHaveEventHandler,
|
|
@@ -1605,7 +1561,7 @@ var AbstractSimplePool = class {
|
|
|
1605
1561
|
if (subcloser)
|
|
1606
1562
|
subcloser.close(reason);
|
|
1607
1563
|
else
|
|
1608
|
-
params.onclose?.(relays.map((
|
|
1564
|
+
params.onclose?.(relays.map((_) => reason));
|
|
1609
1565
|
}
|
|
1610
1566
|
});
|
|
1611
1567
|
return subcloser;
|
|
@@ -2125,6 +2081,7 @@ var nip10_exports = {};
|
|
|
2125
2081
|
__export(nip10_exports, {
|
|
2126
2082
|
parse: () => parse
|
|
2127
2083
|
});
|
|
2084
|
+
var HEX64 = /^[0-9a-fA-F]{64}$/;
|
|
2128
2085
|
function parse(event) {
|
|
2129
2086
|
const result = {
|
|
2130
2087
|
reply: void 0,
|
|
@@ -2137,12 +2094,12 @@ function parse(event) {
|
|
|
2137
2094
|
let maybeRoot;
|
|
2138
2095
|
for (let i2 = event.tags.length - 1; i2 >= 0; i2--) {
|
|
2139
2096
|
const tag = event.tags[i2];
|
|
2140
|
-
if (tag[0] === "e" && tag[1] &&
|
|
2097
|
+
if (tag[0] === "e" && tag[1] && HEX64.test(tag[1])) {
|
|
2141
2098
|
const [_, eTagEventId, eTagRelayUrl, eTagMarker, eTagAuthor] = tag;
|
|
2142
2099
|
const eventPointer = {
|
|
2143
2100
|
id: eTagEventId,
|
|
2144
2101
|
relays: eTagRelayUrl ? [eTagRelayUrl] : [],
|
|
2145
|
-
author: eTagAuthor &&
|
|
2102
|
+
author: eTagAuthor && HEX64.test(eTagAuthor) ? eTagAuthor : void 0
|
|
2146
2103
|
};
|
|
2147
2104
|
if (eTagMarker === "root") {
|
|
2148
2105
|
result.root = eventPointer;
|
|
@@ -2164,14 +2121,14 @@ function parse(event) {
|
|
|
2164
2121
|
result.mentions.push(eventPointer);
|
|
2165
2122
|
continue;
|
|
2166
2123
|
}
|
|
2167
|
-
if (tag[0] === "q" && tag[1] &&
|
|
2124
|
+
if (tag[0] === "q" && tag[1] && HEX64.test(tag[1])) {
|
|
2168
2125
|
const [_, eTagEventId, eTagRelayUrl] = tag;
|
|
2169
2126
|
result.quotes.push({
|
|
2170
2127
|
id: eTagEventId,
|
|
2171
2128
|
relays: eTagRelayUrl ? [eTagRelayUrl] : []
|
|
2172
2129
|
});
|
|
2173
2130
|
}
|
|
2174
|
-
if (tag[0] === "p" && tag[1] &&
|
|
2131
|
+
if (tag[0] === "p" && tag[1] && HEX64.test(tag[1])) {
|
|
2175
2132
|
result.profiles.push({
|
|
2176
2133
|
pubkey: tag[1],
|
|
2177
2134
|
relays: tag[2] ? [tag[2]] : []
|
|
@@ -2668,6 +2625,7 @@ var nip22_exports = {};
|
|
|
2668
2625
|
__export(nip22_exports, {
|
|
2669
2626
|
parse: () => parse3
|
|
2670
2627
|
});
|
|
2628
|
+
var HEX642 = /^[0-9a-fA-F]{64}$/;
|
|
2671
2629
|
function parseKind(kind) {
|
|
2672
2630
|
if (!kind)
|
|
2673
2631
|
return void 0;
|
|
@@ -2682,7 +2640,7 @@ function parseAddressPointer(value, relayUrl) {
|
|
|
2682
2640
|
if (Number.isNaN(kind))
|
|
2683
2641
|
return void 0;
|
|
2684
2642
|
const pubkey = value.slice(idx + 1, idx2);
|
|
2685
|
-
if (!
|
|
2643
|
+
if (!HEX642.test(pubkey))
|
|
2686
2644
|
return void 0;
|
|
2687
2645
|
return {
|
|
2688
2646
|
kind,
|
|
@@ -2695,12 +2653,12 @@ function parsePointer(tag) {
|
|
|
2695
2653
|
switch (tag[0]) {
|
|
2696
2654
|
case "E":
|
|
2697
2655
|
case "e":
|
|
2698
|
-
if (!tag[1] || !
|
|
2656
|
+
if (!tag[1] || !HEX642.test(tag[1]))
|
|
2699
2657
|
return void 0;
|
|
2700
2658
|
return {
|
|
2701
2659
|
id: tag[1],
|
|
2702
2660
|
relays: tag[2] ? [tag[2]] : [],
|
|
2703
|
-
author: tag[3] &&
|
|
2661
|
+
author: tag[3] && HEX642.test(tag[3]) ? tag[3] : void 0
|
|
2704
2662
|
};
|
|
2705
2663
|
case "A":
|
|
2706
2664
|
case "a":
|
|
@@ -2723,12 +2681,12 @@ function parseQuote(tag) {
|
|
|
2723
2681
|
if (tag[1].includes(":")) {
|
|
2724
2682
|
return parseAddressPointer(tag[1], tag[2]);
|
|
2725
2683
|
}
|
|
2726
|
-
if (!
|
|
2684
|
+
if (!HEX642.test(tag[1]))
|
|
2727
2685
|
return void 0;
|
|
2728
2686
|
return {
|
|
2729
2687
|
id: tag[1],
|
|
2730
2688
|
relays: tag[2] ? [tag[2]] : [],
|
|
2731
|
-
author: tag[3] &&
|
|
2689
|
+
author: tag[3] && HEX642.test(tag[3]) ? tag[3] : void 0
|
|
2732
2690
|
};
|
|
2733
2691
|
}
|
|
2734
2692
|
function choosePointer(candidates) {
|
|
@@ -2788,7 +2746,7 @@ function parse3(event) {
|
|
|
2788
2746
|
result.quotes.push(pointer);
|
|
2789
2747
|
continue;
|
|
2790
2748
|
}
|
|
2791
|
-
if ((tag[0] === "P" || tag[0] === "p") && tag[1] &&
|
|
2749
|
+
if ((tag[0] === "P" || tag[0] === "p") && tag[1] && HEX642.test(tag[1])) {
|
|
2792
2750
|
result.profiles.push({
|
|
2793
2751
|
pubkey: tag[1],
|
|
2794
2752
|
relays: tag[2] ? [tag[2]] : []
|
|
@@ -3289,10 +3247,10 @@ function validateZapRequest(zapRequestString) {
|
|
|
3289
3247
|
let p = zapRequest.tags.find(([t, v]) => t === "p" && v);
|
|
3290
3248
|
if (!p)
|
|
3291
3249
|
return "Zap request doesn't have a 'p' tag.";
|
|
3292
|
-
if (!
|
|
3250
|
+
if (!p[1].match(/^[a-f0-9]{64}$/))
|
|
3293
3251
|
return "Zap request 'p' tag is not valid hex.";
|
|
3294
3252
|
let e = zapRequest.tags.find(([t, v]) => t === "e" && v);
|
|
3295
|
-
if (e && !
|
|
3253
|
+
if (e && !e[1].match(/^[a-f0-9]{64}$/))
|
|
3296
3254
|
return "Zap request 'e' tag is not valid hex.";
|
|
3297
3255
|
let relays = zapRequest.tags.find(([t, v]) => t === "relays" && v);
|
|
3298
3256
|
if (!relays)
|