@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
@@ -2228,6 +2228,44 @@ var NostrTools = (() => {
2228
2228
  };
2229
2229
  })();
2230
2230
 
2231
+ // core.ts
2232
+ var verifiedSymbol = Symbol("verified");
2233
+ var isRecord = (obj) => obj instanceof Object;
2234
+ function validateEvent(event) {
2235
+ if (!isRecord(event))
2236
+ return false;
2237
+ if (typeof event.kind !== "number")
2238
+ return false;
2239
+ if (typeof event.content !== "string")
2240
+ return false;
2241
+ if (typeof event.created_at !== "number")
2242
+ return false;
2243
+ if (typeof event.pubkey !== "string")
2244
+ return false;
2245
+ if (!event.pubkey.match(/^[a-f0-9]{64}$/))
2246
+ return false;
2247
+ if (!Array.isArray(event.tags))
2248
+ return false;
2249
+ for (let i2 = 0; i2 < event.tags.length; i2++) {
2250
+ let tag = event.tags[i2];
2251
+ if (!Array.isArray(tag))
2252
+ return false;
2253
+ for (let j = 0; j < tag.length; j++) {
2254
+ if (typeof tag[j] !== "string")
2255
+ return false;
2256
+ }
2257
+ }
2258
+ return true;
2259
+ }
2260
+ function sortEvents(events) {
2261
+ return events.sort((a, b) => {
2262
+ if (a.created_at !== b.created_at) {
2263
+ return b.created_at - a.created_at;
2264
+ }
2265
+ return a.id.localeCompare(b.id);
2266
+ });
2267
+ }
2268
+
2231
2269
  // utils.ts
2232
2270
  var utils_exports = {};
2233
2271
  __export(utils_exports, {
@@ -2236,7 +2274,6 @@ var NostrTools = (() => {
2236
2274
  hexToBytes: () => hexToBytes,
2237
2275
  insertEventIntoAscendingList: () => insertEventIntoAscendingList,
2238
2276
  insertEventIntoDescendingList: () => insertEventIntoDescendingList,
2239
- isHex32: () => isHex32,
2240
2277
  mergeReverseSortedLists: () => mergeReverseSortedLists,
2241
2278
  normalizeURL: () => normalizeURL,
2242
2279
  utf8Decoder: () => utf8Decoder,
@@ -2358,53 +2395,6 @@ var NostrTools = (() => {
2358
2395
  }
2359
2396
  return result;
2360
2397
  }
2361
- function isHex32(input) {
2362
- for (let i2 = 0; i2 < 64; i2++) {
2363
- let cc = input.charCodeAt(i2);
2364
- if (isNaN(cc) || cc < 48 || cc > 102 || cc > 57 && cc < 97) {
2365
- return false;
2366
- }
2367
- }
2368
- return true;
2369
- }
2370
-
2371
- // core.ts
2372
- var verifiedSymbol = Symbol("verified");
2373
- var isRecord = (obj) => obj instanceof Object;
2374
- function validateEvent(event) {
2375
- if (!isRecord(event))
2376
- return false;
2377
- if (typeof event.kind !== "number")
2378
- return false;
2379
- if (typeof event.content !== "string")
2380
- return false;
2381
- if (typeof event.created_at !== "number")
2382
- return false;
2383
- if (typeof event.pubkey !== "string")
2384
- return false;
2385
- if (!isHex32(event.pubkey))
2386
- return false;
2387
- if (!Array.isArray(event.tags))
2388
- return false;
2389
- for (let i2 = 0; i2 < event.tags.length; i2++) {
2390
- let tag = event.tags[i2];
2391
- if (!Array.isArray(tag))
2392
- return false;
2393
- for (let j = 0; j < tag.length; j++) {
2394
- if (typeof tag[j] !== "string")
2395
- return false;
2396
- }
2397
- }
2398
- return true;
2399
- }
2400
- function sortEvents(events) {
2401
- return events.sort((a, b) => {
2402
- if (a.created_at !== b.created_at) {
2403
- return b.created_at - a.created_at;
2404
- }
2405
- return a.id.localeCompare(b.id);
2406
- });
2407
- }
2408
2398
 
2409
2399
  // pure.ts
2410
2400
  var JS = class {
@@ -2509,7 +2499,6 @@ var NostrTools = (() => {
2509
2499
  Emojisets: () => Emojisets,
2510
2500
  EncryptedDirectMessage: () => EncryptedDirectMessage,
2511
2501
  EventDeletion: () => EventDeletion,
2512
- FavoriteFollowSets: () => FavoriteFollowSets,
2513
2502
  FavoritePodcasts: () => FavoritePodcasts,
2514
2503
  FavoriteRelays: () => FavoriteRelays,
2515
2504
  FedimintAnnouncement: () => FedimintAnnouncement,
@@ -2782,7 +2771,6 @@ var NostrTools = (() => {
2782
2771
  var InterestsList = 10015;
2783
2772
  var NutZapInfo = 10019;
2784
2773
  var MediaFollows = 10020;
2785
- var FavoriteFollowSets = 10021;
2786
2774
  var UserEmojiList = 10030;
2787
2775
  var DecoupledKeyAnnouncement = 10044;
2788
2776
  var DirectMessageRelaysList = 10050;
@@ -3031,14 +3019,12 @@ var NostrTools = (() => {
3031
3019
  openSubs = /* @__PURE__ */ new Map();
3032
3020
  enablePing;
3033
3021
  enableReconnect;
3034
- idleTimeout = 0;
3035
3022
  idleSince = Date.now();
3036
3023
  ongoingOperations = 0;
3037
3024
  reconnectTimeoutHandle;
3038
3025
  pingIntervalHandle;
3039
3026
  reconnectAttempts = 0;
3040
3027
  skipReconnection = false;
3041
- idleTimeoutHandle;
3042
3028
  connectionPromise;
3043
3029
  openCountRequests = /* @__PURE__ */ new Map();
3044
3030
  openEventPublishes = /* @__PURE__ */ new Map();
@@ -3054,8 +3040,6 @@ var NostrTools = (() => {
3054
3040
  this._WebSocket = opts.websocketImplementation || WebSocket;
3055
3041
  this.enablePing = opts.enablePing;
3056
3042
  this.enableReconnect = opts.enableReconnect || false;
3057
- if (opts.idleTimeout)
3058
- this.idleTimeout = opts.idleTimeout;
3059
3043
  }
3060
3044
  static async connect(url, opts) {
3061
3045
  const relay = new AbstractRelay(url, opts);
@@ -3079,22 +3063,6 @@ var NostrTools = (() => {
3079
3063
  get connected() {
3080
3064
  return this._connected;
3081
3065
  }
3082
- clearIdleTimeout() {
3083
- if (this.idleTimeoutHandle) {
3084
- clearTimeout(this.idleTimeoutHandle);
3085
- this.idleTimeoutHandle = void 0;
3086
- }
3087
- }
3088
- scheduleIdleClose() {
3089
- this.clearIdleTimeout();
3090
- if (this.idleTimeout > 0) {
3091
- this.idleTimeoutHandle = setTimeout(() => {
3092
- if (this.ongoingOperations === 0 && this.idleSince) {
3093
- this.close();
3094
- }
3095
- }, this.idleTimeout);
3096
- }
3097
- }
3098
3066
  async reconnect() {
3099
3067
  const backoff = this.resubscribeBackoff[Math.min(this.reconnectAttempts, this.resubscribeBackoff.length - 1)];
3100
3068
  this.reconnectAttempts++;
@@ -3106,11 +3074,6 @@ var NostrTools = (() => {
3106
3074
  }, backoff);
3107
3075
  }
3108
3076
  handleHardClose(reason) {
3109
- if (this.ws) {
3110
- this.ws.onopen = null;
3111
- this.ws.onerror = null;
3112
- this.ws.onclose = null;
3113
- }
3114
3077
  if (this.pingIntervalHandle) {
3115
3078
  clearInterval(this.pingIntervalHandle);
3116
3079
  this.pingIntervalHandle = void 0;
@@ -3118,7 +3081,6 @@ var NostrTools = (() => {
3118
3081
  this._connected = false;
3119
3082
  this.connectionPromise = void 0;
3120
3083
  this.idleSince = void 0;
3121
- this.clearIdleTimeout();
3122
3084
  if (this.enableReconnect && !this.skipReconnection) {
3123
3085
  this.reconnect();
3124
3086
  } else {
@@ -3141,6 +3103,7 @@ var NostrTools = (() => {
3141
3103
  if (this.reconnectAttempts === 0) {
3142
3104
  this.skipReconnection = true;
3143
3105
  }
3106
+ this.onclose?.();
3144
3107
  this.handleHardClose("relay connection timed out");
3145
3108
  }, opts.timeout);
3146
3109
  }
@@ -3186,6 +3149,7 @@ var NostrTools = (() => {
3186
3149
  if (this.reconnectAttempts === 0) {
3187
3150
  this.skipReconnection = true;
3188
3151
  }
3152
+ this.onclose?.();
3189
3153
  this.handleHardClose("relay connection failed");
3190
3154
  };
3191
3155
  this.ws.onclose = (ev) => {
@@ -3274,7 +3238,6 @@ var NostrTools = (() => {
3274
3238
  }
3275
3239
  async publish(event) {
3276
3240
  this.idleSince = void 0;
3277
- this.clearIdleTimeout();
3278
3241
  this.ongoingOperations++;
3279
3242
  const ret = new Promise((resolve, reject) => {
3280
3243
  const timeout = setTimeout(() => {
@@ -3296,10 +3259,8 @@ var NostrTools = (() => {
3296
3259
  }
3297
3260
  }
3298
3261
  this.ongoingOperations--;
3299
- if (this.ongoingOperations === 0) {
3262
+ if (this.ongoingOperations === 0)
3300
3263
  this.idleSince = Date.now();
3301
- this.scheduleIdleClose();
3302
- }
3303
3264
  return ret;
3304
3265
  }
3305
3266
  async count(filters, params) {
@@ -3325,7 +3286,6 @@ var NostrTools = (() => {
3325
3286
  subscribe(filters, params) {
3326
3287
  if (params.label !== "<forced-ping>") {
3327
3288
  this.idleSince = void 0;
3328
- this.clearIdleTimeout();
3329
3289
  this.ongoingOperations++;
3330
3290
  }
3331
3291
  const sub = this.prepareSubscription(filters, params);
@@ -3354,17 +3314,10 @@ var NostrTools = (() => {
3354
3314
  }
3355
3315
  this.closeAllSubscriptions("relay connection closed by us");
3356
3316
  this._connected = false;
3357
- this.connectionPromise = void 0;
3358
3317
  this.idleSince = void 0;
3359
- this.clearIdleTimeout();
3360
3318
  this.onclose?.();
3361
- if (this.ws) {
3362
- this.ws.onopen = null;
3363
- this.ws.onerror = null;
3364
- this.ws.onclose = null;
3365
- if (this.ws.readyState !== this._WebSocket.CLOSING && this.ws.readyState !== this._WebSocket.CLOSED) {
3366
- this.ws.close();
3367
- }
3319
+ if (this.ws?.readyState === this._WebSocket.OPEN) {
3320
+ this.ws?.close();
3368
3321
  }
3369
3322
  }
3370
3323
  _onmessage(ev) {
@@ -3391,7 +3344,7 @@ var NostrTools = (() => {
3391
3344
  case "EVENT": {
3392
3345
  const so = this.openSubs.get(data[1]);
3393
3346
  const event = data[2];
3394
- if (matchFilters(so.filters, event) && this.verifyEvent(event, this.url)) {
3347
+ if (this.verifyEvent(event) && matchFilters(so.filters, event)) {
3395
3348
  so.onevent(event);
3396
3349
  } else {
3397
3350
  so.oninvalidevent?.(event);
@@ -3539,10 +3492,8 @@ var NostrTools = (() => {
3539
3492
  }
3540
3493
  this.relay.openSubs.delete(this.id);
3541
3494
  this.relay.ongoingOperations--;
3542
- if (this.relay.ongoingOperations === 0) {
3495
+ if (this.relay.ongoingOperations === 0)
3543
3496
  this.relay.idleSince = Date.now();
3544
- this.relay.scheduleIdleClose();
3545
- }
3546
3497
  this.onclose?.(reason);
3547
3498
  }
3548
3499
  };
@@ -3564,6 +3515,12 @@ var NostrTools = (() => {
3564
3515
  }
3565
3516
  };
3566
3517
 
3518
+ // helpers.ts
3519
+ var alwaysTrue = (t) => {
3520
+ t[verifiedSymbol] = true;
3521
+ return true;
3522
+ };
3523
+
3567
3524
  // nip45.ts
3568
3525
  var M = 256;
3569
3526
  var HLL_HEX_LENGTH = M * 2;
@@ -3588,7 +3545,7 @@ var NostrTools = (() => {
3588
3545
  return new Uint8Array(M);
3589
3546
  }
3590
3547
  function hllDecode(hex2) {
3591
- if (hex2.length !== HLL_HEX_LENGTH || !/^[0-9a-f]+$/.test(hex2))
3548
+ if (hex2.length !== HLL_HEX_LENGTH || !/^[0-9a-fA-F]+$/.test(hex2))
3592
3549
  return void 0;
3593
3550
  const registers = new Uint8Array(M);
3594
3551
  for (let i2 = 0; i2 < M; i2++) {
@@ -3627,8 +3584,8 @@ var NostrTools = (() => {
3627
3584
  verifyEvent;
3628
3585
  enablePing;
3629
3586
  enableReconnect;
3630
- idleTimeout = 2e4;
3631
3587
  automaticallyAuth;
3588
+ trustedRelayURLs = /* @__PURE__ */ new Set();
3632
3589
  onRelayConnectionFailure;
3633
3590
  onRelayConnectionSuccess;
3634
3591
  allowConnectingToRelay;
@@ -3639,8 +3596,6 @@ var NostrTools = (() => {
3639
3596
  this._WebSocket = opts.websocketImplementation;
3640
3597
  this.enablePing = opts.enablePing;
3641
3598
  this.enableReconnect = opts.enableReconnect || false;
3642
- if (opts.idleTimeout)
3643
- this.idleTimeout = opts.idleTimeout;
3644
3599
  this.automaticallyAuth = opts.automaticallyAuth;
3645
3600
  this.onRelayConnectionFailure = opts.onRelayConnectionFailure;
3646
3601
  this.onRelayConnectionSuccess = opts.onRelayConnectionSuccess;
@@ -3652,11 +3607,10 @@ var NostrTools = (() => {
3652
3607
  let relay = this.relays.get(url);
3653
3608
  if (!relay) {
3654
3609
  relay = new AbstractRelay(url, {
3655
- verifyEvent: this.verifyEvent,
3610
+ verifyEvent: this.trustedRelayURLs.has(url) ? alwaysTrue : this.verifyEvent,
3656
3611
  websocketImplementation: this._WebSocket,
3657
3612
  enablePing: this.enablePing,
3658
- enableReconnect: this.enableReconnect,
3659
- idleTimeout: this.idleTimeout
3613
+ enableReconnect: this.enableReconnect
3660
3614
  });
3661
3615
  relay.onclose = () => {
3662
3616
  this.relays.delete(url);
@@ -3736,11 +3690,11 @@ var NostrTools = (() => {
3736
3690
  }
3737
3691
  };
3738
3692
  const closesReceived = [];
3739
- let handleClose = (i2, url, reason) => {
3693
+ let handleClose = (i2, reason) => {
3740
3694
  if (closesReceived[i2])
3741
3695
  return;
3742
3696
  handleEose(i2);
3743
- closesReceived[i2] = { url, reason };
3697
+ closesReceived[i2] = reason;
3744
3698
  if (closesReceived.filter((a) => a).length === groupedRequests.length) {
3745
3699
  params.onclose?.(closesReceived);
3746
3700
  handleClose = () => {
@@ -3758,7 +3712,7 @@ var NostrTools = (() => {
3758
3712
  const allOpened = Promise.all(
3759
3713
  groupedRequests.map(async ({ url, filters }, i2) => {
3760
3714
  if (this.allowConnectingToRelay?.(url, ["read", filters]) === false) {
3761
- handleClose(i2, url, "connection skipped by allowConnectingToRelay");
3715
+ handleClose(i2, "connection skipped by allowConnectingToRelay");
3762
3716
  return;
3763
3717
  }
3764
3718
  let relay;
@@ -3769,7 +3723,7 @@ var NostrTools = (() => {
3769
3723
  });
3770
3724
  } catch (err) {
3771
3725
  this.onRelayConnectionFailure?.(url);
3772
- handleClose(i2, url, err?.message || String(err));
3726
+ handleClose(i2, err?.message || String(err));
3773
3727
  return;
3774
3728
  }
3775
3729
  this.onRelayConnectionSuccess?.(url);
@@ -3783,17 +3737,17 @@ var NostrTools = (() => {
3783
3737
  ...params,
3784
3738
  oneose: () => handleEose(i2),
3785
3739
  onclose: (reason2) => {
3786
- handleClose(i2, url, reason2);
3740
+ handleClose(i2, reason2);
3787
3741
  },
3788
3742
  alreadyHaveEvent: localAlreadyHaveEventHandler,
3789
3743
  eoseTimeout: params.maxWait,
3790
3744
  abort: params.abort
3791
3745
  });
3792
3746
  }).catch((err) => {
3793
- handleClose(i2, url, `auth was required and attempted, but failed with: ${err}`);
3747
+ handleClose(i2, `auth was required and attempted, but failed with: ${err}`);
3794
3748
  });
3795
3749
  } else {
3796
- handleClose(i2, url, reason);
3750
+ handleClose(i2, reason);
3797
3751
  }
3798
3752
  },
3799
3753
  alreadyHaveEvent: localAlreadyHaveEventHandler,
@@ -3821,7 +3775,7 @@ var NostrTools = (() => {
3821
3775
  if (subcloser)
3822
3776
  subcloser.close(reason);
3823
3777
  else
3824
- params.onclose?.(relays.map((url) => ({ url, reason })));
3778
+ params.onclose?.(relays.map((_) => reason));
3825
3779
  }
3826
3780
  });
3827
3781
  return subcloser;
@@ -5237,6 +5191,7 @@ var NostrTools = (() => {
5237
5191
  __export(nip10_exports, {
5238
5192
  parse: () => parse
5239
5193
  });
5194
+ var HEX64 = /^[0-9a-fA-F]{64}$/;
5240
5195
  function parse(event) {
5241
5196
  const result = {
5242
5197
  reply: void 0,
@@ -5249,12 +5204,12 @@ var NostrTools = (() => {
5249
5204
  let maybeRoot;
5250
5205
  for (let i2 = event.tags.length - 1; i2 >= 0; i2--) {
5251
5206
  const tag = event.tags[i2];
5252
- if (tag[0] === "e" && tag[1] && isHex32(tag[1])) {
5207
+ if (tag[0] === "e" && tag[1] && HEX64.test(tag[1])) {
5253
5208
  const [_, eTagEventId, eTagRelayUrl, eTagMarker, eTagAuthor] = tag;
5254
5209
  const eventPointer = {
5255
5210
  id: eTagEventId,
5256
5211
  relays: eTagRelayUrl ? [eTagRelayUrl] : [],
5257
- author: eTagAuthor && isHex32(eTagAuthor) ? eTagAuthor : void 0
5212
+ author: eTagAuthor && HEX64.test(eTagAuthor) ? eTagAuthor : void 0
5258
5213
  };
5259
5214
  if (eTagMarker === "root") {
5260
5215
  result.root = eventPointer;
@@ -5276,14 +5231,14 @@ var NostrTools = (() => {
5276
5231
  result.mentions.push(eventPointer);
5277
5232
  continue;
5278
5233
  }
5279
- if (tag[0] === "q" && tag[1] && isHex32(tag[1])) {
5234
+ if (tag[0] === "q" && tag[1] && HEX64.test(tag[1])) {
5280
5235
  const [_, eTagEventId, eTagRelayUrl] = tag;
5281
5236
  result.quotes.push({
5282
5237
  id: eTagEventId,
5283
5238
  relays: eTagRelayUrl ? [eTagRelayUrl] : []
5284
5239
  });
5285
5240
  }
5286
- if (tag[0] === "p" && tag[1] && isHex32(tag[1])) {
5241
+ if (tag[0] === "p" && tag[1] && HEX64.test(tag[1])) {
5287
5242
  result.profiles.push({
5288
5243
  pubkey: tag[1],
5289
5244
  relays: tag[2] ? [tag[2]] : []
@@ -6403,6 +6358,7 @@ var NostrTools = (() => {
6403
6358
  __export(nip22_exports, {
6404
6359
  parse: () => parse3
6405
6360
  });
6361
+ var HEX642 = /^[0-9a-fA-F]{64}$/;
6406
6362
  function parseKind(kind) {
6407
6363
  if (!kind)
6408
6364
  return void 0;
@@ -6417,7 +6373,7 @@ var NostrTools = (() => {
6417
6373
  if (Number.isNaN(kind))
6418
6374
  return void 0;
6419
6375
  const pubkey = value.slice(idx + 1, idx2);
6420
- if (!isHex32(pubkey))
6376
+ if (!HEX642.test(pubkey))
6421
6377
  return void 0;
6422
6378
  return {
6423
6379
  kind,
@@ -6430,12 +6386,12 @@ var NostrTools = (() => {
6430
6386
  switch (tag[0]) {
6431
6387
  case "E":
6432
6388
  case "e":
6433
- if (!tag[1] || !isHex32(tag[1]))
6389
+ if (!tag[1] || !HEX642.test(tag[1]))
6434
6390
  return void 0;
6435
6391
  return {
6436
6392
  id: tag[1],
6437
6393
  relays: tag[2] ? [tag[2]] : [],
6438
- author: tag[3] && isHex32(tag[3]) ? tag[3] : void 0
6394
+ author: tag[3] && HEX642.test(tag[3]) ? tag[3] : void 0
6439
6395
  };
6440
6396
  case "A":
6441
6397
  case "a":
@@ -6458,12 +6414,12 @@ var NostrTools = (() => {
6458
6414
  if (tag[1].includes(":")) {
6459
6415
  return parseAddressPointer(tag[1], tag[2]);
6460
6416
  }
6461
- if (!isHex32(tag[1]))
6417
+ if (!HEX642.test(tag[1]))
6462
6418
  return void 0;
6463
6419
  return {
6464
6420
  id: tag[1],
6465
6421
  relays: tag[2] ? [tag[2]] : [],
6466
- author: tag[3] && isHex32(tag[3]) ? tag[3] : void 0
6422
+ author: tag[3] && HEX642.test(tag[3]) ? tag[3] : void 0
6467
6423
  };
6468
6424
  }
6469
6425
  function choosePointer(candidates) {
@@ -6523,7 +6479,7 @@ var NostrTools = (() => {
6523
6479
  result.quotes.push(pointer);
6524
6480
  continue;
6525
6481
  }
6526
- if ((tag[0] === "P" || tag[0] === "p") && tag[1] && isHex32(tag[1])) {
6482
+ if ((tag[0] === "P" || tag[0] === "p") && tag[1] && HEX642.test(tag[1])) {
6527
6483
  result.profiles.push({
6528
6484
  pubkey: tag[1],
6529
6485
  relays: tag[2] ? [tag[2]] : []
@@ -7023,10 +6979,10 @@ var NostrTools = (() => {
7023
6979
  let p = zapRequest.tags.find(([t, v]) => t === "p" && v);
7024
6980
  if (!p)
7025
6981
  return "Zap request doesn't have a 'p' tag.";
7026
- if (!isHex32(p[1]))
6982
+ if (!p[1].match(/^[a-f0-9]{64}$/))
7027
6983
  return "Zap request 'p' tag is not valid hex.";
7028
6984
  let e = zapRequest.tags.find(([t, v]) => t === "e" && v);
7029
- if (e && !isHex32(e[1]))
6985
+ if (e && !e[1].match(/^[a-f0-9]{64}$/))
7030
6986
  return "Zap request 'e' tag is not valid hex.";
7031
6987
  let relays = zapRequest.tags.find(([t, v]) => t === "relays" && v);
7032
6988
  if (!relays)