@qntx/nostr 0.6.0 → 0.7.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 (177) hide show
  1. package/dist/{abort-Ba8tDrOI.mjs → abort-DBq2STPj.mjs} +13 -6
  2. package/dist/abort-DBq2STPj.mjs.map +1 -0
  3. package/dist/{builder-9tjI6WQ3.mjs → builder-CdLE4J6O.mjs} +11 -17
  4. package/dist/builder-CdLE4J6O.mjs.map +1 -0
  5. package/dist/{builder-sSflu6nB.d.mts → builder-DgkqDylK.d.mts} +5 -6
  6. package/dist/{client-CadO5fAX.mjs → client-CILhdfsF.mjs} +104 -314
  7. package/dist/client-CILhdfsF.mjs.map +1 -0
  8. package/dist/client.d.mts +2 -2
  9. package/dist/client.mjs +2 -2
  10. package/dist/collections-DtwMc1NU.mjs +33 -0
  11. package/dist/collections-DtwMc1NU.mjs.map +1 -0
  12. package/dist/core.d.mts +9 -8
  13. package/dist/core.mjs +7 -7
  14. package/dist/{error-BW7re1UN.d.mts → error-BD_0QFKT.d.mts} +2 -2
  15. package/dist/{error-CR8Urc84.d.mts → error-BquXDmIN.d.mts} +4 -4
  16. package/dist/{error-DrEIM7FO.mjs → error-L_QdmSnV.mjs} +2 -2
  17. package/dist/{error-DrEIM7FO.mjs.map → error-L_QdmSnV.mjs.map} +1 -1
  18. package/dist/{error-B__OMBRY.mjs → error-gtJvV6YS.mjs} +2 -2
  19. package/dist/{error-B__OMBRY.mjs.map → error-gtJvV6YS.mjs.map} +1 -1
  20. package/dist/{event-fU3Y01PR.d.mts → event-DJeb_DIL.d.mts} +4 -2
  21. package/dist/{event-D8Nfoh4K.mjs → event-DinQMmJ1.mjs} +16 -10
  22. package/dist/event-DinQMmJ1.mjs.map +1 -0
  23. package/dist/{filter-C0IMByE3.d.mts → filter-jI_9htF7.d.mts} +2 -2
  24. package/dist/{gossip-DpIvkBuj.d.mts → gossip-C7HLW5kI.d.mts} +35 -26
  25. package/dist/{gossip-oloDMWEj.mjs → gossip-CcTp9VpU.mjs} +23 -33
  26. package/dist/gossip-CcTp9VpU.mjs.map +1 -0
  27. package/dist/gossip.d.mts +1 -1
  28. package/dist/gossip.mjs +1 -1
  29. package/dist/{index-CvkvqB16.d.mts → index-DU9tRFTZ.d.mts} +7 -20
  30. package/dist/{index-q4MDce_r.d.mts → index-DiXwNn2M.d.mts} +6 -8
  31. package/dist/{index-CNl2q67H.d.mts → index-DocgD9K0.d.mts} +92 -167
  32. package/dist/{index-D1bqFHKB.d.mts → index-InQZpHyQ.d.mts} +18 -18
  33. package/dist/{index-MxC28S4P.d.mts → index-Tx15HGAD.d.mts} +26 -28
  34. package/dist/{index-lvXeER5t.d.mts → index-iLT8UzY3.d.mts} +19 -37
  35. package/dist/index.d.mts +23 -21
  36. package/dist/index.mjs +21 -19
  37. package/dist/{instance-DQE8BoWt.mjs → instance-BcKzxHIP.mjs} +26 -27
  38. package/dist/instance-BcKzxHIP.mjs.map +1 -0
  39. package/dist/{instance-CIca-ynn.d.mts → instance-DjsL8h84.d.mts} +5 -5
  40. package/dist/{key-Cv4_pN3x.d.mts → key-D_5OgGT7.d.mts} +11 -7
  41. package/dist/{key-Bps-LqX7.mjs → key-bshqfmZL.mjs} +13 -9
  42. package/dist/key-bshqfmZL.mjs.map +1 -0
  43. package/dist/{loaders-o6YXB_Ri.mjs → loaders-DD0XAGzw.mjs} +73 -82
  44. package/dist/loaders-DD0XAGzw.mjs.map +1 -0
  45. package/dist/loaders.d.mts +3 -3
  46. package/dist/loaders.mjs +2 -2
  47. package/dist/{memory-C2EVx0_O.mjs → memory-D_-5-T31.mjs} +2 -2
  48. package/dist/memory-D_-5-T31.mjs.map +1 -0
  49. package/dist/{memory-index-Do1mz0WF.mjs → memory-index-C6rujtoc.mjs} +30 -247
  50. package/dist/memory-index-C6rujtoc.mjs.map +1 -0
  51. package/dist/message-CWLcFTQ1.mjs +194 -0
  52. package/dist/message-CWLcFTQ1.mjs.map +1 -0
  53. package/dist/{message-iGPIqnn0.d.mts → message-CbBZOhq3.d.mts} +3 -3
  54. package/dist/{nip17-CKIufV98.d.mts → nip17-cTDFfFVt.d.mts} +5 -6
  55. package/dist/{nip19-BevCJZsp.d.mts → nip19-D1OnJ192.d.mts} +3 -9
  56. package/dist/{nip46-DDV4dC56.d.mts → nip46-DrsPI8EX.d.mts} +3 -5
  57. package/dist/nip51-DoPUvQ--.d.mts +87 -0
  58. package/dist/{nip59-zQgdLcEr.d.mts → nip59-BFIihLYY.d.mts} +3 -4
  59. package/dist/nip65-52HiwiyD.d.mts +23 -0
  60. package/dist/{nip77-DH4RhS5r.d.mts → nip77-C9QcZn7b.d.mts} +3 -4
  61. package/dist/nips/blossom.d.mts +12 -8
  62. package/dist/nips/blossom.mjs +30 -9
  63. package/dist/nips/blossom.mjs.map +1 -1
  64. package/dist/nips/nip04.mjs +17 -7
  65. package/dist/nips/nip04.mjs.map +1 -1
  66. package/dist/nips/nip05.d.mts +2 -3
  67. package/dist/nips/nip05.mjs +1 -4
  68. package/dist/nips/nip05.mjs.map +1 -1
  69. package/dist/nips/nip10.d.mts +3 -3
  70. package/dist/nips/nip10.mjs +3 -3
  71. package/dist/nips/nip11.d.mts +1 -1
  72. package/dist/nips/nip11.mjs +4 -4
  73. package/dist/nips/nip11.mjs.map +1 -1
  74. package/dist/nips/nip13.d.mts +7 -7
  75. package/dist/nips/nip13.mjs +32 -10
  76. package/dist/nips/nip13.mjs.map +1 -1
  77. package/dist/nips/nip17.d.mts +1 -1
  78. package/dist/nips/nip17.mjs +13 -33
  79. package/dist/nips/nip17.mjs.map +1 -1
  80. package/dist/nips/nip19.d.mts +2 -2
  81. package/dist/nips/nip19.mjs +16 -28
  82. package/dist/nips/nip19.mjs.map +1 -1
  83. package/dist/nips/nip21.d.mts +6 -1
  84. package/dist/nips/nip21.mjs +15 -5
  85. package/dist/nips/nip21.mjs.map +1 -1
  86. package/dist/nips/nip27.d.mts +4 -4
  87. package/dist/nips/nip27.mjs.map +1 -1
  88. package/dist/nips/nip42.d.mts +1 -1
  89. package/dist/nips/nip42.mjs +2 -1
  90. package/dist/nips/nip42.mjs.map +1 -1
  91. package/dist/nips/nip44.mjs +1 -1
  92. package/dist/nips/nip46.d.mts +2 -2
  93. package/dist/nips/nip46.mjs +15 -19
  94. package/dist/nips/nip46.mjs.map +1 -1
  95. package/dist/nips/nip49.d.mts +5 -5
  96. package/dist/nips/nip49.mjs +4 -4
  97. package/dist/nips/nip49.mjs.map +1 -1
  98. package/dist/nips/nip51.d.mts +2 -86
  99. package/dist/nips/nip51.mjs +7 -23
  100. package/dist/nips/nip51.mjs.map +1 -1
  101. package/dist/nips/nip57.d.mts +7 -5
  102. package/dist/nips/nip57.mjs +12 -17
  103. package/dist/nips/nip57.mjs.map +1 -1
  104. package/dist/nips/nip59.d.mts +1 -1
  105. package/dist/nips/nip59.mjs +16 -16
  106. package/dist/nips/nip59.mjs.map +1 -1
  107. package/dist/nips/nip65.d.mts +2 -2
  108. package/dist/nips/nip65.mjs +14 -37
  109. package/dist/nips/nip65.mjs.map +1 -1
  110. package/dist/nips/nip77.d.mts +1 -1
  111. package/dist/nips/nip77.mjs +33 -32
  112. package/dist/nips/nip77.mjs.map +1 -1
  113. package/dist/nips/nip98.d.mts +5 -5
  114. package/dist/nips/nip98.mjs +8 -8
  115. package/dist/nips/nip98.mjs.map +1 -1
  116. package/dist/{pool-DBIYMtwy.d.mts → pool-SzJKPIa3.d.mts} +96 -91
  117. package/dist/pool-YHRZgcQ3.mjs +596 -0
  118. package/dist/pool-YHRZgcQ3.mjs.map +1 -0
  119. package/dist/put-DS0yzVJx.mjs +187 -0
  120. package/dist/put-DS0yzVJx.mjs.map +1 -0
  121. package/dist/{reactive-7aqeip4A.d.mts → reactive-BJ1ggn4d.d.mts} +7 -22
  122. package/dist/{reactive-BfhPp9a3.mjs → reactive-BJRoVHxU.mjs} +80 -65
  123. package/dist/reactive-BJRoVHxU.mjs.map +1 -0
  124. package/dist/{pool-As20OGxB.mjs → relay-CvxPiQ_m.mjs} +178 -721
  125. package/dist/relay-CvxPiQ_m.mjs.map +1 -0
  126. package/dist/relay.d.mts +4 -4
  127. package/dist/relay.mjs +3 -2
  128. package/dist/serial-Bzpw-xz3.mjs +21 -0
  129. package/dist/serial-Bzpw-xz3.mjs.map +1 -0
  130. package/dist/{signer-CYQutDzD.mjs → signer-yW3slDC2.mjs} +12 -14
  131. package/dist/signer-yW3slDC2.mjs.map +1 -0
  132. package/dist/signer.d.mts +2 -2
  133. package/dist/signer.mjs +2 -2
  134. package/dist/{storage-Dky3wuoH.mjs → storage-CZ52ifcQ.mjs} +17 -42
  135. package/dist/storage-CZ52ifcQ.mjs.map +1 -0
  136. package/dist/storage.d.mts +3 -3
  137. package/dist/storage.mjs +4 -4
  138. package/dist/store.d.mts +1 -1
  139. package/dist/store.mjs +1 -1
  140. package/dist/testing.d.mts +18 -18
  141. package/dist/testing.mjs +9 -9
  142. package/dist/testing.mjs.map +1 -1
  143. package/dist/{types-2pCUprRU.d.mts → types-Cm-XMgtH.d.mts} +6 -6
  144. package/dist/{types-CRQEk0Oi.d.mts → types-DNmiscfd.d.mts} +2 -2
  145. package/dist/{util-LfQirgDk.mjs → util-yFYzlbrm.mjs} +29 -7
  146. package/dist/util-yFYzlbrm.mjs.map +1 -0
  147. package/dist/{verifier-t5WoWbtY.mjs → verifier-BTLOpo1n.mjs} +3 -3
  148. package/dist/verifier-BTLOpo1n.mjs.map +1 -0
  149. package/dist/verifier-CgTFpgsC.d.mts +22 -0
  150. package/dist/wasm.browser.d.mts +3 -3
  151. package/dist/wasm.browser.mjs +3 -3
  152. package/dist/wasm.d.mts +3 -3
  153. package/dist/wasm.mjs +3 -3
  154. package/dist/wasm.mjs.map +1 -1
  155. package/package.json +5 -9
  156. package/dist/abort-Ba8tDrOI.mjs.map +0 -1
  157. package/dist/builder-9tjI6WQ3.mjs.map +0 -1
  158. package/dist/client-CadO5fAX.mjs.map +0 -1
  159. package/dist/event-D8Nfoh4K.mjs.map +0 -1
  160. package/dist/gossip-oloDMWEj.mjs.map +0 -1
  161. package/dist/instance-DQE8BoWt.mjs.map +0 -1
  162. package/dist/key-Bps-LqX7.mjs.map +0 -1
  163. package/dist/loaders-o6YXB_Ri.mjs.map +0 -1
  164. package/dist/memory-C2EVx0_O.mjs.map +0 -1
  165. package/dist/memory-index-Do1mz0WF.mjs.map +0 -1
  166. package/dist/message-DcY6Fi9o.mjs +0 -193
  167. package/dist/message-DcY6Fi9o.mjs.map +0 -1
  168. package/dist/nip65-CjgmdpPB.d.mts +0 -26
  169. package/dist/nips/nip96.d.mts +0 -40
  170. package/dist/nips/nip96.mjs +0 -118
  171. package/dist/nips/nip96.mjs.map +0 -1
  172. package/dist/pool-As20OGxB.mjs.map +0 -1
  173. package/dist/reactive-BfhPp9a3.mjs.map +0 -1
  174. package/dist/signer-CYQutDzD.mjs.map +0 -1
  175. package/dist/storage-Dky3wuoH.mjs.map +0 -1
  176. package/dist/util-LfQirgDk.mjs.map +0 -1
  177. package/dist/verifier-t5WoWbtY.mjs.map +0 -1
@@ -1,6 +1,6 @@
1
- import { t as Event } from "./event-fU3Y01PR.mjs";
2
- import { t as Filter } from "./filter-C0IMByE3.mjs";
3
- import { i as PutResult, n as NegentropyItem, r as OutboxBound, t as EventStore } from "./types-2pCUprRU.mjs";
1
+ import { t as Event } from "./event-DJeb_DIL.mjs";
2
+ import { t as Filter } from "./filter-jI_9htF7.mjs";
3
+ import { i as PutResult, n as NegentropyItem, r as OutboxBound, t as EventStore } from "./types-Cm-XMgtH.mjs";
4
4
  //#region src/storage/memory-index.d.ts
5
5
  type MemoryIndexOptions = {
6
6
  /**
@@ -8,7 +8,7 @@ type MemoryIndexOptions = {
8
8
  * e-tag ids, and coordinate tombstones. Default unbounded. Trade-off: once an entry is trimmed, a
9
9
  * re-arriving old deleted event or replaceable version can be accepted again.
10
10
  */
11
- maxTombstones?: number;
11
+ maxTombstones?: number | undefined;
12
12
  /**
13
13
  * FIFO cap on replaceable/addressable winner watermarks recorded by {@link evict}. A watermark
14
14
  * keeps only `{ id, created_at }` per address so stale versions stay rejected after the winner's
@@ -16,11 +16,11 @@ type MemoryIndexOptions = {
16
16
  * retention); callers that evict should pass a bound. Once a watermark is trimmed, an older
17
17
  * evicted version can be accepted again — the same trade-off as deletion tombstones.
18
18
  */
19
- maxWatermarks?: number;
19
+ maxWatermarks?: number | undefined;
20
20
  /** Fires after every physical index insert (accept, replace, deletion event). */
21
- onInsert?: (event: Event) => void;
21
+ onInsert?: ((event: Event) => void) | undefined;
22
22
  /** Fires after every physical index remove (replace, delete, evict, remove, clear). */
23
- onRemove?: (event: Event) => void;
23
+ onRemove?: ((event: Event) => void) | undefined;
24
24
  };
25
25
  /**
26
26
  * Synchronous in-memory event index with NIP-01 replaceable / addressable / ephemeral handling and
@@ -68,10 +68,10 @@ declare class MemoryEventStore implements EventStore {
68
68
  /** Sequential `put` in input order. No transaction: a throw leaves earlier events applied. */
69
69
  putMany(events: ReadonlyArray<Event>): Promise<PutResult[]>;
70
70
  get(id: string): Promise<Event | undefined>;
71
- query(filters: Filter[]): Promise<Event[]>;
72
- count(filters: Filter[]): Promise<number>;
71
+ query(filters: ReadonlyArray<Filter>): Promise<Event[]>;
72
+ count(filters: ReadonlyArray<Filter>): Promise<number>;
73
73
  negentropyItems(filter: Filter): Promise<NegentropyItem[]>;
74
- remove(ids: string[]): Promise<number>;
74
+ remove(ids: ReadonlyArray<string>): Promise<number>;
75
75
  getOutboxBound(pubkey: string, kind: number): Promise<OutboxBound | undefined>;
76
76
  setOutboxBound(pubkey: string, kind: number, bound: OutboxBound): Promise<void>;
77
77
  clear(): Promise<void>;
@@ -82,7 +82,7 @@ declare class MemoryEventStore implements EventStore {
82
82
  /** Options for {@link IndexedDbEventStore}. */
83
83
  type IndexedDbEventStoreOptions = {
84
84
  /** IndexedDB database name. */
85
- dbName?: string;
85
+ dbName?: string | undefined;
86
86
  };
87
87
  /**
88
88
  * Browser IndexedDB event store with the same replaceable / deletion semantics as
@@ -100,12 +100,12 @@ declare class IndexedDbEventStore implements EventStore {
100
100
  /** One readwrite transaction; abort rejects the whole batch with no partial persist. */
101
101
  putMany(events: ReadonlyArray<Event>): Promise<PutResult[]>;
102
102
  get(id: string): Promise<Event | undefined>;
103
- query(filters: Filter[]): Promise<Event[]>;
104
- count(filters: Filter[]): Promise<number>;
103
+ query(filters: ReadonlyArray<Filter>): Promise<Event[]>;
104
+ count(filters: ReadonlyArray<Filter>): Promise<number>;
105
105
  negentropyItems(filter: Filter): Promise<NegentropyItem[]>;
106
106
  getOutboxBound(pubkey: string, kind: number): Promise<OutboxBound | undefined>;
107
107
  setOutboxBound(pubkey: string, kind: number, bound: OutboxBound): Promise<void>;
108
- remove(ids: string[]): Promise<number>;
108
+ remove(ids: ReadonlyArray<string>): Promise<number>;
109
109
  clear(): Promise<void>;
110
110
  close(): void;
111
111
  }
@@ -175,14 +175,14 @@ declare class SqliteEventStore implements EventStore {
175
175
  put(event: Event): Promise<PutResult>;
176
176
  putMany(events: ReadonlyArray<Event>): Promise<PutResult[]>;
177
177
  get(id: string): Promise<Event | undefined>;
178
- query(filters: Filter[]): Promise<Event[]>;
179
- count(filters: Filter[]): Promise<number>;
178
+ query(filters: ReadonlyArray<Filter>): Promise<Event[]>;
179
+ count(filters: ReadonlyArray<Filter>): Promise<number>;
180
180
  negentropyItems(filter: Filter): Promise<NegentropyItem[]>;
181
181
  getOutboxBound(pubkey: string, kind: number): Promise<OutboxBound | undefined>;
182
182
  setOutboxBound(pubkey: string, kind: number, bound: OutboxBound): Promise<void>;
183
- remove(ids: string[]): Promise<number>;
183
+ remove(ids: ReadonlyArray<string>): Promise<number>;
184
184
  clear(): Promise<void>;
185
185
  }
186
186
  //#endregion
187
187
  export { IndexedDbEventStoreOptions as a, MemoryIndexOptions as c, IndexedDbEventStore as i, SqlValue as n, MemoryEventStore as o, SqliteEventStore as r, MemoryIndex as s, SqlDriver as t };
188
- //# sourceMappingURL=index-D1bqFHKB.d.mts.map
188
+ //# sourceMappingURL=index-InQZpHyQ.d.mts.map
@@ -1,9 +1,9 @@
1
- import { n as EventTemplate, r as UnsignedEvent, t as Event } from "./event-fU3Y01PR.mjs";
2
- import { r as SecretKey, t as Keys } from "./key-Cv4_pN3x.mjs";
3
- import { t as Filter } from "./filter-C0IMByE3.mjs";
4
- import { a as NostrError } from "./error-CR8Urc84.mjs";
5
- import { t as NostrSigner } from "./types-CRQEk0Oi.mjs";
6
- import { n as BunkerPointer, r as ClientMetadata } from "./nip46-DDV4dC56.mjs";
1
+ import { n as EventTemplate, r as UnsignedEvent, t as Event } from "./event-DJeb_DIL.mjs";
2
+ import { i as SecretKeyInput, t as Keys } from "./key-D_5OgGT7.mjs";
3
+ import { t as Filter } from "./filter-jI_9htF7.mjs";
4
+ import { a as NostrError } from "./error-BquXDmIN.mjs";
5
+ import { t as NostrSigner } from "./types-DNmiscfd.mjs";
6
+ import { n as ClientMetadata, t as BunkerPointer } from "./nip46-DrsPI8EX.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.
@@ -18,7 +18,7 @@ declare class NoSignerError extends NostrError {
18
18
  /** Local secret-key signer with NIP-04 (legacy) and NIP-44 support. */
19
19
  declare class KeysSigner implements NostrSigner {
20
20
  #private;
21
- constructor(secretKey: SecretKey | Uint8Array | string | Keys);
21
+ constructor(secretKey: SecretKeyInput | Keys);
22
22
  get keys(): Keys;
23
23
  getPublicKey(): Promise<string>;
24
24
  signEvent(unsigned: UnsignedEvent): Promise<Event>;
@@ -77,49 +77,47 @@ type Nip46SubscribeOptions = {
77
77
  * constructed above the signer layer so `signer` never imports `relay` (ADR-0001).
78
78
  */
79
79
  type Nip46Transport = {
80
- subscribe: (relays: string[], filters: Filter[], opts?: Nip46SubscribeOptions) => {
80
+ subscribe: (relays: ReadonlyArray<string>, filters: ReadonlyArray<Filter>, opts?: Nip46SubscribeOptions) => {
81
81
  close: (reason?: string) => void;
82
82
  };
83
- publish: (relays: string[], event: Event) => Promise<ReadonlyArray<{
84
- result?: {
85
- ok: boolean;
86
- message: string;
87
- };
88
- error?: string;
83
+ publish: (relays: ReadonlyArray<string>, event: Event) => Promise<ReadonlyArray<{
84
+ readonly status: "ok" | "rejected" | "failed";
85
+ readonly message?: string;
86
+ readonly error?: string;
89
87
  }>>;
90
88
  close: (urls?: string[]) => void;
91
89
  };
92
90
  /** Options for {@link Nip46Signer}: transport, timeouts, and relay hints. */
93
91
  type Nip46SignerOptions = {
94
92
  /** Shared transport. When set, the signer does not close it on {@link Nip46Signer.close}. */
95
- pool?: Nip46Transport;
93
+ pool?: Nip46Transport | undefined;
96
94
  /**
97
95
  * Factory for a private transport when `pool` is omitted. Typical: `() => new Pool({
98
96
  * websocketImplementation, enableReconnect: true })`.
99
97
  */
100
- createPool?: () => Nip46Transport;
98
+ createPool?: (() => Nip46Transport) | undefined;
101
99
  /**
102
100
  * Relays used when the bunker pointer has none, and merged uniquely onto a nonempty pointer
103
101
  * (pointer first).
104
102
  */
105
- relays?: string[];
103
+ relays?: ReadonlyArray<string> | undefined;
106
104
  /** Bunker connection secret when the pointer or bunker:// URL has none. */
107
105
  secret?: string | undefined;
108
106
  /** Local client key used to encrypt RPC (not the remote user key). */
109
- clientSecretKey?: SecretKey | Uint8Array | string;
107
+ clientSecretKey?: SecretKeyInput | undefined;
110
108
  /** Called when bunker returns `auth_url` for a pending request. */
111
- onAuthUrl?: (url: string) => void;
109
+ onAuthUrl?: ((url: string) => void) | undefined;
112
110
  /** Per-request timeout in ms. Default 30s. */
113
- timeoutMs?: number;
111
+ timeoutMs?: number | undefined;
114
112
  /**
115
113
  * Timeout in ms applied after the bunker replies `auth_url`: the request keeps waiting for the
116
114
  * real response until this elapses. Default 300s.
117
115
  */
118
- authTimeoutMs?: number;
116
+ authTimeoutMs?: number | undefined;
119
117
  /** Requested permissions sent with `connect` (`method[:kind]` list). */
120
- perms?: string[];
118
+ perms?: ReadonlyArray<string> | undefined;
121
119
  /** Client metadata sent with bunker-initiated `connect`. */
122
- metadata?: ClientMetadata;
120
+ metadata?: ClientMetadata | undefined;
123
121
  };
124
122
  /**
125
123
  * NIP-46 remote signer (bunker / nostrconnect). Implements {@link NostrSigner}; never holds the
@@ -136,7 +134,7 @@ declare class Nip46Signer implements NostrSigner {
136
134
  * identity.
137
135
  */
138
136
  static fromBunker(pointer: BunkerPointer, opts: Nip46SignerOptions & {
139
- clientSecretKey: SecretKey | Uint8Array | string;
137
+ clientSecretKey: SecretKeyInput;
140
138
  }): Nip46Signer;
141
139
  /**
142
140
  * Connect using a `bunker://` URL or pre-parsed pointer. Invalid strings throw. A NIP-05
@@ -150,13 +148,13 @@ declare class Nip46Signer implements NostrSigner {
150
148
  * {@link createNostrConnectURI} after generating keys).
151
149
  */
152
150
  static fromNostrConnectURI(connectionURI: string, opts: Nip46SignerOptions & {
153
- clientSecretKey: SecretKey | Uint8Array | string;
151
+ clientSecretKey: SecretKeyInput;
154
152
  signal?: AbortSignal;
155
153
  handshakeTimeoutMs?: number;
156
154
  }): Promise<Nip46Signer>;
157
155
  connectRemote(overrides?: {
158
- metadata?: ClientMetadata;
159
- perms?: string[];
156
+ metadata?: ClientMetadata | undefined;
157
+ perms?: ReadonlyArray<string> | undefined;
160
158
  }): Promise<void>;
161
159
  /**
162
160
  * Ask the bunker for its preferred relay list and resubscribe when it changes. Spec result is a
@@ -176,4 +174,4 @@ declare class Nip46Signer implements NostrSigner {
176
174
  }
177
175
  //#endregion
178
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 };
179
- //# sourceMappingURL=index-MxC28S4P.d.mts.map
177
+ //# sourceMappingURL=index-Tx15HGAD.d.mts.map
@@ -1,12 +1,13 @@
1
- import { t as Event } from "./event-fU3Y01PR.mjs";
2
- import { n as ProfileMetadata } from "./builder-sSflu6nB.mjs";
3
- import { t as RelayListItem } from "./nip65-CjgmdpPB.mjs";
4
- import { t as Gossip } from "./gossip-DpIvkBuj.mjs";
5
- import { a as NostrError } from "./error-CR8Urc84.mjs";
6
- import { n as Pool } from "./pool-DBIYMtwy.mjs";
7
- import { r as OutboxBound, t as EventStore } from "./types-2pCUprRU.mjs";
8
- import { t as ReactiveEventStore } from "./reactive-7aqeip4A.mjs";
9
- import { i as EventPointer, t as AddressPointer } from "./nip19-BevCJZsp.mjs";
1
+ import { t as Event } from "./event-DJeb_DIL.mjs";
2
+ import { n as ProfileMetadata } from "./builder-DgkqDylK.mjs";
3
+ import { t as RelayListItem } from "./nip65-52HiwiyD.mjs";
4
+ import { t as Gossip } from "./gossip-C7HLW5kI.mjs";
5
+ import { a as NostrError } from "./error-BquXDmIN.mjs";
6
+ import { g as Closer, n as Pool } from "./pool-SzJKPIa3.mjs";
7
+ import { r as OutboxBound, t as EventStore } from "./types-Cm-XMgtH.mjs";
8
+ import { t as ReactiveEventStore } from "./reactive-BJ1ggn4d.mjs";
9
+ import { i as EventPointer, t as AddressPointer } from "./nip19-D1OnJ192.mjs";
10
+ import { t as MuteItem } from "./nip51-DoPUvQ--.mjs";
10
11
  //#region src/loaders/event.d.ts
11
12
  type EventRef = string | EventPointer | AddressPointer;
12
13
  /**
@@ -39,27 +40,13 @@ type ListResult<T> = {
39
40
  items: T[];
40
41
  fresh: boolean;
41
42
  };
42
- /** One muted entity decoded from a kind:10000 mute list. */
43
- type MutedEntity = {
44
- label: "pubkey";
45
- value: string;
46
- } | {
47
- label: "thread";
48
- value: string;
49
- } | {
50
- label: "hashtag";
51
- value: string;
52
- } | {
53
- label: "word";
54
- value: string;
55
- };
56
43
  type ListLoaderOpts = {
57
44
  hints?: string[] | undefined;
58
45
  style?: LoadStyle | undefined;
59
46
  };
60
47
  type ListLoaders = {
61
48
  follows: (pubkey: string, opts?: ListLoaderOpts) => Promise<ListResult<string>>;
62
- muteList: (pubkey: string, opts?: ListLoaderOpts) => Promise<ListResult<MutedEntity>>;
49
+ muteList: (pubkey: string, opts?: ListLoaderOpts) => Promise<ListResult<MuteItem>>;
63
50
  relayList: (pubkey: string, opts?: ListLoaderOpts) => Promise<ListResult<RelayListItem>>;
64
51
  dmRelayList: (pubkey: string, opts?: ListLoaderOpts) => Promise<ListResult<string>>;
65
52
  };
@@ -90,7 +77,7 @@ type ProfileLoader = {
90
77
  declare class OutboxError extends NostrError {
91
78
  name: string;
92
79
  }
93
- /** Options for {@link createOutboxFeed}. */
80
+ /** Options for {@link OutboxFeed}. */
94
81
  type OutboxFeedOptions = {
95
82
  pool: Pool;
96
83
  gossip: Gossip;
@@ -156,21 +143,16 @@ declare class OutboxFeed {
156
143
  startLive(opts?: {
157
144
  signal?: AbortSignal | undefined;
158
145
  since?: number | undefined;
159
- }): {
160
- close: (reason?: string) => void;
161
- };
146
+ }): Closer;
162
147
  /** Convenience: hydrate + sync + startLive. */
163
148
  start(opts?: {
164
149
  limit?: number | undefined;
165
150
  signal?: AbortSignal | undefined;
166
- }): Promise<{
167
- close: (reason?: string) => void;
151
+ }): Promise<Closer & {
168
152
  events: Event[];
169
153
  }>;
170
154
  close(): void;
171
155
  }
172
- /** Factory matching other loaders helpers. */
173
- declare function createOutboxFeed(opts: OutboxFeedOptions): OutboxFeed;
174
156
  //#endregion
175
157
  //#region src/loaders/index.d.ts
176
158
  /** The loader surface returned by {@link createLoaders}. */
@@ -196,12 +178,12 @@ type CreateLoadersOptions = {
196
178
  * Inbound-event sink for fetched events; defaults to `index.add`. Client wires its single ingest
197
179
  * path so loader fetches get gossip meta and persistence like every other inbound event.
198
180
  */
199
- ingest?: (event: Event, relayUrl: string) => void;
200
- staleAfterSec?: number;
201
- fetchTimeoutMs?: number;
181
+ ingest?: ((event: Event, relayUrl: string) => void) | undefined;
182
+ staleAfterSec?: number | undefined;
183
+ fetchTimeoutMs?: number | undefined;
202
184
  };
203
185
  /** Build an instance-scoped loader suite (no module globals). */
204
186
  declare function createLoaders(opts: CreateLoadersOptions): Loaders;
205
187
  //#endregion
206
- export { ReplaceableLoader as _, OutboxFeed as a, groupAuthorsByOutboxRelay as c, bareNostrUser as d, ListLoaders as f, ReplaceableLoadResult as g, LoadStyle as h, OutboxError as i, NostrUser as l, MutedEntity as m, Loaders as n, OutboxFeedOptions as o, ListResult as p, createLoaders as r, createOutboxFeed as s, CreateLoadersOptions as t, ProfileLoader as u, EventLoader as v, EventRef as y };
207
- //# sourceMappingURL=index-lvXeER5t.d.mts.map
188
+ export { EventRef as _, OutboxFeed as a, NostrUser as c, ListLoaders as d, ListResult as f, EventLoader as g, ReplaceableLoader as h, OutboxError as i, ProfileLoader as l, ReplaceableLoadResult as m, Loaders as n, OutboxFeedOptions as o, LoadStyle as p, createLoaders as r, groupAuthorsByOutboxRelay as s, CreateLoadersOptions as t, bareNostrUser as u };
189
+ //# sourceMappingURL=index-iLT8UzY3.d.mts.map
package/dist/index.d.mts CHANGED
@@ -1,24 +1,26 @@
1
- import { C as parseEventAddress, S as isTag, T as tagValue, _ as Tag, b as formatEventAddress, d as signedMatchesUnsigned, f as sortEvents, g as EventAddress, h as validateSignedEvent, i as getEventHash, m as validateEvent, n as EventTemplate, o as isReplaceableWinner, p as sortedEvents, r as UnsignedEvent, s as itemCompare, t as Event, u as serializeEvent, v as TagInput, w as tagName, x as getDTag, y as eventAddress } from "./event-fU3Y01PR.mjs";
2
- import { a as finalizeEvent, c as signEvent, i as SigningBackend, n as PublicKey, o as getPublicKey, r as SecretKey, s as publicKeyFromHex, t as Keys } from "./key-Cv4_pN3x.mjs";
3
- import { n as ProfileMetadata, t as EventBuilder } from "./builder-sSflu6nB.mjs";
4
- import { a as getFilterLimit, c as mergeFilters, i as filterFingerprint, n as canonicalizeFilter, o as matchFilter, r as canonicalizeFilters, s as matchFilters, t as Filter } from "./filter-C0IMByE3.mjs";
5
- import { a as readRelays, c as writeRelays, i as parseRelayList, n as RelayMarker, o as relayListEventBuilder, r as markerOf, s as relayListToTags, t as RelayListItem } from "./nip65-CjgmdpPB.mjs";
6
- import { i as RoutedFilter, r as PubkeyRoutes, t as Gossip } from "./gossip-DpIvkBuj.mjs";
7
- import { a as assertSubscriptionId, c as encodeRelayMessage, d as parseRelayMessage, i as SubscriptionId, l as mergeCountHll, n as CountResult, o as createSubscriptionId, r as RelayMessage, s as encodeClientMessage, t as ClientMessage, u as parseClientMessage } from "./message-iGPIqnn0.mjs";
8
- import { a as NostrError, i as MessageError, n as EventValidationError, o as UrlError, r as HexError, s as WasmVerifyPoisonedError, t as CryptoError } from "./error-CR8Urc84.mjs";
9
- import { a as PoolOptions, c as PublishResult, d as RelayStatus, f as RelayStatusName, h as SubscribeOptions, i as PoolFetchResult, l as Relay, m as RelayFetchResult, n as Pool, o as PoolPublishResult, p as RelayFetchEnd, r as PoolCountResult, s as PoolSubscribeOptions, t as InvalidEventPolicy, u as RelayOptions } from "./pool-DBIYMtwy.mjs";
1
+ import { C as isTag, E as tagValue, S as getDTag, T as tagName, _ as Tag, d as signedMatchesUnsigned, f as sortEvents, g as EventAddress, h as validateSignedEvent, i as getEventHash, m as validateEvent, n as EventTemplate, o as isReplaceableWinner, p as sortedEvents, r as UnsignedEvent, s as itemCompare, t as Event, u as serializeEvent, v as TagInput, w as parseEventAddress, x as formatEventAddress, y as eventAddress } from "./event-DJeb_DIL.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-D_5OgGT7.mjs";
3
+ import { n as ProfileMetadata, t as EventBuilder } from "./builder-DgkqDylK.mjs";
4
+ import { a as getFilterLimit, c as mergeFilters, i as filterFingerprint, n as canonicalizeFilter, o as matchFilter, r as canonicalizeFilters, s as matchFilters, t as Filter } from "./filter-jI_9htF7.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-52HiwiyD.mjs";
6
+ import { i as RoutedFilter, r as PubkeyRoutes, t as Gossip } from "./gossip-C7HLW5kI.mjs";
7
+ import { a as assertSubscriptionId, c as encodeRelayMessage, d as parseRelayMessage, i as SubscriptionId, l as mergeCountHll, n as CountResult, o as createSubscriptionId, r as RelayMessage, s as encodeClientMessage, t as ClientMessage, u as parseClientMessage } from "./message-CbBZOhq3.mjs";
8
+ import { i as verifyEvent, n as SerializedEventVerifier, r as createEventVerifier, t as EventVerifier } from "./verifier-CgTFpgsC.mjs";
9
+ 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";
10
+ import { _ as RelaySubscription, a as PoolOptions, c as PublishResult, d as RelayOptions, f as RelayStatus, g as Closer, h as RelayFetchResult, i as PoolFetchResult, l as Relay, m as RelayFetchEnd, n as Pool, o as PoolPublishResult, p as RelayStatusName, r as PoolCountResult, s as PoolSubscribeOptions, t as InvalidEventPolicy, u as RelayEventMap, v as SubscribeOptions } from "./pool-SzJKPIa3.mjs";
10
11
  import { i as useWebSocketImplementation } from "./websocket-CmeqvAkp.mjs";
11
- import { i as PutResult, n as NegentropyItem, r as OutboxBound, t as EventStore } from "./types-2pCUprRU.mjs";
12
- import { n as ReactiveEventStoreOptions, r as Watch, t as ReactiveEventStore } from "./reactive-7aqeip4A.mjs";
13
- import { _ as neventEncode, a as NAddr, b as npubEncode, c as NPub, d as Note, f as ProfilePointer, g as naddrEncode, i as EventPointer, l as NSec, m as decodeNostrURI, n as Bech32MaxSize, o as NEvent, p as decode, r as DecodedResult, s as NProfile, t as AddressPointer, u as Nip19Error, v as noteEncode, x as nsecEncode, y as nprofileEncode } from "./nip19-BevCJZsp.mjs";
14
- import { _ as ReplaceableLoader, a as OutboxFeed, c as groupAuthorsByOutboxRelay, d as bareNostrUser, g as ReplaceableLoadResult, h as LoadStyle, i as OutboxError, l as NostrUser, m as MutedEntity, n as Loaders, o as OutboxFeedOptions, p as ListResult, r as createLoaders, s as createOutboxFeed } from "./index-lvXeER5t.mjs";
15
- import { t as NostrSigner } from "./types-CRQEk0Oi.mjs";
16
- import { t as StorageError } from "./error-BW7re1UN.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 ClientBuilder, p as SubscribePrivateMessagesOptions, r as ClientError, s as FetchPrivateMessagesOptions, t as Client, u as ReceivedPrivateMessage } from "./index-CNl2q67H.mjs";
18
- import { C as SIGNATURE_BYTES, S as SECRET_KEY_BYTES, _ as isHex32, a as KindClassification, b as EVENT_ID_BYTES, c as classifyKind, d as isRegularKind, f as isReplaceableKind, g as hexToBytes, h as bytesToHex, i as Kind, l as isAddressableKind, n as createEventVerifier, o as KindName, r as verifyEvent, s as KnownKind, t as SerializedEventVerifier, u as isEphemeralKind, v as isHex64, w as SUBSCRIPTION_ID_MAX_CHARS, x as PUBLIC_KEY_BYTES, y as normalizeURL } from "./index-CvkvqB16.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-MxC28S4P.mjs";
12
+ import { i as PutResult, n as NegentropyItem, r as OutboxBound, t as EventStore } from "./types-Cm-XMgtH.mjs";
13
+ import { n as ReactiveEventStoreOptions, r as Watch, t as ReactiveEventStore } from "./reactive-BJ1ggn4d.mjs";
14
+ 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-D1OnJ192.mjs";
15
+ 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-iLT8UzY3.mjs";
16
+ import { t as NostrSigner } from "./types-DNmiscfd.mjs";
17
+ import { t as StorageError } from "./error-BD_0QFKT.mjs";
18
+ 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-DocgD9K0.mjs";
19
+ 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-DU9tRFTZ.mjs";
20
+ 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-Tx15HGAD.mjs";
21
+ import { Nip21Error, NostrURI, isNostrURI, parseNostrURI } from "./nips/nip21.mjs";
20
22
  import { ReplyTagsOptions, ThreadReferences, buildReplyTags, parseThreadTags, replyTo } from "./nips/nip10.mjs";
21
23
  import { isAuthRequired, makeAuthEvent } from "./nips/nip42.mjs";
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-q4MDce_r.mjs";
23
- import { a as IndexedDbEventStoreOptions, i as IndexedDbEventStore, n as SqlValue, o as MemoryEventStore, r as SqliteEventStore, t as SqlDriver } from "./index-D1bqFHKB.mjs";
24
- export { type AddressPointer, Bech32MaxSize, Client, ClientBuilder, ClientError, type ClientMessage, type ClientOptions, type CountResult, CryptoError, type DecodedResult, EVENT_ID_BYTES, type Event, type EventAddress, EventBuilder, type EventPointer, type EventStore, type EventTemplate, EventValidationError, 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 MutedEntity, type NAddr, type NEvent, type NProfile, type NPub, type NSec, type NegentropyItem, Nip07Signer, Nip19Error, Nip46Signer, type Nip46SignerOptions, type Nip46SubscribeOptions, type Nip46Transport, NoSignerError, NostrError, type NostrSigner, type NostrUser, type Note, type OutboxBound, OutboxError, OutboxFeed, type OutboxFeedOptions, PUBLIC_KEY_BYTES, Pool, type PoolCountResult, type PoolFetchResult, type PoolOptions, type PoolPublishResult, type PoolSubscribeOptions, type PrivateMessageSendResult, type ProfileMetadata, type ProfilePointer, type PubkeyRoutes, type PublicKey, type PublishResult, type PutResult, ReactiveEventStore, type ReactiveEventStoreOptions, type ReceivedPrivateMessage, Relay, RelayClosedError, RelayConnectionError, RelayError, type RelayFetchEnd, type RelayFetchResult, type RelayListItem, type RelayMarker, type RelayMessage, type RelayOptions, RelayPublishError, RelayStatus, type RelayStatusName, RelaySuspendedError, RelayTimeoutError, type ReplaceableLoadResult, type ReplaceableLoader, type ReplyTagsOptions, type RoutedFilter, SECRET_KEY_BYTES, SIGNATURE_BYTES, SUBSCRIPTION_ID_MAX_CHARS, SecretKey, 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, WasmVerifyPoisonedError, type Watch, type WindowNostr, assertSubscriptionId, bareNostrUser, buildReplyTags, bytesToHex, canonicalizeFilter, canonicalizeFilters, classifyKind, createEventVerifier, createLoaders, createOutboxFeed, createSubscriptionId, decodeNostrURI, encodeClientMessage, encodeRelayMessage, eventAddress, filterFingerprint, finalizeEvent, formatEventAddress, getDTag, getEventHash, getFilterLimit, getPublicKey, getWindowNostr, groupAuthorsByOutboxRelay, hexToBytes, isAddressableKind, isAuthRequired, isEphemeralKind, isHex32, isHex64, isInsecureRelayUrl, isNip07Available, isRegularKind, isReplaceableKind, isReplaceableWinner, isTag, itemCompare, makeAuthEvent, markerOf, matchFilter, matchFilters, mergeCountHll, mergeFilters, naddrEncode, neventEncode, decode as nip19Decode, normalizeURL, noteEncode, nprofileEncode, npubEncode, nsecEncode, parseClientMessage, parseEventAddress, parseRelayList, parseRelayMessage, parseThreadTags, publicKeyFromHex, readRelays, relayListEventBuilder, relayListToTags, replyTo, serializeEvent, signEvent, signedMatchesUnsigned, sortEvents, sortedEvents, tagName, tagValue, useWebSocketImplementation, validateEvent, validateSignedEvent, verifyEvent, writeRelays };
24
+ import { a as isInsecureRelayUrl, c as RelayError, d as RelayTimeoutError, l as RelayPublishError, o as RelayClosedError, s as RelayConnectionError, u as RelaySuspendedError } from "./index-DiXwNn2M.mjs";
25
+ import { a as IndexedDbEventStoreOptions, i as IndexedDbEventStore, n as SqlValue, o as MemoryEventStore, r as SqliteEventStore, t as SqlDriver } from "./index-InQZpHyQ.mjs";
26
+ 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 PoolFetchResult, type PoolOptions, type PoolPublishResult, type PoolSubscribeOptions, type PrivateMessageSendResult, type ProfileMetadata, type ProfilePointer, type PubkeyRoutes, type PublicKey, type PublishResult, type PutResult, ReactiveEventStore, 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, mergeFilters, naddrEncode, neventEncode, decode as nip19Decode, normalizeURL, noteEncode, nprofileEncode, npubEncode, nsecEncode, parseClientMessage, parseEventAddress, parseNostrURI, parseRelayList, parseRelayMessage, parseThreadTags, publicKeyFromHex, readRelays, relayListEventBuilder, relayListToTags, replyTo, serializeEvent, signEvent, signedMatchesUnsigned, sortEvents, sortedEvents, tagName, tagValue, toSecretKey, useWebSocketImplementation, validateEvent, validateSignedEvent, verifyEvent, writeRelays };
package/dist/index.mjs CHANGED
@@ -1,25 +1,27 @@
1
- import { C as SUBSCRIPTION_ID_MAX_CHARS, S as SIGNATURE_BYTES, _ as UrlError, a as hexToBytes, b as PUBLIC_KEY_BYTES, f as CryptoError, g as NostrError, h as MessageError, i as bytesToHex, l as normalizeURL, m as HexError, o as isHex32, p as EventValidationError, s as isHex64, v as WasmVerifyPoisonedError, x as SECRET_KEY_BYTES, y as EVENT_ID_BYTES } from "./util-LfQirgDk.mjs";
1
+ import { C as PUBLIC_KEY_BYTES, E as SUBSCRIPTION_ID_MAX_CHARS, S as EVENT_ID_BYTES, T as SIGNATURE_BYTES, _ as MessageError, a as hexToBytes, b as WasmPoisonedError, g as HexError, h as EventValidationError, i as bytesToHex, m as CryptoError, o as isHex32, s as isHex64, u as normalizeURL, v as NostrError, w as SECRET_KEY_BYTES, y as UrlError } from "./util-yFYzlbrm.mjs";
2
2
  import { a as isRegularKind, i as isEphemeralKind, n as classifyKind, o as isReplaceableKind, r as isAddressableKind, t as Kind } from "./kind-Cxwhhkx8.mjs";
3
- import { S as tagValue, _ as formatEventAddress, a as isReplaceableWinner, b as parseEventAddress, d as sortEvents, f as sortedEvents, g as eventAddress, h as Tag, l as serializeEvent, m as validateSignedEvent, n as getEventHash, o as itemCompare, p as validateEvent, u as signedMatchesUnsigned, v as getDTag, x as tagName, y as isTag } from "./event-D8Nfoh4K.mjs";
4
- import { a as publicKeyFromHex, i as getPublicKey, n as SecretKey, o as signEvent, r as finalizeEvent, t as Keys } from "./key-Bps-LqX7.mjs";
5
- import { n as verifyEvent, t as createEventVerifier } from "./verifier-t5WoWbtY.mjs";
6
- import { t as EventBuilder } from "./builder-9tjI6WQ3.mjs";
3
+ import { C as tagValue, S as tagName, a as isReplaceableWinner, b as isTag, d as sortEvents, f as sortedEvents, g as eventAddress, h as Tag, l as serializeEvent, m as validateSignedEvent, n as getEventHash, o as itemCompare, p as validateEvent, u as signedMatchesUnsigned, v as formatEventAddress, x as parseEventAddress, y as getDTag } from "./event-DinQMmJ1.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-bshqfmZL.mjs";
5
+ import { n as verifyEvent, t as createEventVerifier } from "./verifier-BTLOpo1n.mjs";
6
+ import { t as EventBuilder } from "./builder-CdLE4J6O.mjs";
7
7
  import { a as matchFilter, i as getFilterLimit, n as canonicalizeFilters, o as matchFilters, r as filterFingerprint, s as mergeFilters, t as canonicalizeFilter } from "./filter-BQl3GlHt.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-DcY6Fi9o.mjs";
9
- import { t as NoSignerError } from "./error-B__OMBRY.mjs";
10
- import { a as KeysSigner, i as isNip07Available, n as Nip07Signer, r as getWindowNostr, t as Nip46Signer } from "./signer-CYQutDzD.mjs";
11
- import { Bech32MaxSize, Nip19Error, decode, decodeNostrURI, naddrEncode, neventEncode, noteEncode, nprofileEncode, npubEncode, nsecEncode } from "./nips/nip19.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-CWLcFTQ1.mjs";
9
+ import { t as NoSignerError } from "./error-gtJvV6YS.mjs";
10
+ import { a as KeysSigner, i as isNip07Available, n as Nip07Signer, r as getWindowNostr, t as Nip46Signer } from "./signer-yW3slDC2.mjs";
11
+ import { Bech32MaxSize, Nip19Error, decode, naddrEncode, neventEncode, noteEncode, nprofileEncode, npubEncode, nsecEncode } from "./nips/nip19.mjs";
12
+ import { Nip21Error, isNostrURI, parseNostrURI } from "./nips/nip21.mjs";
12
13
  import { buildReplyTags, parseThreadTags, replyTo } from "./nips/nip10.mjs";
13
14
  import { isAuthRequired, makeAuthEvent } from "./nips/nip42.mjs";
14
- import { markerOf, parseRelayList, readRelays, relayListEventBuilder, relayListToTags, writeRelays } from "./nips/nip65.mjs";
15
- import { a as RelayStatus, c as isInsecureRelayUrl, d as RelayClosedError, f as RelayConnectionError, g as RelayTimeoutError, h as RelaySuspendedError, i as Relay, m as RelayPublishError, p as RelayError, t as Pool, u as useWebSocketImplementation } from "./pool-As20OGxB.mjs";
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-CvxPiQ_m.mjs";
17
+ import { i as isInsecureRelayUrl, t as Pool } from "./pool-YHRZgcQ3.mjs";
16
18
  import "./relay.mjs";
17
- import { t as Gossip } from "./gossip-oloDMWEj.mjs";
18
- import { a as groupAuthorsByOutboxRelay, i as createOutboxFeed, n as OutboxError, o as bareNostrUser, r as OutboxFeed, t as createLoaders } from "./loaders-o6YXB_Ri.mjs";
19
- import { t as StorageError } from "./error-DrEIM7FO.mjs";
20
- import { t as MemoryEventStore } from "./memory-C2EVx0_O.mjs";
21
- import { t as ReactiveEventStore } from "./reactive-BfhPp9a3.mjs";
22
- import { i as ClientBuilder, n as ClientError, r as SyncDirection, t as Client } from "./client-CadO5fAX.mjs";
23
- import { n as IndexedDbEventStore, t as SqliteEventStore } from "./storage-Dky3wuoH.mjs";
19
+ import { t as Gossip } from "./gossip-CcTp9VpU.mjs";
20
+ import { a as bareNostrUser, i as groupAuthorsByOutboxRelay, n as OutboxError, r as OutboxFeed, t as createLoaders } from "./loaders-DD0XAGzw.mjs";
21
+ import { t as StorageError } from "./error-L_QdmSnV.mjs";
22
+ import { t as MemoryEventStore } from "./memory-D_-5-T31.mjs";
23
+ import { t as ReactiveEventStore } from "./reactive-BJRoVHxU.mjs";
24
+ import { n as ClientError, r as SyncDirection, t as Client } from "./client-CILhdfsF.mjs";
25
+ import { n as IndexedDbEventStore, t as SqliteEventStore } from "./storage-CZ52ifcQ.mjs";
24
26
  import "./store.mjs";
25
- export { Bech32MaxSize, Client, ClientBuilder, ClientError, CryptoError, EVENT_ID_BYTES, EventBuilder, EventValidationError, Gossip, HexError, IndexedDbEventStore, Keys, KeysSigner, Kind, MemoryEventStore, MessageError, Nip07Signer, Nip19Error, 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, WasmVerifyPoisonedError, assertSubscriptionId, bareNostrUser, buildReplyTags, bytesToHex, canonicalizeFilter, canonicalizeFilters, classifyKind, createEventVerifier, createLoaders, createOutboxFeed, createSubscriptionId, decodeNostrURI, encodeClientMessage, encodeRelayMessage, eventAddress, filterFingerprint, finalizeEvent, formatEventAddress, getDTag, getEventHash, getFilterLimit, getPublicKey, getWindowNostr, groupAuthorsByOutboxRelay, hexToBytes, isAddressableKind, isAuthRequired, isEphemeralKind, isHex32, isHex64, isInsecureRelayUrl, isNip07Available, isRegularKind, isReplaceableKind, isReplaceableWinner, isTag, itemCompare, makeAuthEvent, markerOf, matchFilter, matchFilters, mergeCountHll, mergeFilters, naddrEncode, neventEncode, decode as nip19Decode, normalizeURL, noteEncode, nprofileEncode, npubEncode, nsecEncode, parseClientMessage, parseEventAddress, parseRelayList, parseRelayMessage, parseThreadTags, publicKeyFromHex, readRelays, relayListEventBuilder, relayListToTags, replyTo, serializeEvent, signEvent, signedMatchesUnsigned, sortEvents, sortedEvents, tagName, tagValue, useWebSocketImplementation, validateEvent, validateSignedEvent, verifyEvent, writeRelays };
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, mergeFilters, naddrEncode, neventEncode, decode as nip19Decode, normalizeURL, noteEncode, nprofileEncode, npubEncode, nsecEncode, parseClientMessage, parseEventAddress, parseNostrURI, parseRelayList, parseRelayMessage, parseThreadTags, publicKeyFromHex, readRelays, relayListEventBuilder, relayListToTags, replyTo, serializeEvent, signEvent, signedMatchesUnsigned, sortEvents, sortedEvents, tagName, tagValue, toSecretKey, useWebSocketImplementation, validateEvent, validateSignedEvent, verifyEvent, writeRelays };
@@ -1,5 +1,5 @@
1
- import { f as CryptoError, v as WasmVerifyPoisonedError } from "./util-LfQirgDk.mjs";
2
- import { t as createEventVerifier } from "./verifier-t5WoWbtY.mjs";
1
+ import { b as WasmPoisonedError, m as CryptoError } from "./util-yFYzlbrm.mjs";
2
+ import { t as createEventVerifier } from "./verifier-BTLOpo1n.mjs";
3
3
  //#region src/wasm/abi.ts
4
4
  /** Imports 0.2.122 may request. Instantiation fails if anything else appears. */
5
5
  const ALLOWED_WASM_IMPORTS = [{
@@ -121,21 +121,32 @@ async function instantiateCryptoWasm(bytes) {
121
121
  //#endregion
122
122
  //#region src/wasm/adapter.ts
123
123
  /**
124
+ * Run `fn` unless the instance is already poisoned; a `WebAssembly.RuntimeError` aborts the
125
+ * instance, so it is converted to {@link WasmPoisonedError} and rethrown on every later call.
126
+ */
127
+ function runPoisoned(poison, fn) {
128
+ if (poison.error !== void 0) throw poison.error;
129
+ try {
130
+ return fn();
131
+ } catch (error) {
132
+ if (error instanceof WebAssembly.RuntimeError) {
133
+ poison.error = new WasmPoisonedError("wasm instance aborted", { cause: error });
134
+ throw poison.error;
135
+ }
136
+ throw error;
137
+ }
138
+ }
139
+ /**
124
140
  * Build the WASM event verifier on {@link createEventVerifier}. A `WebAssembly.RuntimeError` from
125
141
  * the module means the instance aborted — it poisons every later call with the same
126
- * `WasmVerifyPoisonedError`; any other backend error verifies `false` (the event is marked
127
- * failed).
142
+ * `WasmPoisonedError`; any other backend error verifies `false` (the event is marked failed).
128
143
  */
129
144
  function createWasmEventVerifier(verifySerialized, poison) {
130
145
  const backend = (serializedUtf8, id, pubkey, sig) => {
131
- if (poison.error !== void 0) throw poison.error;
132
146
  try {
133
- return verifySerialized(serializedUtf8, id, pubkey, sig);
147
+ return runPoisoned(poison, () => verifySerialized(serializedUtf8, id, pubkey, sig));
134
148
  } catch (error) {
135
- if (error instanceof WebAssembly.RuntimeError) {
136
- poison.error = new WasmVerifyPoisonedError("wasm verify aborted the instance", { cause: error });
137
- throw poison.error;
138
- }
149
+ if (error instanceof WasmPoisonedError) throw error;
139
150
  return false;
140
151
  }
141
152
  };
@@ -154,26 +165,14 @@ async function fetchWasmUrl(url) {
154
165
  function requireByteLength(bytes, expected, label) {
155
166
  if (bytes.length !== expected) throw new CryptoError(`invalid ${label} length: expected ${expected}, got ${bytes.length}`);
156
167
  }
157
- function wrapPoison(poison, fn) {
158
- if (poison.error) throw poison.error;
159
- try {
160
- return fn();
161
- } catch (error) {
162
- if (error instanceof WebAssembly.RuntimeError) {
163
- poison.error = new WasmVerifyPoisonedError("wasm verify aborted the instance", { cause: error });
164
- throw poison.error;
165
- }
166
- throw error;
167
- }
168
- }
169
168
  function bindExports(exports) {
170
169
  const poison = {};
171
170
  const rawSerialized = (serializedUtf8, id, pubkey, sig) => wasmVerifySerialized(exports, serializedUtf8, id, pubkey, sig);
172
171
  return {
173
- verify: (id, pubkey, sig) => wrapPoison(poison, () => wasmVerify(exports, id, pubkey, sig)),
174
- verifySerialized: (serializedUtf8, id, pubkey, sig) => wrapPoison(poison, () => rawSerialized(serializedUtf8, id, pubkey, sig)),
172
+ verify: (id, pubkey, sig) => runPoisoned(poison, () => wasmVerify(exports, id, pubkey, sig)),
173
+ verifySerialized: (serializedUtf8, id, pubkey, sig) => runPoisoned(poison, () => rawSerialized(serializedUtf8, id, pubkey, sig)),
175
174
  verifyEvent: createWasmEventVerifier(rawSerialized, poison),
176
- sign: (id, seckey, aux) => wrapPoison(poison, () => {
175
+ sign: (id, seckey, aux) => runPoisoned(poison, () => {
177
176
  requireByteLength(id, 32, "id");
178
177
  requireByteLength(seckey, 32, "secret key");
179
178
  requireByteLength(aux, 32, "aux");
@@ -181,7 +180,7 @@ function bindExports(exports) {
181
180
  if (sig.length !== 64) throw new CryptoError("wasm sign failed");
182
181
  return sig;
183
182
  }),
184
- publicKey: (seckey) => wrapPoison(poison, () => {
183
+ publicKey: (seckey) => runPoisoned(poison, () => {
185
184
  requireByteLength(seckey, 32, "secret key");
186
185
  const pk = wasmPublicKey(exports, seckey);
187
186
  if (pk.length !== 32) throw new CryptoError("wasm publicKey failed");
@@ -218,4 +217,4 @@ function createNostrWasmLoader(wasmBytes) {
218
217
  //#endregion
219
218
  export { fetchWasmUrl as n, isWasmBytes as r, createNostrWasmLoader as t };
220
219
 
221
- //# sourceMappingURL=instance-DQE8BoWt.mjs.map
220
+ //# sourceMappingURL=instance-BcKzxHIP.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instance-BcKzxHIP.mjs","names":[],"sources":["../src/wasm/abi.ts","../src/wasm/adapter.ts","../src/wasm/instance.ts"],"sourcesContent":["/** Wasm-bindgen 0.2.122 bundler-produced exports used by interned TS glue. */\nexport type CryptoWasmExports = {\n memory: WebAssembly.Memory;\n verify: (\n idPtr: number,\n idLen: number,\n pkPtr: number,\n pkLen: number,\n sigPtr: number,\n sigLen: number,\n ) => number;\n verify_serialized: (\n serPtr: number,\n serLen: number,\n idPtr: number,\n idLen: number,\n pkPtr: number,\n pkLen: number,\n sigPtr: number,\n sigLen: number,\n ) => number;\n sign: (\n retptr: number,\n idPtr: number,\n idLen: number,\n skPtr: number,\n skLen: number,\n auxPtr: number,\n auxLen: number,\n ) => void;\n public_key: (retptr: number, skPtr: number, skLen: number) => void;\n /** 0.2.122 name for `__wbindgen_malloc(size, align)`. */\n __wbindgen_export: (size: number, align: number) => number;\n /** 0.2.122 name for `__wbindgen_free(ptr, size, align)` after malloc claimed `__wbindgen_export`. */\n __wbindgen_export2: (ptr: number, size: number, align: number) => void;\n __wbindgen_add_to_stack_pointer: (delta: number) => number;\n __wbindgen_start?: () => void;\n};\n\n/** Imports 0.2.122 may request. Instantiation fails if anything else appears. */\nexport const ALLOWED_WASM_IMPORTS: ReadonlyArray<{ module: string; name: string }> = [\n { module: \"wbg\", name: \"__wbindgen_throw\" },\n { module: \"./nostr_crypto_wasm_bg.js\", name: \"__wbindgen_throw\" },\n];\n\nconst utf8 = new TextDecoder();\n\nfunction decodeUtf8(memory: WebAssembly.Memory, ptr: number, len: number): string {\n return utf8.decode(new Uint8Array(memory.buffer, ptr, len));\n}\n\nfunction makeWbgImports(holder: { exports?: CryptoWasmExports }): WebAssembly.Imports {\n const throwRuntime = (ptr: number, len: number): never => {\n const mem = holder.exports?.memory;\n const msg = mem ? decodeUtf8(mem, ptr, len) : \"wasm panic\";\n throw new WebAssembly.RuntimeError(msg);\n };\n const wbg = {\n __wbindgen_throw: throwRuntime,\n };\n return {\n wbg,\n \"./nostr_crypto_wasm_bg.js\": wbg,\n };\n}\n\n/** Fail if the module imports anything outside {@link ALLOWED_WASM_IMPORTS}. */\nexport function assertAllowedWasmImports(mod: WebAssembly.Module): void {\n const allowed = new Set(ALLOWED_WASM_IMPORTS.map((item) => `${item.module}\\0${item.name}`));\n for (const imp of WebAssembly.Module.imports(mod)) {\n if (imp.kind !== \"function\") {\n throw new TypeError(`unexpected wasm import kind ${imp.kind}: ${imp.module}.${imp.name}`);\n }\n if (!allowed.has(`${imp.module}\\0${imp.name}`)) {\n throw new TypeError(`unexpected wasm import ${imp.module}.${imp.name}`);\n }\n }\n}\n\nfunction requireMemory(value: WebAssembly.ExportValue | undefined): WebAssembly.Memory {\n if (!(value instanceof WebAssembly.Memory)) {\n throw new TypeError(\"wasm missing memory export\");\n }\n return value;\n}\n\n// oxlint-disable-next-line no-unnecessary-type-parameters -- T binds the declared ABI signature at each call site\nfunction requireFn<T extends (...args: number[]) => unknown>(\n value: WebAssembly.ExportValue | undefined,\n name: string,\n): T {\n if (typeof value !== \"function\") {\n throw new TypeError(`wasm missing ${name} export`);\n }\n // oxlint-disable-next-line no-unsafe-type-assertion -- wasm exports are opaque; each name is bound to the signature the ABI contract requires\n return value as T;\n}\n\nfunction asExports(raw: WebAssembly.Exports): CryptoWasmExports {\n const exports: CryptoWasmExports = {\n memory: requireMemory(raw[\"memory\"]),\n verify: requireFn(raw[\"verify\"], \"verify\"),\n verify_serialized: requireFn(raw[\"verify_serialized\"], \"verify_serialized\"),\n sign: requireFn(raw[\"sign\"], \"sign\"),\n public_key: requireFn(raw[\"public_key\"], \"public_key\"),\n __wbindgen_export: requireFn(raw[\"__wbindgen_export\"], \"__wbindgen_export\"),\n __wbindgen_export2: requireFn(raw[\"__wbindgen_export2\"], \"__wbindgen_export2\"),\n __wbindgen_add_to_stack_pointer: requireFn(\n raw[\"__wbindgen_add_to_stack_pointer\"],\n \"__wbindgen_add_to_stack_pointer\",\n ),\n };\n const start = raw[\"__wbindgen_start\"];\n if (typeof start === \"function\") {\n exports.__wbindgen_start = requireFn<() => void>(start, \"__wbindgen_start\");\n }\n return exports;\n}\n\nfunction passBytes(exports: CryptoWasmExports, bytes: Uint8Array): { ptr: number; len: number } {\n const len = bytes.length;\n const ptr = exports.__wbindgen_export(len, 1) >>> 0;\n new Uint8Array(exports.memory.buffer, ptr, len).set(bytes);\n return { ptr, len };\n}\n\nexport function wasmVerify(\n exports: CryptoWasmExports,\n id: Uint8Array,\n pubkey: Uint8Array,\n sig: Uint8Array,\n): boolean {\n const idP = passBytes(exports, id);\n const pkP = passBytes(exports, pubkey);\n const sigP = passBytes(exports, sig);\n return exports.verify(idP.ptr, idP.len, pkP.ptr, pkP.len, sigP.ptr, sigP.len) !== 0;\n}\n\nexport function wasmVerifySerialized(\n exports: CryptoWasmExports,\n serialized: Uint8Array,\n id: Uint8Array,\n pubkey: Uint8Array,\n sig: Uint8Array,\n): boolean {\n const serP = passBytes(exports, serialized);\n const idP = passBytes(exports, id);\n const pkP = passBytes(exports, pubkey);\n const sigP = passBytes(exports, sig);\n return (\n exports.verify_serialized(\n serP.ptr,\n serP.len,\n idP.ptr,\n idP.len,\n pkP.ptr,\n pkP.len,\n sigP.ptr,\n sigP.len,\n ) !== 0\n );\n}\n\nfunction takeBytes(exports: CryptoWasmExports, ptr: number, len: number): Uint8Array {\n const out = new Uint8Array(len);\n if (len > 0) {\n out.set(new Uint8Array(exports.memory.buffer, ptr, len));\n exports.__wbindgen_export2(ptr, len, 1);\n }\n return out;\n}\n\nfunction callReturningBytes(\n exports: CryptoWasmExports,\n invoke: (retptr: number) => void,\n): Uint8Array {\n const retptr = exports.__wbindgen_add_to_stack_pointer(-16);\n try {\n invoke(retptr);\n const view = new DataView(exports.memory.buffer);\n const ptr = view.getUint32(retptr, true);\n const len = view.getUint32(retptr + 4, true);\n return takeBytes(exports, ptr, len);\n } finally {\n exports.__wbindgen_add_to_stack_pointer(16);\n }\n}\n\nexport function wasmSign(\n exports: CryptoWasmExports,\n id: Uint8Array,\n seckey: Uint8Array,\n aux: Uint8Array,\n): Uint8Array {\n const idP = passBytes(exports, id);\n const skP = passBytes(exports, seckey);\n const auxP = passBytes(exports, aux);\n return callReturningBytes(exports, (retptr) => {\n exports.sign(retptr, idP.ptr, idP.len, skP.ptr, skP.len, auxP.ptr, auxP.len);\n });\n}\n\nexport function wasmPublicKey(exports: CryptoWasmExports, seckey: Uint8Array): Uint8Array {\n const skP = passBytes(exports, seckey);\n return callReturningBytes(exports, (retptr) => {\n exports.public_key(retptr, skP.ptr, skP.len);\n });\n}\n\nexport async function instantiateCryptoWasm(\n bytes: ArrayBuffer | ArrayBufferView,\n): Promise<CryptoWasmExports> {\n const holder: { exports?: CryptoWasmExports } = {};\n const { module, instance } = await WebAssembly.instantiate(bytes, makeWbgImports(holder));\n assertAllowedWasmImports(module);\n holder.exports = asExports(instance.exports);\n holder.exports.__wbindgen_start?.();\n return holder.exports;\n}\n","import { WasmPoisonedError } from \"../core/error.ts\";\nimport { createEventVerifier } from \"../core/verifier.ts\";\nimport type { EventVerifier, SerializedEventVerifier } from \"../core/verifier.ts\";\n\nexport { WasmPoisonedError } from \"../core/error.ts\";\n\n/**\n * Run `fn` unless the instance is already poisoned; a `WebAssembly.RuntimeError` aborts the\n * instance, so it is converted to {@link WasmPoisonedError} and rethrown on every later call.\n */\nexport function runPoisoned<T>(poison: { error?: Error }, fn: () => T): T {\n if (poison.error !== undefined) {\n throw poison.error;\n }\n try {\n return fn();\n } catch (error) {\n if (error instanceof WebAssembly.RuntimeError) {\n poison.error = new WasmPoisonedError(\"wasm instance aborted\", {\n cause: error,\n });\n throw poison.error;\n }\n throw error;\n }\n}\n\n/**\n * Build the WASM event verifier on {@link createEventVerifier}. A `WebAssembly.RuntimeError` from\n * the module means the instance aborted — it poisons every later call with the same\n * `WasmPoisonedError`; any other backend error verifies `false` (the event is marked failed).\n */\nexport function createWasmEventVerifier(\n verifySerialized: SerializedEventVerifier,\n poison: { error?: Error },\n): EventVerifier {\n const backend: SerializedEventVerifier = (serializedUtf8, id, pubkey, sig) => {\n try {\n return runPoisoned(poison, () => verifySerialized(serializedUtf8, id, pubkey, sig));\n } catch (error) {\n if (error instanceof WasmPoisonedError) {\n throw error;\n }\n return false;\n }\n };\n return createEventVerifier(backend);\n}\n","import { CryptoError } from \"../core/error.ts\";\nimport type { SigningBackend } from \"../core/key.ts\";\nimport type { EventVerifier } from \"../core/verifier.ts\";\nimport {\n instantiateCryptoWasm,\n wasmPublicKey,\n wasmSign,\n wasmVerify,\n wasmVerifySerialized,\n} from \"./abi.ts\";\nimport type { CryptoWasmExports } from \"./abi.ts\";\nimport { createWasmEventVerifier, runPoisoned } from \"./adapter.ts\";\n\nexport type LoadNostrWasmOptions = {\n /** Bytes, or a URL whose bytes will be read by the platform loader. */\n module?: ArrayBuffer | ArrayBufferView | URL | undefined;\n};\n\nexport type NostrWasm = SigningBackend & {\n verify: (id: Uint8Array, pubkey: Uint8Array, sig: Uint8Array) => boolean;\n verifySerialized: (\n serializedUtf8: Uint8Array,\n id: Uint8Array,\n pubkey: Uint8Array,\n sig: Uint8Array,\n ) => boolean;\n verifyEvent: EventVerifier;\n};\n\nexport function isWasmBytes(value: unknown): value is ArrayBuffer | ArrayBufferView {\n return value instanceof ArrayBuffer || ArrayBuffer.isView(value);\n}\n\nexport async function fetchWasmUrl(url: URL): Promise<Uint8Array> {\n const res = await fetch(url);\n if (!res.ok) {\n throw new CryptoError(`failed to fetch wasm: ${res.status} ${url.href}`);\n }\n return new Uint8Array(await res.arrayBuffer());\n}\n\nfunction requireByteLength(bytes: Uint8Array, expected: number, label: string): void {\n if (bytes.length !== expected) {\n throw new CryptoError(`invalid ${label} length: expected ${expected}, got ${bytes.length}`);\n }\n}\n\nfunction bindExports(exports: CryptoWasmExports): NostrWasm {\n const poison: { error?: Error } = {};\n const rawSerialized = (\n serializedUtf8: Uint8Array,\n id: Uint8Array,\n pubkey: Uint8Array,\n sig: Uint8Array,\n ): boolean => wasmVerifySerialized(exports, serializedUtf8, id, pubkey, sig);\n return {\n verify: (id, pubkey, sig) => runPoisoned(poison, () => wasmVerify(exports, id, pubkey, sig)),\n verifySerialized: (serializedUtf8, id, pubkey, sig) =>\n runPoisoned(poison, () => rawSerialized(serializedUtf8, id, pubkey, sig)),\n verifyEvent: createWasmEventVerifier(rawSerialized, poison),\n sign: (id, seckey, aux) =>\n runPoisoned(poison, () => {\n requireByteLength(id, 32, \"id\");\n requireByteLength(seckey, 32, \"secret key\");\n requireByteLength(aux, 32, \"aux\");\n const sig = wasmSign(exports, id, seckey, aux);\n if (sig.length !== 64) {\n throw new CryptoError(\"wasm sign failed\");\n }\n return sig;\n }),\n publicKey: (seckey) =>\n runPoisoned(poison, () => {\n requireByteLength(seckey, 32, \"secret key\");\n const pk = wasmPublicKey(exports, seckey);\n if (pk.length !== 32) {\n throw new CryptoError(\"wasm publicKey failed\");\n }\n return pk;\n }),\n };\n}\n\n/** Builds a loader that interns a single instance per module slot. */\nexport function createNostrWasmLoader(\n wasmBytes: (opts?: LoadNostrWasmOptions) => Promise<ArrayBuffer | ArrayBufferView>,\n): {\n loadNostrWasm: (opts?: LoadNostrWasmOptions) => Promise<NostrWasm>;\n resetNostrWasm: () => void;\n} {\n let interned: Promise<NostrWasm> | undefined;\n\n async function instantiate(opts?: LoadNostrWasmOptions): Promise<NostrWasm> {\n const bytes = await wasmBytes(opts);\n const exports = await instantiateCryptoWasm(bytes);\n return bindExports(exports);\n }\n\n /** Instantiate once. Repeats reuse the same module. Failure throws; no noble fallback. */\n async function loadNostrWasm(opts?: LoadNostrWasmOptions): Promise<NostrWasm> {\n if (interned) {\n return interned;\n }\n const pending = instantiate(opts);\n interned = pending;\n try {\n return await pending;\n } catch (error) {\n if (interned === pending) {\n interned = undefined;\n }\n throw error;\n }\n }\n\n function resetNostrWasm(): void {\n interned = undefined;\n }\n\n return { loadNostrWasm, resetNostrWasm };\n}\n"],"mappings":";;;;AAwCA,MAAa,uBAAwE,CACnF;CAAE,QAAQ;CAAO,MAAM;AAAmB,GAC1C;CAAE,QAAQ;CAA6B,MAAM;AAAmB,CAClE;AAEA,MAAM,OAAO,IAAI,YAAY;AAE7B,SAAS,WAAW,QAA4B,KAAa,KAAqB;CAChF,OAAO,KAAK,OAAO,IAAI,WAAW,OAAO,QAAQ,KAAK,GAAG,CAAC;AAC5D;AAEA,SAAS,eAAe,QAA8D;CACpF,MAAM,gBAAgB,KAAa,QAAuB;EACxD,MAAM,MAAM,OAAO,SAAS;EAC5B,MAAM,MAAM,MAAM,WAAW,KAAK,KAAK,GAAG,IAAI;EAC9C,MAAM,IAAI,YAAY,aAAa,GAAG;CACxC;CACA,MAAM,MAAM,EACV,kBAAkB,aACpB;CACA,OAAO;EACL;EACA,6BAA6B;CAC/B;AACF;;AAGA,SAAgB,yBAAyB,KAA+B;CACtE,MAAM,UAAU,IAAI,IAAI,qBAAqB,KAAK,SAAS,GAAG,KAAK,OAAO,IAAI,KAAK,MAAM,CAAC;CAC1F,KAAK,MAAM,OAAO,YAAY,OAAO,QAAQ,GAAG,GAAG;EACjD,IAAI,IAAI,SAAS,YACf,MAAM,IAAI,UAAU,+BAA+B,IAAI,KAAK,IAAI,IAAI,OAAO,GAAG,IAAI,MAAM;EAE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ACf,WAAW,KAAA;GAEb,MAAM;EACR;CACF;CAEA,SAAS,iBAAuB;EAC9B,WAAW,KAAA;CACb;CAEA,OAAO;EAAE;EAAe;CAAe;AACzC"}
@@ -1,15 +1,15 @@
1
- import { t as Event } from "./event-fU3Y01PR.mjs";
2
- import { i as SigningBackend } from "./key-Cv4_pN3x.mjs";
1
+ import { a as SigningBackend } from "./key-D_5OgGT7.mjs";
2
+ import { t as EventVerifier } from "./verifier-CgTFpgsC.mjs";
3
3
  //#region src/wasm/instance.d.ts
4
4
  type LoadNostrWasmOptions = {
5
5
  /** Bytes, or a URL whose bytes will be read by the platform loader. */
6
- module?: ArrayBuffer | ArrayBufferView | URL;
6
+ module?: ArrayBuffer | ArrayBufferView | URL | undefined;
7
7
  };
8
8
  type NostrWasm = SigningBackend & {
9
9
  verify: (id: Uint8Array, pubkey: Uint8Array, sig: Uint8Array) => boolean;
10
10
  verifySerialized: (serializedUtf8: Uint8Array, id: Uint8Array, pubkey: Uint8Array, sig: Uint8Array) => boolean;
11
- verifyEvent: (event: Event) => boolean;
11
+ verifyEvent: EventVerifier;
12
12
  };
13
13
  //#endregion
14
14
  export { NostrWasm as n, LoadNostrWasmOptions as t };
15
- //# sourceMappingURL=instance-CIca-ynn.d.mts.map
15
+ //# sourceMappingURL=instance-DjsL8h84.d.mts.map