nostr-tools 2.23.7 → 2.23.8
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/index.js +16 -9
- package/lib/cjs/index.js.map +3 -3
- package/lib/cjs/nip10.js +5 -4
- package/lib/cjs/nip10.js.map +2 -2
- package/lib/cjs/nip22.js +11 -5
- package/lib/cjs/nip22.js.map +2 -2
- package/lib/cjs/nip46.js +7 -2
- package/lib/cjs/nip46.js.map +2 -2
- package/lib/esm/index.js +16 -9
- package/lib/esm/index.js.map +3 -3
- package/lib/esm/nip10.js +5 -4
- package/lib/esm/nip10.js.map +2 -2
- package/lib/esm/nip22.js +11 -5
- package/lib/esm/nip22.js.map +2 -2
- package/lib/esm/nip46.js +7 -2
- package/lib/esm/nip46.js.map +2 -2
- package/lib/nostr.bundle.js +16 -9
- package/lib/nostr.bundle.js.map +3 -3
- package/lib/types/nip46.d.ts +7 -5
- package/package.json +1 -1
package/lib/nostr.bundle.js
CHANGED
|
@@ -4877,6 +4877,7 @@ var NostrTools = (() => {
|
|
|
4877
4877
|
__export(nip10_exports, {
|
|
4878
4878
|
parse: () => parse
|
|
4879
4879
|
});
|
|
4880
|
+
var HEX64 = /^[0-9a-fA-F]{64}$/;
|
|
4880
4881
|
function parse(event) {
|
|
4881
4882
|
const result = {
|
|
4882
4883
|
reply: void 0,
|
|
@@ -4889,12 +4890,12 @@ var NostrTools = (() => {
|
|
|
4889
4890
|
let maybeRoot;
|
|
4890
4891
|
for (let i2 = event.tags.length - 1; i2 >= 0; i2--) {
|
|
4891
4892
|
const tag = event.tags[i2];
|
|
4892
|
-
if (tag[0] === "e" && tag[1]) {
|
|
4893
|
+
if (tag[0] === "e" && tag[1] && HEX64.test(tag[1])) {
|
|
4893
4894
|
const [_, eTagEventId, eTagRelayUrl, eTagMarker, eTagAuthor] = tag;
|
|
4894
4895
|
const eventPointer = {
|
|
4895
4896
|
id: eTagEventId,
|
|
4896
4897
|
relays: eTagRelayUrl ? [eTagRelayUrl] : [],
|
|
4897
|
-
author: eTagAuthor
|
|
4898
|
+
author: eTagAuthor && HEX64.test(eTagAuthor) ? eTagAuthor : void 0
|
|
4898
4899
|
};
|
|
4899
4900
|
if (eTagMarker === "root") {
|
|
4900
4901
|
result.root = eventPointer;
|
|
@@ -4916,14 +4917,14 @@ var NostrTools = (() => {
|
|
|
4916
4917
|
result.mentions.push(eventPointer);
|
|
4917
4918
|
continue;
|
|
4918
4919
|
}
|
|
4919
|
-
if (tag[0] === "q" && tag[1]) {
|
|
4920
|
+
if (tag[0] === "q" && tag[1] && HEX64.test(tag[1])) {
|
|
4920
4921
|
const [_, eTagEventId, eTagRelayUrl] = tag;
|
|
4921
4922
|
result.quotes.push({
|
|
4922
4923
|
id: eTagEventId,
|
|
4923
4924
|
relays: eTagRelayUrl ? [eTagRelayUrl] : []
|
|
4924
4925
|
});
|
|
4925
4926
|
}
|
|
4926
|
-
if (tag[0] === "p" && tag[1]) {
|
|
4927
|
+
if (tag[0] === "p" && tag[1] && HEX64.test(tag[1])) {
|
|
4927
4928
|
result.profiles.push({
|
|
4928
4929
|
pubkey: tag[1],
|
|
4929
4930
|
relays: tag[2] ? [tag[2]] : []
|
|
@@ -6043,6 +6044,7 @@ var NostrTools = (() => {
|
|
|
6043
6044
|
__export(nip22_exports, {
|
|
6044
6045
|
parse: () => parse3
|
|
6045
6046
|
});
|
|
6047
|
+
var HEX642 = /^[0-9a-fA-F]{64}$/;
|
|
6046
6048
|
function parseKind(kind) {
|
|
6047
6049
|
if (!kind)
|
|
6048
6050
|
return void 0;
|
|
@@ -6056,9 +6058,12 @@ var NostrTools = (() => {
|
|
|
6056
6058
|
const kind = parseInt(value.slice(0, idx), 10);
|
|
6057
6059
|
if (Number.isNaN(kind))
|
|
6058
6060
|
return void 0;
|
|
6061
|
+
const pubkey = value.slice(idx + 1, idx2);
|
|
6062
|
+
if (!HEX642.test(pubkey))
|
|
6063
|
+
return void 0;
|
|
6059
6064
|
return {
|
|
6060
6065
|
kind,
|
|
6061
|
-
pubkey
|
|
6066
|
+
pubkey,
|
|
6062
6067
|
identifier: value.slice(idx2 + 1),
|
|
6063
6068
|
relays: relayUrl ? [relayUrl] : []
|
|
6064
6069
|
};
|
|
@@ -6067,12 +6072,12 @@ var NostrTools = (() => {
|
|
|
6067
6072
|
switch (tag[0]) {
|
|
6068
6073
|
case "E":
|
|
6069
6074
|
case "e":
|
|
6070
|
-
if (!tag[1])
|
|
6075
|
+
if (!tag[1] || !HEX642.test(tag[1]))
|
|
6071
6076
|
return void 0;
|
|
6072
6077
|
return {
|
|
6073
6078
|
id: tag[1],
|
|
6074
6079
|
relays: tag[2] ? [tag[2]] : [],
|
|
6075
|
-
author: tag[3]
|
|
6080
|
+
author: tag[3] && HEX642.test(tag[3]) ? tag[3] : void 0
|
|
6076
6081
|
};
|
|
6077
6082
|
case "A":
|
|
6078
6083
|
case "a":
|
|
@@ -6095,10 +6100,12 @@ var NostrTools = (() => {
|
|
|
6095
6100
|
if (tag[1].includes(":")) {
|
|
6096
6101
|
return parseAddressPointer(tag[1], tag[2]);
|
|
6097
6102
|
}
|
|
6103
|
+
if (!HEX642.test(tag[1]))
|
|
6104
|
+
return void 0;
|
|
6098
6105
|
return {
|
|
6099
6106
|
id: tag[1],
|
|
6100
6107
|
relays: tag[2] ? [tag[2]] : [],
|
|
6101
|
-
author: tag[3]
|
|
6108
|
+
author: tag[3] && HEX642.test(tag[3]) ? tag[3] : void 0
|
|
6102
6109
|
};
|
|
6103
6110
|
}
|
|
6104
6111
|
function choosePointer(candidates) {
|
|
@@ -6158,7 +6165,7 @@ var NostrTools = (() => {
|
|
|
6158
6165
|
result.quotes.push(pointer);
|
|
6159
6166
|
continue;
|
|
6160
6167
|
}
|
|
6161
|
-
if ((tag[0] === "P" || tag[0] === "p") && tag[1]) {
|
|
6168
|
+
if ((tag[0] === "P" || tag[0] === "p") && tag[1] && HEX642.test(tag[1])) {
|
|
6162
6169
|
result.profiles.push({
|
|
6163
6170
|
pubkey: tag[1],
|
|
6164
6171
|
relays: tag[2] ? [tag[2]] : []
|