nostr-tools 2.23.12 → 2.24.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/lib/cjs/abstract-pool.js +11 -21
- package/lib/cjs/abstract-pool.js.map +3 -3
- package/lib/cjs/abstract-relay.js +1 -1
- package/lib/cjs/abstract-relay.js.map +2 -2
- package/lib/cjs/core.js +17 -1
- package/lib/cjs/core.js.map +3 -3
- package/lib/cjs/filter.js.map +1 -1
- package/lib/cjs/index.js +124 -123
- package/lib/cjs/index.js.map +4 -4
- package/lib/cjs/kinds.js +17 -1
- package/lib/cjs/kinds.js.map +3 -3
- package/lib/cjs/nip04.js.map +1 -1
- package/lib/cjs/nip10.js +20 -5
- package/lib/cjs/nip10.js.map +3 -3
- package/lib/cjs/nip13.js.map +1 -1
- package/lib/cjs/nip17.js +30 -23
- package/lib/cjs/nip17.js.map +4 -4
- package/lib/cjs/nip18.js +21 -14
- package/lib/cjs/nip18.js.map +4 -4
- package/lib/cjs/nip19.js.map +1 -1
- package/lib/cjs/nip21.js.map +1 -1
- package/lib/cjs/nip22.js +22 -7
- package/lib/cjs/nip22.js.map +3 -3
- package/lib/cjs/nip25.js +21 -14
- package/lib/cjs/nip25.js.map +4 -4
- package/lib/cjs/nip27.js.map +1 -1
- package/lib/cjs/nip28.js +21 -14
- package/lib/cjs/nip28.js.map +4 -4
- package/lib/cjs/nip29.js.map +1 -1
- package/lib/cjs/nip30.js.map +2 -2
- package/lib/cjs/nip42.js.map +2 -2
- package/lib/cjs/nip44.js.map +1 -1
- package/lib/cjs/nip45.js +22 -9
- package/lib/cjs/nip45.js.map +4 -4
- package/lib/cjs/nip46.js +63 -63
- package/lib/cjs/nip46.js.map +4 -4
- package/lib/cjs/nip47.js +25 -18
- package/lib/cjs/nip47.js.map +4 -4
- package/lib/cjs/nip57.js +23 -16
- package/lib/cjs/nip57.js.map +4 -4
- package/lib/cjs/nip58.js.map +2 -2
- package/lib/cjs/nip59.js +16 -7
- package/lib/cjs/nip59.js.map +3 -3
- package/lib/cjs/nip75.js.map +1 -1
- package/lib/cjs/nip94.js.map +1 -1
- package/lib/cjs/nip98.js +23 -16
- package/lib/cjs/nip98.js.map +4 -4
- package/lib/cjs/nip99.js.map +2 -2
- package/lib/cjs/nipb0.js +34 -16
- package/lib/cjs/nipb0.js.map +4 -4
- package/lib/cjs/nipb7.js +13 -7
- package/lib/cjs/nipb7.js.map +2 -2
- package/lib/cjs/pool.js +54 -54
- package/lib/cjs/pool.js.map +4 -4
- package/lib/cjs/pure.js +21 -14
- package/lib/cjs/pure.js.map +4 -4
- package/lib/cjs/references.js.map +1 -1
- package/lib/cjs/relay.js +43 -36
- package/lib/cjs/relay.js.map +4 -4
- package/lib/cjs/signer.js +21 -14
- package/lib/cjs/signer.js.map +4 -4
- package/lib/cjs/utils.js +10 -0
- package/lib/cjs/utils.js.map +2 -2
- package/lib/cjs/wasm.js +16 -2
- package/lib/cjs/wasm.js.map +4 -4
- package/lib/esm/abstract-pool.js +11 -21
- package/lib/esm/abstract-pool.js.map +3 -3
- package/lib/esm/abstract-relay.js +1 -1
- package/lib/esm/abstract-relay.js.map +2 -2
- package/lib/esm/core.js +15 -1
- package/lib/esm/core.js.map +3 -3
- package/lib/esm/filter.js.map +1 -1
- package/lib/esm/index.js +74 -73
- package/lib/esm/index.js.map +4 -4
- package/lib/esm/kinds.js +17 -1
- package/lib/esm/kinds.js.map +3 -3
- package/lib/esm/nip04.js.map +1 -1
- package/lib/esm/nip10.js +18 -5
- package/lib/esm/nip10.js.map +3 -3
- package/lib/esm/nip13.js.map +1 -1
- package/lib/esm/nip17.js +15 -8
- package/lib/esm/nip17.js.map +4 -4
- package/lib/esm/nip18.js +15 -8
- package/lib/esm/nip18.js.map +4 -4
- package/lib/esm/nip19.js.map +1 -1
- package/lib/esm/nip21.js.map +1 -1
- package/lib/esm/nip22.js +20 -7
- package/lib/esm/nip22.js.map +3 -3
- package/lib/esm/nip25.js +15 -8
- package/lib/esm/nip25.js.map +4 -4
- package/lib/esm/nip27.js.map +1 -1
- package/lib/esm/nip28.js +15 -8
- package/lib/esm/nip28.js.map +4 -4
- package/lib/esm/nip29.js.map +1 -1
- package/lib/esm/nip30.js.map +2 -2
- package/lib/esm/nip42.js.map +2 -2
- package/lib/esm/nip44.js.map +1 -1
- package/lib/esm/nip45.js +23 -10
- package/lib/esm/nip45.js.map +4 -4
- package/lib/esm/nip46.js +47 -47
- package/lib/esm/nip46.js.map +4 -4
- package/lib/esm/nip47.js +15 -8
- package/lib/esm/nip47.js.map +4 -4
- package/lib/esm/nip57.js +17 -10
- package/lib/esm/nip57.js.map +4 -4
- package/lib/esm/nip58.js.map +2 -2
- package/lib/esm/nip59.js +10 -1
- package/lib/esm/nip59.js.map +3 -3
- package/lib/esm/nip75.js.map +1 -1
- package/lib/esm/nip94.js.map +1 -1
- package/lib/esm/nip98.js +15 -8
- package/lib/esm/nip98.js.map +4 -4
- package/lib/esm/nip99.js.map +2 -2
- package/lib/esm/nipb0.js +35 -17
- package/lib/esm/nipb0.js.map +4 -4
- package/lib/esm/nipb7.js +13 -7
- package/lib/esm/nipb7.js.map +2 -2
- package/lib/esm/pool.js +47 -47
- package/lib/esm/pool.js.map +4 -4
- package/lib/esm/pure.js +15 -8
- package/lib/esm/pure.js.map +4 -4
- package/lib/esm/references.js.map +1 -1
- package/lib/esm/relay.js +37 -30
- package/lib/esm/relay.js.map +4 -4
- package/lib/esm/signer.js +15 -8
- package/lib/esm/signer.js.map +4 -4
- package/lib/esm/utils.js +10 -0
- package/lib/esm/utils.js.map +2 -2
- package/lib/esm/wasm.js +17 -3
- package/lib/esm/wasm.js.map +4 -4
- package/lib/nostr.bundle.js +73 -70
- package/lib/nostr.bundle.js.map +4 -4
- package/lib/types/abstract-pool.d.ts +6 -4
- package/lib/types/abstract-relay.d.ts +2 -2
- package/lib/types/kinds.d.ts +2 -0
- package/lib/types/nipb0.d.ts +0 -1
- package/lib/types/nipb0.test.d.ts +1 -0
- package/lib/types/nipb7.d.ts +0 -1
- package/lib/types/utils.d.ts +4 -0
- package/package.json +1 -1
- package/lib/types/helpers.d.ts +0 -2
package/lib/cjs/index.js
CHANGED
|
@@ -67,48 +67,7 @@ module.exports = __toCommonJS(nostr_tools_exports);
|
|
|
67
67
|
|
|
68
68
|
// pure.ts
|
|
69
69
|
var import_secp256k1 = require("@noble/curves/secp256k1.js");
|
|
70
|
-
var
|
|
71
|
-
|
|
72
|
-
// core.ts
|
|
73
|
-
var verifiedSymbol = Symbol("verified");
|
|
74
|
-
var isRecord = (obj) => obj instanceof Object;
|
|
75
|
-
function validateEvent(event) {
|
|
76
|
-
if (!isRecord(event))
|
|
77
|
-
return false;
|
|
78
|
-
if (typeof event.kind !== "number")
|
|
79
|
-
return false;
|
|
80
|
-
if (typeof event.content !== "string")
|
|
81
|
-
return false;
|
|
82
|
-
if (typeof event.created_at !== "number")
|
|
83
|
-
return false;
|
|
84
|
-
if (typeof event.pubkey !== "string")
|
|
85
|
-
return false;
|
|
86
|
-
if (!event.pubkey.match(/^[a-f0-9]{64}$/))
|
|
87
|
-
return false;
|
|
88
|
-
if (!Array.isArray(event.tags))
|
|
89
|
-
return false;
|
|
90
|
-
for (let i2 = 0; i2 < event.tags.length; i2++) {
|
|
91
|
-
let tag = event.tags[i2];
|
|
92
|
-
if (!Array.isArray(tag))
|
|
93
|
-
return false;
|
|
94
|
-
for (let j = 0; j < tag.length; j++) {
|
|
95
|
-
if (typeof tag[j] !== "string")
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
function sortEvents(events) {
|
|
102
|
-
return events.sort((a, b) => {
|
|
103
|
-
if (a.created_at !== b.created_at) {
|
|
104
|
-
return b.created_at - a.created_at;
|
|
105
|
-
}
|
|
106
|
-
return a.id.localeCompare(b.id);
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// pure.ts
|
|
111
|
-
var import_sha2 = require("@noble/hashes/sha2.js");
|
|
70
|
+
var import_utils3 = require("@noble/hashes/utils.js");
|
|
112
71
|
|
|
113
72
|
// utils.ts
|
|
114
73
|
var utils_exports = {};
|
|
@@ -118,6 +77,7 @@ __export(utils_exports, {
|
|
|
118
77
|
hexToBytes: () => import_utils.hexToBytes,
|
|
119
78
|
insertEventIntoAscendingList: () => insertEventIntoAscendingList,
|
|
120
79
|
insertEventIntoDescendingList: () => insertEventIntoDescendingList,
|
|
80
|
+
isHex32: () => isHex32,
|
|
121
81
|
mergeReverseSortedLists: () => mergeReverseSortedLists,
|
|
122
82
|
normalizeURL: () => normalizeURL,
|
|
123
83
|
utf8Decoder: () => utf8Decoder,
|
|
@@ -240,20 +200,68 @@ function mergeReverseSortedLists(list1, list2) {
|
|
|
240
200
|
}
|
|
241
201
|
return result;
|
|
242
202
|
}
|
|
203
|
+
function isHex32(input) {
|
|
204
|
+
for (let i2 = 0; i2 < 64; i2++) {
|
|
205
|
+
let cc = input.charCodeAt(i2);
|
|
206
|
+
if (isNaN(cc) || cc < 48 || cc > 102 || cc > 57 && cc < 97) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// core.ts
|
|
214
|
+
var verifiedSymbol = Symbol("verified");
|
|
215
|
+
var isRecord = (obj) => obj instanceof Object;
|
|
216
|
+
function validateEvent(event) {
|
|
217
|
+
if (!isRecord(event))
|
|
218
|
+
return false;
|
|
219
|
+
if (typeof event.kind !== "number")
|
|
220
|
+
return false;
|
|
221
|
+
if (typeof event.content !== "string")
|
|
222
|
+
return false;
|
|
223
|
+
if (typeof event.created_at !== "number")
|
|
224
|
+
return false;
|
|
225
|
+
if (typeof event.pubkey !== "string")
|
|
226
|
+
return false;
|
|
227
|
+
if (!isHex32(event.pubkey))
|
|
228
|
+
return false;
|
|
229
|
+
if (!Array.isArray(event.tags))
|
|
230
|
+
return false;
|
|
231
|
+
for (let i2 = 0; i2 < event.tags.length; i2++) {
|
|
232
|
+
let tag = event.tags[i2];
|
|
233
|
+
if (!Array.isArray(tag))
|
|
234
|
+
return false;
|
|
235
|
+
for (let j = 0; j < tag.length; j++) {
|
|
236
|
+
if (typeof tag[j] !== "string")
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return true;
|
|
241
|
+
}
|
|
242
|
+
function sortEvents(events) {
|
|
243
|
+
return events.sort((a, b) => {
|
|
244
|
+
if (a.created_at !== b.created_at) {
|
|
245
|
+
return b.created_at - a.created_at;
|
|
246
|
+
}
|
|
247
|
+
return a.id.localeCompare(b.id);
|
|
248
|
+
});
|
|
249
|
+
}
|
|
243
250
|
|
|
244
251
|
// pure.ts
|
|
252
|
+
var import_sha2 = require("@noble/hashes/sha2.js");
|
|
245
253
|
var JS = class {
|
|
246
254
|
generateSecretKey() {
|
|
247
255
|
return import_secp256k1.schnorr.utils.randomSecretKey();
|
|
248
256
|
}
|
|
249
257
|
getPublicKey(secretKey) {
|
|
250
|
-
return (0,
|
|
258
|
+
return (0, import_utils3.bytesToHex)(import_secp256k1.schnorr.getPublicKey(secretKey));
|
|
251
259
|
}
|
|
252
260
|
finalizeEvent(t, secretKey) {
|
|
253
261
|
const event = t;
|
|
254
|
-
event.pubkey = (0,
|
|
262
|
+
event.pubkey = (0, import_utils3.bytesToHex)(import_secp256k1.schnorr.getPublicKey(secretKey));
|
|
255
263
|
event.id = getEventHash(event);
|
|
256
|
-
event.sig = (0,
|
|
264
|
+
event.sig = (0, import_utils3.bytesToHex)(import_secp256k1.schnorr.sign((0, import_utils3.hexToBytes)(getEventHash(event)), secretKey));
|
|
257
265
|
event[verifiedSymbol] = true;
|
|
258
266
|
return event;
|
|
259
267
|
}
|
|
@@ -266,7 +274,7 @@ var JS = class {
|
|
|
266
274
|
event[verifiedSymbol] = false;
|
|
267
275
|
return false;
|
|
268
276
|
}
|
|
269
|
-
const valid = import_secp256k1.schnorr.verify((0,
|
|
277
|
+
const valid = import_secp256k1.schnorr.verify((0, import_utils3.hexToBytes)(event.sig), (0, import_utils3.hexToBytes)(hash), (0, import_utils3.hexToBytes)(event.pubkey));
|
|
270
278
|
event[verifiedSymbol] = valid;
|
|
271
279
|
return valid;
|
|
272
280
|
} catch (err) {
|
|
@@ -282,7 +290,7 @@ function serializeEvent(evt) {
|
|
|
282
290
|
}
|
|
283
291
|
function getEventHash(event) {
|
|
284
292
|
let eventHash = (0, import_sha2.sha256)(utf8Encoder.encode(serializeEvent(event)));
|
|
285
|
-
return (0,
|
|
293
|
+
return (0, import_utils3.bytesToHex)(eventHash);
|
|
286
294
|
}
|
|
287
295
|
var i = new JS();
|
|
288
296
|
var generateSecretKey = i.generateSecretKey;
|
|
@@ -344,6 +352,7 @@ __export(kinds_exports, {
|
|
|
344
352
|
Emojisets: () => Emojisets,
|
|
345
353
|
EncryptedDirectMessage: () => EncryptedDirectMessage,
|
|
346
354
|
EventDeletion: () => EventDeletion,
|
|
355
|
+
FavoriteFollowSets: () => FavoriteFollowSets,
|
|
347
356
|
FavoritePodcasts: () => FavoritePodcasts,
|
|
348
357
|
FavoriteRelays: () => FavoriteRelays,
|
|
349
358
|
FedimintAnnouncement: () => FedimintAnnouncement,
|
|
@@ -616,6 +625,7 @@ var PrivateEventRelayList = 10013;
|
|
|
616
625
|
var InterestsList = 10015;
|
|
617
626
|
var NutZapInfo = 10019;
|
|
618
627
|
var MediaFollows = 10020;
|
|
628
|
+
var FavoriteFollowSets = 10021;
|
|
619
629
|
var UserEmojiList = 10030;
|
|
620
630
|
var DecoupledKeyAnnouncement = 10044;
|
|
621
631
|
var DirectMessageRelaysList = 10050;
|
|
@@ -1215,7 +1225,7 @@ var AbstractRelay = class {
|
|
|
1215
1225
|
case "EVENT": {
|
|
1216
1226
|
const so = this.openSubs.get(data[1]);
|
|
1217
1227
|
const event = data[2];
|
|
1218
|
-
if (
|
|
1228
|
+
if (matchFilters(so.filters, event) && this.verifyEvent(event, this.url)) {
|
|
1219
1229
|
so.onevent(event);
|
|
1220
1230
|
} else {
|
|
1221
1231
|
so.oninvalidevent?.(event);
|
|
@@ -1388,15 +1398,9 @@ var Relay = class extends AbstractRelay {
|
|
|
1388
1398
|
}
|
|
1389
1399
|
};
|
|
1390
1400
|
|
|
1391
|
-
// helpers.ts
|
|
1392
|
-
var alwaysTrue = (t) => {
|
|
1393
|
-
t[verifiedSymbol] = true;
|
|
1394
|
-
return true;
|
|
1395
|
-
};
|
|
1396
|
-
|
|
1397
1401
|
// nip45.ts
|
|
1398
1402
|
var import_sha22 = require("@noble/hashes/sha2.js");
|
|
1399
|
-
var
|
|
1403
|
+
var import_utils6 = require("@noble/hashes/utils.js");
|
|
1400
1404
|
var M = 256;
|
|
1401
1405
|
var HLL_HEX_LENGTH = M * 2;
|
|
1402
1406
|
var utf8Encoder2 = new TextEncoder();
|
|
@@ -1420,7 +1424,7 @@ function newHll() {
|
|
|
1420
1424
|
return new Uint8Array(M);
|
|
1421
1425
|
}
|
|
1422
1426
|
function hllDecode(hex) {
|
|
1423
|
-
if (hex.length !== HLL_HEX_LENGTH || !/^[0-9a-
|
|
1427
|
+
if (hex.length !== HLL_HEX_LENGTH || !/^[0-9a-f]+$/.test(hex))
|
|
1424
1428
|
return void 0;
|
|
1425
1429
|
const registers = new Uint8Array(M);
|
|
1426
1430
|
for (let i2 = 0; i2 < M; i2++) {
|
|
@@ -1461,7 +1465,6 @@ var AbstractSimplePool = class {
|
|
|
1461
1465
|
enableReconnect;
|
|
1462
1466
|
idleTimeout = 2e4;
|
|
1463
1467
|
automaticallyAuth;
|
|
1464
|
-
trustedRelayURLs = /* @__PURE__ */ new Set();
|
|
1465
1468
|
onRelayConnectionFailure;
|
|
1466
1469
|
onRelayConnectionSuccess;
|
|
1467
1470
|
allowConnectingToRelay;
|
|
@@ -1485,7 +1488,7 @@ var AbstractSimplePool = class {
|
|
|
1485
1488
|
let relay = this.relays.get(url);
|
|
1486
1489
|
if (!relay) {
|
|
1487
1490
|
relay = new AbstractRelay(url, {
|
|
1488
|
-
verifyEvent: this.
|
|
1491
|
+
verifyEvent: this.verifyEvent,
|
|
1489
1492
|
websocketImplementation: this._WebSocket,
|
|
1490
1493
|
enablePing: this.enablePing,
|
|
1491
1494
|
enableReconnect: this.enableReconnect,
|
|
@@ -1569,11 +1572,11 @@ var AbstractSimplePool = class {
|
|
|
1569
1572
|
}
|
|
1570
1573
|
};
|
|
1571
1574
|
const closesReceived = [];
|
|
1572
|
-
let handleClose = (i2, reason) => {
|
|
1575
|
+
let handleClose = (i2, url, reason) => {
|
|
1573
1576
|
if (closesReceived[i2])
|
|
1574
1577
|
return;
|
|
1575
1578
|
handleEose(i2);
|
|
1576
|
-
closesReceived[i2] = reason;
|
|
1579
|
+
closesReceived[i2] = { url, reason };
|
|
1577
1580
|
if (closesReceived.filter((a) => a).length === groupedRequests.length) {
|
|
1578
1581
|
params.onclose?.(closesReceived);
|
|
1579
1582
|
handleClose = () => {
|
|
@@ -1591,7 +1594,7 @@ var AbstractSimplePool = class {
|
|
|
1591
1594
|
const allOpened = Promise.all(
|
|
1592
1595
|
groupedRequests.map(async ({ url, filters }, i2) => {
|
|
1593
1596
|
if (this.allowConnectingToRelay?.(url, ["read", filters]) === false) {
|
|
1594
|
-
handleClose(i2, "connection skipped by allowConnectingToRelay");
|
|
1597
|
+
handleClose(i2, url, "connection skipped by allowConnectingToRelay");
|
|
1595
1598
|
return;
|
|
1596
1599
|
}
|
|
1597
1600
|
let relay;
|
|
@@ -1602,7 +1605,7 @@ var AbstractSimplePool = class {
|
|
|
1602
1605
|
});
|
|
1603
1606
|
} catch (err) {
|
|
1604
1607
|
this.onRelayConnectionFailure?.(url);
|
|
1605
|
-
handleClose(i2, err?.message || String(err));
|
|
1608
|
+
handleClose(i2, url, err?.message || String(err));
|
|
1606
1609
|
return;
|
|
1607
1610
|
}
|
|
1608
1611
|
this.onRelayConnectionSuccess?.(url);
|
|
@@ -1616,17 +1619,17 @@ var AbstractSimplePool = class {
|
|
|
1616
1619
|
...params,
|
|
1617
1620
|
oneose: () => handleEose(i2),
|
|
1618
1621
|
onclose: (reason2) => {
|
|
1619
|
-
handleClose(i2, reason2);
|
|
1622
|
+
handleClose(i2, url, reason2);
|
|
1620
1623
|
},
|
|
1621
1624
|
alreadyHaveEvent: localAlreadyHaveEventHandler,
|
|
1622
1625
|
eoseTimeout: params.maxWait,
|
|
1623
1626
|
abort: params.abort
|
|
1624
1627
|
});
|
|
1625
1628
|
}).catch((err) => {
|
|
1626
|
-
handleClose(i2, `auth was required and attempted, but failed with: ${err}`);
|
|
1629
|
+
handleClose(i2, url, `auth was required and attempted, but failed with: ${err}`);
|
|
1627
1630
|
});
|
|
1628
1631
|
} else {
|
|
1629
|
-
handleClose(i2, reason);
|
|
1632
|
+
handleClose(i2, url, reason);
|
|
1630
1633
|
}
|
|
1631
1634
|
},
|
|
1632
1635
|
alreadyHaveEvent: localAlreadyHaveEventHandler,
|
|
@@ -1654,7 +1657,7 @@ var AbstractSimplePool = class {
|
|
|
1654
1657
|
if (subcloser)
|
|
1655
1658
|
subcloser.close(reason);
|
|
1656
1659
|
else
|
|
1657
|
-
params.onclose?.(relays.map((
|
|
1660
|
+
params.onclose?.(relays.map((url) => ({ url, reason })));
|
|
1658
1661
|
}
|
|
1659
1662
|
});
|
|
1660
1663
|
return subcloser;
|
|
@@ -1811,7 +1814,7 @@ __export(nip19_exports, {
|
|
|
1811
1814
|
npubEncode: () => npubEncode,
|
|
1812
1815
|
nsecEncode: () => nsecEncode
|
|
1813
1816
|
});
|
|
1814
|
-
var
|
|
1817
|
+
var import_utils8 = require("@noble/hashes/utils.js");
|
|
1815
1818
|
var import_base = require("@scure/base");
|
|
1816
1819
|
var NostrTypeGuard = {
|
|
1817
1820
|
isNProfile: (value) => /^nprofile1[a-z\d]+$/.test(value || ""),
|
|
@@ -1854,7 +1857,7 @@ function decode(code) {
|
|
|
1854
1857
|
return {
|
|
1855
1858
|
type: "nprofile",
|
|
1856
1859
|
data: {
|
|
1857
|
-
pubkey: (0,
|
|
1860
|
+
pubkey: (0, import_utils8.bytesToHex)(tlv[0][0]),
|
|
1858
1861
|
relays: tlv[1] ? tlv[1].map((d) => utf8Decoder.decode(d)) : []
|
|
1859
1862
|
}
|
|
1860
1863
|
};
|
|
@@ -1872,10 +1875,10 @@ function decode(code) {
|
|
|
1872
1875
|
return {
|
|
1873
1876
|
type: "nevent",
|
|
1874
1877
|
data: {
|
|
1875
|
-
id: (0,
|
|
1878
|
+
id: (0, import_utils8.bytesToHex)(tlv[0][0]),
|
|
1876
1879
|
relays: tlv[1] ? tlv[1].map((d) => utf8Decoder.decode(d)) : [],
|
|
1877
|
-
author: tlv[2]?.[0] ? (0,
|
|
1878
|
-
kind: tlv[3]?.[0] ? parseInt((0,
|
|
1880
|
+
author: tlv[2]?.[0] ? (0, import_utils8.bytesToHex)(tlv[2][0]) : void 0,
|
|
1881
|
+
kind: tlv[3]?.[0] ? parseInt((0, import_utils8.bytesToHex)(tlv[3][0]), 16) : void 0
|
|
1879
1882
|
}
|
|
1880
1883
|
};
|
|
1881
1884
|
}
|
|
@@ -1895,8 +1898,8 @@ function decode(code) {
|
|
|
1895
1898
|
type: "naddr",
|
|
1896
1899
|
data: {
|
|
1897
1900
|
identifier: utf8Decoder.decode(tlv[0][0]),
|
|
1898
|
-
pubkey: (0,
|
|
1899
|
-
kind: parseInt((0,
|
|
1901
|
+
pubkey: (0, import_utils8.bytesToHex)(tlv[2][0]),
|
|
1902
|
+
kind: parseInt((0, import_utils8.bytesToHex)(tlv[3][0]), 16),
|
|
1900
1903
|
relays: tlv[1] ? tlv[1].map((d) => utf8Decoder.decode(d)) : []
|
|
1901
1904
|
}
|
|
1902
1905
|
};
|
|
@@ -1905,7 +1908,7 @@ function decode(code) {
|
|
|
1905
1908
|
return { type: prefix, data };
|
|
1906
1909
|
case "npub":
|
|
1907
1910
|
case "note":
|
|
1908
|
-
return { type: prefix, data: (0,
|
|
1911
|
+
return { type: prefix, data: (0, import_utils8.bytesToHex)(data) };
|
|
1909
1912
|
default:
|
|
1910
1913
|
throw new Error(`unknown prefix ${prefix}`);
|
|
1911
1914
|
}
|
|
@@ -1931,10 +1934,10 @@ function nsecEncode(key) {
|
|
|
1931
1934
|
return encodeBytes("nsec", key);
|
|
1932
1935
|
}
|
|
1933
1936
|
function npubEncode(hex) {
|
|
1934
|
-
return encodeBytes("npub", (0,
|
|
1937
|
+
return encodeBytes("npub", (0, import_utils8.hexToBytes)(hex));
|
|
1935
1938
|
}
|
|
1936
1939
|
function noteEncode(hex) {
|
|
1937
|
-
return encodeBytes("note", (0,
|
|
1940
|
+
return encodeBytes("note", (0, import_utils8.hexToBytes)(hex));
|
|
1938
1941
|
}
|
|
1939
1942
|
function encodeBech32(prefix, data) {
|
|
1940
1943
|
let words = import_base.bech32.toWords(data);
|
|
@@ -1945,7 +1948,7 @@ function encodeBytes(prefix, bytes) {
|
|
|
1945
1948
|
}
|
|
1946
1949
|
function nprofileEncode(profile) {
|
|
1947
1950
|
let data = encodeTLV({
|
|
1948
|
-
0: [(0,
|
|
1951
|
+
0: [(0, import_utils8.hexToBytes)(profile.pubkey)],
|
|
1949
1952
|
1: (profile.relays || []).map((url) => utf8Encoder.encode(url))
|
|
1950
1953
|
});
|
|
1951
1954
|
return encodeBech32("nprofile", data);
|
|
@@ -1956,9 +1959,9 @@ function neventEncode(event) {
|
|
|
1956
1959
|
kindArray = integerToUint8Array(event.kind);
|
|
1957
1960
|
}
|
|
1958
1961
|
let data = encodeTLV({
|
|
1959
|
-
0: [(0,
|
|
1962
|
+
0: [(0, import_utils8.hexToBytes)(event.id)],
|
|
1960
1963
|
1: (event.relays || []).map((url) => utf8Encoder.encode(url)),
|
|
1961
|
-
2: event.author ? [(0,
|
|
1964
|
+
2: event.author ? [(0, import_utils8.hexToBytes)(event.author)] : [],
|
|
1962
1965
|
3: kindArray ? [new Uint8Array(kindArray)] : []
|
|
1963
1966
|
});
|
|
1964
1967
|
return encodeBech32("nevent", data);
|
|
@@ -1969,7 +1972,7 @@ function naddrEncode(addr) {
|
|
|
1969
1972
|
let data = encodeTLV({
|
|
1970
1973
|
0: [utf8Encoder.encode(addr.identifier)],
|
|
1971
1974
|
1: (addr.relays || []).map((url) => utf8Encoder.encode(url)),
|
|
1972
|
-
2: [(0,
|
|
1975
|
+
2: [(0, import_utils8.hexToBytes)(addr.pubkey)],
|
|
1973
1976
|
3: [new Uint8Array(kind)]
|
|
1974
1977
|
});
|
|
1975
1978
|
return encodeBech32("naddr", data);
|
|
@@ -1985,7 +1988,7 @@ function encodeTLV(tlv) {
|
|
|
1985
1988
|
entries.push(entry);
|
|
1986
1989
|
});
|
|
1987
1990
|
});
|
|
1988
|
-
return (0,
|
|
1991
|
+
return (0, import_utils8.concatBytes)(...entries);
|
|
1989
1992
|
}
|
|
1990
1993
|
|
|
1991
1994
|
// references.ts
|
|
@@ -2083,15 +2086,15 @@ __export(nip04_exports, {
|
|
|
2083
2086
|
decrypt: () => decrypt,
|
|
2084
2087
|
encrypt: () => encrypt
|
|
2085
2088
|
});
|
|
2086
|
-
var
|
|
2089
|
+
var import_utils10 = require("@noble/hashes/utils.js");
|
|
2087
2090
|
var import_secp256k12 = require("@noble/curves/secp256k1.js");
|
|
2088
2091
|
var import_aes = require("@noble/ciphers/aes.js");
|
|
2089
2092
|
var import_base2 = require("@scure/base");
|
|
2090
2093
|
function encrypt(secretKey, pubkey, text) {
|
|
2091
|
-
const privkey = secretKey instanceof Uint8Array ? secretKey : (0,
|
|
2092
|
-
const key = import_secp256k12.secp256k1.getSharedSecret(privkey, (0,
|
|
2094
|
+
const privkey = secretKey instanceof Uint8Array ? secretKey : (0, import_utils10.hexToBytes)(secretKey);
|
|
2095
|
+
const key = import_secp256k12.secp256k1.getSharedSecret(privkey, (0, import_utils10.hexToBytes)("02" + pubkey));
|
|
2093
2096
|
const normalizedKey = getNormalizedX(key);
|
|
2094
|
-
let iv = Uint8Array.from((0,
|
|
2097
|
+
let iv = Uint8Array.from((0, import_utils10.randomBytes)(16));
|
|
2095
2098
|
let plaintext = utf8Encoder.encode(text);
|
|
2096
2099
|
let ciphertext = (0, import_aes.cbc)(normalizedKey, iv).encrypt(plaintext);
|
|
2097
2100
|
let ctb64 = import_base2.base64.encode(new Uint8Array(ciphertext));
|
|
@@ -2099,9 +2102,9 @@ function encrypt(secretKey, pubkey, text) {
|
|
|
2099
2102
|
return `${ctb64}?iv=${ivb64}`;
|
|
2100
2103
|
}
|
|
2101
2104
|
function decrypt(secretKey, pubkey, data) {
|
|
2102
|
-
const privkey = secretKey instanceof Uint8Array ? secretKey : (0,
|
|
2105
|
+
const privkey = secretKey instanceof Uint8Array ? secretKey : (0, import_utils10.hexToBytes)(secretKey);
|
|
2103
2106
|
let [ctb64, ivb64] = data.split("?iv=");
|
|
2104
|
-
let key = import_secp256k12.secp256k1.getSharedSecret(privkey, (0,
|
|
2107
|
+
let key = import_secp256k12.secp256k1.getSharedSecret(privkey, (0, import_utils10.hexToBytes)("02" + pubkey));
|
|
2105
2108
|
let normalizedKey = getNormalizedX(key);
|
|
2106
2109
|
let iv = import_base2.base64.decode(ivb64);
|
|
2107
2110
|
let ciphertext = import_base2.base64.decode(ctb64);
|
|
@@ -2174,7 +2177,6 @@ var nip10_exports = {};
|
|
|
2174
2177
|
__export(nip10_exports, {
|
|
2175
2178
|
parse: () => parse
|
|
2176
2179
|
});
|
|
2177
|
-
var HEX64 = /^[0-9a-fA-F]{64}$/;
|
|
2178
2180
|
function parse(event) {
|
|
2179
2181
|
const result = {
|
|
2180
2182
|
reply: void 0,
|
|
@@ -2187,12 +2189,12 @@ function parse(event) {
|
|
|
2187
2189
|
let maybeRoot;
|
|
2188
2190
|
for (let i2 = event.tags.length - 1; i2 >= 0; i2--) {
|
|
2189
2191
|
const tag = event.tags[i2];
|
|
2190
|
-
if (tag[0] === "e" && tag[1] &&
|
|
2192
|
+
if (tag[0] === "e" && tag[1] && isHex32(tag[1])) {
|
|
2191
2193
|
const [_, eTagEventId, eTagRelayUrl, eTagMarker, eTagAuthor] = tag;
|
|
2192
2194
|
const eventPointer = {
|
|
2193
2195
|
id: eTagEventId,
|
|
2194
2196
|
relays: eTagRelayUrl ? [eTagRelayUrl] : [],
|
|
2195
|
-
author: eTagAuthor &&
|
|
2197
|
+
author: eTagAuthor && isHex32(eTagAuthor) ? eTagAuthor : void 0
|
|
2196
2198
|
};
|
|
2197
2199
|
if (eTagMarker === "root") {
|
|
2198
2200
|
result.root = eventPointer;
|
|
@@ -2214,14 +2216,14 @@ function parse(event) {
|
|
|
2214
2216
|
result.mentions.push(eventPointer);
|
|
2215
2217
|
continue;
|
|
2216
2218
|
}
|
|
2217
|
-
if (tag[0] === "q" && tag[1] &&
|
|
2219
|
+
if (tag[0] === "q" && tag[1] && isHex32(tag[1])) {
|
|
2218
2220
|
const [_, eTagEventId, eTagRelayUrl] = tag;
|
|
2219
2221
|
result.quotes.push({
|
|
2220
2222
|
id: eTagEventId,
|
|
2221
2223
|
relays: eTagRelayUrl ? [eTagRelayUrl] : []
|
|
2222
2224
|
});
|
|
2223
2225
|
}
|
|
2224
|
-
if (tag[0] === "p" && tag[1] &&
|
|
2226
|
+
if (tag[0] === "p" && tag[1] && isHex32(tag[1])) {
|
|
2225
2227
|
result.profiles.push({
|
|
2226
2228
|
pubkey: tag[1],
|
|
2227
2229
|
relays: tag[2] ? [tag[2]] : []
|
|
@@ -2301,7 +2303,7 @@ __export(nip13_exports, {
|
|
|
2301
2303
|
getPow: () => getPow,
|
|
2302
2304
|
minePow: () => minePow
|
|
2303
2305
|
});
|
|
2304
|
-
var
|
|
2306
|
+
var import_utils13 = require("@noble/hashes/utils.js");
|
|
2305
2307
|
var import_sha23 = require("@noble/hashes/sha2.js");
|
|
2306
2308
|
function getPow(hex) {
|
|
2307
2309
|
let count = 0;
|
|
@@ -2345,7 +2347,7 @@ function minePow(unsigned, difficulty) {
|
|
|
2345
2347
|
utf8Encoder.encode(JSON.stringify([0, event.pubkey, event.created_at, event.kind, event.tags, event.content]))
|
|
2346
2348
|
);
|
|
2347
2349
|
if (getPowFromBytes(hash) >= difficulty) {
|
|
2348
|
-
event.id = (0,
|
|
2350
|
+
event.id = (0, import_utils13.bytesToHex)(hash);
|
|
2349
2351
|
break;
|
|
2350
2352
|
}
|
|
2351
2353
|
}
|
|
@@ -2382,18 +2384,18 @@ __export(nip44_exports, {
|
|
|
2382
2384
|
v2: () => v2
|
|
2383
2385
|
});
|
|
2384
2386
|
var import_chacha = require("@noble/ciphers/chacha.js");
|
|
2385
|
-
var
|
|
2387
|
+
var import_utils15 = require("@noble/ciphers/utils.js");
|
|
2386
2388
|
var import_secp256k13 = require("@noble/curves/secp256k1.js");
|
|
2387
2389
|
var import_hkdf = require("@noble/hashes/hkdf.js");
|
|
2388
2390
|
var import_hmac = require("@noble/hashes/hmac.js");
|
|
2389
2391
|
var import_sha24 = require("@noble/hashes/sha2.js");
|
|
2390
|
-
var
|
|
2392
|
+
var import_utils16 = require("@noble/hashes/utils.js");
|
|
2391
2393
|
var import_base3 = require("@scure/base");
|
|
2392
2394
|
var minPlaintextSize = 1;
|
|
2393
2395
|
var maxPlaintextSize = 4294967295;
|
|
2394
2396
|
var extendedPrefixThreshold = 65536;
|
|
2395
2397
|
function getConversationKey(privkeyA, pubkeyB) {
|
|
2396
|
-
const sharedX = import_secp256k13.secp256k1.getSharedSecret(privkeyA, (0,
|
|
2398
|
+
const sharedX = import_secp256k13.secp256k1.getSharedSecret(privkeyA, (0, import_utils16.hexToBytes)("02" + pubkeyB)).subarray(1, 33);
|
|
2397
2399
|
return (0, import_hkdf.extract)(import_sha24.sha256, sharedX, utf8Encoder.encode("nip44-v2"));
|
|
2398
2400
|
}
|
|
2399
2401
|
function getMessageKeys(conversationKey, nonce) {
|
|
@@ -2432,9 +2434,9 @@ function pad(plaintext) {
|
|
|
2432
2434
|
const unpaddedLen = unpadded.length;
|
|
2433
2435
|
if (unpaddedLen < minPlaintextSize || unpaddedLen > maxPlaintextSize)
|
|
2434
2436
|
throw new Error("invalid plaintext size: must be between 1 and 4294967295 bytes");
|
|
2435
|
-
const prefix = unpaddedLen >= extendedPrefixThreshold ? (0,
|
|
2437
|
+
const prefix = unpaddedLen >= extendedPrefixThreshold ? (0, import_utils16.concatBytes)(new Uint8Array([0, 0]), writeU32BE(unpaddedLen)) : writeU16BE(unpaddedLen);
|
|
2436
2438
|
const suffix = new Uint8Array(calcPaddedLen(unpaddedLen) - unpaddedLen);
|
|
2437
|
-
return (0,
|
|
2439
|
+
return (0, import_utils16.concatBytes)(prefix, unpadded, suffix);
|
|
2438
2440
|
}
|
|
2439
2441
|
function unpad(padded) {
|
|
2440
2442
|
const dv = new DataView(padded.buffer, padded.byteOffset, padded.byteLength);
|
|
@@ -2458,7 +2460,7 @@ function unpad(padded) {
|
|
|
2458
2460
|
function hmacAad(key, message, aad) {
|
|
2459
2461
|
if (aad.length !== 32)
|
|
2460
2462
|
throw new Error("AAD associated data must be 32 bytes");
|
|
2461
|
-
const combined = (0,
|
|
2463
|
+
const combined = (0, import_utils16.concatBytes)(aad, message);
|
|
2462
2464
|
return (0, import_hmac.hmac)(import_sha24.sha256, key, combined);
|
|
2463
2465
|
}
|
|
2464
2466
|
function decodePayload(payload) {
|
|
@@ -2487,18 +2489,18 @@ function decodePayload(payload) {
|
|
|
2487
2489
|
mac: data.subarray(-32)
|
|
2488
2490
|
};
|
|
2489
2491
|
}
|
|
2490
|
-
function encrypt2(plaintext, conversationKey, nonce = (0,
|
|
2492
|
+
function encrypt2(plaintext, conversationKey, nonce = (0, import_utils16.randomBytes)(32)) {
|
|
2491
2493
|
const { chacha_key, chacha_nonce, hmac_key } = getMessageKeys(conversationKey, nonce);
|
|
2492
2494
|
const padded = pad(plaintext);
|
|
2493
2495
|
const ciphertext = (0, import_chacha.chacha20)(chacha_key, chacha_nonce, padded);
|
|
2494
2496
|
const mac = hmacAad(hmac_key, ciphertext, nonce);
|
|
2495
|
-
return import_base3.base64.encode((0,
|
|
2497
|
+
return import_base3.base64.encode((0, import_utils16.concatBytes)(new Uint8Array([2]), nonce, ciphertext, mac));
|
|
2496
2498
|
}
|
|
2497
2499
|
function decrypt2(payload, conversationKey) {
|
|
2498
2500
|
const { nonce, ciphertext, mac } = decodePayload(payload);
|
|
2499
2501
|
const { chacha_key, chacha_nonce, hmac_key } = getMessageKeys(conversationKey, nonce);
|
|
2500
2502
|
const calculatedMac = hmacAad(hmac_key, ciphertext, nonce);
|
|
2501
|
-
if (!(0,
|
|
2503
|
+
if (!(0, import_utils15.equalBytes)(calculatedMac, mac))
|
|
2502
2504
|
throw new Error("invalid MAC");
|
|
2503
2505
|
const padded = (0, import_chacha.chacha20)(chacha_key, chacha_nonce, ciphertext);
|
|
2504
2506
|
return unpad(padded);
|
|
@@ -2718,7 +2720,6 @@ var nip22_exports = {};
|
|
|
2718
2720
|
__export(nip22_exports, {
|
|
2719
2721
|
parse: () => parse3
|
|
2720
2722
|
});
|
|
2721
|
-
var HEX642 = /^[0-9a-fA-F]{64}$/;
|
|
2722
2723
|
function parseKind(kind) {
|
|
2723
2724
|
if (!kind)
|
|
2724
2725
|
return void 0;
|
|
@@ -2733,7 +2734,7 @@ function parseAddressPointer(value, relayUrl) {
|
|
|
2733
2734
|
if (Number.isNaN(kind))
|
|
2734
2735
|
return void 0;
|
|
2735
2736
|
const pubkey = value.slice(idx + 1, idx2);
|
|
2736
|
-
if (!
|
|
2737
|
+
if (!isHex32(pubkey))
|
|
2737
2738
|
return void 0;
|
|
2738
2739
|
return {
|
|
2739
2740
|
kind,
|
|
@@ -2746,12 +2747,12 @@ function parsePointer(tag) {
|
|
|
2746
2747
|
switch (tag[0]) {
|
|
2747
2748
|
case "E":
|
|
2748
2749
|
case "e":
|
|
2749
|
-
if (!tag[1] || !
|
|
2750
|
+
if (!tag[1] || !isHex32(tag[1]))
|
|
2750
2751
|
return void 0;
|
|
2751
2752
|
return {
|
|
2752
2753
|
id: tag[1],
|
|
2753
2754
|
relays: tag[2] ? [tag[2]] : [],
|
|
2754
|
-
author: tag[3] &&
|
|
2755
|
+
author: tag[3] && isHex32(tag[3]) ? tag[3] : void 0
|
|
2755
2756
|
};
|
|
2756
2757
|
case "A":
|
|
2757
2758
|
case "a":
|
|
@@ -2774,12 +2775,12 @@ function parseQuote(tag) {
|
|
|
2774
2775
|
if (tag[1].includes(":")) {
|
|
2775
2776
|
return parseAddressPointer(tag[1], tag[2]);
|
|
2776
2777
|
}
|
|
2777
|
-
if (!
|
|
2778
|
+
if (!isHex32(tag[1]))
|
|
2778
2779
|
return void 0;
|
|
2779
2780
|
return {
|
|
2780
2781
|
id: tag[1],
|
|
2781
2782
|
relays: tag[2] ? [tag[2]] : [],
|
|
2782
|
-
author: tag[3] &&
|
|
2783
|
+
author: tag[3] && isHex32(tag[3]) ? tag[3] : void 0
|
|
2783
2784
|
};
|
|
2784
2785
|
}
|
|
2785
2786
|
function choosePointer(candidates) {
|
|
@@ -2839,7 +2840,7 @@ function parse3(event) {
|
|
|
2839
2840
|
result.quotes.push(pointer);
|
|
2840
2841
|
continue;
|
|
2841
2842
|
}
|
|
2842
|
-
if ((tag[0] === "P" || tag[0] === "p") && tag[1] &&
|
|
2843
|
+
if ((tag[0] === "P" || tag[0] === "p") && tag[1] && isHex32(tag[1])) {
|
|
2843
2844
|
result.profiles.push({
|
|
2844
2845
|
pubkey: tag[1],
|
|
2845
2846
|
relays: tag[2] ? [tag[2]] : []
|
|
@@ -3340,10 +3341,10 @@ function validateZapRequest(zapRequestString) {
|
|
|
3340
3341
|
let p = zapRequest.tags.find(([t, v]) => t === "p" && v);
|
|
3341
3342
|
if (!p)
|
|
3342
3343
|
return "Zap request doesn't have a 'p' tag.";
|
|
3343
|
-
if (!p[1]
|
|
3344
|
+
if (!isHex32(p[1]))
|
|
3344
3345
|
return "Zap request 'p' tag is not valid hex.";
|
|
3345
3346
|
let e = zapRequest.tags.find(([t, v]) => t === "e" && v);
|
|
3346
|
-
if (e && !e[1]
|
|
3347
|
+
if (e && !isHex32(e[1]))
|
|
3347
3348
|
return "Zap request 'e' tag is not valid hex.";
|
|
3348
3349
|
let relays = zapRequest.tags.find(([t, v]) => t === "relays" && v);
|
|
3349
3350
|
if (!relays)
|
|
@@ -3418,7 +3419,7 @@ __export(nip77_exports, {
|
|
|
3418
3419
|
NegentropyStorageVector: () => NegentropyStorageVector,
|
|
3419
3420
|
NegentropySync: () => NegentropySync
|
|
3420
3421
|
});
|
|
3421
|
-
var
|
|
3422
|
+
var import_utils20 = require("@noble/hashes/utils.js");
|
|
3422
3423
|
var import_sha25 = require("@noble/hashes/sha2.js");
|
|
3423
3424
|
var PROTOCOL_VERSION = 97;
|
|
3424
3425
|
var ID_SIZE = 32;
|
|
@@ -3564,7 +3565,7 @@ var NegentropyStorageVector = class {
|
|
|
3564
3565
|
insert(timestamp, id) {
|
|
3565
3566
|
if (this.sealed)
|
|
3566
3567
|
throw Error("already sealed");
|
|
3567
|
-
const idb = (0,
|
|
3568
|
+
const idb = (0, import_utils20.hexToBytes)(id);
|
|
3568
3569
|
if (idb.byteLength !== ID_SIZE)
|
|
3569
3570
|
throw Error("bad id size for added item");
|
|
3570
3571
|
this.items.push({ timestamp, id: idb });
|
|
@@ -3658,10 +3659,10 @@ var Negentropy = class {
|
|
|
3658
3659
|
let output = new WrappedBuffer();
|
|
3659
3660
|
output.extend(new Uint8Array([PROTOCOL_VERSION]));
|
|
3660
3661
|
this.splitRange(0, this.storage.size(), this._bound(Number.MAX_VALUE), output);
|
|
3661
|
-
return (0,
|
|
3662
|
+
return (0, import_utils20.bytesToHex)(output.unwrap());
|
|
3662
3663
|
}
|
|
3663
3664
|
reconcile(queryMsg, onhave, onneed) {
|
|
3664
|
-
const query = new WrappedBuffer((0,
|
|
3665
|
+
const query = new WrappedBuffer((0, import_utils20.hexToBytes)(queryMsg));
|
|
3665
3666
|
this.lastTimestampIn = this.lastTimestampOut = 0;
|
|
3666
3667
|
let fullOutput = new WrappedBuffer();
|
|
3667
3668
|
fullOutput.extend(new Uint8Array([PROTOCOL_VERSION]));
|
|
@@ -3704,22 +3705,22 @@ var Negentropy = class {
|
|
|
3704
3705
|
let theirElems = {};
|
|
3705
3706
|
for (let i2 = 0; i2 < numIds; i2++) {
|
|
3706
3707
|
let e = getBytes(query, ID_SIZE);
|
|
3707
|
-
theirElems[(0,
|
|
3708
|
+
theirElems[(0, import_utils20.bytesToHex)(e)] = e;
|
|
3708
3709
|
}
|
|
3709
3710
|
skip = true;
|
|
3710
3711
|
this.storage.iterate(lower, upper, (item) => {
|
|
3711
3712
|
let k = item.id;
|
|
3712
|
-
const id = (0,
|
|
3713
|
+
const id = (0, import_utils20.bytesToHex)(k);
|
|
3713
3714
|
if (!theirElems[id]) {
|
|
3714
3715
|
onhave?.(id);
|
|
3715
3716
|
} else {
|
|
3716
|
-
delete theirElems[(0,
|
|
3717
|
+
delete theirElems[(0, import_utils20.bytesToHex)(k)];
|
|
3717
3718
|
}
|
|
3718
3719
|
return true;
|
|
3719
3720
|
});
|
|
3720
3721
|
if (onneed) {
|
|
3721
3722
|
for (let v of Object.values(theirElems)) {
|
|
3722
|
-
onneed((0,
|
|
3723
|
+
onneed((0, import_utils20.bytesToHex)(v));
|
|
3723
3724
|
}
|
|
3724
3725
|
}
|
|
3725
3726
|
} else {
|
|
@@ -3737,7 +3738,7 @@ var Negentropy = class {
|
|
|
3737
3738
|
prevIndex = upper;
|
|
3738
3739
|
prevBound = currBound;
|
|
3739
3740
|
}
|
|
3740
|
-
return fullOutput.length === 1 ? null : (0,
|
|
3741
|
+
return fullOutput.length === 1 ? null : (0, import_utils20.bytesToHex)(fullOutput.unwrap());
|
|
3741
3742
|
}
|
|
3742
3743
|
splitRange(lower, upper, upperBound, o) {
|
|
3743
3744
|
let numElems = upper - lower;
|
|
@@ -3926,7 +3927,7 @@ __export(nip98_exports, {
|
|
|
3926
3927
|
validateToken: () => validateToken
|
|
3927
3928
|
});
|
|
3928
3929
|
var import_sha26 = require("@noble/hashes/sha2.js");
|
|
3929
|
-
var
|
|
3930
|
+
var import_utils21 = require("@noble/hashes/utils.js");
|
|
3930
3931
|
var import_base5 = require("@scure/base");
|
|
3931
3932
|
var _authorizationScheme = "Nostr ";
|
|
3932
3933
|
async function getToken(loginUrl, httpMethod, sign, includeAuthorizationScheme = false, payload) {
|
|
@@ -3992,7 +3993,7 @@ function validateEventMethodTag(event, method) {
|
|
|
3992
3993
|
}
|
|
3993
3994
|
function hashPayload(payload) {
|
|
3994
3995
|
const hash = (0, import_sha26.sha256)(utf8Encoder.encode(JSON.stringify(payload)));
|
|
3995
|
-
return (0,
|
|
3996
|
+
return (0, import_utils21.bytesToHex)(hash);
|
|
3996
3997
|
}
|
|
3997
3998
|
function validateEventPayloadTag(event, payload) {
|
|
3998
3999
|
const payloadTag = event.tags.find((t) => t[0] === "payload");
|