@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.
Files changed (185) hide show
  1. package/dist/abort-Ba8tDrOI.mjs +38 -0
  2. package/dist/abort-Ba8tDrOI.mjs.map +1 -0
  3. package/dist/{builder-BphJa-Y-.d.mts → builder-BWn55Paf.d.mts} +20 -14
  4. package/dist/{builder-q0VsvnYE.mjs → builder-CyrGKRVP.mjs} +32 -16
  5. package/dist/builder-CyrGKRVP.mjs.map +1 -0
  6. package/dist/{client-Bd8B1mYm.mjs → client-BWsX9Cv1.mjs} +354 -195
  7. package/dist/client-BWsX9Cv1.mjs.map +1 -0
  8. package/dist/client.d.mts +1 -1
  9. package/dist/client.mjs +1 -1
  10. package/dist/core.d.mts +8 -8
  11. package/dist/core.mjs +8 -9
  12. package/dist/error-BW7re1UN.d.mts +9 -0
  13. package/dist/error-B__OMBRY.mjs +14 -0
  14. package/dist/error-B__OMBRY.mjs.map +1 -0
  15. package/dist/{error-WEFS-R-4.d.mts → error-CR8Urc84.d.mts} +20 -8
  16. package/dist/{error-CwBxle6N.mjs → error-DrEIM7FO.mjs} +5 -3
  17. package/dist/error-DrEIM7FO.mjs.map +1 -0
  18. package/dist/{event-CzoQEFMF.mjs → event-D8Nfoh4K.mjs} +40 -32
  19. package/dist/event-D8Nfoh4K.mjs.map +1 -0
  20. package/dist/{event-B5D2jxt_.d.mts → event-fU3Y01PR.d.mts} +23 -20
  21. package/dist/{filter-BxwjEkZp.mjs → filter-BQl3GlHt.mjs} +42 -35
  22. package/dist/filter-BQl3GlHt.mjs.map +1 -0
  23. package/dist/filter-C0IMByE3.d.mts +37 -0
  24. package/dist/{gossip-C5RVB1UB.d.mts → gossip-BRQwIM_q.d.mts} +25 -23
  25. package/dist/{gossip-3xkRRCm_.mjs → gossip-oloDMWEj.mjs} +52 -34
  26. package/dist/gossip-oloDMWEj.mjs.map +1 -0
  27. package/dist/gossip.d.mts +1 -1
  28. package/dist/gossip.mjs +1 -1
  29. package/dist/{http-6vevbBlu.d.mts → http-C4HwIu4B.d.mts} +7 -7
  30. package/dist/{http-D2rhokZo.mjs → http-CuazNRIP.mjs} +10 -6
  31. package/dist/http-CuazNRIP.mjs.map +1 -0
  32. package/dist/index-B425CAcQ.d.mts +328 -0
  33. package/dist/index-BVyfUBuG.d.mts +181 -0
  34. package/dist/{index-BYMnhRIC.d.mts → index-Ba7bJ7DD.d.mts} +68 -50
  35. package/dist/{index-DaRyjo7O.d.mts → index-Boe8FshM.d.mts} +13 -7
  36. package/dist/index-CUIvFQdE.d.mts +73 -0
  37. package/dist/index-JdaS_uce.d.mts +207 -0
  38. package/dist/index.d.mts +22 -20
  39. package/dist/index.mjs +19 -18
  40. package/dist/{key-Dn-aX4x4.mjs → key-Bbtys6o7.mjs} +22 -14
  41. package/dist/key-Bbtys6o7.mjs.map +1 -0
  42. package/dist/{key-BiGxGLhg.d.mts → key-BlsYhN1V.d.mts} +9 -6
  43. package/dist/{kind-BLl4cLOc.mjs → kind-Cxwhhkx8.mjs} +2 -1
  44. package/dist/kind-Cxwhhkx8.mjs.map +1 -0
  45. package/dist/{loaders-BNQszDAn.mjs → loaders-o6YXB_Ri.mjs} +329 -305
  46. package/dist/loaders-o6YXB_Ri.mjs.map +1 -0
  47. package/dist/loaders.d.mts +3 -3
  48. package/dist/loaders.mjs +2 -2
  49. package/dist/memory-C2EVx0_O.mjs +46 -0
  50. package/dist/memory-C2EVx0_O.mjs.map +1 -0
  51. package/dist/{memory-BCmhZPek.mjs → memory-index-Do1mz0WF.mjs} +212 -82
  52. package/dist/memory-index-Do1mz0WF.mjs.map +1 -0
  53. package/dist/{message-C_Uj-Y-c.mjs → message-DcY6Fi9o.mjs} +38 -24
  54. package/dist/message-DcY6Fi9o.mjs.map +1 -0
  55. package/dist/{message-DJC-Jz6T.d.mts → message-iGPIqnn0.d.mts} +15 -8
  56. package/dist/{nip17-BWq-Kfq5.d.mts → nip17-DNEkz8rM.d.mts} +18 -17
  57. package/dist/{nip19-D7905oIv.d.mts → nip19-BevCJZsp.d.mts} +23 -3
  58. package/dist/{nip46-C_DoxiS_.d.mts → nip46-DDV4dC56.d.mts} +13 -12
  59. package/dist/{nip59-DljW_sYh.d.mts → nip59-zQgdLcEr.d.mts} +28 -25
  60. package/dist/{nip65-Di5hZRuV.d.mts → nip65-DBfh2smt.d.mts} +8 -3
  61. package/dist/{nip77-ByxlgoQO.d.mts → nip77-DH4RhS5r.d.mts} +9 -8
  62. package/dist/nips/blossom.d.mts +37 -37
  63. package/dist/nips/blossom.mjs +67 -52
  64. package/dist/nips/blossom.mjs.map +1 -1
  65. package/dist/nips/nip04.d.mts +2 -3
  66. package/dist/nips/nip04.mjs +6 -10
  67. package/dist/nips/nip04.mjs.map +1 -1
  68. package/dist/nips/nip05.d.mts +37 -43
  69. package/dist/nips/nip05.mjs +57 -57
  70. package/dist/nips/nip05.mjs.map +1 -1
  71. package/dist/nips/nip10.d.mts +18 -19
  72. package/dist/nips/nip10.mjs +76 -61
  73. package/dist/nips/nip10.mjs.map +1 -1
  74. package/dist/nips/nip11.d.mts +9 -8
  75. package/dist/nips/nip11.mjs +14 -11
  76. package/dist/nips/nip11.mjs.map +1 -1
  77. package/dist/nips/nip13.d.mts +9 -9
  78. package/dist/nips/nip13.mjs +15 -17
  79. package/dist/nips/nip13.mjs.map +1 -1
  80. package/dist/nips/nip17.d.mts +1 -1
  81. package/dist/nips/nip17.mjs +17 -12
  82. package/dist/nips/nip17.mjs.map +1 -1
  83. package/dist/nips/nip19.d.mts +1 -1
  84. package/dist/nips/nip19.mjs +52 -29
  85. package/dist/nips/nip19.mjs.map +1 -1
  86. package/dist/nips/nip21.d.mts +5 -6
  87. package/dist/nips/nip21.mjs +8 -7
  88. package/dist/nips/nip21.mjs.map +1 -1
  89. package/dist/nips/nip27.d.mts +7 -8
  90. package/dist/nips/nip27.mjs +26 -25
  91. package/dist/nips/nip27.mjs.map +1 -1
  92. package/dist/nips/nip42.d.mts +5 -6
  93. package/dist/nips/nip42.mjs +3 -3
  94. package/dist/nips/nip42.mjs.map +1 -1
  95. package/dist/nips/nip44.d.mts +24 -7
  96. package/dist/nips/nip44.mjs +25 -15
  97. package/dist/nips/nip44.mjs.map +1 -1
  98. package/dist/nips/nip46.d.mts +1 -1
  99. package/dist/nips/nip46.mjs +52 -49
  100. package/dist/nips/nip46.mjs.map +1 -1
  101. package/dist/nips/nip49.d.mts +8 -7
  102. package/dist/nips/nip49.mjs +16 -12
  103. package/dist/nips/nip49.mjs.map +1 -1
  104. package/dist/nips/nip51.d.mts +25 -27
  105. package/dist/nips/nip51.mjs +47 -36
  106. package/dist/nips/nip51.mjs.map +1 -1
  107. package/dist/nips/nip57.d.mts +12 -13
  108. package/dist/nips/nip57.mjs +35 -38
  109. package/dist/nips/nip57.mjs.map +1 -1
  110. package/dist/nips/nip59.d.mts +1 -1
  111. package/dist/nips/nip59.mjs +14 -18
  112. package/dist/nips/nip59.mjs.map +1 -1
  113. package/dist/nips/nip65.d.mts +1 -1
  114. package/dist/nips/nip65.mjs +11 -8
  115. package/dist/nips/nip65.mjs.map +1 -1
  116. package/dist/nips/nip77.d.mts +1 -1
  117. package/dist/nips/nip77.mjs +56 -34
  118. package/dist/nips/nip77.mjs.map +1 -1
  119. package/dist/nips/nip96.d.mts +21 -12
  120. package/dist/nips/nip96.mjs +59 -36
  121. package/dist/nips/nip96.mjs.map +1 -1
  122. package/dist/nips/nip98.d.mts +12 -12
  123. package/dist/nips/nip98.mjs +18 -19
  124. package/dist/nips/nip98.mjs.map +1 -1
  125. package/dist/{pool-C_j1OmBB.mjs → pool-XmAGaufS.mjs} +611 -487
  126. package/dist/pool-XmAGaufS.mjs.map +1 -0
  127. package/dist/pool-tEr7c5bG.d.mts +302 -0
  128. package/dist/reactive-DDlThDSZ.mjs +324 -0
  129. package/dist/reactive-DDlThDSZ.mjs.map +1 -0
  130. package/dist/reactive-DFpqtIf_.d.mts +66 -0
  131. package/dist/relay.d.mts +5 -4
  132. package/dist/relay.mjs +2 -2
  133. package/dist/report-CHld4uWj.mjs +32 -0
  134. package/dist/report-CHld4uWj.mjs.map +1 -0
  135. package/dist/{signer-CZ6K6FUc.mjs → signer-CKR9EHce.mjs} +107 -72
  136. package/dist/signer-CKR9EHce.mjs.map +1 -0
  137. package/dist/signer.d.mts +3 -3
  138. package/dist/signer.mjs +3 -2
  139. package/dist/storage-xXxLGCVb.mjs +1376 -0
  140. package/dist/storage-xXxLGCVb.mjs.map +1 -0
  141. package/dist/storage.d.mts +4 -4
  142. package/dist/storage.mjs +5 -4
  143. package/dist/store.d.mts +2 -0
  144. package/dist/store.mjs +2 -0
  145. package/dist/testing.d.mts +125 -0
  146. package/dist/testing.mjs +957 -0
  147. package/dist/testing.mjs.map +1 -0
  148. package/dist/types-2pCUprRU.d.mts +47 -0
  149. package/dist/types-CRQEk0Oi.d.mts +19 -0
  150. package/dist/util-LfQirgDk.mjs +113 -0
  151. package/dist/util-LfQirgDk.mjs.map +1 -0
  152. package/dist/wasm.d.mts +4 -4
  153. package/dist/wasm.mjs +54 -55
  154. package/dist/wasm.mjs.map +1 -1
  155. package/dist/websocket-CmeqvAkp.d.mts +27 -0
  156. package/package.json +31 -9
  157. package/dist/builder-q0VsvnYE.mjs.map +0 -1
  158. package/dist/client-Bd8B1mYm.mjs.map +0 -1
  159. package/dist/error-B49rbDzT.d.mts +0 -7
  160. package/dist/error-CwBxle6N.mjs.map +0 -1
  161. package/dist/error-DZEs5OuZ.mjs +0 -24
  162. package/dist/error-DZEs5OuZ.mjs.map +0 -1
  163. package/dist/event-CzoQEFMF.mjs.map +0 -1
  164. package/dist/filter-BxwjEkZp.mjs.map +0 -1
  165. package/dist/filter-DUEKP3q1.d.mts +0 -40
  166. package/dist/gossip-3xkRRCm_.mjs.map +0 -1
  167. package/dist/http-D2rhokZo.mjs.map +0 -1
  168. package/dist/index-C0C4e-Gn.d.mts +0 -55
  169. package/dist/index-DgOugrpF.d.mts +0 -275
  170. package/dist/index-EwL6fHLo.d.mts +0 -267
  171. package/dist/index-k2YhCgsh.d.mts +0 -57
  172. package/dist/key-Dn-aX4x4.mjs.map +0 -1
  173. package/dist/kind-BLl4cLOc.mjs.map +0 -1
  174. package/dist/loaders-BNQszDAn.mjs.map +0 -1
  175. package/dist/memory-BCmhZPek.mjs.map +0 -1
  176. package/dist/message-C_Uj-Y-c.mjs.map +0 -1
  177. package/dist/pool-C_j1OmBB.mjs.map +0 -1
  178. package/dist/pool-DhRi7l-b.d.mts +0 -297
  179. package/dist/signer-CZ6K6FUc.mjs.map +0 -1
  180. package/dist/storage-DOy0iLRE.mjs +0 -870
  181. package/dist/storage-DOy0iLRE.mjs.map +0 -1
  182. package/dist/types-BzyADqnw.d.mts +0 -19
  183. package/dist/types-Dn24TPFs.d.mts +0 -43
  184. package/dist/util-6tfLQ9JF.mjs +0 -73
  185. package/dist/util-6tfLQ9JF.mjs.map +0 -1
@@ -1,55 +0,0 @@
1
- import { t as Event } from "./event-B5D2jxt_.mjs";
2
- import { t as Filter } from "./filter-DUEKP3q1.mjs";
3
- import { a as NostrError } from "./error-WEFS-R-4.mjs";
4
- import { t as Pool } from "./pool-DhRi7l-b.mjs";
5
- //#region src/relay/error.d.ts
6
- declare class RelayError extends NostrError {
7
- readonly url?: string;
8
- constructor(message: string, url?: string);
9
- }
10
- declare class RelayConnectionError extends RelayError {}
11
- declare class RelayPublishError extends RelayError {}
12
- declare class RelayClosedError extends RelayError {}
13
- //#endregion
14
- //#region src/relay/url.d.ts
15
- /**
16
- * True for `ws:` / `http:` URLs that are not `.onion`.
17
- * Local-network `ws://` is still insecure; allow those via a trusted set.
18
- */
19
- declare function isInsecureRelayUrl(url: string): boolean;
20
- //#endregion
21
- //#region src/relay/fan-in.d.ts
22
- type RoutedJob = {
23
- urls: readonly string[];
24
- filters: readonly Filter[];
25
- id?: string;
26
- };
27
- type FanInOptions = {
28
- onevent?: (event: Event) => void;
29
- oneose?: () => void;
30
- onclose?: (reason: string) => void;
31
- signal?: AbortSignal;
32
- /** Armed at fan-in only. Never forwarded to relay.subscribe. */
33
- eoseTimeoutMs?: number;
34
- alreadyHaveEvent?: (id: string) => boolean;
35
- receivedEvent?: (id: string) => void;
36
- closeOnEose?: boolean;
37
- /** Optional. ensureRelay uses Pool.#opts.connectTimeoutMs when omitted. */
38
- connectTimeoutMs?: number;
39
- };
40
- /**
41
- * Aggregate EOSE/close across routed jobs. One `seen` set.
42
- * `pending` counts URL list entries (duplicates included).
43
- * `pendingEose` counts unique `jobIndex:url` keys.
44
- */
45
- declare function fanIn(pool: Pool, jobs: readonly RoutedJob[], opts?: FanInOptions): {
46
- close: (reason?: string) => void;
47
- };
48
- declare function fetchRouted(pool: Pool, jobs: readonly RoutedJob[], opts?: {
49
- timeoutMs?: number;
50
- signal?: AbortSignal;
51
- connectTimeoutMs?: number;
52
- }): Promise<Event[]>;
53
- //#endregion
54
- export { isInsecureRelayUrl as a, RelayError as c, fetchRouted as i, RelayPublishError as l, RoutedJob as n, RelayClosedError as o, fanIn as r, RelayConnectionError as s, FanInOptions as t };
55
- //# sourceMappingURL=index-C0C4e-Gn.d.mts.map
@@ -1,275 +0,0 @@
1
- import { n as EventTemplate, r as UnsignedEvent, t as Event } from "./event-B5D2jxt_.mjs";
2
- import { t as EventBuilder } from "./builder-BphJa-Y-.mjs";
3
- import { t as Filter } from "./filter-DUEKP3q1.mjs";
4
- import { t as Gossip } from "./gossip-C5RVB1UB.mjs";
5
- import { a as NostrError } from "./error-WEFS-R-4.mjs";
6
- import { i as PoolPublishResult, t as Pool, u as WebSocketConstructor } from "./pool-DhRi7l-b.mjs";
7
- import { a as OutboxFeed, n as Loaders } from "./index-EwL6fHLo.mjs";
8
- import { t as EventStore } from "./types-Dn24TPFs.mjs";
9
- import { a as Rumor } from "./nip59-DljW_sYh.mjs";
10
- import { i as ReplyTo, r as Recipient } from "./nip17-BWq-Kfq5.mjs";
11
- import { t as NostrSigner } from "./types-BzyADqnw.mjs";
12
- import { t as StorageError } from "./error-B49rbDzT.mjs";
13
- //#region src/client/builder.d.ts
14
- /** Fluent constructor for {@link Client}. */
15
- declare class ClientBuilder {
16
- #private;
17
- signer(signer: NostrSigner): this;
18
- relays(urls: readonly string[]): this;
19
- addRelay(url: string): this;
20
- websocketImplementation(impl: WebSocketConstructor): this;
21
- verifyEvent(fn: (event: Event) => boolean): this;
22
- connectTimeoutMs(ms: number): this;
23
- publishTimeoutMs(ms: number): this;
24
- automaticAuth(enabled: boolean): this;
25
- enableReconnect(enabled: boolean): this;
26
- enablePing(enabled: boolean): this;
27
- pingIntervalMs(ms: number): this;
28
- pingTimeoutMs(ms: number): this;
29
- /**
30
- * Local event store. Defaults to {@link MemoryEventStore}.
31
- * Browser apps that want persistence must pass {@link IndexedDbEventStore} and `await open()`.
32
- */
33
- storage(store: EventStore): this;
34
- /** When false, Client will not auto-write events to storage. Default true. */
35
- persistEvents(enabled: boolean): this;
36
- gossip(gossip: Gossip): this;
37
- onstorageerror(fn: (err: StorageError) => void): this;
38
- build(): Client;
39
- }
40
- //#endregion
41
- //#region src/client/types.d.ts
42
- declare const SyncDirection: {
43
- readonly Up: "up";
44
- readonly Down: "down";
45
- readonly Both: "both";
46
- };
47
- type SyncDirectionName = (typeof SyncDirection)[keyof typeof SyncDirection];
48
- type SyncOptions = {
49
- relays?: readonly string[];
50
- direction?: SyncDirectionName;
51
- /**
52
- * Wall-clock deadline for the Negentropy reconciliation session
53
- * (`NEG-OPEN` through `NEG-CLOSE`), in milliseconds.
54
- * One clock for the whole session — not reset per `NEG-MSG`.
55
- * Default: the relay `publishTimeoutMs`.
56
- * Upload/download phases reuse this value as their per-call timeout.
57
- */
58
- timeoutMs?: number;
59
- signal?: AbortSignal;
60
- dryRun?: boolean;
61
- /** When false, skip observe/storage on downloaded events. Default true. */
62
- observe?: boolean;
63
- };
64
- type SyncSummary = {
65
- local: string[];
66
- remote: string[];
67
- sent: string[];
68
- received: string[];
69
- sendFailures: Record<string, string>;
70
- persistFailures: Record<string, string>;
71
- };
72
- type ClientOptions = {
73
- signer?: NostrSigner;
74
- relays?: readonly string[];
75
- websocketImplementation?: WebSocketConstructor;
76
- /** Injected EVENT verifier. Default is core BIP-340. */
77
- verifyEvent?: (event: Event) => boolean;
78
- connectTimeoutMs?: number;
79
- publishTimeoutMs?: number;
80
- /** When true (default if signer present), answer NIP-42 AUTH automatically. */
81
- automaticAuth?: boolean;
82
- /** When true (default), relays reconnect with backoff after disconnect. */
83
- enableReconnect?: boolean;
84
- /** Keepalive ping. Default false. */
85
- enablePing?: boolean;
86
- pingIntervalMs?: number;
87
- pingTimeoutMs?: number;
88
- gossip?: Gossip;
89
- /**
90
- * Local event store. Defaults to {@link MemoryEventStore}.
91
- * Browser apps that want persistence must pass {@link IndexedDbEventStore} and `await open()`.
92
- */
93
- storage?: EventStore;
94
- /**
95
- * When true (default), every ingested event is written to storage.
96
- * Set false to disable automatic persistence while keeping the store for manual use.
97
- */
98
- persistEvents?: boolean;
99
- /**
100
- * Storage I/O failures: live `putMany` flush and `fetchEvents({ localFirst: true })` query.
101
- * Those paths do not throw.
102
- */
103
- onstorageerror?: (err: StorageError) => void;
104
- };
105
- type FetchEventsOptions = {
106
- relays?: string[];
107
- timeoutMs?: number;
108
- signal?: AbortSignal;
109
- gossip?: boolean;
110
- /**
111
- * When true, query local storage first and merge with network results.
112
- * Defaults to false.
113
- */
114
- localFirst?: boolean;
115
- /** When false, skip writing fetched events to storage/observe. Default true. */
116
- observe?: boolean;
117
- };
118
- type SubscribeOptions = {
119
- relays?: string[];
120
- onevent?: (event: Event) => void;
121
- oneose?: () => void;
122
- onclose?: (reason: string) => void;
123
- signal?: AbortSignal;
124
- id?: string;
125
- /**
126
- * If set, fire `oneose` once after this many ms if not all relays have EOSEd.
127
- * Does not close the subscription.
128
- */
129
- eoseTimeoutMs?: number;
130
- /** Fan out REQs via NIP-65 gossip routes when available. */
131
- gossip?: boolean;
132
- /** When false, skip writing received events to storage/observe. Default true. */
133
- observe?: boolean;
134
- };
135
- type PublishOptions = {
136
- relays?: string[];
137
- timeoutMs?: number;
138
- gossip?: boolean;
139
- /** When false, skip writing the published event to storage/observe. Default true. */
140
- observe?: boolean;
141
- };
142
- type SendPrivateMessageOptions = {
143
- readonly subject?: string;
144
- readonly replyTo?: ReplyTo;
145
- readonly created_at?: number;
146
- readonly timeoutMs?: number;
147
- readonly observe?: boolean;
148
- };
149
- type PrivateMessageSendResult = {
150
- rumor: Rumor;
151
- wraps: ReadonlyArray<{
152
- recipient: string;
153
- wrap: Event;
154
- results: PoolPublishResult[];
155
- }>;
156
- };
157
- type ReceivedPrivateMessage = {
158
- wrap: Event;
159
- rumor: Rumor;
160
- };
161
- type FetchPrivateMessagesOptions = {
162
- readonly since?: number;
163
- readonly until?: number;
164
- readonly timeoutMs?: number;
165
- readonly signal?: AbortSignal;
166
- readonly observe?: boolean;
167
- };
168
- type SubscribePrivateMessagesOptions = {
169
- readonly since?: number;
170
- readonly onevent?: (msg: ReceivedPrivateMessage) => void;
171
- readonly oneose?: () => void;
172
- readonly onclose?: (reason: string) => void;
173
- readonly signal?: AbortSignal;
174
- readonly eoseTimeoutMs?: number;
175
- readonly observe?: boolean;
176
- };
177
- /** Client lifecycle, configuration, or abort failure (not cryptographic). */
178
- declare class ClientError extends NostrError {}
179
- //#endregion
180
- //#region src/client/client.d.ts
181
- /**
182
- * Layer-5 facade: signer + default relays + pool + loaders + gossip + event store.
183
- */
184
- declare class Client {
185
- #private;
186
- readonly pool: Pool;
187
- readonly loaders: Loaders;
188
- readonly gossip: Gossip;
189
- readonly storage: EventStore;
190
- onstorageerror: ((err: StorageError) => void) | null;
191
- constructor(opts?: ClientOptions);
192
- static builder(): ClientBuilder;
193
- get signer(): NostrSigner | undefined;
194
- get relays(): readonly string[];
195
- get isShutdown(): boolean;
196
- setSigner(signer: NostrSigner): void;
197
- addRelay(url: string): void;
198
- removeRelay(url: string): void;
199
- /** Connect all configured relays (best-effort; failures are ignored). */
200
- connect(opts?: {
201
- signal?: AbortSignal;
202
- }): Promise<void>;
203
- shutdown(): Promise<void>;
204
- /**
205
- * Unified ingest pipeline: gossip + replaceable loader cache immediately;
206
- * storage writes are coalesced into a single-flight `putMany`.
207
- */
208
- observe(event: Event): void;
209
- /** Observe many events (deduped by id, order preserved) as one persist batch. */
210
- observeAll(events: readonly Event[]): void;
211
- /**
212
- * Explicitly load kind:10002 and kind:10050 lists for pubkeys and feed gossip.
213
- * Does not background-fetch unknown authors on every subscribe (predictable DX).
214
- */
215
- hydrateGossip(pubkeys: readonly string[], opts?: {
216
- hints?: string[];
217
- force?: boolean;
218
- }): Promise<void>;
219
- /**
220
- * Create an outbox-model feed for the given authors (NIP-65 write relays).
221
- * Live events go through {@link observe}; sync persists via applySync.
222
- */
223
- outbox(opts: {
224
- authors: readonly string[];
225
- kinds?: readonly number[];
226
- onEvent?: (event: Event) => void;
227
- maxRelaysPerAuthor?: number;
228
- }): OutboxFeed;
229
- getPublicKey(): Promise<string>;
230
- signEvent(unsigned: UnsignedEvent): Promise<Event>;
231
- signEventBuilder(builder: EventBuilder): Promise<Event>;
232
- signTemplate(template: EventTemplate): Promise<Event>;
233
- /**
234
- * Sign (if builder) and publish to relays.
235
- * With `gossip: true`, prefers the author's NIP-65 outbox relays, tagged `p`
236
- * inboxes, and up to 5 `e`/`a` tag relay hints when known.
237
- * On any successful OK, observes the event into storage/gossip.
238
- */
239
- publish(eventOrBuilder: Event | EventBuilder, opts?: PublishOptions): Promise<PoolPublishResult[]>;
240
- /**
241
- * Fetch events. With `gossip: true`, routes filters by NIP-65 when possible.
242
- * With `localFirst: true`, merges storage hits with network results.
243
- */
244
- fetchEvents(filter: Filter | Filter[], opts?: FetchEventsOptions): Promise<Event[]>;
245
- /**
246
- * Query local storage only (no network).
247
- */
248
- queryLocal(filter: Filter | Filter[]): Promise<Event[]>;
249
- subscribe(filter: Filter | Filter[], opts?: SubscribeOptions): {
250
- close: (reason?: string) => void;
251
- };
252
- /** Publish a kind:10050 NIP-17 DM relay list (`relay` tags). Not kind 10002. */
253
- setDmRelays(relays: readonly string[], opts?: PublishOptions): Promise<PoolPublishResult[]>;
254
- sendPrivateMessage(recipients: string | Recipient | readonly (string | Recipient)[], content: string, opts?: SendPrivateMessageOptions): Promise<PrivateMessageSendResult>;
255
- fetchPrivateMessages(opts?: FetchPrivateMessagesOptions): Promise<ReceivedPrivateMessage[]>;
256
- subscribePrivateMessages(opts?: SubscribePrivateMessagesOptions): Promise<{
257
- close: (reason?: string) => void;
258
- }>;
259
- /**
260
- * NIP-77 sync against one relay: reconcile, then optionally upload
261
- * local-only events and/or download remote-only events.
262
- * `observe: false` skips putMany and ingestMeta; received ids are still listed.
263
- * `persistEvents: false` skips putMany, still ingestMeta when observe is on.
264
- */
265
- syncToRelay(url: string, filter: Filter, opts?: Omit<SyncOptions, "relays">): Promise<SyncSummary>;
266
- /**
267
- * NIP-77 sync against the given relays (or Client default relays).
268
- * Independent sessions run in parallel. Fulfilled summaries are merged;
269
- * if every relay rejects, throws the first rejection in URL order.
270
- */
271
- sync(filter: Filter, opts?: SyncOptions): Promise<SyncSummary>;
272
- }
273
- //#endregion
274
- export { FetchPrivateMessagesOptions as a, ReceivedPrivateMessage as c, SubscribePrivateMessagesOptions as d, SyncDirection as f, ClientBuilder as g, SyncSummary as h, FetchEventsOptions as i, SendPrivateMessageOptions as l, SyncOptions as m, ClientError as n, PrivateMessageSendResult as o, SyncDirectionName as p, ClientOptions as r, PublishOptions as s, Client as t, SubscribeOptions as u };
275
- //# sourceMappingURL=index-DgOugrpF.d.mts.map
@@ -1,267 +0,0 @@
1
- import { t as Event } from "./event-B5D2jxt_.mjs";
2
- import { n as ProfileMetadata } from "./builder-BphJa-Y-.mjs";
3
- import { t as RelayListItem } from "./nip65-Di5hZRuV.mjs";
4
- import { t as Gossip } from "./gossip-C5RVB1UB.mjs";
5
- import { a as NostrError } from "./error-WEFS-R-4.mjs";
6
- import { t as Pool } from "./pool-DhRi7l-b.mjs";
7
- import { i as EventPointer, t as AddressPointer } from "./nip19-D7905oIv.mjs";
8
- import { r as OutboxBound, t as EventStore } from "./types-Dn24TPFs.mjs";
9
- //#region src/loaders/cache.d.ts
10
- type ReplaceableKey = {
11
- kind: number;
12
- pubkey: string;
13
- dTag?: string;
14
- };
15
- /** In-memory replaceable-event cache used by loaders (no DOM / localStorage). */
16
- declare class ReplaceableCache {
17
- #private;
18
- get(spec: ReplaceableKey): {
19
- event: Event | null;
20
- fetchedAt: number;
21
- } | undefined;
22
- set(spec: ReplaceableKey, event: Event | null, fetchedAt?: number): void;
23
- /** Keep newer event by created_at. */
24
- putIfNewer(event: Event, dTag?: string): void;
25
- clear(spec?: ReplaceableKey): void;
26
- get size(): number;
27
- }
28
- //#endregion
29
- //#region src/loaders/context.d.ts
30
- type LoaderContextOptions = {
31
- pool: Pool;
32
- /** Fallback / discovery relays when no per-user routing is known. */
33
- relays: readonly string[];
34
- cache?: ReplaceableCache;
35
- /** Max age (seconds) before a cached replaceable is considered stale. Default 2 days. */
36
- staleAfterSec?: number;
37
- fetchTimeoutMs?: number;
38
- };
39
- /**
40
- * Explicit dependency bag for loaders — never a module-level singleton.
41
- */
42
- declare class LoaderContext {
43
- #private;
44
- readonly pool: Pool;
45
- readonly cache: ReplaceableCache;
46
- readonly staleAfterSec: number;
47
- readonly fetchTimeoutMs: number;
48
- constructor(opts: LoaderContextOptions);
49
- /** Snapshot of discovery/fallback relays. */
50
- get relays(): readonly string[];
51
- addRelay(url: string): void;
52
- removeRelay(url: string): void;
53
- setRelays(urls: readonly string[]): void;
54
- isFresh(fetchedAt: number, now?: number): boolean;
55
- }
56
- //#endregion
57
- //#region src/loaders/dataloader.d.ts
58
- declare class LoaderError extends NostrError {}
59
- /** Minimal request coalescer. Batches keys within a microtask; no global state. */
60
- type BatchLoadFn<K, V> = (keys: readonly K[]) => Promise<readonly (V | Error)[]>;
61
- type DataLoaderOptions<K, C = K> = {
62
- cacheKeyFn?: (key: K) => C;
63
- maxBatchSize?: number;
64
- /** When false, only coalesces in-flight requests (no durable memoization). Default true. */
65
- cache?: boolean;
66
- };
67
- declare class DataLoader<K, V, C = K> {
68
- #private;
69
- constructor(batchLoadFn: BatchLoadFn<K, V>, options?: DataLoaderOptions<K, C>);
70
- load(key: K): Promise<V>;
71
- clear(key: K): void;
72
- clearAll(): void;
73
- }
74
- //#endregion
75
- //#region src/loaders/replaceable.d.ts
76
- type ReplaceableLoadResult = {
77
- event: Event | null;
78
- fresh: boolean;
79
- };
80
- type LoadStyle = "default" | "force" | "cache-only";
81
- /**
82
- * Batch-fetch replaceable events (kind + authors) via the pool, with cache.
83
- * Durable cache is ReplaceableCache; DataLoader only coalesces in-flight requests.
84
- */
85
- declare function createReplaceableLoader(ctx: LoaderContext, kind: number): {
86
- load(pubkey: string, opts?: {
87
- hints?: string[];
88
- style?: LoadStyle;
89
- }): Promise<ReplaceableLoadResult>;
90
- clear(pubkey?: string): void;
91
- };
92
- //#endregion
93
- //#region src/loaders/lists.d.ts
94
- type ListResult<T> = {
95
- event: Event | null;
96
- items: T[];
97
- fresh: boolean;
98
- };
99
- type MutedEntity = {
100
- label: "pubkey";
101
- value: string;
102
- } | {
103
- label: "thread";
104
- value: string;
105
- } | {
106
- label: "hashtag";
107
- value: string;
108
- } | {
109
- label: "word";
110
- value: string;
111
- };
112
- declare function createListLoaders(ctx: LoaderContext): {
113
- follows(pubkey: string, opts?: {
114
- hints?: string[];
115
- style?: LoadStyle;
116
- }): Promise<ListResult<string>>;
117
- muteList(pubkey: string, opts?: {
118
- hints?: string[];
119
- style?: LoadStyle;
120
- }): Promise<ListResult<MutedEntity>>;
121
- relayList(pubkey: string, opts?: {
122
- hints?: string[];
123
- style?: LoadStyle;
124
- }): Promise<ListResult<RelayListItem>>;
125
- dmRelayList(pubkey: string, opts?: {
126
- hints?: string[];
127
- style?: LoadStyle;
128
- }): Promise<ListResult<string>>;
129
- };
130
- type ListLoaders = ReturnType<typeof createListLoaders>;
131
- //#endregion
132
- //#region src/loaders/profile.d.ts
133
- type NostrUser = {
134
- pubkey: string;
135
- npub: string;
136
- shortName: string;
137
- image?: string;
138
- metadata: ProfileMetadata;
139
- lastUpdated: number;
140
- event: Event | null;
141
- fresh: boolean;
142
- };
143
- declare function bareNostrUser(pubkey: string): NostrUser;
144
- declare function createProfileLoader(ctx: LoaderContext): {
145
- load(pubkey: string, opts?: {
146
- hints?: string[];
147
- style?: LoadStyle;
148
- }): Promise<NostrUser>;
149
- };
150
- type ProfileLoader = ReturnType<typeof createProfileLoader>;
151
- //#endregion
152
- //#region src/loaders/event.d.ts
153
- type EventRef = string | EventPointer | AddressPointer;
154
- declare function createEventLoader(ctx: LoaderContext): {
155
- load(ref: EventRef): Promise<Event | undefined>;
156
- clearAll(): void;
157
- };
158
- type EventLoader = ReturnType<typeof createEventLoader>;
159
- //#endregion
160
- //#region src/loaders/outbox.d.ts
161
- declare class OutboxError extends NostrError {}
162
- type OutboxFeedOptions = {
163
- pool: Pool;
164
- gossip: Gossip;
165
- storage: EventStore;
166
- /** Fallback relays when an author has no known outbox routes. */
167
- discoveryRelays: readonly string[];
168
- authors: readonly string[];
169
- /** Event kinds to fetch. Default `[Kind.TextNote]`. */
170
- kinds?: readonly number[];
171
- /** Max write-relays to use per author. Default 3. */
172
- maxRelaysPerAuthor?: number;
173
- fetchTimeoutMs?: number;
174
- /** Called for live events after observe, and for sync events returned by applySync. */
175
- onEvent?: (event: Event) => void;
176
- /** Live ingest (e.g. `client.observe`). StartLive never putManys. */
177
- observe?: (event: Event) => void;
178
- /**
179
- * Sync path only. Awaited. Return events that should advance bounds.
180
- * Throw → sync throws, bounds unchanged.
181
- */
182
- applySync?: (events: readonly Event[]) => Promise<readonly Event[]>;
183
- /**
184
- * Load kind:10002 for authors before sync when routes are missing.
185
- * Requires a relay-list loader.
186
- */
187
- hydrate?: (pubkeys: readonly string[]) => Promise<void>;
188
- };
189
- /**
190
- * Group authors by outbox relay (discovery fallback).
191
- * `prefer` reorders existing candidates only; it never appends a URL
192
- * that is not already in the author's outbox or discovery list.
193
- * Returns Map<relayUrl, authors[]>.
194
- */
195
- declare function groupAuthorsByOutboxRelay(authors: readonly string[], gossip: Gossip, discoveryRelays: readonly string[], maxRelaysPerAuthor?: number, prefer?: readonly string[]): Map<string, string[]>;
196
- /**
197
- * Outbox-model feed: history sync + live subscription for a set of authors,
198
- * routed via NIP-65 write relays (with discovery fallback).
199
- */
200
- declare class OutboxFeed {
201
- #private;
202
- constructor(opts: OutboxFeedOptions);
203
- get authors(): readonly string[];
204
- get kinds(): readonly number[];
205
- /** Replace the author set (does not auto-restart live). */
206
- setAuthors(authors: readonly string[]): void;
207
- getBound(pubkey: string, kind: number): OutboxBound | undefined;
208
- /**
209
- * Load NIP-65 relay lists for authors that have no outbox routes yet.
210
- */
211
- hydrate(): Promise<void>;
212
- /**
213
- * One-shot history pull. Persistence is `applySync`; bounds move only for events it returns.
214
- */
215
- sync(opts?: {
216
- limit?: number;
217
- since?: number;
218
- until?: number;
219
- signal?: AbortSignal;
220
- /** Skip hydrate() even if provided. */
221
- skipHydrate?: boolean;
222
- }): Promise<Event[]>;
223
- /**
224
- * Start a live subscription across outbox relays for the current authors.
225
- * Closes any previous live subscription.
226
- */
227
- startLive(opts?: {
228
- signal?: AbortSignal;
229
- since?: number;
230
- }): {
231
- close: (reason?: string) => void;
232
- };
233
- /** Convenience: hydrate + sync + startLive. */
234
- start(opts?: {
235
- limit?: number;
236
- signal?: AbortSignal;
237
- }): Promise<{
238
- close: (reason?: string) => void;
239
- events: Event[];
240
- }>;
241
- close(): void;
242
- }
243
- /** Factory matching other loaders helpers. */
244
- declare function createOutboxFeed(opts: OutboxFeedOptions): OutboxFeed;
245
- //#endregion
246
- //#region src/loaders/index.d.ts
247
- type Loaders = {
248
- context: LoaderContext;
249
- follows: ListLoaders["follows"];
250
- muteList: ListLoaders["muteList"];
251
- relayList: ListLoaders["relayList"];
252
- dmRelayList: ListLoaders["dmRelayList"];
253
- profile: ProfileLoader["load"];
254
- event: EventLoader["load"];
255
- };
256
- type CreateLoadersOptions = {
257
- pool: Pool;
258
- relays: readonly string[];
259
- cache?: ReplaceableCache;
260
- staleAfterSec?: number;
261
- fetchTimeoutMs?: number;
262
- };
263
- /** Build an instance-scoped loader suite (no module globals). */
264
- declare function createLoaders(opts: CreateLoadersOptions): Loaders;
265
- //#endregion
266
- export { DataLoader as C, ReplaceableCache as D, LoaderContextOptions as E, createReplaceableLoader as S, LoaderContext as T, ListResult as _, OutboxFeed as a, LoadStyle as b, groupAuthorsByOutboxRelay as c, createEventLoader as d, NostrUser as f, ListLoaders as g, createProfileLoader as h, OutboxError as i, EventLoader as l, bareNostrUser as m, Loaders as n, OutboxFeedOptions as o, ProfileLoader as p, createLoaders as r, createOutboxFeed as s, CreateLoadersOptions as t, EventRef as u, MutedEntity as v, LoaderError as w, ReplaceableLoadResult as x, createListLoaders as y };
267
- //# sourceMappingURL=index-EwL6fHLo.d.mts.map
@@ -1,57 +0,0 @@
1
- import { t as Event } from "./event-B5D2jxt_.mjs";
2
- import { t as Filter } from "./filter-DUEKP3q1.mjs";
3
- import { i as PutResult, n as NegentropyItem, r as OutboxBound, t as EventStore } from "./types-Dn24TPFs.mjs";
4
- //#region src/storage/memory.d.ts
5
- /**
6
- * In-memory event store with NIP-01 replaceable / addressable / ephemeral
7
- * handling and NIP-09 deletion (kind 5) application.
8
- */
9
- declare class MemoryEventStore implements EventStore {
10
- #private;
11
- put(raw: Event): Promise<PutResult>;
12
- /** Sequential `put` in input order. No transaction: a throw leaves earlier events applied. */
13
- putMany(events: readonly Event[]): Promise<PutResult[]>;
14
- get(id: string): Promise<Event | undefined>;
15
- query(filters: Filter[]): Promise<Event[]>;
16
- count(filters: Filter[]): Promise<number>;
17
- negentropyItems(filter: Filter): Promise<NegentropyItem[]>;
18
- remove(ids: string[]): Promise<number>;
19
- getOutboxBound(pubkey: string, kind: number): Promise<OutboxBound | undefined>;
20
- setOutboxBound(pubkey: string, kind: number, bound: OutboxBound): Promise<void>;
21
- clear(): Promise<void>;
22
- get size(): number;
23
- }
24
- //#endregion
25
- //#region src/storage/indexeddb.d.ts
26
- type IndexedDbEventStoreOptions = {
27
- /** IndexedDB database name. */
28
- dbName?: string;
29
- };
30
- /**
31
- * Browser IndexedDB event store with the same replaceable / deletion semantics
32
- * as {@link MemoryEventStore}. Requires a DOM IndexedDB implementation.
33
- *
34
- * `open` loads every tombstone and address row into memory. Fine at 10^4 events;
35
- * tens of MB at 10^5 addressables.
36
- */
37
- declare class IndexedDbEventStore implements EventStore {
38
- #private;
39
- constructor(opts?: IndexedDbEventStoreOptions);
40
- static isAvailable(): boolean;
41
- open(): Promise<void>;
42
- put(event: Event): Promise<PutResult>;
43
- /** One readwrite transaction; abort rejects the whole batch with no partial persist. */
44
- putMany(events: readonly Event[]): Promise<PutResult[]>;
45
- get(id: string): Promise<Event | undefined>;
46
- query(filters: Filter[]): Promise<Event[]>;
47
- count(filters: Filter[]): Promise<number>;
48
- negentropyItems(filter: Filter): Promise<NegentropyItem[]>;
49
- getOutboxBound(pubkey: string, kind: number): Promise<OutboxBound | undefined>;
50
- setOutboxBound(pubkey: string, kind: number, bound: OutboxBound): Promise<void>;
51
- remove(ids: string[]): Promise<number>;
52
- clear(): Promise<void>;
53
- close(): void;
54
- }
55
- //#endregion
56
- export { IndexedDbEventStoreOptions as n, MemoryEventStore as r, IndexedDbEventStore as t };
57
- //# sourceMappingURL=index-k2YhCgsh.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"key-Dn-aX4x4.mjs","names":["#bytes"],"sources":["../src/core/key.ts"],"sourcesContent":["import { schnorr } from \"@noble/curves/secp256k1.js\";\nimport { CryptoError } from \"./error.ts\";\nimport {\n type Event,\n type EventTemplate,\n type UnsignedEvent,\n getEventHash,\n isMarkedFailed,\n isMarkedVerified,\n markUnverified,\n markVerified,\n validateEvent,\n validateSignedEvent,\n} from \"./event.ts\";\nimport { assertHex32, assertSecretKeyBytes, bytesToHex, hexToBytes } from \"./util.ts\";\n\n/** 32-byte secret key held as bytes; prefer zeroize when done. */\nexport class SecretKey {\n #bytes: Uint8Array | null;\n\n private constructor(bytes: Uint8Array) {\n assertSecretKeyBytes(bytes);\n this.#bytes = new Uint8Array(bytes);\n }\n\n static generate(): SecretKey {\n return new SecretKey(schnorr.utils.randomSecretKey());\n }\n\n static fromBytes(bytes: Uint8Array): SecretKey {\n return new SecretKey(bytes);\n }\n\n static fromHex(hex: string): SecretKey {\n return new SecretKey(hexToBytes(assertHex32(hex, \"secret key\")));\n }\n\n get bytes(): Uint8Array {\n if (!this.#bytes) throw new CryptoError(\"secret key has been zeroized\");\n return new Uint8Array(this.#bytes);\n }\n\n toHex(): string {\n return bytesToHex(this.bytes);\n }\n\n /** Best-effort wipe of the internal buffer. */\n zeroize(): void {\n if (this.#bytes) {\n this.#bytes.fill(0);\n this.#bytes = null;\n }\n }\n}\n\nexport type PublicKey = string;\n\nexport function publicKeyFromHex(hex: string): PublicKey {\n return assertHex32(hex, \"public key\");\n}\n\nexport function getPublicKey(secretKey: SecretKey | Uint8Array | string): PublicKey {\n const bytes =\n secretKey instanceof SecretKey\n ? secretKey.bytes\n : typeof secretKey === \"string\"\n ? hexToBytes(assertHex32(secretKey, \"secret key\"))\n : (assertSecretKeyBytes(secretKey), secretKey);\n return bytesToHex(schnorr.getPublicKey(bytes));\n}\n\n/** Keypair convenience wrapper. */\nexport class Keys {\n readonly secretKey: SecretKey;\n readonly publicKey: PublicKey;\n\n private constructor(secretKey: SecretKey) {\n this.secretKey = secretKey;\n this.publicKey = getPublicKey(secretKey);\n }\n\n static generate(): Keys {\n return new Keys(SecretKey.generate());\n }\n\n static fromSecretKey(secretKey: SecretKey | Uint8Array | string): Keys {\n const sk =\n secretKey instanceof SecretKey\n ? secretKey\n : typeof secretKey === \"string\"\n ? SecretKey.fromHex(secretKey)\n : SecretKey.fromBytes(secretKey);\n return new Keys(sk);\n }\n}\n\nfunction resolveSecretKeyBytes(secretKey: SecretKey | Uint8Array | string): Uint8Array {\n if (secretKey instanceof SecretKey) return secretKey.bytes;\n if (typeof secretKey === \"string\") return hexToBytes(assertHex32(secretKey, \"secret key\"));\n assertSecretKeyBytes(secretKey);\n return secretKey;\n}\n\n/** Fill pubkey/id/sig on a template and return a signed event. */\nexport function finalizeEvent(\n template: EventTemplate,\n secretKey: SecretKey | Uint8Array | string,\n): Event {\n const sk = resolveSecretKeyBytes(secretKey);\n const pubkey = bytesToHex(schnorr.getPublicKey(sk));\n const unsigned: UnsignedEvent = {\n kind: template.kind,\n tags: template.tags,\n content: template.content,\n created_at: template.created_at,\n pubkey,\n };\n return signEvent(unsigned, sk);\n}\n\n/**\n * Sign an already-assembled unsigned event.\n * Rejects when `unsigned.pubkey` does not match the secret key.\n */\nexport function signEvent(\n unsigned: UnsignedEvent,\n secretKey: SecretKey | Uint8Array | string,\n): Event {\n const sk = resolveSecretKeyBytes(secretKey);\n if (!validateEvent(unsigned)) {\n throw new CryptoError(\"cannot sign invalid unsigned event\");\n }\n\n const expected = bytesToHex(schnorr.getPublicKey(sk));\n if (unsigned.pubkey.toLowerCase() !== expected) {\n throw new CryptoError(\"unsigned event pubkey does not match secret key\");\n }\n\n const normalized: UnsignedEvent = {\n kind: unsigned.kind,\n tags: unsigned.tags,\n content: unsigned.content,\n created_at: unsigned.created_at,\n pubkey: expected,\n };\n\n const id = getEventHash(normalized);\n const sig = bytesToHex(schnorr.sign(hexToBytes(id), sk));\n const event: Event = { ...normalized, id, sig };\n markVerified(event);\n return event;\n}\n\n/** Verify event id and BIP-340 signature. Uses WeakSet cache (does not mutate the event). */\nexport function verifyEvent(event: Event): boolean {\n if (isMarkedVerified(event)) return true;\n if (isMarkedFailed(event)) return false;\n\n if (!validateSignedEvent(event)) {\n markUnverified(event);\n return false;\n }\n\n try {\n const hash = getEventHash(event);\n if (hash !== event.id.toLowerCase()) {\n markUnverified(event);\n return false;\n }\n const ok = schnorr.verify(\n hexToBytes(event.sig.toLowerCase()),\n hexToBytes(hash),\n hexToBytes(event.pubkey.toLowerCase()),\n );\n if (ok) markVerified(event);\n else markUnverified(event);\n return ok;\n } catch {\n markUnverified(event);\n return false;\n }\n}\n"],"mappings":"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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"kind-BLl4cLOc.mjs","names":[],"sources":["../src/core/kind.ts"],"sourcesContent":["/** NIP-01 regular: stored by relays. */\nexport function isRegularKind(kind: number): boolean {\n return kind === 1 || kind === 2 || (kind >= 4 && kind < 45) || (kind >= 1000 && kind < 10000);\n}\n\n/** Replaceable: latest per (pubkey, kind) wins. */\nexport function isReplaceableKind(kind: number): boolean {\n return kind === 0 || kind === 3 || (kind >= 10000 && kind < 20000);\n}\n\n/** Ephemeral: not expected to be stored. */\nexport function isEphemeralKind(kind: number): boolean {\n return kind >= 20000 && kind < 30000;\n}\n\n/** Addressable (parameterized replaceable): latest per (pubkey, kind, d-tag) wins. */\nexport function isAddressableKind(kind: number): boolean {\n return kind >= 30000 && kind < 40000;\n}\n\nexport type KindClassification =\n | \"regular\"\n | \"replaceable\"\n | \"ephemeral\"\n | \"addressable\"\n | \"unknown\";\n\nexport function classifyKind(kind: number): KindClassification {\n if (isRegularKind(kind)) return \"regular\";\n if (isReplaceableKind(kind)) return \"replaceable\";\n if (isEphemeralKind(kind)) return \"ephemeral\";\n if (isAddressableKind(kind)) return \"addressable\";\n return \"unknown\";\n}\n\n/** Kind numbers used by this package. */\nexport const Kind = {\n Metadata: 0,\n TextNote: 1,\n Contacts: 3,\n EventDeletion: 5,\n Repost: 6,\n Reaction: 7,\n Seal: 13,\n PrivateDirectMessage: 14,\n GenericRepost: 16,\n GiftWrap: 1059,\n ZapRequest: 9734,\n Zap: 9735,\n MuteList: 10000,\n PinList: 10001,\n RelayList: 10002,\n BookmarkList: 10003,\n FavoriteRelays: 10012,\n UserEmojiList: 10030,\n DirectMessageRelaysList: 10050,\n BlossomServerList: 10063,\n GiftWrapEphemeral: 21059,\n ClientAuth: 22242,\n NostrConnect: 24133,\n BlobsAuth: 24242,\n HttpAuth: 27235,\n RelaySets: 30002,\n EmojiSet: 30030,\n StarterPack: 39089,\n} as const;\n\nexport type KindName = keyof typeof Kind;\nexport type KnownKind = (typeof Kind)[KindName];\n"],"mappings":";;AACA,SAAgB,cAAc,MAAuB;CACnD,OAAO,SAAS,KAAK,SAAS,KAAM,QAAQ,KAAK,OAAO,MAAQ,QAAQ,OAAQ,OAAO;AACzF;;AAGA,SAAgB,kBAAkB,MAAuB;CACvD,OAAO,SAAS,KAAK,SAAS,KAAM,QAAQ,OAAS,OAAO;AAC9D;;AAGA,SAAgB,gBAAgB,MAAuB;CACrD,OAAO,QAAQ,OAAS,OAAO;AACjC;;AAGA,SAAgB,kBAAkB,MAAuB;CACvD,OAAO,QAAQ,OAAS,OAAO;AACjC;AASA,SAAgB,aAAa,MAAkC;CAC7D,IAAI,cAAc,IAAI,GAAG,OAAO;CAChC,IAAI,kBAAkB,IAAI,GAAG,OAAO;CACpC,IAAI,gBAAgB,IAAI,GAAG,OAAO;CAClC,IAAI,kBAAkB,IAAI,GAAG,OAAO;CACpC,OAAO;AACT;;AAGA,MAAa,OAAO;CAClB,UAAU;CACV,UAAU;CACV,UAAU;CACV,eAAe;CACf,QAAQ;CACR,UAAU;CACV,MAAM;CACN,sBAAsB;CACtB,eAAe;CACf,UAAU;CACV,YAAY;CACZ,KAAK;CACL,UAAU;CACV,SAAS;CACT,WAAW;CACX,cAAc;CACd,gBAAgB;CAChB,eAAe;CACf,yBAAyB;CACzB,mBAAmB;CACnB,mBAAmB;CACnB,YAAY;CACZ,cAAc;CACd,WAAW;CACX,UAAU;CACV,WAAW;CACX,UAAU;CACV,aAAa;AACf"}