@muhkoo/connect 0.14.0-alpha.8 → 0.14.0-alpha.9

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/README.md CHANGED
@@ -121,9 +121,8 @@ npm install @muhkoo/connect@alpha
121
121
  # or: yarn add @muhkoo/connect@alpha / pnpm add @muhkoo/connect@alpha
122
122
  ```
123
123
 
124
- Ask for the **`alpha`** tag explicitly. `latest` still points at the older
125
- `0.13.2-alpha.0` line, so a bare `npm install @muhkoo/connect` installs a build
126
- without the surface documented here. Two published builds are deprecated and
124
+ The **`alpha`** and **`latest`** tags both point at the newest alpha, so a bare
125
+ `npm install @muhkoo/connect` gets it too. Two published builds are deprecated and
127
126
  should not be pinned: `0.14.0-alpha.0` (reports the wrong version at runtime)
128
127
  and `0.14.0-alpha.3` (shipped with no type declarations, so every SDK type
129
128
  resolves to `any`).
@@ -395,6 +394,56 @@ that the remembered pairing lives on the auth origin only: `localStorage` is
395
394
  per-origin, so sharing a registrable domain buys an app nothing here, and the
396
395
  key that opens the seed is never handed to a developer app.
397
396
 
397
+ ### The encrypted filesystem (`client.vfs` / `client.vcs`)
398
+
399
+ `client.vfs` is a filesystem of encrypted directory records, with file content
400
+ written through `client.storage`. `client.vcs` is version control for one
401
+ project at a time: `client.vcs.open(slug)` returns the repository for
402
+ `/apps/<slug>`.
403
+
404
+ ```typescript
405
+ await client.vfs.writeFile("/apps/my-app/src/index.ts", "export {};");
406
+ const files = await client.vfs.walk("/apps/my-app"); // every file path, depth-first
407
+ const all = await client.vfs.walkEntries("/apps/my-app"); // directories too, as VfsStat (the release after 0.14.0-alpha.8)
408
+
409
+ const repo = client.vcs.open("my-app");
410
+ await repo.status();
411
+ await repo.commit("First commit");
412
+ ```
413
+
414
+ **Read it as untrusted input.** Hosted sign-in hands the app the master seed, so
415
+ every app a user signs into can write any directory record, history record or
416
+ repository object in that user's filesystem, in shapes this SDK would never
417
+ write. From the release after 0.14.0-alpha.8, the SDK treats everything it
418
+ reads back as untrusted. A record that used to crash, hang or quietly mislead it
419
+ now throws a typed error, or is hidden with a `[muhkoo/vfs]` warning. Two new
420
+ errors are exported from the package root:
421
+
422
+ - **`VfsLimitError`**: a walk or copy would pass a ceiling (500,000 entries,
423
+ 32,000,000 characters of path text, 64 directories deep, or one directory in
424
+ more than 4 places in a copy), or a write would put a directory more than 64
425
+ below the root. It is thrown rather than returning part of the tree, because
426
+ a sync reads a missing path as a deleted one. `limit` and `max` say which
427
+ ceiling; `at` says where it was reached.
428
+ - **`VfsCorruptRecordError`**: a directory record does not decrypt, or is not a
429
+ shape this version reads. It is never read as an empty directory and never
430
+ skipped, and it is left exactly as stored. `id` is the record, `path` where it
431
+ was reached.
432
+
433
+ The remedy for either is to remove what you do not recognise with a recursive
434
+ delete: `client.vfs.delete(path, { recursive: true })`, or `muhkoo vfs rm -r
435
+ <path>` from the CLI. Version control checks every object against its hash and
436
+ throws `VcsError` for any repository record it cannot read. The new `repo.abortMerge()`
437
+ clears a pending merge, including one whose record cannot be read, which would
438
+ otherwise stop every commit. One behaviour change to note: `exists("/")` is now
439
+ `true`, and it throws `VfsLockedError` while the filesystem is locked, where it
440
+ used to answer `false`.
441
+
442
+ This is a mitigation, not a fix: apps being handed the seed is still the root
443
+ cause. The limits, messages and every behaviour change are listed under
444
+ *Filesystem and version control* in [`API_REFERENCE.md`](./API_REFERENCE.md);
445
+ [`CHANGELOG.md`](./CHANGELOG.md) says why each one changed.
446
+
398
447
  > The sections below document the lower-level building blocks the client is
399
448
  > composed from (`BroadcastChannel`, `EncryptedSession`, `PersonalSpaceClient`,
400
449
  > the Groth16 verifier, …). Reach for them directly only when you need control
@@ -489,7 +538,7 @@ app uses PBKDF2(password, "muhkoo-zk-v1:" + username) -> 32-byte seed ->
489
538
  HKDF-Expand for each material -> P-256 via `@noble/curves` -> Poseidon
490
539
  commitment.
491
540
 
492
- ### Universal Groth16 verification (Workers / Node / browser)
541
+ ### Universal Groth16 verification (edge / Node / browser)
493
542
 
494
543
  ```typescript
495
544
  import {