@qntx/nostr 0.10.1 → 0.11.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/{builder-CVRmUeNm.mjs → builder-BQbFDO6S.mjs} +22 -5
- package/dist/builder-BQbFDO6S.mjs.map +1 -0
- package/dist/{client-CeyDLoyO.mjs → client-CTmp5w84.mjs} +14 -14
- package/dist/{client-CeyDLoyO.mjs.map → client-CTmp5w84.mjs.map} +1 -1
- package/dist/client.d.mts +1 -1
- package/dist/client.mjs +1 -1
- package/dist/core.d.mts +2 -2
- package/dist/core.mjs +7 -7
- package/dist/{error-BILMe3Gr.mjs → error-DH4guike.mjs} +2 -2
- package/dist/{error-BILMe3Gr.mjs.map → error-DH4guike.mjs.map} +1 -1
- package/dist/{error-DlhGW4mJ.mjs → error-UHkqzWL7.mjs} +2 -2
- package/dist/{error-DlhGW4mJ.mjs.map → error-UHkqzWL7.mjs.map} +1 -1
- package/dist/{event-C2eLiPpV.mjs → event-B3ua2_oL.mjs} +24 -11
- package/dist/event-B3ua2_oL.mjs.map +1 -0
- package/dist/{filter-TrF2LEoy.mjs → filter-B16P33dz.mjs} +31 -10
- package/dist/filter-B16P33dz.mjs.map +1 -0
- package/dist/{filter-CfEgQBXt.d.mts → filter-PG7r79rt.d.mts} +6 -2
- package/dist/{gossip-BWb9HmfK.d.mts → gossip-BTMdlUI7.d.mts} +2 -2
- package/dist/{gossip-5ezg0Quo.mjs → gossip-K_JIexQs.mjs} +3 -3
- package/dist/{gossip-5ezg0Quo.mjs.map → gossip-K_JIexQs.mjs.map} +1 -1
- package/dist/gossip.d.mts +1 -1
- package/dist/gossip.mjs +1 -1
- package/dist/{index-B1fLejg4.d.mts → index-BP94lABY.d.mts} +5 -5
- package/dist/{index-uCYwXaaP.d.mts → index-CSsnE32i.d.mts} +7 -7
- package/dist/{index-CLJEKFGd.d.mts → index-DD0Ywpay.d.mts} +3 -3
- package/dist/{index-C0mFpelb.d.mts → index-N7HUGgwo.d.mts} +2 -2
- package/dist/{index-CoX7SnO7.d.mts → index-rKcmI6ex.d.mts} +3 -3
- package/dist/index.d.mts +11 -11
- package/dist/index.mjs +18 -18
- package/dist/{key-DY_HEIpY.mjs → key-k8LDEPZh.mjs} +3 -3
- package/dist/{key-DY_HEIpY.mjs.map → key-k8LDEPZh.mjs.map} +1 -1
- package/dist/{loaders-DifimjJ7.mjs → loaders-Dp2nXEFk.mjs} +6 -6
- package/dist/{loaders-DifimjJ7.mjs.map → loaders-Dp2nXEFk.mjs.map} +1 -1
- package/dist/loaders.d.mts +2 -2
- package/dist/loaders.mjs +1 -1
- package/dist/{memory-DENGQ_f6.mjs → memory-VyPnOBU3.mjs} +2 -2
- package/dist/{memory-DENGQ_f6.mjs.map → memory-VyPnOBU3.mjs.map} +1 -1
- package/dist/{memory-index-D_lvlYAy.mjs → memory-index-Bhwe0ZdG.mjs} +4 -4
- package/dist/{memory-index-D_lvlYAy.mjs.map → memory-index-Bhwe0ZdG.mjs.map} +1 -1
- package/dist/{message-Rd5Z_17h.mjs → message-pYfVKxPn.mjs} +74 -29
- package/dist/message-pYfVKxPn.mjs.map +1 -0
- package/dist/nips/blossom.mjs +2 -2
- package/dist/nips/nip04.mjs +1 -1
- package/dist/nips/nip05.mjs +1 -1
- package/dist/nips/nip10.mjs +3 -3
- package/dist/nips/nip11.mjs +1 -1
- package/dist/nips/nip13.mjs +1 -1
- package/dist/nips/nip17.mjs +3 -3
- package/dist/nips/nip19.mjs +11 -4
- package/dist/nips/nip19.mjs.map +1 -1
- package/dist/nips/nip21.mjs +1 -1
- package/dist/nips/nip42.mjs +1 -1
- package/dist/nips/nip44.mjs +1 -1
- package/dist/nips/nip46.mjs +1 -1
- package/dist/nips/nip49.mjs +1 -1
- package/dist/nips/nip51.mjs +3 -3
- package/dist/nips/nip57.mjs +3 -3
- package/dist/nips/nip59.mjs +4 -4
- package/dist/nips/nip65.mjs +2 -2
- package/dist/nips/nip77.mjs +1 -1
- package/dist/nips/nip98.mjs +3 -3
- package/dist/{pool-jok2-iBJ.mjs → pool-BMUsw2un.mjs} +5 -5
- package/dist/{pool-jok2-iBJ.mjs.map → pool-BMUsw2un.mjs.map} +1 -1
- package/dist/{pool-Bfe3Tu40.d.mts → pool-DUuYJ0x4.d.mts} +3 -3
- package/dist/{put-JsiCKMyZ.mjs → put-DRmV1wHD.mjs} +3 -3
- package/dist/{put-JsiCKMyZ.mjs.map → put-DRmV1wHD.mjs.map} +1 -1
- package/dist/{reactive-6Wn9qf_d.mjs → reactive--pDpLt2H.mjs} +5 -5
- package/dist/{reactive-6Wn9qf_d.mjs.map → reactive--pDpLt2H.mjs.map} +1 -1
- package/dist/{reactive-X4p6nABy.d.mts → reactive-jyKrA9ej.d.mts} +3 -3
- package/dist/{relay-__QtO33h.mjs → relay-DXtwUEdX.mjs} +6 -6
- package/dist/{relay-__QtO33h.mjs.map → relay-DXtwUEdX.mjs.map} +1 -1
- package/dist/relay.d.mts +3 -3
- package/dist/relay.mjs +2 -2
- package/dist/{signer-D7PtVvQn.mjs → signer-CWtxpOxc.mjs} +5 -5
- package/dist/{signer-D7PtVvQn.mjs.map → signer-CWtxpOxc.mjs.map} +1 -1
- package/dist/signer.d.mts +1 -1
- package/dist/signer.mjs +2 -2
- package/dist/{storage-oihjE0_x.mjs → storage-B5Wdt_Mn.mjs} +12 -29
- package/dist/storage-B5Wdt_Mn.mjs.map +1 -0
- package/dist/storage.d.mts +2 -2
- package/dist/storage.mjs +4 -4
- package/dist/store.d.mts +1 -1
- package/dist/store.mjs +1 -1
- package/dist/testing.d.mts +1 -1
- package/dist/testing.mjs +18 -7
- package/dist/testing.mjs.map +1 -1
- package/dist/{types-Ccox7-5v.d.mts → types-CqhnT-Mx.d.mts} +2 -2
- package/dist/{util-DMF9AIO0.mjs → util-DDpPkiED.mjs} +14 -2
- package/dist/util-DDpPkiED.mjs.map +1 -0
- package/dist/{verifier-uC_jd-Nw.mjs → verifier-CjH1vnP2.mjs} +3 -3
- package/dist/{verifier-uC_jd-Nw.mjs.map → verifier-CjH1vnP2.mjs.map} +1 -1
- package/dist/{verifier-9c-bINrv.d.mts → verifier-Cl24c9ph.d.mts} +3 -3
- package/package.json +1 -1
- package/dist/builder-CVRmUeNm.mjs.map +0 -1
- package/dist/event-C2eLiPpV.mjs.map +0 -1
- package/dist/filter-TrF2LEoy.mjs.map +0 -1
- package/dist/message-Rd5Z_17h.mjs.map +0 -1
- package/dist/storage-oihjE0_x.mjs.map +0 -1
- package/dist/util-DMF9AIO0.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as
|
|
1
|
+
import { a as hasLoneSurrogate, c as isHex64, g as EventValidationError, i as bytesToHex, l as isRecord, m as utf8Encoder, s as isHex32 } from "./util-DDpPkiED.mjs";
|
|
2
2
|
import { o as isReplaceableKind, r as isAddressableKind } from "./kind-D8fENiiL.mjs";
|
|
3
3
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
4
4
|
//#region src/core/tag.ts
|
|
@@ -16,19 +16,29 @@ function tagName(tag) {
|
|
|
16
16
|
function tagValue(tag) {
|
|
17
17
|
return tag[1];
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Push positional tag values: "" for absent slots before a present one, trailing absent slots
|
|
21
|
+
* omitted.
|
|
22
|
+
*/
|
|
23
|
+
function pushPositions(t, positions) {
|
|
24
|
+
let end = positions.length;
|
|
25
|
+
while (end > 0 && positions[end - 1] === void 0) end -= 1;
|
|
26
|
+
for (let i = 0; i < end; i += 1) t.push(positions[i] ?? "");
|
|
27
|
+
}
|
|
19
28
|
/** Construct common tags. */
|
|
20
29
|
const Tag = {
|
|
21
30
|
e(id, relay, marker, pubkey) {
|
|
22
31
|
const t = ["e", id.toLowerCase()];
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
pushPositions(t, [
|
|
33
|
+
relay,
|
|
34
|
+
marker,
|
|
35
|
+
pubkey?.toLowerCase()
|
|
36
|
+
]);
|
|
26
37
|
return t;
|
|
27
38
|
},
|
|
28
39
|
p(pubkey, relay, petname) {
|
|
29
40
|
const t = ["p", pubkey.toLowerCase()];
|
|
30
|
-
|
|
31
|
-
if (petname !== void 0) t.push(petname);
|
|
41
|
+
pushPositions(t, [relay, petname]);
|
|
32
42
|
return t;
|
|
33
43
|
},
|
|
34
44
|
a(coordinate, relay) {
|
|
@@ -112,12 +122,15 @@ function isMarkedFailed(event) {
|
|
|
112
122
|
/** Structural validation of an unsigned event (no crypto). */
|
|
113
123
|
function validateEvent(event) {
|
|
114
124
|
if (!isRecord(event)) return false;
|
|
115
|
-
if (typeof event["kind"] !== "number" || !Number.
|
|
116
|
-
if (typeof event["content"] !== "string") return false;
|
|
117
|
-
if (typeof event["created_at"] !== "number" || !Number.
|
|
125
|
+
if (typeof event["kind"] !== "number" || !Number.isSafeInteger(event["kind"]) || event["kind"] < 0 || event["kind"] > 65535) return false;
|
|
126
|
+
if (typeof event["content"] !== "string" || hasLoneSurrogate(event["content"])) return false;
|
|
127
|
+
if (typeof event["created_at"] !== "number" || !Number.isSafeInteger(event["created_at"]) || event["created_at"] < 0) return false;
|
|
118
128
|
if (typeof event["pubkey"] !== "string" || !isHex32(event["pubkey"])) return false;
|
|
119
129
|
if (!Array.isArray(event["tags"])) return false;
|
|
120
|
-
for (const tag of event["tags"])
|
|
130
|
+
for (const tag of event["tags"]) {
|
|
131
|
+
if (!isTag(tag)) return false;
|
|
132
|
+
for (const item of tag) if (hasLoneSurrogate(item)) return false;
|
|
133
|
+
}
|
|
121
134
|
return true;
|
|
122
135
|
}
|
|
123
136
|
/** Structural validation of a full event including id and sig hex shape. */
|
|
@@ -209,4 +222,4 @@ function signedMatchesUnsigned(signed, unsigned) {
|
|
|
209
222
|
//#endregion
|
|
210
223
|
export { tagName as C, parseEventAddress as S, eventAddress as _, isReplaceableWinner as a, getDTag as b, markVerified as c, signedMatchesUnsigned as d, sortEvents as f, Tag as g, validateSignedEvent as h, isMarkedVerified as i, serializeEvent as l, validateEvent as m, getEventHash as n, itemCompare as o, sortedEvents as p, isMarkedFailed as r, markUnverified as s, compareEventsDesc as t, serializeValidatedEvent as u, firstTagValue as v, tagValue as w, isTag as x, formatEventAddress as y };
|
|
211
224
|
|
|
212
|
-
//# sourceMappingURL=event-
|
|
225
|
+
//# sourceMappingURL=event-B3ua2_oL.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-B3ua2_oL.mjs","names":[],"sources":["../src/core/tag.ts","../src/core/event.ts"],"sourcesContent":["import { isAddressableKind, isReplaceableKind } from \"./kind.ts\";\nimport { isHex32 } from \"./util.ts\";\n\n/** A NIP-01 tag: first element is the name, rest are values. */\nexport type Tag = ReadonlyArray<string>;\n\n/** Mutable tag builder input. */\nexport type TagInput = string[];\n\n/** Type guard: a non-empty array of strings. */\nexport function isTag(value: unknown): value is Tag {\n if (!Array.isArray(value) || value.length === 0) {\n return false;\n }\n for (const item of value) {\n if (typeof item !== \"string\") {\n return false;\n }\n }\n return true;\n}\n\n/** First element of a tag (its name). */\nexport function tagName(tag: Tag): string {\n return tag[0] ?? \"\";\n}\n\n/** Second element of a tag (its primary value), or undefined for a bare name tag. */\nexport function tagValue(tag: Tag): string | undefined {\n return tag[1];\n}\n\n/**\n * Push positional tag values: \"\" for absent slots before a present one, trailing absent slots\n * omitted.\n */\nfunction pushPositions(t: string[], positions: Array<string | undefined>): void {\n let end = positions.length;\n while (end > 0 && positions[end - 1] === undefined) {\n end -= 1;\n }\n for (let i = 0; i < end; i += 1) {\n t.push(positions[i] ?? \"\");\n }\n}\n\n/** Construct common tags. */\nexport const Tag = {\n e(id: string, relay?: string, marker?: string, pubkey?: string): Tag {\n const t: string[] = [\"e\", id.toLowerCase()];\n pushPositions(t, [relay, marker, pubkey?.toLowerCase()]);\n return t;\n },\n p(pubkey: string, relay?: string, petname?: string): Tag {\n const t: string[] = [\"p\", pubkey.toLowerCase()];\n pushPositions(t, [relay, petname]);\n return t;\n },\n a(coordinate: string, relay?: string): Tag {\n const t: string[] = [\"a\", coordinate];\n if (relay !== undefined) {\n t.push(relay);\n }\n return t;\n },\n d(identifier: string): Tag {\n return [\"d\", identifier];\n },\n t(hashtag: string): Tag {\n return [\"t\", hashtag];\n },\n r(url: string, marker?: string): Tag {\n const t: string[] = [\"r\", url];\n if (marker !== undefined) {\n t.push(marker);\n }\n return t;\n },\n k(kind: number | string): Tag {\n return [\"k\", String(kind)];\n },\n} as const;\n\n/** First tag value with the given name, or undefined when no such tag has a value. */\nexport function firstTagValue(tags: ReadonlyArray<Tag>, name: string): string | undefined {\n for (const tag of tags) {\n if (tag[0] === name && tag[1] !== undefined) {\n return tag[1];\n }\n }\n return undefined;\n}\n\n/** First `d` tag value on an event, if any. */\nexport function getDTag(tags: ReadonlyArray<Tag>): string | undefined {\n return firstTagValue(tags, \"d\");\n}\n\n/** NIP-01 `a` tag: `kind:pubkey:identifier` (identifier may be empty and may contain extra colons). */\nexport type EventAddress = {\n kind: number;\n pubkey: string;\n identifier: string;\n};\n\n/** Parse a NIP-01 addressable/replaceable coordinate. */\nexport function parseEventAddress(value: string): EventAddress | undefined {\n const first = value.indexOf(\":\");\n if (first <= 0) {\n return undefined;\n }\n const second = value.indexOf(\":\", first + 1);\n if (second === -1) {\n return undefined;\n }\n const kindText = value.slice(0, first);\n // Strict decimal: Number() also accepts \"1e4\", \"0x10\", \" 1\", \"+1\" — none are NIP-19 kinds.\n if (!/^\\d{1,5}$/.test(kindText)) {\n return undefined;\n }\n const kind = Number(kindText);\n if (kind > 65535) {\n return undefined;\n }\n const pubkey = value.slice(first + 1, second).toLowerCase();\n if (!isHex32(pubkey)) {\n return undefined;\n }\n return { kind, pubkey, identifier: value.slice(second + 1) };\n}\n\n/** Format an address as a `kind:pubkey:dTag` coordinate string. */\nexport function formatEventAddress(kind: number, pubkey: string, identifier = \"\"): string {\n return `${kind}:${pubkey.toLowerCase()}:${identifier}`;\n}\n\n/**\n * Coordinate for replaceable (`kind:pubkey:`) and addressable (`kind:pubkey:d`) events. Undefined\n * for regular/ephemeral kinds.\n */\nexport function eventAddress(event: {\n kind: number;\n pubkey: string;\n tags: ReadonlyArray<Tag>;\n}): string | undefined {\n if (isAddressableKind(event.kind)) {\n return formatEventAddress(event.kind, event.pubkey, getDTag(event.tags) ?? \"\");\n }\n if (isReplaceableKind(event.kind)) {\n return formatEventAddress(event.kind, event.pubkey, \"\");\n }\n return undefined;\n}\n","import { sha256 } from \"@noble/hashes/sha2.js\";\n\nimport { EventValidationError } from \"./error.ts\";\nimport type { Tag } from \"./tag.ts\";\nimport { isTag } from \"./tag.ts\";\nimport { bytesToHex, hasLoneSurrogate, isHex32, isHex64, isRecord, utf8Encoder } from \"./util.ts\";\n\n/** Wire event template before pubkey/id/sig. */\nexport type EventTemplate = {\n readonly kind: number;\n readonly tags: ReadonlyArray<Tag>;\n readonly content: string;\n readonly created_at: number;\n};\n\n/** Event with pubkey, ready to hash and sign. */\nexport type UnsignedEvent = EventTemplate & {\n readonly pubkey: string;\n};\n\n/**\n * Fully formed NIP-01 event (JSON-friendly plain object). Fields are readonly at the type level;\n * wire interop remains plain JSON.\n */\nexport type Event = UnsignedEvent & {\n readonly id: string;\n readonly sig: string;\n};\n\n/** Cache of events whose signatures have been verified successfully. */\nconst verifiedEvents = new WeakSet<Event>();\n\n/** Cache of events known to fail verification. */\nconst failedEvents = new WeakSet<Event>();\n\nexport function markVerified(event: Event): void {\n verifiedEvents.add(event);\n failedEvents.delete(event);\n}\n\nexport function markUnverified(event: Event): void {\n failedEvents.add(event);\n verifiedEvents.delete(event);\n}\n\nexport function isMarkedVerified(event: Event): boolean {\n return verifiedEvents.has(event);\n}\n\nexport function isMarkedFailed(event: Event): boolean {\n return failedEvents.has(event);\n}\n\n/** Structural validation of an unsigned event (no crypto). */\nexport function validateEvent(event: unknown): event is UnsignedEvent {\n if (!isRecord(event)) {\n return false;\n }\n if (\n typeof event[\"kind\"] !== \"number\" ||\n !Number.isSafeInteger(event[\"kind\"]) ||\n event[\"kind\"] < 0 ||\n event[\"kind\"] > 65535\n ) {\n return false;\n }\n // Lone surrogates are rejected per NIP-01: after JSON.parse they differ from\n // what serde_json (and thus Rust) can express, so the event id would diverge.\n if (typeof event[\"content\"] !== \"string\" || hasLoneSurrogate(event[\"content\"])) {\n return false;\n }\n if (\n typeof event[\"created_at\"] !== \"number\" ||\n !Number.isSafeInteger(event[\"created_at\"]) ||\n event[\"created_at\"] < 0\n ) {\n return false;\n }\n if (typeof event[\"pubkey\"] !== \"string\" || !isHex32(event[\"pubkey\"])) {\n return false;\n }\n if (!Array.isArray(event[\"tags\"])) {\n return false;\n }\n for (const tag of event[\"tags\"]) {\n if (!isTag(tag)) {\n return false;\n }\n for (const item of tag) {\n if (hasLoneSurrogate(item)) {\n return false;\n }\n }\n }\n return true;\n}\n\n/** Structural validation of a full event including id and sig hex shape. */\nexport function validateSignedEvent(event: unknown): event is Event {\n if (!validateEvent(event)) {\n return false;\n }\n const e = event as Record<string, unknown>;\n if (typeof e[\"id\"] !== \"string\" || !isHex32(e[\"id\"])) {\n return false;\n }\n if (typeof e[\"sig\"] !== \"string\" || !isHex64(e[\"sig\"])) {\n return false;\n }\n return true;\n}\n\n/**\n * Canonical NIP-01 serialization used for hashing: JSON array `[0, pubkey, created_at, kind, tags,\n * content]` with no extra whitespace.\n */\nexport function serializeEvent(event: UnsignedEvent): string {\n if (!validateEvent(event)) {\n throw new EventValidationError(\"cannot serialize event with invalid shape\");\n }\n return serializeValidatedEvent(event);\n}\n\n/**\n * Canonical serialization for an event already known valid (after {@link validateEvent} or\n * {@link validateSignedEvent}); identical output to {@link serializeEvent} without re-walking the\n * structural checks.\n */\nexport function serializeValidatedEvent(event: UnsignedEvent): string {\n return JSON.stringify([0, event.pubkey, event.created_at, event.kind, event.tags, event.content]);\n}\n\n/** SHA-256 of the canonical serialization, lowercase hex. */\nexport function getEventHash(event: UnsignedEvent): string {\n const serialized = serializeEvent(event);\n return bytesToHex(sha256(utf8Encoder.encode(serialized)));\n}\n\n/** Id tie-break: plain code-unit order (ids are canonical lowercase hex, so `<` is lexical). */\nfunction compareIds(a: { id: string }, b: { id: string }): number {\n if (a.id < b.id) {\n return -1;\n }\n if (a.id > b.id) {\n return 1;\n }\n return 0;\n}\n\n/**\n * NIP-01 newest-first order: `created_at` descending, then `id` in plain code-unit order (ids are\n * canonical lowercase hex, so `<` is lexical order).\n */\nexport function compareEventsDesc(\n a: { id: string; created_at: number },\n b: { id: string; created_at: number },\n): number {\n if (a.created_at !== b.created_at) {\n return b.created_at - a.created_at;\n }\n return compareIds(a, b);\n}\n\n/**\n * Sort events reverse-chronologically by `created_at`, then by `id` lexicographically. Mutates and\n * returns the array.\n */\nexport function sortEvents(events: Event[]): Event[] {\n return events.sort(compareEventsDesc);\n}\n\n/** Non-mutating sort; returns a new array. */\nexport function sortedEvents(events: ReadonlyArray<Event>): Event[] {\n return [...events].sort(compareEventsDesc);\n}\n\n/**\n * Negentropy item order: `created_at` ascending, then `id` lexicographic (`<`/`>`). Time axis is\n * opposite {@link sortEvents}; id tie-break is the same direction.\n */\nexport function itemCompare(\n a: { id: string; created_at: number },\n b: { id: string; created_at: number },\n): number {\n if (a.created_at !== b.created_at) {\n return a.created_at - b.created_at;\n }\n return compareIds(a, b);\n}\n\n/**\n * NIP-01 replaceable/addressable winner: higher `created_at`, or equal timestamp and\n * lexicographically lower `id`.\n */\nexport function isReplaceableWinner(\n candidate: { created_at: number; id: string },\n incumbent: { created_at: number; id: string },\n): boolean {\n if (candidate.created_at !== incumbent.created_at) {\n return candidate.created_at > incumbent.created_at;\n }\n return candidate.id < incumbent.id;\n}\n\n/** True when a signed event is the signed form of `unsigned` (kind/tags/content/time/pubkey). */\nexport function signedMatchesUnsigned(signed: Event, unsigned: UnsignedEvent): boolean {\n if (signed.kind !== unsigned.kind) {\n return false;\n }\n if (signed.content !== unsigned.content) {\n return false;\n }\n if (signed.created_at !== unsigned.created_at) {\n return false;\n }\n if (JSON.stringify(signed.tags) !== JSON.stringify(unsigned.tags)) {\n return false;\n }\n if (unsigned.pubkey && signed.pubkey.toLowerCase() !== unsigned.pubkey.toLowerCase()) {\n return false;\n }\n return true;\n}\n"],"mappings":";;;;;AAUA,SAAgB,MAAM,OAA8B;CAClD,IAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW,GAC5C,OAAO;CAET,KAAK,MAAM,QAAQ,OACjB,IAAI,OAAO,SAAS,UAClB,OAAO;CAGX,OAAO;AACT;;AAGA,SAAgB,QAAQ,KAAkB;CACxC,OAAO,IAAI,MAAM;AACnB;;AAGA,SAAgB,SAAS,KAA8B;CACrD,OAAO,IAAI;AACb;;;;;AAMA,SAAS,cAAc,GAAa,WAA4C;CAC9E,IAAI,MAAM,UAAU;CACpB,OAAO,MAAM,KAAK,UAAU,MAAM,OAAO,KAAA,GACvC,OAAO;CAET,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,KAAK,GAC5B,EAAE,KAAK,UAAU,MAAM,EAAE;AAE7B;;AAGA,MAAa,MAAM;CACjB,EAAE,IAAY,OAAgB,QAAiB,QAAsB;EACnE,MAAM,IAAc,CAAC,KAAK,GAAG,YAAY,CAAC;EAC1C,cAAc,GAAG;GAAC;GAAO;GAAQ,QAAQ,YAAY;EAAC,CAAC;EACvD,OAAO;CACT;CACA,EAAE,QAAgB,OAAgB,SAAuB;EACvD,MAAM,IAAc,CAAC,KAAK,OAAO,YAAY,CAAC;EAC9C,cAAc,GAAG,CAAC,OAAO,OAAO,CAAC;EACjC,OAAO;CACT;CACA,EAAE,YAAoB,OAAqB;EACzC,MAAM,IAAc,CAAC,KAAK,UAAU;EACpC,IAAI,UAAU,KAAA,GACZ,EAAE,KAAK,KAAK;EAEd,OAAO;CACT;CACA,EAAE,YAAyB;EACzB,OAAO,CAAC,KAAK,UAAU;CACzB;CACA,EAAE,SAAsB;EACtB,OAAO,CAAC,KAAK,OAAO;CACtB;CACA,EAAE,KAAa,QAAsB;EACnC,MAAM,IAAc,CAAC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,UAAU,OAAO,IAAI,MAAM,KAAK,UAAU,SAAS,IAAI,GAC9D,OAAO;CAET,IAAI,SAAS,UAAU,OAAO,OAAO,YAAY,MAAM,SAAS,OAAO,YAAY,GACjF,OAAO;CAET,OAAO;AACT"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { o as isReplaceableKind, r as isAddressableKind } from "./kind-D8fENiiL.mjs";
|
|
2
2
|
//#region src/core/filter.ts
|
|
3
|
+
/** NIP-01 only defines single-letter tag conditions. */
|
|
4
|
+
const SINGLE_LETTER_TAG = /^#[a-zA-Z]$/;
|
|
3
5
|
/** Local NIP-01 match. `search` is ignored; relays interpret NIP-50. */
|
|
4
6
|
function matchFilter(filter, event) {
|
|
5
7
|
if (filter.ids && !filter.ids.some((id) => id.toLowerCase() === event.id)) return false;
|
|
6
8
|
if (filter.kinds && !filter.kinds.includes(event.kind)) return false;
|
|
7
9
|
if (filter.authors && !filter.authors.some((pk) => pk.toLowerCase() === event.pubkey)) return false;
|
|
8
10
|
for (const key of Object.keys(filter)) {
|
|
9
|
-
if (!
|
|
11
|
+
if (!SINGLE_LETTER_TAG.test(key)) continue;
|
|
10
12
|
const tagName = key.slice(1);
|
|
11
13
|
const values = filter[`#${tagName}`];
|
|
12
14
|
if (!values) continue;
|
|
@@ -36,13 +38,15 @@ function getFilterLimit(filter) {
|
|
|
36
38
|
if (filter.kinds && filter.kinds.length === 0) return 0;
|
|
37
39
|
if (filter.authors && filter.authors.length === 0) return 0;
|
|
38
40
|
let limit = Number.POSITIVE_INFINITY;
|
|
39
|
-
if (filter.ids) limit = Math.min(limit, filter.ids.
|
|
41
|
+
if (filter.ids) limit = Math.min(limit, new Set(filter.ids.map((id) => id.toLowerCase())).size);
|
|
40
42
|
if (filter.limit !== void 0) limit = Math.min(limit, filter.limit);
|
|
41
43
|
if (filter.kinds && filter.authors) {
|
|
42
|
-
|
|
44
|
+
const kinds = new Set(filter.kinds);
|
|
45
|
+
if ([...kinds].every((k) => isReplaceableKind(k) || isAddressableKind(k))) {
|
|
43
46
|
const dTags = filter["#d"];
|
|
44
|
-
const perAuthor = dTags && dTags.length > 0 ? dTags.
|
|
45
|
-
|
|
47
|
+
const perAuthor = dTags && dTags.length > 0 ? new Set(dTags).size : 1;
|
|
48
|
+
const authors = new Set(filter.authors.map((pk) => pk.toLowerCase())).size;
|
|
49
|
+
limit = Math.min(limit, authors * kinds.size * perAuthor);
|
|
46
50
|
}
|
|
47
51
|
}
|
|
48
52
|
return limit;
|
|
@@ -53,17 +57,34 @@ const HEX_LIST_KEYS = /* @__PURE__ */ new Set([
|
|
|
53
57
|
"#e",
|
|
54
58
|
"#p"
|
|
55
59
|
]);
|
|
56
|
-
/**
|
|
60
|
+
/** NIP-01 known fields; everything else (incl. multi-letter `#` keys) is dropped. */
|
|
61
|
+
const KNOWN_FILTER_KEYS = /* @__PURE__ */ new Set([
|
|
62
|
+
"ids",
|
|
63
|
+
"authors",
|
|
64
|
+
"kinds",
|
|
65
|
+
"since",
|
|
66
|
+
"until",
|
|
67
|
+
"limit",
|
|
68
|
+
"search"
|
|
69
|
+
]);
|
|
70
|
+
/**
|
|
71
|
+
* Lowercase hex lists, sort and dedupe every array, and keep only the NIP-01 known fields plus
|
|
72
|
+
* single-letter `#` keys — unknown keys and multi-letter `#` keys are dropped. Omits undefined so
|
|
73
|
+
* `[]` stays distinct from missing.
|
|
74
|
+
*/
|
|
57
75
|
function canonicalizeFilter(filter) {
|
|
58
76
|
const raw = filter;
|
|
59
77
|
const out = {};
|
|
60
78
|
for (const key of Object.keys(raw).sort()) {
|
|
79
|
+
if (key.startsWith("#")) {
|
|
80
|
+
if (!SINGLE_LETTER_TAG.test(key)) continue;
|
|
81
|
+
} else if (!KNOWN_FILTER_KEYS.has(key)) continue;
|
|
61
82
|
const value = raw[key];
|
|
62
83
|
if (value === void 0) continue;
|
|
63
84
|
if (Array.isArray(value)) {
|
|
64
|
-
if (HEX_LIST_KEYS.has(key)) out[key] = value.map((v) => String(v).toLowerCase()).sort();
|
|
65
|
-
else if (key === "kinds") out[key] = value.map(Number).sort((a, b) => a - b);
|
|
66
|
-
else out[key] = value.map(String).sort();
|
|
85
|
+
if (HEX_LIST_KEYS.has(key)) out[key] = [...new Set(value.map((v) => String(v).toLowerCase()))].sort();
|
|
86
|
+
else if (key === "kinds") out[key] = [...new Set(value.map(Number))].sort((a, b) => a - b);
|
|
87
|
+
else out[key] = [...new Set(value.map(String))].sort();
|
|
67
88
|
} else out[key] = value;
|
|
68
89
|
}
|
|
69
90
|
return out;
|
|
@@ -84,4 +105,4 @@ function filterFingerprint(filters) {
|
|
|
84
105
|
//#endregion
|
|
85
106
|
export { matchFilter as a, getFilterLimit as i, canonicalizeFilters as n, matchFilters as o, filterFingerprint as r, canonicalizeFilter as t };
|
|
86
107
|
|
|
87
|
-
//# sourceMappingURL=filter-
|
|
108
|
+
//# sourceMappingURL=filter-B16P33dz.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-B16P33dz.mjs","names":[],"sources":["../src/core/filter.ts"],"sourcesContent":["import type { Event } from \"./event.ts\";\nimport { isAddressableKind, isReplaceableKind } from \"./kind.ts\";\n\n/** NIP-01 filter object (immutable-friendly; callers may still pass plain objects). */\nexport type Filter = {\n readonly ids?: ReadonlyArray<string> | undefined;\n readonly kinds?: ReadonlyArray<number> | undefined;\n readonly authors?: ReadonlyArray<string> | undefined;\n readonly since?: number | undefined;\n readonly until?: number | undefined;\n readonly limit?: number | undefined;\n /** NIP-50 full-text search. Relays interpret this. Local `matchFilter` / `query` ignore it. */\n readonly search?: string | undefined;\n readonly [key: `#${string}`]: ReadonlyArray<string> | undefined;\n};\n\n/** NIP-01 only defines single-letter tag conditions. */\nconst SINGLE_LETTER_TAG = /^#[a-zA-Z]$/;\n\n/** Local NIP-01 match. `search` is ignored; relays interpret NIP-50. */\nexport function matchFilter(filter: Filter, event: Event): boolean {\n if (filter.ids && !filter.ids.some((id) => id.toLowerCase() === event.id)) {\n return false;\n }\n if (filter.kinds && !filter.kinds.includes(event.kind)) {\n return false;\n }\n if (filter.authors && !filter.authors.some((pk) => pk.toLowerCase() === event.pubkey)) {\n return false;\n }\n\n for (const key of Object.keys(filter)) {\n // Multi-letter # keys are outside NIP-01 and ignored.\n if (!SINGLE_LETTER_TAG.test(key)) {\n continue;\n }\n const tagName = key.slice(1);\n const values = filter[`#${tagName}`];\n if (!values) {\n continue;\n }\n const hexTag = tagName === \"e\" || tagName === \"p\";\n const hit = event.tags.some((tag) => {\n const [tagKey, tagValue] = tag;\n if (tagKey !== tagName || tagValue === undefined) {\n return false;\n }\n if (hexTag) {\n return values.some((v) => v.toLowerCase() === tagValue.toLowerCase());\n }\n return values.includes(tagValue);\n });\n if (!hit) {\n return false;\n }\n }\n\n if (filter.since !== undefined && event.created_at < filter.since) {\n return false;\n }\n if (filter.until !== undefined && event.created_at > filter.until) {\n return false;\n }\n\n return true;\n}\n\n/** True when the event matches any of the filters (NIP-01 OR semantics). */\nexport function matchFilters(filters: ReadonlyArray<Filter>, event: Event): boolean {\n for (const filter of filters) {\n if (matchFilter(filter, event)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Intrinsic upper bound implied by the filter alone. Returns a positive integer, or `Infinity` when\n * unbounded.\n */\nexport function getFilterLimit(filter: Filter): number {\n if (filter.ids && filter.ids.length === 0) {\n return 0;\n }\n if (filter.kinds && filter.kinds.length === 0) {\n return 0;\n }\n if (filter.authors && filter.authors.length === 0) {\n return 0;\n }\n\n let limit = Number.POSITIVE_INFINITY;\n if (filter.ids) {\n limit = Math.min(limit, new Set(filter.ids.map((id) => id.toLowerCase())).size);\n }\n if (filter.limit !== undefined) {\n limit = Math.min(limit, filter.limit);\n }\n\n if (filter.kinds && filter.authors) {\n const kinds = new Set(filter.kinds);\n const allReplaceable = [...kinds].every((k) => isReplaceableKind(k) || isAddressableKind(k));\n if (allReplaceable) {\n const dTags = filter[\"#d\"];\n const perAuthor = dTags && dTags.length > 0 ? new Set(dTags).size : 1;\n const authors = new Set(filter.authors.map((pk) => pk.toLowerCase())).size;\n limit = Math.min(limit, authors * kinds.size * perAuthor);\n }\n }\n\n return limit;\n}\n\nconst HEX_LIST_KEYS = new Set([\"ids\", \"authors\", \"#e\", \"#p\"]);\n\n/** NIP-01 known fields; everything else (incl. multi-letter `#` keys) is dropped. */\nconst KNOWN_FILTER_KEYS = new Set([\"ids\", \"authors\", \"kinds\", \"since\", \"until\", \"limit\", \"search\"]);\n\n/**\n * Lowercase hex lists, sort and dedupe every array, and keep only the NIP-01 known fields plus\n * single-letter `#` keys — unknown keys and multi-letter `#` keys are dropped. Omits undefined so\n * `[]` stays distinct from missing.\n */\nexport function canonicalizeFilter(filter: Filter): Filter {\n const raw = filter as Record<string, unknown>;\n const out: Record<string, unknown> = {};\n for (const key of Object.keys(raw).sort()) {\n if (key.startsWith(\"#\")) {\n if (!SINGLE_LETTER_TAG.test(key)) {\n continue;\n }\n } else if (!KNOWN_FILTER_KEYS.has(key)) {\n continue;\n }\n const value = raw[key];\n // omit undefined so a missing key is not `[]` / null\n if (value === undefined) {\n continue;\n }\n if (Array.isArray(value)) {\n if (HEX_LIST_KEYS.has(key)) {\n out[key] = [...new Set(value.map((v) => String(v).toLowerCase()))].sort();\n } else if (key === \"kinds\") {\n out[key] = [...new Set(value.map(Number))].sort((a, b) => a - b);\n } else {\n out[key] = [...new Set(value.map(String))].sort();\n }\n } else {\n out[key] = value;\n }\n }\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- built key by key above; the record is filter-shaped by construction\n return out as Filter;\n}\n\n/** Apply {@link canonicalizeFilter} to each filter. */\nexport function canonicalizeFilters(filters: ReadonlyArray<Filter>): Filter[] {\n return filters.map(canonicalizeFilter);\n}\n\n/**\n * Canonical identity for live REQ coalescing. Relays treat a missing list key as unconstrained and\n * `[]` as match-nothing.\n */\nexport function filterFingerprint(filters: ReadonlyArray<Filter>): string {\n const parts = filters.map((filter) => JSON.stringify(canonicalizeFilter(filter)));\n parts.sort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AI,UAAU,KAAA,GACZ;EAEF,IAAI,MAAM,QAAQ,KAAK,GAAG;GACxB,IAAI,cAAc,IAAI,GAAG,GACvB,IAAI,OAAO,CAAC,GAAG,IAAI,IAAI,MAAM,KAAK,MAAM,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK;QACnE,IAAI,QAAQ,SACjB,IAAI,OAAO,CAAC,GAAG,IAAI,IAAI,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC;QAE/D,IAAI,OAAO,CAAC,GAAG,IAAI,IAAI,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK;EAEpD,OACE,IAAI,OAAO;CAEf;CAEA,OAAO;AACT;;AAGA,SAAgB,oBAAoB,SAA0C;CAC5E,OAAO,QAAQ,IAAI,kBAAkB;AACvC;;;;;AAMA,SAAgB,kBAAkB,SAAwC;CACxE,MAAM,QAAQ,QAAQ,KAAK,WAAW,KAAK,UAAU,mBAAmB,MAAM,CAAC,CAAC;CAChF,MAAM,KAAK;CACX,OAAO,IAAI,MAAM,KAAK,GAAG,EAAE;AAC7B"}
|
|
@@ -21,7 +21,11 @@ declare function matchFilters(filters: ReadonlyArray<Filter>, event: Event): boo
|
|
|
21
21
|
* unbounded.
|
|
22
22
|
*/
|
|
23
23
|
declare function getFilterLimit(filter: Filter): number;
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Lowercase hex lists, sort and dedupe every array, and keep only the NIP-01 known fields plus
|
|
26
|
+
* single-letter `#` keys — unknown keys and multi-letter `#` keys are dropped. Omits undefined so
|
|
27
|
+
* `[]` stays distinct from missing.
|
|
28
|
+
*/
|
|
25
29
|
declare function canonicalizeFilter(filter: Filter): Filter;
|
|
26
30
|
/** Apply {@link canonicalizeFilter} to each filter. */
|
|
27
31
|
declare function canonicalizeFilters(filters: ReadonlyArray<Filter>): Filter[];
|
|
@@ -32,4 +36,4 @@ declare function canonicalizeFilters(filters: ReadonlyArray<Filter>): Filter[];
|
|
|
32
36
|
declare function filterFingerprint(filters: ReadonlyArray<Filter>): string;
|
|
33
37
|
//#endregion
|
|
34
38
|
export { getFilterLimit as a, filterFingerprint as i, canonicalizeFilter as n, matchFilter as o, canonicalizeFilters as r, matchFilters as s, Filter as t };
|
|
35
|
-
//# sourceMappingURL=filter-
|
|
39
|
+
//# sourceMappingURL=filter-PG7r79rt.d.mts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as Event } from "./event-j3BwI5dF.mjs";
|
|
2
|
-
import { t as Filter } from "./filter-
|
|
2
|
+
import { t as Filter } from "./filter-PG7r79rt.mjs";
|
|
3
3
|
import { t as RelayListItem } from "./nip65-BL79HI8N.mjs";
|
|
4
4
|
//#region src/gossip/gossip.d.ts
|
|
5
5
|
/** Relay routing state for one pubkey: NIP-65 outbox/inbox plus NIP-17 DM relays. */
|
|
@@ -82,4 +82,4 @@ declare class Gossip {
|
|
|
82
82
|
}
|
|
83
83
|
//#endregion
|
|
84
84
|
export { RoutedFilter as i, GossipOptions as n, PubkeyRoutes as r, Gossip as t };
|
|
85
|
-
//# sourceMappingURL=gossip-
|
|
85
|
+
//# sourceMappingURL=gossip-BTMdlUI7.d.mts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { d as
|
|
1
|
+
import { d as normalizeURL, f as nowSeconds, u as normalizeRelayUrls } from "./util-DDpPkiED.mjs";
|
|
2
2
|
import { t as Kind } from "./kind-D8fENiiL.mjs";
|
|
3
|
-
import { a as isReplaceableWinner } from "./event-
|
|
3
|
+
import { a as isReplaceableWinner } from "./event-B3ua2_oL.mjs";
|
|
4
4
|
import { parseRelayList } from "./nips/nip65.mjs";
|
|
5
5
|
import { i as trimOldest, r as touchKey } from "./collections-DtwMc1NU.mjs";
|
|
6
6
|
import { parseDmRelayList } from "./nips/nip17.mjs";
|
|
@@ -225,4 +225,4 @@ var Gossip = class {
|
|
|
225
225
|
//#endregion
|
|
226
226
|
export { Gossip as t };
|
|
227
227
|
|
|
228
|
-
//# sourceMappingURL=gossip-
|
|
228
|
+
//# sourceMappingURL=gossip-K_JIexQs.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gossip-5ezg0Quo.mjs","names":[],"sources":["../src/gossip/gossip.ts"],"sourcesContent":["import { touchKey, trimOldest } from \"../core/collections.ts\";\nimport type { Event } from \"../core/event.ts\";\nimport { isReplaceableWinner } from \"../core/event.ts\";\nimport type { Filter } from \"../core/filter.ts\";\nimport { Kind } from \"../core/kind.ts\";\nimport { normalizeRelayUrls, normalizeURL, nowSeconds } from \"../core/util.ts\";\nimport { parseDmRelayList } from \"../nips/nip17.ts\";\nimport { parseRelayList } from \"../nips/nip65.ts\";\nimport type { RelayListItem } from \"../nips/nip65.ts\";\n\n/** Relay routing state for one pubkey: NIP-65 outbox/inbox plus NIP-17 DM relays. */\nexport type PubkeyRoutes = {\n /** Relays the user writes to (outbox). NIP-65. */\n readonly write: ReadonlyArray<string>;\n /** Relays the user reads from (inbox). NIP-65. */\n readonly read: ReadonlyArray<string>;\n /** Relays for NIP-17 gift-wrap delivery. Kind 10050. */\n readonly dm: ReadonlyArray<string>;\n /** `created_at` of the last accepted kind:10002 list. */\n readonly updatedAt: number;\n /** `created_at` of the last accepted kind:10050 list. */\n readonly dmUpdatedAt: number;\n /** Event id of the last accepted kind:10002 (NIP-01 equal-timestamp tie-break). */\n readonly relayListId?: string | undefined;\n /** Event id of the last accepted kind:10050. */\n readonly dmListId?: string | undefined;\n};\n\n/** A filter split by gossip routes: per-relay narrowed filters plus the unrouted remainder. */\nexport type RoutedFilter = {\n /** Url → already-narrowed filter. Empty when nothing routed. */\n readonly perRelay: ReadonlyMap<string, Filter>;\n /**\n * Unrouted work for the caller:\n *\n * - No authors and no #p: original filter (\"generic\")\n * - Authors/#p all unrouted: original filter (\"orphan\")\n * - Mixed: narrowed leftover (\"fallback\")\n * - All routed: undefined\n */\n readonly remainder?: Filter | undefined;\n};\n\nexport type GossipOptions = {\n /**\n * Max relays kept per direction; the first N in list order win (NIP-65 defines no ranking).\n * Default 4.\n */\n maxRelaysPerPubkey?: number | undefined;\n /**\n * Max pubkeys with tracked routes; the map is LRU — writes and lookups refresh recency, and\n * inserting beyond the cap drops the oldest entry. Default 10_000.\n */\n maxPubkeys?: number | undefined;\n};\n\nfunction emptyRoutes(): PubkeyRoutes {\n return {\n write: [],\n read: [],\n dm: [],\n updatedAt: 0,\n dmUpdatedAt: 0,\n };\n}\n\n/**\n * Routing table for NIP-65 (10002) and NIP-17 DM relays (10050). Ingest replaceable list events,\n * then route filters into per-relay REQs.\n */\nexport class Gossip {\n readonly #routes = new Map<string, PubkeyRoutes>();\n readonly #maxRelays: number;\n readonly #maxPubkeys: number;\n\n constructor(opts: GossipOptions = {}) {\n this.#maxRelays = opts.maxRelaysPerPubkey ?? 4;\n this.#maxPubkeys = opts.maxPubkeys ?? 10_000;\n }\n\n /**\n * Ingest a routing list event.\n *\n * - Kind:10002 → write/read (NIP-65)\n * - Kind:10050 → dm (NIP-17)\n *\n * Returns true if routes for that list type were updated.\n */\n ingest(event: Event): boolean {\n if (event.kind === Kind.RelayList) {\n let items: RelayListItem[];\n try {\n items = parseRelayList(event);\n } catch {\n return false;\n }\n return this.setRoutes(event.pubkey, items, event.created_at, event.id);\n }\n if (event.kind === Kind.DirectMessageRelaysList) {\n let relays: string[];\n try {\n relays = parseDmRelayList(event);\n } catch {\n return false;\n }\n return this.setDmRoutes(event.pubkey, relays, event.created_at, event.id);\n }\n return false;\n }\n\n setRoutes(\n pubkey: string,\n items: ReadonlyArray<RelayListItem>,\n updatedAt: number = nowSeconds(),\n eventId?: string,\n ): boolean {\n const pk = pubkey.toLowerCase();\n const prev = this.#lookup(pk) ?? emptyRoutes();\n if (prev.updatedAt > updatedAt) {\n return false;\n }\n if (\n eventId !== undefined &&\n prev.relayListId !== undefined &&\n prev.updatedAt === updatedAt &&\n !isReplaceableWinner(\n { created_at: updatedAt, id: eventId },\n { created_at: prev.updatedAt, id: prev.relayListId },\n )\n ) {\n return false;\n }\n\n const write: string[] = [];\n const read: string[] = [];\n for (const item of items) {\n let url: string;\n try {\n url = normalizeURL(item.url);\n } catch {\n continue;\n }\n if (item.marker !== \"read\" && !write.includes(url)) {\n write.push(url);\n }\n if (item.marker !== \"write\" && !read.includes(url)) {\n read.push(url);\n }\n }\n\n this.#put(pk, {\n write: write.slice(0, this.#maxRelays),\n read: read.slice(0, this.#maxRelays),\n dm: prev.dm,\n updatedAt,\n dmUpdatedAt: prev.dmUpdatedAt,\n relayListId: eventId ?? prev.relayListId,\n dmListId: prev.dmListId,\n });\n return true;\n }\n\n setDmRoutes(\n pubkey: string,\n relays: ReadonlyArray<string>,\n updatedAt: number = nowSeconds(),\n eventId?: string,\n ): boolean {\n const pk = pubkey.toLowerCase();\n const prev = this.#lookup(pk) ?? emptyRoutes();\n if (prev.dmUpdatedAt > updatedAt) {\n return false;\n }\n if (\n eventId !== undefined &&\n prev.dmListId !== undefined &&\n prev.dmUpdatedAt === updatedAt &&\n !isReplaceableWinner(\n { created_at: updatedAt, id: eventId },\n { created_at: prev.dmUpdatedAt, id: prev.dmListId },\n )\n ) {\n return false;\n }\n\n const dm = normalizeRelayUrls(relays);\n\n this.#put(pk, {\n write: prev.write,\n read: prev.read,\n dm: dm.slice(0, this.#maxRelays),\n updatedAt: prev.updatedAt,\n dmUpdatedAt: updatedAt,\n relayListId: prev.relayListId,\n dmListId: eventId ?? prev.dmListId,\n });\n return true;\n }\n\n getRoutes(pubkey: string): Readonly<PubkeyRoutes> | undefined {\n return this.#lookup(pubkey.toLowerCase());\n }\n\n outboxRelays(pubkey: string): ReadonlyArray<string> {\n return this.#lookup(pubkey.toLowerCase())?.write ?? [];\n }\n\n inboxRelays(pubkey: string): ReadonlyArray<string> {\n return this.#lookup(pubkey.toLowerCase())?.read ?? [];\n }\n\n /** NIP-17 kind:10050 delivery relays for gift-wraps. */\n dmRelays(pubkey: string): ReadonlyArray<string> {\n return this.#lookup(pubkey.toLowerCase())?.dm ?? [];\n }\n\n clear(pubkey?: string): void {\n if (pubkey !== undefined && pubkey !== \"\") {\n this.#routes.delete(pubkey.toLowerCase());\n } else {\n this.#routes.clear();\n }\n }\n\n get size(): number {\n return this.#routes.size;\n }\n\n /**\n * Route a user-facing filter into per-relay sub-filters plus leftover.\n *\n * - Authors → outbox relays, filter narrowed per relay's authors\n * - #p only → inbox relays of those pubkeys\n * - Neither / all unrouted → remainder is the original filter\n * - Mixed → remainder is the narrowed leftover; all routed → no remainder\n */\n route(filter: Filter): RoutedFilter {\n const authors = filter.authors?.map((a) => a.toLowerCase());\n const pTags = filter[\"#p\"]?.map((p) => p.toLowerCase());\n\n if ((!authors || authors.length === 0) && (!pTags || pTags.length === 0)) {\n return { perRelay: new Map(), remainder: filter };\n }\n\n if (authors && authors.length > 0 && (!pTags || pTags.length === 0)) {\n return this.#breakAuthors(filter, authors, \"write\");\n }\n\n if (pTags && pTags.length > 0 && (!authors || authors.length === 0)) {\n const { authors: _authors, ...base } = filter;\n return this.#breakAuthors(base, pTags, \"read\", (b, pubkeys) => ({ ...b, \"#p\": pubkeys }));\n }\n\n // both authors and #p: send full filter to union of routes\n const unionKeys = new Set([...(authors ?? []), ...(pTags ?? [])]);\n const relays = new Set<string>();\n let anyUnrouted = false;\n for (const pk of unionKeys) {\n const r = this.#lookup(pk);\n const urls = r ? [...r.write, ...r.read] : [];\n if (urls.length === 0) {\n anyUnrouted = true;\n continue;\n }\n for (const u of urls) {\n relays.add(u);\n }\n }\n if (relays.size === 0) {\n return { perRelay: new Map(), remainder: filter };\n }\n const map = new Map<string, Filter>();\n for (const url of relays) {\n map.set(url, { ...filter });\n }\n return anyUnrouted ? { perRelay: map, remainder: filter } : { perRelay: map };\n }\n\n #breakAuthors(\n filter: Filter,\n pubkeys: string[],\n direction: \"read\" | \"write\",\n narrow: (base: Filter, pubkeys: string[]) => Filter = (base, pks) => ({\n ...base,\n authors: pks,\n }),\n ): RoutedFilter {\n const perRelay = new Map<string, string[]>();\n const unrouted: string[] = [];\n let anyRoute = false;\n\n for (const pk of pubkeys) {\n const routes = this.#lookup(pk);\n const urls = direction === \"write\" ? routes?.write : routes?.read;\n if (!urls || urls.length === 0) {\n unrouted.push(pk);\n continue;\n }\n anyRoute = true;\n for (const url of urls) {\n const list = perRelay.get(url) ?? [];\n list.push(pk);\n perRelay.set(url, list);\n }\n }\n\n if (!anyRoute) {\n return { perRelay: new Map(), remainder: filter };\n }\n\n const map = new Map<string, Filter>();\n for (const [url, pks] of perRelay) {\n map.set(url, narrow(filter, pks));\n }\n return unrouted.length > 0\n ? { perRelay: map, remainder: narrow(filter, unrouted) }\n : { perRelay: map };\n }\n\n /** Read that refreshes LRU recency. */\n #lookup(pk: string): PubkeyRoutes | undefined {\n const routes = this.#routes.get(pk);\n if (routes !== undefined) {\n touchKey(this.#routes, pk, routes);\n }\n return routes;\n }\n\n /** Write at the newest LRU end, then trim the oldest beyond the cap. */\n #put(pk: string, routes: PubkeyRoutes): void {\n touchKey(this.#routes, pk, routes);\n trimOldest(this.#routes, this.#maxPubkeys);\n }\n}\n"],"mappings":";;;;;;;AAwDA,SAAS,cAA4B;CACnC,OAAO;EACL,OAAO,CAAC;EACR,MAAM,CAAC;EACP,IAAI,CAAC;EACL,WAAW;EACX,aAAa;CACf;AACF;;;;;AAMA,IAAa,SAAb,MAAoB;CAClB,0BAAmB,IAAI,IAA0B;CACjD;CACA;CAEA,YAAY,OAAsB,CAAC,GAAG;EACpC,KAAK,aAAa,KAAK,sBAAsB;EAC7C,KAAK,cAAc,KAAK,cAAc;CACxC;;;;;;;;;CAUA,OAAO,OAAuB;EAC5B,IAAI,MAAM,SAAS,KAAK,WAAW;GACjC,IAAI;GACJ,IAAI;IACF,QAAQ,eAAe,KAAK;GAC9B,QAAQ;IACN,OAAO;GACT;GACA,OAAO,KAAK,UAAU,MAAM,QAAQ,OAAO,MAAM,YAAY,MAAM,EAAE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C9B,MAAM,OAAO,cAAc,UAAU,QAAQ,QAAQ,QAAQ;GAC7D,IAAI,CAAC,QAAQ,KAAK,WAAW,GAAG;IAC9B,SAAS,KAAK,EAAE;IAChB;GACF;GACA,WAAW;GACX,KAAK,MAAM,OAAO,MAAM;IACtB,MAAM,OAAO,SAAS,IAAI,GAAG,KAAK,CAAC;IACnC,KAAK,KAAK,EAAE;IACZ,SAAS,IAAI,KAAK,IAAI;GACxB;EACF;EAEA,IAAI,CAAC,UACH,OAAO;GAAE,0BAAU,IAAI,IAAI;GAAG,WAAW;EAAO;EAGlD,MAAM,sBAAM,IAAI,IAAoB;EACpC,KAAK,MAAM,CAAC,KAAK,QAAQ,UACvB,IAAI,IAAI,KAAK,OAAO,QAAQ,GAAG,CAAC;EAElC,OAAO,SAAS,SAAS,IACrB;GAAE,UAAU;GAAK,WAAW,OAAO,QAAQ,QAAQ;EAAE,IACrD,EAAE,UAAU,IAAI;CACtB;;CAGA,QAAQ,IAAsC;EAC5C,MAAM,SAAS,KAAK,QAAQ,IAAI,EAAE;EAClC,IAAI,WAAW,KAAA,GACb,SAAS,KAAK,SAAS,IAAI,MAAM;EAEnC,OAAO;CACT;;CAGA,KAAK,IAAY,QAA4B;EAC3C,SAAS,KAAK,SAAS,IAAI,MAAM;EACjC,WAAW,KAAK,SAAS,KAAK,WAAW;CAC3C;AACF"}
|
|
1
|
+
{"version":3,"file":"gossip-K_JIexQs.mjs","names":[],"sources":["../src/gossip/gossip.ts"],"sourcesContent":["import { touchKey, trimOldest } from \"../core/collections.ts\";\nimport type { Event } from \"../core/event.ts\";\nimport { isReplaceableWinner } from \"../core/event.ts\";\nimport type { Filter } from \"../core/filter.ts\";\nimport { Kind } from \"../core/kind.ts\";\nimport { normalizeRelayUrls, normalizeURL, nowSeconds } from \"../core/util.ts\";\nimport { parseDmRelayList } from \"../nips/nip17.ts\";\nimport { parseRelayList } from \"../nips/nip65.ts\";\nimport type { RelayListItem } from \"../nips/nip65.ts\";\n\n/** Relay routing state for one pubkey: NIP-65 outbox/inbox plus NIP-17 DM relays. */\nexport type PubkeyRoutes = {\n /** Relays the user writes to (outbox). NIP-65. */\n readonly write: ReadonlyArray<string>;\n /** Relays the user reads from (inbox). NIP-65. */\n readonly read: ReadonlyArray<string>;\n /** Relays for NIP-17 gift-wrap delivery. Kind 10050. */\n readonly dm: ReadonlyArray<string>;\n /** `created_at` of the last accepted kind:10002 list. */\n readonly updatedAt: number;\n /** `created_at` of the last accepted kind:10050 list. */\n readonly dmUpdatedAt: number;\n /** Event id of the last accepted kind:10002 (NIP-01 equal-timestamp tie-break). */\n readonly relayListId?: string | undefined;\n /** Event id of the last accepted kind:10050. */\n readonly dmListId?: string | undefined;\n};\n\n/** A filter split by gossip routes: per-relay narrowed filters plus the unrouted remainder. */\nexport type RoutedFilter = {\n /** Url → already-narrowed filter. Empty when nothing routed. */\n readonly perRelay: ReadonlyMap<string, Filter>;\n /**\n * Unrouted work for the caller:\n *\n * - No authors and no #p: original filter (\"generic\")\n * - Authors/#p all unrouted: original filter (\"orphan\")\n * - Mixed: narrowed leftover (\"fallback\")\n * - All routed: undefined\n */\n readonly remainder?: Filter | undefined;\n};\n\nexport type GossipOptions = {\n /**\n * Max relays kept per direction; the first N in list order win (NIP-65 defines no ranking).\n * Default 4.\n */\n maxRelaysPerPubkey?: number | undefined;\n /**\n * Max pubkeys with tracked routes; the map is LRU — writes and lookups refresh recency, and\n * inserting beyond the cap drops the oldest entry. Default 10_000.\n */\n maxPubkeys?: number | undefined;\n};\n\nfunction emptyRoutes(): PubkeyRoutes {\n return {\n write: [],\n read: [],\n dm: [],\n updatedAt: 0,\n dmUpdatedAt: 0,\n };\n}\n\n/**\n * Routing table for NIP-65 (10002) and NIP-17 DM relays (10050). Ingest replaceable list events,\n * then route filters into per-relay REQs.\n */\nexport class Gossip {\n readonly #routes = new Map<string, PubkeyRoutes>();\n readonly #maxRelays: number;\n readonly #maxPubkeys: number;\n\n constructor(opts: GossipOptions = {}) {\n this.#maxRelays = opts.maxRelaysPerPubkey ?? 4;\n this.#maxPubkeys = opts.maxPubkeys ?? 10_000;\n }\n\n /**\n * Ingest a routing list event.\n *\n * - Kind:10002 → write/read (NIP-65)\n * - Kind:10050 → dm (NIP-17)\n *\n * Returns true if routes for that list type were updated.\n */\n ingest(event: Event): boolean {\n if (event.kind === Kind.RelayList) {\n let items: RelayListItem[];\n try {\n items = parseRelayList(event);\n } catch {\n return false;\n }\n return this.setRoutes(event.pubkey, items, event.created_at, event.id);\n }\n if (event.kind === Kind.DirectMessageRelaysList) {\n let relays: string[];\n try {\n relays = parseDmRelayList(event);\n } catch {\n return false;\n }\n return this.setDmRoutes(event.pubkey, relays, event.created_at, event.id);\n }\n return false;\n }\n\n setRoutes(\n pubkey: string,\n items: ReadonlyArray<RelayListItem>,\n updatedAt: number = nowSeconds(),\n eventId?: string,\n ): boolean {\n const pk = pubkey.toLowerCase();\n const prev = this.#lookup(pk) ?? emptyRoutes();\n if (prev.updatedAt > updatedAt) {\n return false;\n }\n if (\n eventId !== undefined &&\n prev.relayListId !== undefined &&\n prev.updatedAt === updatedAt &&\n !isReplaceableWinner(\n { created_at: updatedAt, id: eventId },\n { created_at: prev.updatedAt, id: prev.relayListId },\n )\n ) {\n return false;\n }\n\n const write: string[] = [];\n const read: string[] = [];\n for (const item of items) {\n let url: string;\n try {\n url = normalizeURL(item.url);\n } catch {\n continue;\n }\n if (item.marker !== \"read\" && !write.includes(url)) {\n write.push(url);\n }\n if (item.marker !== \"write\" && !read.includes(url)) {\n read.push(url);\n }\n }\n\n this.#put(pk, {\n write: write.slice(0, this.#maxRelays),\n read: read.slice(0, this.#maxRelays),\n dm: prev.dm,\n updatedAt,\n dmUpdatedAt: prev.dmUpdatedAt,\n relayListId: eventId ?? prev.relayListId,\n dmListId: prev.dmListId,\n });\n return true;\n }\n\n setDmRoutes(\n pubkey: string,\n relays: ReadonlyArray<string>,\n updatedAt: number = nowSeconds(),\n eventId?: string,\n ): boolean {\n const pk = pubkey.toLowerCase();\n const prev = this.#lookup(pk) ?? emptyRoutes();\n if (prev.dmUpdatedAt > updatedAt) {\n return false;\n }\n if (\n eventId !== undefined &&\n prev.dmListId !== undefined &&\n prev.dmUpdatedAt === updatedAt &&\n !isReplaceableWinner(\n { created_at: updatedAt, id: eventId },\n { created_at: prev.dmUpdatedAt, id: prev.dmListId },\n )\n ) {\n return false;\n }\n\n const dm = normalizeRelayUrls(relays);\n\n this.#put(pk, {\n write: prev.write,\n read: prev.read,\n dm: dm.slice(0, this.#maxRelays),\n updatedAt: prev.updatedAt,\n dmUpdatedAt: updatedAt,\n relayListId: prev.relayListId,\n dmListId: eventId ?? prev.dmListId,\n });\n return true;\n }\n\n getRoutes(pubkey: string): Readonly<PubkeyRoutes> | undefined {\n return this.#lookup(pubkey.toLowerCase());\n }\n\n outboxRelays(pubkey: string): ReadonlyArray<string> {\n return this.#lookup(pubkey.toLowerCase())?.write ?? [];\n }\n\n inboxRelays(pubkey: string): ReadonlyArray<string> {\n return this.#lookup(pubkey.toLowerCase())?.read ?? [];\n }\n\n /** NIP-17 kind:10050 delivery relays for gift-wraps. */\n dmRelays(pubkey: string): ReadonlyArray<string> {\n return this.#lookup(pubkey.toLowerCase())?.dm ?? [];\n }\n\n clear(pubkey?: string): void {\n if (pubkey !== undefined && pubkey !== \"\") {\n this.#routes.delete(pubkey.toLowerCase());\n } else {\n this.#routes.clear();\n }\n }\n\n get size(): number {\n return this.#routes.size;\n }\n\n /**\n * Route a user-facing filter into per-relay sub-filters plus leftover.\n *\n * - Authors → outbox relays, filter narrowed per relay's authors\n * - #p only → inbox relays of those pubkeys\n * - Neither / all unrouted → remainder is the original filter\n * - Mixed → remainder is the narrowed leftover; all routed → no remainder\n */\n route(filter: Filter): RoutedFilter {\n const authors = filter.authors?.map((a) => a.toLowerCase());\n const pTags = filter[\"#p\"]?.map((p) => p.toLowerCase());\n\n if ((!authors || authors.length === 0) && (!pTags || pTags.length === 0)) {\n return { perRelay: new Map(), remainder: filter };\n }\n\n if (authors && authors.length > 0 && (!pTags || pTags.length === 0)) {\n return this.#breakAuthors(filter, authors, \"write\");\n }\n\n if (pTags && pTags.length > 0 && (!authors || authors.length === 0)) {\n const { authors: _authors, ...base } = filter;\n return this.#breakAuthors(base, pTags, \"read\", (b, pubkeys) => ({ ...b, \"#p\": pubkeys }));\n }\n\n // both authors and #p: send full filter to union of routes\n const unionKeys = new Set([...(authors ?? []), ...(pTags ?? [])]);\n const relays = new Set<string>();\n let anyUnrouted = false;\n for (const pk of unionKeys) {\n const r = this.#lookup(pk);\n const urls = r ? [...r.write, ...r.read] : [];\n if (urls.length === 0) {\n anyUnrouted = true;\n continue;\n }\n for (const u of urls) {\n relays.add(u);\n }\n }\n if (relays.size === 0) {\n return { perRelay: new Map(), remainder: filter };\n }\n const map = new Map<string, Filter>();\n for (const url of relays) {\n map.set(url, { ...filter });\n }\n return anyUnrouted ? { perRelay: map, remainder: filter } : { perRelay: map };\n }\n\n #breakAuthors(\n filter: Filter,\n pubkeys: string[],\n direction: \"read\" | \"write\",\n narrow: (base: Filter, pubkeys: string[]) => Filter = (base, pks) => ({\n ...base,\n authors: pks,\n }),\n ): RoutedFilter {\n const perRelay = new Map<string, string[]>();\n const unrouted: string[] = [];\n let anyRoute = false;\n\n for (const pk of pubkeys) {\n const routes = this.#lookup(pk);\n const urls = direction === \"write\" ? routes?.write : routes?.read;\n if (!urls || urls.length === 0) {\n unrouted.push(pk);\n continue;\n }\n anyRoute = true;\n for (const url of urls) {\n const list = perRelay.get(url) ?? [];\n list.push(pk);\n perRelay.set(url, list);\n }\n }\n\n if (!anyRoute) {\n return { perRelay: new Map(), remainder: filter };\n }\n\n const map = new Map<string, Filter>();\n for (const [url, pks] of perRelay) {\n map.set(url, narrow(filter, pks));\n }\n return unrouted.length > 0\n ? { perRelay: map, remainder: narrow(filter, unrouted) }\n : { perRelay: map };\n }\n\n /** Read that refreshes LRU recency. */\n #lookup(pk: string): PubkeyRoutes | undefined {\n const routes = this.#routes.get(pk);\n if (routes !== undefined) {\n touchKey(this.#routes, pk, routes);\n }\n return routes;\n }\n\n /** Write at the newest LRU end, then trim the oldest beyond the cap. */\n #put(pk: string, routes: PubkeyRoutes): void {\n touchKey(this.#routes, pk, routes);\n trimOldest(this.#routes, this.#maxPubkeys);\n }\n}\n"],"mappings":";;;;;;;AAwDA,SAAS,cAA4B;CACnC,OAAO;EACL,OAAO,CAAC;EACR,MAAM,CAAC;EACP,IAAI,CAAC;EACL,WAAW;EACX,aAAa;CACf;AACF;;;;;AAMA,IAAa,SAAb,MAAoB;CAClB,0BAAmB,IAAI,IAA0B;CACjD;CACA;CAEA,YAAY,OAAsB,CAAC,GAAG;EACpC,KAAK,aAAa,KAAK,sBAAsB;EAC7C,KAAK,cAAc,KAAK,cAAc;CACxC;;;;;;;;;CAUA,OAAO,OAAuB;EAC5B,IAAI,MAAM,SAAS,KAAK,WAAW;GACjC,IAAI;GACJ,IAAI;IACF,QAAQ,eAAe,KAAK;GAC9B,QAAQ;IACN,OAAO;GACT;GACA,OAAO,KAAK,UAAU,MAAM,QAAQ,OAAO,MAAM,YAAY,MAAM,EAAE;EACvE;EACA,IAAI,MAAM,SAAS,KAAK,yBAAyB;GAC/C,IAAI;GACJ,IAAI;IACF,SAAS,iBAAiB,KAAK;GACjC,QAAQ;IACN,OAAO;GACT;GACA,OAAO,KAAK,YAAY,MAAM,QAAQ,QAAQ,MAAM,YAAY,MAAM,EAAE;EAC1E;EACA,OAAO;CACT;CAEA,UACE,QACA,OACA,YAAoB,WAAW,GAC/B,SACS;EACT,MAAM,KAAK,OAAO,YAAY;EAC9B,MAAM,OAAO,KAAK,QAAQ,EAAE,KAAK,YAAY;EAC7C,IAAI,KAAK,YAAY,WACnB,OAAO;EAET,IACE,YAAY,KAAA,KACZ,KAAK,gBAAgB,KAAA,KACrB,KAAK,cAAc,aACnB,CAAC,oBACC;GAAE,YAAY;GAAW,IAAI;EAAQ,GACrC;GAAE,YAAY,KAAK;GAAW,IAAI,KAAK;E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,QAAQ,QAAQ;EAAE,IACrD,EAAE,UAAU,IAAI;CACtB;;CAGA,QAAQ,IAAsC;EAC5C,MAAM,SAAS,KAAK,QAAQ,IAAI,EAAE;EAClC,IAAI,WAAW,KAAA,GACb,SAAS,KAAK,SAAS,IAAI,MAAM;EAEnC,OAAO;CACT;;CAGA,KAAK,IAAY,QAA4B;EAC3C,SAAS,KAAK,SAAS,IAAI,MAAM;EACjC,WAAW,KAAK,SAAS,KAAK,WAAW;CAC3C;AACF"}
|
package/dist/gossip.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as RoutedFilter, n as GossipOptions, r as PubkeyRoutes, t as Gossip } from "./gossip-
|
|
1
|
+
import { i as RoutedFilter, n as GossipOptions, r as PubkeyRoutes, t as Gossip } from "./gossip-BTMdlUI7.mjs";
|
|
2
2
|
import "./index-CaxrMD1A.mjs";
|
|
3
3
|
export { Gossip, type GossipOptions, type PubkeyRoutes, type RoutedFilter };
|
package/dist/gossip.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as Gossip } from "./gossip-
|
|
1
|
+
import { t as Gossip } from "./gossip-K_JIexQs.mjs";
|
|
2
2
|
export { Gossip };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { t as Event } from "./event-j3BwI5dF.mjs";
|
|
2
2
|
import { n as ProfileMetadata } from "./builder-GBddxj8i.mjs";
|
|
3
3
|
import { t as RelayListItem } from "./nip65-BL79HI8N.mjs";
|
|
4
|
-
import { t as Gossip } from "./gossip-
|
|
4
|
+
import { t as Gossip } from "./gossip-BTMdlUI7.mjs";
|
|
5
5
|
import { a as NostrError } from "./error-BquXDmIN.mjs";
|
|
6
|
-
import { _ as Closer, n as Pool } from "./pool-
|
|
7
|
-
import { r as OutboxBound, t as EventStore } from "./types-
|
|
8
|
-
import { t as ReactiveEventStore } from "./reactive-
|
|
6
|
+
import { _ as Closer, n as Pool } from "./pool-DUuYJ0x4.mjs";
|
|
7
|
+
import { r as OutboxBound, t as EventStore } from "./types-CqhnT-Mx.mjs";
|
|
8
|
+
import { t as ReactiveEventStore } from "./reactive-jyKrA9ej.mjs";
|
|
9
9
|
import { i as EventPointer, t as AddressPointer } from "./nip19-DpPN17bY.mjs";
|
|
10
10
|
import { t as MuteItem } from "./nip51-O_vhOiK2.mjs";
|
|
11
11
|
//#region src/loaders/event.d.ts
|
|
@@ -186,4 +186,4 @@ type CreateLoadersOptions = {
|
|
|
186
186
|
declare function createLoaders(opts: CreateLoadersOptions): Loaders;
|
|
187
187
|
//#endregion
|
|
188
188
|
export { EventRef as _, OutboxFeed as a, NostrUser as c, ListLoaders as d, ListResult as f, EventLoader as g, ReplaceableLoader as h, OutboxError as i, ProfileLoader as l, ReplaceableLoadResult as m, Loaders as n, OutboxFeedOptions as o, LoadStyle as p, createLoaders as r, groupAuthorsByOutboxRelay as s, CreateLoadersOptions as t, bareNostrUser as u };
|
|
189
|
-
//# sourceMappingURL=index-
|
|
189
|
+
//# sourceMappingURL=index-BP94lABY.d.mts.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { n as EventTemplate, r as UnsignedEvent, t as Event } from "./event-j3BwI5dF.mjs";
|
|
2
2
|
import { t as EventBuilder } from "./builder-GBddxj8i.mjs";
|
|
3
|
-
import { t as Filter } from "./filter-
|
|
4
|
-
import { t as Gossip } from "./gossip-
|
|
3
|
+
import { t as Filter } from "./filter-PG7r79rt.mjs";
|
|
4
|
+
import { t as Gossip } from "./gossip-BTMdlUI7.mjs";
|
|
5
5
|
import { a as NostrError } from "./error-BquXDmIN.mjs";
|
|
6
|
-
import { _ as Closer, a as PoolFetchResult, n as Pool, o as PoolOptions, s as PoolPublishResult } from "./pool-
|
|
7
|
-
import { t as EventStore } from "./types-
|
|
8
|
-
import { t as ReactiveEventStore } from "./reactive-
|
|
9
|
-
import { a as OutboxFeed, n as Loaders } from "./index-
|
|
6
|
+
import { _ as Closer, a as PoolFetchResult, n as Pool, o as PoolOptions, s as PoolPublishResult } from "./pool-DUuYJ0x4.mjs";
|
|
7
|
+
import { t as EventStore } from "./types-CqhnT-Mx.mjs";
|
|
8
|
+
import { t as ReactiveEventStore } from "./reactive-jyKrA9ej.mjs";
|
|
9
|
+
import { a as OutboxFeed, n as Loaders } from "./index-BP94lABY.mjs";
|
|
10
10
|
import { a as Rumor } from "./nip59-CdDoJptA.mjs";
|
|
11
11
|
import { i as ReplyTo, r as Recipient } from "./nip17-B7MI82Iq.mjs";
|
|
12
12
|
import { t as NostrSigner } from "./types-BJ4wZ7JJ.mjs";
|
|
@@ -290,4 +290,4 @@ declare class Client {
|
|
|
290
290
|
}
|
|
291
291
|
//#endregion
|
|
292
292
|
export { SyncSummary as _, FetchEachOptions as a, PrivateMessageSendResult as c, SendPrivateMessageOptions as d, SubscribeOptions as f, SyncOptions as g, SyncDirectionName as h, ClientOptions as i, PublishOptions as l, SyncDirection as m, ClientError as n, FetchEventsOptions as o, SubscribePrivateMessagesOptions as p, ClientEventMap as r, FetchPrivateMessagesOptions as s, Client as t, ReceivedPrivateMessage as u };
|
|
293
|
-
//# sourceMappingURL=index-
|
|
293
|
+
//# sourceMappingURL=index-CSsnE32i.d.mts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as Event } from "./event-j3BwI5dF.mjs";
|
|
2
|
-
import { t as Filter } from "./filter-
|
|
2
|
+
import { t as Filter } from "./filter-PG7r79rt.mjs";
|
|
3
3
|
import { a as NostrError } from "./error-BquXDmIN.mjs";
|
|
4
|
-
import { _ as Closer, n as Pool } from "./pool-
|
|
4
|
+
import { _ as Closer, n as Pool } from "./pool-DUuYJ0x4.mjs";
|
|
5
5
|
//#region src/relay/error.d.ts
|
|
6
6
|
/** Base class for relay errors; carries the relay URL when known. */
|
|
7
7
|
declare class RelayError extends NostrError {
|
|
@@ -79,4 +79,4 @@ declare function fetchRouted(pool: Pool, jobs: ReadonlyArray<RoutedJob>, opts?:
|
|
|
79
79
|
}): Promise<Event[]>;
|
|
80
80
|
//#endregion
|
|
81
81
|
export { isInsecureRelayUrl as a, RelayError as c, RelayTimeoutError as d, fetchRouted as i, RelayPublishError as l, RoutedJob as n, RelayClosedError as o, fanIn as r, RelayConnectionError as s, FanInOptions as t, RelaySuspendedError as u };
|
|
82
|
-
//# sourceMappingURL=index-
|
|
82
|
+
//# sourceMappingURL=index-DD0Ywpay.d.mts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as EventTemplate, r as UnsignedEvent, t as Event } from "./event-j3BwI5dF.mjs";
|
|
2
2
|
import { i as SecretKeyInput, t as Keys } from "./key-CyKN1RTi.mjs";
|
|
3
|
-
import { t as Filter } from "./filter-
|
|
3
|
+
import { t as Filter } from "./filter-PG7r79rt.mjs";
|
|
4
4
|
import { a as NostrError } from "./error-BquXDmIN.mjs";
|
|
5
5
|
import { t as NostrSigner } from "./types-BJ4wZ7JJ.mjs";
|
|
6
6
|
import { n as ClientMetadata, t as BunkerPointer } from "./nip46-BHaxC9TZ.mjs";
|
|
@@ -174,4 +174,4 @@ declare class Nip46Signer implements NostrSigner {
|
|
|
174
174
|
}
|
|
175
175
|
//#endregion
|
|
176
176
|
export { Nip07Signer as a, isNip07Available as c, Nip46Transport as i, KeysSigner as l, Nip46SignerOptions as n, WindowNostr as o, Nip46SubscribeOptions as r, getWindowNostr as s, Nip46Signer as t, NoSignerError as u };
|
|
177
|
-
//# sourceMappingURL=index-
|
|
177
|
+
//# sourceMappingURL=index-N7HUGgwo.d.mts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as Event } from "./event-j3BwI5dF.mjs";
|
|
2
|
-
import { t as Filter } from "./filter-
|
|
3
|
-
import { i as PutResult, n as NegentropyItem, r as OutboxBound, t as EventStore } from "./types-
|
|
2
|
+
import { t as Filter } from "./filter-PG7r79rt.mjs";
|
|
3
|
+
import { i as PutResult, n as NegentropyItem, r as OutboxBound, t as EventStore } from "./types-CqhnT-Mx.mjs";
|
|
4
4
|
//#region src/storage/memory-index.d.ts
|
|
5
5
|
type MemoryIndexOptions = {
|
|
6
6
|
/**
|
|
@@ -188,4 +188,4 @@ declare class SqliteEventStore implements EventStore {
|
|
|
188
188
|
}
|
|
189
189
|
//#endregion
|
|
190
190
|
export { IndexedDbEventStoreOptions as a, MemoryIndexOptions as c, IndexedDbEventStore as i, SqlValue as n, MemoryEventStore as o, SqliteEventStore as r, MemoryIndex as s, SqlDriver as t };
|
|
191
|
-
//# sourceMappingURL=index-
|
|
191
|
+
//# sourceMappingURL=index-rKcmI6ex.d.mts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { C as tagName, S as parseEventAddress, _ as eventAddress, b as getDTag, c as serializeEvent, d as sortedEvents, f as validateEvent, g as TagInput, h as Tag, i as getEventHash, l as signedMatchesUnsigned, m as EventAddress, n as EventTemplate, o as isReplaceableWinner, p as validateSignedEvent, r as UnsignedEvent, s as itemCompare, t as Event, u as sortEvents, w as tagValue, x as isTag, y as formatEventAddress } from "./event-j3BwI5dF.mjs";
|
|
2
2
|
import { a as SigningBackend, c as publicKeyFromHex, i as SecretKeyInput, l as signEvent, n as PublicKey, o as finalizeEvent, r as SecretKey, s as getPublicKey, t as Keys, u as toSecretKey } from "./key-CyKN1RTi.mjs";
|
|
3
3
|
import { n as ProfileMetadata, t as EventBuilder } from "./builder-GBddxj8i.mjs";
|
|
4
|
-
import { a as getFilterLimit, i as filterFingerprint, n as canonicalizeFilter, o as matchFilter, r as canonicalizeFilters, s as matchFilters, t as Filter } from "./filter-
|
|
4
|
+
import { a as getFilterLimit, i as filterFingerprint, n as canonicalizeFilter, o as matchFilter, r as canonicalizeFilters, s as matchFilters, t as Filter } from "./filter-PG7r79rt.mjs";
|
|
5
5
|
import { a as relayListEventBuilder, i as readRelays, n as RelayMarker, o as relayListToTags, r as parseRelayList, s as writeRelays, t as RelayListItem } from "./nip65-BL79HI8N.mjs";
|
|
6
|
-
import { i as RoutedFilter, r as PubkeyRoutes, t as Gossip } from "./gossip-
|
|
7
|
-
import { a as ClientMessage, c as SubscriptionId, d as encodeClientMessage, f as encodeRelayMessage, h as parseRelayMessage, i as verifyEvent, l as assertSubscriptionId, m as parseClientMessage, n as SerializedEventVerifier, o as CountResult, p as mergeCountHll, r as createEventVerifier, s as RelayMessage, t as EventVerifier, u as createSubscriptionId } from "./verifier-
|
|
6
|
+
import { i as RoutedFilter, r as PubkeyRoutes, t as Gossip } from "./gossip-BTMdlUI7.mjs";
|
|
7
|
+
import { a as ClientMessage, c as SubscriptionId, d as encodeClientMessage, f as encodeRelayMessage, h as parseRelayMessage, i as verifyEvent, l as assertSubscriptionId, m as parseClientMessage, n as SerializedEventVerifier, o as CountResult, p as mergeCountHll, r as createEventVerifier, s as RelayMessage, t as EventVerifier, u as createSubscriptionId } from "./verifier-Cl24c9ph.mjs";
|
|
8
8
|
import { a as NostrError, i as MessageError, n as EventValidationError, o as UrlError, r as HexError, s as WasmPoisonedError, t as CryptoError } from "./error-BquXDmIN.mjs";
|
|
9
|
-
import { _ as Closer, a as PoolFetchResult, c as PoolSubscribeOptions, d as RelayOptions, f as RelayStatus, g as RelayFetchResult, h as RelayFetchEnd, i as PoolEventMap, l as Relay, m as PublishResult, n as Pool, o as PoolOptions, p as RelayStatusName, r as PoolCountResult, s as PoolPublishResult, t as InvalidEventPolicy, u as RelayEventMap, v as RelaySubscription, y as SubscribeOptions } from "./pool-
|
|
9
|
+
import { _ as Closer, a as PoolFetchResult, c as PoolSubscribeOptions, d as RelayOptions, f as RelayStatus, g as RelayFetchResult, h as RelayFetchEnd, i as PoolEventMap, l as Relay, m as PublishResult, n as Pool, o as PoolOptions, p as RelayStatusName, r as PoolCountResult, s as PoolPublishResult, t as InvalidEventPolicy, u as RelayEventMap, v as RelaySubscription, y as SubscribeOptions } from "./pool-DUuYJ0x4.mjs";
|
|
10
10
|
import { i as useWebSocketImplementation } from "./websocket-CmeqvAkp.mjs";
|
|
11
|
-
import { i as PutResult, n as NegentropyItem, r as OutboxBound, t as EventStore } from "./types-
|
|
12
|
-
import { i as Watch, n as ReactiveEventStoreEventMap, r as ReactiveEventStoreOptions, t as ReactiveEventStore } from "./reactive-
|
|
11
|
+
import { i as PutResult, n as NegentropyItem, r as OutboxBound, t as EventStore } from "./types-CqhnT-Mx.mjs";
|
|
12
|
+
import { i as Watch, n as ReactiveEventStoreEventMap, r as ReactiveEventStoreOptions, t as ReactiveEventStore } from "./reactive-jyKrA9ej.mjs";
|
|
13
13
|
import { _ as noteEncode, a as NAddr, b as nsecEncode, c as NPub, d as Note, f as ProfilePointer, g as neventEncode, h as naddrEncode, i as EventPointer, l as NSec, n as Bech32MaxSize, o as NEvent, p as decode, r as DecodedResult, s as NProfile, t as AddressPointer, u as Nip19Error, v as nprofileEncode, y as npubEncode } from "./nip19-DpPN17bY.mjs";
|
|
14
|
-
import { a as OutboxFeed, c as NostrUser, f as ListResult, h as ReplaceableLoader, i as OutboxError, m as ReplaceableLoadResult, n as Loaders, o as OutboxFeedOptions, p as LoadStyle, r as createLoaders, s as groupAuthorsByOutboxRelay, u as bareNostrUser } from "./index-
|
|
14
|
+
import { a as OutboxFeed, c as NostrUser, f as ListResult, h as ReplaceableLoader, i as OutboxError, m as ReplaceableLoadResult, n as Loaders, o as OutboxFeedOptions, p as LoadStyle, r as createLoaders, s as groupAuthorsByOutboxRelay, u as bareNostrUser } from "./index-BP94lABY.mjs";
|
|
15
15
|
import { t as NostrSigner } from "./types-BJ4wZ7JJ.mjs";
|
|
16
16
|
import { t as StorageError } from "./error-BD_0QFKT.mjs";
|
|
17
|
-
import { _ as SyncSummary, c as PrivateMessageSendResult, d as SendPrivateMessageOptions, g as SyncOptions, h as SyncDirectionName, i as ClientOptions, m as SyncDirection, n as ClientError, p as SubscribePrivateMessagesOptions, r as ClientEventMap, s as FetchPrivateMessagesOptions, t as Client, u as ReceivedPrivateMessage } from "./index-
|
|
17
|
+
import { _ as SyncSummary, c as PrivateMessageSendResult, d as SendPrivateMessageOptions, g as SyncOptions, h as SyncDirectionName, i as ClientOptions, m as SyncDirection, n as ClientError, p as SubscribePrivateMessagesOptions, r as ClientEventMap, s as FetchPrivateMessagesOptions, t as Client, u as ReceivedPrivateMessage } from "./index-CSsnE32i.mjs";
|
|
18
18
|
import { S as SUBSCRIPTION_ID_MAX_CHARS, _ as normalizeURL, a as classifyKind, b as SECRET_KEY_BYTES, c as isRegularKind, f as bytesToHex, h as isHex64, i as KnownKind, l as isReplaceableKind, m as isHex32, n as KindClassification, o as isAddressableKind, p as hexToBytes, r as KindName, s as isEphemeralKind, t as Kind, v as EVENT_ID_BYTES, x as SIGNATURE_BYTES, y as PUBLIC_KEY_BYTES } from "./index-Hp26bgYG.mjs";
|
|
19
|
-
import { a as Nip07Signer, c as isNip07Available, i as Nip46Transport, l as KeysSigner, n as Nip46SignerOptions, o as WindowNostr, r as Nip46SubscribeOptions, s as getWindowNostr, t as Nip46Signer, u as NoSignerError } from "./index-
|
|
19
|
+
import { a as Nip07Signer, c as isNip07Available, i as Nip46Transport, l as KeysSigner, n as Nip46SignerOptions, o as WindowNostr, r as Nip46SubscribeOptions, s as getWindowNostr, t as Nip46Signer, u as NoSignerError } from "./index-N7HUGgwo.mjs";
|
|
20
20
|
import { Nip21Error, NostrURI, isNostrURI, parseNostrURI } from "./nips/nip21.mjs";
|
|
21
21
|
import { ReplyTagsOptions, ThreadReferences, buildReplyTags, parseThreadTags, replyTo } from "./nips/nip10.mjs";
|
|
22
22
|
import { isAuthRequired, makeAuthEvent } from "./nips/nip42.mjs";
|
|
23
|
-
import { a as isInsecureRelayUrl, c as RelayError, d as RelayTimeoutError, l as RelayPublishError, o as RelayClosedError, s as RelayConnectionError, u as RelaySuspendedError } from "./index-
|
|
24
|
-
import { a as IndexedDbEventStoreOptions, i as IndexedDbEventStore, n as SqlValue, o as MemoryEventStore, r as SqliteEventStore, t as SqlDriver } from "./index-
|
|
23
|
+
import { a as isInsecureRelayUrl, c as RelayError, d as RelayTimeoutError, l as RelayPublishError, o as RelayClosedError, s as RelayConnectionError, u as RelaySuspendedError } from "./index-DD0Ywpay.mjs";
|
|
24
|
+
import { a as IndexedDbEventStoreOptions, i as IndexedDbEventStore, n as SqlValue, o as MemoryEventStore, r as SqliteEventStore, t as SqlDriver } from "./index-rKcmI6ex.mjs";
|
|
25
25
|
export { type AddressPointer, Bech32MaxSize, Client, ClientError, type ClientEventMap, type ClientMessage, type ClientOptions, type Closer, type CountResult, CryptoError, type DecodedResult, EVENT_ID_BYTES, type Event, type EventAddress, EventBuilder, type EventPointer, type EventStore, type EventTemplate, EventValidationError, type EventVerifier, type FetchPrivateMessagesOptions, type Filter, Gossip, HexError, IndexedDbEventStore, type IndexedDbEventStoreOptions, type InvalidEventPolicy, Keys, KeysSigner, Kind, type KindClassification, type KindName, type KnownKind, type ListResult, type LoadStyle, type Loaders, MemoryEventStore, MessageError, type NAddr, type NEvent, type NProfile, type NPub, type NSec, type NegentropyItem, Nip07Signer, Nip19Error, Nip21Error, Nip46Signer, type Nip46SignerOptions, type Nip46SubscribeOptions, type Nip46Transport, NoSignerError, NostrError, type NostrSigner, type NostrURI, type NostrUser, type Note, type OutboxBound, OutboxError, OutboxFeed, type OutboxFeedOptions, PUBLIC_KEY_BYTES, Pool, type PoolCountResult, type PoolEventMap, type PoolFetchResult, type PoolOptions, type PoolPublishResult, type PoolSubscribeOptions, type PrivateMessageSendResult, type ProfileMetadata, type ProfilePointer, type PubkeyRoutes, type PublicKey, type PublishResult, type PutResult, ReactiveEventStore, type ReactiveEventStoreEventMap, type ReactiveEventStoreOptions, type ReceivedPrivateMessage, Relay, RelayClosedError, RelayConnectionError, RelayError, type RelayEventMap, type RelayFetchEnd, type RelayFetchResult, type RelayListItem, type RelayMarker, type RelayMessage, type RelayOptions, RelayPublishError, RelayStatus, type RelayStatusName, type RelaySubscription, RelaySuspendedError, RelayTimeoutError, type ReplaceableLoadResult, type ReplaceableLoader, type ReplyTagsOptions, type RoutedFilter, SECRET_KEY_BYTES, SIGNATURE_BYTES, SUBSCRIPTION_ID_MAX_CHARS, SecretKey, type SecretKeyInput, type SendPrivateMessageOptions, type SerializedEventVerifier, type SigningBackend, type SqlDriver, type SqlValue, SqliteEventStore, StorageError, type SubscribeOptions, type SubscribePrivateMessagesOptions, type SubscriptionId, SyncDirection, type SyncDirectionName, type SyncOptions, type SyncSummary, Tag, type TagInput, type ThreadReferences, type UnsignedEvent, UrlError, WasmPoisonedError, type Watch, type WindowNostr, assertSubscriptionId, bareNostrUser, buildReplyTags, bytesToHex, canonicalizeFilter, canonicalizeFilters, classifyKind, createEventVerifier, createLoaders, createSubscriptionId, encodeClientMessage, encodeRelayMessage, eventAddress, filterFingerprint, finalizeEvent, formatEventAddress, getDTag, getEventHash, getFilterLimit, getPublicKey, getWindowNostr, groupAuthorsByOutboxRelay, hexToBytes, isAddressableKind, isAuthRequired, isEphemeralKind, isHex32, isHex64, isInsecureRelayUrl, isNip07Available, isNostrURI, isRegularKind, isReplaceableKind, isReplaceableWinner, isTag, itemCompare, makeAuthEvent, matchFilter, matchFilters, mergeCountHll, naddrEncode, neventEncode, decode as nip19Decode, normalizeURL, noteEncode, nprofileEncode, npubEncode, nsecEncode, parseClientMessage, parseEventAddress, parseNostrURI, parseRelayList, parseRelayMessage, parseThreadTags, publicKeyFromHex, readRelays, relayListEventBuilder, relayListToTags, replyTo, serializeEvent, signEvent, signedMatchesUnsigned, sortEvents, sortedEvents, tagName, tagValue, toSecretKey, useWebSocketImplementation, validateEvent, validateSignedEvent, verifyEvent, writeRelays };
|
package/dist/index.mjs
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as SIGNATURE_BYTES, E as SECRET_KEY_BYTES, O as SUBSCRIPTION_ID_MAX_CHARS, T as PUBLIC_KEY_BYTES, _ as HexError, b as UrlError, c as isHex64, d as normalizeURL, g as EventValidationError, h as CryptoError, i as bytesToHex, o as hexToBytes, s as isHex32, v as MessageError, w as EVENT_ID_BYTES, x as WasmPoisonedError, y as NostrError } from "./util-DDpPkiED.mjs";
|
|
2
2
|
import { a as isRegularKind, i as isEphemeralKind, n as classifyKind, o as isReplaceableKind, r as isAddressableKind, t as Kind } from "./kind-D8fENiiL.mjs";
|
|
3
|
-
import { C as tagName, S as parseEventAddress, _ as eventAddress, a as isReplaceableWinner, b as getDTag, d as signedMatchesUnsigned, f as sortEvents, g as Tag, h as validateSignedEvent, l as serializeEvent, m as validateEvent, n as getEventHash, o as itemCompare, p as sortedEvents, w as tagValue, x as isTag, y as formatEventAddress } from "./event-
|
|
4
|
-
import { a as publicKeyFromHex, i as getPublicKey, n as SecretKey, o as signEvent, r as finalizeEvent, s as toSecretKey, t as Keys } from "./key-
|
|
5
|
-
import { n as verifyEvent, t as createEventVerifier } from "./verifier-
|
|
6
|
-
import { t as EventBuilder } from "./builder-
|
|
7
|
-
import { a as matchFilter, i as getFilterLimit, n as canonicalizeFilters, o as matchFilters, r as filterFingerprint, t as canonicalizeFilter } from "./filter-
|
|
8
|
-
import { a as mergeCountHll, i as encodeRelayMessage, n as createSubscriptionId, o as parseClientMessage, r as encodeClientMessage, s as parseRelayMessage, t as assertSubscriptionId } from "./message-
|
|
9
|
-
import { t as NoSignerError } from "./error-
|
|
10
|
-
import { a as KeysSigner, i as isNip07Available, n as Nip07Signer, r as getWindowNostr, t as Nip46Signer } from "./signer-
|
|
3
|
+
import { C as tagName, S as parseEventAddress, _ as eventAddress, a as isReplaceableWinner, b as getDTag, d as signedMatchesUnsigned, f as sortEvents, g as Tag, h as validateSignedEvent, l as serializeEvent, m as validateEvent, n as getEventHash, o as itemCompare, p as sortedEvents, w as tagValue, x as isTag, y as formatEventAddress } from "./event-B3ua2_oL.mjs";
|
|
4
|
+
import { a as publicKeyFromHex, i as getPublicKey, n as SecretKey, o as signEvent, r as finalizeEvent, s as toSecretKey, t as Keys } from "./key-k8LDEPZh.mjs";
|
|
5
|
+
import { n as verifyEvent, t as createEventVerifier } from "./verifier-CjH1vnP2.mjs";
|
|
6
|
+
import { t as EventBuilder } from "./builder-BQbFDO6S.mjs";
|
|
7
|
+
import { a as matchFilter, i as getFilterLimit, n as canonicalizeFilters, o as matchFilters, r as filterFingerprint, t as canonicalizeFilter } from "./filter-B16P33dz.mjs";
|
|
8
|
+
import { a as mergeCountHll, i as encodeRelayMessage, n as createSubscriptionId, o as parseClientMessage, r as encodeClientMessage, s as parseRelayMessage, t as assertSubscriptionId } from "./message-pYfVKxPn.mjs";
|
|
9
|
+
import { t as NoSignerError } from "./error-UHkqzWL7.mjs";
|
|
10
|
+
import { a as KeysSigner, i as isNip07Available, n as Nip07Signer, r as getWindowNostr, t as Nip46Signer } from "./signer-CWtxpOxc.mjs";
|
|
11
11
|
import { Bech32MaxSize, Nip19Error, decode, naddrEncode, neventEncode, noteEncode, nprofileEncode, npubEncode, nsecEncode } from "./nips/nip19.mjs";
|
|
12
12
|
import { Nip21Error, isNostrURI, parseNostrURI } from "./nips/nip21.mjs";
|
|
13
13
|
import { buildReplyTags, parseThreadTags, replyTo } from "./nips/nip10.mjs";
|
|
14
14
|
import { isAuthRequired, makeAuthEvent } from "./nips/nip42.mjs";
|
|
15
15
|
import { parseRelayList, readRelays, relayListEventBuilder, relayListToTags, writeRelays } from "./nips/nip65.mjs";
|
|
16
|
-
import { c as RelayConnectionError, d as RelaySuspendedError, f as RelayTimeoutError, l as RelayError, n as Relay, o as useWebSocketImplementation, r as RelayStatus, s as RelayClosedError, u as RelayPublishError } from "./relay-
|
|
17
|
-
import { i as isInsecureRelayUrl, t as Pool } from "./pool-
|
|
16
|
+
import { c as RelayConnectionError, d as RelaySuspendedError, f as RelayTimeoutError, l as RelayError, n as Relay, o as useWebSocketImplementation, r as RelayStatus, s as RelayClosedError, u as RelayPublishError } from "./relay-DXtwUEdX.mjs";
|
|
17
|
+
import { i as isInsecureRelayUrl, t as Pool } from "./pool-BMUsw2un.mjs";
|
|
18
18
|
import "./relay.mjs";
|
|
19
|
-
import { t as Gossip } from "./gossip-
|
|
20
|
-
import { a as bareNostrUser, i as groupAuthorsByOutboxRelay, n as OutboxError, r as OutboxFeed, t as createLoaders } from "./loaders-
|
|
21
|
-
import { t as StorageError } from "./error-
|
|
22
|
-
import { t as MemoryEventStore } from "./memory-
|
|
23
|
-
import { t as ReactiveEventStore } from "./reactive
|
|
24
|
-
import { n as ClientError, r as SyncDirection, t as Client } from "./client-
|
|
25
|
-
import { n as IndexedDbEventStore, t as SqliteEventStore } from "./storage-
|
|
19
|
+
import { t as Gossip } from "./gossip-K_JIexQs.mjs";
|
|
20
|
+
import { a as bareNostrUser, i as groupAuthorsByOutboxRelay, n as OutboxError, r as OutboxFeed, t as createLoaders } from "./loaders-Dp2nXEFk.mjs";
|
|
21
|
+
import { t as StorageError } from "./error-DH4guike.mjs";
|
|
22
|
+
import { t as MemoryEventStore } from "./memory-VyPnOBU3.mjs";
|
|
23
|
+
import { t as ReactiveEventStore } from "./reactive--pDpLt2H.mjs";
|
|
24
|
+
import { n as ClientError, r as SyncDirection, t as Client } from "./client-CTmp5w84.mjs";
|
|
25
|
+
import { n as IndexedDbEventStore, t as SqliteEventStore } from "./storage-B5Wdt_Mn.mjs";
|
|
26
26
|
import "./store.mjs";
|
|
27
27
|
export { Bech32MaxSize, Client, ClientError, CryptoError, EVENT_ID_BYTES, EventBuilder, EventValidationError, Gossip, HexError, IndexedDbEventStore, Keys, KeysSigner, Kind, MemoryEventStore, MessageError, Nip07Signer, Nip19Error, Nip21Error, Nip46Signer, NoSignerError, NostrError, OutboxError, OutboxFeed, PUBLIC_KEY_BYTES, Pool, ReactiveEventStore, Relay, RelayClosedError, RelayConnectionError, RelayError, RelayPublishError, RelayStatus, RelaySuspendedError, RelayTimeoutError, SECRET_KEY_BYTES, SIGNATURE_BYTES, SUBSCRIPTION_ID_MAX_CHARS, SecretKey, SqliteEventStore, StorageError, SyncDirection, Tag, UrlError, WasmPoisonedError, assertSubscriptionId, bareNostrUser, buildReplyTags, bytesToHex, canonicalizeFilter, canonicalizeFilters, classifyKind, createEventVerifier, createLoaders, createSubscriptionId, encodeClientMessage, encodeRelayMessage, eventAddress, filterFingerprint, finalizeEvent, formatEventAddress, getDTag, getEventHash, getFilterLimit, getPublicKey, getWindowNostr, groupAuthorsByOutboxRelay, hexToBytes, isAddressableKind, isAuthRequired, isEphemeralKind, isHex32, isHex64, isInsecureRelayUrl, isNip07Available, isNostrURI, isRegularKind, isReplaceableKind, isReplaceableWinner, isTag, itemCompare, makeAuthEvent, matchFilter, matchFilters, mergeCountHll, naddrEncode, neventEncode, decode as nip19Decode, normalizeURL, noteEncode, nprofileEncode, npubEncode, nsecEncode, parseClientMessage, parseEventAddress, parseNostrURI, parseRelayList, parseRelayMessage, parseThreadTags, publicKeyFromHex, readRelays, relayListEventBuilder, relayListToTags, replyTo, serializeEvent, signEvent, signedMatchesUnsigned, sortEvents, sortedEvents, tagName, tagValue, toSecretKey, useWebSocketImplementation, validateEvent, validateSignedEvent, verifyEvent, writeRelays };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as markVerified, m as validateEvent, u as serializeValidatedEvent } from "./event-
|
|
1
|
+
import { g as EventValidationError, h as CryptoError, i as bytesToHex$1, m as utf8Encoder, n as assertHex32, o as hexToBytes$1, r as assertSecretKeyBytes } from "./util-DDpPkiED.mjs";
|
|
2
|
+
import { c as markVerified, m as validateEvent, u as serializeValidatedEvent } from "./event-B3ua2_oL.mjs";
|
|
3
3
|
import { randomBytes } from "@noble/hashes/utils.js";
|
|
4
4
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
5
5
|
import { schnorr } from "@noble/curves/secp256k1.js";
|
|
@@ -120,4 +120,4 @@ function signEvent(unsigned, secretKey) {
|
|
|
120
120
|
//#endregion
|
|
121
121
|
export { publicKeyFromHex as a, getPublicKey as i, SecretKey as n, signEvent as o, finalizeEvent as r, toSecretKey as s, Keys as t };
|
|
122
122
|
|
|
123
|
-
//# sourceMappingURL=key-
|
|
123
|
+
//# sourceMappingURL=key-k8LDEPZh.mjs.map
|