@muhkoo/connect 0.14.0-alpha.7 → 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 +62 -12
- package/dist/browser/index.js +7369 -5138
- package/dist/browser/index.js.map +1 -1
- package/dist/connect.d.ts +2194 -1482
- package/dist/connect.workers.d.ts +1188 -0
- package/dist/server/index.js +10153 -8123
- package/dist/server/index.js.map +1 -1
- package/dist/workers/index.js +73 -13
- package/dist/workers/index.js.map +1 -1
- package/package.json +25 -12
package/README.md
CHANGED
|
@@ -95,8 +95,7 @@ and other APIs edge runtimes don't expose):
|
|
|
95
95
|
etc.
|
|
96
96
|
- `Authenticator.ts`
|
|
97
97
|
- `DoubleRatchetManager.ts`
|
|
98
|
-
- `personal/` — `PersonalSpaceClient
|
|
99
|
-
`unwrapWithPassphrase`
|
|
98
|
+
- `personal/` — `PersonalSpaceClient`
|
|
100
99
|
|
|
101
100
|
The `workers` build keeps `KeyStore`, `DoubleRatchet`, `EncryptedSession`,
|
|
102
101
|
`BroadcastChannel`, `WSTransport`, and the bn128.wasm-driven
|
|
@@ -122,9 +121,8 @@ npm install @muhkoo/connect@alpha
|
|
|
122
121
|
# or: yarn add @muhkoo/connect@alpha / pnpm add @muhkoo/connect@alpha
|
|
123
122
|
```
|
|
124
123
|
|
|
125
|
-
|
|
126
|
-
`
|
|
127
|
-
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
|
|
128
126
|
should not be pinned: `0.14.0-alpha.0` (reports the wrong version at runtime)
|
|
129
127
|
and `0.14.0-alpha.3` (shipped with no type declarations, so every SDK type
|
|
130
128
|
resolves to `any`).
|
|
@@ -396,6 +394,56 @@ that the remembered pairing lives on the auth origin only: `localStorage` is
|
|
|
396
394
|
per-origin, so sharing a registrable domain buys an app nothing here, and the
|
|
397
395
|
key that opens the seed is never handed to a developer app.
|
|
398
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
|
+
|
|
399
447
|
> The sections below document the lower-level building blocks the client is
|
|
400
448
|
> composed from (`BroadcastChannel`, `EncryptedSession`, `PersonalSpaceClient`,
|
|
401
449
|
> the Groth16 verifier, …). Reach for them directly only when you need control
|
|
@@ -490,7 +538,7 @@ app uses PBKDF2(password, "muhkoo-zk-v1:" + username) -> 32-byte seed ->
|
|
|
490
538
|
HKDF-Expand for each material -> P-256 via `@noble/curves` -> Poseidon
|
|
491
539
|
commitment.
|
|
492
540
|
|
|
493
|
-
### Universal Groth16 verification (
|
|
541
|
+
### Universal Groth16 verification (edge / Node / browser)
|
|
494
542
|
|
|
495
543
|
```typescript
|
|
496
544
|
import {
|
|
@@ -545,31 +593,33 @@ src/
|
|
|
545
593
|
crypto/ KeyStore, DoubleRatchet, DoubleRatchetManager, Authenticator, ZeroKnowledge
|
|
546
594
|
sessions/ EncryptedSession, BroadcastChannel
|
|
547
595
|
transport/ WSTransport
|
|
548
|
-
personal/ PersonalSpaceClient
|
|
596
|
+
personal/ PersonalSpaceClient (excluded from workers build)
|
|
549
597
|
storage/ FileStorage, ShardClient, SharedSpaceClient, Reed-Solomon codec
|
|
550
598
|
vfs/ vcs/ the encrypted filesystem and its history (client.vfs / client.vcs)
|
|
551
599
|
offline/ p2p/ CRDT offline sync; WebRTC peer shard exchange
|
|
552
600
|
events/ EventCore + EventCoreEvents
|
|
553
601
|
messaging/ Message, Packet, decorators
|
|
554
602
|
types/ shared type defs (incl. zk.ts with PREIMAGE_POK_VERIFICATION_KEY)
|
|
555
|
-
network/
|
|
603
|
+
network/ PacketCipher + DoubleRatchetCipher (the legacy Network class is gone)
|
|
556
604
|
utilities/ Logger, base58, ID generation, decorators
|
|
557
605
|
```
|
|
558
606
|
|
|
559
607
|
## Scripts
|
|
560
608
|
|
|
561
609
|
```bash
|
|
562
|
-
yarn build # rm -rf dist &&
|
|
610
|
+
yarn build # typecheck && sync-version && rm -rf dist && rollup browser + server + workers && build:dts
|
|
611
|
+
yarn typecheck # tsc --noEmit
|
|
563
612
|
yarn dev # all three targets in watch mode (concurrently)
|
|
564
613
|
yarn rollup:browser # one-off browser build
|
|
565
614
|
yarn rollup:server # one-off server build
|
|
566
615
|
yarn rollup:workers # one-off workers build
|
|
567
616
|
yarn build:dts # complete .d.ts bundle -> dist/connect.d.ts
|
|
568
|
-
yarn build:docs # typedoc -> docs/
|
|
617
|
+
yarn build:docs # typedoc -> connect-docs/docs (see typedoc.json)
|
|
569
618
|
|
|
570
619
|
yarn test # vitest
|
|
571
|
-
yarn test:unit # vitest --run
|
|
572
|
-
yarn test:
|
|
620
|
+
yarn test:unit # vitest --run --project unit
|
|
621
|
+
yarn test:e2e # vitest --run --project e2e (needs E2E_STAGING=1 + MUHKOO_BASE_URL)
|
|
622
|
+
yarn typecheck # tsc --noEmit
|
|
573
623
|
yarn lint # eslint ./src
|
|
574
624
|
```
|
|
575
625
|
|