Files
Claude 68d1a1c8e9
CI / Node 24 (push) Successful in 15s
CI / Node 26 (push) Successful in 16s
CI / Node 22 (pull_request) Successful in 13s
CI / Node 24 (pull_request) Failing after 3s
CI / Node 26 (pull_request) Failing after 4s
CI / Chromium (push) Failing after 1m8s
CI / Publish to staging registry (push) Skipped
CI / Chromium (pull_request) Failing after 1m3s
CI / Publish to staging registry (pull_request) Skipped
CI / Node 22 (push) Failing after 4s
Add encryption, Chromium tests and a README
- KVStorageEncrypted: AES-GCM per value (fresh IV, storage key as AAD), keys stay
  readable; decrypts and re-emits pushed changes and passes subscriptions through, so it
  can be a composite source. generateKey / exportKey / importKey / deriveKey (PBKDF2).
- KVStorageHttpServer: allowOrigins (CORS), including cache-control for SSE preflights.
- Chromium tests (Vitest browser mode + Playwright) against a real cross-origin server:
  conformance for IndexedDB, encrypted, HTTP and composite stores; signed requests and
  SSE; two devices syncing, offline writes surviving a reload. New CI job.
- Composite fixes found by those tests: sync() during a running sync schedules one more
  (changes between the first scan and the stream connecting were missed); a queued write
  the source refuses is dropped, restored and reported (onError) instead of blocking the
  queue forever.
- README with examples, mirrored in test/readme.test.ts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Qxbkp4tA7G5SCWjzWuxmE
2026-10-23 14:25:22 +00:00

1.9 KiB

PotentialStorage

Layered TypeScript storage library: KV → Events → Documents. The design is in DESIGN.md; read it before changing anything and keep it up to date.

Commands

  • npm test: tsc --noEmit, then all Vitest tests (including test/types.test-d.ts)
  • npm run test:only -- <file>: Vitest only
  • npm run test:browser: test/browser/ in headless Chromium (Vitest browser mode + Playwright) against a real server on another origin (test/browser/global-setup.ts)
  • npm run typecheck, npm run build, npm run bench
  • npm run format / npm run format:check: Prettier

CI (.gitea/workflows/ci.yml, Gitea Actions) runs the format check, typecheck, tests and build on Node 22, 24 and 26, and the Chromium tests. On pushes it then publishes to the staging registry (scripts/publish.mjs: main → latest, next → next, others → dev-<branch>).

Conventions

  • One abstract base class per layer (src/<layer>/base-*.ts); implementations only provide the raw primitives, and the user-facing API lives in the base class.
  • Classes over loose functions; TS private, not #; no overloads (use param? or tuple-union rest params); don't override base methods in subclasses.
  • Never reassign a field after construction. child() nodes are frozen Object.create(root) views, so this.x = ... on a child throws. Keep mutable state in a private readonly state object or in Maps (see KVStorageComposite, KVStorageHttp).
  • No runtime dependencies; third-party code is vendored (src/utils/sse-session/, event-emitter.ts, extended-json.ts, with a header naming the source). Tests live only in test/, mirroring src/.
  • README.md examples are mirrored in test/readme.test.ts; change both together.
  • New KV/document implementations must pass test/kv-storage/kv-storage.conformance.ts / test/document-storage/document-storage.suite.ts.
  • Ask the owner before pushing.