@qntx/nostr 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abort-Ba8tDrOI.mjs +38 -0
- package/dist/abort-Ba8tDrOI.mjs.map +1 -0
- package/dist/{builder-BphJa-Y-.d.mts → builder-BWn55Paf.d.mts} +20 -14
- package/dist/{builder-q0VsvnYE.mjs → builder-CyrGKRVP.mjs} +32 -16
- package/dist/builder-CyrGKRVP.mjs.map +1 -0
- package/dist/{client-Bd8B1mYm.mjs → client-BWsX9Cv1.mjs} +354 -195
- package/dist/client-BWsX9Cv1.mjs.map +1 -0
- package/dist/client.d.mts +1 -1
- package/dist/client.mjs +1 -1
- package/dist/core.d.mts +8 -8
- package/dist/core.mjs +8 -9
- package/dist/error-BW7re1UN.d.mts +9 -0
- package/dist/error-B__OMBRY.mjs +14 -0
- package/dist/error-B__OMBRY.mjs.map +1 -0
- package/dist/{error-WEFS-R-4.d.mts → error-CR8Urc84.d.mts} +20 -8
- package/dist/{error-CwBxle6N.mjs → error-DrEIM7FO.mjs} +5 -3
- package/dist/error-DrEIM7FO.mjs.map +1 -0
- package/dist/{event-CzoQEFMF.mjs → event-D8Nfoh4K.mjs} +40 -32
- package/dist/event-D8Nfoh4K.mjs.map +1 -0
- package/dist/{event-B5D2jxt_.d.mts → event-fU3Y01PR.d.mts} +23 -20
- package/dist/{filter-BxwjEkZp.mjs → filter-BQl3GlHt.mjs} +42 -35
- package/dist/filter-BQl3GlHt.mjs.map +1 -0
- package/dist/filter-C0IMByE3.d.mts +37 -0
- package/dist/{gossip-C5RVB1UB.d.mts → gossip-BRQwIM_q.d.mts} +25 -23
- package/dist/{gossip-3xkRRCm_.mjs → gossip-oloDMWEj.mjs} +52 -34
- package/dist/gossip-oloDMWEj.mjs.map +1 -0
- package/dist/gossip.d.mts +1 -1
- package/dist/gossip.mjs +1 -1
- package/dist/{http-6vevbBlu.d.mts → http-C4HwIu4B.d.mts} +7 -7
- package/dist/{http-D2rhokZo.mjs → http-CuazNRIP.mjs} +10 -6
- package/dist/http-CuazNRIP.mjs.map +1 -0
- package/dist/index-B425CAcQ.d.mts +328 -0
- package/dist/index-BVyfUBuG.d.mts +181 -0
- package/dist/{index-BYMnhRIC.d.mts → index-Ba7bJ7DD.d.mts} +68 -50
- package/dist/{index-DaRyjo7O.d.mts → index-Boe8FshM.d.mts} +13 -7
- package/dist/index-CUIvFQdE.d.mts +73 -0
- package/dist/index-JdaS_uce.d.mts +207 -0
- package/dist/index.d.mts +22 -20
- package/dist/index.mjs +19 -18
- package/dist/{key-Dn-aX4x4.mjs → key-Bbtys6o7.mjs} +22 -14
- package/dist/key-Bbtys6o7.mjs.map +1 -0
- package/dist/{key-BiGxGLhg.d.mts → key-BlsYhN1V.d.mts} +9 -6
- package/dist/{kind-BLl4cLOc.mjs → kind-Cxwhhkx8.mjs} +2 -1
- package/dist/kind-Cxwhhkx8.mjs.map +1 -0
- package/dist/{loaders-BNQszDAn.mjs → loaders-o6YXB_Ri.mjs} +329 -305
- package/dist/loaders-o6YXB_Ri.mjs.map +1 -0
- package/dist/loaders.d.mts +3 -3
- package/dist/loaders.mjs +2 -2
- package/dist/memory-C2EVx0_O.mjs +46 -0
- package/dist/memory-C2EVx0_O.mjs.map +1 -0
- package/dist/{memory-BCmhZPek.mjs → memory-index-Do1mz0WF.mjs} +212 -82
- package/dist/memory-index-Do1mz0WF.mjs.map +1 -0
- package/dist/{message-C_Uj-Y-c.mjs → message-DcY6Fi9o.mjs} +38 -24
- package/dist/message-DcY6Fi9o.mjs.map +1 -0
- package/dist/{message-DJC-Jz6T.d.mts → message-iGPIqnn0.d.mts} +15 -8
- package/dist/{nip17-BWq-Kfq5.d.mts → nip17-DNEkz8rM.d.mts} +18 -17
- package/dist/{nip19-D7905oIv.d.mts → nip19-BevCJZsp.d.mts} +23 -3
- package/dist/{nip46-C_DoxiS_.d.mts → nip46-DDV4dC56.d.mts} +13 -12
- package/dist/{nip59-DljW_sYh.d.mts → nip59-zQgdLcEr.d.mts} +28 -25
- package/dist/{nip65-Di5hZRuV.d.mts → nip65-DBfh2smt.d.mts} +8 -3
- package/dist/{nip77-ByxlgoQO.d.mts → nip77-DH4RhS5r.d.mts} +9 -8
- package/dist/nips/blossom.d.mts +37 -37
- package/dist/nips/blossom.mjs +67 -52
- package/dist/nips/blossom.mjs.map +1 -1
- package/dist/nips/nip04.d.mts +2 -3
- package/dist/nips/nip04.mjs +6 -10
- package/dist/nips/nip04.mjs.map +1 -1
- package/dist/nips/nip05.d.mts +37 -43
- package/dist/nips/nip05.mjs +57 -57
- package/dist/nips/nip05.mjs.map +1 -1
- package/dist/nips/nip10.d.mts +18 -19
- package/dist/nips/nip10.mjs +76 -61
- package/dist/nips/nip10.mjs.map +1 -1
- package/dist/nips/nip11.d.mts +9 -8
- package/dist/nips/nip11.mjs +14 -11
- package/dist/nips/nip11.mjs.map +1 -1
- package/dist/nips/nip13.d.mts +9 -9
- package/dist/nips/nip13.mjs +15 -17
- package/dist/nips/nip13.mjs.map +1 -1
- package/dist/nips/nip17.d.mts +1 -1
- package/dist/nips/nip17.mjs +17 -12
- package/dist/nips/nip17.mjs.map +1 -1
- package/dist/nips/nip19.d.mts +1 -1
- package/dist/nips/nip19.mjs +52 -29
- package/dist/nips/nip19.mjs.map +1 -1
- package/dist/nips/nip21.d.mts +5 -6
- package/dist/nips/nip21.mjs +8 -7
- package/dist/nips/nip21.mjs.map +1 -1
- package/dist/nips/nip27.d.mts +7 -8
- package/dist/nips/nip27.mjs +26 -25
- package/dist/nips/nip27.mjs.map +1 -1
- package/dist/nips/nip42.d.mts +5 -6
- package/dist/nips/nip42.mjs +3 -3
- package/dist/nips/nip42.mjs.map +1 -1
- package/dist/nips/nip44.d.mts +24 -7
- package/dist/nips/nip44.mjs +25 -15
- package/dist/nips/nip44.mjs.map +1 -1
- package/dist/nips/nip46.d.mts +1 -1
- package/dist/nips/nip46.mjs +52 -49
- package/dist/nips/nip46.mjs.map +1 -1
- package/dist/nips/nip49.d.mts +8 -7
- package/dist/nips/nip49.mjs +16 -12
- package/dist/nips/nip49.mjs.map +1 -1
- package/dist/nips/nip51.d.mts +25 -27
- package/dist/nips/nip51.mjs +47 -36
- package/dist/nips/nip51.mjs.map +1 -1
- package/dist/nips/nip57.d.mts +12 -13
- package/dist/nips/nip57.mjs +35 -38
- package/dist/nips/nip57.mjs.map +1 -1
- package/dist/nips/nip59.d.mts +1 -1
- package/dist/nips/nip59.mjs +14 -18
- package/dist/nips/nip59.mjs.map +1 -1
- package/dist/nips/nip65.d.mts +1 -1
- package/dist/nips/nip65.mjs +11 -8
- package/dist/nips/nip65.mjs.map +1 -1
- package/dist/nips/nip77.d.mts +1 -1
- package/dist/nips/nip77.mjs +56 -34
- package/dist/nips/nip77.mjs.map +1 -1
- package/dist/nips/nip96.d.mts +21 -12
- package/dist/nips/nip96.mjs +59 -36
- package/dist/nips/nip96.mjs.map +1 -1
- package/dist/nips/nip98.d.mts +12 -12
- package/dist/nips/nip98.mjs +18 -19
- package/dist/nips/nip98.mjs.map +1 -1
- package/dist/{pool-C_j1OmBB.mjs → pool-XmAGaufS.mjs} +611 -487
- package/dist/pool-XmAGaufS.mjs.map +1 -0
- package/dist/pool-tEr7c5bG.d.mts +302 -0
- package/dist/reactive-DDlThDSZ.mjs +324 -0
- package/dist/reactive-DDlThDSZ.mjs.map +1 -0
- package/dist/reactive-DFpqtIf_.d.mts +66 -0
- package/dist/relay.d.mts +5 -4
- package/dist/relay.mjs +2 -2
- package/dist/report-CHld4uWj.mjs +32 -0
- package/dist/report-CHld4uWj.mjs.map +1 -0
- package/dist/{signer-CZ6K6FUc.mjs → signer-CKR9EHce.mjs} +107 -72
- package/dist/signer-CKR9EHce.mjs.map +1 -0
- package/dist/signer.d.mts +3 -3
- package/dist/signer.mjs +3 -2
- package/dist/storage-xXxLGCVb.mjs +1376 -0
- package/dist/storage-xXxLGCVb.mjs.map +1 -0
- package/dist/storage.d.mts +4 -4
- package/dist/storage.mjs +5 -4
- package/dist/store.d.mts +2 -0
- package/dist/store.mjs +2 -0
- package/dist/testing.d.mts +125 -0
- package/dist/testing.mjs +957 -0
- package/dist/testing.mjs.map +1 -0
- package/dist/types-2pCUprRU.d.mts +47 -0
- package/dist/types-CRQEk0Oi.d.mts +19 -0
- package/dist/util-LfQirgDk.mjs +113 -0
- package/dist/util-LfQirgDk.mjs.map +1 -0
- package/dist/wasm.d.mts +4 -4
- package/dist/wasm.mjs +54 -55
- package/dist/wasm.mjs.map +1 -1
- package/dist/websocket-CmeqvAkp.d.mts +27 -0
- package/package.json +31 -9
- package/dist/builder-q0VsvnYE.mjs.map +0 -1
- package/dist/client-Bd8B1mYm.mjs.map +0 -1
- package/dist/error-B49rbDzT.d.mts +0 -7
- package/dist/error-CwBxle6N.mjs.map +0 -1
- package/dist/error-DZEs5OuZ.mjs +0 -24
- package/dist/error-DZEs5OuZ.mjs.map +0 -1
- package/dist/event-CzoQEFMF.mjs.map +0 -1
- package/dist/filter-BxwjEkZp.mjs.map +0 -1
- package/dist/filter-DUEKP3q1.d.mts +0 -40
- package/dist/gossip-3xkRRCm_.mjs.map +0 -1
- package/dist/http-D2rhokZo.mjs.map +0 -1
- package/dist/index-C0C4e-Gn.d.mts +0 -55
- package/dist/index-DgOugrpF.d.mts +0 -275
- package/dist/index-EwL6fHLo.d.mts +0 -267
- package/dist/index-k2YhCgsh.d.mts +0 -57
- package/dist/key-Dn-aX4x4.mjs.map +0 -1
- package/dist/kind-BLl4cLOc.mjs.map +0 -1
- package/dist/loaders-BNQszDAn.mjs.map +0 -1
- package/dist/memory-BCmhZPek.mjs.map +0 -1
- package/dist/message-C_Uj-Y-c.mjs.map +0 -1
- package/dist/pool-C_j1OmBB.mjs.map +0 -1
- package/dist/pool-DhRi7l-b.d.mts +0 -297
- package/dist/signer-CZ6K6FUc.mjs.map +0 -1
- package/dist/storage-DOy0iLRE.mjs +0 -870
- package/dist/storage-DOy0iLRE.mjs.map +0 -1
- package/dist/types-BzyADqnw.d.mts +0 -19
- package/dist/types-Dn24TPFs.d.mts +0 -43
- package/dist/util-6tfLQ9JF.mjs +0 -73
- package/dist/util-6tfLQ9JF.mjs.map +0 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
//#region src/nips/http.d.ts
|
|
2
2
|
/**
|
|
3
|
-
* Shared nips HTTP primitive. Not a pack entry (core has zero network).
|
|
4
|
-
*
|
|
3
|
+
* Shared nips HTTP primitive. Not a pack entry (core has zero network). Callers never pass
|
|
4
|
+
* `redirect`; sendManual always sets `"manual"`.
|
|
5
5
|
*/
|
|
6
6
|
type ManualFetch = (url: string, init?: {
|
|
7
7
|
method?: string;
|
|
8
8
|
headers?: Record<string, string>;
|
|
9
9
|
body?: Blob | FormData | string | null;
|
|
10
|
-
signal?: AbortSignal;
|
|
10
|
+
signal?: AbortSignal | undefined;
|
|
11
11
|
}) => Promise<{
|
|
12
12
|
ok: boolean;
|
|
13
13
|
status: number;
|
|
14
14
|
headers: {
|
|
15
|
-
get(name: string)
|
|
15
|
+
get: (name: string) => string | null;
|
|
16
16
|
};
|
|
17
|
-
json()
|
|
18
|
-
arrayBuffer()
|
|
17
|
+
json: () => Promise<unknown>;
|
|
18
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
19
19
|
}>;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { ManualFetch as t };
|
|
22
|
-
//# sourceMappingURL=http-
|
|
22
|
+
//# sourceMappingURL=http-C4HwIu4B.d.mts.map
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
//#region src/nips/http.ts
|
|
2
2
|
function requireGlobalFetch(missing) {
|
|
3
3
|
if (typeof globalThis.fetch !== "function") throw missing();
|
|
4
|
-
|
|
4
|
+
const fetchImpl = globalThis.fetch.bind(globalThis);
|
|
5
|
+
return async (url, init) => fetchImpl(url, init === void 0 ? init : {
|
|
6
|
+
...init,
|
|
7
|
+
signal: init.signal ?? null
|
|
8
|
+
});
|
|
5
9
|
}
|
|
6
10
|
/** Always sets redirect:manual. Shared by fetchManual and headStatus. */
|
|
7
11
|
async function sendManual(fetchImpl, url, init) {
|
|
8
|
-
return
|
|
12
|
+
return fetchImpl(url, {
|
|
9
13
|
...init,
|
|
10
14
|
redirect: "manual"
|
|
11
15
|
});
|
|
@@ -13,12 +17,12 @@ async function sendManual(fetchImpl, url, init) {
|
|
|
13
17
|
async function fetchManual(fetchImpl, url, init, wrapNetwork) {
|
|
14
18
|
try {
|
|
15
19
|
return await sendManual(fetchImpl, url, init);
|
|
16
|
-
} catch (
|
|
17
|
-
if (
|
|
18
|
-
throw wrapNetwork(
|
|
20
|
+
} catch (error) {
|
|
21
|
+
if (error instanceof Error && error.name === "AbortError") throw error;
|
|
22
|
+
throw wrapNetwork(error);
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
25
|
//#endregion
|
|
22
26
|
export { requireGlobalFetch as n, sendManual as r, fetchManual as t };
|
|
23
27
|
|
|
24
|
-
//# sourceMappingURL=http-
|
|
28
|
+
//# sourceMappingURL=http-CuazNRIP.mjs.map
|
|
@@ -0,0 +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 ManualFetch = (\n url: string,\n init?: {\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) => 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 = NonNullable<Parameters<ManualFetch>[1]>;\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\" } as Parameters<ManualFetch>[1]);\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":";AAyBA,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,CAA+B;AACrF;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"}
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import { n as EventTemplate, r as UnsignedEvent, t as Event } from "./event-fU3Y01PR.mjs";
|
|
2
|
+
import { t as EventBuilder } from "./builder-BWn55Paf.mjs";
|
|
3
|
+
import { t as Filter } from "./filter-C0IMByE3.mjs";
|
|
4
|
+
import { t as Gossip } from "./gossip-BRQwIM_q.mjs";
|
|
5
|
+
import { a as NostrError } from "./error-CR8Urc84.mjs";
|
|
6
|
+
import { i as PoolPublishResult, t as Pool } from "./pool-tEr7c5bG.mjs";
|
|
7
|
+
import { t as WebSocketConstructor } from "./websocket-CmeqvAkp.mjs";
|
|
8
|
+
import { t as EventStore } from "./types-2pCUprRU.mjs";
|
|
9
|
+
import { t as ReactiveEventStore } from "./reactive-DFpqtIf_.mjs";
|
|
10
|
+
import { a as OutboxFeed, n as Loaders } from "./index-JdaS_uce.mjs";
|
|
11
|
+
import { a as Rumor } from "./nip59-zQgdLcEr.mjs";
|
|
12
|
+
import { i as ReplyTo, r as Recipient } from "./nip17-DNEkz8rM.mjs";
|
|
13
|
+
import { t as NostrSigner } from "./types-CRQEk0Oi.mjs";
|
|
14
|
+
import { t as StorageError } from "./error-BW7re1UN.mjs";
|
|
15
|
+
//#region src/client/types.d.ts
|
|
16
|
+
/** Direction of a {@link Client.sync} run: upload, download, or both. */
|
|
17
|
+
declare const SyncDirection: {
|
|
18
|
+
readonly Up: "up";
|
|
19
|
+
readonly Down: "down";
|
|
20
|
+
readonly Both: "both";
|
|
21
|
+
};
|
|
22
|
+
/** Union of the {@link SyncDirection} values. */
|
|
23
|
+
type SyncDirectionName = (typeof SyncDirection)[keyof typeof SyncDirection];
|
|
24
|
+
/** Options for {@link Client.sync} (NIP-77 set reconciliation). */
|
|
25
|
+
type SyncOptions = {
|
|
26
|
+
relays?: ReadonlyArray<string>;
|
|
27
|
+
direction?: SyncDirectionName;
|
|
28
|
+
/**
|
|
29
|
+
* Wall-clock deadline for the Negentropy reconciliation session (`NEG-OPEN` through `NEG-CLOSE`),
|
|
30
|
+
* in milliseconds. One clock for the whole session — not reset per `NEG-MSG`. Default: the relay
|
|
31
|
+
* `publishTimeoutMs`. Upload/download phases reuse this value as their per-call timeout.
|
|
32
|
+
*/
|
|
33
|
+
timeoutMs?: number;
|
|
34
|
+
signal?: AbortSignal;
|
|
35
|
+
dryRun?: boolean;
|
|
36
|
+
/** When false, skip observe/storage on downloaded events. Default true. */
|
|
37
|
+
observe?: boolean;
|
|
38
|
+
};
|
|
39
|
+
/** Outcome of a {@link Client.sync} run: ids compared, sent, received, and failures. */
|
|
40
|
+
type SyncSummary = {
|
|
41
|
+
local: string[];
|
|
42
|
+
remote: string[];
|
|
43
|
+
sent: string[];
|
|
44
|
+
received: string[];
|
|
45
|
+
sendFailures: Record<string, string>;
|
|
46
|
+
persistFailures: Record<string, string>;
|
|
47
|
+
};
|
|
48
|
+
/** Options for {@link Client.builder} / `ClientOptions` accepted by the builder. */
|
|
49
|
+
type ClientOptions = {
|
|
50
|
+
signer?: NostrSigner;
|
|
51
|
+
relays?: ReadonlyArray<string>;
|
|
52
|
+
websocketImplementation?: WebSocketConstructor;
|
|
53
|
+
/** Injected EVENT verifier. Default is core BIP-340. */
|
|
54
|
+
verifyEvent?: (event: Event) => boolean;
|
|
55
|
+
connectTimeoutMs?: number;
|
|
56
|
+
publishTimeoutMs?: number;
|
|
57
|
+
/**
|
|
58
|
+
* When true (default), answer NIP-42 AUTH automatically. The signer is read at challenge time, so
|
|
59
|
+
* `setSigner()` applies to live connections; challenges received while no signer is set are
|
|
60
|
+
* ignored.
|
|
61
|
+
*/
|
|
62
|
+
automaticAuth?: boolean;
|
|
63
|
+
/** When true (default), relays reconnect with backoff after disconnect. */
|
|
64
|
+
enableReconnect?: boolean;
|
|
65
|
+
/** Keepalive ping. Default false. */
|
|
66
|
+
enablePing?: boolean;
|
|
67
|
+
pingIntervalMs?: number;
|
|
68
|
+
pingTimeoutMs?: number;
|
|
69
|
+
/** Forwarded to the pool: when false (default), `ws://` relays are rejected. */
|
|
70
|
+
allowInsecure?: boolean;
|
|
71
|
+
/** Forwarded to the pool: `ws://` URLs allowed despite `allowInsecure`. */
|
|
72
|
+
trustedInsecureUrls?: ReadonlyArray<string>;
|
|
73
|
+
/** Forwarded to the pool: close idle relays after this many ms. */
|
|
74
|
+
idleTimeoutMs?: number;
|
|
75
|
+
/** Forwarded to the pool: soft cap on connected non-pinned relays. */
|
|
76
|
+
maxRelays?: number;
|
|
77
|
+
/** Forwarded to the pool: relays never closed by idle cleanup or `maxRelays`. */
|
|
78
|
+
pinnedUrls?: ReadonlyArray<string>;
|
|
79
|
+
gossip?: Gossip;
|
|
80
|
+
/**
|
|
81
|
+
* Local event store. Defaults to {@link MemoryEventStore}. Browser apps that want persistence must
|
|
82
|
+
* pass {@link IndexedDbEventStore} and `await open()`.
|
|
83
|
+
*/
|
|
84
|
+
storage?: EventStore;
|
|
85
|
+
/**
|
|
86
|
+
* Synchronous reactive index that mirrors every ingested event before callbacks and persistence.
|
|
87
|
+
* Defaults to a new {@link ReactiveEventStore}.
|
|
88
|
+
*/
|
|
89
|
+
index?: ReactiveEventStore;
|
|
90
|
+
/**
|
|
91
|
+
* When true (default), every ingested event is written to storage. Set false to disable automatic
|
|
92
|
+
* persistence while keeping the store for manual use.
|
|
93
|
+
*/
|
|
94
|
+
persistEvents?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Storage I/O failures: live `putMany` flush and `fetchEvents({ localFirst: true })` query. Those
|
|
97
|
+
* paths do not throw.
|
|
98
|
+
*/
|
|
99
|
+
onstorageerror?: (err: StorageError) => void;
|
|
100
|
+
};
|
|
101
|
+
type FetchEventsOptions = {
|
|
102
|
+
relays?: string[];
|
|
103
|
+
timeoutMs?: number;
|
|
104
|
+
signal?: AbortSignal;
|
|
105
|
+
gossip?: boolean;
|
|
106
|
+
/** When true, query local storage first and merge with network results. Defaults to false. */
|
|
107
|
+
localFirst?: boolean;
|
|
108
|
+
/** When false, skip writing fetched events to storage/observe. Default true. */
|
|
109
|
+
observe?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Every event of every relay batch, including duplicates across relays. `relayUrl` is the
|
|
112
|
+
* normalized URL of the relay that delivered it.
|
|
113
|
+
*/
|
|
114
|
+
onevent?: (event: Event, relayUrl: string) => void;
|
|
115
|
+
};
|
|
116
|
+
type SubscribeOptions = {
|
|
117
|
+
relays?: string[];
|
|
118
|
+
/**
|
|
119
|
+
* First receipt of each event only (deduped across relays). `relayUrl` is the normalized URL of
|
|
120
|
+
* the relay that delivered it first.
|
|
121
|
+
*/
|
|
122
|
+
onevent?: (event: Event, relayUrl: string) => void;
|
|
123
|
+
/** Every receipt from every relay, including duplicates skipped by dedupe. */
|
|
124
|
+
receivedEvent?: (id: string, relayUrl: string) => void;
|
|
125
|
+
oneose?: () => void;
|
|
126
|
+
onclose?: (reason: string) => void;
|
|
127
|
+
signal?: AbortSignal;
|
|
128
|
+
id?: string;
|
|
129
|
+
/**
|
|
130
|
+
* If set, fire `oneose` once after this many ms if not all relays have EOSEd. Does not close the
|
|
131
|
+
* subscription.
|
|
132
|
+
*/
|
|
133
|
+
eoseTimeoutMs?: number;
|
|
134
|
+
/** Fan out REQs via NIP-65 gossip routes when available. */
|
|
135
|
+
gossip?: boolean;
|
|
136
|
+
/** When false, skip writing received events to storage/observe. Default true. */
|
|
137
|
+
observe?: boolean;
|
|
138
|
+
};
|
|
139
|
+
type PublishOptions = {
|
|
140
|
+
relays?: string[];
|
|
141
|
+
timeoutMs?: number;
|
|
142
|
+
gossip?: boolean;
|
|
143
|
+
/** When false, skip writing the published event to storage/observe. Default true. */
|
|
144
|
+
observe?: boolean;
|
|
145
|
+
};
|
|
146
|
+
/** Options for sending a NIP-17 private message. */
|
|
147
|
+
type SendPrivateMessageOptions = {
|
|
148
|
+
readonly subject?: string;
|
|
149
|
+
readonly replyTo?: ReplyTo;
|
|
150
|
+
readonly created_at?: number;
|
|
151
|
+
readonly timeoutMs?: number;
|
|
152
|
+
readonly observe?: boolean;
|
|
153
|
+
};
|
|
154
|
+
/** Result of sending a NIP-17 DM: the rumor plus per-recipient wrap publish results. */
|
|
155
|
+
type PrivateMessageSendResult = {
|
|
156
|
+
rumor: Rumor;
|
|
157
|
+
wraps: ReadonlyArray<{
|
|
158
|
+
recipient: string;
|
|
159
|
+
wrap: Event;
|
|
160
|
+
results: PoolPublishResult[];
|
|
161
|
+
}>;
|
|
162
|
+
};
|
|
163
|
+
/** An unwrapped NIP-17 private message: the received gift wrap and its inner rumor. */
|
|
164
|
+
type ReceivedPrivateMessage = {
|
|
165
|
+
wrap: Event;
|
|
166
|
+
rumor: Rumor;
|
|
167
|
+
/** Normalized URL of the relay that delivered the wrap, when known. */
|
|
168
|
+
relayUrl?: string;
|
|
169
|
+
};
|
|
170
|
+
/** Options for fetching NIP-17 private-message history. */
|
|
171
|
+
type FetchPrivateMessagesOptions = {
|
|
172
|
+
readonly since?: number;
|
|
173
|
+
readonly until?: number;
|
|
174
|
+
readonly timeoutMs?: number;
|
|
175
|
+
readonly signal?: AbortSignal;
|
|
176
|
+
readonly observe?: boolean;
|
|
177
|
+
};
|
|
178
|
+
/** Options for a live NIP-17 private-message subscription. */
|
|
179
|
+
type SubscribePrivateMessagesOptions = {
|
|
180
|
+
readonly since?: number;
|
|
181
|
+
readonly onevent?: (msg: ReceivedPrivateMessage) => void;
|
|
182
|
+
readonly oneose?: () => void;
|
|
183
|
+
readonly onclose?: (reason: string) => void;
|
|
184
|
+
readonly signal?: AbortSignal;
|
|
185
|
+
readonly eoseTimeoutMs?: number;
|
|
186
|
+
readonly observe?: boolean;
|
|
187
|
+
};
|
|
188
|
+
/** Client lifecycle, configuration, or abort failure (not cryptographic). */
|
|
189
|
+
declare class ClientError extends NostrError {
|
|
190
|
+
name: string;
|
|
191
|
+
}
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region src/client/builder.d.ts
|
|
194
|
+
/**
|
|
195
|
+
* Fluent constructor for {@link Client}. The constructor is supplied by {@link Client.builder} so
|
|
196
|
+
* this module never imports the `Client` value, keeping the client/builder dependency
|
|
197
|
+
* one-directional.
|
|
198
|
+
*/
|
|
199
|
+
declare class ClientBuilder {
|
|
200
|
+
#private;
|
|
201
|
+
constructor(newClient: (opts: ClientOptions) => Client);
|
|
202
|
+
signer(signer: NostrSigner): this;
|
|
203
|
+
relays(urls: ReadonlyArray<string>): this;
|
|
204
|
+
addRelay(url: string): this;
|
|
205
|
+
websocketImplementation(impl: WebSocketConstructor): this;
|
|
206
|
+
verifyEvent(fn: (event: Event) => boolean): this;
|
|
207
|
+
connectTimeoutMs(ms: number): this;
|
|
208
|
+
publishTimeoutMs(ms: number): this;
|
|
209
|
+
automaticAuth(enabled: boolean): this;
|
|
210
|
+
/** Allow `ws://` relays. Default false. */
|
|
211
|
+
allowInsecure(allow: boolean): this;
|
|
212
|
+
/** `ws://` URLs allowed despite `allowInsecure` being off. */
|
|
213
|
+
trustedInsecureUrls(urls: ReadonlyArray<string>): this;
|
|
214
|
+
/** Close idle relays after this many ms. Unset = disabled. */
|
|
215
|
+
idleTimeoutMs(ms: number): this;
|
|
216
|
+
/** Soft cap on connected non-pinned relays. */
|
|
217
|
+
maxRelays(n: number): this;
|
|
218
|
+
/** Relays never closed by idle cleanup or `maxRelays` eviction. */
|
|
219
|
+
pinnedUrls(urls: ReadonlyArray<string>): this;
|
|
220
|
+
enableReconnect(enabled: boolean): this;
|
|
221
|
+
enablePing(enabled: boolean): this;
|
|
222
|
+
pingIntervalMs(ms: number): this;
|
|
223
|
+
pingTimeoutMs(ms: number): this;
|
|
224
|
+
/**
|
|
225
|
+
* Local event store. Defaults to {@link MemoryEventStore}. Browser apps that want persistence must
|
|
226
|
+
* pass {@link IndexedDbEventStore} and `await open()`.
|
|
227
|
+
*/
|
|
228
|
+
storage(store: EventStore): this;
|
|
229
|
+
/**
|
|
230
|
+
* Synchronous reactive index mirroring ingested events. Defaults to a new
|
|
231
|
+
* {@link ReactiveEventStore}.
|
|
232
|
+
*/
|
|
233
|
+
index(index: ReactiveEventStore): this;
|
|
234
|
+
/** When false, Client will not auto-write events to storage. Default true. */
|
|
235
|
+
persistEvents(enabled: boolean): this;
|
|
236
|
+
gossip(gossip: Gossip): this;
|
|
237
|
+
onstorageerror(fn: (err: StorageError) => void): this;
|
|
238
|
+
build(): Client;
|
|
239
|
+
}
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region src/client/client.d.ts
|
|
242
|
+
/** Layer-5 facade: signer + default relays + pool + loaders + gossip + event store. */
|
|
243
|
+
declare class Client {
|
|
244
|
+
#private;
|
|
245
|
+
readonly pool: Pool;
|
|
246
|
+
readonly loaders: Loaders;
|
|
247
|
+
readonly gossip: Gossip;
|
|
248
|
+
readonly storage: EventStore;
|
|
249
|
+
readonly index: ReactiveEventStore;
|
|
250
|
+
onstorageerror: ((err: StorageError) => void) | undefined;
|
|
251
|
+
constructor(opts?: ClientOptions);
|
|
252
|
+
static builder(): ClientBuilder;
|
|
253
|
+
get signer(): NostrSigner | undefined;
|
|
254
|
+
get relays(): ReadonlyArray<string>;
|
|
255
|
+
get isShutdown(): boolean;
|
|
256
|
+
setSigner(signer: NostrSigner | undefined): void;
|
|
257
|
+
addRelay(url: string): void;
|
|
258
|
+
removeRelay(url: string): void;
|
|
259
|
+
/** Connect all configured relays (best-effort; failures are ignored). */
|
|
260
|
+
connect(opts?: {
|
|
261
|
+
signal?: AbortSignal;
|
|
262
|
+
}): Promise<void>;
|
|
263
|
+
shutdown(): Promise<void>;
|
|
264
|
+
/** Ingest one inbound event: index (with relay URL) → meta → persistence. */
|
|
265
|
+
observe(event: Event, relayUrl?: string): void;
|
|
266
|
+
/** Ingest many events (deduped by id, order preserved) as one persist batch. */
|
|
267
|
+
observeAll(events: ReadonlyArray<Event>): void;
|
|
268
|
+
/**
|
|
269
|
+
* Explicitly load kind:10002 and kind:10050 lists for pubkeys and feed gossip. Does not
|
|
270
|
+
* background-fetch unknown authors on every subscribe (predictable DX).
|
|
271
|
+
*/
|
|
272
|
+
hydrateGossip(pubkeys: ReadonlyArray<string>, opts?: {
|
|
273
|
+
hints?: string[];
|
|
274
|
+
force?: boolean;
|
|
275
|
+
}): Promise<void>;
|
|
276
|
+
/**
|
|
277
|
+
* Create an outbox-model feed for the given authors (NIP-65 write relays). Live events go through
|
|
278
|
+
* {@link observe}; sync persists via applySync.
|
|
279
|
+
*/
|
|
280
|
+
outbox(opts: {
|
|
281
|
+
authors: ReadonlyArray<string>;
|
|
282
|
+
kinds?: ReadonlyArray<number>;
|
|
283
|
+
onEvent?: (event: Event) => void;
|
|
284
|
+
maxRelaysPerAuthor?: number;
|
|
285
|
+
}): OutboxFeed;
|
|
286
|
+
getPublicKey(): Promise<string>;
|
|
287
|
+
signEvent(unsigned: UnsignedEvent): Promise<Event>;
|
|
288
|
+
signEventBuilder(builder: EventBuilder): Promise<Event>;
|
|
289
|
+
signTemplate(template: EventTemplate): Promise<Event>;
|
|
290
|
+
/**
|
|
291
|
+
* Sign (if builder) and publish to relays. With `gossip: true`, prefers the author's NIP-65
|
|
292
|
+
* outbox relays, tagged `p` inboxes, and up to 5 `e`/`a` tag relay hints when known. On any
|
|
293
|
+
* successful OK, observes the event into storage/gossip.
|
|
294
|
+
*/
|
|
295
|
+
publish(eventOrBuilder: Event | EventBuilder, opts?: PublishOptions): Promise<PoolPublishResult[]>;
|
|
296
|
+
/**
|
|
297
|
+
* Fetch events. With `gossip: true`, routes filters by NIP-65 when possible. With `localFirst:
|
|
298
|
+
* true`, merges storage hits with network results.
|
|
299
|
+
*/
|
|
300
|
+
fetchEvents(filter: Filter | Filter[], opts?: FetchEventsOptions): Promise<Event[]>;
|
|
301
|
+
/** Query local storage only (no network). */
|
|
302
|
+
queryLocal(filter: Filter | Filter[]): Promise<Event[]>;
|
|
303
|
+
subscribe(filter: Filter | Filter[], opts?: SubscribeOptions): {
|
|
304
|
+
close: (reason?: string) => void;
|
|
305
|
+
};
|
|
306
|
+
/** Publish a kind:10050 NIP-17 DM relay list (`relay` tags). Not kind 10002. */
|
|
307
|
+
setDmRelays(relays: ReadonlyArray<string>, opts?: PublishOptions): Promise<PoolPublishResult[]>;
|
|
308
|
+
sendPrivateMessage(recipients: string | Recipient | ReadonlyArray<string | Recipient>, content: string, opts?: SendPrivateMessageOptions): Promise<PrivateMessageSendResult>;
|
|
309
|
+
fetchPrivateMessages(opts?: FetchPrivateMessagesOptions): Promise<ReceivedPrivateMessage[]>;
|
|
310
|
+
subscribePrivateMessages(opts?: SubscribePrivateMessagesOptions): Promise<{
|
|
311
|
+
close: (reason?: string) => void;
|
|
312
|
+
}>;
|
|
313
|
+
/**
|
|
314
|
+
* NIP-77 sync against one relay: reconcile, then optionally upload local-only events and/or
|
|
315
|
+
* download remote-only events. `observe: false` skips putMany and ingest; received ids are still
|
|
316
|
+
* listed. `persistEvents: false` skips putMany, still ingests when observe is on.
|
|
317
|
+
*/
|
|
318
|
+
syncToRelay(url: string, filter: Filter, opts?: Omit<SyncOptions, "relays">): Promise<SyncSummary>;
|
|
319
|
+
/**
|
|
320
|
+
* NIP-77 sync against the given relays (or Client default relays). Independent sessions run in
|
|
321
|
+
* parallel. Fulfilled summaries are merged; if every relay rejects, throws the first rejection in
|
|
322
|
+
* URL order.
|
|
323
|
+
*/
|
|
324
|
+
sync(filter: Filter, opts?: SyncOptions): Promise<SyncSummary>;
|
|
325
|
+
}
|
|
326
|
+
//#endregion
|
|
327
|
+
export { FetchEventsOptions as a, PublishOptions as c, SubscribeOptions as d, SubscribePrivateMessagesOptions as f, SyncSummary as g, SyncOptions as h, ClientOptions as i, ReceivedPrivateMessage as l, SyncDirectionName as m, ClientBuilder as n, FetchPrivateMessagesOptions as o, SyncDirection as p, ClientError as r, PrivateMessageSendResult as s, Client as t, SendPrivateMessageOptions as u };
|
|
328
|
+
//# sourceMappingURL=index-B425CAcQ.d.mts.map
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { t as Event } from "./event-fU3Y01PR.mjs";
|
|
2
|
+
import { t as Filter } from "./filter-C0IMByE3.mjs";
|
|
3
|
+
import { i as PutResult, n as NegentropyItem, r as OutboxBound, t as EventStore } from "./types-2pCUprRU.mjs";
|
|
4
|
+
//#region src/storage/memory-index.d.ts
|
|
5
|
+
type MemoryIndexOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* FIFO cap applied independently to each deletion-state collection: tombstoned event ids, pending
|
|
8
|
+
* e-tag ids, and coordinate tombstones. Default unbounded. Trade-off: once an entry is trimmed, a
|
|
9
|
+
* re-arriving old deleted event or replaceable version can be accepted again.
|
|
10
|
+
*/
|
|
11
|
+
maxTombstones?: number;
|
|
12
|
+
/**
|
|
13
|
+
* FIFO cap on replaceable/addressable winner watermarks recorded by {@link evict}. A watermark
|
|
14
|
+
* keeps only `{ id, created_at }` per address so stale versions stay rejected after the winner's
|
|
15
|
+
* body is evicted, and a re-put of the watermarked id re-inserts it. Default 0 (no watermark
|
|
16
|
+
* retention); callers that evict should pass a bound. Once a watermark is trimmed, an older
|
|
17
|
+
* evicted version can be accepted again — the same trade-off as deletion tombstones.
|
|
18
|
+
*/
|
|
19
|
+
maxWatermarks?: number;
|
|
20
|
+
/** Fires after every physical index insert (accept, replace, deletion event). */
|
|
21
|
+
onInsert?: (event: Event) => void;
|
|
22
|
+
/** Fires after every physical index remove (replace, delete, evict, remove, clear). */
|
|
23
|
+
onRemove?: (event: Event) => void;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Synchronous in-memory event index with NIP-01 replaceable / addressable / ephemeral handling and
|
|
27
|
+
* NIP-09 deletion (kind 5) application. Shared by {@link MemoryEventStore} (async facade) and
|
|
28
|
+
* `ReactiveEventStore`.
|
|
29
|
+
*/
|
|
30
|
+
declare class MemoryIndex {
|
|
31
|
+
#private;
|
|
32
|
+
constructor(opts?: MemoryIndexOptions);
|
|
33
|
+
put(raw: Event): PutResult;
|
|
34
|
+
/** Sequential `put` in input order. */
|
|
35
|
+
putMany(events: ReadonlyArray<Event>): PutResult[];
|
|
36
|
+
get(id: string): Event | undefined;
|
|
37
|
+
/** Current event at a `kind:pubkey:d` coordinate (replaceable or addressable). */
|
|
38
|
+
getByAddress(address: string): Event | undefined;
|
|
39
|
+
query(filters: ReadonlyArray<Filter>): Event[];
|
|
40
|
+
count(filters: ReadonlyArray<Filter>): number;
|
|
41
|
+
negentropyItems(filter: Filter): NegentropyItem[];
|
|
42
|
+
/** Remove by id and tombstone (like a local NIP-09). Returns removed count. */
|
|
43
|
+
remove(ids: ReadonlyArray<string>): number;
|
|
44
|
+
/**
|
|
45
|
+
* Remove by id without writing a tombstone (LRU eviction). When the evicted event is the current
|
|
46
|
+
* winner of a replaceable/addressable address, a `{ id, created_at }` watermark is recorded so
|
|
47
|
+
* stale versions stay rejected while the body is gone; the watermarks are FIFO-bounded by
|
|
48
|
+
* `maxWatermarks`.
|
|
49
|
+
*/
|
|
50
|
+
evict(ids: ReadonlyArray<string>): number;
|
|
51
|
+
/**
|
|
52
|
+
* True when the id is tombstoned, or the coordinate has a deletion marker that still covers the
|
|
53
|
+
* current event at that address: a replacement published after the marker's `until` clears the
|
|
54
|
+
* deletion. Coordinates are matched on the canonical lowercase pubkey.
|
|
55
|
+
*/
|
|
56
|
+
isDeleted(idOrAddress: string): boolean;
|
|
57
|
+
getOutboxBound(pubkey: string, kind: number): OutboxBound | undefined;
|
|
58
|
+
setOutboxBound(pubkey: string, kind: number, bound: OutboxBound): void;
|
|
59
|
+
clear(): void;
|
|
60
|
+
get size(): number;
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/storage/memory.d.ts
|
|
64
|
+
/** In-memory event store: async {@link EventStore} facade over the synchronous {@link MemoryIndex}. */
|
|
65
|
+
declare class MemoryEventStore implements EventStore {
|
|
66
|
+
#private;
|
|
67
|
+
put(raw: Event): Promise<PutResult>;
|
|
68
|
+
/** Sequential `put` in input order. No transaction: a throw leaves earlier events applied. */
|
|
69
|
+
putMany(events: ReadonlyArray<Event>): Promise<PutResult[]>;
|
|
70
|
+
get(id: string): Promise<Event | undefined>;
|
|
71
|
+
query(filters: Filter[]): Promise<Event[]>;
|
|
72
|
+
count(filters: Filter[]): Promise<number>;
|
|
73
|
+
negentropyItems(filter: Filter): Promise<NegentropyItem[]>;
|
|
74
|
+
remove(ids: string[]): Promise<number>;
|
|
75
|
+
getOutboxBound(pubkey: string, kind: number): Promise<OutboxBound | undefined>;
|
|
76
|
+
setOutboxBound(pubkey: string, kind: number, bound: OutboxBound): Promise<void>;
|
|
77
|
+
clear(): Promise<void>;
|
|
78
|
+
get size(): number;
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/storage/indexeddb.d.ts
|
|
82
|
+
/** Options for {@link IndexedDbEventStore}. */
|
|
83
|
+
type IndexedDbEventStoreOptions = {
|
|
84
|
+
/** IndexedDB database name. */
|
|
85
|
+
dbName?: string;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Browser IndexedDB event store with the same replaceable / deletion semantics as
|
|
89
|
+
* {@link MemoryEventStore}. Requires a DOM IndexedDB implementation.
|
|
90
|
+
*
|
|
91
|
+
* `open` loads every tombstone and address row into memory. Fine at 10^4 events; tens of MB at 10^5
|
|
92
|
+
* addressables.
|
|
93
|
+
*/
|
|
94
|
+
declare class IndexedDbEventStore implements EventStore {
|
|
95
|
+
#private;
|
|
96
|
+
constructor(opts?: IndexedDbEventStoreOptions);
|
|
97
|
+
static isAvailable(): boolean;
|
|
98
|
+
open(): Promise<void>;
|
|
99
|
+
put(event: Event): Promise<PutResult>;
|
|
100
|
+
/** One readwrite transaction; abort rejects the whole batch with no partial persist. */
|
|
101
|
+
putMany(events: ReadonlyArray<Event>): Promise<PutResult[]>;
|
|
102
|
+
get(id: string): Promise<Event | undefined>;
|
|
103
|
+
query(filters: Filter[]): Promise<Event[]>;
|
|
104
|
+
count(filters: Filter[]): Promise<number>;
|
|
105
|
+
negentropyItems(filter: Filter): Promise<NegentropyItem[]>;
|
|
106
|
+
getOutboxBound(pubkey: string, kind: number): Promise<OutboxBound | undefined>;
|
|
107
|
+
setOutboxBound(pubkey: string, kind: number, bound: OutboxBound): Promise<void>;
|
|
108
|
+
remove(ids: string[]): Promise<number>;
|
|
109
|
+
clear(): Promise<void>;
|
|
110
|
+
close(): void;
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/storage/sqlite.d.ts
|
|
114
|
+
/** Value bindable to a SQLite statement parameter. */
|
|
115
|
+
type SqlValue = string | number | null | Uint8Array;
|
|
116
|
+
/**
|
|
117
|
+
* Minimal async SQLite driver surface.
|
|
118
|
+
*
|
|
119
|
+
* `transaction` must serialize `fn` exclusively — no interleaved statements from other callers may
|
|
120
|
+
* run while the callback transaction is active. It commits when `fn` resolves and rolls back when
|
|
121
|
+
* `fn` rejects.
|
|
122
|
+
*
|
|
123
|
+
* The store always issues statements sequentially — a driver never sees a second `exec`/`run`/`all`
|
|
124
|
+
* start before the previous one settles, inside or outside a transaction — so drivers need not
|
|
125
|
+
* support overlapping statements on one connection.
|
|
126
|
+
*
|
|
127
|
+
* `expo-sqlite` maps onto this interface without changes to query code:
|
|
128
|
+
*
|
|
129
|
+
* ```ts
|
|
130
|
+
* const db = await openDatabaseAsync("nostr.db");
|
|
131
|
+
* const driver: SqlDriver = {
|
|
132
|
+
* exec: (sql) => db.execAsync(sql),
|
|
133
|
+
* run: async (sql, params = []) => {
|
|
134
|
+
* const r = await db.runAsync(sql, params);
|
|
135
|
+
* return { changes: r.changes };
|
|
136
|
+
* },
|
|
137
|
+
* all: (sql, params = []) => db.getAllAsync(sql, params),
|
|
138
|
+
* transaction: (fn) => db.withExclusiveTransactionAsync(() => fn(driver)),
|
|
139
|
+
* };
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
type SqlDriver = {
|
|
143
|
+
/** Execute SQL without parameters (DDL, PRAGMA, multi-statement batches). */
|
|
144
|
+
exec: (sql: string) => Promise<void>;
|
|
145
|
+
/** Run a statement; resolves with the number of changed rows. */
|
|
146
|
+
run: (sql: string, params?: ReadonlyArray<SqlValue>) => Promise<{
|
|
147
|
+
changes: number;
|
|
148
|
+
}>;
|
|
149
|
+
/** Run a query; resolves with all result rows. */
|
|
150
|
+
all: <Row>(sql: string, params?: ReadonlyArray<SqlValue>) => Promise<Row[]>;
|
|
151
|
+
/** Run `fn` inside an exclusive transaction; commit on resolve, roll back on reject. */
|
|
152
|
+
transaction: <T>(fn: (tx: SqlDriver) => Promise<T>) => Promise<T>;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* SQLite-backed {@link EventStore} for React Native (`expo-sqlite`, `op-sqlite`) and desktop
|
|
156
|
+
* runtimes. Same semantics as {@link MemoryEventStore} and {@link IndexedDbEventStore}: identical
|
|
157
|
+
* `decidePut` insertion policy, NIP-09 tombstones, and filter handling, with the database — not
|
|
158
|
+
* in-memory caches — as the source of truth.
|
|
159
|
+
*
|
|
160
|
+
* Construct via {@link SqliteEventStore.open}; writes are serialized and run inside an exclusive
|
|
161
|
+
* driver transaction.
|
|
162
|
+
*/
|
|
163
|
+
declare class SqliteEventStore implements EventStore {
|
|
164
|
+
#private;
|
|
165
|
+
private constructor();
|
|
166
|
+
/** Create the schema on first use and return a ready store. */
|
|
167
|
+
static open(driver: SqlDriver): Promise<SqliteEventStore>;
|
|
168
|
+
put(event: Event): Promise<PutResult>;
|
|
169
|
+
putMany(events: ReadonlyArray<Event>): Promise<PutResult[]>;
|
|
170
|
+
get(id: string): Promise<Event | undefined>;
|
|
171
|
+
query(filters: Filter[]): Promise<Event[]>;
|
|
172
|
+
count(filters: Filter[]): Promise<number>;
|
|
173
|
+
negentropyItems(filter: Filter): Promise<NegentropyItem[]>;
|
|
174
|
+
getOutboxBound(pubkey: string, kind: number): Promise<OutboxBound | undefined>;
|
|
175
|
+
setOutboxBound(pubkey: string, kind: number, bound: OutboxBound): Promise<void>;
|
|
176
|
+
remove(ids: string[]): Promise<number>;
|
|
177
|
+
clear(): Promise<void>;
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
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 };
|
|
181
|
+
//# sourceMappingURL=index-BVyfUBuG.d.mts.map
|