@openclaw/nostr 2026.7.2-beta.7 → 2026.7.33

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.
Files changed (159) hide show
  1. package/dist/{channel-O6-jXoT5.js → .setup/channel-B4SX7Iq6.mjs} +554 -877
  2. package/dist/{config-schema-CelPzg1N.js → .setup/config-schema-DIiXiBKr.mjs} +1 -1
  3. package/dist/.setup/inbound-direct-dm-runtime-EdLLVtkh.mjs +2 -0
  4. package/dist/{setup-adapter-BjKmSwdW.js → .setup/setup-adapter-DEU3o8MF.mjs} +1 -31
  5. package/dist/.setup/setup-plugin-api-DzlCumkz.mjs +2 -0
  6. package/dist/.setup/setup-plugin-api-csfJrRxD.mjs +111 -0
  7. package/dist/{setup-surface-BJCFpe02.js → .setup/setup-surface-DWa6-9ku.mjs} +70 -41
  8. package/dist/api.js +72 -61
  9. package/dist/channel-plugin-api.js +1 -1
  10. package/dist/doctor-contract-api.js +3 -2
  11. package/dist/setup-api.js +1 -1
  12. package/dist/setup-entry.js +2 -1
  13. package/dist/setup-plugin-api.js +1 -112
  14. package/node_modules/nostr-tools/lib/cjs/abstract-pool.js +28 -59
  15. package/node_modules/nostr-tools/lib/cjs/abstract-pool.js.map +3 -3
  16. package/node_modules/nostr-tools/lib/cjs/abstract-relay.js +7 -44
  17. package/node_modules/nostr-tools/lib/cjs/abstract-relay.js.map +2 -2
  18. package/node_modules/nostr-tools/lib/cjs/core.js +1 -17
  19. package/node_modules/nostr-tools/lib/cjs/core.js.map +3 -3
  20. package/node_modules/nostr-tools/lib/cjs/filter.js.map +1 -1
  21. package/node_modules/nostr-tools/lib/cjs/index.js +130 -172
  22. package/node_modules/nostr-tools/lib/cjs/index.js.map +4 -4
  23. package/node_modules/nostr-tools/lib/cjs/kinds.js +1 -17
  24. package/node_modules/nostr-tools/lib/cjs/kinds.js.map +3 -3
  25. package/node_modules/nostr-tools/lib/cjs/nip04.js.map +1 -1
  26. package/node_modules/nostr-tools/lib/cjs/nip10.js +5 -20
  27. package/node_modules/nostr-tools/lib/cjs/nip10.js.map +3 -3
  28. package/node_modules/nostr-tools/lib/cjs/nip13.js.map +1 -1
  29. package/node_modules/nostr-tools/lib/cjs/nip17.js +23 -30
  30. package/node_modules/nostr-tools/lib/cjs/nip17.js.map +4 -4
  31. package/node_modules/nostr-tools/lib/cjs/nip18.js +14 -21
  32. package/node_modules/nostr-tools/lib/cjs/nip18.js.map +4 -4
  33. package/node_modules/nostr-tools/lib/cjs/nip19.js.map +1 -1
  34. package/node_modules/nostr-tools/lib/cjs/nip21.js.map +1 -1
  35. package/node_modules/nostr-tools/lib/cjs/nip22.js +7 -22
  36. package/node_modules/nostr-tools/lib/cjs/nip22.js.map +3 -3
  37. package/node_modules/nostr-tools/lib/cjs/nip25.js +14 -21
  38. package/node_modules/nostr-tools/lib/cjs/nip25.js.map +4 -4
  39. package/node_modules/nostr-tools/lib/cjs/nip27.js.map +1 -1
  40. package/node_modules/nostr-tools/lib/cjs/nip28.js +14 -21
  41. package/node_modules/nostr-tools/lib/cjs/nip28.js.map +4 -4
  42. package/node_modules/nostr-tools/lib/cjs/nip29.js.map +1 -1
  43. package/node_modules/nostr-tools/lib/cjs/nip30.js.map +2 -2
  44. package/node_modules/nostr-tools/lib/cjs/nip42.js.map +2 -2
  45. package/node_modules/nostr-tools/lib/cjs/nip44.js.map +1 -1
  46. package/node_modules/nostr-tools/lib/cjs/nip45.js +9 -22
  47. package/node_modules/nostr-tools/lib/cjs/nip45.js.map +4 -4
  48. package/node_modules/nostr-tools/lib/cjs/nip46.js +70 -111
  49. package/node_modules/nostr-tools/lib/cjs/nip46.js.map +4 -4
  50. package/node_modules/nostr-tools/lib/cjs/nip47.js +18 -25
  51. package/node_modules/nostr-tools/lib/cjs/nip47.js.map +4 -4
  52. package/node_modules/nostr-tools/lib/cjs/nip57.js +16 -23
  53. package/node_modules/nostr-tools/lib/cjs/nip57.js.map +4 -4
  54. package/node_modules/nostr-tools/lib/cjs/nip58.js.map +2 -2
  55. package/node_modules/nostr-tools/lib/cjs/nip59.js +7 -16
  56. package/node_modules/nostr-tools/lib/cjs/nip59.js.map +3 -3
  57. package/node_modules/nostr-tools/lib/cjs/nip75.js.map +1 -1
  58. package/node_modules/nostr-tools/lib/cjs/nip94.js.map +1 -1
  59. package/node_modules/nostr-tools/lib/cjs/nip98.js +16 -23
  60. package/node_modules/nostr-tools/lib/cjs/nip98.js.map +4 -4
  61. package/node_modules/nostr-tools/lib/cjs/nip99.js.map +2 -2
  62. package/node_modules/nostr-tools/lib/cjs/nipb0.js +17 -38
  63. package/node_modules/nostr-tools/lib/cjs/nipb0.js.map +4 -4
  64. package/node_modules/nostr-tools/lib/cjs/nipb7.js +7 -13
  65. package/node_modules/nostr-tools/lib/cjs/nipb7.js.map +2 -2
  66. package/node_modules/nostr-tools/lib/cjs/pool.js +61 -102
  67. package/node_modules/nostr-tools/lib/cjs/pool.js.map +4 -4
  68. package/node_modules/nostr-tools/lib/cjs/pure.js +14 -21
  69. package/node_modules/nostr-tools/lib/cjs/pure.js.map +4 -4
  70. package/node_modules/nostr-tools/lib/cjs/references.js.map +1 -1
  71. package/node_modules/nostr-tools/lib/cjs/relay.js +42 -86
  72. package/node_modules/nostr-tools/lib/cjs/relay.js.map +4 -4
  73. package/node_modules/nostr-tools/lib/cjs/signer.js +14 -21
  74. package/node_modules/nostr-tools/lib/cjs/signer.js.map +4 -4
  75. package/node_modules/nostr-tools/lib/cjs/utils.js +0 -10
  76. package/node_modules/nostr-tools/lib/cjs/utils.js.map +2 -2
  77. package/node_modules/nostr-tools/lib/cjs/wasm.js +2 -16
  78. package/node_modules/nostr-tools/lib/cjs/wasm.js.map +4 -4
  79. package/node_modules/nostr-tools/lib/esm/abstract-pool.js +28 -59
  80. package/node_modules/nostr-tools/lib/esm/abstract-pool.js.map +3 -3
  81. package/node_modules/nostr-tools/lib/esm/abstract-relay.js +7 -44
  82. package/node_modules/nostr-tools/lib/esm/abstract-relay.js.map +2 -2
  83. package/node_modules/nostr-tools/lib/esm/core.js +1 -15
  84. package/node_modules/nostr-tools/lib/esm/core.js.map +3 -3
  85. package/node_modules/nostr-tools/lib/esm/filter.js.map +1 -1
  86. package/node_modules/nostr-tools/lib/esm/index.js +80 -122
  87. package/node_modules/nostr-tools/lib/esm/index.js.map +4 -4
  88. package/node_modules/nostr-tools/lib/esm/kinds.js +1 -17
  89. package/node_modules/nostr-tools/lib/esm/kinds.js.map +3 -3
  90. package/node_modules/nostr-tools/lib/esm/nip04.js.map +1 -1
  91. package/node_modules/nostr-tools/lib/esm/nip10.js +5 -18
  92. package/node_modules/nostr-tools/lib/esm/nip10.js.map +3 -3
  93. package/node_modules/nostr-tools/lib/esm/nip13.js.map +1 -1
  94. package/node_modules/nostr-tools/lib/esm/nip17.js +8 -15
  95. package/node_modules/nostr-tools/lib/esm/nip17.js.map +4 -4
  96. package/node_modules/nostr-tools/lib/esm/nip18.js +8 -15
  97. package/node_modules/nostr-tools/lib/esm/nip18.js.map +4 -4
  98. package/node_modules/nostr-tools/lib/esm/nip19.js.map +1 -1
  99. package/node_modules/nostr-tools/lib/esm/nip21.js.map +1 -1
  100. package/node_modules/nostr-tools/lib/esm/nip22.js +7 -20
  101. package/node_modules/nostr-tools/lib/esm/nip22.js.map +3 -3
  102. package/node_modules/nostr-tools/lib/esm/nip25.js +8 -15
  103. package/node_modules/nostr-tools/lib/esm/nip25.js.map +4 -4
  104. package/node_modules/nostr-tools/lib/esm/nip27.js.map +1 -1
  105. package/node_modules/nostr-tools/lib/esm/nip28.js +8 -15
  106. package/node_modules/nostr-tools/lib/esm/nip28.js.map +4 -4
  107. package/node_modules/nostr-tools/lib/esm/nip29.js.map +1 -1
  108. package/node_modules/nostr-tools/lib/esm/nip30.js.map +2 -2
  109. package/node_modules/nostr-tools/lib/esm/nip42.js.map +2 -2
  110. package/node_modules/nostr-tools/lib/esm/nip44.js.map +1 -1
  111. package/node_modules/nostr-tools/lib/esm/nip45.js +10 -23
  112. package/node_modules/nostr-tools/lib/esm/nip45.js.map +4 -4
  113. package/node_modules/nostr-tools/lib/esm/nip46.js +54 -95
  114. package/node_modules/nostr-tools/lib/esm/nip46.js.map +4 -4
  115. package/node_modules/nostr-tools/lib/esm/nip47.js +8 -15
  116. package/node_modules/nostr-tools/lib/esm/nip47.js.map +4 -4
  117. package/node_modules/nostr-tools/lib/esm/nip57.js +10 -17
  118. package/node_modules/nostr-tools/lib/esm/nip57.js.map +4 -4
  119. package/node_modules/nostr-tools/lib/esm/nip58.js.map +2 -2
  120. package/node_modules/nostr-tools/lib/esm/nip59.js +1 -10
  121. package/node_modules/nostr-tools/lib/esm/nip59.js.map +3 -3
  122. package/node_modules/nostr-tools/lib/esm/nip75.js.map +1 -1
  123. package/node_modules/nostr-tools/lib/esm/nip94.js.map +1 -1
  124. package/node_modules/nostr-tools/lib/esm/nip98.js +8 -15
  125. package/node_modules/nostr-tools/lib/esm/nip98.js.map +4 -4
  126. package/node_modules/nostr-tools/lib/esm/nip99.js.map +2 -2
  127. package/node_modules/nostr-tools/lib/esm/nipb0.js +18 -39
  128. package/node_modules/nostr-tools/lib/esm/nipb0.js.map +4 -4
  129. package/node_modules/nostr-tools/lib/esm/nipb7.js +7 -13
  130. package/node_modules/nostr-tools/lib/esm/nipb7.js.map +2 -2
  131. package/node_modules/nostr-tools/lib/esm/pool.js +54 -95
  132. package/node_modules/nostr-tools/lib/esm/pool.js.map +4 -4
  133. package/node_modules/nostr-tools/lib/esm/pure.js +8 -15
  134. package/node_modules/nostr-tools/lib/esm/pure.js.map +4 -4
  135. package/node_modules/nostr-tools/lib/esm/references.js.map +1 -1
  136. package/node_modules/nostr-tools/lib/esm/relay.js +36 -80
  137. package/node_modules/nostr-tools/lib/esm/relay.js.map +4 -4
  138. package/node_modules/nostr-tools/lib/esm/signer.js +8 -15
  139. package/node_modules/nostr-tools/lib/esm/signer.js.map +4 -4
  140. package/node_modules/nostr-tools/lib/esm/utils.js +0 -10
  141. package/node_modules/nostr-tools/lib/esm/utils.js.map +2 -2
  142. package/node_modules/nostr-tools/lib/esm/wasm.js +3 -17
  143. package/node_modules/nostr-tools/lib/esm/wasm.js.map +4 -4
  144. package/node_modules/nostr-tools/lib/nostr.bundle.js +77 -121
  145. package/node_modules/nostr-tools/lib/nostr.bundle.js.map +4 -4
  146. package/node_modules/nostr-tools/lib/types/abstract-pool.d.ts +4 -7
  147. package/node_modules/nostr-tools/lib/types/abstract-relay.d.ts +2 -7
  148. package/node_modules/nostr-tools/lib/types/helpers.d.ts +2 -0
  149. package/node_modules/nostr-tools/lib/types/kinds.d.ts +0 -2
  150. package/node_modules/nostr-tools/lib/types/nipb0.d.ts +1 -0
  151. package/node_modules/nostr-tools/lib/types/nipb7.d.ts +1 -0
  152. package/node_modules/nostr-tools/lib/types/relay.d.ts +2 -2
  153. package/node_modules/nostr-tools/lib/types/utils.d.ts +0 -4
  154. package/node_modules/nostr-tools/package.json +1 -1
  155. package/openclaw.plugin.json +5 -0
  156. package/package.json +15 -41
  157. package/dist/inbound-direct-dm-runtime-DHn9NoYN.js +0 -2
  158. package/node_modules/nostr-tools/lib/types/nipb0.test.d.ts +0 -1
  159. /package/dist/{state-account-id-CvBZ9s6P.js → .setup/state-account-id-CvBZ9s6P.mjs} +0 -0
@@ -67,7 +67,48 @@ module.exports = __toCommonJS(nostr_tools_exports);
67
67
 
68
68
  // pure.ts
69
69
  var import_secp256k1 = require("@noble/curves/secp256k1.js");
70
- var import_utils3 = require("@noble/hashes/utils.js");
70
+ var import_utils2 = require("@noble/hashes/utils.js");
71
+
72
+ // core.ts
73
+ var verifiedSymbol = Symbol("verified");
74
+ var isRecord = (obj) => obj instanceof Object;
75
+ function validateEvent(event) {
76
+ if (!isRecord(event))
77
+ return false;
78
+ if (typeof event.kind !== "number")
79
+ return false;
80
+ if (typeof event.content !== "string")
81
+ return false;
82
+ if (typeof event.created_at !== "number")
83
+ return false;
84
+ if (typeof event.pubkey !== "string")
85
+ return false;
86
+ if (!event.pubkey.match(/^[a-f0-9]{64}$/))
87
+ return false;
88
+ if (!Array.isArray(event.tags))
89
+ return false;
90
+ for (let i2 = 0; i2 < event.tags.length; i2++) {
91
+ let tag = event.tags[i2];
92
+ if (!Array.isArray(tag))
93
+ return false;
94
+ for (let j = 0; j < tag.length; j++) {
95
+ if (typeof tag[j] !== "string")
96
+ return false;
97
+ }
98
+ }
99
+ return true;
100
+ }
101
+ function sortEvents(events) {
102
+ return events.sort((a, b) => {
103
+ if (a.created_at !== b.created_at) {
104
+ return b.created_at - a.created_at;
105
+ }
106
+ return a.id.localeCompare(b.id);
107
+ });
108
+ }
109
+
110
+ // pure.ts
111
+ var import_sha2 = require("@noble/hashes/sha2.js");
71
112
 
72
113
  // utils.ts
73
114
  var utils_exports = {};
@@ -77,7 +118,6 @@ __export(utils_exports, {
77
118
  hexToBytes: () => import_utils.hexToBytes,
78
119
  insertEventIntoAscendingList: () => insertEventIntoAscendingList,
79
120
  insertEventIntoDescendingList: () => insertEventIntoDescendingList,
80
- isHex32: () => isHex32,
81
121
  mergeReverseSortedLists: () => mergeReverseSortedLists,
82
122
  normalizeURL: () => normalizeURL,
83
123
  utf8Decoder: () => utf8Decoder,
@@ -200,68 +240,20 @@ function mergeReverseSortedLists(list1, list2) {
200
240
  }
201
241
  return result;
202
242
  }
203
- function isHex32(input) {
204
- for (let i2 = 0; i2 < 64; i2++) {
205
- let cc = input.charCodeAt(i2);
206
- if (isNaN(cc) || cc < 48 || cc > 102 || cc > 57 && cc < 97) {
207
- return false;
208
- }
209
- }
210
- return true;
211
- }
212
-
213
- // core.ts
214
- var verifiedSymbol = Symbol("verified");
215
- var isRecord = (obj) => obj instanceof Object;
216
- function validateEvent(event) {
217
- if (!isRecord(event))
218
- return false;
219
- if (typeof event.kind !== "number")
220
- return false;
221
- if (typeof event.content !== "string")
222
- return false;
223
- if (typeof event.created_at !== "number")
224
- return false;
225
- if (typeof event.pubkey !== "string")
226
- return false;
227
- if (!isHex32(event.pubkey))
228
- return false;
229
- if (!Array.isArray(event.tags))
230
- return false;
231
- for (let i2 = 0; i2 < event.tags.length; i2++) {
232
- let tag = event.tags[i2];
233
- if (!Array.isArray(tag))
234
- return false;
235
- for (let j = 0; j < tag.length; j++) {
236
- if (typeof tag[j] !== "string")
237
- return false;
238
- }
239
- }
240
- return true;
241
- }
242
- function sortEvents(events) {
243
- return events.sort((a, b) => {
244
- if (a.created_at !== b.created_at) {
245
- return b.created_at - a.created_at;
246
- }
247
- return a.id.localeCompare(b.id);
248
- });
249
- }
250
243
 
251
244
  // pure.ts
252
- var import_sha2 = require("@noble/hashes/sha2.js");
253
245
  var JS = class {
254
246
  generateSecretKey() {
255
247
  return import_secp256k1.schnorr.utils.randomSecretKey();
256
248
  }
257
249
  getPublicKey(secretKey) {
258
- return (0, import_utils3.bytesToHex)(import_secp256k1.schnorr.getPublicKey(secretKey));
250
+ return (0, import_utils2.bytesToHex)(import_secp256k1.schnorr.getPublicKey(secretKey));
259
251
  }
260
252
  finalizeEvent(t, secretKey) {
261
253
  const event = t;
262
- event.pubkey = (0, import_utils3.bytesToHex)(import_secp256k1.schnorr.getPublicKey(secretKey));
254
+ event.pubkey = (0, import_utils2.bytesToHex)(import_secp256k1.schnorr.getPublicKey(secretKey));
263
255
  event.id = getEventHash(event);
264
- event.sig = (0, import_utils3.bytesToHex)(import_secp256k1.schnorr.sign((0, import_utils3.hexToBytes)(getEventHash(event)), secretKey));
256
+ event.sig = (0, import_utils2.bytesToHex)(import_secp256k1.schnorr.sign((0, import_utils2.hexToBytes)(getEventHash(event)), secretKey));
265
257
  event[verifiedSymbol] = true;
266
258
  return event;
267
259
  }
@@ -274,7 +266,7 @@ var JS = class {
274
266
  event[verifiedSymbol] = false;
275
267
  return false;
276
268
  }
277
- const valid = import_secp256k1.schnorr.verify((0, import_utils3.hexToBytes)(event.sig), (0, import_utils3.hexToBytes)(hash), (0, import_utils3.hexToBytes)(event.pubkey));
269
+ const valid = import_secp256k1.schnorr.verify((0, import_utils2.hexToBytes)(event.sig), (0, import_utils2.hexToBytes)(hash), (0, import_utils2.hexToBytes)(event.pubkey));
278
270
  event[verifiedSymbol] = valid;
279
271
  return valid;
280
272
  } catch (err) {
@@ -290,7 +282,7 @@ function serializeEvent(evt) {
290
282
  }
291
283
  function getEventHash(event) {
292
284
  let eventHash = (0, import_sha2.sha256)(utf8Encoder.encode(serializeEvent(event)));
293
- return (0, import_utils3.bytesToHex)(eventHash);
285
+ return (0, import_utils2.bytesToHex)(eventHash);
294
286
  }
295
287
  var i = new JS();
296
288
  var generateSecretKey = i.generateSecretKey;
@@ -352,7 +344,6 @@ __export(kinds_exports, {
352
344
  Emojisets: () => Emojisets,
353
345
  EncryptedDirectMessage: () => EncryptedDirectMessage,
354
346
  EventDeletion: () => EventDeletion,
355
- FavoriteFollowSets: () => FavoriteFollowSets,
356
347
  FavoritePodcasts: () => FavoritePodcasts,
357
348
  FavoriteRelays: () => FavoriteRelays,
358
349
  FedimintAnnouncement: () => FedimintAnnouncement,
@@ -625,7 +616,6 @@ var PrivateEventRelayList = 10013;
625
616
  var InterestsList = 10015;
626
617
  var NutZapInfo = 10019;
627
618
  var MediaFollows = 10020;
628
- var FavoriteFollowSets = 10021;
629
619
  var UserEmojiList = 10030;
630
620
  var DecoupledKeyAnnouncement = 10044;
631
621
  var DirectMessageRelaysList = 10050;
@@ -874,14 +864,12 @@ var AbstractRelay = class {
874
864
  openSubs = /* @__PURE__ */ new Map();
875
865
  enablePing;
876
866
  enableReconnect;
877
- idleTimeout = 0;
878
867
  idleSince = Date.now();
879
868
  ongoingOperations = 0;
880
869
  reconnectTimeoutHandle;
881
870
  pingIntervalHandle;
882
871
  reconnectAttempts = 0;
883
872
  skipReconnection = false;
884
- idleTimeoutHandle;
885
873
  connectionPromise;
886
874
  openCountRequests = /* @__PURE__ */ new Map();
887
875
  openEventPublishes = /* @__PURE__ */ new Map();
@@ -897,8 +885,6 @@ var AbstractRelay = class {
897
885
  this._WebSocket = opts.websocketImplementation || WebSocket;
898
886
  this.enablePing = opts.enablePing;
899
887
  this.enableReconnect = opts.enableReconnect || false;
900
- if (opts.idleTimeout)
901
- this.idleTimeout = opts.idleTimeout;
902
888
  }
903
889
  static async connect(url, opts) {
904
890
  const relay = new AbstractRelay(url, opts);
@@ -922,22 +908,6 @@ var AbstractRelay = class {
922
908
  get connected() {
923
909
  return this._connected;
924
910
  }
925
- clearIdleTimeout() {
926
- if (this.idleTimeoutHandle) {
927
- clearTimeout(this.idleTimeoutHandle);
928
- this.idleTimeoutHandle = void 0;
929
- }
930
- }
931
- scheduleIdleClose() {
932
- this.clearIdleTimeout();
933
- if (this.idleTimeout > 0) {
934
- this.idleTimeoutHandle = setTimeout(() => {
935
- if (this.ongoingOperations === 0 && this.idleSince) {
936
- this.close();
937
- }
938
- }, this.idleTimeout);
939
- }
940
- }
941
911
  async reconnect() {
942
912
  const backoff = this.resubscribeBackoff[Math.min(this.reconnectAttempts, this.resubscribeBackoff.length - 1)];
943
913
  this.reconnectAttempts++;
@@ -949,11 +919,6 @@ var AbstractRelay = class {
949
919
  }, backoff);
950
920
  }
951
921
  handleHardClose(reason) {
952
- if (this.ws) {
953
- this.ws.onopen = null;
954
- this.ws.onerror = null;
955
- this.ws.onclose = null;
956
- }
957
922
  if (this.pingIntervalHandle) {
958
923
  clearInterval(this.pingIntervalHandle);
959
924
  this.pingIntervalHandle = void 0;
@@ -961,7 +926,6 @@ var AbstractRelay = class {
961
926
  this._connected = false;
962
927
  this.connectionPromise = void 0;
963
928
  this.idleSince = void 0;
964
- this.clearIdleTimeout();
965
929
  if (this.enableReconnect && !this.skipReconnection) {
966
930
  this.reconnect();
967
931
  } else {
@@ -984,6 +948,7 @@ var AbstractRelay = class {
984
948
  if (this.reconnectAttempts === 0) {
985
949
  this.skipReconnection = true;
986
950
  }
951
+ this.onclose?.();
987
952
  this.handleHardClose("relay connection timed out");
988
953
  }, opts.timeout);
989
954
  }
@@ -1029,6 +994,7 @@ var AbstractRelay = class {
1029
994
  if (this.reconnectAttempts === 0) {
1030
995
  this.skipReconnection = true;
1031
996
  }
997
+ this.onclose?.();
1032
998
  this.handleHardClose("relay connection failed");
1033
999
  };
1034
1000
  this.ws.onclose = (ev) => {
@@ -1117,7 +1083,6 @@ var AbstractRelay = class {
1117
1083
  }
1118
1084
  async publish(event) {
1119
1085
  this.idleSince = void 0;
1120
- this.clearIdleTimeout();
1121
1086
  this.ongoingOperations++;
1122
1087
  const ret = new Promise((resolve, reject) => {
1123
1088
  const timeout = setTimeout(() => {
@@ -1139,10 +1104,8 @@ var AbstractRelay = class {
1139
1104
  }
1140
1105
  }
1141
1106
  this.ongoingOperations--;
1142
- if (this.ongoingOperations === 0) {
1107
+ if (this.ongoingOperations === 0)
1143
1108
  this.idleSince = Date.now();
1144
- this.scheduleIdleClose();
1145
- }
1146
1109
  return ret;
1147
1110
  }
1148
1111
  async count(filters, params) {
@@ -1168,7 +1131,6 @@ var AbstractRelay = class {
1168
1131
  subscribe(filters, params) {
1169
1132
  if (params.label !== "<forced-ping>") {
1170
1133
  this.idleSince = void 0;
1171
- this.clearIdleTimeout();
1172
1134
  this.ongoingOperations++;
1173
1135
  }
1174
1136
  const sub = this.prepareSubscription(filters, params);
@@ -1197,17 +1159,10 @@ var AbstractRelay = class {
1197
1159
  }
1198
1160
  this.closeAllSubscriptions("relay connection closed by us");
1199
1161
  this._connected = false;
1200
- this.connectionPromise = void 0;
1201
1162
  this.idleSince = void 0;
1202
- this.clearIdleTimeout();
1203
1163
  this.onclose?.();
1204
- if (this.ws) {
1205
- this.ws.onopen = null;
1206
- this.ws.onerror = null;
1207
- this.ws.onclose = null;
1208
- if (this.ws.readyState !== this._WebSocket.CLOSING && this.ws.readyState !== this._WebSocket.CLOSED) {
1209
- this.ws.close();
1210
- }
1164
+ if (this.ws?.readyState === this._WebSocket.OPEN) {
1165
+ this.ws?.close();
1211
1166
  }
1212
1167
  }
1213
1168
  _onmessage(ev) {
@@ -1234,7 +1189,7 @@ var AbstractRelay = class {
1234
1189
  case "EVENT": {
1235
1190
  const so = this.openSubs.get(data[1]);
1236
1191
  const event = data[2];
1237
- if (matchFilters(so.filters, event) && this.verifyEvent(event, this.url)) {
1192
+ if (this.verifyEvent(event) && matchFilters(so.filters, event)) {
1238
1193
  so.onevent(event);
1239
1194
  } else {
1240
1195
  so.oninvalidevent?.(event);
@@ -1382,10 +1337,8 @@ var Subscription = class {
1382
1337
  }
1383
1338
  this.relay.openSubs.delete(this.id);
1384
1339
  this.relay.ongoingOperations--;
1385
- if (this.relay.ongoingOperations === 0) {
1340
+ if (this.relay.ongoingOperations === 0)
1386
1341
  this.relay.idleSince = Date.now();
1387
- this.relay.scheduleIdleClose();
1388
- }
1389
1342
  this.onclose?.(reason);
1390
1343
  }
1391
1344
  };
@@ -1407,9 +1360,15 @@ var Relay = class extends AbstractRelay {
1407
1360
  }
1408
1361
  };
1409
1362
 
1363
+ // helpers.ts
1364
+ var alwaysTrue = (t) => {
1365
+ t[verifiedSymbol] = true;
1366
+ return true;
1367
+ };
1368
+
1410
1369
  // nip45.ts
1411
1370
  var import_sha22 = require("@noble/hashes/sha2.js");
1412
- var import_utils6 = require("@noble/hashes/utils.js");
1371
+ var import_utils5 = require("@noble/hashes/utils.js");
1413
1372
  var M = 256;
1414
1373
  var HLL_HEX_LENGTH = M * 2;
1415
1374
  var utf8Encoder2 = new TextEncoder();
@@ -1433,7 +1392,7 @@ function newHll() {
1433
1392
  return new Uint8Array(M);
1434
1393
  }
1435
1394
  function hllDecode(hex) {
1436
- if (hex.length !== HLL_HEX_LENGTH || !/^[0-9a-f]+$/.test(hex))
1395
+ if (hex.length !== HLL_HEX_LENGTH || !/^[0-9a-fA-F]+$/.test(hex))
1437
1396
  return void 0;
1438
1397
  const registers = new Uint8Array(M);
1439
1398
  for (let i2 = 0; i2 < M; i2++) {
@@ -1472,8 +1431,8 @@ var AbstractSimplePool = class {
1472
1431
  verifyEvent;
1473
1432
  enablePing;
1474
1433
  enableReconnect;
1475
- idleTimeout = 2e4;
1476
1434
  automaticallyAuth;
1435
+ trustedRelayURLs = /* @__PURE__ */ new Set();
1477
1436
  onRelayConnectionFailure;
1478
1437
  onRelayConnectionSuccess;
1479
1438
  allowConnectingToRelay;
@@ -1484,8 +1443,6 @@ var AbstractSimplePool = class {
1484
1443
  this._WebSocket = opts.websocketImplementation;
1485
1444
  this.enablePing = opts.enablePing;
1486
1445
  this.enableReconnect = opts.enableReconnect || false;
1487
- if (opts.idleTimeout)
1488
- this.idleTimeout = opts.idleTimeout;
1489
1446
  this.automaticallyAuth = opts.automaticallyAuth;
1490
1447
  this.onRelayConnectionFailure = opts.onRelayConnectionFailure;
1491
1448
  this.onRelayConnectionSuccess = opts.onRelayConnectionSuccess;
@@ -1497,11 +1454,10 @@ var AbstractSimplePool = class {
1497
1454
  let relay = this.relays.get(url);
1498
1455
  if (!relay) {
1499
1456
  relay = new AbstractRelay(url, {
1500
- verifyEvent: this.verifyEvent,
1457
+ verifyEvent: this.trustedRelayURLs.has(url) ? alwaysTrue : this.verifyEvent,
1501
1458
  websocketImplementation: this._WebSocket,
1502
1459
  enablePing: this.enablePing,
1503
- enableReconnect: this.enableReconnect,
1504
- idleTimeout: this.idleTimeout
1460
+ enableReconnect: this.enableReconnect
1505
1461
  });
1506
1462
  relay.onclose = () => {
1507
1463
  this.relays.delete(url);
@@ -1581,11 +1537,11 @@ var AbstractSimplePool = class {
1581
1537
  }
1582
1538
  };
1583
1539
  const closesReceived = [];
1584
- let handleClose = (i2, url, reason) => {
1540
+ let handleClose = (i2, reason) => {
1585
1541
  if (closesReceived[i2])
1586
1542
  return;
1587
1543
  handleEose(i2);
1588
- closesReceived[i2] = { url, reason };
1544
+ closesReceived[i2] = reason;
1589
1545
  if (closesReceived.filter((a) => a).length === groupedRequests.length) {
1590
1546
  params.onclose?.(closesReceived);
1591
1547
  handleClose = () => {
@@ -1603,7 +1559,7 @@ var AbstractSimplePool = class {
1603
1559
  const allOpened = Promise.all(
1604
1560
  groupedRequests.map(async ({ url, filters }, i2) => {
1605
1561
  if (this.allowConnectingToRelay?.(url, ["read", filters]) === false) {
1606
- handleClose(i2, url, "connection skipped by allowConnectingToRelay");
1562
+ handleClose(i2, "connection skipped by allowConnectingToRelay");
1607
1563
  return;
1608
1564
  }
1609
1565
  let relay;
@@ -1614,7 +1570,7 @@ var AbstractSimplePool = class {
1614
1570
  });
1615
1571
  } catch (err) {
1616
1572
  this.onRelayConnectionFailure?.(url);
1617
- handleClose(i2, url, err?.message || String(err));
1573
+ handleClose(i2, err?.message || String(err));
1618
1574
  return;
1619
1575
  }
1620
1576
  this.onRelayConnectionSuccess?.(url);
@@ -1628,17 +1584,17 @@ var AbstractSimplePool = class {
1628
1584
  ...params,
1629
1585
  oneose: () => handleEose(i2),
1630
1586
  onclose: (reason2) => {
1631
- handleClose(i2, url, reason2);
1587
+ handleClose(i2, reason2);
1632
1588
  },
1633
1589
  alreadyHaveEvent: localAlreadyHaveEventHandler,
1634
1590
  eoseTimeout: params.maxWait,
1635
1591
  abort: params.abort
1636
1592
  });
1637
1593
  }).catch((err) => {
1638
- handleClose(i2, url, `auth was required and attempted, but failed with: ${err}`);
1594
+ handleClose(i2, `auth was required and attempted, but failed with: ${err}`);
1639
1595
  });
1640
1596
  } else {
1641
- handleClose(i2, url, reason);
1597
+ handleClose(i2, reason);
1642
1598
  }
1643
1599
  },
1644
1600
  alreadyHaveEvent: localAlreadyHaveEventHandler,
@@ -1666,7 +1622,7 @@ var AbstractSimplePool = class {
1666
1622
  if (subcloser)
1667
1623
  subcloser.close(reason);
1668
1624
  else
1669
- params.onclose?.(relays.map((url) => ({ url, reason })));
1625
+ params.onclose?.(relays.map((_) => reason));
1670
1626
  }
1671
1627
  });
1672
1628
  return subcloser;
@@ -1823,7 +1779,7 @@ __export(nip19_exports, {
1823
1779
  npubEncode: () => npubEncode,
1824
1780
  nsecEncode: () => nsecEncode
1825
1781
  });
1826
- var import_utils8 = require("@noble/hashes/utils.js");
1782
+ var import_utils7 = require("@noble/hashes/utils.js");
1827
1783
  var import_base = require("@scure/base");
1828
1784
  var NostrTypeGuard = {
1829
1785
  isNProfile: (value) => /^nprofile1[a-z\d]+$/.test(value || ""),
@@ -1866,7 +1822,7 @@ function decode(code) {
1866
1822
  return {
1867
1823
  type: "nprofile",
1868
1824
  data: {
1869
- pubkey: (0, import_utils8.bytesToHex)(tlv[0][0]),
1825
+ pubkey: (0, import_utils7.bytesToHex)(tlv[0][0]),
1870
1826
  relays: tlv[1] ? tlv[1].map((d) => utf8Decoder.decode(d)) : []
1871
1827
  }
1872
1828
  };
@@ -1884,10 +1840,10 @@ function decode(code) {
1884
1840
  return {
1885
1841
  type: "nevent",
1886
1842
  data: {
1887
- id: (0, import_utils8.bytesToHex)(tlv[0][0]),
1843
+ id: (0, import_utils7.bytesToHex)(tlv[0][0]),
1888
1844
  relays: tlv[1] ? tlv[1].map((d) => utf8Decoder.decode(d)) : [],
1889
- author: tlv[2]?.[0] ? (0, import_utils8.bytesToHex)(tlv[2][0]) : void 0,
1890
- kind: tlv[3]?.[0] ? parseInt((0, import_utils8.bytesToHex)(tlv[3][0]), 16) : void 0
1845
+ author: tlv[2]?.[0] ? (0, import_utils7.bytesToHex)(tlv[2][0]) : void 0,
1846
+ kind: tlv[3]?.[0] ? parseInt((0, import_utils7.bytesToHex)(tlv[3][0]), 16) : void 0
1891
1847
  }
1892
1848
  };
1893
1849
  }
@@ -1907,8 +1863,8 @@ function decode(code) {
1907
1863
  type: "naddr",
1908
1864
  data: {
1909
1865
  identifier: utf8Decoder.decode(tlv[0][0]),
1910
- pubkey: (0, import_utils8.bytesToHex)(tlv[2][0]),
1911
- kind: parseInt((0, import_utils8.bytesToHex)(tlv[3][0]), 16),
1866
+ pubkey: (0, import_utils7.bytesToHex)(tlv[2][0]),
1867
+ kind: parseInt((0, import_utils7.bytesToHex)(tlv[3][0]), 16),
1912
1868
  relays: tlv[1] ? tlv[1].map((d) => utf8Decoder.decode(d)) : []
1913
1869
  }
1914
1870
  };
@@ -1917,7 +1873,7 @@ function decode(code) {
1917
1873
  return { type: prefix, data };
1918
1874
  case "npub":
1919
1875
  case "note":
1920
- return { type: prefix, data: (0, import_utils8.bytesToHex)(data) };
1876
+ return { type: prefix, data: (0, import_utils7.bytesToHex)(data) };
1921
1877
  default:
1922
1878
  throw new Error(`unknown prefix ${prefix}`);
1923
1879
  }
@@ -1943,10 +1899,10 @@ function nsecEncode(key) {
1943
1899
  return encodeBytes("nsec", key);
1944
1900
  }
1945
1901
  function npubEncode(hex) {
1946
- return encodeBytes("npub", (0, import_utils8.hexToBytes)(hex));
1902
+ return encodeBytes("npub", (0, import_utils7.hexToBytes)(hex));
1947
1903
  }
1948
1904
  function noteEncode(hex) {
1949
- return encodeBytes("note", (0, import_utils8.hexToBytes)(hex));
1905
+ return encodeBytes("note", (0, import_utils7.hexToBytes)(hex));
1950
1906
  }
1951
1907
  function encodeBech32(prefix, data) {
1952
1908
  let words = import_base.bech32.toWords(data);
@@ -1957,7 +1913,7 @@ function encodeBytes(prefix, bytes) {
1957
1913
  }
1958
1914
  function nprofileEncode(profile) {
1959
1915
  let data = encodeTLV({
1960
- 0: [(0, import_utils8.hexToBytes)(profile.pubkey)],
1916
+ 0: [(0, import_utils7.hexToBytes)(profile.pubkey)],
1961
1917
  1: (profile.relays || []).map((url) => utf8Encoder.encode(url))
1962
1918
  });
1963
1919
  return encodeBech32("nprofile", data);
@@ -1968,9 +1924,9 @@ function neventEncode(event) {
1968
1924
  kindArray = integerToUint8Array(event.kind);
1969
1925
  }
1970
1926
  let data = encodeTLV({
1971
- 0: [(0, import_utils8.hexToBytes)(event.id)],
1927
+ 0: [(0, import_utils7.hexToBytes)(event.id)],
1972
1928
  1: (event.relays || []).map((url) => utf8Encoder.encode(url)),
1973
- 2: event.author ? [(0, import_utils8.hexToBytes)(event.author)] : [],
1929
+ 2: event.author ? [(0, import_utils7.hexToBytes)(event.author)] : [],
1974
1930
  3: kindArray ? [new Uint8Array(kindArray)] : []
1975
1931
  });
1976
1932
  return encodeBech32("nevent", data);
@@ -1981,7 +1937,7 @@ function naddrEncode(addr) {
1981
1937
  let data = encodeTLV({
1982
1938
  0: [utf8Encoder.encode(addr.identifier)],
1983
1939
  1: (addr.relays || []).map((url) => utf8Encoder.encode(url)),
1984
- 2: [(0, import_utils8.hexToBytes)(addr.pubkey)],
1940
+ 2: [(0, import_utils7.hexToBytes)(addr.pubkey)],
1985
1941
  3: [new Uint8Array(kind)]
1986
1942
  });
1987
1943
  return encodeBech32("naddr", data);
@@ -1997,7 +1953,7 @@ function encodeTLV(tlv) {
1997
1953
  entries.push(entry);
1998
1954
  });
1999
1955
  });
2000
- return (0, import_utils8.concatBytes)(...entries);
1956
+ return (0, import_utils7.concatBytes)(...entries);
2001
1957
  }
2002
1958
 
2003
1959
  // references.ts
@@ -2095,15 +2051,15 @@ __export(nip04_exports, {
2095
2051
  decrypt: () => decrypt,
2096
2052
  encrypt: () => encrypt
2097
2053
  });
2098
- var import_utils10 = require("@noble/hashes/utils.js");
2054
+ var import_utils9 = require("@noble/hashes/utils.js");
2099
2055
  var import_secp256k12 = require("@noble/curves/secp256k1.js");
2100
2056
  var import_aes = require("@noble/ciphers/aes.js");
2101
2057
  var import_base2 = require("@scure/base");
2102
2058
  function encrypt(secretKey, pubkey, text) {
2103
- const privkey = secretKey instanceof Uint8Array ? secretKey : (0, import_utils10.hexToBytes)(secretKey);
2104
- const key = import_secp256k12.secp256k1.getSharedSecret(privkey, (0, import_utils10.hexToBytes)("02" + pubkey));
2059
+ const privkey = secretKey instanceof Uint8Array ? secretKey : (0, import_utils9.hexToBytes)(secretKey);
2060
+ const key = import_secp256k12.secp256k1.getSharedSecret(privkey, (0, import_utils9.hexToBytes)("02" + pubkey));
2105
2061
  const normalizedKey = getNormalizedX(key);
2106
- let iv = Uint8Array.from((0, import_utils10.randomBytes)(16));
2062
+ let iv = Uint8Array.from((0, import_utils9.randomBytes)(16));
2107
2063
  let plaintext = utf8Encoder.encode(text);
2108
2064
  let ciphertext = (0, import_aes.cbc)(normalizedKey, iv).encrypt(plaintext);
2109
2065
  let ctb64 = import_base2.base64.encode(new Uint8Array(ciphertext));
@@ -2111,9 +2067,9 @@ function encrypt(secretKey, pubkey, text) {
2111
2067
  return `${ctb64}?iv=${ivb64}`;
2112
2068
  }
2113
2069
  function decrypt(secretKey, pubkey, data) {
2114
- const privkey = secretKey instanceof Uint8Array ? secretKey : (0, import_utils10.hexToBytes)(secretKey);
2070
+ const privkey = secretKey instanceof Uint8Array ? secretKey : (0, import_utils9.hexToBytes)(secretKey);
2115
2071
  let [ctb64, ivb64] = data.split("?iv=");
2116
- let key = import_secp256k12.secp256k1.getSharedSecret(privkey, (0, import_utils10.hexToBytes)("02" + pubkey));
2072
+ let key = import_secp256k12.secp256k1.getSharedSecret(privkey, (0, import_utils9.hexToBytes)("02" + pubkey));
2117
2073
  let normalizedKey = getNormalizedX(key);
2118
2074
  let iv = import_base2.base64.decode(ivb64);
2119
2075
  let ciphertext = import_base2.base64.decode(ctb64);
@@ -2186,6 +2142,7 @@ var nip10_exports = {};
2186
2142
  __export(nip10_exports, {
2187
2143
  parse: () => parse
2188
2144
  });
2145
+ var HEX64 = /^[0-9a-fA-F]{64}$/;
2189
2146
  function parse(event) {
2190
2147
  const result = {
2191
2148
  reply: void 0,
@@ -2198,12 +2155,12 @@ function parse(event) {
2198
2155
  let maybeRoot;
2199
2156
  for (let i2 = event.tags.length - 1; i2 >= 0; i2--) {
2200
2157
  const tag = event.tags[i2];
2201
- if (tag[0] === "e" && tag[1] && isHex32(tag[1])) {
2158
+ if (tag[0] === "e" && tag[1] && HEX64.test(tag[1])) {
2202
2159
  const [_, eTagEventId, eTagRelayUrl, eTagMarker, eTagAuthor] = tag;
2203
2160
  const eventPointer = {
2204
2161
  id: eTagEventId,
2205
2162
  relays: eTagRelayUrl ? [eTagRelayUrl] : [],
2206
- author: eTagAuthor && isHex32(eTagAuthor) ? eTagAuthor : void 0
2163
+ author: eTagAuthor && HEX64.test(eTagAuthor) ? eTagAuthor : void 0
2207
2164
  };
2208
2165
  if (eTagMarker === "root") {
2209
2166
  result.root = eventPointer;
@@ -2225,14 +2182,14 @@ function parse(event) {
2225
2182
  result.mentions.push(eventPointer);
2226
2183
  continue;
2227
2184
  }
2228
- if (tag[0] === "q" && tag[1] && isHex32(tag[1])) {
2185
+ if (tag[0] === "q" && tag[1] && HEX64.test(tag[1])) {
2229
2186
  const [_, eTagEventId, eTagRelayUrl] = tag;
2230
2187
  result.quotes.push({
2231
2188
  id: eTagEventId,
2232
2189
  relays: eTagRelayUrl ? [eTagRelayUrl] : []
2233
2190
  });
2234
2191
  }
2235
- if (tag[0] === "p" && tag[1] && isHex32(tag[1])) {
2192
+ if (tag[0] === "p" && tag[1] && HEX64.test(tag[1])) {
2236
2193
  result.profiles.push({
2237
2194
  pubkey: tag[1],
2238
2195
  relays: tag[2] ? [tag[2]] : []
@@ -2312,7 +2269,7 @@ __export(nip13_exports, {
2312
2269
  getPow: () => getPow,
2313
2270
  minePow: () => minePow
2314
2271
  });
2315
- var import_utils13 = require("@noble/hashes/utils.js");
2272
+ var import_utils11 = require("@noble/hashes/utils.js");
2316
2273
  var import_sha23 = require("@noble/hashes/sha2.js");
2317
2274
  function getPow(hex) {
2318
2275
  let count = 0;
@@ -2356,7 +2313,7 @@ function minePow(unsigned, difficulty) {
2356
2313
  utf8Encoder.encode(JSON.stringify([0, event.pubkey, event.created_at, event.kind, event.tags, event.content]))
2357
2314
  );
2358
2315
  if (getPowFromBytes(hash) >= difficulty) {
2359
- event.id = (0, import_utils13.bytesToHex)(hash);
2316
+ event.id = (0, import_utils11.bytesToHex)(hash);
2360
2317
  break;
2361
2318
  }
2362
2319
  }
@@ -2393,18 +2350,18 @@ __export(nip44_exports, {
2393
2350
  v2: () => v2
2394
2351
  });
2395
2352
  var import_chacha = require("@noble/ciphers/chacha.js");
2396
- var import_utils15 = require("@noble/ciphers/utils.js");
2353
+ var import_utils13 = require("@noble/ciphers/utils.js");
2397
2354
  var import_secp256k13 = require("@noble/curves/secp256k1.js");
2398
2355
  var import_hkdf = require("@noble/hashes/hkdf.js");
2399
2356
  var import_hmac = require("@noble/hashes/hmac.js");
2400
2357
  var import_sha24 = require("@noble/hashes/sha2.js");
2401
- var import_utils16 = require("@noble/hashes/utils.js");
2358
+ var import_utils14 = require("@noble/hashes/utils.js");
2402
2359
  var import_base3 = require("@scure/base");
2403
2360
  var minPlaintextSize = 1;
2404
2361
  var maxPlaintextSize = 4294967295;
2405
2362
  var extendedPrefixThreshold = 65536;
2406
2363
  function getConversationKey(privkeyA, pubkeyB) {
2407
- const sharedX = import_secp256k13.secp256k1.getSharedSecret(privkeyA, (0, import_utils16.hexToBytes)("02" + pubkeyB)).subarray(1, 33);
2364
+ const sharedX = import_secp256k13.secp256k1.getSharedSecret(privkeyA, (0, import_utils14.hexToBytes)("02" + pubkeyB)).subarray(1, 33);
2408
2365
  return (0, import_hkdf.extract)(import_sha24.sha256, sharedX, utf8Encoder.encode("nip44-v2"));
2409
2366
  }
2410
2367
  function getMessageKeys(conversationKey, nonce) {
@@ -2443,9 +2400,9 @@ function pad(plaintext) {
2443
2400
  const unpaddedLen = unpadded.length;
2444
2401
  if (unpaddedLen < minPlaintextSize || unpaddedLen > maxPlaintextSize)
2445
2402
  throw new Error("invalid plaintext size: must be between 1 and 4294967295 bytes");
2446
- const prefix = unpaddedLen >= extendedPrefixThreshold ? (0, import_utils16.concatBytes)(new Uint8Array([0, 0]), writeU32BE(unpaddedLen)) : writeU16BE(unpaddedLen);
2403
+ const prefix = unpaddedLen >= extendedPrefixThreshold ? (0, import_utils14.concatBytes)(new Uint8Array([0, 0]), writeU32BE(unpaddedLen)) : writeU16BE(unpaddedLen);
2447
2404
  const suffix = new Uint8Array(calcPaddedLen(unpaddedLen) - unpaddedLen);
2448
- return (0, import_utils16.concatBytes)(prefix, unpadded, suffix);
2405
+ return (0, import_utils14.concatBytes)(prefix, unpadded, suffix);
2449
2406
  }
2450
2407
  function unpad(padded) {
2451
2408
  const dv = new DataView(padded.buffer, padded.byteOffset, padded.byteLength);
@@ -2469,7 +2426,7 @@ function unpad(padded) {
2469
2426
  function hmacAad(key, message, aad) {
2470
2427
  if (aad.length !== 32)
2471
2428
  throw new Error("AAD associated data must be 32 bytes");
2472
- const combined = (0, import_utils16.concatBytes)(aad, message);
2429
+ const combined = (0, import_utils14.concatBytes)(aad, message);
2473
2430
  return (0, import_hmac.hmac)(import_sha24.sha256, key, combined);
2474
2431
  }
2475
2432
  function decodePayload(payload) {
@@ -2498,18 +2455,18 @@ function decodePayload(payload) {
2498
2455
  mac: data.subarray(-32)
2499
2456
  };
2500
2457
  }
2501
- function encrypt2(plaintext, conversationKey, nonce = (0, import_utils16.randomBytes)(32)) {
2458
+ function encrypt2(plaintext, conversationKey, nonce = (0, import_utils14.randomBytes)(32)) {
2502
2459
  const { chacha_key, chacha_nonce, hmac_key } = getMessageKeys(conversationKey, nonce);
2503
2460
  const padded = pad(plaintext);
2504
2461
  const ciphertext = (0, import_chacha.chacha20)(chacha_key, chacha_nonce, padded);
2505
2462
  const mac = hmacAad(hmac_key, ciphertext, nonce);
2506
- return import_base3.base64.encode((0, import_utils16.concatBytes)(new Uint8Array([2]), nonce, ciphertext, mac));
2463
+ return import_base3.base64.encode((0, import_utils14.concatBytes)(new Uint8Array([2]), nonce, ciphertext, mac));
2507
2464
  }
2508
2465
  function decrypt2(payload, conversationKey) {
2509
2466
  const { nonce, ciphertext, mac } = decodePayload(payload);
2510
2467
  const { chacha_key, chacha_nonce, hmac_key } = getMessageKeys(conversationKey, nonce);
2511
2468
  const calculatedMac = hmacAad(hmac_key, ciphertext, nonce);
2512
- if (!(0, import_utils15.equalBytes)(calculatedMac, mac))
2469
+ if (!(0, import_utils13.equalBytes)(calculatedMac, mac))
2513
2470
  throw new Error("invalid MAC");
2514
2471
  const padded = (0, import_chacha.chacha20)(chacha_key, chacha_nonce, ciphertext);
2515
2472
  return unpad(padded);
@@ -2729,6 +2686,7 @@ var nip22_exports = {};
2729
2686
  __export(nip22_exports, {
2730
2687
  parse: () => parse3
2731
2688
  });
2689
+ var HEX642 = /^[0-9a-fA-F]{64}$/;
2732
2690
  function parseKind(kind) {
2733
2691
  if (!kind)
2734
2692
  return void 0;
@@ -2743,7 +2701,7 @@ function parseAddressPointer(value, relayUrl) {
2743
2701
  if (Number.isNaN(kind))
2744
2702
  return void 0;
2745
2703
  const pubkey = value.slice(idx + 1, idx2);
2746
- if (!isHex32(pubkey))
2704
+ if (!HEX642.test(pubkey))
2747
2705
  return void 0;
2748
2706
  return {
2749
2707
  kind,
@@ -2756,12 +2714,12 @@ function parsePointer(tag) {
2756
2714
  switch (tag[0]) {
2757
2715
  case "E":
2758
2716
  case "e":
2759
- if (!tag[1] || !isHex32(tag[1]))
2717
+ if (!tag[1] || !HEX642.test(tag[1]))
2760
2718
  return void 0;
2761
2719
  return {
2762
2720
  id: tag[1],
2763
2721
  relays: tag[2] ? [tag[2]] : [],
2764
- author: tag[3] && isHex32(tag[3]) ? tag[3] : void 0
2722
+ author: tag[3] && HEX642.test(tag[3]) ? tag[3] : void 0
2765
2723
  };
2766
2724
  case "A":
2767
2725
  case "a":
@@ -2784,12 +2742,12 @@ function parseQuote(tag) {
2784
2742
  if (tag[1].includes(":")) {
2785
2743
  return parseAddressPointer(tag[1], tag[2]);
2786
2744
  }
2787
- if (!isHex32(tag[1]))
2745
+ if (!HEX642.test(tag[1]))
2788
2746
  return void 0;
2789
2747
  return {
2790
2748
  id: tag[1],
2791
2749
  relays: tag[2] ? [tag[2]] : [],
2792
- author: tag[3] && isHex32(tag[3]) ? tag[3] : void 0
2750
+ author: tag[3] && HEX642.test(tag[3]) ? tag[3] : void 0
2793
2751
  };
2794
2752
  }
2795
2753
  function choosePointer(candidates) {
@@ -2849,7 +2807,7 @@ function parse3(event) {
2849
2807
  result.quotes.push(pointer);
2850
2808
  continue;
2851
2809
  }
2852
- if ((tag[0] === "P" || tag[0] === "p") && tag[1] && isHex32(tag[1])) {
2810
+ if ((tag[0] === "P" || tag[0] === "p") && tag[1] && HEX642.test(tag[1])) {
2853
2811
  result.profiles.push({
2854
2812
  pubkey: tag[1],
2855
2813
  relays: tag[2] ? [tag[2]] : []
@@ -3350,10 +3308,10 @@ function validateZapRequest(zapRequestString) {
3350
3308
  let p = zapRequest.tags.find(([t, v]) => t === "p" && v);
3351
3309
  if (!p)
3352
3310
  return "Zap request doesn't have a 'p' tag.";
3353
- if (!isHex32(p[1]))
3311
+ if (!p[1].match(/^[a-f0-9]{64}$/))
3354
3312
  return "Zap request 'p' tag is not valid hex.";
3355
3313
  let e = zapRequest.tags.find(([t, v]) => t === "e" && v);
3356
- if (e && !isHex32(e[1]))
3314
+ if (e && !e[1].match(/^[a-f0-9]{64}$/))
3357
3315
  return "Zap request 'e' tag is not valid hex.";
3358
3316
  let relays = zapRequest.tags.find(([t, v]) => t === "relays" && v);
3359
3317
  if (!relays)
@@ -3428,7 +3386,7 @@ __export(nip77_exports, {
3428
3386
  NegentropyStorageVector: () => NegentropyStorageVector,
3429
3387
  NegentropySync: () => NegentropySync
3430
3388
  });
3431
- var import_utils20 = require("@noble/hashes/utils.js");
3389
+ var import_utils17 = require("@noble/hashes/utils.js");
3432
3390
  var import_sha25 = require("@noble/hashes/sha2.js");
3433
3391
  var PROTOCOL_VERSION = 97;
3434
3392
  var ID_SIZE = 32;
@@ -3574,7 +3532,7 @@ var NegentropyStorageVector = class {
3574
3532
  insert(timestamp, id) {
3575
3533
  if (this.sealed)
3576
3534
  throw Error("already sealed");
3577
- const idb = (0, import_utils20.hexToBytes)(id);
3535
+ const idb = (0, import_utils17.hexToBytes)(id);
3578
3536
  if (idb.byteLength !== ID_SIZE)
3579
3537
  throw Error("bad id size for added item");
3580
3538
  this.items.push({ timestamp, id: idb });
@@ -3668,10 +3626,10 @@ var Negentropy = class {
3668
3626
  let output = new WrappedBuffer();
3669
3627
  output.extend(new Uint8Array([PROTOCOL_VERSION]));
3670
3628
  this.splitRange(0, this.storage.size(), this._bound(Number.MAX_VALUE), output);
3671
- return (0, import_utils20.bytesToHex)(output.unwrap());
3629
+ return (0, import_utils17.bytesToHex)(output.unwrap());
3672
3630
  }
3673
3631
  reconcile(queryMsg, onhave, onneed) {
3674
- const query = new WrappedBuffer((0, import_utils20.hexToBytes)(queryMsg));
3632
+ const query = new WrappedBuffer((0, import_utils17.hexToBytes)(queryMsg));
3675
3633
  this.lastTimestampIn = this.lastTimestampOut = 0;
3676
3634
  let fullOutput = new WrappedBuffer();
3677
3635
  fullOutput.extend(new Uint8Array([PROTOCOL_VERSION]));
@@ -3714,22 +3672,22 @@ var Negentropy = class {
3714
3672
  let theirElems = {};
3715
3673
  for (let i2 = 0; i2 < numIds; i2++) {
3716
3674
  let e = getBytes(query, ID_SIZE);
3717
- theirElems[(0, import_utils20.bytesToHex)(e)] = e;
3675
+ theirElems[(0, import_utils17.bytesToHex)(e)] = e;
3718
3676
  }
3719
3677
  skip = true;
3720
3678
  this.storage.iterate(lower, upper, (item) => {
3721
3679
  let k = item.id;
3722
- const id = (0, import_utils20.bytesToHex)(k);
3680
+ const id = (0, import_utils17.bytesToHex)(k);
3723
3681
  if (!theirElems[id]) {
3724
3682
  onhave?.(id);
3725
3683
  } else {
3726
- delete theirElems[(0, import_utils20.bytesToHex)(k)];
3684
+ delete theirElems[(0, import_utils17.bytesToHex)(k)];
3727
3685
  }
3728
3686
  return true;
3729
3687
  });
3730
3688
  if (onneed) {
3731
3689
  for (let v of Object.values(theirElems)) {
3732
- onneed((0, import_utils20.bytesToHex)(v));
3690
+ onneed((0, import_utils17.bytesToHex)(v));
3733
3691
  }
3734
3692
  }
3735
3693
  } else {
@@ -3747,7 +3705,7 @@ var Negentropy = class {
3747
3705
  prevIndex = upper;
3748
3706
  prevBound = currBound;
3749
3707
  }
3750
- return fullOutput.length === 1 ? null : (0, import_utils20.bytesToHex)(fullOutput.unwrap());
3708
+ return fullOutput.length === 1 ? null : (0, import_utils17.bytesToHex)(fullOutput.unwrap());
3751
3709
  }
3752
3710
  splitRange(lower, upper, upperBound, o) {
3753
3711
  let numElems = upper - lower;
@@ -3936,7 +3894,7 @@ __export(nip98_exports, {
3936
3894
  validateToken: () => validateToken
3937
3895
  });
3938
3896
  var import_sha26 = require("@noble/hashes/sha2.js");
3939
- var import_utils21 = require("@noble/hashes/utils.js");
3897
+ var import_utils18 = require("@noble/hashes/utils.js");
3940
3898
  var import_base5 = require("@scure/base");
3941
3899
  var _authorizationScheme = "Nostr ";
3942
3900
  async function getToken(loginUrl, httpMethod, sign, includeAuthorizationScheme = false, payload) {
@@ -4002,7 +3960,7 @@ function validateEventMethodTag(event, method) {
4002
3960
  }
4003
3961
  function hashPayload(payload) {
4004
3962
  const hash = (0, import_sha26.sha256)(utf8Encoder.encode(JSON.stringify(payload)));
4005
- return (0, import_utils21.bytesToHex)(hash);
3963
+ return (0, import_utils18.bytesToHex)(hash);
4006
3964
  }
4007
3965
  function validateEventPayloadTag(event, payload) {
4008
3966
  const payloadTag = event.tags.find((t) => t[0] === "payload");