@qntx/nostr 0.11.0 → 0.13.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 (164) hide show
  1. package/dist/{builder-GBddxj8i.d.mts → builder-C72nJITG.d.mts} +2 -2
  2. package/dist/{builder-BQbFDO6S.mjs → builder-CGgM_QHT.mjs} +5 -5
  3. package/dist/{builder-BQbFDO6S.mjs.map → builder-CGgM_QHT.mjs.map} +1 -1
  4. package/dist/{client-CTmp5w84.mjs → client-COkEihj_.mjs} +87 -79
  5. package/dist/client-COkEihj_.mjs.map +1 -0
  6. package/dist/client.d.mts +1 -1
  7. package/dist/client.mjs +1 -1
  8. package/dist/core.d.mts +7 -7
  9. package/dist/core.mjs +9 -9
  10. package/dist/{emitter-DkCY6NkU.mjs → emitter-u4kJqQDk.mjs} +2 -2
  11. package/dist/{emitter-DkCY6NkU.mjs.map → emitter-u4kJqQDk.mjs.map} +1 -1
  12. package/dist/{error-BquXDmIN.d.mts → error-BPqAU5RB.d.mts} +2 -6
  13. package/dist/{error-BD_0QFKT.d.mts → error-BjSUsx6M.d.mts} +2 -2
  14. package/dist/{error-UHkqzWL7.mjs → error-Dyb89ahb.mjs} +7 -3
  15. package/dist/error-Dyb89ahb.mjs.map +1 -0
  16. package/dist/{error-DH4guike.mjs → error-QyECUDIp.mjs} +2 -2
  17. package/dist/{error-DH4guike.mjs.map → error-QyECUDIp.mjs.map} +1 -1
  18. package/dist/{event-B3ua2_oL.mjs → event-DvM1f03b.mjs} +7 -3
  19. package/dist/event-DvM1f03b.mjs.map +1 -0
  20. package/dist/{filter-B16P33dz.mjs → filter-3jOh4uLN.mjs} +50 -20
  21. package/dist/filter-3jOh4uLN.mjs.map +1 -0
  22. package/dist/{filter-PG7r79rt.d.mts → filter-oYG2zjJ3.d.mts} +6 -2
  23. package/dist/{gossip-BTMdlUI7.d.mts → gossip-BvCItMVZ.d.mts} +3 -3
  24. package/dist/{gossip-K_JIexQs.mjs → gossip-CRyhK6E6.mjs} +4 -4
  25. package/dist/{gossip-K_JIexQs.mjs.map → gossip-CRyhK6E6.mjs.map} +1 -1
  26. package/dist/gossip.d.mts +1 -1
  27. package/dist/gossip.mjs +1 -1
  28. package/dist/http-CuazNRIP.mjs.map +1 -1
  29. package/dist/{index-DD0Ywpay.d.mts → index-B2JlP2Jf.d.mts} +9 -9
  30. package/dist/{index-BP94lABY.d.mts → index-DCobP2Jj.d.mts} +10 -10
  31. package/dist/{index-Hp26bgYG.d.mts → index-Dpj_MUxb.d.mts} +8 -5
  32. package/dist/{index-rKcmI6ex.d.mts → index-DzHmhHqD.d.mts} +3 -3
  33. package/dist/{index-N7HUGgwo.d.mts → index-YID-zPDF.d.mts} +58 -8
  34. package/dist/{index-CSsnE32i.d.mts → index-muydfuYD.d.mts} +21 -21
  35. package/dist/index.d.mts +19 -20
  36. package/dist/index.mjs +20 -20
  37. package/dist/{key-k8LDEPZh.mjs → key-D_oEutQ6.mjs} +32 -9
  38. package/dist/key-D_oEutQ6.mjs.map +1 -0
  39. package/dist/{key-CyKN1RTi.d.mts → key-DojW2QZl.d.mts} +14 -4
  40. package/dist/{kind-D8fENiiL.mjs → kind-I2Tvbe82.mjs} +6 -5
  41. package/dist/kind-I2Tvbe82.mjs.map +1 -0
  42. package/dist/{loaders-Dp2nXEFk.mjs → loaders-BRh2riV9.mjs} +17 -16
  43. package/dist/loaders-BRh2riV9.mjs.map +1 -0
  44. package/dist/loaders.d.mts +2 -2
  45. package/dist/loaders.mjs +1 -1
  46. package/dist/{memory-VyPnOBU3.mjs → memory-D_GdEQYG.mjs} +2 -2
  47. package/dist/memory-D_GdEQYG.mjs.map +1 -0
  48. package/dist/memory-index-3GSrPIWj.mjs +671 -0
  49. package/dist/memory-index-3GSrPIWj.mjs.map +1 -0
  50. package/dist/{message-pYfVKxPn.mjs → message-BMfreCQc.mjs} +6 -6
  51. package/dist/message-BMfreCQc.mjs.map +1 -0
  52. package/dist/{nip17-B7MI82Iq.d.mts → nip17-BZvFQLcs.d.mts} +5 -5
  53. package/dist/{nip19-DpPN17bY.d.mts → nip19-D4RKn6GC.d.mts} +2 -2
  54. package/dist/{nip46-BHaxC9TZ.d.mts → nip46-i8L8_nIm.d.mts} +2 -2
  55. package/dist/{nip51-O_vhOiK2.d.mts → nip51-C_kTYcud.d.mts} +2 -2
  56. package/dist/{nip59-CdDoJptA.d.mts → nip59-DfJ6Moeu.d.mts} +15 -7
  57. package/dist/{nip65-BL79HI8N.d.mts → nip65-CPNE0SV0.d.mts} +2 -2
  58. package/dist/{nip77-wHA_nEV5.d.mts → nip77-DhpoL7d8.d.mts} +2 -2
  59. package/dist/nips/blossom.d.mts +2 -2
  60. package/dist/nips/blossom.mjs +3 -3
  61. package/dist/nips/blossom.mjs.map +1 -1
  62. package/dist/nips/nip04.d.mts +11 -4
  63. package/dist/nips/nip04.mjs +44 -21
  64. package/dist/nips/nip04.mjs.map +1 -1
  65. package/dist/nips/nip05.d.mts +6 -3
  66. package/dist/nips/nip05.mjs +6 -3
  67. package/dist/nips/nip05.mjs.map +1 -1
  68. package/dist/nips/nip10.d.mts +2 -2
  69. package/dist/nips/nip10.mjs +4 -4
  70. package/dist/nips/nip11.d.mts +1 -1
  71. package/dist/nips/nip11.mjs +1 -1
  72. package/dist/nips/nip13.d.mts +1 -1
  73. package/dist/nips/nip13.mjs +1 -1
  74. package/dist/nips/nip13.mjs.map +1 -1
  75. package/dist/nips/nip17.d.mts +1 -1
  76. package/dist/nips/nip17.mjs +5 -5
  77. package/dist/nips/nip17.mjs.map +1 -1
  78. package/dist/nips/nip19.d.mts +1 -1
  79. package/dist/nips/nip19.mjs +2 -2
  80. package/dist/nips/nip19.mjs.map +1 -1
  81. package/dist/nips/nip21.d.mts +6 -3
  82. package/dist/nips/nip21.mjs +8 -5
  83. package/dist/nips/nip21.mjs.map +1 -1
  84. package/dist/nips/nip27.d.mts +1 -1
  85. package/dist/nips/nip27.mjs +15 -9
  86. package/dist/nips/nip27.mjs.map +1 -1
  87. package/dist/nips/nip42.mjs +2 -2
  88. package/dist/nips/nip44.d.mts +5 -0
  89. package/dist/nips/nip44.mjs +10 -3
  90. package/dist/nips/nip44.mjs.map +1 -1
  91. package/dist/nips/nip46.d.mts +1 -1
  92. package/dist/nips/nip46.mjs +9 -7
  93. package/dist/nips/nip46.mjs.map +1 -1
  94. package/dist/nips/nip49.d.mts +8 -2
  95. package/dist/nips/nip49.mjs +17 -3
  96. package/dist/nips/nip49.mjs.map +1 -1
  97. package/dist/nips/nip51.d.mts +1 -1
  98. package/dist/nips/nip51.mjs +5 -5
  99. package/dist/nips/nip51.mjs.map +1 -1
  100. package/dist/nips/nip57.mjs +6 -5
  101. package/dist/nips/nip57.mjs.map +1 -1
  102. package/dist/nips/nip59.d.mts +1 -1
  103. package/dist/nips/nip59.mjs +51 -23
  104. package/dist/nips/nip59.mjs.map +1 -1
  105. package/dist/nips/nip65.d.mts +1 -1
  106. package/dist/nips/nip65.mjs +3 -3
  107. package/dist/nips/nip77.d.mts +1 -1
  108. package/dist/nips/nip77.mjs +1 -1
  109. package/dist/nips/nip77.mjs.map +1 -1
  110. package/dist/nips/nip98.d.mts +1 -1
  111. package/dist/nips/nip98.mjs +18 -7
  112. package/dist/nips/nip98.mjs.map +1 -1
  113. package/dist/{pool-DUuYJ0x4.d.mts → pool-MehgIIzm.d.mts} +20 -16
  114. package/dist/{pool-BMUsw2un.mjs → pool-lMT_mvzn.mjs} +25 -25
  115. package/dist/pool-lMT_mvzn.mjs.map +1 -0
  116. package/dist/{put-DRmV1wHD.mjs → put-BEM5j8xK.mjs} +5 -5
  117. package/dist/{put-DRmV1wHD.mjs.map → put-BEM5j8xK.mjs.map} +1 -1
  118. package/dist/{reactive-jyKrA9ej.d.mts → reactive-B7lPFgTS.d.mts} +3 -3
  119. package/dist/{reactive--pDpLt2H.mjs → reactive-DFHY-f00.mjs} +24 -9
  120. package/dist/reactive-DFHY-f00.mjs.map +1 -0
  121. package/dist/{relay-DXtwUEdX.mjs → relay-DIR77xQ2.mjs} +102 -89
  122. package/dist/relay-DIR77xQ2.mjs.map +1 -0
  123. package/dist/relay.d.mts +5 -5
  124. package/dist/relay.mjs +3 -3
  125. package/dist/{report-CHld4uWj.mjs → report-D2BM5dgn.mjs} +2 -2
  126. package/dist/{report-CHld4uWj.mjs.map → report-D2BM5dgn.mjs.map} +1 -1
  127. package/dist/{signer-CWtxpOxc.mjs → signer-DJcmC4nA.mjs} +176 -17
  128. package/dist/signer-DJcmC4nA.mjs.map +1 -0
  129. package/dist/signer.d.mts +2 -2
  130. package/dist/signer.mjs +3 -3
  131. package/dist/{storage-B5Wdt_Mn.mjs → storage-n2BE1bdY.mjs} +108 -179
  132. package/dist/storage-n2BE1bdY.mjs.map +1 -0
  133. package/dist/storage.d.mts +3 -3
  134. package/dist/storage.mjs +4 -4
  135. package/dist/store.d.mts +1 -1
  136. package/dist/store.mjs +1 -1
  137. package/dist/testing.d.mts +4 -4
  138. package/dist/testing.mjs +35 -10
  139. package/dist/testing.mjs.map +1 -1
  140. package/dist/{types-CqhnT-Mx.d.mts → types-DiVVyf1e.d.mts} +2 -2
  141. package/dist/{util-DDpPkiED.mjs → util-DfsyJ9nz.mjs} +30 -10
  142. package/dist/util-DfsyJ9nz.mjs.map +1 -0
  143. package/dist/{verifier-CjH1vnP2.mjs → verifier-DEHUy4AD.mjs} +3 -3
  144. package/dist/{verifier-CjH1vnP2.mjs.map → verifier-DEHUy4AD.mjs.map} +1 -1
  145. package/dist/{verifier-Cl24c9ph.d.mts → verifier-DhAbqVJF.d.mts} +2 -2
  146. package/dist/{websocket-CmeqvAkp.d.mts → websocket-DaCvJkF9.d.mts} +2 -5
  147. package/package.json +4 -3
  148. package/dist/client-CTmp5w84.mjs.map +0 -1
  149. package/dist/error-UHkqzWL7.mjs.map +0 -1
  150. package/dist/event-B3ua2_oL.mjs.map +0 -1
  151. package/dist/filter-B16P33dz.mjs.map +0 -1
  152. package/dist/key-k8LDEPZh.mjs.map +0 -1
  153. package/dist/kind-D8fENiiL.mjs.map +0 -1
  154. package/dist/loaders-Dp2nXEFk.mjs.map +0 -1
  155. package/dist/memory-VyPnOBU3.mjs.map +0 -1
  156. package/dist/memory-index-Bhwe0ZdG.mjs +0 -374
  157. package/dist/memory-index-Bhwe0ZdG.mjs.map +0 -1
  158. package/dist/message-pYfVKxPn.mjs.map +0 -1
  159. package/dist/pool-BMUsw2un.mjs.map +0 -1
  160. package/dist/reactive--pDpLt2H.mjs.map +0 -1
  161. package/dist/relay-DXtwUEdX.mjs.map +0 -1
  162. package/dist/signer-CWtxpOxc.mjs.map +0 -1
  163. package/dist/storage-B5Wdt_Mn.mjs.map +0 -1
  164. package/dist/util-DDpPkiED.mjs.map +0 -1
@@ -1,9 +1,9 @@
1
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-PG7r79rt.mjs";
4
- import { a as NostrError } from "./error-BquXDmIN.mjs";
2
+ import { i as SecretKeyInput, t as Keys } from "./key-DojW2QZl.mjs";
3
+ import { t as Filter } from "./filter-oYG2zjJ3.mjs";
4
+ import { a as NostrError } from "./error-BPqAU5RB.mjs";
5
5
  import { t as NostrSigner } from "./types-BJ4wZ7JJ.mjs";
6
- import { n as ClientMetadata, t as BunkerPointer } from "./nip46-BHaxC9TZ.mjs";
6
+ import { n as ClientMetadata, t as BunkerPointer } from "./nip46-i8L8_nIm.mjs";
7
7
  //#region src/signer/error.d.ts
8
8
  /**
9
9
  * Thrown by a lazy NIP-42 AUTH sign function when no signer is configured at challenge time.
@@ -13,12 +13,57 @@ import { n as ClientMetadata, t as BunkerPointer } from "./nip46-BHaxC9TZ.mjs";
13
13
  declare class NoSignerError extends NostrError {
14
14
  name: string;
15
15
  }
16
+ /** Thrown when a method is called on a signer after {@link NostrSigner dispose}. */
17
+ declare class SignerDisposedError extends NostrError {
18
+ name: string;
19
+ }
20
+ //#endregion
21
+ //#region src/signer/delegated.d.ts
22
+ /**
23
+ * The three operations an external key holder (wallet keyring, NFC card, platform secure store)
24
+ * provides. The secret itself never enters this process.
25
+ */
26
+ type NostrKeyOperations = {
27
+ /** Lowercase 64-char hex x-only public key. */
28
+ getPublicKey: () => Promise<string>;
29
+ /** 64-byte BIP-340 signature over the 32-byte event id. */
30
+ signEventId: (id: Uint8Array) => Promise<Uint8Array>;
31
+ /**
32
+ * Optional. 32-byte x-coordinate of `ECDH(secret, lift_x(peer))`, unhashed. Enables NIP-04 and
33
+ * NIP-44.
34
+ */
35
+ sharedSecret?: (peer: string) => Promise<Uint8Array>;
36
+ };
37
+ /**
38
+ * {@link NostrSigner} backed by a {@link NostrKeyOperations} key holder. The signer verifies
39
+ * everything the holder returns: the public key shape, the signature length, and the BIP-340
40
+ * signature itself — a misbehaving holder never produces an event relays would reject.
41
+ */
42
+ declare class DelegatedSigner implements NostrSigner {
43
+ #private;
44
+ constructor(operations: NostrKeyOperations);
45
+ getPublicKey(): Promise<string>;
46
+ signEvent(unsigned: UnsignedEvent): Promise<Event>;
47
+ nip44Encrypt(peer: string, plaintext: string): Promise<string>;
48
+ nip44Decrypt(peer: string, payload: string): Promise<string>;
49
+ nip04Encrypt(peer: string, plaintext: string): Promise<string>;
50
+ nip04Decrypt(peer: string, ciphertext: string): Promise<string>;
51
+ /**
52
+ * Zero-fill and clear every cached NIP-44 conversation key. All later calls reject with
53
+ * {@link SignerDisposedError} and never reach the key holder. Idempotent.
54
+ */
55
+ dispose(): void;
56
+ }
16
57
  //#endregion
17
58
  //#region src/signer/keys.d.ts
18
59
  /** Local secret-key signer with NIP-04 (legacy) and NIP-44 support. */
19
60
  declare class KeysSigner implements NostrSigner {
20
61
  #private;
21
62
  constructor(secretKey: SecretKeyInput | Keys);
63
+ /**
64
+ * The live {@link Keys} instance holding the secret material. {@link KeysSigner.dispose} zeroizes
65
+ * it, so a reference obtained earlier reports a zeroized secret afterwards.
66
+ */
22
67
  get keys(): Keys;
23
68
  getPublicKey(): Promise<string>;
24
69
  signEvent(unsigned: UnsignedEvent): Promise<Event>;
@@ -26,6 +71,11 @@ declare class KeysSigner implements NostrSigner {
26
71
  nip04Decrypt(peer: string, ciphertext: string): Promise<string>;
27
72
  nip44Encrypt(peer: string, plaintext: string): Promise<string>;
28
73
  nip44Decrypt(peer: string, payload: string): Promise<string>;
74
+ /**
75
+ * Zeroize the wrapped secret key and every cached NIP-44 conversation key. All later calls reject
76
+ * with {@link SignerDisposedError}. Idempotent.
77
+ */
78
+ dispose(): void;
29
79
  }
30
80
  //#endregion
31
81
  //#region src/signer/nip07.d.ts
@@ -69,8 +119,8 @@ declare class Nip07Signer implements NostrSigner {
69
119
  /** Subscribe options used by NIP-46 transport (structural subset of Pool). */
70
120
  type Nip46SubscribeOptions = {
71
121
  signal?: AbortSignal | undefined;
72
- onevent?: ((event: Event) => void) | undefined;
73
- onclose?: ((reason: string) => void) | undefined;
122
+ onEvent?: ((event: Event) => void) | undefined;
123
+ onClose?: ((reason: string) => void) | undefined;
74
124
  };
75
125
  /**
76
126
  * Structural relay transport for NIP-46 RPC. Satisfied by {@link import("../relay/pool.ts").Pool};
@@ -173,5 +223,5 @@ declare class Nip46Signer implements NostrSigner {
173
223
  close(): Promise<void>;
174
224
  }
175
225
  //#endregion
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-N7HUGgwo.d.mts.map
226
+ export { Nip07Signer as a, isNip07Available as c, NostrKeyOperations as d, NoSignerError as f, Nip46Transport as i, KeysSigner as l, Nip46SignerOptions as n, WindowNostr as o, SignerDisposedError as p, Nip46SubscribeOptions as r, getWindowNostr as s, Nip46Signer as t, DelegatedSigner as u };
227
+ //# sourceMappingURL=index-YID-zPDF.d.mts.map
@@ -1,16 +1,16 @@
1
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-PG7r79rt.mjs";
4
- import { t as Gossip } from "./gossip-BTMdlUI7.mjs";
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-DUuYJ0x4.mjs";
7
- import { t as EventStore } from "./types-CqhnT-Mx.mjs";
8
- import { t as ReactiveEventStore } from "./reactive-jyKrA9ej.mjs";
9
- import { a as OutboxFeed, n as Loaders } from "./index-BP94lABY.mjs";
10
- import { a as Rumor } from "./nip59-CdDoJptA.mjs";
11
- import { i as ReplyTo, r as Recipient } from "./nip17-B7MI82Iq.mjs";
2
+ import { t as EventBuilder } from "./builder-C72nJITG.mjs";
3
+ import { t as Filter } from "./filter-oYG2zjJ3.mjs";
4
+ import { t as Gossip } from "./gossip-BvCItMVZ.mjs";
5
+ import { a as NostrError } from "./error-BPqAU5RB.mjs";
6
+ import { _ as Closer, a as PoolFetchResult, n as Pool, o as PoolOptions, s as PoolPublishResult } from "./pool-MehgIIzm.mjs";
7
+ import { t as EventStore } from "./types-DiVVyf1e.mjs";
8
+ import { t as ReactiveEventStore } from "./reactive-B7lPFgTS.mjs";
9
+ import { a as OutboxFeed, n as Loaders } from "./index-DCobP2Jj.mjs";
10
+ import { a as Rumor } from "./nip59-DfJ6Moeu.mjs";
11
+ import { i as ReplyTo, r as Recipient } from "./nip17-BZvFQLcs.mjs";
12
12
  import { t as NostrSigner } from "./types-BJ4wZ7JJ.mjs";
13
- import { t as StorageError } from "./error-BD_0QFKT.mjs";
13
+ import { t as StorageError } from "./error-BjSUsx6M.mjs";
14
14
  //#region src/client/types.d.ts
15
15
  /** Direction of a {@link Client.sync} run: upload, download, or both. */
16
16
  declare const SyncDirection: {
@@ -97,7 +97,7 @@ type FetchEventsOptions = {
97
97
  * Every event of every relay batch, including duplicates across relays. `relayUrl` is the
98
98
  * normalized URL of the relay that delivered it.
99
99
  */
100
- onevent?: ((event: Event, relayUrl: string) => void) | undefined;
100
+ onEvent?: ((event: Event, relayUrl: string) => void) | undefined;
101
101
  };
102
102
  /** Options for {@link Client.fetchEach}: one-shot per-relay fetch, no gossip routing. */
103
103
  type FetchEachOptions = {
@@ -113,15 +113,15 @@ type SubscribeOptions = {
113
113
  * First receipt of each event only (deduped across relays). `relayUrl` is the normalized URL of
114
114
  * the relay that delivered it first.
115
115
  */
116
- onevent?: ((event: Event, relayUrl: string) => void) | undefined;
116
+ onEvent?: ((event: Event, relayUrl: string) => void) | undefined;
117
117
  /** Every receipt from every relay, including duplicates skipped by dedupe. */
118
- receivedEvent?: ((id: string, relayUrl: string) => void) | undefined;
119
- oneose?: (() => void) | undefined;
120
- onclose?: ((reason: string) => void) | undefined;
118
+ onEventSeen?: ((id: string, relayUrl: string) => void) | undefined;
119
+ onEose?: (() => void) | undefined;
120
+ onClose?: ((reason: string) => void) | undefined;
121
121
  signal?: AbortSignal | undefined;
122
122
  id?: string | undefined;
123
123
  /**
124
- * If set, fire `oneose` once after this many ms if not all relays have EOSEd. Does not close the
124
+ * If set, fire `onEose` once after this many ms if not all relays have EOSEd. Does not close the
125
125
  * subscription.
126
126
  */
127
127
  eoseTimeoutMs?: number | undefined;
@@ -176,9 +176,9 @@ type FetchPrivateMessagesOptions = {
176
176
  /** Options for a live NIP-17 private-message subscription. */
177
177
  type SubscribePrivateMessagesOptions = {
178
178
  readonly since?: number | undefined;
179
- readonly onevent?: ((msg: ReceivedPrivateMessage) => void) | undefined;
180
- readonly oneose?: (() => void) | undefined;
181
- readonly onclose?: ((reason: string) => void) | undefined;
179
+ readonly onEvent?: ((msg: ReceivedPrivateMessage) => void) | undefined;
180
+ readonly onEose?: (() => void) | undefined;
181
+ readonly onClose?: ((reason: string) => void) | undefined;
182
182
  readonly signal?: AbortSignal | undefined;
183
183
  readonly eoseTimeoutMs?: number | undefined;
184
184
  readonly observe?: boolean | undefined;
@@ -290,4 +290,4 @@ declare class Client {
290
290
  }
291
291
  //#endregion
292
292
  export { SyncSummary as _, FetchEachOptions as a, PrivateMessageSendResult as c, SendPrivateMessageOptions as d, SubscribeOptions as f, SyncOptions as g, SyncDirectionName as h, ClientOptions as i, PublishOptions as l, SyncDirection as m, ClientError as n, FetchEventsOptions as o, SubscribePrivateMessagesOptions as p, ClientEventMap as r, FetchPrivateMessagesOptions as s, Client as t, ReceivedPrivateMessage as u };
293
- //# sourceMappingURL=index-CSsnE32i.d.mts.map
293
+ //# sourceMappingURL=index-muydfuYD.d.mts.map
package/dist/index.d.mts CHANGED
@@ -1,25 +1,24 @@
1
1
  import { C as tagName, S as parseEventAddress, _ as eventAddress, b as getDTag, c as serializeEvent, d as sortedEvents, f as validateEvent, g as TagInput, h as Tag, i as getEventHash, l as signedMatchesUnsigned, m as EventAddress, n as EventTemplate, o as isReplaceableWinner, p as validateSignedEvent, r as UnsignedEvent, s as itemCompare, t as Event, u as sortEvents, w as tagValue, x as isTag, y as formatEventAddress } from "./event-j3BwI5dF.mjs";
2
- 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-PG7r79rt.mjs";
5
- import { a as relayListEventBuilder, i as readRelays, n as RelayMarker, o as relayListToTags, r as parseRelayList, s as writeRelays, t as RelayListItem } from "./nip65-BL79HI8N.mjs";
6
- import { i as RoutedFilter, r as PubkeyRoutes, t as Gossip } from "./gossip-BTMdlUI7.mjs";
7
- import { a as ClientMessage, c as SubscriptionId, d as encodeClientMessage, f as encodeRelayMessage, h as parseRelayMessage, i as verifyEvent, l as assertSubscriptionId, m as parseClientMessage, n as SerializedEventVerifier, o as CountResult, p as mergeCountHll, r as createEventVerifier, s as RelayMessage, t as EventVerifier, u as createSubscriptionId } from "./verifier-Cl24c9ph.mjs";
8
- import { a as NostrError, i as MessageError, n as EventValidationError, o as UrlError, r as HexError, s as WasmPoisonedError, t as CryptoError } from "./error-BquXDmIN.mjs";
9
- import { _ as Closer, a as PoolFetchResult, c as PoolSubscribeOptions, d as RelayOptions, f as RelayStatus, g as RelayFetchResult, h as RelayFetchEnd, i as PoolEventMap, l as Relay, m as PublishResult, n as Pool, o as PoolOptions, p as RelayStatusName, r as PoolCountResult, s as PoolPublishResult, t as InvalidEventPolicy, u as RelayEventMap, v as RelaySubscription, y as SubscribeOptions } from "./pool-DUuYJ0x4.mjs";
10
- import { i as useWebSocketImplementation } from "./websocket-CmeqvAkp.mjs";
11
- import { i as PutResult, n as NegentropyItem, r as OutboxBound, t as EventStore } from "./types-CqhnT-Mx.mjs";
12
- import { i as Watch, n as ReactiveEventStoreEventMap, r as ReactiveEventStoreOptions, t as ReactiveEventStore } from "./reactive-jyKrA9ej.mjs";
13
- import { _ as noteEncode, a as NAddr, b as nsecEncode, c as NPub, d as Note, f as ProfilePointer, g as neventEncode, h as naddrEncode, i as EventPointer, l as NSec, n as Bech32MaxSize, o as NEvent, p as decode, r as DecodedResult, s as NProfile, t as AddressPointer, u as Nip19Error, v as nprofileEncode, y as npubEncode } from "./nip19-DpPN17bY.mjs";
14
- import { a as OutboxFeed, c as NostrUser, f as ListResult, h as ReplaceableLoader, i as OutboxError, m as ReplaceableLoadResult, n as Loaders, o as OutboxFeedOptions, p as LoadStyle, r as createLoaders, s as groupAuthorsByOutboxRelay, u as bareNostrUser } from "./index-BP94lABY.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-DojW2QZl.mjs";
3
+ import { n as ProfileMetadata, t as EventBuilder } from "./builder-C72nJITG.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-oYG2zjJ3.mjs";
5
+ import { a as relayListEventBuilder, i as readRelays, n as RelayMarker, o as relayListToTags, r as parseRelayList, s as writeRelays, t as RelayListItem } from "./nip65-CPNE0SV0.mjs";
6
+ import { i as RoutedFilter, r as PubkeyRoutes, t as Gossip } from "./gossip-BvCItMVZ.mjs";
7
+ import { a as ClientMessage, c as SubscriptionId, d as encodeClientMessage, f as encodeRelayMessage, h as parseRelayMessage, i as verifyEvent, l as assertSubscriptionId, m as parseClientMessage, n as SerializedEventVerifier, o as CountResult, p as mergeCountHll, r as createEventVerifier, s as RelayMessage, t as EventVerifier, u as createSubscriptionId } from "./verifier-DhAbqVJF.mjs";
8
+ import { a as NostrError, i as MessageError, n as EventValidationError, o as UrlError, r as HexError, t as CryptoError } from "./error-BPqAU5RB.mjs";
9
+ import { _ as Closer, a as PoolFetchResult, c as PoolSubscribeOptions, d as RelayOptions, f as RelayStatus, g as RelayFetchResult, h as RelayFetchEnd, i as PoolEventMap, l as Relay, m as PublishResult, n as Pool, o as PoolOptions, p as RelayStatusName, r as PoolCountResult, s as PoolPublishResult, t as InvalidEventPolicy, u as RelayEventMap, v as RelaySubscription, y as SubscribeOptions } from "./pool-MehgIIzm.mjs";
10
+ import { i as PutResult, n as NegentropyItem, r as OutboxBound, t as EventStore } from "./types-DiVVyf1e.mjs";
11
+ import { i as Watch, n as ReactiveEventStoreEventMap, r as ReactiveEventStoreOptions, t as ReactiveEventStore } from "./reactive-B7lPFgTS.mjs";
12
+ import { _ as noteEncode, a as NAddr, b as nsecEncode, c as NPub, d as Note, f as ProfilePointer, g as neventEncode, h as naddrEncode, i as EventPointer, l as NSec, n as Bech32MaxSize, o as NEvent, p as decode, r as DecodedResult, s as NProfile, t as AddressPointer, u as Nip19Error, v as nprofileEncode, y as npubEncode } from "./nip19-D4RKn6GC.mjs";
13
+ import { a as OutboxFeed, c as NostrUser, f as ListResult, h as ReplaceableLoader, i as OutboxError, m as ReplaceableLoadResult, n as Loaders, o as OutboxFeedOptions, p as LoadStyle, r as createLoaders, s as groupAuthorsByOutboxRelay, u as bareNostrUser } from "./index-DCobP2Jj.mjs";
15
14
  import { t as NostrSigner } from "./types-BJ4wZ7JJ.mjs";
16
- import { t as StorageError } from "./error-BD_0QFKT.mjs";
17
- import { _ as SyncSummary, c as PrivateMessageSendResult, d as SendPrivateMessageOptions, g as SyncOptions, h as SyncDirectionName, i as ClientOptions, m as SyncDirection, n as ClientError, p as SubscribePrivateMessagesOptions, r as ClientEventMap, s as FetchPrivateMessagesOptions, t as Client, u as ReceivedPrivateMessage } from "./index-CSsnE32i.mjs";
18
- import { S as SUBSCRIPTION_ID_MAX_CHARS, _ as normalizeURL, a as classifyKind, b as SECRET_KEY_BYTES, c as isRegularKind, f as bytesToHex, h as isHex64, i as KnownKind, l as isReplaceableKind, m as isHex32, n as KindClassification, o as isAddressableKind, p as hexToBytes, r as KindName, s as isEphemeralKind, t as Kind, v as EVENT_ID_BYTES, x as SIGNATURE_BYTES, y as PUBLIC_KEY_BYTES } from "./index-Hp26bgYG.mjs";
19
- import { a as Nip07Signer, c as isNip07Available, i as Nip46Transport, l as KeysSigner, n as Nip46SignerOptions, o as WindowNostr, r as Nip46SubscribeOptions, s as getWindowNostr, t as Nip46Signer, u as NoSignerError } from "./index-N7HUGgwo.mjs";
15
+ import { t as StorageError } from "./error-BjSUsx6M.mjs";
16
+ import { _ as SyncSummary, c as PrivateMessageSendResult, d as SendPrivateMessageOptions, g as SyncOptions, h as SyncDirectionName, i as ClientOptions, m as SyncDirection, n as ClientError, p as SubscribePrivateMessagesOptions, r as ClientEventMap, s as FetchPrivateMessagesOptions, t as Client, u as ReceivedPrivateMessage } from "./index-muydfuYD.mjs";
17
+ import { C as SUBSCRIPTION_ID_MAX_CHARS, S as SIGNATURE_BYTES, _ as normalizeURL, a as classifyKind, b as PUBLIC_KEY_BYTES, c as isRegularKind, f as bytesToHex, h as isHex64, i as KnownKind, l as isReplaceableKind, m as isHex32, n as KindClassification, o as isAddressableKind, p as hexToBytes, r as KindName, s as isEphemeralKind, t as Kind, x as SECRET_KEY_BYTES, y as EVENT_ID_BYTES } from "./index-Dpj_MUxb.mjs";
18
+ import { a as Nip07Signer, c as isNip07Available, d as NostrKeyOperations, f as NoSignerError, i as Nip46Transport, l as KeysSigner, n as Nip46SignerOptions, o as WindowNostr, p as SignerDisposedError, r as Nip46SubscribeOptions, s as getWindowNostr, t as Nip46Signer, u as DelegatedSigner } from "./index-YID-zPDF.mjs";
20
19
  import { Nip21Error, NostrURI, isNostrURI, parseNostrURI } from "./nips/nip21.mjs";
21
20
  import { ReplyTagsOptions, ThreadReferences, buildReplyTags, parseThreadTags, replyTo } from "./nips/nip10.mjs";
22
21
  import { isAuthRequired, makeAuthEvent } from "./nips/nip42.mjs";
23
- import { a as isInsecureRelayUrl, c as RelayError, d as RelayTimeoutError, l as RelayPublishError, o as RelayClosedError, s as RelayConnectionError, u as RelaySuspendedError } from "./index-DD0Ywpay.mjs";
24
- import { a as IndexedDbEventStoreOptions, i as IndexedDbEventStore, n as SqlValue, o as MemoryEventStore, r as SqliteEventStore, t as SqlDriver } from "./index-rKcmI6ex.mjs";
25
- export { type AddressPointer, Bech32MaxSize, Client, ClientError, type ClientEventMap, type ClientMessage, type ClientOptions, type Closer, type CountResult, CryptoError, type DecodedResult, EVENT_ID_BYTES, type Event, type EventAddress, EventBuilder, type EventPointer, type EventStore, type EventTemplate, EventValidationError, type EventVerifier, type FetchPrivateMessagesOptions, type Filter, Gossip, HexError, IndexedDbEventStore, type IndexedDbEventStoreOptions, type InvalidEventPolicy, Keys, KeysSigner, Kind, type KindClassification, type KindName, type KnownKind, type ListResult, type LoadStyle, type Loaders, MemoryEventStore, MessageError, type NAddr, type NEvent, type NProfile, type NPub, type NSec, type NegentropyItem, Nip07Signer, Nip19Error, Nip21Error, Nip46Signer, type Nip46SignerOptions, type Nip46SubscribeOptions, type Nip46Transport, NoSignerError, NostrError, type NostrSigner, type NostrURI, type NostrUser, type Note, type OutboxBound, OutboxError, OutboxFeed, type OutboxFeedOptions, PUBLIC_KEY_BYTES, Pool, type PoolCountResult, type PoolEventMap, type PoolFetchResult, type PoolOptions, type PoolPublishResult, type PoolSubscribeOptions, type PrivateMessageSendResult, type ProfileMetadata, type ProfilePointer, type PubkeyRoutes, type PublicKey, type PublishResult, type PutResult, ReactiveEventStore, type ReactiveEventStoreEventMap, type ReactiveEventStoreOptions, type ReceivedPrivateMessage, Relay, RelayClosedError, RelayConnectionError, RelayError, type RelayEventMap, type RelayFetchEnd, type RelayFetchResult, type RelayListItem, type RelayMarker, type RelayMessage, type RelayOptions, RelayPublishError, RelayStatus, type RelayStatusName, type RelaySubscription, RelaySuspendedError, RelayTimeoutError, type ReplaceableLoadResult, type ReplaceableLoader, type ReplyTagsOptions, type RoutedFilter, SECRET_KEY_BYTES, SIGNATURE_BYTES, SUBSCRIPTION_ID_MAX_CHARS, SecretKey, type SecretKeyInput, type SendPrivateMessageOptions, type SerializedEventVerifier, type SigningBackend, type SqlDriver, type SqlValue, SqliteEventStore, StorageError, type SubscribeOptions, type SubscribePrivateMessagesOptions, type SubscriptionId, SyncDirection, type SyncDirectionName, type SyncOptions, type SyncSummary, Tag, type TagInput, type ThreadReferences, type UnsignedEvent, UrlError, WasmPoisonedError, type Watch, type WindowNostr, assertSubscriptionId, bareNostrUser, buildReplyTags, bytesToHex, canonicalizeFilter, canonicalizeFilters, classifyKind, createEventVerifier, createLoaders, createSubscriptionId, encodeClientMessage, encodeRelayMessage, eventAddress, filterFingerprint, finalizeEvent, formatEventAddress, getDTag, getEventHash, getFilterLimit, getPublicKey, getWindowNostr, groupAuthorsByOutboxRelay, hexToBytes, isAddressableKind, isAuthRequired, isEphemeralKind, isHex32, isHex64, isInsecureRelayUrl, isNip07Available, isNostrURI, isRegularKind, isReplaceableKind, isReplaceableWinner, isTag, itemCompare, makeAuthEvent, matchFilter, matchFilters, mergeCountHll, naddrEncode, neventEncode, decode as nip19Decode, normalizeURL, noteEncode, nprofileEncode, npubEncode, nsecEncode, parseClientMessage, parseEventAddress, parseNostrURI, parseRelayList, parseRelayMessage, parseThreadTags, publicKeyFromHex, readRelays, relayListEventBuilder, relayListToTags, replyTo, serializeEvent, signEvent, signedMatchesUnsigned, sortEvents, sortedEvents, tagName, tagValue, toSecretKey, useWebSocketImplementation, validateEvent, validateSignedEvent, verifyEvent, writeRelays };
22
+ import { a as isInsecureRelayUrl, c as RelayError, d as RelayTimeoutError, l as RelayPublishError, o as RelayClosedError, s as RelayConnectionError, u as RelaySuspendedError } from "./index-B2JlP2Jf.mjs";
23
+ import { a as IndexedDbEventStoreOptions, i as IndexedDbEventStore, n as SqlValue, o as MemoryEventStore, r as SqliteEventStore, t as SqlDriver } from "./index-DzHmhHqD.mjs";
24
+ export { type AddressPointer, Bech32MaxSize, Client, ClientError, type ClientEventMap, type ClientMessage, type ClientOptions, type Closer, type CountResult, CryptoError, type DecodedResult, DelegatedSigner, EVENT_ID_BYTES, type Event, type EventAddress, EventBuilder, type EventPointer, type EventStore, type EventTemplate, EventValidationError, type EventVerifier, type FetchPrivateMessagesOptions, type Filter, Gossip, HexError, IndexedDbEventStore, type IndexedDbEventStoreOptions, type InvalidEventPolicy, Keys, KeysSigner, Kind, type KindClassification, type KindName, type KnownKind, type ListResult, type LoadStyle, type Loaders, MemoryEventStore, MessageError, type NAddr, type NEvent, type NProfile, type NPub, type NSec, type NegentropyItem, Nip07Signer, Nip19Error, Nip21Error, Nip46Signer, type Nip46SignerOptions, type Nip46SubscribeOptions, type Nip46Transport, NoSignerError, NostrError, type NostrKeyOperations, type NostrSigner, type NostrURI, type NostrUser, type Note, type OutboxBound, OutboxError, OutboxFeed, type OutboxFeedOptions, PUBLIC_KEY_BYTES, Pool, type PoolCountResult, type PoolEventMap, type PoolFetchResult, type PoolOptions, type PoolPublishResult, type PoolSubscribeOptions, type PrivateMessageSendResult, type ProfileMetadata, type ProfilePointer, type PubkeyRoutes, type PublicKey, type PublishResult, type PutResult, ReactiveEventStore, type ReactiveEventStoreEventMap, type ReactiveEventStoreOptions, type ReceivedPrivateMessage, Relay, RelayClosedError, RelayConnectionError, RelayError, type RelayEventMap, type RelayFetchEnd, type RelayFetchResult, type RelayListItem, type RelayMarker, type RelayMessage, type RelayOptions, RelayPublishError, RelayStatus, type RelayStatusName, type RelaySubscription, RelaySuspendedError, RelayTimeoutError, type ReplaceableLoadResult, type ReplaceableLoader, type ReplyTagsOptions, type RoutedFilter, SECRET_KEY_BYTES, SIGNATURE_BYTES, SUBSCRIPTION_ID_MAX_CHARS, SecretKey, type SecretKeyInput, type SendPrivateMessageOptions, type SerializedEventVerifier, SignerDisposedError, type SigningBackend, type SqlDriver, type SqlValue, SqliteEventStore, StorageError, type SubscribeOptions, type SubscribePrivateMessagesOptions, type SubscriptionId, SyncDirection, type SyncDirectionName, type SyncOptions, type SyncSummary, Tag, type TagInput, type ThreadReferences, type UnsignedEvent, UrlError, type Watch, type WindowNostr, assertSubscriptionId, bareNostrUser, buildReplyTags, bytesToHex, canonicalizeFilter, canonicalizeFilters, classifyKind, createEventVerifier, createLoaders, createSubscriptionId, encodeClientMessage, encodeRelayMessage, eventAddress, filterFingerprint, finalizeEvent, formatEventAddress, getDTag, getEventHash, getFilterLimit, getPublicKey, getWindowNostr, groupAuthorsByOutboxRelay, hexToBytes, isAddressableKind, isAuthRequired, isEphemeralKind, isHex32, isHex64, isInsecureRelayUrl, isNip07Available, isNostrURI, isRegularKind, isReplaceableKind, isReplaceableWinner, isTag, itemCompare, makeAuthEvent, matchFilter, matchFilters, mergeCountHll, naddrEncode, neventEncode, decode as nip19Decode, normalizeURL, noteEncode, nprofileEncode, npubEncode, nsecEncode, parseClientMessage, parseEventAddress, parseNostrURI, parseRelayList, parseRelayMessage, parseThreadTags, publicKeyFromHex, readRelays, relayListEventBuilder, relayListToTags, replyTo, serializeEvent, signEvent, signedMatchesUnsigned, sortEvents, sortedEvents, tagName, tagValue, toSecretKey, validateEvent, validateSignedEvent, verifyEvent, writeRelays };
package/dist/index.mjs CHANGED
@@ -1,27 +1,27 @@
1
- import { D as SIGNATURE_BYTES, E as SECRET_KEY_BYTES, O as SUBSCRIPTION_ID_MAX_CHARS, T as PUBLIC_KEY_BYTES, _ as HexError, b as UrlError, c as isHex64, d as normalizeURL, g as EventValidationError, h as CryptoError, i as bytesToHex, o as hexToBytes, s as isHex32, v as MessageError, w as EVENT_ID_BYTES, x as WasmPoisonedError, y as NostrError } from "./util-DDpPkiED.mjs";
2
- import { a as isRegularKind, i as isEphemeralKind, n as classifyKind, o as isReplaceableKind, r as isAddressableKind, t as Kind } from "./kind-D8fENiiL.mjs";
3
- import { C as tagName, S as parseEventAddress, _ as eventAddress, a as isReplaceableWinner, b as getDTag, d as signedMatchesUnsigned, f as sortEvents, g as Tag, h as validateSignedEvent, l as serializeEvent, m as validateEvent, n as getEventHash, o as itemCompare, p as sortedEvents, w as tagValue, x as isTag, y as formatEventAddress } from "./event-B3ua2_oL.mjs";
4
- import { a as publicKeyFromHex, i as getPublicKey, n as SecretKey, o as signEvent, r as finalizeEvent, s as toSecretKey, t as Keys } from "./key-k8LDEPZh.mjs";
5
- import { n as verifyEvent, t as createEventVerifier } from "./verifier-CjH1vnP2.mjs";
6
- import { t as EventBuilder } from "./builder-BQbFDO6S.mjs";
7
- import { a as matchFilter, i as getFilterLimit, n as canonicalizeFilters, o as matchFilters, r as filterFingerprint, t as canonicalizeFilter } from "./filter-B16P33dz.mjs";
8
- import { a as mergeCountHll, i as encodeRelayMessage, n as createSubscriptionId, o as parseClientMessage, r as encodeClientMessage, s as parseRelayMessage, t as assertSubscriptionId } from "./message-pYfVKxPn.mjs";
9
- import { t as NoSignerError } from "./error-UHkqzWL7.mjs";
10
- import { a as KeysSigner, i as isNip07Available, n as Nip07Signer, r as getWindowNostr, t as Nip46Signer } from "./signer-CWtxpOxc.mjs";
1
+ import { D as SECRET_KEY_BYTES, E as PUBLIC_KEY_BYTES, O as SIGNATURE_BYTES, S as UrlError, T as EVENT_ID_BYTES, _ as CryptoError, b as MessageError, c as isHex32, f as normalizeURL, i as bytesToHex, k as SUBSCRIPTION_ID_MAX_CHARS, l as isHex64, s as hexToBytes, v as EventValidationError, x as NostrError, y as HexError } from "./util-DfsyJ9nz.mjs";
2
+ import { a as isRegularKind, i as isEphemeralKind, n as classifyKind, o as isReplaceableKind, r as isAddressableKind, t as Kind } from "./kind-I2Tvbe82.mjs";
3
+ import { C as tagName, S as parseEventAddress, _ as eventAddress, a as isReplaceableWinner, b as getDTag, d as signedMatchesUnsigned, f as sortEvents, g as Tag, h as validateSignedEvent, l as serializeEvent, m as validateEvent, n as getEventHash, o as itemCompare, p as sortedEvents, w as tagValue, x as isTag, y as formatEventAddress } from "./event-DvM1f03b.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-D_oEutQ6.mjs";
5
+ import { n as verifyEvent, t as createEventVerifier } from "./verifier-DEHUy4AD.mjs";
6
+ import { t as EventBuilder } from "./builder-CGgM_QHT.mjs";
7
+ import { a as getFilterLimit, n as canonicalizeFilters, o as matchFilter, r as filterFingerprint, s as matchFilters, t as canonicalizeFilter } from "./filter-3jOh4uLN.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-BMfreCQc.mjs";
9
+ import { n as SignerDisposedError, t as NoSignerError } from "./error-Dyb89ahb.mjs";
10
+ import { a as KeysSigner, i as isNip07Available, n as Nip07Signer, o as DelegatedSigner, r as getWindowNostr, t as Nip46Signer } from "./signer-DJcmC4nA.mjs";
11
11
  import { Bech32MaxSize, Nip19Error, decode, naddrEncode, neventEncode, noteEncode, nprofileEncode, npubEncode, nsecEncode } from "./nips/nip19.mjs";
12
12
  import { Nip21Error, isNostrURI, parseNostrURI } from "./nips/nip21.mjs";
13
13
  import { buildReplyTags, parseThreadTags, replyTo } from "./nips/nip10.mjs";
14
14
  import { isAuthRequired, makeAuthEvent } from "./nips/nip42.mjs";
15
15
  import { parseRelayList, readRelays, relayListEventBuilder, relayListToTags, writeRelays } from "./nips/nip65.mjs";
16
- import { c as RelayConnectionError, d as RelaySuspendedError, f as RelayTimeoutError, l as RelayError, n as Relay, o as useWebSocketImplementation, r as RelayStatus, s as RelayClosedError, u as RelayPublishError } from "./relay-DXtwUEdX.mjs";
17
- import { i as isInsecureRelayUrl, t as Pool } from "./pool-BMUsw2un.mjs";
16
+ import { a as RelayClosedError, c as RelayPublishError, l as RelaySuspendedError, n as Relay, o as RelayConnectionError, r as RelayStatus, s as RelayError, u as RelayTimeoutError } from "./relay-DIR77xQ2.mjs";
17
+ import { i as isInsecureRelayUrl, t as Pool } from "./pool-lMT_mvzn.mjs";
18
18
  import "./relay.mjs";
19
- import { t as Gossip } from "./gossip-K_JIexQs.mjs";
20
- import { a as bareNostrUser, i as groupAuthorsByOutboxRelay, n as OutboxError, r as OutboxFeed, t as createLoaders } from "./loaders-Dp2nXEFk.mjs";
21
- import { t as StorageError } from "./error-DH4guike.mjs";
22
- import { t as MemoryEventStore } from "./memory-VyPnOBU3.mjs";
23
- import { t as ReactiveEventStore } from "./reactive--pDpLt2H.mjs";
24
- import { n as ClientError, r as SyncDirection, t as Client } from "./client-CTmp5w84.mjs";
25
- import { n as IndexedDbEventStore, t as SqliteEventStore } from "./storage-B5Wdt_Mn.mjs";
19
+ import { t as Gossip } from "./gossip-CRyhK6E6.mjs";
20
+ import { a as bareNostrUser, i as groupAuthorsByOutboxRelay, n as OutboxError, r as OutboxFeed, t as createLoaders } from "./loaders-BRh2riV9.mjs";
21
+ import { t as StorageError } from "./error-QyECUDIp.mjs";
22
+ import { t as MemoryEventStore } from "./memory-D_GdEQYG.mjs";
23
+ import { t as ReactiveEventStore } from "./reactive-DFHY-f00.mjs";
24
+ import { n as ClientError, r as SyncDirection, t as Client } from "./client-COkEihj_.mjs";
25
+ import { n as IndexedDbEventStore, t as SqliteEventStore } from "./storage-n2BE1bdY.mjs";
26
26
  import "./store.mjs";
27
- export { Bech32MaxSize, Client, ClientError, CryptoError, EVENT_ID_BYTES, EventBuilder, EventValidationError, Gossip, HexError, IndexedDbEventStore, Keys, KeysSigner, Kind, MemoryEventStore, MessageError, Nip07Signer, Nip19Error, Nip21Error, Nip46Signer, NoSignerError, NostrError, OutboxError, OutboxFeed, PUBLIC_KEY_BYTES, Pool, ReactiveEventStore, Relay, RelayClosedError, RelayConnectionError, RelayError, RelayPublishError, RelayStatus, RelaySuspendedError, RelayTimeoutError, SECRET_KEY_BYTES, SIGNATURE_BYTES, SUBSCRIPTION_ID_MAX_CHARS, SecretKey, SqliteEventStore, StorageError, SyncDirection, Tag, UrlError, WasmPoisonedError, assertSubscriptionId, bareNostrUser, buildReplyTags, bytesToHex, canonicalizeFilter, canonicalizeFilters, classifyKind, createEventVerifier, createLoaders, createSubscriptionId, encodeClientMessage, encodeRelayMessage, eventAddress, filterFingerprint, finalizeEvent, formatEventAddress, getDTag, getEventHash, getFilterLimit, getPublicKey, getWindowNostr, groupAuthorsByOutboxRelay, hexToBytes, isAddressableKind, isAuthRequired, isEphemeralKind, isHex32, isHex64, isInsecureRelayUrl, isNip07Available, isNostrURI, isRegularKind, isReplaceableKind, isReplaceableWinner, isTag, itemCompare, makeAuthEvent, matchFilter, matchFilters, mergeCountHll, naddrEncode, neventEncode, decode as nip19Decode, normalizeURL, noteEncode, nprofileEncode, npubEncode, nsecEncode, parseClientMessage, parseEventAddress, parseNostrURI, parseRelayList, parseRelayMessage, parseThreadTags, publicKeyFromHex, readRelays, relayListEventBuilder, relayListToTags, replyTo, serializeEvent, signEvent, signedMatchesUnsigned, sortEvents, sortedEvents, tagName, tagValue, toSecretKey, useWebSocketImplementation, validateEvent, validateSignedEvent, verifyEvent, writeRelays };
27
+ export { Bech32MaxSize, Client, ClientError, CryptoError, DelegatedSigner, EVENT_ID_BYTES, EventBuilder, EventValidationError, Gossip, HexError, IndexedDbEventStore, Keys, KeysSigner, Kind, MemoryEventStore, MessageError, Nip07Signer, Nip19Error, Nip21Error, Nip46Signer, NoSignerError, NostrError, OutboxError, OutboxFeed, PUBLIC_KEY_BYTES, Pool, ReactiveEventStore, Relay, RelayClosedError, RelayConnectionError, RelayError, RelayPublishError, RelayStatus, RelaySuspendedError, RelayTimeoutError, SECRET_KEY_BYTES, SIGNATURE_BYTES, SUBSCRIPTION_ID_MAX_CHARS, SecretKey, SignerDisposedError, SqliteEventStore, StorageError, SyncDirection, Tag, UrlError, assertSubscriptionId, bareNostrUser, buildReplyTags, bytesToHex, canonicalizeFilter, canonicalizeFilters, classifyKind, createEventVerifier, createLoaders, createSubscriptionId, encodeClientMessage, encodeRelayMessage, eventAddress, filterFingerprint, finalizeEvent, formatEventAddress, getDTag, getEventHash, getFilterLimit, getPublicKey, getWindowNostr, groupAuthorsByOutboxRelay, hexToBytes, isAddressableKind, isAuthRequired, isEphemeralKind, isHex32, isHex64, isInsecureRelayUrl, isNip07Available, isNostrURI, isRegularKind, isReplaceableKind, isReplaceableWinner, isTag, itemCompare, makeAuthEvent, matchFilter, matchFilters, mergeCountHll, naddrEncode, neventEncode, decode as nip19Decode, normalizeURL, noteEncode, nprofileEncode, npubEncode, nsecEncode, parseClientMessage, parseEventAddress, parseNostrURI, parseRelayList, parseRelayMessage, parseThreadTags, publicKeyFromHex, readRelays, relayListEventBuilder, relayListToTags, replyTo, serializeEvent, signEvent, signedMatchesUnsigned, sortEvents, sortedEvents, tagName, tagValue, toSecretKey, validateEvent, validateSignedEvent, verifyEvent, writeRelays };
@@ -1,5 +1,5 @@
1
- import { g as EventValidationError, h as CryptoError, i as bytesToHex$1, m as utf8Encoder, n as assertHex32, o as hexToBytes$1, r as assertSecretKeyBytes } from "./util-DDpPkiED.mjs";
2
- import { c as markVerified, m as validateEvent, u as serializeValidatedEvent } from "./event-B3ua2_oL.mjs";
1
+ import { _ as CryptoError, g as utf8Encoder, i as bytesToHex$1, n as assertHex32, r as assertSecretKeyBytes, s as hexToBytes$1, v as EventValidationError } from "./util-DfsyJ9nz.mjs";
2
+ import { c as markVerified, m as validateEvent, u as serializeValidatedEvent } from "./event-DvM1f03b.mjs";
3
3
  import { randomBytes } from "@noble/hashes/utils.js";
4
4
  import { sha256 } from "@noble/hashes/sha2.js";
5
5
  import { schnorr } from "@noble/curves/secp256k1.js";
@@ -66,7 +66,13 @@ var Keys = class Keys {
66
66
  constructor(secretKey, backend) {
67
67
  this.secretKey = secretKey;
68
68
  this.backend = backend;
69
- const pubkey = backend.publicKey(secretKey.bytes);
69
+ const secretBytes = secretKey.bytes;
70
+ let pubkey;
71
+ try {
72
+ pubkey = backend.publicKey(secretBytes);
73
+ } finally {
74
+ secretBytes.fill(0);
75
+ }
70
76
  if (pubkey.length !== 32) throw new CryptoError("signing backend returned an invalid public key");
71
77
  this.publicKey = bytesToHex$1(pubkey);
72
78
  }
@@ -80,8 +86,14 @@ var Keys = class Keys {
80
86
  function resolveKeys(secretKey) {
81
87
  return secretKey instanceof Keys ? secretKey : Keys.fromSecretKey(secretKey);
82
88
  }
83
- /** Fill pubkey/id/sig on a template and return a signed event. */
84
- function finalizeEvent(template, secretKey) {
89
+ /**
90
+ * Fill pubkey/id/sig on a template and return a signed event.
91
+ *
92
+ * `auxRand` is the 32-byte BIP-340 auxiliary randomness. It defaults to a fresh `randomBytes(32)`
93
+ * draw; an explicit value makes the signature reproducible, which is required for vectors and
94
+ * tests. Never reuse aux randomness in production.
95
+ */
96
+ function finalizeEvent(template, secretKey, auxRand) {
85
97
  const keys = resolveKeys(secretKey);
86
98
  return signEvent({
87
99
  kind: template.kind,
@@ -89,14 +101,19 @@ function finalizeEvent(template, secretKey) {
89
101
  content: template.content,
90
102
  created_at: template.created_at,
91
103
  pubkey: keys.publicKey
92
- }, keys);
104
+ }, keys, auxRand);
93
105
  }
94
106
  /**
95
107
  * Sign an already-assembled unsigned event. Rejects when `unsigned.pubkey` does not match the
96
108
  * secret key.
109
+ *
110
+ * `auxRand` is the 32-byte BIP-340 auxiliary randomness. It defaults to a fresh `randomBytes(32)`
111
+ * draw; an explicit value makes the signature reproducible, which is required for vectors and
112
+ * tests. Never reuse aux randomness in production.
97
113
  */
98
- function signEvent(unsigned, secretKey) {
114
+ function signEvent(unsigned, secretKey, auxRand) {
99
115
  const keys = resolveKeys(secretKey);
116
+ if (auxRand !== void 0 && auxRand.length !== 32) throw new CryptoError("auxRand must be 32 bytes");
100
117
  if (!validateEvent(unsigned)) throw new EventValidationError("cannot sign invalid unsigned event");
101
118
  if (unsigned.pubkey !== keys.publicKey) throw new CryptoError("unsigned event pubkey does not match secret key");
102
119
  const normalized = {
@@ -107,7 +124,13 @@ function signEvent(unsigned, secretKey) {
107
124
  pubkey: keys.publicKey
108
125
  };
109
126
  const id = bytesToHex$1(sha256(utf8Encoder.encode(serializeValidatedEvent(normalized))));
110
- const sig = keys.backend.sign(hexToBytes$1(id), keys.secretKey.bytes, randomBytes(32));
127
+ const secretBytes = keys.secretKey.bytes;
128
+ let sig;
129
+ try {
130
+ sig = keys.backend.sign(hexToBytes$1(id), secretBytes, auxRand ?? randomBytes(32));
131
+ } finally {
132
+ secretBytes.fill(0);
133
+ }
111
134
  if (sig.length !== 64) throw new CryptoError("signing backend returned an invalid signature");
112
135
  const event = {
113
136
  ...normalized,
@@ -120,4 +143,4 @@ function signEvent(unsigned, secretKey) {
120
143
  //#endregion
121
144
  export { publicKeyFromHex as a, getPublicKey as i, SecretKey as n, signEvent as o, finalizeEvent as r, toSecretKey as s, Keys as t };
122
145
 
123
- //# sourceMappingURL=key-k8LDEPZh.mjs.map
146
+ //# sourceMappingURL=key-D_oEutQ6.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key-D_oEutQ6.mjs","names":["hexToBytes","bytesToHex"],"sources":["../src/core/key.ts"],"sourcesContent":["import { schnorr } from \"@noble/curves/secp256k1.js\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport { randomBytes } from \"@noble/hashes/utils.js\";\n\nimport { CryptoError, EventValidationError } from \"./error.ts\";\nimport { markVerified, serializeValidatedEvent, validateEvent } from \"./event.ts\";\nimport type { Event, EventTemplate, UnsignedEvent } from \"./event.ts\";\nimport { assertHex32, assertSecretKeyBytes, bytesToHex, hexToBytes, utf8Encoder } from \"./util.ts\";\n\n/** 32-byte secret key held as bytes; prefer zeroize when done. */\nexport class SecretKey {\n #bytes: Uint8Array | undefined;\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) {\n throw new CryptoError(\"secret key has been zeroized\");\n }\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 = undefined;\n }\n }\n}\n\n/** Anything a secret key can be given as: instance, raw bytes, or hex. */\nexport type SecretKeyInput = SecretKey | Uint8Array | string;\n\n/** Coerce a {@link SecretKeyInput} to {@link SecretKey}. */\nexport function toSecretKey(input: SecretKeyInput): SecretKey {\n if (input instanceof SecretKey) {\n return input;\n }\n if (typeof input === \"string\") {\n return SecretKey.fromHex(input);\n }\n return SecretKey.fromBytes(input);\n}\n\n/** Lowercase hex-encoded secp256k1 public key (x-only, 64 chars). */\nexport type PublicKey = string;\n\n/** Validate and normalize a hex public key; throws {@link HexError} on bad input. */\nexport function publicKeyFromHex(hex: string): PublicKey {\n return assertHex32(hex, \"public key\");\n}\n\n/**\n * BIP-340 signing backend. `publicKey` returns the 32-byte x-only public key of a 32-byte secret\n * key; `sign` returns the 64-byte BIP-340 signature of a 32-byte `id` using 32 bytes of auxiliary\n * randomness. Both throw on invalid input (for example an out-of-range secret key).\n */\nexport type SigningBackend = {\n publicKey: (secretKey: Uint8Array) => Uint8Array;\n sign: (id: Uint8Array, secretKey: Uint8Array, auxRand: Uint8Array) => Uint8Array;\n};\n\nconst nobleSigning: SigningBackend = {\n publicKey: (secretKey) => schnorr.getPublicKey(secretKey),\n sign: (id, secretKey, auxRand) => schnorr.sign(id, secretKey, auxRand),\n};\n\n/** Derive the public key for a secret key given as SecretKey, bytes, or hex. */\nexport function getPublicKey(secretKey: SecretKeyInput): PublicKey {\n return bytesToHex(schnorr.getPublicKey(toSecretKey(secretKey).bytes));\n}\n\n/** Keypair convenience wrapper. */\nexport class Keys {\n readonly secretKey: SecretKey;\n readonly publicKey: PublicKey;\n /**\n * BIP-340 backend that derived {@link publicKey} and signs in {@link finalizeEvent}/\n * {@link signEvent}. Defaults to noble; pass a loaded `NostrWasm` module or a native backend to\n * delegate signing.\n */\n readonly backend: SigningBackend;\n\n private constructor(secretKey: SecretKey, backend: SigningBackend) {\n this.secretKey = secretKey;\n this.backend = backend;\n const secretBytes = secretKey.bytes;\n let pubkey: Uint8Array;\n try {\n pubkey = backend.publicKey(secretBytes);\n } finally {\n secretBytes.fill(0);\n }\n if (pubkey.length !== 32) {\n throw new CryptoError(\"signing backend returned an invalid public key\");\n }\n this.publicKey = bytesToHex(pubkey);\n }\n\n static generate(backend: SigningBackend = nobleSigning): Keys {\n return new Keys(SecretKey.generate(), backend);\n }\n\n static fromSecretKey(secretKey: SecretKeyInput, backend: SigningBackend = nobleSigning): Keys {\n return new Keys(toSecretKey(secretKey), backend);\n }\n}\n\nfunction resolveKeys(secretKey: SecretKeyInput | Keys): Keys {\n return secretKey instanceof Keys ? secretKey : Keys.fromSecretKey(secretKey);\n}\n\n/**\n * Fill pubkey/id/sig on a template and return a signed event.\n *\n * `auxRand` is the 32-byte BIP-340 auxiliary randomness. It defaults to a fresh `randomBytes(32)`\n * draw; an explicit value makes the signature reproducible, which is required for vectors and\n * tests. Never reuse aux randomness in production.\n */\nexport function finalizeEvent(\n template: EventTemplate,\n secretKey: SecretKeyInput | Keys,\n auxRand?: Uint8Array,\n): Event {\n const keys = resolveKeys(secretKey);\n const unsigned: UnsignedEvent = {\n kind: template.kind,\n tags: template.tags,\n content: template.content,\n created_at: template.created_at,\n pubkey: keys.publicKey,\n };\n return signEvent(unsigned, keys, auxRand);\n}\n\n/**\n * Sign an already-assembled unsigned event. Rejects when `unsigned.pubkey` does not match the\n * secret key.\n *\n * `auxRand` is the 32-byte BIP-340 auxiliary randomness. It defaults to a fresh `randomBytes(32)`\n * draw; an explicit value makes the signature reproducible, which is required for vectors and\n * tests. Never reuse aux randomness in production.\n */\nexport function signEvent(\n unsigned: UnsignedEvent,\n secretKey: SecretKeyInput | Keys,\n auxRand?: Uint8Array,\n): Event {\n const keys = resolveKeys(secretKey);\n if (auxRand !== undefined && auxRand.length !== 32) {\n throw new CryptoError(\"auxRand must be 32 bytes\");\n }\n if (!validateEvent(unsigned)) {\n throw new EventValidationError(\"cannot sign invalid unsigned event\");\n }\n\n if (unsigned.pubkey !== keys.publicKey) {\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: keys.publicKey,\n };\n\n const id = bytesToHex(sha256(utf8Encoder.encode(serializeValidatedEvent(normalized))));\n const secretBytes = keys.secretKey.bytes;\n let sig: Uint8Array;\n try {\n sig = keys.backend.sign(hexToBytes(id), secretBytes, auxRand ?? randomBytes(32));\n } finally {\n secretBytes.fill(0);\n }\n if (sig.length !== 64) {\n throw new CryptoError(\"signing backend returned an invalid signature\");\n }\n const event: Event = { ...normalized, id, sig: bytesToHex(sig) };\n markVerified(event);\n return event;\n}\n"],"mappings":";;;;;;;AAUA,IAAa,YAAb,MAAa,UAAU;CACrB;CAEA,YAAoB,OAAmB;EACrC,qBAAqB,KAAK;EAC1B,KAAK,SAAS,IAAI,WAAW,KAAK;CACpC;CAEA,OAAO,WAAsB;EAC3B,OAAO,IAAI,UAAU,QAAQ,MAAM,gBAAgB,CAAC;CACtD;CAEA,OAAO,UAAU,OAA8B;EAC7C,OAAO,IAAI,UAAU,KAAK;CAC5B;CAEA,OAAO,QAAQ,KAAwB;EACrC,OAAO,IAAI,UAAUA,aAAW,YAAY,KAAK,YAAY,CAAC,CAAC;CACjE;CAEA,IAAI,QAAoB;EACtB,IAAI,CAAC,KAAK,QACR,MAAM,IAAI,YAAY,8BAA8B;EAEtD,OAAO,IAAI,WAAW,KAAK,MAAM;CACnC;CAEA,QAAgB;EACd,OAAOC,aAAW,KAAK,KAAK;CAC9B;;CAGA,UAAgB;EACd,IAAI,KAAK,QAAQ;GACf,KAAK,OAAO,KAAK,CAAC;GAClB,KAAK,SAAS,KAAA;EAChB;CACF;AACF;;AAMA,SAAgB,YAAY,OAAkC;CAC5D,IAAI,iBAAiB,WACnB,OAAO;CAET,IAAI,OAAO,UAAU,UACnB,OAAO,UAAU,QAAQ,KAAK;CAEhC,OAAO,UAAU,UAAU,KAAK;AAClC;;AAMA,SAAgB,iBAAiB,KAAwB;CACvD,OAAO,YAAY,KAAK,YAAY;AACtC;AAYA,MAAM,eAA+B;CACnC,YAAY,cAAc,QAAQ,aAAa,SAAS;CACxD,OAAO,IAAI,WAAW,YAAY,QAAQ,KAAK,IAAI,WAAW,OAAO;AACvE;;AAGA,SAAgB,aAAa,WAAsC;CACjE,OAAOA,aAAW,QAAQ,aAAa,YAAY,SAAS,CAAC,CAAC,KAAK,CAAC;AACtE;;AAGA,IAAa,OAAb,MAAa,KAAK;CAChB;CACA;;;;;;CAMA;CAEA,YAAoB,WAAsB,SAAyB;EACjE,KAAK,YAAY;EACjB,KAAK,UAAU;EACf,MAAM,cAAc,UAAU;EAC9B,IAAI;EACJ,IAAI;GACF,SAAS,QAAQ,UAAU,WAAW;EACxC,UAAU;GACR,YAAY,KAAK,CAAC;EACpB;EACA,IAAI,OAAO,WAAW,IACpB,MAAM,IAAI,YAAY,gDAAgD;EAExE,KAAK,YAAYA,aAAW,MAAM;CACpC;CAEA,OAAO,SAAS,UAA0B,cAAoB;EAC5D,OAAO,IAAI,KAAK,UAAU,SAAS,GAAG,OAAO;CAC/C;CAEA,OAAO,cAAc,WAA2B,UAA0B,cAAoB;EAC5F,OAAO,IAAI,KAAK,YAAY,SAAS,GAAG,OAAO;CACjD;AACF;AAEA,SAAS,YAAY,WAAwC;CAC3D,OAAO,qBAAqB,OAAO,YAAY,KAAK,cAAc,SAAS;AAC7E;;;;;;;;AASA,SAAgB,cACd,UACA,WACA,SACO;CACP,MAAM,OAAO,YAAY,SAAS;CAQlC,OAAO,UAAU;EANf,MAAM,SAAS;EACf,MAAM,SAAS;EACf,SAAS,SAAS;EAClB,YAAY,SAAS;EACrB,QAAQ,KAAK;CAES,GAAG,MAAM,OAAO;AAC1C;;;;;;;;;AAUA,SAAgB,UACd,UACA,WACA,SACO;CACP,MAAM,OAAO,YAAY,SAAS;CAClC,IAAI,YAAY,KAAA,KAAa,QAAQ,WAAW,IAC9C,MAAM,IAAI,YAAY,0BAA0B;CAElD,IAAI,CAAC,cAAc,QAAQ,GACzB,MAAM,IAAI,qBAAqB,oCAAoC;CAGrE,IAAI,SAAS,WAAW,KAAK,WAC3B,MAAM,IAAI,YAAY,iDAAiD;CAGzE,MAAM,aAA4B;EAChC,MAAM,SAAS;EACf,MAAM,SAAS;EACf,SAAS,SAAS;EAClB,YAAY,SAAS;EACrB,QAAQ,KAAK;CACf;CAEA,MAAM,KAAKA,aAAW,OAAO,YAAY,OAAO,wBAAwB,UAAU,CAAC,CAAC,CAAC;CACrF,MAAM,cAAc,KAAK,UAAU;CACnC,IAAI;CACJ,IAAI;EACF,MAAM,KAAK,QAAQ,KAAKD,aAAW,EAAE,GAAG,aAAa,WAAW,YAAY,EAAE,CAAC;CACjF,UAAU;EACR,YAAY,KAAK,CAAC;CACpB;CACA,IAAI,IAAI,WAAW,IACjB,MAAM,IAAI,YAAY,+CAA+C;CAEvE,MAAM,QAAe;EAAE,GAAG;EAAY;EAAI,KAAKC,aAAW,GAAG;CAAE;CAC/D,aAAa,KAAK;CAClB,OAAO;AACT"}
@@ -45,13 +45,23 @@ declare class Keys {
45
45
  static generate(backend?: SigningBackend): Keys;
46
46
  static fromSecretKey(secretKey: SecretKeyInput, backend?: SigningBackend): Keys;
47
47
  }
48
- /** Fill pubkey/id/sig on a template and return a signed event. */
49
- declare function finalizeEvent(template: EventTemplate, secretKey: SecretKeyInput | Keys): Event;
48
+ /**
49
+ * Fill pubkey/id/sig on a template and return a signed event.
50
+ *
51
+ * `auxRand` is the 32-byte BIP-340 auxiliary randomness. It defaults to a fresh `randomBytes(32)`
52
+ * draw; an explicit value makes the signature reproducible, which is required for vectors and
53
+ * tests. Never reuse aux randomness in production.
54
+ */
55
+ declare function finalizeEvent(template: EventTemplate, secretKey: SecretKeyInput | Keys, auxRand?: Uint8Array): Event;
50
56
  /**
51
57
  * Sign an already-assembled unsigned event. Rejects when `unsigned.pubkey` does not match the
52
58
  * secret key.
59
+ *
60
+ * `auxRand` is the 32-byte BIP-340 auxiliary randomness. It defaults to a fresh `randomBytes(32)`
61
+ * draw; an explicit value makes the signature reproducible, which is required for vectors and
62
+ * tests. Never reuse aux randomness in production.
53
63
  */
54
- declare function signEvent(unsigned: UnsignedEvent, secretKey: SecretKeyInput | Keys): Event;
64
+ declare function signEvent(unsigned: UnsignedEvent, secretKey: SecretKeyInput | Keys, auxRand?: Uint8Array): Event;
55
65
  //#endregion
56
66
  export { SigningBackend as a, publicKeyFromHex as c, SecretKeyInput as i, signEvent as l, PublicKey as n, finalizeEvent as o, SecretKey as r, getPublicKey as s, Keys as t, toSecretKey as u };
57
- //# sourceMappingURL=key-CyKN1RTi.d.mts.map
67
+ //# sourceMappingURL=key-DojW2QZl.d.mts.map
@@ -1,10 +1,11 @@
1
1
  //#region src/core/kind.ts
2
2
  /**
3
- * NIP-01 regular ranges verbatim; kinds outside every defined range are still stored like regular
4
- * events (see {@link classifyKind}).
3
+ * Regular means relays store the event: every kind below 10000 except the replaceable kinds 0 and 3.
4
+ * The NIP-01 enumerated regular ranges are a subset; kinds 45–999 are stored like regular events in
5
+ * practice (nostr-tools and rust-nostr agree).
5
6
  */
6
7
  function isRegularKind(kind) {
7
- return kind === 1 || kind === 2 || kind >= 4 && kind < 45 || kind >= 1e3 && kind < 1e4;
8
+ return kind < 1e4 && kind !== 0 && kind !== 3;
8
9
  }
9
10
  /** Replaceable: latest per (pubkey, kind) wins. */
10
11
  function isReplaceableKind(kind) {
@@ -21,7 +22,7 @@ function isAddressableKind(kind) {
21
22
  /**
22
23
  * Classify a kind number into its NIP-01 storage class. NIP-01 leaves kinds 45–999 and 40000+
23
24
  * undefined (rather than forbidden); relays store them like regular events, so they classify
24
- * `"regular"` here even though {@link isRegularKind} returns false for them.
25
+ * `"regular"` here even though {@link isRegularKind} returns false for kinds 40000+.
25
26
  */
26
27
  function classifyKind(kind) {
27
28
  if (isReplaceableKind(kind)) return "replaceable";
@@ -63,4 +64,4 @@ const Kind = {
63
64
  //#endregion
64
65
  export { isRegularKind as a, isEphemeralKind as i, classifyKind as n, isReplaceableKind as o, isAddressableKind as r, Kind as t };
65
66
 
66
- //# sourceMappingURL=kind-D8fENiiL.mjs.map
67
+ //# sourceMappingURL=kind-I2Tvbe82.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kind-I2Tvbe82.mjs","names":[],"sources":["../src/core/kind.ts"],"sourcesContent":["/**\n * Regular means relays store the event: every kind below 10000 except the replaceable kinds 0 and 3.\n * The NIP-01 enumerated regular ranges are a subset; kinds 45–999 are stored like regular events in\n * practice (nostr-tools and rust-nostr agree).\n */\nexport function isRegularKind(kind: number): boolean {\n return kind < 10000 && kind !== 0 && kind !== 3;\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\n/** NIP-01 kind classes: regular / replaceable / ephemeral / addressable. */\nexport type KindClassification = \"regular\" | \"replaceable\" | \"ephemeral\" | \"addressable\";\n\n/**\n * Classify a kind number into its NIP-01 storage class. NIP-01 leaves kinds 45–999 and 40000+\n * undefined (rather than forbidden); relays store them like regular events, so they classify\n * `\"regular\"` here even though {@link isRegularKind} returns false for kinds 40000+.\n */\nexport function classifyKind(kind: number): KindClassification {\n if (isReplaceableKind(kind)) {\n return \"replaceable\";\n }\n if (isEphemeralKind(kind)) {\n return \"ephemeral\";\n }\n if (isAddressableKind(kind)) {\n return \"addressable\";\n }\n return \"regular\";\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\n/** Name of a kind constant on {@link Kind}. */\nexport type KindName = keyof typeof Kind;\n/** Union of the numeric kind values on {@link Kind}. */\nexport type KnownKind = (typeof Kind)[KindName];\n"],"mappings":";;;;;;AAKA,SAAgB,cAAc,MAAuB;CACnD,OAAO,OAAO,OAAS,SAAS,KAAK,SAAS;AAChD;;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;;;;;;AAUA,SAAgB,aAAa,MAAkC;CAC7D,IAAI,kBAAkB,IAAI,GACxB,OAAO;CAET,IAAI,gBAAgB,IAAI,GACtB,OAAO;CAET,IAAI,kBAAkB,IAAI,GACxB,OAAO;CAET,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"}
@@ -1,16 +1,16 @@
1
- import { f as nowSeconds, l as isRecord, s as isHex32, u as normalizeRelayUrls, y as NostrError } from "./util-DDpPkiED.mjs";
2
- import { r as isAddressableKind, t as Kind } from "./kind-D8fENiiL.mjs";
3
- import { p as sortedEvents, y as formatEventAddress } from "./event-B3ua2_oL.mjs";
1
+ import { c as isHex32, d as normalizeRelayUrls, p as nowSeconds, u as isRecord, x as NostrError } from "./util-DfsyJ9nz.mjs";
2
+ import { r as isAddressableKind, t as Kind } from "./kind-I2Tvbe82.mjs";
3
+ import { p as sortedEvents, y as formatEventAddress } from "./event-DvM1f03b.mjs";
4
4
  import { i as throwIfAborted } from "./abort-DBq2STPj.mjs";
5
- import { t as invokeSafely } from "./report-CHld4uWj.mjs";
5
+ import { t as invokeSafely } from "./report-D2BM5dgn.mjs";
6
6
  import { Nip19Error, decode, npubEncode } from "./nips/nip19.mjs";
7
7
  import { parseRelayList } from "./nips/nip65.mjs";
8
- import "./relay-DXtwUEdX.mjs";
8
+ import "./relay-DIR77xQ2.mjs";
9
9
  import { i as trimOldest, r as touchKey } from "./collections-DtwMc1NU.mjs";
10
10
  import { parseDmRelayList } from "./nips/nip17.mjs";
11
11
  import { parseMuteList } from "./nips/nip51.mjs";
12
- import { n as toStorageError } from "./error-DH4guike.mjs";
13
- import { r as outboxBoundKey } from "./put-DRmV1wHD.mjs";
12
+ import { n as toStorageError } from "./error-QyECUDIp.mjs";
13
+ import { r as outboxBoundKey } from "./put-BEM5j8xK.mjs";
14
14
  //#region src/loaders/context.ts
15
15
  /** Internal dependency bag for loaders — never a module-level singleton. */
16
16
  var LoaderContext = class {
@@ -130,7 +130,7 @@ function createEventLoader(ctx) {
130
130
  if (relays.length === 0) return;
131
131
  await ctx.pool.fetch(relays, [parsed.filter], {
132
132
  timeoutMs: ctx.fetchTimeoutMs,
133
- onevent: (event, relayUrl) => ctx.ingest(event, relayUrl)
133
+ onEvent: (event, relayUrl) => ctx.ingest(event, relayUrl)
134
134
  });
135
135
  return parsed.lookup(ctx);
136
136
  } finally {
@@ -321,13 +321,14 @@ var DataLoader = class {
321
321
  queueMicrotask(() => this.#dispatch());
322
322
  }
323
323
  });
324
- const promise = (async () => {
324
+ const cleanup = async () => {
325
325
  try {
326
326
  return await pending;
327
327
  } finally {
328
- this.#inflight.delete(cacheKey);
328
+ if (this.#inflight.get(cacheKey) === promise) this.#inflight.delete(cacheKey);
329
329
  }
330
- })();
330
+ };
331
+ const promise = cleanup();
331
332
  this.#inflight.set(cacheKey, promise);
332
333
  if (this.#useCache) this.#cache.set(cacheKey, promise);
333
334
  return promise;
@@ -377,7 +378,7 @@ var DataLoader = class {
377
378
  const MAX_FETCHED_AT = 1e4;
378
379
  /**
379
380
  * Batch-fetch replaceable events (kind + authors) via the pool. Fetched events are written into the
380
- * reactive index (`onevent` records `seenOn`) and the winner is read back from it; the index — not
381
+ * reactive index (`onEvent` records `seenOn`) and the winner is read back from it; the index — not
381
382
  * the loader — owns the stored value and winner selection. The loader only tracks per-address
382
383
  * `fetchedAt` timestamps so a recent fetch (including a miss) is not repeated within
383
384
  * `staleAfterSec`.
@@ -401,7 +402,7 @@ function createReplaceableLoader(ctx, kind) {
401
402
  };
402
403
  await ctx.pool.fetch(relays, [filter], {
403
404
  timeoutMs: ctx.fetchTimeoutMs,
404
- onevent: (event, relayUrl) => ctx.ingest(event, relayUrl)
405
+ onEvent: (event, relayUrl) => ctx.ingest(event, relayUrl)
405
406
  });
406
407
  }
407
408
  const now = nowSeconds();
@@ -550,7 +551,7 @@ var OutboxFeed = class {
550
551
  const batch = await this.#pool.fetch([url], filters, {
551
552
  timeoutMs: this.#timeoutMs,
552
553
  signal: opts?.signal,
553
- onevent: (event, relayUrl) => invokeSafely(() => this.#seen?.(event, relayUrl))
554
+ onEvent: (event, relayUrl) => invokeSafely(() => this.#seen?.(event, relayUrl))
554
555
  });
555
556
  for (const event of batch) byId.set(event.id, event);
556
557
  } catch (error) {
@@ -593,7 +594,7 @@ var OutboxFeed = class {
593
594
  };
594
595
  closers.push(this.#pool.subscribe([url], [filter], {
595
596
  signal: opts?.signal,
596
- onevent: (event, relayUrl) => {
597
+ onEvent: (event, relayUrl) => {
597
598
  invokeSafely(() => this.#seen?.(event, relayUrl));
598
599
  if (seen.has(event.id)) return;
599
600
  seen.add(event.id);
@@ -780,4 +781,4 @@ function createLoaders(opts) {
780
781
  //#endregion
781
782
  export { bareNostrUser as a, groupAuthorsByOutboxRelay as i, OutboxError as n, OutboxFeed as r, createLoaders as t };
782
783
 
783
- //# sourceMappingURL=loaders-Dp2nXEFk.mjs.map
784
+ //# sourceMappingURL=loaders-BRh2riV9.mjs.map