@openclaw/nostr 2026.9.2 → 2026.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { s as resolveNostrAccount } from "./setup-surface-mA5PMspO.js";
2
2
  import { getPluginRuntimeGatewayRequestScope } from "./runtime-api.js";
3
3
  import { n as NostrProfileSchema } from "./config-schema-CkYd8ACn.js";
4
- import { a as getNostrRuntime, i as contentToProfile, n as nostrPlugin, o as setNostrRuntime, r as publishNostrProfile, t as getNostrProfileState } from "./channel-CLybVB2-.js";
4
+ import { a as getNostrRuntime, i as contentToProfile, n as nostrPlugin, o as setNostrRuntime, r as publishNostrProfile, t as getNostrProfileState } from "./channel-DWFChLbP.js";
5
5
  import { normalizeLowercaseStringOrEmpty, normalizeOptionalLowercaseString, readStringValue } from "openclaw/plugin-sdk/string-coerce-runtime";
6
6
  import { z } from "zod";
7
7
  import { SimplePool } from "nostr-tools";
@@ -646,16 +646,6 @@ function contentToProfile(content) {
646
646
  return profile;
647
647
  }
648
648
  //#endregion
649
- //#region extensions/nostr/src/relay-publish.ts
650
- const CONNECTION_FAILURE_PREFIX = "connection failure: ";
651
- async function publishNostrEventToRelay(pool, relay, event) {
652
- const publishPromise = pool.publish([relay], event)[0];
653
- if (!publishPromise) throw new Error(`Failed to create publish promise for relay ${relay}`);
654
- const result = await publishPromise;
655
- if (result.startsWith(CONNECTION_FAILURE_PREFIX)) throw new Error(result.slice(20));
656
- return result;
657
- }
658
- //#endregion
659
649
  //#region extensions/nostr/src/nostr-profile.ts
660
650
  /**
661
651
  * Nostr Profile Management (NIP-01 kind:0)
@@ -705,7 +695,7 @@ async function publishProfileEvent(pool, relays, event) {
705
695
  const timeoutPromise = new Promise((_, reject) => {
706
696
  timer = setTimeout(() => reject(/* @__PURE__ */ new Error("timeout")), RELAY_PUBLISH_TIMEOUT_MS);
707
697
  });
708
- await Promise.race([publishNostrEventToRelay(pool, relay, event), timeoutPromise]);
698
+ await Promise.race([pool.publish([relay], event)[0], timeoutPromise]);
709
699
  successes.push(relay);
710
700
  } catch (err) {
711
701
  const errorMessage = formatErrorMessage(err);
@@ -1290,7 +1280,7 @@ async function sendEncryptedDm(pool, sk, toPubkey, text, relays, metrics, circui
1290
1280
  if (cb && !cb.canAttempt()) continue;
1291
1281
  const startTime = Date.now();
1292
1282
  try {
1293
- await publishNostrEventToRelay(pool, relay, reply);
1283
+ await pool.publish([relay], reply)[0];
1294
1284
  const latency = Date.now() - startTime;
1295
1285
  cb?.recordSuccess();
1296
1286
  healthTracker.recordSuccess(relay, latency);
@@ -1,2 +1,2 @@
1
- import { n as nostrPlugin } from "./channel-CLybVB2-.js";
1
+ import { n as nostrPlugin } from "./channel-DWFChLbP.js";
2
2
  export { nostrPlugin };
@@ -459,6 +459,29 @@ summary for relay read message and verify event
459
459
  </script>
460
460
  ```
461
461
 
462
+ ### Using it with React Native
463
+
464
+ React Native requires polyfills:
465
+
466
+ ```sh
467
+ npm install react-native-get-random-values text-encoding-polyfill react-native-url-polyfill
468
+ ```
469
+
470
+ Import the polyfills at the very top of your entry file (`index.js`), **before** anything that imports `nostr-tools`:
471
+
472
+ ```js
473
+ import 'react-native-get-random-values'
474
+ import 'text-encoding-polyfill'
475
+ import 'react-native-url-polyfill/auto'
476
+
477
+ import { AppRegistry } from 'react-native'
478
+ // ...
479
+ ```
480
+
481
+ Future versions of React Native may implement these features natively, allowing the polyfills to be removed.
482
+
483
+ Note: `nostr-tools/wasm` will not work with React Native because it does not have WebAssembly support.
484
+
462
485
  ## Plumbing
463
486
 
464
487
  To develop `@nostr/tools`, install [`just`](https://just.systems/) and run `just -l` to see commands available.
@@ -2963,8 +2963,8 @@ function* parse4(content) {
2963
2963
  if (h === 0 || content[h - 1].match(noCharacter)) {
2964
2964
  const m = content.slice(h + 1, h + MAX_HASHTAG_LENGTH).match(noCharacter);
2965
2965
  const end = m ? h + 1 + m.index : max;
2966
- yield { type: "text", text: content.slice(prevIndex, h) };
2967
- yield { type: "hashtag", value: content.slice(h + 1, end) };
2966
+ yield { type: "text", text: content.slice(prevIndex, h), start: prevIndex, end: h };
2967
+ yield { type: "hashtag", value: content.slice(h + 1, end), start: h, end };
2968
2968
  index = end;
2969
2969
  prevIndex = index;
2970
2970
  continue mainloop;
@@ -2992,9 +2992,9 @@ function* parse4(content) {
2992
2992
  pointer = data;
2993
2993
  }
2994
2994
  if (prevIndex !== u - 5) {
2995
- yield { type: "text", text: content.slice(prevIndex, u - 5) };
2995
+ yield { type: "text", text: content.slice(prevIndex, u - 5), start: prevIndex, end: u - 5 };
2996
2996
  }
2997
- yield { type: "reference", pointer };
2997
+ yield { type: "reference", pointer, start: u - 5, end };
2998
2998
  index = end;
2999
2999
  prevIndex = index;
3000
3000
  continue mainloop;
@@ -3012,27 +3012,32 @@ function* parse4(content) {
3012
3012
  throw new Error("invalid url");
3013
3013
  }
3014
3014
  if (prevIndex !== u - prefixLen) {
3015
- yield { type: "text", text: content.slice(prevIndex, u - prefixLen) };
3015
+ yield {
3016
+ type: "text",
3017
+ text: content.slice(prevIndex, u - prefixLen),
3018
+ start: prevIndex,
3019
+ end: u - prefixLen
3020
+ };
3016
3021
  }
3017
3022
  if (/\.(png|jpe?g|gif|webp|heic|svg)$/i.test(url.pathname)) {
3018
- yield { type: "image", url: url.toString() };
3023
+ yield { type: "image", url: url.toString(), start: u - prefixLen, end };
3019
3024
  index = end;
3020
3025
  prevIndex = index;
3021
3026
  continue mainloop;
3022
3027
  }
3023
3028
  if (/\.(mp4|avi|webm|mkv|mov)$/i.test(url.pathname)) {
3024
- yield { type: "video", url: url.toString() };
3029
+ yield { type: "video", url: url.toString(), start: u - prefixLen, end };
3025
3030
  index = end;
3026
3031
  prevIndex = index;
3027
3032
  continue mainloop;
3028
3033
  }
3029
3034
  if (/\.(mp3|aac|ogg|opus|wav|flac)$/i.test(url.pathname)) {
3030
- yield { type: "audio", url: url.toString() };
3035
+ yield { type: "audio", url: url.toString(), start: u - prefixLen, end };
3031
3036
  index = end;
3032
3037
  prevIndex = index;
3033
3038
  continue mainloop;
3034
3039
  }
3035
- yield { type: "url", url: url.toString() };
3040
+ yield { type: "url", url: url.toString(), start: u - prefixLen, end };
3036
3041
  index = end;
3037
3042
  prevIndex = index;
3038
3043
  continue mainloop;
@@ -3050,9 +3055,14 @@ function* parse4(content) {
3050
3055
  throw new Error("invalid ws url");
3051
3056
  }
3052
3057
  if (prevIndex !== u - prefixLen) {
3053
- yield { type: "text", text: content.slice(prevIndex, u - prefixLen) };
3058
+ yield {
3059
+ type: "text",
3060
+ text: content.slice(prevIndex, u - prefixLen),
3061
+ start: prevIndex,
3062
+ end: u - prefixLen
3063
+ };
3054
3064
  }
3055
- yield { type: "relay", url: url.toString() };
3065
+ yield { type: "relay", url: url.toString(), start: u - prefixLen, end };
3056
3066
  index = end;
3057
3067
  prevIndex = index;
3058
3068
  continue mainloop;
@@ -3065,9 +3075,9 @@ function* parse4(content) {
3065
3075
  const emoji = emojis[e];
3066
3076
  if (content[u + emoji.shortcode.length + 1] === ":" && content.slice(u + 1, u + emoji.shortcode.length + 1) === emoji.shortcode) {
3067
3077
  if (prevIndex !== u) {
3068
- yield { type: "text", text: content.slice(prevIndex, u) };
3078
+ yield { type: "text", text: content.slice(prevIndex, u), start: prevIndex, end: u };
3069
3079
  }
3070
- yield emoji;
3080
+ yield { ...emoji, start: u, end: u + emoji.shortcode.length + 2 };
3071
3081
  index = u + emoji.shortcode.length + 2;
3072
3082
  prevIndex = index;
3073
3083
  continue mainloop;
@@ -3078,7 +3088,7 @@ function* parse4(content) {
3078
3088
  }
3079
3089
  }
3080
3090
  if (prevIndex !== max) {
3081
- yield { type: "text", text: content.slice(prevIndex) };
3091
+ yield { type: "text", text: content.slice(prevIndex), start: prevIndex, end: max };
3082
3092
  }
3083
3093
  }
3084
3094