chirli 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/ARCHITECTURE.md +18 -20
  2. package/CONTRIBUTING.md +7 -3
  3. package/README.md +63 -55
  4. package/SECURITY.md +11 -11
  5. package/dist/allowlist.d.ts +3 -0
  6. package/dist/allowlist.js +9 -0
  7. package/dist/announcements.d.ts +4 -4
  8. package/dist/announcements.js +66 -34
  9. package/dist/attachments.d.ts +43 -0
  10. package/dist/attachments.js +340 -0
  11. package/dist/blossom.d.ts +2 -2
  12. package/dist/blossom.js +120 -66
  13. package/dist/bot-handlers.d.ts +9 -18
  14. package/dist/bot-handlers.js +125 -66
  15. package/dist/bot.d.ts +17 -20
  16. package/dist/bot.js +150 -55
  17. package/dist/client.d.ts +43 -39
  18. package/dist/client.js +476 -290
  19. package/dist/command-discovery.d.ts +2 -2
  20. package/dist/command-discovery.js +16 -7
  21. package/dist/command-schema.d.ts +2 -2
  22. package/dist/command-schema.js +62 -31
  23. package/dist/commands.d.ts +7 -6
  24. package/dist/commands.js +116 -51
  25. package/dist/defaults.js +13 -6
  26. package/dist/errors.d.ts +12 -12
  27. package/dist/errors.js +55 -18
  28. package/dist/inbox.d.ts +9 -7
  29. package/dist/inbox.js +107 -62
  30. package/dist/index.d.ts +25 -24
  31. package/dist/index.js +11 -11
  32. package/dist/key-sync.d.ts +4 -4
  33. package/dist/key-sync.js +88 -50
  34. package/dist/keys.d.ts +7 -6
  35. package/dist/keys.js +187 -93
  36. package/dist/message-storage-sqlite.d.ts +1 -1
  37. package/dist/message-storage-sqlite.js +32 -27
  38. package/dist/message-storage.d.ts +2 -2
  39. package/dist/messaging-metadata.d.ts +4 -4
  40. package/dist/messaging-metadata.js +73 -46
  41. package/dist/metadata.d.ts +3 -3
  42. package/dist/metadata.js +29 -15
  43. package/dist/modes.d.ts +7 -7
  44. package/dist/modes.js +53 -24
  45. package/dist/nip4e-compat.d.ts +2 -2
  46. package/dist/nip4e-compat.js +2 -2
  47. package/dist/nipcd.d.ts +14 -14
  48. package/dist/nipcd.js +225 -126
  49. package/dist/protocol.d.ts +7 -6
  50. package/dist/protocol.js +101 -54
  51. package/dist/public-inbox.d.ts +17 -15
  52. package/dist/public-inbox.js +129 -138
  53. package/dist/public-thread.d.ts +7 -4
  54. package/dist/public-thread.js +205 -88
  55. package/dist/relay-pool.d.ts +5 -5
  56. package/dist/relay-pool.js +172 -67
  57. package/dist/relay-roles.js +22 -13
  58. package/dist/relay.d.ts +11 -11
  59. package/dist/relay.js +194 -100
  60. package/dist/request-timing.d.ts +2 -2
  61. package/dist/request-timing.js +19 -7
  62. package/dist/session.js +7 -5
  63. package/dist/signer.d.ts +1 -1
  64. package/dist/signers/bunker-relays.d.ts +2 -2
  65. package/dist/signers/bunker-relays.js +16 -13
  66. package/dist/signers/bunker.d.ts +2 -2
  67. package/dist/signers/bunker.js +57 -37
  68. package/dist/signers/nsec.d.ts +2 -2
  69. package/dist/signers/nsec.js +8 -8
  70. package/dist/signers.d.ts +8 -8
  71. package/dist/signers.js +25 -18
  72. package/dist/storage-sqlite.d.ts +3 -1
  73. package/dist/storage-sqlite.js +110 -58
  74. package/dist/storage.d.ts +10 -6
  75. package/dist/store.d.ts +12 -8
  76. package/dist/store.js +156 -78
  77. package/docs/ACCESS.md +14 -25
  78. package/docs/API.md +125 -79
  79. package/docs/KEYS.md +3 -3
  80. package/docs/NIP-CD.md +29 -19
  81. package/docs/PUBLIC.md +33 -23
  82. package/docs/RECOVERY.md +7 -5
  83. package/docs/RELAYS.md +6 -6
  84. package/docs/SESSIONS.md +25 -21
  85. package/docs/SIGNERS.md +5 -3
  86. package/docs/STORAGE.md +15 -15
  87. package/docs/TUTORIAL.md +42 -39
  88. package/package.json +1 -37
  89. package/dist/inbound-policy.d.ts +0 -4
  90. package/dist/inbound-policy.js +0 -9
package/dist/bot.js CHANGED
@@ -1,5 +1,5 @@
1
- import { Client } from './client.js';
2
- import { BotHandlers } from './bot-handlers.js';
1
+ import { Client, rejectRemovedIntakeOptions, } from "./client.js";
2
+ import { BotHandlers } from "./bot-handlers.js";
3
3
  export class Bot {
4
4
  #client;
5
5
  #opening;
@@ -11,9 +11,9 @@ export class Bot {
11
11
  #errorHandlers = new Set();
12
12
  #observers = new Set();
13
13
  #options;
14
- constructor({ sessionStore, ...options }) {
15
- if ('allowlist' in options)
16
- throw new TypeError('Use inboundPolicy: allowlist(pubkeys) for sender authorization');
14
+ constructor(input) {
15
+ rejectRemovedIntakeOptions(input);
16
+ const { sessionStore, ...options } = input;
17
17
  this.#options = {
18
18
  ...options,
19
19
  relays: options.relays?.slice(),
@@ -23,76 +23,121 @@ export class Bot {
23
23
  discoveryRelays: options.discoveryRelays?.slice(),
24
24
  blossomServers: options.blossomServers?.slice(),
25
25
  blossomDownloadOrigins: options.blossomDownloadOrigins?.slice(),
26
- publicInbox: options.publicInbox ? { ...options.publicInbox, relays: options.publicInbox.relays.slice(), thread: options.publicInbox.thread ? { ...options.publicInbox.thread } : undefined } : undefined,
26
+ publicInbox: options.publicInbox
27
+ ? {
28
+ ...options.publicInbox,
29
+ relays: options.publicInbox.relays.slice(),
30
+ thread: options.publicInbox.thread
31
+ ? { ...options.publicInbox.thread }
32
+ : undefined,
33
+ }
34
+ : undefined,
27
35
  storageKey: options.storageKey?.slice(),
28
36
  };
29
37
  this.#handlers = new BotHandlers(undefined, { sessionStore });
30
38
  }
31
39
  #ready() {
32
40
  if (!this.#client)
33
- throw new Error('Call and await bot.start() before accessing bot state');
41
+ throw new Error("Call and await bot.start() before accessing bot state");
34
42
  return this.#client;
35
43
  }
36
44
  #open() {
37
45
  if (this.#closing)
38
- return Promise.reject(new Error('Bot is closed or closing'));
46
+ return Promise.reject(new Error("Bot is closed or closing"));
39
47
  if (this.#client)
40
48
  return Promise.resolve(this.#client);
41
- return this.#opening ??= Client.create(this.#options).then(client => {
49
+ this.#opening ??= Client.create(this.#options)
50
+ .then((client) => {
42
51
  try {
43
52
  this.#handlers.attach(client);
44
53
  }
45
54
  catch (error) {
46
- return client.close().then(() => { throw error; });
55
+ return client.close().then(() => {
56
+ throw error;
57
+ });
47
58
  }
48
59
  client.onError((error, message) => {
49
60
  for (const handler of this.#errorHandlers) {
50
- void Promise.resolve().then(() => handler(error, message)).catch(() => { });
61
+ void Promise.resolve()
62
+ .then(() => handler(error, message))
63
+ .catch(() => { });
51
64
  }
52
65
  });
53
- client.on('message', message => {
66
+ client.on("message", (message) => {
54
67
  for (const observer of this.#observers) {
55
- void Promise.resolve().then(() => observer(structuredClone(message))).catch(error => client.report(error, structuredClone(message)));
68
+ void Promise.resolve()
69
+ .then(() => observer(client.withAttachment(structuredClone(message))))
70
+ .catch((error) => client.report(error, structuredClone(message)));
56
71
  }
57
72
  });
58
73
  this.#client = client;
59
74
  return client;
60
- }).finally(() => { this.#opening = undefined; });
75
+ })
76
+ .finally(() => {
77
+ this.#opening = undefined;
78
+ });
79
+ return this.#opening;
80
+ }
81
+ get pubkey() {
82
+ return this.#ready().pubkey;
83
+ }
84
+ get mode() {
85
+ return this.#options.mode ?? "nip17";
86
+ }
87
+ use(fn) {
88
+ this.#handlers.use(fn);
89
+ return this;
90
+ }
91
+ catch(fn) {
92
+ this.#handlers.catch(fn);
93
+ return this;
61
94
  }
62
- get pubkey() { return this.#ready().pubkey; }
63
- get mode() { return this.#options.mode ?? 'nip17'; }
64
- use(fn) { this.#handlers.use(fn); return this; }
65
- catch(fn) { this.#handlers.catch(fn); return this; }
66
95
  command(command, fn, options) {
67
96
  this.#handlers.command(command, fn, options);
68
97
  return this;
69
98
  }
70
- getCommandDefinitions() { return this.#handlers.getCommandDefinitions(); }
71
- handle(handler) { return this.#handlers.handle(handler); }
99
+ getCommandDefinitions() {
100
+ return this.#handlers.getCommandDefinitions();
101
+ }
102
+ handle(handler) {
103
+ return this.#handlers.handle(handler);
104
+ }
72
105
  observe(observer) {
73
106
  this.#observers.add(observer);
74
- return () => { this.#observers.delete(observer); };
107
+ return () => {
108
+ this.#observers.delete(observer);
109
+ };
75
110
  }
76
111
  onError(handler) {
77
112
  this.#errorHandlers.add(handler);
78
- return () => { this.#errorHandlers.delete(handler); };
113
+ return () => {
114
+ this.#errorHandlers.delete(handler);
115
+ };
79
116
  }
80
117
  start() {
81
118
  if (this.#closing)
82
- return Promise.reject(new Error('Bot is closed or closing'));
119
+ return Promise.reject(new Error("Bot is closed or closing"));
83
120
  if (this.#stopping)
84
121
  return this.#stopping.then(() => this.start());
85
122
  const generation = this.#generation;
86
- return this.#starting ??= this.#open().then(client => {
123
+ this.#starting ??= this.#open()
124
+ .then((client) => {
87
125
  if (this.#generation === generation)
88
126
  return client.start(true);
89
- }).finally(() => { this.#starting = undefined; });
127
+ })
128
+ .finally(() => {
129
+ this.#starting = undefined;
130
+ });
131
+ return this.#starting;
90
132
  }
91
133
  async stop() {
92
134
  this.#client?.assertOutsideHandler();
93
135
  if (this.#closing)
94
136
  return this.#closing;
95
- return this.#stopping ??= this.#shutdown(false).finally(() => { this.#stopping = undefined; });
137
+ this.#stopping ??= this.#shutdown(false).finally(() => {
138
+ this.#stopping = undefined;
139
+ });
140
+ return this.#stopping;
96
141
  }
97
142
  async close() {
98
143
  this.#client?.assertOutsideHandler();
@@ -100,13 +145,15 @@ export class Bot {
100
145
  return this.#closing;
101
146
  const task = this.#shutdown(true);
102
147
  this.#closing = task;
103
- void task.catch(() => { if (this.#closing === task)
104
- this.#closing = undefined; });
148
+ void task.catch(() => {
149
+ if (this.#closing === task)
150
+ this.#closing = undefined;
151
+ });
105
152
  return task;
106
153
  }
107
154
  async #shutdown(close) {
108
155
  this.#generation++;
109
- const client = this.#client ?? await this.#opening?.catch(() => undefined);
156
+ const client = this.#client ?? (await this.#opening?.catch(() => undefined));
110
157
  if (client) {
111
158
  if (close)
112
159
  await client.close();
@@ -116,34 +163,82 @@ export class Bot {
116
163
  if (close)
117
164
  this.#handlers.dispose();
118
165
  }
119
- requestStop() { this.#generation++; this.#ready().requestStop(); }
120
- async announce(options) { await (await this.#open()).announce(options); }
121
- async reply(event, text, options) { return this.#ready().reply(event, text, options); }
122
- async replyFile(event, data, options) { return this.#ready().replyFile(event, data, options); }
123
- async thread(event, options) { return this.#ready().thread(event, options); }
124
- send(peer, text, options) { return this.#ready().send(peer, text, options); }
125
- uploadFile(data, options) { return this.#ready().uploadFile(data, options); }
126
- sendFile(peer, data, options) { return this.#ready().sendFile(peer, data, options); }
127
- history(peer, options) { return this.#ready().history(peer, options); }
128
- react(messageId, reaction) { return this.#ready().react(messageId, reaction); }
129
- getMessage(id) { return this.#ready().getMessage(id); }
130
- idle() { return this.#ready().idle(); }
131
- receive(event, source, metadata) { return this.#ready().receive(event, source, metadata); }
132
- getMessageState(id) { return this.#ready().getMessageState(id); }
133
- listMessages(options) { return this.#ready().listMessages(options); }
134
- retryInbox(options) { return this.#ready().retryInbox(options); }
166
+ requestStop() {
167
+ this.#generation++;
168
+ this.#ready().requestStop();
169
+ }
170
+ async announce(options) {
171
+ await (await this.#open()).announce(options);
172
+ }
173
+ async reply(event, text, options) {
174
+ return this.#ready().reply(event, text, options);
175
+ }
176
+ async replyFile(event, data, options) {
177
+ return this.#ready().replyFile(event, data, options);
178
+ }
179
+ async thread(event, options) {
180
+ return this.#ready().thread(event, options);
181
+ }
182
+ send(peer, text, options) {
183
+ return this.#ready().send(peer, text, options);
184
+ }
185
+ uploadFile(data, options) {
186
+ return this.#ready().uploadFile(data, options);
187
+ }
188
+ sendFile(peer, data, options) {
189
+ return this.#ready().sendFile(peer, data, options);
190
+ }
191
+ dmHistory(peerPubkey, options) {
192
+ return this.#ready().history(peerPubkey, options);
193
+ }
194
+ async react(event, reaction) {
195
+ return this.#ready().react(event, reaction);
196
+ }
197
+ getMessage(id) {
198
+ return this.#ready().getMessage(id);
199
+ }
200
+ idle() {
201
+ return this.#ready().idle();
202
+ }
203
+ receive(event, source, metadata) {
204
+ return this.#ready().receive(event, source, metadata);
205
+ }
206
+ getMessageState(id) {
207
+ return this.#ready().getMessageState(id);
208
+ }
209
+ listMessages(options) {
210
+ return this.#ready().listMessages(options);
211
+ }
135
212
  async getSession(peer) {
136
213
  return structuredClone(await this.#handlers.sessionStore(this.#ready()).get(peer));
137
214
  }
138
215
  async setSession(peer, value) {
139
- await this.#handlers.sessionStore(this.#ready()).set(peer, structuredClone(value));
140
- }
141
- syncHistory() { return this.#ready().syncHistory(); }
142
- syncCommands() { return this.#ready().syncCommands(); }
143
- discoverCommands(options) { return this.#ready().discoverCommands(options); }
144
- flushAnnouncements() { return this.#ready().flushAnnouncements(); }
145
- flushOutbox() { return this.#ready().flushOutbox(); }
146
- encryptionKeys() { return this.#ready().encryptionKeys(); }
147
- rotateEncryptionKey() { return this.#ready().rotateEncryptionKey(); }
148
- refreshPeer(peer) { return this.#ready().refreshPeer(peer); }
216
+ await this.#handlers
217
+ .sessionStore(this.#ready())
218
+ .set(peer, structuredClone(value));
219
+ }
220
+ syncHistory() {
221
+ return this.#ready().syncHistory();
222
+ }
223
+ syncCommands() {
224
+ return this.#ready().syncCommands();
225
+ }
226
+ discoverCommands(options) {
227
+ return this.#ready().discoverCommands(options);
228
+ }
229
+ flushAnnouncements() {
230
+ return this.#ready().flushAnnouncements();
231
+ }
232
+ flushOutbox() {
233
+ return this.#ready().flushOutbox();
234
+ }
235
+ encryptionKeys() {
236
+ return this.#ready().encryptionKeys();
237
+ }
238
+ rotateEncryptionKey() {
239
+ return this.#ready().rotateEncryptionKey();
240
+ }
241
+ refreshPeer(peer) {
242
+ return this.#ready().refreshPeer(peer);
243
+ }
149
244
  }
package/dist/client.d.ts CHANGED
@@ -1,28 +1,28 @@
1
- import { type ReplyFileOptions, type SendFileOptions, type UploadFileOptions, type UploadFileResult } from './blossom.js';
2
- import { type PublicInboxOptions, type PublicInput } from './public-inbox.js';
3
- import { type ThreadOptions, type ThreadResult } from './public-thread.js';
4
- import type { InboundPolicy } from './inbound-policy.js';
5
- import { type Event } from 'nostr-tools';
6
- import type { Signer } from './signer.js';
7
- import { type Message } from './store.js';
8
- import { type Transport, type WebSocketTransportOptions } from './relay.js';
9
- import { type Rumor } from './protocol.js';
10
- import { type ProtocolMode } from './modes.js';
11
- import { type ReconnectOptions, type RecoveryOptions } from './inbox.js';
12
- import { type CommandDefinition, type DiscoverCommandsOptions } from './nipcd.js';
13
- import { type RelayRoles } from './relay-roles.js';
14
- import { type KeySyncOptions } from './key-sync.js';
15
- import { type MetadataCacheOptions } from './messaging-metadata.js';
16
- import { type CommandSyncResult } from './commands.js';
17
- import type { MessageState } from './storage.js';
18
- import type { MessageStorage } from './message-storage.js';
19
- import { type AnnounceOptions, type KeyRotationOptions } from './keys.js';
1
+ import { type ReplyFileOptions, type SendFileOptions, type UploadFileOptions, type UploadFileResult } from "./blossom.js";
2
+ import { type PublicInboxOptions, type PublicInput } from "./public-inbox.js";
3
+ import { type Input, type ThreadOptions, type ThreadResult } from "./public-thread.js";
4
+ import { type Event } from "nostr-tools";
5
+ import type { Signer } from "./signer.js";
6
+ import { type Message } from "./store.js";
7
+ import { type Transport, type WebSocketTransportOptions } from "./relay.js";
8
+ import { type DecodedEnvelope, type Rumor } from "./protocol.js";
9
+ import { type ProtocolMode } from "./modes.js";
10
+ import { type ReconnectOptions, type RecoveryOptions } from "./inbox.js";
11
+ import { type CommandDefinition, type DiscoverCommandsOptions } from "./nipcd.js";
12
+ import { type RelayRoles } from "./relay-roles.js";
13
+ import { type KeySyncOptions } from "./key-sync.js";
14
+ import { type MetadataCacheOptions } from "./messaging-metadata.js";
15
+ import { type CommandSyncResult } from "./commands.js";
16
+ import type { MessageState } from "./storage.js";
17
+ import type { MessageStorage } from "./message-storage.js";
18
+ import { type AnnounceOptions, type KeyRotationOptions } from "./keys.js";
19
+ export declare function rejectRemovedIntakeOptions(options: object): void;
20
20
  export interface SendResult {
21
21
  id: string;
22
- status: 'relay-accepted' | 'pending';
22
+ status: "relay-accepted" | "pending";
23
23
  }
24
24
  export interface SendOptions {
25
- /** ID of the decrypted kind-14 message being replied to. */
25
+ /** ID of the decrypted private message being replied to. */
26
26
  replyTo?: string;
27
27
  }
28
28
  export interface IntakeMetadata {
@@ -32,8 +32,6 @@ export interface CommonClientOptions {
32
32
  publicInbox?: PublicInboxOptions;
33
33
  metadataCache?: false | MetadataCacheOptions;
34
34
  keySync?: false | KeySyncOptions;
35
- /** Optional synchronous gate over the verified external sender, before persistence. */
36
- inboundPolicy?: InboundPolicy;
37
35
  nip4eCompatibility?: boolean;
38
36
  reconnect?: false | ReconnectOptions;
39
37
  recovery?: false | RecoveryOptions;
@@ -44,6 +42,8 @@ export interface CommonClientOptions {
44
42
  discoveryRelays?: readonly string[];
45
43
  blossomServers?: readonly string[];
46
44
  blossomDownloadOrigins?: readonly string[];
45
+ /** Root for verified plaintext attachments, scoped by account below this directory. */
46
+ attachmentDirectory?: string;
47
47
  storageKey?: Uint8Array;
48
48
  historyLimit?: number;
49
49
  database?: string;
@@ -60,7 +60,7 @@ type ClientConfiguration = CommonClientOptions & ({
60
60
  mode?: ProtocolMode;
61
61
  keyRotation?: false;
62
62
  } | {
63
- mode: 'nip4e';
63
+ mode: "nip4e";
64
64
  keyRotation: KeyRotationOptions;
65
65
  });
66
66
  /** Account credentials are supplied only through signer capabilities. */
@@ -70,7 +70,8 @@ export type ClientOptions = ClientConfiguration & {
70
70
  export type CommandRegistration = (() => void) & {
71
71
  active(): boolean;
72
72
  };
73
- export type MessageHandler = (message: Message) => void | Promise<void>;
73
+ type AdmitMessage = () => void;
74
+ export type MessageHandler = (message: Message, admit: AdmitMessage, anchor: DecodedEnvelope) => void | Promise<void>;
74
75
  export type MessageObserver = (message: Readonly<Message>) => void | Promise<void>;
75
76
  export type ErrorHandler = (error: unknown, message?: Message) => void | Promise<void>;
76
77
  export declare class Client {
@@ -78,6 +79,7 @@ export declare class Client {
78
79
  relays: string[];
79
80
  };
80
81
  private metadataLookupRelays;
82
+ private readonly attachments;
81
83
  private readonly blossomServers;
82
84
  private readonly blossomDownloadOrigins;
83
85
  private announcements;
@@ -98,7 +100,6 @@ export declare class Client {
98
100
  private readonly account;
99
101
  readonly mode: ProtocolMode;
100
102
  readonly nip4eCompatibility: boolean;
101
- private readonly inboundPolicy?;
102
103
  private keys;
103
104
  private rotationTimer?;
104
105
  private protocol;
@@ -108,10 +109,10 @@ export declare class Client {
108
109
  private handlers;
109
110
  private errors;
110
111
  private queues;
111
- private scheduled;
112
112
  private intake;
113
113
  private sub?;
114
114
  private running;
115
+ private dmActivatedAt?;
115
116
  private closed;
116
117
  private starting?;
117
118
  private stopping?;
@@ -123,28 +124,24 @@ export declare class Client {
123
124
  /** Resolve the account asynchronously, regardless of local or remote signing. */
124
125
  static create(options: ClientOptions): Promise<Client>;
125
126
  private constructor();
126
- /** Durable processing group: failures keep the message retryable. Register before start. */
127
- handle(handler: MessageHandler): () => void;
127
+ /** Internal Bot handlers manage history admission through the middleware chain. */
128
+ handle(handler: MessageHandler, managesAdmission?: boolean): () => void;
128
129
  /** Receipt observer only: failures cannot change inbox state or replay business work. */
129
- on(event: 'message', observer: MessageObserver): () => void;
130
+ on(_event: "message", observer: MessageObserver): () => void;
130
131
  onError(handler: ErrorHandler): () => void;
131
132
  report(error: unknown, message?: Message): void;
132
133
  private assertOpen;
133
134
  start(publishMetadata?: boolean): Promise<void>;
134
135
  private startUp;
135
136
  /** Verify and persist a relay event using the same asynchronous signer capabilities. */
136
- receive(event: Event, source: 'live' | 'history', metadata?: IntakeMetadata): Promise<boolean>;
137
+ receive(event: Event, source: "live" | "history", metadata?: IntakeMetadata): Promise<boolean>;
137
138
  private accept;
138
- private allowsSender;
139
139
  private enqueue;
140
140
  idle(): Promise<void>;
141
141
  private drainInbox;
142
- retryInbox(options?: {
143
- ids?: readonly string[];
144
- }): Promise<void>;
145
142
  getMessage(id: string, peer?: string): Message | undefined;
146
143
  getMessageState(id: string): MessageState | undefined;
147
- listMessages(options?: import('./store.js').MessageListOptions): import("./store.js").MessageList;
144
+ listMessages(options?: import("./store.js").MessageListOptions): import("./store.js").MessageList;
148
145
  private assertSessionOpen;
149
146
  getSession<T>(peer: string): T | undefined;
150
147
  setSession(peer: string, value: unknown): void;
@@ -161,11 +158,15 @@ export declare class Client {
161
158
  limit?: number;
162
159
  cursor?: string;
163
160
  }): import("./store.js").HistoryPage;
161
+ withAttachment(message: Message): Message;
162
+ inputForMessage(message: Message): Input;
164
163
  /** Rebind an unsigned rumor only to this account's authenticated incoming record. */
165
164
  private authenticatedInput;
166
165
  /** Application-owned delayed work uses the exact event exposed by ctx.input.event. */
167
166
  reply(event: Event | Rumor, text: string, options?: SendOptions): Promise<SendResult>;
168
167
  replyFile(event: Event | Rumor, data: Uint8Array, options?: ReplyFileOptions): Promise<SendResult>;
168
+ /** Verified public context retains its source relay without journaling the input. */
169
+ replyPublicFile(target: PublicInput, data: Uint8Array, options?: ReplyFileOptions): Promise<SendResult>;
169
170
  thread(event: Event | Rumor, options?: ThreadOptions): Promise<ThreadResult>;
170
171
  private publicKinds;
171
172
  handlePublic(handler: (input: PublicInput) => Promise<void>): () => void;
@@ -207,10 +208,13 @@ export declare class Client {
207
208
  status: "relay-accepted";
208
209
  }>;
209
210
  discoverCommands(options: DiscoverCommandsOptions): Promise<import("./nipcd.js").CommandDiscoveryResult>;
210
- send(peer: string, text: string, { replyTo }?: SendOptions): Promise<SendResult>;
211
+ send(peer: string, text: string, { replyTo }?: SendOptions, input?: DecodedEnvelope): Promise<SendResult>;
211
212
  uploadFile(data: Uint8Array, options?: UploadFileOptions): Promise<UploadFileResult>;
212
- sendFile(peer: string, data: Uint8Array, options?: SendFileOptions): Promise<SendResult>;
213
- react(id: string, reaction?: string, peer?: string): Promise<SendResult>;
213
+ sendFile(peer: string, data: Uint8Array, options?: SendFileOptions, input?: DecodedEnvelope): Promise<SendResult>;
214
+ react(event: Event | Rumor, reaction?: string): Promise<SendResult>;
215
+ reactPublic(input: PublicInput, reaction?: string): Promise<SendResult>;
216
+ /** The Bot may use a verified incoming anchor before admitting it to history. */
217
+ reactToMessage(target: Message, reaction?: string, input?: DecodedEnvelope): Promise<SendResult>;
214
218
  private publishPrivate;
215
219
  flushOutbox(): Promise<void>;
216
220
  }