@poolse/crypto 3.9.0 → 3.10.1

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/CHANGELOG.md CHANGED
@@ -4,6 +4,23 @@ All notable changes to `@poolse/crypto` are documented here. Format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow
5
5
  [semver](https://semver.org).
6
6
 
7
+ ## [3.10.0] - 2026-11-23
8
+
9
+ ### Added
10
+
11
+ - Workspace notes helpers on the NOTES.md contract: `sealNote`,
12
+ `openNoteMeta`, `openNoteContent`, `envelopeKeyVersion`,
13
+ `noteKeyForVersion` (NT8), `sealFolder` / `openFolderName`,
14
+ `shareWrapsFor` (NT5, NT16), `rotateNoteKey` and `shareExpired` (NT15),
15
+ the associated-data builders, `recoveryAuth`, `signForServer`,
16
+ `deviceApprovalMessage`, `recoveryReplaceMessage`, `signedDeviceGrant`
17
+ (NT10), `noteAsDocument` (NT12).
18
+ - `NoteSearchIndex` and `searchWords`: on-device search for encrypted notes,
19
+ sealed under the account key (NT7).
20
+ - `NoteOutbox` and `MemoryOutboxStorage`: the offline queue for notes with
21
+ conflict resolution, encrypted at rest (NT9).
22
+ - Frozen test vectors for all of them (`NOTES_V1`).
23
+
7
24
  ## [3.9.0] - 2026-11-22
8
25
 
9
26
  ### Added
package/README.md CHANGED
@@ -281,6 +281,90 @@ Any other backend works too: implement `BlobTransport` (`get`, `put`,
281
281
  `delete`, `list`, optional `changes`). `MemoryBlobTransport` is an in-memory
282
282
  one for tests.
283
283
 
284
+ ### Workspace notes (NOTES.md)
285
+
286
+ Helpers that follow the Workspace API's notes contract
287
+ (`apps/workspace/NOTES.md`): the associated data, field names and
288
+ base64url encodings it expects, so results go straight into request bodies.
289
+
290
+ ```ts
291
+ import {
292
+ sealNote,
293
+ openNoteMeta,
294
+ openNoteContent,
295
+ noteKeyForVersion,
296
+ shareWrapsFor,
297
+ rotateNoteKey,
298
+ recoveryAuth,
299
+ signedDeviceGrant,
300
+ NoteSearchIndex,
301
+ NoteOutbox,
302
+ noteAsDocument,
303
+ } from '@poolse/crypto';
304
+
305
+ // Write (revision = base_revision + 1, bound into the associated data).
306
+ const { meta, content } = await sealNote(
307
+ key,
308
+ { title, body, metadata },
309
+ { noteId, revision: base + 1 },
310
+ );
311
+ await ws.put(`/notes/${noteId}`, { base_revision: base, meta, content, key_wrap });
312
+
313
+ // Share (NT5): one signed wrap per approved device of each recipient.
314
+ const wraps = await shareWrapsFor(key, recipients /* from POST /notes/keys/lookup */, {
315
+ noteId,
316
+ signer: device,
317
+ });
318
+
319
+ // Revoke or expiry (NT15, on notes:rotate): new key, re-encrypted, wraps for who's left.
320
+ const r = await rotateNoteKey(key, note, {
321
+ noteId,
322
+ revision: base + 1,
323
+ accountKey,
324
+ signer: device,
325
+ remaining,
326
+ });
327
+ await ws.put(`/notes/${noteId}`, {
328
+ base_revision: base,
329
+ meta: r.meta,
330
+ content: r.content,
331
+ key_wrap: r.key_wrap,
332
+ key_history: r.key_history,
333
+ share_wraps: r.share_wraps,
334
+ });
335
+
336
+ // Versions (NT8): the key the version was written with, then its own revision.
337
+ const vkey = await noteKeyForVersion(key, note.key_history, version.key_version, { noteId });
338
+ const old = await openNoteContent(vkey, version.content, { noteId, revision: version.revision });
339
+ ```
340
+
341
+ | Helper | For |
342
+ | --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
343
+ | `noteAssociatedData`, `noteAttachmentAssociatedData`, `folderAssociatedData` | the associated data of each ciphertext |
344
+ | `sealNote` / `openNoteMeta` / `openNoteContent` / `envelopeKeyVersion` | `meta` (title + metadata, no body) and `content` |
345
+ | `sealFolder` / `openFolderName` | encrypted folder names (`name_envelope`, `key_wrap`) |
346
+ | `shareWrapsFor` | `wraps` / `share_wraps` (`{member_id, device_id, wrap}`); editors (NT16) get the same wrap and write with the same key |
347
+ | `rotateNoteKey`, `shareExpired` | rotation after a revoke or an expired share |
348
+ | `noteKeyForVersion` | walk `key_history` back for a version |
349
+ | `recoveryAuth` | `recovery.auth` / `recovery_auth`: 32 bytes, HKDF-SHA-256 of the recovery secret (empty salt, info `poolse-crypto/v1/recovery-auth`) |
350
+ | `signForServer`, `deviceApprovalMessage`, `recoveryReplaceMessage`, `signedDeviceGrant` | the device signatures the server checks (raw P-256 `r‖s`) |
351
+ | `noteAsDocument` | NT12: one decrypted note as Markdown for an agent task (only after the member chose to hand it over) |
352
+
353
+ **On-device search (NT7).** `NoteSearchIndex` keeps the words of the notes
354
+ this device has decrypted; `put(id, {title, text, updatedAt})`, `remove`,
355
+ `search(query)` (every word must match as a prefix, case and accents
356
+ ignored; title and whole-word matches first). `seal(accountKey)` encrypts it
357
+ for storage on the device (key `HKDF(accountKey, "key/search-index")`);
358
+ `NoteSearchIndex.open(sealed, accountKey)` reads it back.
359
+
360
+ **Offline queue (NT9).** `NoteOutbox.load({storage, accountKey})` keeps
361
+ edits made offline, encrypted at rest; `put(noteId, baseRevision, data)` /
362
+ `delete(...)`; several edits of a note collapse into one write on the first
363
+ `baseRevision`. `flush({send, resolve})` sends them in order: `send` seals
364
+ and writes one entry and answers `ok`, `conflict` (`409 revision_conflict`,
365
+ with the server's note) or `gone`; `resolve` merges a conflict (default:
366
+ keep the local edit). A thrown error stops the flush and keeps the rest.
367
+
284
368
  ## Format
285
369
 
286
370
  Everything the library writes is a binary envelope (base64url it with