@qntx/nostr 0.8.0 → 0.10.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/LICENSE-APACHE +201 -0
- package/README.md +9 -19
- package/dist/{builder-aNU2gGFP.mjs → builder-CVRmUeNm.mjs} +4 -4
- package/dist/{builder-aNU2gGFP.mjs.map → builder-CVRmUeNm.mjs.map} +1 -1
- package/dist/{builder-CTwkB2zM.d.mts → builder-GBddxj8i.d.mts} +3 -3
- package/dist/{client-Cj2lUaVh.mjs → client-CeyDLoyO.mjs} +50 -28
- package/dist/client-CeyDLoyO.mjs.map +1 -0
- package/dist/client.d.mts +1 -1
- package/dist/client.mjs +1 -1
- package/dist/core.d.mts +7 -8
- package/dist/core.mjs +8 -8
- package/dist/{event-CHf47dPM.mjs → event-C2eLiPpV.mjs} +15 -5
- package/dist/event-C2eLiPpV.mjs.map +1 -0
- package/dist/{event-DJeb_DIL.d.mts → event-j3BwI5dF.d.mts} +2 -4
- package/dist/{filter-jI_9htF7.d.mts → filter-CfEgQBXt.d.mts} +3 -5
- package/dist/{filter-BQl3GlHt.mjs → filter-TrF2LEoy.mjs} +3 -36
- package/dist/filter-TrF2LEoy.mjs.map +1 -0
- package/dist/{gossip-DFxIBlsr.mjs → gossip-5ezg0Quo.mjs} +3 -3
- package/dist/gossip-5ezg0Quo.mjs.map +1 -0
- package/dist/{gossip-OOeeFzG5.d.mts → gossip-BWb9HmfK.d.mts} +8 -5
- package/dist/gossip.d.mts +1 -1
- package/dist/gossip.mjs +1 -1
- package/dist/http-CuazNRIP.mjs.map +1 -1
- package/dist/{http-C4HwIu4B.d.mts → http-kwWG-V1X.d.mts} +9 -3
- package/dist/{index-CPVEyzNX.d.mts → index-B1fLejg4.d.mts} +9 -9
- package/dist/{index-C_w2WfVz.d.mts → index-C0mFpelb.d.mts} +6 -6
- package/dist/{index-DyKwQnbt.d.mts → index-CLJEKFGd.d.mts} +4 -4
- package/dist/{index-BxCBX-8R.d.mts → index-CoX7SnO7.d.mts} +7 -4
- package/dist/{index-DU9tRFTZ.d.mts → index-Hp26bgYG.d.mts} +11 -4
- package/dist/{index-Cl_1XdYP.d.mts → index-uCYwXaaP.d.mts} +22 -14
- package/dist/index.d.mts +18 -19
- package/dist/index.mjs +17 -17
- package/dist/{key-D_5OgGT7.d.mts → key-CyKN1RTi.d.mts} +2 -2
- package/dist/{key-DnVpchl6.mjs → key-DY_HEIpY.mjs} +5 -4
- package/dist/key-DY_HEIpY.mjs.map +1 -0
- package/dist/{kind-Cxwhhkx8.mjs → kind-D8fENiiL.mjs} +11 -5
- package/dist/kind-D8fENiiL.mjs.map +1 -0
- package/dist/{loaders-BmPkQfzI.mjs → loaders-DifimjJ7.mjs} +9 -8
- package/dist/{loaders-BmPkQfzI.mjs.map → loaders-DifimjJ7.mjs.map} +1 -1
- package/dist/loaders.d.mts +2 -2
- package/dist/loaders.mjs +1 -1
- package/dist/{memory-CdJ07kub.mjs → memory-DENGQ_f6.mjs} +2 -2
- package/dist/{memory-CdJ07kub.mjs.map → memory-DENGQ_f6.mjs.map} +1 -1
- package/dist/{memory-index-Cbc83vOZ.mjs → memory-index-D_lvlYAy.mjs} +4 -4
- package/dist/{memory-index-Cbc83vOZ.mjs.map → memory-index-D_lvlYAy.mjs.map} +1 -1
- package/dist/{message-oNr7t0SJ.mjs → message-Rd5Z_17h.mjs} +5 -4
- package/dist/{message-oNr7t0SJ.mjs.map → message-Rd5Z_17h.mjs.map} +1 -1
- package/dist/{nip17-B5WgW4C4.d.mts → nip17-B7MI82Iq.d.mts} +4 -4
- package/dist/{nip51-CR0Q8eym.d.mts → nip51-O_vhOiK2.d.mts} +3 -3
- package/dist/{nip59-C-RWFQIv.d.mts → nip59-CdDoJptA.d.mts} +2 -2
- package/dist/{nip65-D1fbmhOg.d.mts → nip65-BL79HI8N.d.mts} +3 -3
- package/dist/{nip77-DzUwUxHq.d.mts → nip77-wHA_nEV5.d.mts} +2 -2
- package/dist/nips/blossom.d.mts +3 -3
- package/dist/nips/blossom.mjs +2 -2
- package/dist/nips/nip05.d.mts +1 -1
- package/dist/nips/nip10.d.mts +2 -2
- package/dist/nips/nip10.mjs +3 -3
- package/dist/nips/nip11.d.mts +1 -1
- package/dist/nips/nip13.d.mts +1 -1
- package/dist/nips/nip17.d.mts +1 -1
- package/dist/nips/nip17.mjs +3 -3
- package/dist/nips/nip27.d.mts +1 -1
- package/dist/nips/nip42.d.mts +1 -1
- package/dist/nips/nip42.mjs +1 -1
- package/dist/nips/nip51.d.mts +1 -1
- package/dist/nips/nip51.mjs +3 -3
- package/dist/nips/nip57.d.mts +1 -1
- package/dist/nips/nip57.mjs +3 -3
- package/dist/nips/nip59.d.mts +1 -1
- package/dist/nips/nip59.mjs +4 -4
- package/dist/nips/nip65.d.mts +1 -1
- package/dist/nips/nip65.mjs +2 -2
- package/dist/nips/nip77.d.mts +1 -1
- package/dist/nips/nip77.mjs +8 -5
- package/dist/nips/nip77.mjs.map +1 -1
- package/dist/nips/nip98.d.mts +1 -1
- package/dist/nips/nip98.mjs +3 -3
- package/dist/{pool-CqQvUnsq.d.mts → pool-Bfe3Tu40.d.mts} +7 -7
- package/dist/{pool-vlw74C4t.mjs → pool-jok2-iBJ.mjs} +28 -21
- package/dist/pool-jok2-iBJ.mjs.map +1 -0
- package/dist/{put-w13ci3sC.mjs → put-JsiCKMyZ.mjs} +4 -4
- package/dist/put-JsiCKMyZ.mjs.map +1 -0
- package/dist/{reactive-Tz0otDIP.mjs → reactive-6Wn9qf_d.mjs} +5 -5
- package/dist/{reactive-Tz0otDIP.mjs.map → reactive-6Wn9qf_d.mjs.map} +1 -1
- package/dist/{reactive-gGqUrzW8.d.mts → reactive-X4p6nABy.d.mts} +4 -4
- package/dist/{relay-quCs7MHD.mjs → relay-__QtO33h.mjs} +18 -10
- package/dist/relay-__QtO33h.mjs.map +1 -0
- package/dist/relay.d.mts +3 -3
- package/dist/relay.mjs +2 -2
- package/dist/{signer-poTGe6Er.mjs → signer-D7PtVvQn.mjs} +14 -7
- package/dist/signer-D7PtVvQn.mjs.map +1 -0
- package/dist/signer.d.mts +2 -2
- package/dist/signer.mjs +1 -1
- package/dist/{storage-B5IXTVuS.mjs → storage-oihjE0_x.mjs} +10 -10
- package/dist/{storage-B5IXTVuS.mjs.map → storage-oihjE0_x.mjs.map} +1 -1
- package/dist/storage.d.mts +2 -2
- package/dist/storage.mjs +3 -3
- package/dist/store.d.mts +1 -1
- package/dist/store.mjs +1 -1
- package/dist/testing.d.mts +8 -2
- package/dist/testing.mjs +32 -10
- package/dist/testing.mjs.map +1 -1
- package/dist/{types-DNmiscfd.d.mts → types-BJ4wZ7JJ.d.mts} +2 -2
- package/dist/{types-BacwnDtU.d.mts → types-Ccox7-5v.d.mts} +3 -3
- package/dist/{message-tclYCVNc.d.mts → verifier-9c-bINrv.d.mts} +23 -4
- package/dist/{verifier-B51Wkt5H.mjs → verifier-uC_jd-Nw.mjs} +3 -3
- package/dist/verifier-uC_jd-Nw.mjs.map +1 -0
- package/package.json +25 -50
- package/dist/client-Cj2lUaVh.mjs.map +0 -1
- package/dist/event-CHf47dPM.mjs.map +0 -1
- package/dist/filter-BQl3GlHt.mjs.map +0 -1
- package/dist/gossip-DFxIBlsr.mjs.map +0 -1
- package/dist/instance-C62w3cEt.mjs +0 -220
- package/dist/instance-C62w3cEt.mjs.map +0 -1
- package/dist/instance-DjsL8h84.d.mts +0 -15
- package/dist/key-DnVpchl6.mjs.map +0 -1
- package/dist/kind-Cxwhhkx8.mjs.map +0 -1
- package/dist/nostr_crypto_wasm_bg-Czrdty7Q.mjs +0 -4
- package/dist/nostr_crypto_wasm_bg.wasm +0 -0
- package/dist/pool-vlw74C4t.mjs.map +0 -1
- package/dist/put-w13ci3sC.mjs.map +0 -1
- package/dist/relay-quCs7MHD.mjs.map +0 -1
- package/dist/signer-poTGe6Er.mjs.map +0 -1
- package/dist/verifier-B51Wkt5H.mjs.map +0 -1
- package/dist/verifier-CgTFpgsC.d.mts +0 -22
- package/dist/wasm.browser.d.mts +0 -8
- package/dist/wasm.browser.mjs +0 -19
- package/dist/wasm.browser.mjs.map +0 -1
- package/dist/wasm.d.mts +0 -8
- package/dist/wasm.mjs +0 -28
- package/dist/wasm.mjs.map +0 -1
- /package/{LICENSE → LICENSE-MIT} +0 -0
package/dist/client.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as SyncSummary, a as FetchEachOptions, c as PrivateMessageSendResult, d as SendPrivateMessageOptions, f as SubscribeOptions, g as SyncOptions, h as SyncDirectionName, i as ClientOptions, l as PublishOptions, m as SyncDirection, n as ClientError, o as FetchEventsOptions, p as SubscribePrivateMessagesOptions, r as ClientEventMap, s as FetchPrivateMessagesOptions, t as Client, u as ReceivedPrivateMessage } from "./index-
|
|
1
|
+
import { _ as SyncSummary, a as FetchEachOptions, c as PrivateMessageSendResult, d as SendPrivateMessageOptions, f as SubscribeOptions, g as SyncOptions, h as SyncDirectionName, i as ClientOptions, l as PublishOptions, m as SyncDirection, n as ClientError, o as FetchEventsOptions, p as SubscribePrivateMessagesOptions, r as ClientEventMap, s as FetchPrivateMessagesOptions, t as Client, u as ReceivedPrivateMessage } from "./index-uCYwXaaP.mjs";
|
|
2
2
|
export { Client, ClientError, type ClientEventMap, type ClientOptions, type FetchEachOptions, type FetchEventsOptions, type FetchPrivateMessagesOptions, type PrivateMessageSendResult, type PublishOptions, type ReceivedPrivateMessage, type SendPrivateMessageOptions, type SubscribeOptions, type SubscribePrivateMessagesOptions, SyncDirection, type SyncDirectionName, type SyncOptions, type SyncSummary };
|
package/dist/client.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as ClientError, r as SyncDirection, t as Client } from "./client-
|
|
1
|
+
import { n as ClientError, r as SyncDirection, t as Client } from "./client-CeyDLoyO.mjs";
|
|
2
2
|
export { Client, ClientError, SyncDirection };
|
package/dist/core.d.mts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { C as
|
|
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-
|
|
3
|
-
import { n as ProfileMetadata, t as EventBuilder } from "./builder-
|
|
4
|
-
import { a as getFilterLimit,
|
|
5
|
-
import { a as
|
|
6
|
-
import { i as verifyEvent, n as SerializedEventVerifier, r as createEventVerifier, t as EventVerifier } from "./verifier-CgTFpgsC.mjs";
|
|
1
|
+
import { C as tagName, S as parseEventAddress, _ as eventAddress, a as isMarkedFailed, 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, v as firstTagValue, w as tagValue, x as isTag, y as formatEventAddress } from "./event-j3BwI5dF.mjs";
|
|
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
|
+
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-CfEgQBXt.mjs";
|
|
5
|
+
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-9c-bINrv.mjs";
|
|
7
6
|
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";
|
|
8
|
-
import { S as SUBSCRIPTION_ID_MAX_CHARS, _ as normalizeURL, a as classifyKind, b as SECRET_KEY_BYTES, c as isRegularKind, d as assertSecretKeyBytes, f as bytesToHex, g as normalizeRelayUrls, 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, u as assertHex32, v as EVENT_ID_BYTES, x as SIGNATURE_BYTES, y as PUBLIC_KEY_BYTES } from "./index-
|
|
9
|
-
export { type ClientMessage, type CountResult, CryptoError, EVENT_ID_BYTES, type Event, type EventAddress, EventBuilder, type EventTemplate, EventValidationError, type EventVerifier, type Filter, HexError, Keys, Kind, type KindClassification, type KindName, type KnownKind, MessageError, NostrError, PUBLIC_KEY_BYTES, type ProfileMetadata, type PublicKey, type RelayMessage, SECRET_KEY_BYTES, SIGNATURE_BYTES, SUBSCRIPTION_ID_MAX_CHARS, SecretKey, type SecretKeyInput, type SerializedEventVerifier, type SigningBackend, type SubscriptionId, Tag, type TagInput, type UnsignedEvent, UrlError, WasmPoisonedError, assertHex32, assertSecretKeyBytes, assertSubscriptionId, bytesToHex, canonicalizeFilter, canonicalizeFilters, classifyKind, createEventVerifier, createSubscriptionId, encodeClientMessage, encodeRelayMessage, eventAddress, filterFingerprint, finalizeEvent, firstTagValue, formatEventAddress, getDTag, getEventHash, getFilterLimit, getPublicKey, hexToBytes, isAddressableKind, isEphemeralKind, isHex32, isHex64, isMarkedFailed, isRegularKind, isReplaceableKind, isReplaceableWinner, isTag, itemCompare,
|
|
7
|
+
import { S as SUBSCRIPTION_ID_MAX_CHARS, _ as normalizeURL, a as classifyKind, b as SECRET_KEY_BYTES, c as isRegularKind, d as assertSecretKeyBytes, f as bytesToHex, g as normalizeRelayUrls, 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, u as assertHex32, v as EVENT_ID_BYTES, x as SIGNATURE_BYTES, y as PUBLIC_KEY_BYTES } from "./index-Hp26bgYG.mjs";
|
|
8
|
+
export { type ClientMessage, type CountResult, CryptoError, EVENT_ID_BYTES, type Event, type EventAddress, EventBuilder, type EventTemplate, EventValidationError, type EventVerifier, type Filter, HexError, Keys, Kind, type KindClassification, type KindName, type KnownKind, MessageError, NostrError, PUBLIC_KEY_BYTES, type ProfileMetadata, type PublicKey, type RelayMessage, SECRET_KEY_BYTES, SIGNATURE_BYTES, SUBSCRIPTION_ID_MAX_CHARS, SecretKey, type SecretKeyInput, type SerializedEventVerifier, type SigningBackend, type SubscriptionId, Tag, type TagInput, type UnsignedEvent, UrlError, WasmPoisonedError, assertHex32, assertSecretKeyBytes, assertSubscriptionId, bytesToHex, canonicalizeFilter, canonicalizeFilters, classifyKind, createEventVerifier, createSubscriptionId, encodeClientMessage, encodeRelayMessage, eventAddress, filterFingerprint, finalizeEvent, firstTagValue, formatEventAddress, getDTag, getEventHash, getFilterLimit, getPublicKey, hexToBytes, isAddressableKind, isEphemeralKind, isHex32, isHex64, isMarkedFailed, isRegularKind, isReplaceableKind, isReplaceableWinner, isTag, itemCompare, matchFilter, matchFilters, mergeCountHll, normalizeRelayUrls, normalizeURL, parseClientMessage, parseEventAddress, parseRelayMessage, publicKeyFromHex, serializeEvent, signEvent, signedMatchesUnsigned, sortEvents, sortedEvents, tagName, tagValue, toSecretKey, validateEvent, validateSignedEvent, verifyEvent };
|
package/dist/core.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { C as EVENT_ID_BYTES, D as SUBSCRIPTION_ID_MAX_CHARS, E as SIGNATURE_BYTES, T as SECRET_KEY_BYTES, _ as MessageError, a as hexToBytes, b as WasmPoisonedError, g as HexError, h as EventValidationError, i as bytesToHex, l as normalizeRelayUrls, m as CryptoError, n as assertHex32, o as isHex32, r as assertSecretKeyBytes, s as isHex64, u as normalizeURL, v as NostrError, w as PUBLIC_KEY_BYTES, y as UrlError } from "./util-DMF9AIO0.mjs";
|
|
2
|
-
import { a as isRegularKind, i as isEphemeralKind, n as classifyKind, o as isReplaceableKind, r as isAddressableKind, t as Kind } from "./kind-
|
|
3
|
-
import { C as
|
|
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,
|
|
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
|
-
export { CryptoError, EVENT_ID_BYTES, EventBuilder, EventValidationError, HexError, Keys, Kind, MessageError, NostrError, PUBLIC_KEY_BYTES, SECRET_KEY_BYTES, SIGNATURE_BYTES, SUBSCRIPTION_ID_MAX_CHARS, SecretKey, Tag, UrlError, WasmPoisonedError, assertHex32, assertSecretKeyBytes, assertSubscriptionId, bytesToHex, canonicalizeFilter, canonicalizeFilters, classifyKind, createEventVerifier, createSubscriptionId, encodeClientMessage, encodeRelayMessage, eventAddress, filterFingerprint, finalizeEvent, firstTagValue, formatEventAddress, getDTag, getEventHash, getFilterLimit, getPublicKey, hexToBytes, isAddressableKind, isEphemeralKind, isHex32, isHex64, isMarkedFailed, isRegularKind, isReplaceableKind, isReplaceableWinner, isTag, itemCompare,
|
|
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, r as isMarkedFailed, v as firstTagValue, w as tagValue, x as isTag, y as formatEventAddress } from "./event-C2eLiPpV.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-DY_HEIpY.mjs";
|
|
5
|
+
import { n as verifyEvent, t as createEventVerifier } from "./verifier-uC_jd-Nw.mjs";
|
|
6
|
+
import { t as EventBuilder } from "./builder-CVRmUeNm.mjs";
|
|
7
|
+
import { a as matchFilter, i as getFilterLimit, n as canonicalizeFilters, o as matchFilters, r as filterFingerprint, t as canonicalizeFilter } from "./filter-TrF2LEoy.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-Rd5Z_17h.mjs";
|
|
9
|
+
export { CryptoError, EVENT_ID_BYTES, EventBuilder, EventValidationError, HexError, Keys, Kind, MessageError, NostrError, PUBLIC_KEY_BYTES, SECRET_KEY_BYTES, SIGNATURE_BYTES, SUBSCRIPTION_ID_MAX_CHARS, SecretKey, Tag, UrlError, WasmPoisonedError, assertHex32, assertSecretKeyBytes, assertSubscriptionId, bytesToHex, canonicalizeFilter, canonicalizeFilters, classifyKind, createEventVerifier, createSubscriptionId, encodeClientMessage, encodeRelayMessage, eventAddress, filterFingerprint, finalizeEvent, firstTagValue, formatEventAddress, getDTag, getEventHash, getFilterLimit, getPublicKey, hexToBytes, isAddressableKind, isEphemeralKind, isHex32, isHex64, isMarkedFailed, isRegularKind, isReplaceableKind, isReplaceableWinner, isTag, itemCompare, matchFilter, matchFilters, mergeCountHll, normalizeRelayUrls, normalizeURL, parseClientMessage, parseEventAddress, parseRelayMessage, publicKeyFromHex, serializeEvent, signEvent, signedMatchesUnsigned, sortEvents, sortedEvents, tagName, tagValue, toSecretKey, validateEvent, validateSignedEvent, verifyEvent };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as isRecord, h as EventValidationError, i as bytesToHex, o as isHex32, p as utf8Encoder, s as isHex64 } from "./util-DMF9AIO0.mjs";
|
|
2
|
-
import { o as isReplaceableKind, r as isAddressableKind } from "./kind-
|
|
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
|
|
5
5
|
/** Type guard: a non-empty array of strings. */
|
|
@@ -65,8 +65,10 @@ function parseEventAddress(value) {
|
|
|
65
65
|
if (first <= 0) return;
|
|
66
66
|
const second = value.indexOf(":", first + 1);
|
|
67
67
|
if (second === -1) return;
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
68
|
+
const kindText = value.slice(0, first);
|
|
69
|
+
if (!/^\d{1,5}$/.test(kindText)) return;
|
|
70
|
+
const kind = Number(kindText);
|
|
71
|
+
if (kind > 65535) return;
|
|
70
72
|
const pubkey = value.slice(first + 1, second).toLowerCase();
|
|
71
73
|
if (!isHex32(pubkey)) return;
|
|
72
74
|
return {
|
|
@@ -132,6 +134,14 @@ function validateSignedEvent(event) {
|
|
|
132
134
|
*/
|
|
133
135
|
function serializeEvent(event) {
|
|
134
136
|
if (!validateEvent(event)) throw new EventValidationError("cannot serialize event with invalid shape");
|
|
137
|
+
return serializeValidatedEvent(event);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Canonical serialization for an event already known valid (after {@link validateEvent} or
|
|
141
|
+
* {@link validateSignedEvent}); identical output to {@link serializeEvent} without re-walking the
|
|
142
|
+
* structural checks.
|
|
143
|
+
*/
|
|
144
|
+
function serializeValidatedEvent(event) {
|
|
135
145
|
return JSON.stringify([
|
|
136
146
|
0,
|
|
137
147
|
event.pubkey,
|
|
@@ -197,6 +207,6 @@ function signedMatchesUnsigned(signed, unsigned) {
|
|
|
197
207
|
return true;
|
|
198
208
|
}
|
|
199
209
|
//#endregion
|
|
200
|
-
export {
|
|
210
|
+
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 };
|
|
201
211
|
|
|
202
|
-
//# sourceMappingURL=event-
|
|
212
|
+
//# sourceMappingURL=event-C2eLiPpV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-C2eLiPpV.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/** 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 if (relay !== undefined) {\n t.push(relay);\n }\n if (marker !== undefined) {\n t.push(marker);\n }\n if (pubkey !== undefined) {\n t.push(pubkey.toLowerCase());\n }\n return t;\n },\n p(pubkey: string, relay?: string, petname?: string): Tag {\n const t: string[] = [\"p\", pubkey.toLowerCase()];\n if (relay !== undefined) {\n t.push(relay);\n }\n if (petname !== undefined) {\n t.push(petname);\n }\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 { isHex32, isHex64, isRecord, utf8Encoder, bytesToHex } 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.isInteger(event[\"kind\"]) ||\n event[\"kind\"] < 0 ||\n event[\"kind\"] > 65535\n ) {\n return false;\n }\n if (typeof event[\"content\"] !== \"string\") {\n return false;\n }\n if (typeof event[\"created_at\"] !== \"number\" || !Number.isInteger(event[\"created_at\"])) {\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 }\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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YAAY,OAAO,UAAU,CAAC,CAAC;AAC1D;;AAGA,SAAS,WAAW,GAAmB,GAA2B;CAChE,IAAI,EAAE,KAAK,EAAE,IACX,OAAO;CAET,IAAI,EAAE,KAAK,EAAE,IACX,OAAO;CAET,OAAO;AACT;;;;;AAMA,SAAgB,kBACd,GACA,GACQ;CACR,IAAI,EAAE,eAAe,EAAE,YACrB,OAAO,EAAE,aAAa,EAAE;CAE1B,OAAO,WAAW,GAAG,CAAC;AACxB;;;;;AAMA,SAAgB,WAAW,QAA0B;CACnD,OAAO,OAAO,KAAK,iBAAiB;AACtC;;AAGA,SAAgB,aAAa,QAAuC;CAClE,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,KAAK,iBAAiB;AAC3C;;;;;AAMA,SAAgB,YACd,GACA,GACQ;CACR,IAAI,EAAE,eAAe,EAAE,YACrB,OAAO,EAAE,aAAa,EAAE;CAE1B,OAAO,WAAW,GAAG,CAAC;AACxB;;;;;AAMA,SAAgB,oBACd,WACA,WACS;CACT,IAAI,UAAU,eAAe,UAAU,YACrC,OAAO,UAAU,aAAa,UAAU;CAE1C,OAAO,UAAU,KAAK,UAAU;AAClC;;AAGA,SAAgB,sBAAsB,QAAe,UAAkC;CACrF,IAAI,OAAO,SAAS,SAAS,MAC3B,OAAO;CAET,IAAI,OAAO,YAAY,SAAS,SAC9B,OAAO;CAET,IAAI,OAAO,eAAe,SAAS,YACjC,OAAO;CAET,IAAI,KAAK,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"}
|
|
@@ -63,8 +63,6 @@ type Event = UnsignedEvent & {
|
|
|
63
63
|
readonly id: string;
|
|
64
64
|
readonly sig: string;
|
|
65
65
|
};
|
|
66
|
-
declare function markVerified(event: Event): void;
|
|
67
|
-
declare function markUnverified(event: Event): void;
|
|
68
66
|
declare function isMarkedFailed(event: Event): boolean;
|
|
69
67
|
/** Structural validation of an unsigned event (no crypto). */
|
|
70
68
|
declare function validateEvent(event: unknown): event is UnsignedEvent;
|
|
@@ -109,5 +107,5 @@ declare function isReplaceableWinner(candidate: {
|
|
|
109
107
|
/** True when a signed event is the signed form of `unsigned` (kind/tags/content/time/pubkey). */
|
|
110
108
|
declare function signedMatchesUnsigned(signed: Event, unsigned: UnsignedEvent): boolean;
|
|
111
109
|
//#endregion
|
|
112
|
-
export {
|
|
113
|
-
//# sourceMappingURL=event-
|
|
110
|
+
export { tagName as C, parseEventAddress as S, eventAddress as _, isMarkedFailed as a, getDTag as b, serializeEvent as c, sortedEvents as d, validateEvent as f, TagInput as g, Tag as h, getEventHash as i, signedMatchesUnsigned as l, EventAddress as m, EventTemplate as n, isReplaceableWinner as o, validateSignedEvent as p, UnsignedEvent as r, itemCompare as s, Event as t, sortEvents as u, firstTagValue as v, tagValue as w, isTag as x, formatEventAddress as y };
|
|
111
|
+
//# sourceMappingURL=event-j3BwI5dF.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Event } from "./event-
|
|
1
|
+
import { t as Event } from "./event-j3BwI5dF.mjs";
|
|
2
2
|
//#region src/core/filter.d.ts
|
|
3
3
|
/** NIP-01 filter object (immutable-friendly; callers may still pass plain objects). */
|
|
4
4
|
type Filter = {
|
|
@@ -16,8 +16,6 @@ type Filter = {
|
|
|
16
16
|
declare function matchFilter(filter: Filter, event: Event): boolean;
|
|
17
17
|
/** True when the event matches any of the filters (NIP-01 OR semantics). */
|
|
18
18
|
declare function matchFilters(filters: ReadonlyArray<Filter>, event: Event): boolean;
|
|
19
|
-
/** Merge filters by unioning list fields; returns a new plain object. */
|
|
20
|
-
declare function mergeFilters(...filters: Filter[]): Filter;
|
|
21
19
|
/**
|
|
22
20
|
* Intrinsic upper bound implied by the filter alone. Returns a positive integer, or `Infinity` when
|
|
23
21
|
* unbounded.
|
|
@@ -33,5 +31,5 @@ declare function canonicalizeFilters(filters: ReadonlyArray<Filter>): Filter[];
|
|
|
33
31
|
*/
|
|
34
32
|
declare function filterFingerprint(filters: ReadonlyArray<Filter>): string;
|
|
35
33
|
//#endregion
|
|
36
|
-
export { getFilterLimit as a,
|
|
37
|
-
//# sourceMappingURL=filter-
|
|
34
|
+
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-CfEgQBXt.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as isReplaceableKind, r as isAddressableKind } from "./kind-
|
|
1
|
+
import { o as isReplaceableKind, r as isAddressableKind } from "./kind-D8fENiiL.mjs";
|
|
2
2
|
//#region src/core/filter.ts
|
|
3
3
|
/** Local NIP-01 match. `search` is ignored; relays interpret NIP-50. */
|
|
4
4
|
function matchFilter(filter, event) {
|
|
@@ -27,39 +27,6 @@ function matchFilters(filters, event) {
|
|
|
27
27
|
for (const filter of filters) if (matchFilter(filter, event)) return true;
|
|
28
28
|
return false;
|
|
29
29
|
}
|
|
30
|
-
/** Merge filters by unioning list fields; returns a new plain object. */
|
|
31
|
-
function mergeFilters(...filters) {
|
|
32
|
-
const result = {};
|
|
33
|
-
const mergeList = (property, values) => {
|
|
34
|
-
if (values === void 0) return;
|
|
35
|
-
const existing = result[property];
|
|
36
|
-
const list = Array.isArray(existing) ? [...existing] : [];
|
|
37
|
-
for (const value of values) if (!list.includes(value)) list.push(value);
|
|
38
|
-
result[property] = list;
|
|
39
|
-
};
|
|
40
|
-
const mergeMax = (property, value) => {
|
|
41
|
-
if (value === void 0) return;
|
|
42
|
-
const prev = result[property];
|
|
43
|
-
if (typeof prev !== "number" || value > prev) result[property] = value;
|
|
44
|
-
};
|
|
45
|
-
for (const filter of filters) {
|
|
46
|
-
mergeList("ids", filter.ids);
|
|
47
|
-
mergeList("authors", filter.authors);
|
|
48
|
-
mergeList("kinds", filter.kinds);
|
|
49
|
-
for (const key of Object.keys(filter)) {
|
|
50
|
-
if (!key.startsWith("#")) continue;
|
|
51
|
-
mergeList(key, filter[key]);
|
|
52
|
-
}
|
|
53
|
-
mergeMax("limit", filter.limit);
|
|
54
|
-
mergeMax("until", filter.until);
|
|
55
|
-
if (filter.since !== void 0) {
|
|
56
|
-
const prev = result["since"];
|
|
57
|
-
if (typeof prev !== "number" || filter.since < prev) result["since"] = filter.since;
|
|
58
|
-
}
|
|
59
|
-
if (filter.search !== void 0) result["search"] = filter.search;
|
|
60
|
-
}
|
|
61
|
-
return result;
|
|
62
|
-
}
|
|
63
30
|
/**
|
|
64
31
|
* Intrinsic upper bound implied by the filter alone. Returns a positive integer, or `Infinity` when
|
|
65
32
|
* unbounded.
|
|
@@ -115,6 +82,6 @@ function filterFingerprint(filters) {
|
|
|
115
82
|
return `[${parts.join(",")}]`;
|
|
116
83
|
}
|
|
117
84
|
//#endregion
|
|
118
|
-
export { matchFilter as a, getFilterLimit as i, canonicalizeFilters as n, matchFilters as o, filterFingerprint as r,
|
|
85
|
+
export { matchFilter as a, getFilterLimit as i, canonicalizeFilters as n, matchFilters as o, filterFingerprint as r, canonicalizeFilter as t };
|
|
119
86
|
|
|
120
|
-
//# sourceMappingURL=filter-
|
|
87
|
+
//# sourceMappingURL=filter-TrF2LEoy.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-TrF2LEoy.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/** 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 if (!key.startsWith(\"#\")) {\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, filter.ids.length);\n }\n if (filter.limit !== undefined) {\n limit = Math.min(limit, filter.limit);\n }\n\n if (filter.kinds && filter.authors) {\n const allReplaceable = filter.kinds.every((k) => isReplaceableKind(k) || isAddressableKind(k));\n if (allReplaceable) {\n const dTags = filter[\"#d\"];\n const perAuthor = dTags && dTags.length > 0 ? dTags.length : 1;\n limit = Math.min(limit, filter.authors.length * filter.kinds.length * perAuthor);\n }\n }\n\n return limit;\n}\n\nconst HEX_LIST_KEYS = new Set([\"ids\", \"authors\", \"#e\", \"#p\"]);\n\n/** Lowercase hex lists and sort every array. Omits undefined so `[]` stays distinct from missing. */\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 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] = value.map((v) => String(v).toLowerCase()).sort();\n } else if (key === \"kinds\") {\n out[key] = value.map(Number).sort((a, b) => a - b);\n } else {\n out[key] = 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();\n return `[${parts.join(\",\")}]`;\n}\n"],"mappings":";;;AAiBA,SAAgB,YAAY,QAAgB,OAAuB;CACjE,IAAI,OAAO,OAAO,CAAC,OAAO,IAAI,MAAM,OAAO,GAAG,YAAY,MAAM,MAAM,EAAE,GACtE,OAAO;CAET,IAAI,OAAO,SAAS,CAAC,OAAO,MAAM,SAAS,MAAM,IAAI,GACnD,OAAO;CAET,IAAI,OAA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
2
|
-
import { t as Kind } from "./kind-
|
|
3
|
-
import { a as isReplaceableWinner } from "./event-
|
|
2
|
+
import { t as Kind } from "./kind-D8fENiiL.mjs";
|
|
3
|
+
import { a as isReplaceableWinner } from "./event-C2eLiPpV.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-5ezg0Quo.mjs.map
|
|
@@ -0,0 +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;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import { t as Event } from "./event-
|
|
2
|
-
import { t as Filter } from "./filter-
|
|
3
|
-
import { t as RelayListItem } from "./nip65-
|
|
1
|
+
import { t as Event } from "./event-j3BwI5dF.mjs";
|
|
2
|
+
import { t as Filter } from "./filter-CfEgQBXt.mjs";
|
|
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. */
|
|
6
6
|
type PubkeyRoutes = {
|
|
@@ -34,7 +34,10 @@ type RoutedFilter = {
|
|
|
34
34
|
readonly remainder?: Filter | undefined;
|
|
35
35
|
};
|
|
36
36
|
type GossipOptions = {
|
|
37
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Max relays kept per direction; the first N in list order win (NIP-65 defines no ranking).
|
|
39
|
+
* Default 4.
|
|
40
|
+
*/
|
|
38
41
|
maxRelaysPerPubkey?: number | undefined;
|
|
39
42
|
/**
|
|
40
43
|
* Max pubkeys with tracked routes; the map is LRU — writes and lookups refresh recency, and
|
|
@@ -79,4 +82,4 @@ declare class Gossip {
|
|
|
79
82
|
}
|
|
80
83
|
//#endregion
|
|
81
84
|
export { RoutedFilter as i, GossipOptions as n, PubkeyRoutes as r, Gossip as t };
|
|
82
|
-
//# sourceMappingURL=gossip-
|
|
85
|
+
//# sourceMappingURL=gossip-BWb9HmfK.d.mts.map
|
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-BWb9HmfK.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-5ezg0Quo.mjs";
|
|
2
2
|
export { Gossip };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-CuazNRIP.mjs","names":[],"sources":["../src/nips/http.ts"],"sourcesContent":["/**\n * Shared nips HTTP primitive. Not a pack entry (core has zero network). Callers never pass\n * `redirect`; sendManual always sets `\"manual\"`.\n */\n\nexport type
|
|
1
|
+
{"version":3,"file":"http-CuazNRIP.mjs","names":[],"sources":["../src/nips/http.ts"],"sourcesContent":["/**\n * Shared nips HTTP primitive. Not a pack entry (core has zero network). Callers never pass\n * `redirect`; sendManual always sets `\"manual\"`.\n */\n\nexport type ManualFetchInit = {\n method?: string;\n headers?: Record<string, string>;\n // oxlint-disable-next-line no-restricted-types -- mirrors RequestInit.body, which is nullable\n body?: Blob | FormData | string | null;\n signal?: AbortSignal | undefined;\n /**\n * Always `\"manual\"`: NIP-05, NIP-11 and Blossom responses must never be followed through\n * redirects. Adapters must forward this to their underlying fetch implementation.\n */\n redirect: \"manual\";\n};\n\nexport type ManualFetch = (\n url: string,\n init?: ManualFetchInit,\n) => Promise<{\n ok: boolean;\n status: number;\n // oxlint-disable-next-line no-restricted-types -- mirrors Headers.get, which returns null\n headers: { get: (name: string) => string | null };\n json: () => Promise<unknown>;\n arrayBuffer: () => Promise<ArrayBuffer>;\n}>;\n\ntype ManualInit = Omit<ManualFetchInit, \"redirect\">;\n\nexport function requireGlobalFetch(missing: () => Error): ManualFetch {\n if (typeof globalThis.fetch !== \"function\") {\n throw missing();\n }\n const fetchImpl = globalThis.fetch.bind(globalThis);\n // RequestInit.signal is AbortSignal | null and rejects explicit undefined under\n // exactOptionalPropertyTypes; normalize it for the real fetch.\n return async (url, init) =>\n fetchImpl(url, init === undefined ? init : { ...init, signal: init.signal ?? null });\n}\n\n/** Always sets redirect:manual. Shared by fetchManual and headStatus. */\nexport async function sendManual(\n fetchImpl: ManualFetch,\n url: string,\n init: ManualInit,\n): Promise<Awaited<ReturnType<ManualFetch>>> {\n return fetchImpl(url, { ...init, redirect: \"manual\" });\n}\n\nexport async function fetchManual(\n fetchImpl: ManualFetch,\n url: string,\n init: ManualInit,\n wrapNetwork: (err: unknown) => Error,\n): Promise<Awaited<ReturnType<ManualFetch>>> {\n try {\n return await sendManual(fetchImpl, url, init);\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n throw error;\n }\n throw wrapNetwork(error);\n }\n}\n"],"mappings":";AAgCA,SAAgB,mBAAmB,SAAmC;CACpE,IAAI,OAAO,WAAW,UAAU,YAC9B,MAAM,QAAQ;CAEhB,MAAM,YAAY,WAAW,MAAM,KAAK,UAAU;CAGlD,OAAO,OAAO,KAAK,SACjB,UAAU,KAAK,SAAS,KAAA,IAAY,OAAO;EAAE,GAAG;EAAM,QAAQ,KAAK,UAAU;CAAK,CAAC;AACvF;;AAGA,eAAsB,WACpB,WACA,KACA,MAC2C;CAC3C,OAAO,UAAU,KAAK;EAAE,GAAG;EAAM,UAAU;CAAS,CAAC;AACvD;AAEA,eAAsB,YACpB,WACA,KACA,MACA,aAC2C;CAC3C,IAAI;EACF,OAAO,MAAM,WAAW,WAAW,KAAK,IAAI;CAC9C,SAAS,OAAO;EACd,IAAI,iBAAiB,SAAS,MAAM,SAAS,cAC3C,MAAM;EAER,MAAM,YAAY,KAAK;CACzB;AACF"}
|
|
@@ -3,12 +3,18 @@
|
|
|
3
3
|
* Shared nips HTTP primitive. Not a pack entry (core has zero network). Callers never pass
|
|
4
4
|
* `redirect`; sendManual always sets `"manual"`.
|
|
5
5
|
*/
|
|
6
|
-
type
|
|
6
|
+
type ManualFetchInit = {
|
|
7
7
|
method?: string;
|
|
8
8
|
headers?: Record<string, string>;
|
|
9
9
|
body?: Blob | FormData | string | null;
|
|
10
10
|
signal?: AbortSignal | undefined;
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Always `"manual"`: NIP-05, NIP-11 and Blossom responses must never be followed through
|
|
13
|
+
* redirects. Adapters must forward this to their underlying fetch implementation.
|
|
14
|
+
*/
|
|
15
|
+
redirect: "manual";
|
|
16
|
+
};
|
|
17
|
+
type ManualFetch = (url: string, init?: ManualFetchInit) => Promise<{
|
|
12
18
|
ok: boolean;
|
|
13
19
|
status: number;
|
|
14
20
|
headers: {
|
|
@@ -19,4 +25,4 @@ type ManualFetch = (url: string, init?: {
|
|
|
19
25
|
}>;
|
|
20
26
|
//#endregion
|
|
21
27
|
export { ManualFetch as t };
|
|
22
|
-
//# sourceMappingURL=http-
|
|
28
|
+
//# sourceMappingURL=http-kwWG-V1X.d.mts.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { t as Event } from "./event-
|
|
2
|
-
import { n as ProfileMetadata } from "./builder-
|
|
3
|
-
import { t as RelayListItem } from "./nip65-
|
|
4
|
-
import { t as Gossip } from "./gossip-
|
|
1
|
+
import { t as Event } from "./event-j3BwI5dF.mjs";
|
|
2
|
+
import { n as ProfileMetadata } from "./builder-GBddxj8i.mjs";
|
|
3
|
+
import { t as RelayListItem } from "./nip65-BL79HI8N.mjs";
|
|
4
|
+
import { t as Gossip } from "./gossip-BWb9HmfK.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-Bfe3Tu40.mjs";
|
|
7
|
+
import { r as OutboxBound, t as EventStore } from "./types-Ccox7-5v.mjs";
|
|
8
|
+
import { t as ReactiveEventStore } from "./reactive-X4p6nABy.mjs";
|
|
9
9
|
import { i as EventPointer, t as AddressPointer } from "./nip19-DpPN17bY.mjs";
|
|
10
|
-
import { t as MuteItem } from "./nip51-
|
|
10
|
+
import { t as MuteItem } from "./nip51-O_vhOiK2.mjs";
|
|
11
11
|
//#region src/loaders/event.d.ts
|
|
12
12
|
type EventRef = string | EventPointer | AddressPointer;
|
|
13
13
|
/**
|
|
@@ -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-B1fLejg4.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as EventTemplate, r as UnsignedEvent, t as Event } from "./event-
|
|
2
|
-
import { i as SecretKeyInput, t as Keys } from "./key-
|
|
3
|
-
import { t as Filter } from "./filter-
|
|
1
|
+
import { n as EventTemplate, r as UnsignedEvent, t as Event } from "./event-j3BwI5dF.mjs";
|
|
2
|
+
import { i as SecretKeyInput, t as Keys } from "./key-CyKN1RTi.mjs";
|
|
3
|
+
import { t as Filter } from "./filter-CfEgQBXt.mjs";
|
|
4
4
|
import { a as NostrError } from "./error-BquXDmIN.mjs";
|
|
5
|
-
import { t as NostrSigner } from "./types-
|
|
5
|
+
import { t as NostrSigner } from "./types-BJ4wZ7JJ.mjs";
|
|
6
6
|
import { n as ClientMetadata, t as BunkerPointer } from "./nip46-BHaxC9TZ.mjs";
|
|
7
7
|
//#region src/signer/error.d.ts
|
|
8
8
|
/**
|
|
@@ -74,7 +74,7 @@ type Nip46SubscribeOptions = {
|
|
|
74
74
|
};
|
|
75
75
|
/**
|
|
76
76
|
* Structural relay transport for NIP-46 RPC. Satisfied by {@link import("../relay/pool.ts").Pool};
|
|
77
|
-
* constructed above the signer layer so `signer` never imports `relay` (
|
|
77
|
+
* constructed above the signer layer so `signer` never imports `relay` (see AGENTS.md).
|
|
78
78
|
*/
|
|
79
79
|
type Nip46Transport = {
|
|
80
80
|
subscribe: (relays: ReadonlyArray<string>, filters: ReadonlyArray<Filter>, opts?: Nip46SubscribeOptions) => {
|
|
@@ -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-C0mFpelb.d.mts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as Event } from "./event-
|
|
2
|
-
import { t as Filter } from "./filter-
|
|
1
|
+
import { t as Event } from "./event-j3BwI5dF.mjs";
|
|
2
|
+
import { t as Filter } from "./filter-CfEgQBXt.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-Bfe3Tu40.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-CLJEKFGd.d.mts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as Event } from "./event-
|
|
2
|
-
import { t as Filter } from "./filter-
|
|
3
|
-
import { i as PutResult, n as NegentropyItem, r as OutboxBound, t as EventStore } from "./types-
|
|
1
|
+
import { t as Event } from "./event-j3BwI5dF.mjs";
|
|
2
|
+
import { t as Filter } from "./filter-CfEgQBXt.mjs";
|
|
3
|
+
import { i as PutResult, n as NegentropyItem, r as OutboxBound, t as EventStore } from "./types-Ccox7-5v.mjs";
|
|
4
4
|
//#region src/storage/memory-index.d.ts
|
|
5
5
|
type MemoryIndexOptions = {
|
|
6
6
|
/**
|
|
@@ -124,6 +124,9 @@ type SqlValue = string | number | null | Uint8Array;
|
|
|
124
124
|
* start before the previous one settles, inside or outside a transaction — so drivers need not
|
|
125
125
|
* support overlapping statements on one connection.
|
|
126
126
|
*
|
|
127
|
+
* The store does not rely on per-connection PRAGMAs: tag rows are deleted explicitly, so `PRAGMA
|
|
128
|
+
* foreign_keys` may be off on any connection (including transaction connections).
|
|
129
|
+
*
|
|
127
130
|
* `expo-sqlite` maps onto this interface without changes to query code. Note that
|
|
128
131
|
* `withExclusiveTransactionAsync` resolves `void` and statements inside the exclusive transaction
|
|
129
132
|
* must run on the `txn` connection passed to its callback, not on `db` — the result is captured
|
|
@@ -185,4 +188,4 @@ declare class SqliteEventStore implements EventStore {
|
|
|
185
188
|
}
|
|
186
189
|
//#endregion
|
|
187
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 };
|
|
188
|
-
//# sourceMappingURL=index-
|
|
191
|
+
//# sourceMappingURL=index-CoX7SnO7.d.mts.map
|
|
@@ -36,7 +36,10 @@ declare function normalizeURL(url: string): string;
|
|
|
36
36
|
declare function normalizeRelayUrls(urls: Iterable<string>): string[];
|
|
37
37
|
//#endregion
|
|
38
38
|
//#region src/core/kind.d.ts
|
|
39
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* NIP-01 regular ranges verbatim; kinds outside every defined range are still stored like regular
|
|
41
|
+
* events (see {@link classifyKind}).
|
|
42
|
+
*/
|
|
40
43
|
declare function isRegularKind(kind: number): boolean;
|
|
41
44
|
/** Replaceable: latest per (pubkey, kind) wins. */
|
|
42
45
|
declare function isReplaceableKind(kind: number): boolean;
|
|
@@ -45,8 +48,12 @@ declare function isEphemeralKind(kind: number): boolean;
|
|
|
45
48
|
/** Addressable (parameterized replaceable): latest per (pubkey, kind, d-tag) wins. */
|
|
46
49
|
declare function isAddressableKind(kind: number): boolean;
|
|
47
50
|
/** NIP-01 kind classes: regular / replaceable / ephemeral / addressable. */
|
|
48
|
-
type KindClassification = "regular" | "replaceable" | "ephemeral" | "addressable"
|
|
49
|
-
/**
|
|
51
|
+
type KindClassification = "regular" | "replaceable" | "ephemeral" | "addressable";
|
|
52
|
+
/**
|
|
53
|
+
* Classify a kind number into its NIP-01 storage class. NIP-01 leaves kinds 45–999 and 40000+
|
|
54
|
+
* undefined (rather than forbidden); relays store them like regular events, so they classify
|
|
55
|
+
* `"regular"` here even though {@link isRegularKind} returns false for them.
|
|
56
|
+
*/
|
|
50
57
|
declare function classifyKind(kind: number): KindClassification;
|
|
51
58
|
/** Kind numbers used by this package. */
|
|
52
59
|
declare const Kind: {
|
|
@@ -85,4 +92,4 @@ type KindName = keyof typeof Kind;
|
|
|
85
92
|
type KnownKind = (typeof Kind)[KindName];
|
|
86
93
|
//#endregion
|
|
87
94
|
export { SUBSCRIPTION_ID_MAX_CHARS as S, normalizeURL as _, classifyKind as a, SECRET_KEY_BYTES as b, isRegularKind as c, assertSecretKeyBytes as d, bytesToHex as f, normalizeRelayUrls as g, isHex64 as h, KnownKind as i, isReplaceableKind as l, isHex32 as m, KindClassification as n, isAddressableKind as o, hexToBytes as p, KindName as r, isEphemeralKind as s, Kind as t, assertHex32 as u, EVENT_ID_BYTES as v, SIGNATURE_BYTES as x, PUBLIC_KEY_BYTES as y };
|
|
88
|
-
//# sourceMappingURL=index-
|
|
95
|
+
//# sourceMappingURL=index-Hp26bgYG.d.mts.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { n as EventTemplate, r as UnsignedEvent, t as Event } from "./event-
|
|
2
|
-
import { t as EventBuilder } from "./builder-
|
|
3
|
-
import { t as Filter } from "./filter-
|
|
4
|
-
import { t as Gossip } from "./gossip-
|
|
1
|
+
import { n as EventTemplate, r as UnsignedEvent, t as Event } from "./event-j3BwI5dF.mjs";
|
|
2
|
+
import { t as EventBuilder } from "./builder-GBddxj8i.mjs";
|
|
3
|
+
import { t as Filter } from "./filter-CfEgQBXt.mjs";
|
|
4
|
+
import { t as Gossip } from "./gossip-BWb9HmfK.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-
|
|
10
|
-
import { a as Rumor } from "./nip59-
|
|
11
|
-
import { i as ReplyTo, r as Recipient } from "./nip17-
|
|
12
|
-
import { t as NostrSigner } from "./types-
|
|
6
|
+
import { _ as Closer, a as PoolFetchResult, n as Pool, o as PoolOptions, s as PoolPublishResult } from "./pool-Bfe3Tu40.mjs";
|
|
7
|
+
import { t as EventStore } from "./types-Ccox7-5v.mjs";
|
|
8
|
+
import { t as ReactiveEventStore } from "./reactive-X4p6nABy.mjs";
|
|
9
|
+
import { a as OutboxFeed, n as Loaders } from "./index-B1fLejg4.mjs";
|
|
10
|
+
import { a as Rumor } from "./nip59-CdDoJptA.mjs";
|
|
11
|
+
import { i as ReplyTo, r as Recipient } from "./nip17-B7MI82Iq.mjs";
|
|
12
|
+
import { t as NostrSigner } from "./types-BJ4wZ7JJ.mjs";
|
|
13
13
|
import { t as StorageError } from "./error-BD_0QFKT.mjs";
|
|
14
14
|
//#region src/client/types.d.ts
|
|
15
15
|
/** Direction of a {@link Client.sync} run: upload, download, or both. */
|
|
@@ -215,9 +215,17 @@ declare class Client {
|
|
|
215
215
|
* function.
|
|
216
216
|
*/
|
|
217
217
|
on<K extends keyof ClientEventMap>(type: K, listener: (err: ClientEventMap[K]) => void): () => void;
|
|
218
|
-
/**
|
|
218
|
+
/**
|
|
219
|
+
* Ingest one inbound event: index (with relay URL) → meta → persistence. The event must carry a
|
|
220
|
+
* valid signature; {@link EventValidationError} is thrown otherwise. Events delivered by relay
|
|
221
|
+
* subscriptions are already verified, so this is a WeakSet cache hit on those paths.
|
|
222
|
+
*/
|
|
219
223
|
observe(event: Event, relayUrl?: string): void;
|
|
220
|
-
/**
|
|
224
|
+
/**
|
|
225
|
+
* Ingest many events (deduped by id, order preserved) as one persist batch. Every event must
|
|
226
|
+
* carry a valid signature — all are verified before anything is ingested, so a batch is
|
|
227
|
+
* all-or-nothing.
|
|
228
|
+
*/
|
|
221
229
|
observeAll(events: ReadonlyArray<Event>): void;
|
|
222
230
|
/**
|
|
223
231
|
* Explicitly load kind:10002 and kind:10050 lists for pubkeys and feed gossip. Does not
|
|
@@ -282,4 +290,4 @@ declare class Client {
|
|
|
282
290
|
}
|
|
283
291
|
//#endregion
|
|
284
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 };
|
|
285
|
-
//# sourceMappingURL=index-
|
|
293
|
+
//# sourceMappingURL=index-uCYwXaaP.d.mts.map
|