@openclaw/nostr 2026.5.28 → 2026.5.30-beta.1
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 +15 -4
- package/npm-shrinkwrap.json +3 -3
- package/package.json +4 -4
package/dist/api.js
CHANGED
|
@@ -7,6 +7,7 @@ import { z } from "zod";
|
|
|
7
7
|
import { SimplePool, verifyEvent } from "nostr-tools";
|
|
8
8
|
import { readJsonBodyWithLimit, requestBodyErrorToText } from "openclaw/plugin-sdk/webhook-request-guards";
|
|
9
9
|
import { createFixedWindowRateLimiter } from "openclaw/plugin-sdk/webhook-ingress";
|
|
10
|
+
import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
10
11
|
import { isBlockedHostnameOrIp } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
11
12
|
//#region extensions/nostr/src/nostr-profile-url-safety.ts
|
|
12
13
|
function validateUrlSafety(urlStr) {
|
|
@@ -64,7 +65,8 @@ function sanitizeProfileUrls(profile) {
|
|
|
64
65
|
* - Parses and returns the profile
|
|
65
66
|
*/
|
|
66
67
|
async function importProfileFromRelays(opts) {
|
|
67
|
-
const { pubkey, relays
|
|
68
|
+
const { pubkey, relays } = opts;
|
|
69
|
+
const timeoutMs = resolveTimerTimeoutMs(opts.timeoutMs, DEFAULT_TIMEOUT_MS);
|
|
68
70
|
if (!pubkey || !/^[0-9a-fA-F]{64}$/.test(pubkey)) return {
|
|
69
71
|
ok: false,
|
|
70
72
|
error: "Invalid pubkey format (must be 64 hex characters)",
|
|
@@ -77,10 +79,17 @@ async function importProfileFromRelays(opts) {
|
|
|
77
79
|
};
|
|
78
80
|
const pool = new SimplePool();
|
|
79
81
|
const relaysQueried = [];
|
|
82
|
+
const timers = [];
|
|
83
|
+
const scheduleTimeout = (callback) => {
|
|
84
|
+
const timer = setTimeout(callback, timeoutMs);
|
|
85
|
+
timer.unref?.();
|
|
86
|
+
timers.push(timer);
|
|
87
|
+
return timer;
|
|
88
|
+
};
|
|
80
89
|
try {
|
|
81
90
|
const events = [];
|
|
82
91
|
const timeoutPromise = new Promise((resolve) => {
|
|
83
|
-
|
|
92
|
+
scheduleTimeout(resolve);
|
|
84
93
|
});
|
|
85
94
|
const subscriptionPromise = new Promise((resolve) => {
|
|
86
95
|
let completed = 0;
|
|
@@ -107,12 +116,13 @@ async function importProfileFromRelays(opts) {
|
|
|
107
116
|
if (completed >= relays.length) resolve();
|
|
108
117
|
}
|
|
109
118
|
});
|
|
110
|
-
|
|
119
|
+
scheduleTimeout(() => {
|
|
111
120
|
sub.close();
|
|
112
|
-
}
|
|
121
|
+
});
|
|
113
122
|
}
|
|
114
123
|
});
|
|
115
124
|
await Promise.race([subscriptionPromise, timeoutPromise]);
|
|
125
|
+
for (const timer of timers.splice(0)) clearTimeout(timer);
|
|
116
126
|
if (events.length === 0) return {
|
|
117
127
|
ok: false,
|
|
118
128
|
error: "No profile found on any relay",
|
|
@@ -154,6 +164,7 @@ async function importProfileFromRelays(opts) {
|
|
|
154
164
|
sourceRelay: bestEvent.relay
|
|
155
165
|
};
|
|
156
166
|
} finally {
|
|
167
|
+
for (const timer of timers) clearTimeout(timer);
|
|
157
168
|
pool.close(relays);
|
|
158
169
|
}
|
|
159
170
|
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/nostr",
|
|
3
|
-
"version": "2026.5.
|
|
3
|
+
"version": "2026.5.30-beta.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@openclaw/nostr",
|
|
9
|
-
"version": "2026.5.
|
|
9
|
+
"version": "2026.5.30-beta.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"nostr-tools": "2.23.5",
|
|
12
12
|
"zod": "4.4.3"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"openclaw": ">=2026.5.
|
|
15
|
+
"openclaw": ">=2026.5.30-beta.1"
|
|
16
16
|
},
|
|
17
17
|
"peerDependenciesMeta": {
|
|
18
18
|
"openclaw": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/nostr",
|
|
3
|
-
"version": "2026.5.
|
|
3
|
+
"version": "2026.5.30-beta.1",
|
|
4
4
|
"description": "OpenClaw Nostr channel plugin for NIP-04 encrypted direct messages.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"zod": "4.4.3"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"openclaw": ">=2026.5.
|
|
15
|
+
"openclaw": ">=2026.5.30-beta.1"
|
|
16
16
|
},
|
|
17
17
|
"peerDependenciesMeta": {
|
|
18
18
|
"openclaw": {
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"minHostVersion": ">=2026.4.10"
|
|
51
51
|
},
|
|
52
52
|
"compat": {
|
|
53
|
-
"pluginApi": ">=2026.5.
|
|
53
|
+
"pluginApi": ">=2026.5.30-beta.1"
|
|
54
54
|
},
|
|
55
55
|
"build": {
|
|
56
|
-
"openclawVersion": "2026.5.
|
|
56
|
+
"openclawVersion": "2026.5.30-beta.1"
|
|
57
57
|
},
|
|
58
58
|
"release": {
|
|
59
59
|
"publishToClawHub": true,
|