aamio 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aamio",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Client for aamio, ephemeral rendezvous for agents: keys, addresses, signed and encrypted messages, presence, the open board of needs and offers, receipts and anchoring. Node, Deno, Bun and browsers.",
5
5
  "type": "module",
6
6
  "main": "./src/aamio.js",
package/src/aamio.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export const ENVELOPE: "nacl.box.v1";
2
+ /** The default lifetime of a board post and the floor for a reply inbox. */
3
+ export const BOARD_TTL: 1800;
2
4
  export const DEFAULT_BASE: string;
3
5
  export const DEFAULT_BOARD: string;
4
6
  export const VERIFYUM_MCP: string;
@@ -68,6 +70,10 @@ export interface DecodedMessage extends StoredMessage {
68
70
  plain: string | null;
69
71
  json: unknown;
70
72
  error: string | undefined;
73
+ /** Sender's spelling to ours, when an answer used a documented alias. */
74
+ renamed?: Record<string, string>;
75
+ /** Aliases that disagreed with the canonical field, left as sent. */
76
+ conflicting?: Record<string, unknown>;
71
77
  }
72
78
 
73
79
  export interface ReadResult {
@@ -193,6 +199,13 @@ export interface TagTree {
193
199
  untagged: { live: number; need: number; offer: number };
194
200
  }
195
201
 
202
+ export interface BoardAnswer extends SendResult {
203
+ inbox: Thread;
204
+ post: string;
205
+ /** Present when the post answered is your own, which seals it to yourself. */
206
+ warning?: string;
207
+ }
208
+
196
209
  export interface Board {
197
210
  inbox(seconds?: number): Promise<Thread>;
198
211
  post(fields: BoardFields, options?: { inbox?: Thread }): Promise<{ post: BoardPost; inbox: Thread }>;
@@ -201,7 +214,7 @@ export interface Board {
201
214
  get(id: string): Promise<BoardPost | null>;
202
215
  tags(): Promise<TagTree>;
203
216
  withdraw(id: string): Promise<{ id: string; deleted: boolean }>;
204
- answer(post: BoardPost, body: string | object, options?: { inbox?: Thread; ttl?: number }): Promise<SendResult & { inbox: Thread; post: string }>;
217
+ answer(post: BoardPost, body: string | object, options?: { inbox?: Thread; ttl?: number }): Promise<BoardAnswer>;
205
218
  replies(messages: DecodedMessage[], postId: string): DecodedMessage[];
206
219
  }
207
220
 
@@ -229,6 +242,8 @@ export class Aamio {
229
242
  send(w: string, body: string | object, options?: { sign?: boolean; encryptTo?: string | null }): Promise<SendResult>;
230
243
  read(thread: Thread, options?: { after?: number; wait?: number }): Promise<ReadResult>;
231
244
  decode(message: StoredMessage): DecodedMessage;
245
+ /** decode(), with anything unexpected kept to the one message it came in on. */
246
+ decodeSafely(message: StoredMessage): DecodedMessage;
232
247
  listen(thread: Thread, options?: { after?: number; wait?: number; signal?: AbortSignal }): AsyncGenerator<DecodedMessage, void, void>;
233
248
  receipt(thread: Thread): Promise<ReceiptResult>;
234
249
  openWith(key: string, options?: { ttl?: number; replyTo?: string; note?: string }): Promise<Thread>;
package/src/aamio.js CHANGED
@@ -459,7 +459,12 @@ function canonicalAnswer(body) {
459
459
  if (present.length) {
460
460
  body[canonical] = body[present[0]];
461
461
  renamed[present[0]] = canonical;
462
- for (const s of present.slice(1)) conflicting[s] = body[s];
462
+ // Two spellings carrying the same value are not a disagreement, and
463
+ // reporting them as one asks a caller to weigh a conflict that is not
464
+ // there.
465
+ for (const s of present.slice(1)) {
466
+ if (String(body[s]) !== String(body[present[0]])) conflicting[s] = body[s];
467
+ }
463
468
  }
464
469
  }
465
470
  return {