@qntx/nostr 0.6.0 → 0.8.0
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/{abort-Ba8tDrOI.mjs → abort-DBq2STPj.mjs} +13 -6
- package/dist/abort-DBq2STPj.mjs.map +1 -0
- package/dist/{builder-sSflu6nB.d.mts → builder-CTwkB2zM.d.mts} +14 -15
- package/dist/{builder-9tjI6WQ3.mjs → builder-aNU2gGFP.mjs} +11 -17
- package/dist/builder-aNU2gGFP.mjs.map +1 -0
- package/dist/{client-CadO5fAX.mjs → client-Cj2lUaVh.mjs} +141 -353
- package/dist/client-Cj2lUaVh.mjs.map +1 -0
- package/dist/client.d.mts +2 -2
- package/dist/client.mjs +2 -2
- package/dist/collections-DtwMc1NU.mjs +33 -0
- package/dist/collections-DtwMc1NU.mjs.map +1 -0
- package/dist/core.d.mts +9 -8
- package/dist/core.mjs +7 -7
- package/dist/emitter-DkCY6NkU.mjs +32 -0
- package/dist/emitter-DkCY6NkU.mjs.map +1 -0
- package/dist/{error-BW7re1UN.d.mts → error-BD_0QFKT.d.mts} +2 -2
- package/dist/{error-DrEIM7FO.mjs → error-BILMe3Gr.mjs} +2 -2
- package/dist/{error-DrEIM7FO.mjs.map → error-BILMe3Gr.mjs.map} +1 -1
- package/dist/{error-CR8Urc84.d.mts → error-BquXDmIN.d.mts} +4 -4
- package/dist/{error-B__OMBRY.mjs → error-DlhGW4mJ.mjs} +2 -2
- package/dist/{error-B__OMBRY.mjs.map → error-DlhGW4mJ.mjs.map} +1 -1
- package/dist/{event-D8Nfoh4K.mjs → event-CHf47dPM.mjs} +16 -10
- package/dist/event-CHf47dPM.mjs.map +1 -0
- package/dist/{event-fU3Y01PR.d.mts → event-DJeb_DIL.d.mts} +4 -2
- package/dist/{filter-C0IMByE3.d.mts → filter-jI_9htF7.d.mts} +2 -2
- package/dist/{gossip-oloDMWEj.mjs → gossip-DFxIBlsr.mjs} +23 -33
- package/dist/gossip-DFxIBlsr.mjs.map +1 -0
- package/dist/{gossip-DpIvkBuj.d.mts → gossip-OOeeFzG5.d.mts} +37 -28
- package/dist/gossip.d.mts +1 -1
- package/dist/gossip.mjs +1 -1
- package/dist/{index-D1bqFHKB.d.mts → index-BxCBX-8R.d.mts} +18 -18
- package/dist/{index-lvXeER5t.d.mts → index-CPVEyzNX.d.mts} +32 -50
- package/dist/{index-MxC28S4P.d.mts → index-C_w2WfVz.d.mts} +27 -29
- package/dist/{index-CNl2q67H.d.mts → index-Cl_1XdYP.d.mts} +111 -180
- package/dist/{index-CvkvqB16.d.mts → index-DU9tRFTZ.d.mts} +7 -20
- package/dist/{index-q4MDce_r.d.mts → index-DyKwQnbt.d.mts} +6 -8
- package/dist/index.d.mts +23 -21
- package/dist/index.mjs +21 -19
- package/dist/{instance-DQE8BoWt.mjs → instance-C62w3cEt.mjs} +26 -27
- package/dist/instance-C62w3cEt.mjs.map +1 -0
- package/dist/{instance-CIca-ynn.d.mts → instance-DjsL8h84.d.mts} +5 -5
- package/dist/{key-Cv4_pN3x.d.mts → key-D_5OgGT7.d.mts} +11 -7
- package/dist/{key-Bps-LqX7.mjs → key-DnVpchl6.mjs} +13 -9
- package/dist/key-DnVpchl6.mjs.map +1 -0
- package/dist/{loaders-o6YXB_Ri.mjs → loaders-BmPkQfzI.mjs} +73 -82
- package/dist/loaders-BmPkQfzI.mjs.map +1 -0
- package/dist/loaders.d.mts +3 -3
- package/dist/loaders.mjs +2 -2
- package/dist/{memory-C2EVx0_O.mjs → memory-CdJ07kub.mjs} +2 -2
- package/dist/memory-CdJ07kub.mjs.map +1 -0
- package/dist/{memory-index-Do1mz0WF.mjs → memory-index-Cbc83vOZ.mjs} +30 -247
- package/dist/memory-index-Cbc83vOZ.mjs.map +1 -0
- package/dist/message-oNr7t0SJ.mjs +194 -0
- package/dist/message-oNr7t0SJ.mjs.map +1 -0
- package/dist/{message-iGPIqnn0.d.mts → message-tclYCVNc.d.mts} +6 -6
- package/dist/{nip17-CKIufV98.d.mts → nip17-B5WgW4C4.d.mts} +6 -7
- package/dist/{nip19-BevCJZsp.d.mts → nip19-DpPN17bY.d.mts} +25 -31
- package/dist/{nip46-DDV4dC56.d.mts → nip46-BHaxC9TZ.d.mts} +19 -21
- package/dist/nip51-CR0Q8eym.d.mts +87 -0
- package/dist/{nip59-zQgdLcEr.d.mts → nip59-C-RWFQIv.d.mts} +11 -5
- package/dist/nip65-D1fbmhOg.d.mts +23 -0
- package/dist/{nip77-DH4RhS5r.d.mts → nip77-DzUwUxHq.d.mts} +8 -9
- package/dist/nips/blossom.d.mts +17 -13
- package/dist/nips/blossom.mjs +30 -9
- package/dist/nips/blossom.mjs.map +1 -1
- package/dist/nips/nip04.mjs +17 -7
- package/dist/nips/nip04.mjs.map +1 -1
- package/dist/nips/nip05.d.mts +9 -10
- package/dist/nips/nip05.mjs +1 -4
- package/dist/nips/nip05.mjs.map +1 -1
- package/dist/nips/nip10.d.mts +8 -8
- package/dist/nips/nip10.mjs +34 -32
- package/dist/nips/nip10.mjs.map +1 -1
- package/dist/nips/nip11.d.mts +28 -28
- package/dist/nips/nip11.mjs +4 -4
- package/dist/nips/nip11.mjs.map +1 -1
- package/dist/nips/nip13.d.mts +7 -7
- package/dist/nips/nip13.mjs +32 -10
- package/dist/nips/nip13.mjs.map +1 -1
- package/dist/nips/nip17.d.mts +1 -1
- package/dist/nips/nip17.mjs +16 -34
- package/dist/nips/nip17.mjs.map +1 -1
- package/dist/nips/nip19.d.mts +2 -2
- package/dist/nips/nip19.mjs +16 -28
- package/dist/nips/nip19.mjs.map +1 -1
- package/dist/nips/nip21.d.mts +9 -4
- package/dist/nips/nip21.mjs +15 -5
- package/dist/nips/nip21.mjs.map +1 -1
- package/dist/nips/nip27.d.mts +22 -22
- package/dist/nips/nip27.mjs +2 -2
- package/dist/nips/nip27.mjs.map +1 -1
- package/dist/nips/nip42.d.mts +1 -1
- package/dist/nips/nip42.mjs +2 -1
- package/dist/nips/nip42.mjs.map +1 -1
- package/dist/nips/nip44.mjs +2 -2
- package/dist/nips/nip44.mjs.map +1 -1
- package/dist/nips/nip46.d.mts +2 -2
- package/dist/nips/nip46.mjs +15 -19
- package/dist/nips/nip46.mjs.map +1 -1
- package/dist/nips/nip49.d.mts +9 -9
- package/dist/nips/nip49.mjs +4 -4
- package/dist/nips/nip49.mjs.map +1 -1
- package/dist/nips/nip51.d.mts +2 -86
- package/dist/nips/nip51.mjs +7 -23
- package/dist/nips/nip51.mjs.map +1 -1
- package/dist/nips/nip57.d.mts +25 -23
- package/dist/nips/nip57.mjs +12 -17
- package/dist/nips/nip57.mjs.map +1 -1
- package/dist/nips/nip59.d.mts +1 -1
- package/dist/nips/nip59.mjs +27 -19
- package/dist/nips/nip59.mjs.map +1 -1
- package/dist/nips/nip65.d.mts +2 -2
- package/dist/nips/nip65.mjs +14 -37
- package/dist/nips/nip65.mjs.map +1 -1
- package/dist/nips/nip77.d.mts +1 -1
- package/dist/nips/nip77.mjs +33 -32
- package/dist/nips/nip77.mjs.map +1 -1
- package/dist/nips/nip98.d.mts +5 -5
- package/dist/nips/nip98.mjs +8 -8
- package/dist/nips/nip98.mjs.map +1 -1
- package/dist/{pool-DBIYMtwy.d.mts → pool-CqQvUnsq.d.mts} +132 -108
- package/dist/pool-vlw74C4t.mjs +606 -0
- package/dist/pool-vlw74C4t.mjs.map +1 -0
- package/dist/put-w13ci3sC.mjs +187 -0
- package/dist/put-w13ci3sC.mjs.map +1 -0
- package/dist/{reactive-BfhPp9a3.mjs → reactive-Tz0otDIP.mjs} +125 -88
- package/dist/reactive-Tz0otDIP.mjs.map +1 -0
- package/dist/{reactive-7aqeip4A.d.mts → reactive-gGqUrzW8.d.mts} +20 -26
- package/dist/relay-quCs7MHD.mjs +1811 -0
- package/dist/relay-quCs7MHD.mjs.map +1 -0
- package/dist/relay.d.mts +4 -4
- package/dist/relay.mjs +3 -2
- package/dist/serial-Bzpw-xz3.mjs +21 -0
- package/dist/serial-Bzpw-xz3.mjs.map +1 -0
- package/dist/{signer-CYQutDzD.mjs → signer-poTGe6Er.mjs} +12 -14
- package/dist/signer-poTGe6Er.mjs.map +1 -0
- package/dist/signer.d.mts +2 -2
- package/dist/signer.mjs +2 -2
- package/dist/{storage-Dky3wuoH.mjs → storage-B5IXTVuS.mjs} +28 -51
- package/dist/storage-B5IXTVuS.mjs.map +1 -0
- package/dist/storage.d.mts +3 -3
- package/dist/storage.mjs +4 -4
- package/dist/store.d.mts +2 -2
- package/dist/store.mjs +1 -1
- package/dist/testing.d.mts +19 -19
- package/dist/testing.mjs +9 -9
- package/dist/testing.mjs.map +1 -1
- package/dist/{types-2pCUprRU.d.mts → types-BacwnDtU.d.mts} +10 -10
- package/dist/{types-CRQEk0Oi.d.mts → types-DNmiscfd.d.mts} +2 -2
- package/dist/{util-LfQirgDk.mjs → util-DMF9AIO0.mjs} +33 -7
- package/dist/util-DMF9AIO0.mjs.map +1 -0
- package/dist/{verifier-t5WoWbtY.mjs → verifier-B51Wkt5H.mjs} +3 -3
- package/dist/verifier-B51Wkt5H.mjs.map +1 -0
- package/dist/verifier-CgTFpgsC.d.mts +22 -0
- package/dist/wasm.browser.d.mts +3 -3
- package/dist/wasm.browser.mjs +3 -3
- package/dist/wasm.d.mts +3 -3
- package/dist/wasm.mjs +3 -3
- package/dist/wasm.mjs.map +1 -1
- package/package.json +5 -9
- package/dist/abort-Ba8tDrOI.mjs.map +0 -1
- package/dist/builder-9tjI6WQ3.mjs.map +0 -1
- package/dist/client-CadO5fAX.mjs.map +0 -1
- package/dist/event-D8Nfoh4K.mjs.map +0 -1
- package/dist/gossip-oloDMWEj.mjs.map +0 -1
- package/dist/instance-DQE8BoWt.mjs.map +0 -1
- package/dist/key-Bps-LqX7.mjs.map +0 -1
- package/dist/loaders-o6YXB_Ri.mjs.map +0 -1
- package/dist/memory-C2EVx0_O.mjs.map +0 -1
- package/dist/memory-index-Do1mz0WF.mjs.map +0 -1
- package/dist/message-DcY6Fi9o.mjs +0 -193
- package/dist/message-DcY6Fi9o.mjs.map +0 -1
- package/dist/nip65-CjgmdpPB.d.mts +0 -26
- package/dist/nips/nip96.d.mts +0 -40
- package/dist/nips/nip96.mjs +0 -118
- package/dist/nips/nip96.mjs.map +0 -1
- package/dist/pool-As20OGxB.mjs +0 -2166
- package/dist/pool-As20OGxB.mjs.map +0 -1
- package/dist/reactive-BfhPp9a3.mjs.map +0 -1
- package/dist/signer-CYQutDzD.mjs.map +0 -1
- package/dist/storage-Dky3wuoH.mjs.map +0 -1
- package/dist/util-LfQirgDk.mjs.map +0 -1
- package/dist/verifier-t5WoWbtY.mjs.map +0 -1
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { _ as MessageError, a as hexToBytes, c as isRecord, i as bytesToHex } from "./util-DMF9AIO0.mjs";
|
|
2
|
+
import { m as validateSignedEvent } from "./event-CHf47dPM.mjs";
|
|
3
|
+
//#region src/core/message.ts
|
|
4
|
+
/** Validate a subscription id; throws {@link MessageError} unless 1..64 chars. */
|
|
5
|
+
function assertSubscriptionId(id) {
|
|
6
|
+
if (id.length === 0 || id.length > 64) throw new MessageError(`subscription id length must be 1..64`);
|
|
7
|
+
return id;
|
|
8
|
+
}
|
|
9
|
+
/** Validate the given id, or mint a random 16-hex-char subscription id. */
|
|
10
|
+
function createSubscriptionId(id) {
|
|
11
|
+
if (id !== void 0) return assertSubscriptionId(id);
|
|
12
|
+
const bytes = /* @__PURE__ */ new Uint8Array(8);
|
|
13
|
+
crypto.getRandomValues(bytes);
|
|
14
|
+
return bytesToHex(bytes);
|
|
15
|
+
}
|
|
16
|
+
const HLL_BYTES = 256;
|
|
17
|
+
const HLL_HEX_LEN = HLL_BYTES * 2;
|
|
18
|
+
const HEX_RE = /^[0-9a-fA-F]+$/;
|
|
19
|
+
/**
|
|
20
|
+
* Register-wise max of NIP-45 HyperLogLog sketches. Output is always lowercase 512 hex. Empty input
|
|
21
|
+
* is the zero sketch (identity).
|
|
22
|
+
*/
|
|
23
|
+
function mergeCountHll(hexes) {
|
|
24
|
+
const merged = new Uint8Array(HLL_BYTES);
|
|
25
|
+
for (const hex of hexes) {
|
|
26
|
+
if (hex.length !== HLL_HEX_LEN || !HEX_RE.test(hex)) throw new MessageError("invalid NIP-45 HLL sketch: expected 512-char hex");
|
|
27
|
+
const bytes = hexToBytes(hex);
|
|
28
|
+
for (const [i, b] of bytes.entries()) {
|
|
29
|
+
const m = merged[i];
|
|
30
|
+
if (m !== void 0 && b > m) merged[i] = b;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return bytesToHex(merged);
|
|
34
|
+
}
|
|
35
|
+
/** Serialize a client->relay message to its NIP-01 JSON wire form. */
|
|
36
|
+
function encodeClientMessage(message) {
|
|
37
|
+
return JSON.stringify(message);
|
|
38
|
+
}
|
|
39
|
+
/** Serialize a relay->client message to its NIP-01 JSON wire form. */
|
|
40
|
+
function encodeRelayMessage(message) {
|
|
41
|
+
return JSON.stringify(message);
|
|
42
|
+
}
|
|
43
|
+
/** Parse a client->relay JSON message; throws {@link MessageError} on malformed input. */
|
|
44
|
+
function parseClientMessage(raw) {
|
|
45
|
+
let parsed;
|
|
46
|
+
try {
|
|
47
|
+
parsed = JSON.parse(raw);
|
|
48
|
+
} catch {
|
|
49
|
+
throw new MessageError("client message is not valid JSON");
|
|
50
|
+
}
|
|
51
|
+
if (!Array.isArray(parsed) || parsed.length === 0 || typeof parsed[0] !== "string") throw new MessageError("client message must be a non-empty JSON array");
|
|
52
|
+
const items = parsed;
|
|
53
|
+
const [type] = items;
|
|
54
|
+
switch (type) {
|
|
55
|
+
case "EVENT":
|
|
56
|
+
if (items.length !== 2 || !validateSignedEvent(items[1])) throw new MessageError("invalid EVENT client message");
|
|
57
|
+
return ["EVENT", items[1]];
|
|
58
|
+
case "REQ":
|
|
59
|
+
if (items.length < 3 || typeof items[1] !== "string") throw new MessageError("invalid REQ client message");
|
|
60
|
+
return [
|
|
61
|
+
"REQ",
|
|
62
|
+
items[1],
|
|
63
|
+
...parseWireFilters(items.slice(2), "REQ")
|
|
64
|
+
];
|
|
65
|
+
case "CLOSE":
|
|
66
|
+
if (items.length !== 2 || typeof items[1] !== "string") throw new MessageError("invalid CLOSE client message");
|
|
67
|
+
return ["CLOSE", items[1]];
|
|
68
|
+
case "AUTH":
|
|
69
|
+
if (items.length !== 2 || !validateSignedEvent(items[1])) throw new MessageError("invalid AUTH client message");
|
|
70
|
+
return ["AUTH", items[1]];
|
|
71
|
+
case "COUNT":
|
|
72
|
+
if (items.length < 3 || typeof items[1] !== "string") throw new MessageError("invalid COUNT client message");
|
|
73
|
+
return [
|
|
74
|
+
"COUNT",
|
|
75
|
+
items[1],
|
|
76
|
+
...parseWireFilters(items.slice(2), "COUNT")
|
|
77
|
+
];
|
|
78
|
+
case "NEG-OPEN":
|
|
79
|
+
if (items.length === 5) throw new MessageError("obsolete 5-element NEG-OPEN; expected [NEG-OPEN, id, filter, hex]");
|
|
80
|
+
if (items.length !== 4 || typeof items[1] !== "string" || !isWireFilter(items[2]) || !isNegHex(items[3])) throw new MessageError("invalid NEG-OPEN client message");
|
|
81
|
+
return [
|
|
82
|
+
"NEG-OPEN",
|
|
83
|
+
items[1],
|
|
84
|
+
items[2],
|
|
85
|
+
items[3].toLowerCase()
|
|
86
|
+
];
|
|
87
|
+
case "NEG-MSG":
|
|
88
|
+
if (items.length !== 3 || typeof items[1] !== "string" || !isNegHex(items[2])) throw new MessageError("invalid NEG-MSG client message");
|
|
89
|
+
return [
|
|
90
|
+
"NEG-MSG",
|
|
91
|
+
items[1],
|
|
92
|
+
items[2].toLowerCase()
|
|
93
|
+
];
|
|
94
|
+
case "NEG-CLOSE":
|
|
95
|
+
if (items.length !== 2 || typeof items[1] !== "string") throw new MessageError("invalid NEG-CLOSE client message");
|
|
96
|
+
return ["NEG-CLOSE", items[1]];
|
|
97
|
+
default: throw new MessageError(`unknown client message type: ${String(type)}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/** Parse a relay->client JSON message; throws {@link MessageError} on malformed input. */
|
|
101
|
+
function parseRelayMessage(raw) {
|
|
102
|
+
let parsed;
|
|
103
|
+
try {
|
|
104
|
+
parsed = JSON.parse(raw);
|
|
105
|
+
} catch {
|
|
106
|
+
throw new MessageError("relay message is not valid JSON");
|
|
107
|
+
}
|
|
108
|
+
if (!Array.isArray(parsed) || parsed.length === 0 || typeof parsed[0] !== "string") throw new MessageError("relay message must be a non-empty JSON array");
|
|
109
|
+
const items = parsed;
|
|
110
|
+
const [type] = items;
|
|
111
|
+
switch (type) {
|
|
112
|
+
case "EVENT":
|
|
113
|
+
if (items.length !== 3 || typeof items[1] !== "string" || !validateSignedEvent(items[2])) throw new MessageError("invalid EVENT relay message");
|
|
114
|
+
return [
|
|
115
|
+
"EVENT",
|
|
116
|
+
items[1],
|
|
117
|
+
items[2]
|
|
118
|
+
];
|
|
119
|
+
case "OK":
|
|
120
|
+
if (items.length !== 4 || typeof items[1] !== "string" || typeof items[2] !== "boolean" || typeof items[3] !== "string") throw new MessageError("invalid OK relay message");
|
|
121
|
+
return [
|
|
122
|
+
"OK",
|
|
123
|
+
items[1],
|
|
124
|
+
items[2],
|
|
125
|
+
items[3]
|
|
126
|
+
];
|
|
127
|
+
case "EOSE":
|
|
128
|
+
if (items.length !== 2 || typeof items[1] !== "string") throw new MessageError("invalid EOSE relay message");
|
|
129
|
+
return ["EOSE", items[1]];
|
|
130
|
+
case "CLOSED":
|
|
131
|
+
if (items.length !== 3 || typeof items[1] !== "string" || typeof items[2] !== "string") throw new MessageError("invalid CLOSED relay message");
|
|
132
|
+
return [
|
|
133
|
+
"CLOSED",
|
|
134
|
+
items[1],
|
|
135
|
+
items[2]
|
|
136
|
+
];
|
|
137
|
+
case "NOTICE":
|
|
138
|
+
if (items.length !== 2 || typeof items[1] !== "string") throw new MessageError("invalid NOTICE relay message");
|
|
139
|
+
return ["NOTICE", items[1]];
|
|
140
|
+
case "AUTH":
|
|
141
|
+
if (items.length !== 2 || typeof items[1] !== "string") throw new MessageError("invalid AUTH relay message");
|
|
142
|
+
return ["AUTH", items[1]];
|
|
143
|
+
case "COUNT": {
|
|
144
|
+
const payload = items.at(2);
|
|
145
|
+
if (items.length !== 3 || typeof items[1] !== "string" || !isRecord(payload) || typeof payload["count"] !== "number") throw new MessageError("invalid COUNT relay message");
|
|
146
|
+
const result = { count: payload["count"] };
|
|
147
|
+
if (typeof payload["approximate"] === "boolean") result.approximate = payload["approximate"];
|
|
148
|
+
const hll = parseCountHll(payload["hll"]);
|
|
149
|
+
if (hll !== void 0) result.hll = hll;
|
|
150
|
+
return [
|
|
151
|
+
"COUNT",
|
|
152
|
+
items[1],
|
|
153
|
+
result
|
|
154
|
+
];
|
|
155
|
+
}
|
|
156
|
+
case "NEG-MSG":
|
|
157
|
+
if (items.length !== 3 || typeof items[1] !== "string" || !isNegHex(items[2])) throw new MessageError("invalid NEG-MSG relay message");
|
|
158
|
+
return [
|
|
159
|
+
"NEG-MSG",
|
|
160
|
+
items[1],
|
|
161
|
+
items[2].toLowerCase()
|
|
162
|
+
];
|
|
163
|
+
case "NEG-ERR":
|
|
164
|
+
if (items.length !== 3 && items.length !== 4 || typeof items[1] !== "string" || typeof items[2] !== "string") throw new MessageError("invalid NEG-ERR relay message");
|
|
165
|
+
return [
|
|
166
|
+
"NEG-ERR",
|
|
167
|
+
items[1],
|
|
168
|
+
items[2]
|
|
169
|
+
];
|
|
170
|
+
default: throw new MessageError(`unknown relay message type: ${String(type)}`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function parseCountHll(value) {
|
|
174
|
+
if (typeof value !== "string" || value.length !== HLL_HEX_LEN || !HEX_RE.test(value)) return;
|
|
175
|
+
return value.toLowerCase();
|
|
176
|
+
}
|
|
177
|
+
function isWireFilter(value) {
|
|
178
|
+
return isRecord(value);
|
|
179
|
+
}
|
|
180
|
+
function parseWireFilters(items, kind) {
|
|
181
|
+
const filters = [];
|
|
182
|
+
for (const item of items) {
|
|
183
|
+
if (!isWireFilter(item)) throw new MessageError(`invalid ${kind} filter`);
|
|
184
|
+
filters.push(item);
|
|
185
|
+
}
|
|
186
|
+
return filters;
|
|
187
|
+
}
|
|
188
|
+
function isNegHex(value) {
|
|
189
|
+
return typeof value === "string" && value.length > 0 && value.length % 2 === 0 && HEX_RE.test(value);
|
|
190
|
+
}
|
|
191
|
+
//#endregion
|
|
192
|
+
export { mergeCountHll as a, encodeRelayMessage as i, createSubscriptionId as n, parseClientMessage as o, encodeClientMessage as r, parseRelayMessage as s, assertSubscriptionId as t };
|
|
193
|
+
|
|
194
|
+
//# sourceMappingURL=message-oNr7t0SJ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-oNr7t0SJ.mjs","names":[],"sources":["../src/core/message.ts"],"sourcesContent":["import { MessageError } from \"./error.ts\";\nimport type { Event } from \"./event.ts\";\nimport { validateSignedEvent } from \"./event.ts\";\nimport type { Filter } from \"./filter.ts\";\nimport { SUBSCRIPTION_ID_MAX_CHARS } from \"./limits.ts\";\nimport type { Mutable } from \"./util.ts\";\nimport { bytesToHex, hexToBytes, isRecord } from \"./util.ts\";\n\n/** NIP-01 subscription id: 1..64 chars. */\nexport type SubscriptionId = string;\n\n/** Validate a subscription id; throws {@link MessageError} unless 1..64 chars. */\nexport function assertSubscriptionId(id: string): SubscriptionId {\n if (id.length === 0 || id.length > SUBSCRIPTION_ID_MAX_CHARS) {\n throw new MessageError(`subscription id length must be 1..${SUBSCRIPTION_ID_MAX_CHARS}`);\n }\n return id;\n}\n\n/** Validate the given id, or mint a random 16-hex-char subscription id. */\nexport function createSubscriptionId(id?: string): SubscriptionId {\n if (id !== undefined) {\n return assertSubscriptionId(id);\n }\n const bytes = new Uint8Array(8);\n crypto.getRandomValues(bytes);\n return bytesToHex(bytes);\n}\n\n/** Client → relay messages (NIP-01 + NIP-42 AUTH + NIP-45 COUNT + NIP-77). */\nexport type ClientMessage =\n | [\"EVENT\", Event]\n | [\"REQ\", SubscriptionId, ...Filter[]]\n | [\"CLOSE\", SubscriptionId]\n | [\"AUTH\", Event]\n | [\"COUNT\", SubscriptionId, ...Filter[]]\n | [\"NEG-OPEN\", SubscriptionId, Filter, string]\n | [\"NEG-MSG\", SubscriptionId, string]\n | [\"NEG-CLOSE\", SubscriptionId];\n\n/** Relay → client messages. */\nexport type RelayMessage =\n | [\"EVENT\", SubscriptionId, Event]\n | [\"OK\", string, boolean, string]\n | [\"EOSE\", SubscriptionId]\n | [\"CLOSED\", SubscriptionId, string]\n | [\"NOTICE\", string]\n | [\"AUTH\", string]\n | [\"COUNT\", SubscriptionId, CountResult]\n | [\"NEG-MSG\", SubscriptionId, string]\n | [\"NEG-ERR\", SubscriptionId, string];\n\n/** NIP-45 COUNT reply payload. */\nexport type CountResult = {\n readonly count: number;\n readonly approximate?: boolean | undefined;\n /**\n * Optional 512-char hex HyperLogLog sketch (256 registers). Merge sketches with `mergeCountHll`.\n * Estimation is unspecified by NIP-45 and not provided.\n */\n readonly hll?: string | undefined;\n};\n\nconst HLL_BYTES = 256; // 512 hex chars (NIP-45; hex only, not base64)\nconst HLL_HEX_LEN = HLL_BYTES * 2;\nconst HEX_RE = /^[0-9a-fA-F]+$/;\n\n/**\n * Register-wise max of NIP-45 HyperLogLog sketches. Output is always lowercase 512 hex. Empty input\n * is the zero sketch (identity).\n */\nexport function mergeCountHll(hexes: ReadonlyArray<string>): string {\n const merged = new Uint8Array(HLL_BYTES);\n for (const hex of hexes) {\n if (hex.length !== HLL_HEX_LEN || !HEX_RE.test(hex)) {\n throw new MessageError(\"invalid NIP-45 HLL sketch: expected 512-char hex\");\n }\n const bytes = hexToBytes(hex);\n for (const [i, b] of bytes.entries()) {\n const m = merged[i];\n if (m !== undefined && b > m) {\n merged[i] = b;\n }\n }\n }\n return bytesToHex(merged);\n}\n\n/** Serialize a client->relay message to its NIP-01 JSON wire form. */\nexport function encodeClientMessage(message: ClientMessage): string {\n return JSON.stringify(message);\n}\n\n/** Serialize a relay->client message to its NIP-01 JSON wire form. */\nexport function encodeRelayMessage(message: RelayMessage): string {\n return JSON.stringify(message);\n}\n\n/** Parse a client->relay JSON message; throws {@link MessageError} on malformed input. */\nexport function parseClientMessage(raw: string): ClientMessage {\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n throw new MessageError(\"client message is not valid JSON\");\n }\n if (!Array.isArray(parsed) || parsed.length === 0 || typeof parsed[0] !== \"string\") {\n throw new MessageError(\"client message must be a non-empty JSON array\");\n }\n const items: unknown[] = parsed;\n const [type] = items;\n switch (type) {\n case \"EVENT\":\n if (items.length !== 2 || !validateSignedEvent(items[1])) {\n throw new MessageError(\"invalid EVENT client message\");\n }\n return [\"EVENT\", items[1]];\n\n case \"REQ\":\n if (items.length < 3 || typeof items[1] !== \"string\") {\n throw new MessageError(\"invalid REQ client message\");\n }\n return [\"REQ\", items[1], ...parseWireFilters(items.slice(2), \"REQ\")];\n\n case \"CLOSE\":\n if (items.length !== 2 || typeof items[1] !== \"string\") {\n throw new MessageError(\"invalid CLOSE client message\");\n }\n return [\"CLOSE\", items[1]];\n\n case \"AUTH\":\n if (items.length !== 2 || !validateSignedEvent(items[1])) {\n throw new MessageError(\"invalid AUTH client message\");\n }\n return [\"AUTH\", items[1]];\n\n case \"COUNT\":\n if (items.length < 3 || typeof items[1] !== \"string\") {\n throw new MessageError(\"invalid COUNT client message\");\n }\n return [\"COUNT\", items[1], ...parseWireFilters(items.slice(2), \"COUNT\")];\n\n case \"NEG-OPEN\":\n if (items.length === 5) {\n throw new MessageError(\"obsolete 5-element NEG-OPEN; expected [NEG-OPEN, id, filter, hex]\");\n }\n if (\n items.length !== 4 ||\n typeof items[1] !== \"string\" ||\n !isWireFilter(items[2]) ||\n !isNegHex(items[3])\n ) {\n throw new MessageError(\"invalid NEG-OPEN client message\");\n }\n return [\"NEG-OPEN\", items[1], items[2], items[3].toLowerCase()];\n\n case \"NEG-MSG\":\n if (items.length !== 3 || typeof items[1] !== \"string\" || !isNegHex(items[2])) {\n throw new MessageError(\"invalid NEG-MSG client message\");\n }\n return [\"NEG-MSG\", items[1], items[2].toLowerCase()];\n\n case \"NEG-CLOSE\":\n if (items.length !== 2 || typeof items[1] !== \"string\") {\n throw new MessageError(\"invalid NEG-CLOSE client message\");\n }\n return [\"NEG-CLOSE\", items[1]];\n\n default:\n throw new MessageError(`unknown client message type: ${String(type)}`);\n }\n}\n\n/** Parse a relay->client JSON message; throws {@link MessageError} on malformed input. */\nexport function parseRelayMessage(raw: string): RelayMessage {\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n throw new MessageError(\"relay message is not valid JSON\");\n }\n if (!Array.isArray(parsed) || parsed.length === 0 || typeof parsed[0] !== \"string\") {\n throw new MessageError(\"relay message must be a non-empty JSON array\");\n }\n const items: unknown[] = parsed;\n const [type] = items;\n switch (type) {\n case \"EVENT\":\n if (items.length !== 3 || typeof items[1] !== \"string\" || !validateSignedEvent(items[2])) {\n throw new MessageError(\"invalid EVENT relay message\");\n }\n return [\"EVENT\", items[1], items[2]];\n\n case \"OK\":\n if (\n items.length !== 4 ||\n typeof items[1] !== \"string\" ||\n typeof items[2] !== \"boolean\" ||\n typeof items[3] !== \"string\"\n ) {\n throw new MessageError(\"invalid OK relay message\");\n }\n return [\"OK\", items[1], items[2], items[3]];\n\n case \"EOSE\":\n if (items.length !== 2 || typeof items[1] !== \"string\") {\n throw new MessageError(\"invalid EOSE relay message\");\n }\n return [\"EOSE\", items[1]];\n\n case \"CLOSED\":\n if (items.length !== 3 || typeof items[1] !== \"string\" || typeof items[2] !== \"string\") {\n throw new MessageError(\"invalid CLOSED relay message\");\n }\n return [\"CLOSED\", items[1], items[2]];\n\n case \"NOTICE\":\n if (items.length !== 2 || typeof items[1] !== \"string\") {\n throw new MessageError(\"invalid NOTICE relay message\");\n }\n return [\"NOTICE\", items[1]];\n\n case \"AUTH\":\n if (items.length !== 2 || typeof items[1] !== \"string\") {\n throw new MessageError(\"invalid AUTH relay message\");\n }\n return [\"AUTH\", items[1]];\n\n case \"COUNT\": {\n const payload = items.at(2);\n if (\n items.length !== 3 ||\n typeof items[1] !== \"string\" ||\n !isRecord(payload) ||\n typeof payload[\"count\"] !== \"number\"\n ) {\n throw new MessageError(\"invalid COUNT relay message\");\n }\n const result: Mutable<CountResult> = { count: payload[\"count\"] };\n if (typeof payload[\"approximate\"] === \"boolean\") {\n result.approximate = payload[\"approximate\"];\n }\n const hll = parseCountHll(payload[\"hll\"]);\n if (hll !== undefined) {\n result.hll = hll;\n }\n return [\"COUNT\", items[1], result];\n }\n case \"NEG-MSG\":\n if (items.length !== 3 || typeof items[1] !== \"string\" || !isNegHex(items[2])) {\n throw new MessageError(\"invalid NEG-MSG relay message\");\n }\n return [\"NEG-MSG\", items[1], items[2].toLowerCase()];\n\n case \"NEG-ERR\":\n if (\n (items.length !== 3 && items.length !== 4) ||\n typeof items[1] !== \"string\" ||\n typeof items[2] !== \"string\"\n ) {\n throw new MessageError(\"invalid NEG-ERR relay message\");\n }\n return [\"NEG-ERR\", items[1], items[2]];\n\n default:\n throw new MessageError(`unknown relay message type: ${String(type)}`);\n }\n}\n\nfunction parseCountHll(value: unknown): string | undefined {\n if (typeof value !== \"string\" || value.length !== HLL_HEX_LEN || !HEX_RE.test(value)) {\n return undefined;\n }\n return value.toLowerCase();\n}\n\nfunction isWireFilter(value: unknown): value is Filter {\n return isRecord(value);\n}\n\nfunction parseWireFilters(items: unknown[], kind: string): Filter[] {\n const filters: Filter[] = [];\n for (const item of items) {\n if (!isWireFilter(item)) {\n throw new MessageError(`invalid ${kind} filter`);\n }\n filters.push(item);\n }\n return filters;\n}\n\nfunction isNegHex(value: unknown): value is string {\n return (\n typeof value === \"string\" && value.length > 0 && value.length % 2 === 0 && HEX_RE.test(value)\n );\n}\n"],"mappings":";;;;AAYA,SAAgB,qBAAqB,IAA4B;CAC/D,IAAI,GAAG,WAAW,KAAK,GAAG,SAAA,IACxB,MAAM,IAAI,aAAa,sCAAgE;CAEzF,OAAO;AACT;;AAGA,SAAgB,qBAAqB,IA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,aAAa,WAAW,KAAK,QAAQ;EAEjD,QAAQ,KAAK,IAAI;CACnB;CACA,OAAO;AACT;AAEA,SAAS,SAAS,OAAiC;CACjD,OACE,OAAO,UAAU,YAAY,MAAM,SAAS,KAAK,MAAM,SAAS,MAAM,KAAK,OAAO,KAAK,KAAK;AAEhG"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as Event } from "./event-
|
|
2
|
-
import { t as Filter } from "./filter-
|
|
1
|
+
import { t as Event } from "./event-DJeb_DIL.mjs";
|
|
2
|
+
import { t as Filter } from "./filter-jI_9htF7.mjs";
|
|
3
3
|
//#region src/core/message.d.ts
|
|
4
4
|
/** NIP-01 subscription id: 1..64 chars. */
|
|
5
5
|
type SubscriptionId = string;
|
|
@@ -13,13 +13,13 @@ type ClientMessage = ["EVENT", Event] | ["REQ", SubscriptionId, ...Filter[]] | [
|
|
|
13
13
|
type RelayMessage = ["EVENT", SubscriptionId, Event] | ["OK", string, boolean, string] | ["EOSE", SubscriptionId] | ["CLOSED", SubscriptionId, string] | ["NOTICE", string] | ["AUTH", string] | ["COUNT", SubscriptionId, CountResult] | ["NEG-MSG", SubscriptionId, string] | ["NEG-ERR", SubscriptionId, string];
|
|
14
14
|
/** NIP-45 COUNT reply payload. */
|
|
15
15
|
type CountResult = {
|
|
16
|
-
count: number;
|
|
17
|
-
approximate?: boolean;
|
|
16
|
+
readonly count: number;
|
|
17
|
+
readonly approximate?: boolean | undefined;
|
|
18
18
|
/**
|
|
19
19
|
* Optional 512-char hex HyperLogLog sketch (256 registers). Merge sketches with `mergeCountHll`.
|
|
20
20
|
* Estimation is unspecified by NIP-45 and not provided.
|
|
21
21
|
*/
|
|
22
|
-
hll?: string;
|
|
22
|
+
readonly hll?: string | undefined;
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
25
25
|
* Register-wise max of NIP-45 HyperLogLog sketches. Output is always lowercase 512 hex. Empty input
|
|
@@ -36,4 +36,4 @@ declare function parseClientMessage(raw: string): ClientMessage;
|
|
|
36
36
|
declare function parseRelayMessage(raw: string): RelayMessage;
|
|
37
37
|
//#endregion
|
|
38
38
|
export { assertSubscriptionId as a, encodeRelayMessage as c, parseRelayMessage as d, SubscriptionId as i, mergeCountHll as l, CountResult as n, createSubscriptionId as o, RelayMessage as r, encodeClientMessage as s, ClientMessage as t, parseClientMessage as u };
|
|
39
|
-
//# sourceMappingURL=message-
|
|
39
|
+
//# sourceMappingURL=message-tclYCVNc.d.mts.map
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { _ as Tag, t as Event } from "./event-
|
|
2
|
-
import { t as EventBuilder } from "./builder-
|
|
3
|
-
import { a as NostrError } from "./error-
|
|
4
|
-
import { a as Rumor, l as WrapOptions, r as Nip59Crypto } from "./nip59-
|
|
1
|
+
import { _ as Tag, t as Event } from "./event-DJeb_DIL.mjs";
|
|
2
|
+
import { t as EventBuilder } from "./builder-CTwkB2zM.mjs";
|
|
3
|
+
import { a as NostrError } from "./error-BquXDmIN.mjs";
|
|
4
|
+
import { a as Rumor, l as WrapOptions, r as Nip59Crypto } from "./nip59-C-RWFQIv.mjs";
|
|
5
5
|
//#region src/nips/nip17.d.ts
|
|
6
6
|
declare class Nip17Error extends NostrError {
|
|
7
7
|
name: string;
|
|
8
|
-
constructor(message: string, options?: ErrorOptions);
|
|
9
8
|
}
|
|
10
9
|
type Recipient = {
|
|
11
10
|
readonly pubkey: string;
|
|
@@ -29,11 +28,11 @@ declare function dmRelayListEventBuilder(relays: ReadonlyArray<string>): EventBu
|
|
|
29
28
|
/** Accept a hex pubkey, a Recipient, or a readonly array of either. Dedup by pubkey. */
|
|
30
29
|
declare function normalizeRecipients(input: string | Recipient | ReadonlyArray<string | Recipient>): Recipient[];
|
|
31
30
|
declare function buildChatMessageRumor(senderPubkey: string, recipients: ReadonlyArray<Recipient>, content: string, opts?: ChatMessageOptions): Rumor;
|
|
32
|
-
declare function wrapDirectMessage(crypto: Nip59Crypto, recipients: ReadonlyArray<Recipient>, rumor: Rumor, opts?: Pick<WrapOptions, "now" | "randomInt" | "timestamps" | "randomize">): Promise<ReadonlyArray<{
|
|
31
|
+
declare function wrapDirectMessage(crypto: Nip59Crypto, recipients: ReadonlyArray<Recipient>, rumor: Rumor, opts?: Pick<WrapOptions, "now" | "randomInt" | "timestamps" | "expiration" | "ephemeral" | "randomize">): Promise<ReadonlyArray<{
|
|
33
32
|
recipient: string;
|
|
34
33
|
wrap: Event;
|
|
35
34
|
}>>;
|
|
36
35
|
declare function requireDmRelays(pubkey: string, relays: ReadonlyArray<string>): string[];
|
|
37
36
|
//#endregion
|
|
38
37
|
export { buildChatMessageRumor as a, normalizeRecipients as c, wrapDirectMessage as d, ReplyTo as i, parseDmRelayList as l, Nip17Error as n, dmRelayListEventBuilder as o, Recipient as r, dmRelayListToTags as s, ChatMessageOptions as t, requireDmRelays as u };
|
|
39
|
-
//# sourceMappingURL=nip17-
|
|
38
|
+
//# sourceMappingURL=nip17-B5WgW4C4.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as NostrError } from "./error-
|
|
1
|
+
import { a as NostrError } from "./error-BquXDmIN.mjs";
|
|
2
2
|
//#region src/nips/nip19.d.ts
|
|
3
3
|
/** Bech32 `nprofile1…` string (TLV profile pointer). */
|
|
4
4
|
type NProfile = `nprofile1${string}`;
|
|
@@ -16,47 +16,46 @@ type Note = `note1${string}`;
|
|
|
16
16
|
declare const Bech32MaxSize = 5000;
|
|
17
17
|
/** Decoded `nprofile` payload: a pubkey plus optional relay hints. */
|
|
18
18
|
type ProfilePointer = {
|
|
19
|
-
pubkey: string;
|
|
20
|
-
relays?: string
|
|
19
|
+
readonly pubkey: string;
|
|
20
|
+
readonly relays?: ReadonlyArray<string> | undefined;
|
|
21
21
|
};
|
|
22
22
|
/** Decoded `nevent` payload: an event id plus optional relay/author/kind hints. */
|
|
23
23
|
type EventPointer = {
|
|
24
|
-
id: string;
|
|
25
|
-
relays?: string
|
|
26
|
-
author?: string;
|
|
27
|
-
kind?: number;
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly relays?: ReadonlyArray<string> | undefined;
|
|
26
|
+
readonly author?: string | undefined;
|
|
27
|
+
readonly kind?: number | undefined;
|
|
28
28
|
};
|
|
29
29
|
/** Decoded `naddr` payload: a replaceable-event coordinate plus optional relay hints. */
|
|
30
30
|
type AddressPointer = {
|
|
31
|
-
identifier: string;
|
|
32
|
-
pubkey: string;
|
|
33
|
-
kind: number;
|
|
34
|
-
relays?: string
|
|
31
|
+
readonly identifier: string;
|
|
32
|
+
readonly pubkey: string;
|
|
33
|
+
readonly kind: number;
|
|
34
|
+
readonly relays?: ReadonlyArray<string> | undefined;
|
|
35
35
|
};
|
|
36
36
|
/** Result of {@link decode}: the bech32 prefix and its decoded payload. */
|
|
37
37
|
type DecodedResult = {
|
|
38
|
-
type: "nprofile";
|
|
39
|
-
data: ProfilePointer;
|
|
38
|
+
readonly type: "nprofile";
|
|
39
|
+
readonly data: ProfilePointer;
|
|
40
40
|
} | {
|
|
41
|
-
type: "nevent";
|
|
42
|
-
data: EventPointer;
|
|
41
|
+
readonly type: "nevent";
|
|
42
|
+
readonly data: EventPointer;
|
|
43
43
|
} | {
|
|
44
|
-
type: "naddr";
|
|
45
|
-
data: AddressPointer;
|
|
44
|
+
readonly type: "naddr";
|
|
45
|
+
readonly data: AddressPointer;
|
|
46
46
|
} | {
|
|
47
|
-
type: "nsec";
|
|
48
|
-
data: Uint8Array;
|
|
47
|
+
readonly type: "nsec";
|
|
48
|
+
readonly data: Uint8Array;
|
|
49
49
|
} | {
|
|
50
|
-
type: "npub";
|
|
51
|
-
data: string;
|
|
50
|
+
readonly type: "npub";
|
|
51
|
+
readonly data: string;
|
|
52
52
|
} | {
|
|
53
|
-
type: "note";
|
|
54
|
-
data: string;
|
|
53
|
+
readonly type: "note";
|
|
54
|
+
readonly data: string;
|
|
55
55
|
};
|
|
56
56
|
/** Error thrown by NIP-19 encoding/decoding failures. */
|
|
57
57
|
declare class Nip19Error extends NostrError {
|
|
58
58
|
name: string;
|
|
59
|
-
constructor(message: string);
|
|
60
59
|
}
|
|
61
60
|
declare function encodeBytes<Prefix extends string>(prefix: Prefix, bytes: Uint8Array): `${Prefix}1${string}`;
|
|
62
61
|
/** Encode a 32-byte secret key as `nsec1…`; throws {@link Nip19Error} on wrong length. */
|
|
@@ -73,11 +72,6 @@ declare function neventEncode(event: EventPointer): NEvent;
|
|
|
73
72
|
declare function naddrEncode(addr: AddressPointer): NAddr;
|
|
74
73
|
/** Decode a NIP-19 bech32 entity; throws {@link Nip19Error} on bad input or unknown prefix. */
|
|
75
74
|
declare function decode(code: string): DecodedResult;
|
|
76
|
-
/** Decode `nostr:` URI or bare bech32; returns invalid sentinel instead of throwing. */
|
|
77
|
-
declare function decodeNostrURI(nip19code: string): DecodedResult | {
|
|
78
|
-
type: "invalid";
|
|
79
|
-
data: undefined;
|
|
80
|
-
};
|
|
81
75
|
//#endregion
|
|
82
|
-
export {
|
|
83
|
-
//# sourceMappingURL=nip19-
|
|
76
|
+
export { noteEncode as _, NAddr as a, nsecEncode as b, NPub as c, Note as d, ProfilePointer as f, neventEncode as g, naddrEncode as h, EventPointer as i, NSec as l, encodeBytes as m, Bech32MaxSize as n, NEvent as o, decode as p, DecodedResult as r, NProfile as s, AddressPointer as t, Nip19Error as u, nprofileEncode as v, npubEncode as y };
|
|
77
|
+
//# sourceMappingURL=nip19-DpPN17bY.d.mts.map
|
|
@@ -1,36 +1,34 @@
|
|
|
1
|
-
import { a as NostrError } from "./error-
|
|
1
|
+
import { a as NostrError } from "./error-BquXDmIN.mjs";
|
|
2
2
|
//#region src/nips/nip46.d.ts
|
|
3
|
-
declare const BUNKER_REGEX: RegExp;
|
|
4
3
|
type BunkerPointer = {
|
|
5
4
|
/** Remote signer / bunker public key (hex). */
|
|
6
|
-
pubkey: string;
|
|
7
|
-
relays: string
|
|
8
|
-
secret
|
|
5
|
+
readonly pubkey: string;
|
|
6
|
+
readonly relays: ReadonlyArray<string>;
|
|
7
|
+
readonly secret?: string | undefined;
|
|
9
8
|
};
|
|
10
9
|
type ClientMetadata = {
|
|
11
|
-
name?: string | undefined;
|
|
12
|
-
url?: string | undefined;
|
|
13
|
-
image?: string | undefined;
|
|
10
|
+
readonly name?: string | undefined;
|
|
11
|
+
readonly url?: string | undefined;
|
|
12
|
+
readonly image?: string | undefined;
|
|
14
13
|
};
|
|
15
14
|
type NostrConnectParams = {
|
|
16
|
-
clientPubkey: string;
|
|
17
|
-
relays: string
|
|
18
|
-
secret: string;
|
|
19
|
-
perms?: string
|
|
15
|
+
readonly clientPubkey: string;
|
|
16
|
+
readonly relays: ReadonlyArray<string>;
|
|
17
|
+
readonly secret: string;
|
|
18
|
+
readonly perms?: ReadonlyArray<string> | undefined;
|
|
20
19
|
} & ClientMetadata;
|
|
21
20
|
type Nip46Request = {
|
|
22
|
-
id: string;
|
|
23
|
-
method: string;
|
|
24
|
-
params: string
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly method: string;
|
|
23
|
+
readonly params: ReadonlyArray<string>;
|
|
25
24
|
};
|
|
26
25
|
type Nip46Response = {
|
|
27
|
-
id: string;
|
|
28
|
-
result?: string | undefined;
|
|
29
|
-
error?: string | undefined;
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly result?: string | undefined;
|
|
28
|
+
readonly error?: string | undefined;
|
|
30
29
|
};
|
|
31
30
|
declare class Nip46Error extends NostrError {
|
|
32
31
|
name: string;
|
|
33
|
-
constructor(message: string, options?: ErrorOptions);
|
|
34
32
|
}
|
|
35
33
|
/** Encode a bunker pointer as `bunker://…`. */
|
|
36
34
|
declare function toBunkerURL(pointer: BunkerPointer): string;
|
|
@@ -48,5 +46,5 @@ declare function decodeNip46Request(json: string): Nip46Request;
|
|
|
48
46
|
declare function encodeNip46Response(res: Nip46Response): string;
|
|
49
47
|
declare function decodeNip46Response(json: string): Nip46Response;
|
|
50
48
|
//#endregion
|
|
51
|
-
export {
|
|
52
|
-
//# sourceMappingURL=nip46-
|
|
49
|
+
export { Nip46Response as a, decodeNip46Request as c, encodeNip46Response as d, parseBunkerURL as f, Nip46Request as i, decodeNip46Response as l, toBunkerURL as m, ClientMetadata as n, NostrConnectParams as o, parseNostrConnectURI as p, Nip46Error as r, createNostrConnectURI as s, BunkerPointer as t, encodeNip46Request as u };
|
|
50
|
+
//# sourceMappingURL=nip46-BHaxC9TZ.d.mts.map
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { t as Event } from "./event-DJeb_DIL.mjs";
|
|
2
|
+
import { t as EventBuilder } from "./builder-CTwkB2zM.mjs";
|
|
3
|
+
//#region src/nips/nip51.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Structural crypto used by NIP-51 private tags. Satisfied by NostrSigner when
|
|
6
|
+
* nip44Encrypt/nip44Decrypt are present. This module must not import src/signer/.
|
|
7
|
+
*/
|
|
8
|
+
type Nip51Crypto = {
|
|
9
|
+
getPublicKey: () => Promise<string>;
|
|
10
|
+
nip44Encrypt: (peer: string, plaintext: string) => Promise<string>;
|
|
11
|
+
nip44Decrypt: (peer: string, payload: string) => Promise<string>;
|
|
12
|
+
};
|
|
13
|
+
type MuteItem = {
|
|
14
|
+
readonly type: "pubkey";
|
|
15
|
+
readonly value: string;
|
|
16
|
+
} | {
|
|
17
|
+
readonly type: "event";
|
|
18
|
+
readonly value: string;
|
|
19
|
+
} | {
|
|
20
|
+
readonly type: "hashtag";
|
|
21
|
+
readonly value: string;
|
|
22
|
+
} | {
|
|
23
|
+
readonly type: "word";
|
|
24
|
+
readonly value: string;
|
|
25
|
+
};
|
|
26
|
+
/** Parse kind:10000 mute list public tags (`p` / `e` / `t` / `word`). */
|
|
27
|
+
declare function parseMuteList(event: Pick<Event, "kind" | "tags">): MuteItem[];
|
|
28
|
+
/** Build an unsigned kind:10000 EventBuilder from public mute items. */
|
|
29
|
+
declare function muteListEventBuilder(items: ReadonlyArray<MuteItem>): EventBuilder;
|
|
30
|
+
/** NIP-44 ciphertext of tags, conversation peer = author's own pubkey. */
|
|
31
|
+
declare function encryptPrivateTags(crypto: Nip51Crypto, tags: Event["tags"]): Promise<string>;
|
|
32
|
+
/** Decrypt NIP-51 `.content`. Empty content is no private tags, not ciphertext. */
|
|
33
|
+
declare function decryptPrivateTags(crypto: Nip51Crypto, event: Pick<Event, "pubkey" | "content">): Promise<Event["tags"]>;
|
|
34
|
+
/** Public mute items from tags; private mute items from NIP-44 `.content`. */
|
|
35
|
+
declare function parseMuteListPrivate(crypto: Nip51Crypto, event: Pick<Event, "kind" | "tags" | "pubkey" | "content">): Promise<{
|
|
36
|
+
public: MuteItem[];
|
|
37
|
+
private: MuteItem[];
|
|
38
|
+
}>;
|
|
39
|
+
/** Parse kind:10001 pin list public `e` tags. */
|
|
40
|
+
declare function parsePinList(event: Pick<Event, "kind" | "tags">): string[];
|
|
41
|
+
/** Build an unsigned kind:10001 EventBuilder from event ids. */
|
|
42
|
+
declare function pinListEventBuilder(ids: ReadonlyArray<string>): EventBuilder;
|
|
43
|
+
/** Parse kind:10003 bookmark list public `e` and `a` tags. */
|
|
44
|
+
declare function parseBookmarkList(event: Pick<Event, "kind" | "tags">): {
|
|
45
|
+
e: string[];
|
|
46
|
+
a: string[];
|
|
47
|
+
};
|
|
48
|
+
/** Build an unsigned kind:10003 EventBuilder from public bookmark pointers. */
|
|
49
|
+
declare function bookmarkListEventBuilder(items: {
|
|
50
|
+
e?: ReadonlyArray<string>;
|
|
51
|
+
a?: ReadonlyArray<string>;
|
|
52
|
+
}): EventBuilder;
|
|
53
|
+
/** Parse kind:10030 user emoji list public `emoji` and `a` tags. */
|
|
54
|
+
declare function parseUserEmojiList(event: Pick<Event, "kind" | "tags">): {
|
|
55
|
+
emoji: Array<{
|
|
56
|
+
shortcode: string;
|
|
57
|
+
url: string;
|
|
58
|
+
}>;
|
|
59
|
+
sets: string[];
|
|
60
|
+
};
|
|
61
|
+
/** Parse kind:30002 relay set public `d` and `relay` tags. */
|
|
62
|
+
declare function parseRelaySet(event: Pick<Event, "kind" | "tags">): {
|
|
63
|
+
d: string;
|
|
64
|
+
relays: string[];
|
|
65
|
+
};
|
|
66
|
+
/** Parse kind:10012 favorite relays public `relay` tags and kind:30002 `a` tags. */
|
|
67
|
+
declare function parseFavoriteRelays(event: Pick<Event, "kind" | "tags">): {
|
|
68
|
+
relays: string[];
|
|
69
|
+
sets: string[];
|
|
70
|
+
};
|
|
71
|
+
/** Parse kind:30030 emoji set public `d` / `title` / `emoji` tags. */
|
|
72
|
+
declare function parseEmojiSet(event: Pick<Event, "kind" | "tags">): {
|
|
73
|
+
d: string;
|
|
74
|
+
title?: string;
|
|
75
|
+
emoji: Array<{
|
|
76
|
+
shortcode: string;
|
|
77
|
+
url: string;
|
|
78
|
+
}>;
|
|
79
|
+
};
|
|
80
|
+
/** Parse kind:39089 starter pack (follow pack) public `d` and `p` tags. */
|
|
81
|
+
declare function parseFollowPack(event: Pick<Event, "kind" | "tags">): {
|
|
82
|
+
d: string;
|
|
83
|
+
pubkeys: string[];
|
|
84
|
+
};
|
|
85
|
+
//#endregion
|
|
86
|
+
export { encryptPrivateTags as a, parseEmojiSet as c, parseMuteList as d, parseMuteListPrivate as f, pinListEventBuilder as g, parseUserEmojiList as h, decryptPrivateTags as i, parseFavoriteRelays as l, parseRelaySet as m, Nip51Crypto as n, muteListEventBuilder as o, parsePinList as p, bookmarkListEventBuilder as r, parseBookmarkList as s, MuteItem as t, parseFollowPack as u };
|
|
87
|
+
//# sourceMappingURL=nip51-CR0Q8eym.d.mts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as Tag, r as UnsignedEvent, t as Event } from "./event-
|
|
2
|
-
import { a as NostrError } from "./error-
|
|
1
|
+
import { _ as Tag, r as UnsignedEvent, t as Event } from "./event-DJeb_DIL.mjs";
|
|
2
|
+
import { a as NostrError } from "./error-BquXDmIN.mjs";
|
|
3
3
|
//#region src/nips/nip59.d.ts
|
|
4
4
|
/** Unsigned event with a computed id. Never has `sig`. */
|
|
5
5
|
type Rumor = UnsignedEvent & {
|
|
@@ -34,16 +34,22 @@ type WrapOptions = {
|
|
|
34
34
|
readonly relayHint?: string | undefined;
|
|
35
35
|
/** Appended after the required wrap `p` tag. Never applied to the seal. */
|
|
36
36
|
readonly extraTags?: ReadonlyArray<Tag> | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* NIP-17 disappearing-message expiry (unix seconds): sets `["expiration", ts]` on the seal and on
|
|
39
|
+
* the gift wrap, signalling relays to discard the wrap after that time.
|
|
40
|
+
*/
|
|
41
|
+
readonly expiration?: number | undefined;
|
|
42
|
+
/** Use ephemeral gift wrap kind 21059 instead of 1059 (NIP-59; relays MUST NOT store). */
|
|
43
|
+
readonly ephemeral?: boolean | undefined;
|
|
37
44
|
/**
|
|
38
45
|
* Default `"seal+wrap"` (NIP-59). `"wrap"` = only wrap timestamp is randomized; seal uses
|
|
39
46
|
* rumor.created_at.
|
|
40
47
|
*/
|
|
41
48
|
readonly randomize?: TimestampRandomize | undefined;
|
|
42
49
|
};
|
|
43
|
-
type SealOptions = Pick<WrapOptions, "now" | "randomInt" | "timestamps" | "randomize">;
|
|
50
|
+
type SealOptions = Pick<WrapOptions, "now" | "randomInt" | "timestamps" | "expiration" | "randomize">;
|
|
44
51
|
declare class Nip59Error extends NostrError {
|
|
45
52
|
name: string;
|
|
46
|
-
constructor(message: string, options?: ErrorOptions);
|
|
47
53
|
}
|
|
48
54
|
declare const TWO_DAYS_SECS: number;
|
|
49
55
|
declare function isGiftWrapKind(kind: number): boolean;
|
|
@@ -76,4 +82,4 @@ declare function wrap(crypto: Nip59Crypto, recipient: string, rumor: Rumor, opts
|
|
|
76
82
|
declare function unwrap(crypto: Nip44Decryptor, giftWrap: Event): Promise<Rumor>;
|
|
77
83
|
//#endregion
|
|
78
84
|
export { requireNip59Crypto as _, Rumor as a, wrap as b, TimestampRandomize as c, createRumor as d, createSeal as f, requireNip44Decryptor as g, randomPastTimestamp as h, Nip59Error as i, WrapOptions as l, isGiftWrapKind as m, Nip44Decryptor as n, SealOptions as o, eventToJson as p, Nip59Crypto as r, TWO_DAYS_SECS as s, GiftWrapTimestamps as t, createGiftWrap as u, rumorToJson as v, unwrap as y };
|
|
79
|
-
//# sourceMappingURL=nip59-
|
|
85
|
+
//# sourceMappingURL=nip59-C-RWFQIv.d.mts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { _ as Tag, t as Event } from "./event-DJeb_DIL.mjs";
|
|
2
|
+
import { t as EventBuilder } from "./builder-CTwkB2zM.mjs";
|
|
3
|
+
//#region src/nips/nip65.d.ts
|
|
4
|
+
/** NIP-65 `r` tag marker: read-only, write-only, or unmarked (both). */
|
|
5
|
+
type RelayMarker = "read" | "write" | "both";
|
|
6
|
+
/** One NIP-65 relay-list entry: normalized URL plus its marker. */
|
|
7
|
+
type RelayListItem = {
|
|
8
|
+
readonly url: string;
|
|
9
|
+
readonly marker: RelayMarker;
|
|
10
|
+
};
|
|
11
|
+
/** Parse a kind:10002 NIP-65 event into relay list entries. */
|
|
12
|
+
declare function parseRelayList(event: Event): RelayListItem[];
|
|
13
|
+
/** Encode relay list items as NIP-65 `r` tags (`both` is unmarked). */
|
|
14
|
+
declare function relayListToTags(items: ReadonlyArray<RelayListItem>): Tag[];
|
|
15
|
+
/** Build an unsigned kind:10002 EventBuilder from relay list items. */
|
|
16
|
+
declare function relayListEventBuilder(items: ReadonlyArray<RelayListItem>): EventBuilder;
|
|
17
|
+
/** URLs of the read-enabled items. */
|
|
18
|
+
declare function readRelays(items: ReadonlyArray<RelayListItem>): string[];
|
|
19
|
+
/** URLs of the write-enabled items. */
|
|
20
|
+
declare function writeRelays(items: ReadonlyArray<RelayListItem>): string[];
|
|
21
|
+
//#endregion
|
|
22
|
+
export { relayListEventBuilder as a, readRelays as i, RelayMarker as n, relayListToTags as o, parseRelayList as r, writeRelays as s, RelayListItem as t };
|
|
23
|
+
//# sourceMappingURL=nip65-D1fbmhOg.d.mts.map
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import { t as Event } from "./event-
|
|
2
|
-
import { a as NostrError } from "./error-
|
|
1
|
+
import { t as Event } from "./event-DJeb_DIL.mjs";
|
|
2
|
+
import { a as NostrError } from "./error-BquXDmIN.mjs";
|
|
3
3
|
//#region src/nips/nip77.d.ts
|
|
4
4
|
declare const PROTOCOL_VERSION = 97;
|
|
5
5
|
declare const DEFAULT_FRAME_SIZE_LIMIT = 60000;
|
|
6
6
|
declare const MAX_NEG_ROUNDS = 1024;
|
|
7
7
|
declare class Nip77Error extends NostrError {
|
|
8
8
|
name: string;
|
|
9
|
-
constructor(message: string, options?: ErrorOptions);
|
|
10
9
|
}
|
|
11
10
|
type NegItem = {
|
|
12
|
-
timestamp: number;
|
|
13
|
-
id: Uint8Array;
|
|
11
|
+
readonly timestamp: number;
|
|
12
|
+
readonly id: Uint8Array;
|
|
14
13
|
};
|
|
15
14
|
type ReconcileOutcome = {
|
|
16
15
|
/** Event ids the local side holds that the peer does not. */
|
|
17
|
-
have: string
|
|
16
|
+
readonly have: ReadonlyArray<string>;
|
|
18
17
|
/** Event ids the peer holds that the local side does not. */
|
|
19
|
-
need: string
|
|
18
|
+
readonly need: ReadonlyArray<string>;
|
|
20
19
|
/** Next NEG-MSG hex, or undefined when the session converged. */
|
|
21
|
-
nextMessage: string | undefined;
|
|
20
|
+
readonly nextMessage: string | undefined;
|
|
22
21
|
};
|
|
23
22
|
declare class NegentropyStorageVector {
|
|
24
23
|
#private;
|
|
@@ -53,4 +52,4 @@ declare function runNegSession(opts: {
|
|
|
53
52
|
}>;
|
|
54
53
|
//#endregion
|
|
55
54
|
export { NegentropyStorageVector as a, ReconcileOutcome as c, storageFromItems as d, Negentropy as i, runNegSession as l, MAX_NEG_ROUNDS as n, Nip77Error as o, NegItem as r, PROTOCOL_VERSION as s, DEFAULT_FRAME_SIZE_LIMIT as t, storageFromEvents as u };
|
|
56
|
-
//# sourceMappingURL=nip77-
|
|
55
|
+
//# sourceMappingURL=nip77-DzUwUxHq.d.mts.map
|