@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.
- 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
package/dist/setup-plugin-api.js
CHANGED
|
@@ -1,113 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as DEFAULT_RELAYS, n as createNostrSetupAdapter, r as createNostrSetupContract } from "./setup-adapter-BjKmSwdW.js";
|
|
3
|
-
import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
|
|
4
|
-
import { DEFAULT_ACCOUNT_ID, createDelegatedSetupWizardProxy, createSetupTranslator, createStandardChannelSetupStatus } from "openclaw/plugin-sdk/setup-runtime";
|
|
5
|
-
//#region extensions/nostr/src/channel.setup.ts
|
|
6
|
-
const t = createSetupTranslator();
|
|
7
|
-
const channel = "nostr";
|
|
8
|
-
function getNostrConfig(cfg) {
|
|
9
|
-
return cfg.channels?.nostr;
|
|
10
|
-
}
|
|
11
|
-
function listSetupNostrAccountIds(cfg) {
|
|
12
|
-
const nostrCfg = getNostrConfig(cfg);
|
|
13
|
-
if (!(typeof nostrCfg?.privateKey === "string" ? nostrCfg.privateKey.trim() : "")) return [];
|
|
14
|
-
return [resolveDefaultSetupNostrAccountId(cfg)];
|
|
15
|
-
}
|
|
16
|
-
function resolveDefaultSetupNostrAccountId(cfg) {
|
|
17
|
-
const configured = getNostrConfig(cfg)?.defaultAccount;
|
|
18
|
-
return typeof configured === "string" && configured.trim() ? configured.trim() : DEFAULT_ACCOUNT_ID;
|
|
19
|
-
}
|
|
20
|
-
function resolveSetupNostrAccount(params) {
|
|
21
|
-
const nostrCfg = getNostrConfig(params.cfg);
|
|
22
|
-
const accountId = params.accountId?.trim() || resolveDefaultSetupNostrAccountId(params.cfg);
|
|
23
|
-
const privateKey = typeof nostrCfg?.privateKey === "string" ? nostrCfg.privateKey.trim() : "";
|
|
24
|
-
const configured = Boolean(privateKey);
|
|
25
|
-
return {
|
|
26
|
-
accountId,
|
|
27
|
-
name: typeof nostrCfg?.name === "string" ? nostrCfg.name : void 0,
|
|
28
|
-
enabled: nostrCfg?.enabled !== false,
|
|
29
|
-
configured,
|
|
30
|
-
privateKey,
|
|
31
|
-
publicKey: "",
|
|
32
|
-
relays: nostrCfg?.relays ?? DEFAULT_RELAYS,
|
|
33
|
-
profile: nostrCfg?.profile,
|
|
34
|
-
config: {
|
|
35
|
-
enabled: nostrCfg?.enabled,
|
|
36
|
-
name: nostrCfg?.name,
|
|
37
|
-
privateKey: nostrCfg?.privateKey,
|
|
38
|
-
relays: nostrCfg?.relays,
|
|
39
|
-
dmPolicy: nostrCfg?.dmPolicy,
|
|
40
|
-
allowFrom: nostrCfg?.allowFrom,
|
|
41
|
-
profile: nostrCfg?.profile
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
function looksLikeNostrPrivateKey(privateKey) {
|
|
46
|
-
return privateKey.startsWith("nsec1") || privateKey.startsWith("NSEC1") || /^[0-9a-fA-F]{64}$/.test(privateKey);
|
|
47
|
-
}
|
|
48
|
-
const nostrSetupAdapter = createNostrSetupAdapter({
|
|
49
|
-
resolveAccountId: (cfg, accountId) => accountId?.trim() || resolveDefaultSetupNostrAccountId(cfg),
|
|
50
|
-
validatePrivateKey: looksLikeNostrPrivateKey
|
|
51
|
-
});
|
|
52
|
-
const nostrSetupContract = createNostrSetupContract(nostrSetupAdapter);
|
|
53
|
-
const nostrSetupWizard = createDelegatedSetupWizardProxy({
|
|
54
|
-
channel,
|
|
55
|
-
loadWizard: async () => (await import("./setup-surface-BJCFpe02.js").then((n) => n.i)).nostrSetupWizard,
|
|
56
|
-
status: { ...createStandardChannelSetupStatus({
|
|
57
|
-
channelLabel: "Nostr",
|
|
58
|
-
configuredLabel: t("wizard.channels.statusConfigured"),
|
|
59
|
-
unconfiguredLabel: t("wizard.channels.statusNeedsPrivateKey"),
|
|
60
|
-
configuredHint: t("wizard.channels.statusConfigured"),
|
|
61
|
-
unconfiguredHint: t("wizard.channels.statusNeedsPrivateKey"),
|
|
62
|
-
configuredScore: 1,
|
|
63
|
-
unconfiguredScore: 0,
|
|
64
|
-
includeStatusLine: true,
|
|
65
|
-
resolveConfigured: ({ cfg, accountId }) => resolveSetupNostrAccount({
|
|
66
|
-
cfg,
|
|
67
|
-
accountId
|
|
68
|
-
}).configured,
|
|
69
|
-
resolveExtraStatusLines: ({ cfg }) => {
|
|
70
|
-
return [`Relays: ${resolveSetupNostrAccount({ cfg }).relays.length || DEFAULT_RELAYS.length}`];
|
|
71
|
-
}
|
|
72
|
-
}) },
|
|
73
|
-
resolveShouldPromptAccountIds: () => false,
|
|
74
|
-
delegatePrepare: true,
|
|
75
|
-
delegateFinalize: true
|
|
76
|
-
});
|
|
77
|
-
const nostrSetupPlugin = {
|
|
78
|
-
id: channel,
|
|
79
|
-
meta: {
|
|
80
|
-
id: channel,
|
|
81
|
-
label: "Nostr",
|
|
82
|
-
selectionLabel: "Nostr",
|
|
83
|
-
docsPath: "/channels/nostr",
|
|
84
|
-
docsLabel: "nostr",
|
|
85
|
-
blurb: "Decentralized DMs via Nostr relays (NIP-04)",
|
|
86
|
-
order: 100
|
|
87
|
-
},
|
|
88
|
-
capabilities: {
|
|
89
|
-
chatTypes: ["direct"],
|
|
90
|
-
media: false
|
|
91
|
-
},
|
|
92
|
-
reload: { configPrefixes: ["channels.nostr"] },
|
|
93
|
-
configSchema: buildChannelConfigSchema(NostrConfigSchema),
|
|
94
|
-
setup: nostrSetupAdapter,
|
|
95
|
-
setupContract: nostrSetupContract,
|
|
96
|
-
setupWizard: nostrSetupWizard,
|
|
97
|
-
config: {
|
|
98
|
-
listAccountIds: listSetupNostrAccountIds,
|
|
99
|
-
resolveAccount: (cfg, accountId) => resolveSetupNostrAccount({
|
|
100
|
-
cfg,
|
|
101
|
-
accountId
|
|
102
|
-
}),
|
|
103
|
-
defaultAccountId: resolveDefaultSetupNostrAccountId,
|
|
104
|
-
isConfigured: (account) => account.configured,
|
|
105
|
-
describeAccount: (account) => describeAccountSnapshot({
|
|
106
|
-
account,
|
|
107
|
-
configured: account.configured,
|
|
108
|
-
extra: { publicKey: account.publicKey }
|
|
109
|
-
})
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
//#endregion
|
|
1
|
+
import { t as nostrSetupPlugin } from "./.setup/setup-plugin-api-csfJrRxD.mjs";
|
|
113
2
|
export { nostrSetupPlugin };
|
|
@@ -24,6 +24,9 @@ __export(abstract_pool_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(abstract_pool_exports);
|
|
26
26
|
|
|
27
|
+
// core.ts
|
|
28
|
+
var verifiedSymbol = Symbol("verified");
|
|
29
|
+
|
|
27
30
|
// utils.ts
|
|
28
31
|
var import_utils = require("@noble/hashes/utils.js");
|
|
29
32
|
var utf8Decoder = new TextDecoder("utf-8");
|
|
@@ -143,14 +146,12 @@ var AbstractRelay = class {
|
|
|
143
146
|
openSubs = /* @__PURE__ */ new Map();
|
|
144
147
|
enablePing;
|
|
145
148
|
enableReconnect;
|
|
146
|
-
idleTimeout = 0;
|
|
147
149
|
idleSince = Date.now();
|
|
148
150
|
ongoingOperations = 0;
|
|
149
151
|
reconnectTimeoutHandle;
|
|
150
152
|
pingIntervalHandle;
|
|
151
153
|
reconnectAttempts = 0;
|
|
152
154
|
skipReconnection = false;
|
|
153
|
-
idleTimeoutHandle;
|
|
154
155
|
connectionPromise;
|
|
155
156
|
openCountRequests = /* @__PURE__ */ new Map();
|
|
156
157
|
openEventPublishes = /* @__PURE__ */ new Map();
|
|
@@ -166,8 +167,6 @@ var AbstractRelay = class {
|
|
|
166
167
|
this._WebSocket = opts.websocketImplementation || WebSocket;
|
|
167
168
|
this.enablePing = opts.enablePing;
|
|
168
169
|
this.enableReconnect = opts.enableReconnect || false;
|
|
169
|
-
if (opts.idleTimeout)
|
|
170
|
-
this.idleTimeout = opts.idleTimeout;
|
|
171
170
|
}
|
|
172
171
|
static async connect(url, opts) {
|
|
173
172
|
const relay = new AbstractRelay(url, opts);
|
|
@@ -191,22 +190,6 @@ var AbstractRelay = class {
|
|
|
191
190
|
get connected() {
|
|
192
191
|
return this._connected;
|
|
193
192
|
}
|
|
194
|
-
clearIdleTimeout() {
|
|
195
|
-
if (this.idleTimeoutHandle) {
|
|
196
|
-
clearTimeout(this.idleTimeoutHandle);
|
|
197
|
-
this.idleTimeoutHandle = void 0;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
scheduleIdleClose() {
|
|
201
|
-
this.clearIdleTimeout();
|
|
202
|
-
if (this.idleTimeout > 0) {
|
|
203
|
-
this.idleTimeoutHandle = setTimeout(() => {
|
|
204
|
-
if (this.ongoingOperations === 0 && this.idleSince) {
|
|
205
|
-
this.close();
|
|
206
|
-
}
|
|
207
|
-
}, this.idleTimeout);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
193
|
async reconnect() {
|
|
211
194
|
const backoff = this.resubscribeBackoff[Math.min(this.reconnectAttempts, this.resubscribeBackoff.length - 1)];
|
|
212
195
|
this.reconnectAttempts++;
|
|
@@ -218,11 +201,6 @@ var AbstractRelay = class {
|
|
|
218
201
|
}, backoff);
|
|
219
202
|
}
|
|
220
203
|
handleHardClose(reason) {
|
|
221
|
-
if (this.ws) {
|
|
222
|
-
this.ws.onopen = null;
|
|
223
|
-
this.ws.onerror = null;
|
|
224
|
-
this.ws.onclose = null;
|
|
225
|
-
}
|
|
226
204
|
if (this.pingIntervalHandle) {
|
|
227
205
|
clearInterval(this.pingIntervalHandle);
|
|
228
206
|
this.pingIntervalHandle = void 0;
|
|
@@ -230,7 +208,6 @@ var AbstractRelay = class {
|
|
|
230
208
|
this._connected = false;
|
|
231
209
|
this.connectionPromise = void 0;
|
|
232
210
|
this.idleSince = void 0;
|
|
233
|
-
this.clearIdleTimeout();
|
|
234
211
|
if (this.enableReconnect && !this.skipReconnection) {
|
|
235
212
|
this.reconnect();
|
|
236
213
|
} else {
|
|
@@ -253,6 +230,7 @@ var AbstractRelay = class {
|
|
|
253
230
|
if (this.reconnectAttempts === 0) {
|
|
254
231
|
this.skipReconnection = true;
|
|
255
232
|
}
|
|
233
|
+
this.onclose?.();
|
|
256
234
|
this.handleHardClose("relay connection timed out");
|
|
257
235
|
}, opts.timeout);
|
|
258
236
|
}
|
|
@@ -298,6 +276,7 @@ var AbstractRelay = class {
|
|
|
298
276
|
if (this.reconnectAttempts === 0) {
|
|
299
277
|
this.skipReconnection = true;
|
|
300
278
|
}
|
|
279
|
+
this.onclose?.();
|
|
301
280
|
this.handleHardClose("relay connection failed");
|
|
302
281
|
};
|
|
303
282
|
this.ws.onclose = (ev) => {
|
|
@@ -386,7 +365,6 @@ var AbstractRelay = class {
|
|
|
386
365
|
}
|
|
387
366
|
async publish(event) {
|
|
388
367
|
this.idleSince = void 0;
|
|
389
|
-
this.clearIdleTimeout();
|
|
390
368
|
this.ongoingOperations++;
|
|
391
369
|
const ret = new Promise((resolve, reject) => {
|
|
392
370
|
const timeout = setTimeout(() => {
|
|
@@ -408,10 +386,8 @@ var AbstractRelay = class {
|
|
|
408
386
|
}
|
|
409
387
|
}
|
|
410
388
|
this.ongoingOperations--;
|
|
411
|
-
if (this.ongoingOperations === 0)
|
|
389
|
+
if (this.ongoingOperations === 0)
|
|
412
390
|
this.idleSince = Date.now();
|
|
413
|
-
this.scheduleIdleClose();
|
|
414
|
-
}
|
|
415
391
|
return ret;
|
|
416
392
|
}
|
|
417
393
|
async count(filters, params) {
|
|
@@ -437,7 +413,6 @@ var AbstractRelay = class {
|
|
|
437
413
|
subscribe(filters, params) {
|
|
438
414
|
if (params.label !== "<forced-ping>") {
|
|
439
415
|
this.idleSince = void 0;
|
|
440
|
-
this.clearIdleTimeout();
|
|
441
416
|
this.ongoingOperations++;
|
|
442
417
|
}
|
|
443
418
|
const sub = this.prepareSubscription(filters, params);
|
|
@@ -466,17 +441,10 @@ var AbstractRelay = class {
|
|
|
466
441
|
}
|
|
467
442
|
this.closeAllSubscriptions("relay connection closed by us");
|
|
468
443
|
this._connected = false;
|
|
469
|
-
this.connectionPromise = void 0;
|
|
470
444
|
this.idleSince = void 0;
|
|
471
|
-
this.clearIdleTimeout();
|
|
472
445
|
this.onclose?.();
|
|
473
|
-
if (this.ws) {
|
|
474
|
-
this.ws
|
|
475
|
-
this.ws.onerror = null;
|
|
476
|
-
this.ws.onclose = null;
|
|
477
|
-
if (this.ws.readyState !== this._WebSocket.CLOSING && this.ws.readyState !== this._WebSocket.CLOSED) {
|
|
478
|
-
this.ws.close();
|
|
479
|
-
}
|
|
446
|
+
if (this.ws?.readyState === this._WebSocket.OPEN) {
|
|
447
|
+
this.ws?.close();
|
|
480
448
|
}
|
|
481
449
|
}
|
|
482
450
|
_onmessage(ev) {
|
|
@@ -503,7 +471,7 @@ var AbstractRelay = class {
|
|
|
503
471
|
case "EVENT": {
|
|
504
472
|
const so = this.openSubs.get(data[1]);
|
|
505
473
|
const event = data[2];
|
|
506
|
-
if (
|
|
474
|
+
if (this.verifyEvent(event) && matchFilters(so.filters, event)) {
|
|
507
475
|
so.onevent(event);
|
|
508
476
|
} else {
|
|
509
477
|
so.oninvalidevent?.(event);
|
|
@@ -651,14 +619,18 @@ var Subscription = class {
|
|
|
651
619
|
}
|
|
652
620
|
this.relay.openSubs.delete(this.id);
|
|
653
621
|
this.relay.ongoingOperations--;
|
|
654
|
-
if (this.relay.ongoingOperations === 0)
|
|
622
|
+
if (this.relay.ongoingOperations === 0)
|
|
655
623
|
this.relay.idleSince = Date.now();
|
|
656
|
-
this.relay.scheduleIdleClose();
|
|
657
|
-
}
|
|
658
624
|
this.onclose?.(reason);
|
|
659
625
|
}
|
|
660
626
|
};
|
|
661
627
|
|
|
628
|
+
// helpers.ts
|
|
629
|
+
var alwaysTrue = (t) => {
|
|
630
|
+
t[verifiedSymbol] = true;
|
|
631
|
+
return true;
|
|
632
|
+
};
|
|
633
|
+
|
|
662
634
|
// nip45.ts
|
|
663
635
|
var import_sha2 = require("@noble/hashes/sha2.js");
|
|
664
636
|
var import_utils3 = require("@noble/hashes/utils.js");
|
|
@@ -685,7 +657,7 @@ function newHll() {
|
|
|
685
657
|
return new Uint8Array(M);
|
|
686
658
|
}
|
|
687
659
|
function hllDecode(hex) {
|
|
688
|
-
if (hex.length !== HLL_HEX_LENGTH || !/^[0-9a-
|
|
660
|
+
if (hex.length !== HLL_HEX_LENGTH || !/^[0-9a-fA-F]+$/.test(hex))
|
|
689
661
|
return void 0;
|
|
690
662
|
const registers = new Uint8Array(M);
|
|
691
663
|
for (let i = 0; i < M; i++) {
|
|
@@ -724,8 +696,8 @@ var AbstractSimplePool = class {
|
|
|
724
696
|
verifyEvent;
|
|
725
697
|
enablePing;
|
|
726
698
|
enableReconnect;
|
|
727
|
-
idleTimeout = 2e4;
|
|
728
699
|
automaticallyAuth;
|
|
700
|
+
trustedRelayURLs = /* @__PURE__ */ new Set();
|
|
729
701
|
onRelayConnectionFailure;
|
|
730
702
|
onRelayConnectionSuccess;
|
|
731
703
|
allowConnectingToRelay;
|
|
@@ -736,8 +708,6 @@ var AbstractSimplePool = class {
|
|
|
736
708
|
this._WebSocket = opts.websocketImplementation;
|
|
737
709
|
this.enablePing = opts.enablePing;
|
|
738
710
|
this.enableReconnect = opts.enableReconnect || false;
|
|
739
|
-
if (opts.idleTimeout)
|
|
740
|
-
this.idleTimeout = opts.idleTimeout;
|
|
741
711
|
this.automaticallyAuth = opts.automaticallyAuth;
|
|
742
712
|
this.onRelayConnectionFailure = opts.onRelayConnectionFailure;
|
|
743
713
|
this.onRelayConnectionSuccess = opts.onRelayConnectionSuccess;
|
|
@@ -749,11 +719,10 @@ var AbstractSimplePool = class {
|
|
|
749
719
|
let relay = this.relays.get(url);
|
|
750
720
|
if (!relay) {
|
|
751
721
|
relay = new AbstractRelay(url, {
|
|
752
|
-
verifyEvent: this.verifyEvent,
|
|
722
|
+
verifyEvent: this.trustedRelayURLs.has(url) ? alwaysTrue : this.verifyEvent,
|
|
753
723
|
websocketImplementation: this._WebSocket,
|
|
754
724
|
enablePing: this.enablePing,
|
|
755
|
-
enableReconnect: this.enableReconnect
|
|
756
|
-
idleTimeout: this.idleTimeout
|
|
725
|
+
enableReconnect: this.enableReconnect
|
|
757
726
|
});
|
|
758
727
|
relay.onclose = () => {
|
|
759
728
|
this.relays.delete(url);
|
|
@@ -833,11 +802,11 @@ var AbstractSimplePool = class {
|
|
|
833
802
|
}
|
|
834
803
|
};
|
|
835
804
|
const closesReceived = [];
|
|
836
|
-
let handleClose = (i,
|
|
805
|
+
let handleClose = (i, reason) => {
|
|
837
806
|
if (closesReceived[i])
|
|
838
807
|
return;
|
|
839
808
|
handleEose(i);
|
|
840
|
-
closesReceived[i] =
|
|
809
|
+
closesReceived[i] = reason;
|
|
841
810
|
if (closesReceived.filter((a) => a).length === groupedRequests.length) {
|
|
842
811
|
params.onclose?.(closesReceived);
|
|
843
812
|
handleClose = () => {
|
|
@@ -855,7 +824,7 @@ var AbstractSimplePool = class {
|
|
|
855
824
|
const allOpened = Promise.all(
|
|
856
825
|
groupedRequests.map(async ({ url, filters }, i) => {
|
|
857
826
|
if (this.allowConnectingToRelay?.(url, ["read", filters]) === false) {
|
|
858
|
-
handleClose(i,
|
|
827
|
+
handleClose(i, "connection skipped by allowConnectingToRelay");
|
|
859
828
|
return;
|
|
860
829
|
}
|
|
861
830
|
let relay;
|
|
@@ -866,7 +835,7 @@ var AbstractSimplePool = class {
|
|
|
866
835
|
});
|
|
867
836
|
} catch (err) {
|
|
868
837
|
this.onRelayConnectionFailure?.(url);
|
|
869
|
-
handleClose(i,
|
|
838
|
+
handleClose(i, err?.message || String(err));
|
|
870
839
|
return;
|
|
871
840
|
}
|
|
872
841
|
this.onRelayConnectionSuccess?.(url);
|
|
@@ -880,17 +849,17 @@ var AbstractSimplePool = class {
|
|
|
880
849
|
...params,
|
|
881
850
|
oneose: () => handleEose(i),
|
|
882
851
|
onclose: (reason2) => {
|
|
883
|
-
handleClose(i,
|
|
852
|
+
handleClose(i, reason2);
|
|
884
853
|
},
|
|
885
854
|
alreadyHaveEvent: localAlreadyHaveEventHandler,
|
|
886
855
|
eoseTimeout: params.maxWait,
|
|
887
856
|
abort: params.abort
|
|
888
857
|
});
|
|
889
858
|
}).catch((err) => {
|
|
890
|
-
handleClose(i,
|
|
859
|
+
handleClose(i, `auth was required and attempted, but failed with: ${err}`);
|
|
891
860
|
});
|
|
892
861
|
} else {
|
|
893
|
-
handleClose(i,
|
|
862
|
+
handleClose(i, reason);
|
|
894
863
|
}
|
|
895
864
|
},
|
|
896
865
|
alreadyHaveEvent: localAlreadyHaveEventHandler,
|
|
@@ -918,7 +887,7 @@ var AbstractSimplePool = class {
|
|
|
918
887
|
if (subcloser)
|
|
919
888
|
subcloser.close(reason);
|
|
920
889
|
else
|
|
921
|
-
params.onclose?.(relays.map((
|
|
890
|
+
params.onclose?.(relays.map((_) => reason));
|
|
922
891
|
}
|
|
923
892
|
});
|
|
924
893
|
return subcloser;
|