@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 +53 -4
- package/dist/browser/index.js +2244 -458
- package/dist/browser/index.js.map +1 -1
- package/dist/connect.d.ts +377 -14
- package/dist/server/index.js +2244 -458
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
package/dist/connect.d.ts
CHANGED
|
@@ -5920,6 +5920,8 @@ interface FileEntry {
|
|
|
5920
5920
|
* would defeat the point of keeping history out of the directory record.
|
|
5921
5921
|
*/
|
|
5922
5922
|
versions?: number;
|
|
5923
|
+
/** See `DirEntry.moving`. */
|
|
5924
|
+
moving?: true;
|
|
5923
5925
|
}
|
|
5924
5926
|
interface DirEntry {
|
|
5925
5927
|
kind: "dir";
|
|
@@ -5928,6 +5930,25 @@ interface DirEntry {
|
|
|
5928
5930
|
/** Base64 AES-256 key for that record. See the capability note above. */
|
|
5929
5931
|
key: string;
|
|
5930
5932
|
mtime: number;
|
|
5933
|
+
/**
|
|
5934
|
+
* Set on both copies while a move between two directories is under way.
|
|
5935
|
+
*
|
|
5936
|
+
* A move writes two records, attaching before it detaches, and one that
|
|
5937
|
+
* is interrupted leaves the same entry - the same directory record, or
|
|
5938
|
+
* the same file id, content and history - named in both. This is how a
|
|
5939
|
+
* delete of either copy knows to look for the other before letting go of
|
|
5940
|
+
* anything. Cleared by the move's last write, and from the one copy left
|
|
5941
|
+
* when a delete removes the other. Left in place, it costs a delete of
|
|
5942
|
+
* that entry one read of the tree, and a file keeps every version that
|
|
5943
|
+
* falls off its history.
|
|
5944
|
+
*
|
|
5945
|
+
* Not cleared when that last write is the one that fails: the move has
|
|
5946
|
+
* otherwise finished, only one copy is named anywhere, and nothing comes
|
|
5947
|
+
* back to unmark it. A retried move of the same entry carries the mark
|
|
5948
|
+
* over. That copy then keeps what falls off its history for good - a
|
|
5949
|
+
* storage cost, never a loss.
|
|
5950
|
+
*/
|
|
5951
|
+
moving?: true;
|
|
5931
5952
|
}
|
|
5932
5953
|
type Entry = FileEntry | DirEntry;
|
|
5933
5954
|
/** One directory record, as stored (before encryption). */
|
|
@@ -5983,6 +6004,57 @@ declare class VfsNotFoundError extends Error {
|
|
|
5983
6004
|
declare class VfsConflictError extends Error {
|
|
5984
6005
|
constructor(message: string);
|
|
5985
6006
|
}
|
|
6007
|
+
/**
|
|
6008
|
+
* Raised when a directory record cannot be read: it does not decrypt or parse
|
|
6009
|
+
* with the key its parent holds, or it does but is not a shape this SDK can
|
|
6010
|
+
* read - not an object, a version other than 1, `entries` missing or not a map.
|
|
6011
|
+
*
|
|
6012
|
+
* Thrown, never read as an empty directory. The next write into an "empty"
|
|
6013
|
+
* directory would seal an empty record over the real one, and a record this
|
|
6014
|
+
* version cannot read may simply be one a NEWER version wrote. Nor is the
|
|
6015
|
+
* directory skipped: a sync that cannot see a subtree reads its absence as a
|
|
6016
|
+
* deletion. The record is left exactly as stored; a recursive delete
|
|
6017
|
+
* (`delete(path, { recursive: true })`) detaches it when the user wants it
|
|
6018
|
+
* gone.
|
|
6019
|
+
*/
|
|
6020
|
+
declare class VfsCorruptRecordError extends Error {
|
|
6021
|
+
/** The record's id - `dirKey(id)` is where it is stored. */
|
|
6022
|
+
readonly id: string;
|
|
6023
|
+
/** The path it was reached through, when known. A moved subtree can have two. */
|
|
6024
|
+
readonly path?: string;
|
|
6025
|
+
constructor(id: string, path: string | undefined, reason: string);
|
|
6026
|
+
}
|
|
6027
|
+
/**
|
|
6028
|
+
* Raised when a walk or a copy would go past a size or depth ceiling, or a
|
|
6029
|
+
* write would put a directory deeper than a walk reads.
|
|
6030
|
+
*
|
|
6031
|
+
* Thrown rather than returning what was gathered so far, because every caller
|
|
6032
|
+
* of a walk treats a path that is missing from the result as a path that does
|
|
6033
|
+
* not exist - and a sync then plans a deletion for it. A tree this large or
|
|
6034
|
+
* deep is almost always one built to be expensive to read: directory records
|
|
6035
|
+
* can point at the same directory many times over, so a handful of tiny
|
|
6036
|
+
* records can describe more paths than there are atoms.
|
|
6037
|
+
*/
|
|
6038
|
+
declare class VfsLimitError extends Error {
|
|
6039
|
+
/**
|
|
6040
|
+
* Which ceiling was hit: total entries, total characters of path text,
|
|
6041
|
+
* nesting depth, or - for a copy - how many places one directory may
|
|
6042
|
+
* appear. Entries alone do not bound memory - a name may be 255 bytes, so
|
|
6043
|
+
* one path can be ~16KB - which is why path text has its own.
|
|
6044
|
+
*/
|
|
6045
|
+
readonly limit: "entries" | "pathChars" | "depth" | "shared";
|
|
6046
|
+
/** The ceiling itself. */
|
|
6047
|
+
readonly max: number;
|
|
6048
|
+
/** Where the operation started, or for a write what it was asked to write. */
|
|
6049
|
+
readonly path: string;
|
|
6050
|
+
/**
|
|
6051
|
+
* Where the ceiling was reached: the directory being listed, or for depth
|
|
6052
|
+
* the entry one level too deep. Walking the tree to find the culprit would
|
|
6053
|
+
* hit the same ceiling, so this is the only pointer the caller gets.
|
|
6054
|
+
*/
|
|
6055
|
+
readonly at: string;
|
|
6056
|
+
constructor(limit: VfsLimitError["limit"], max: number, path: string, at: string, doing?: string);
|
|
6057
|
+
}
|
|
5986
6058
|
|
|
5987
6059
|
/**
|
|
5988
6060
|
* `client.vfs` — a real filesystem over Muhkoo primitives.
|
|
@@ -6053,6 +6125,18 @@ interface VfsNamespaceDeps {
|
|
|
6053
6125
|
seed: () => Uint8Array | null;
|
|
6054
6126
|
/** Versions retained per file. */
|
|
6055
6127
|
historyLimit?: number;
|
|
6128
|
+
/**
|
|
6129
|
+
* Ceilings for the operations that visit a whole subtree - `walk` (and so
|
|
6130
|
+
* `glob`) and `copy`. `entries` is the most entries one call may visit;
|
|
6131
|
+
* `pathChars` the most characters of path text, summed over every path it
|
|
6132
|
+
* visits. The defaults are far past any real project; tests lower them so
|
|
6133
|
+
* a hostile tree hits them in milliseconds. `Client` does not pass these,
|
|
6134
|
+
* so `client.vfs` always has the defaults.
|
|
6135
|
+
*/
|
|
6136
|
+
limits?: {
|
|
6137
|
+
entries?: number;
|
|
6138
|
+
pathChars?: number;
|
|
6139
|
+
};
|
|
6056
6140
|
}
|
|
6057
6141
|
declare class VfsNamespace {
|
|
6058
6142
|
private readonly deps;
|
|
@@ -6066,6 +6150,8 @@ declare class VfsNamespace {
|
|
|
6066
6150
|
*/
|
|
6067
6151
|
private cache;
|
|
6068
6152
|
private readonly historyLimit;
|
|
6153
|
+
private readonly maxEntries;
|
|
6154
|
+
private readonly maxPathChars;
|
|
6069
6155
|
constructor(deps: VfsNamespaceDeps);
|
|
6070
6156
|
/**
|
|
6071
6157
|
* The working directory relative paths resolve against.
|
|
@@ -6117,14 +6203,46 @@ declare class VfsNamespace {
|
|
|
6117
6203
|
stat(path: string): Promise<VfsStat>;
|
|
6118
6204
|
/** Immediate children of a directory. One record fetch. */
|
|
6119
6205
|
list(path?: string): Promise<VfsStat[]>;
|
|
6206
|
+
/**
|
|
6207
|
+
* A directory's entries in listing order: directories first, then by name.
|
|
6208
|
+
* Shared by `list` and `walk`, so a walk's output order is exactly the order
|
|
6209
|
+
* of the listings it is made of.
|
|
6210
|
+
*/
|
|
6211
|
+
private children;
|
|
6120
6212
|
private warn;
|
|
6121
6213
|
/**
|
|
6122
6214
|
* Every file path under a prefix, depth-first.
|
|
6123
6215
|
*
|
|
6124
6216
|
* Deliberately separate from `list`: this walks the whole subtree, which is
|
|
6125
6217
|
* one fetch per directory. Fine for a project, wrong as a default.
|
|
6218
|
+
*
|
|
6219
|
+
* Throws VfsLimitError past the entry budget or the depth ceiling, and
|
|
6220
|
+
* VfsCorruptRecordError for a directory it cannot read, rather than
|
|
6221
|
+
* returning part of the tree. Skips (with a warning) a directory that is
|
|
6222
|
+
* one of its own ancestors.
|
|
6126
6223
|
*/
|
|
6127
6224
|
walk(path?: string): Promise<string[]>;
|
|
6225
|
+
/**
|
|
6226
|
+
* Every entry under a prefix - directories as well as files - depth-first,
|
|
6227
|
+
* each directory just before its contents. `walk` is this with the
|
|
6228
|
+
* directories filtered out, so the two can never disagree about what is in
|
|
6229
|
+
* a tree; version control uses this one because a commit records empty
|
|
6230
|
+
* directories too.
|
|
6231
|
+
*/
|
|
6232
|
+
walkEntries(path?: string): Promise<VfsStat[]>;
|
|
6233
|
+
/**
|
|
6234
|
+
* `walkEntries` without the list: `visit` is called with each entry in
|
|
6235
|
+
* the same order, and for a file with its manifest - the handle
|
|
6236
|
+
* `statManifest` gives, without resolving the path all over again, which
|
|
6237
|
+
* on a deep tree cost far more than the walk itself. Null for a directory.
|
|
6238
|
+
*
|
|
6239
|
+
* For a caller that does not need every entry at once. Version control
|
|
6240
|
+
* compares the working tree with a commit as it goes, where holding the
|
|
6241
|
+
* whole walk beside the whole commit, and a map of one beside a map of
|
|
6242
|
+
* the other, ran a 512MB heap out of memory inside the default budgets.
|
|
6243
|
+
* The same guards and budgets as `walk`, which is built on this.
|
|
6244
|
+
*/
|
|
6245
|
+
eachEntry(path: string, visit: (stat: VfsStat, manifest: FileManifest | null) => void): Promise<void>;
|
|
6128
6246
|
readFile(path: string): Promise<Uint8Array>;
|
|
6129
6247
|
readText(path: string): Promise<string>;
|
|
6130
6248
|
/**
|
|
@@ -6170,6 +6288,16 @@ declare class VfsNamespace {
|
|
|
6170
6288
|
mkdir(path: string, opts?: {
|
|
6171
6289
|
recursive?: boolean;
|
|
6172
6290
|
}): Promise<void>;
|
|
6291
|
+
/**
|
|
6292
|
+
* Refuse now what creating these directories with `mkdir -p` would refuse
|
|
6293
|
+
* part way: one deeper than MAX_DEPTH, or a name on the way held by an
|
|
6294
|
+
* entry this version cannot read. Writes nothing.
|
|
6295
|
+
*
|
|
6296
|
+
* For an operation that removes things before it writes - a checkout -
|
|
6297
|
+
* so that a refusal comes before anything is gone. A FILE in the way is
|
|
6298
|
+
* not refused: such an operation removes those first.
|
|
6299
|
+
*/
|
|
6300
|
+
assertCreatable(dirs: Iterable<string>): Promise<void>;
|
|
6173
6301
|
/**
|
|
6174
6302
|
* Write a file, creating parent directories as needed.
|
|
6175
6303
|
*
|
|
@@ -6183,10 +6311,10 @@ declare class VfsNamespace {
|
|
|
6183
6311
|
/**
|
|
6184
6312
|
* Delete a file, or a directory when `recursive`.
|
|
6185
6313
|
*
|
|
6186
|
-
* `keepContent` removes the entry WITHOUT releasing its shards
|
|
6187
|
-
*
|
|
6188
|
-
*
|
|
6189
|
-
* depends on.
|
|
6314
|
+
* `keepContent` removes the entry WITHOUT releasing its shards - or, for
|
|
6315
|
+
* a directory, the shards of anything in it. A checkout needs that: the
|
|
6316
|
+
* file is leaving the working tree, but commits still reference the same
|
|
6317
|
+
* manifest, and releasing would free content history depends on.
|
|
6190
6318
|
*/
|
|
6191
6319
|
delete(path: string, opts?: {
|
|
6192
6320
|
recursive?: boolean;
|
|
@@ -6198,9 +6326,21 @@ declare class VfsNamespace {
|
|
|
6198
6326
|
*
|
|
6199
6327
|
* A directory move is O(1) regardless of how much is inside it — the
|
|
6200
6328
|
* subtree records are not touched at all, because nothing in them records
|
|
6201
|
-
* its own path.
|
|
6329
|
+
* its own path. Except a move to a DEEPER place, which reads the subtree
|
|
6330
|
+
* first: what is below must still be inside MAX_DEPTH once it is moved.
|
|
6202
6331
|
*/
|
|
6203
6332
|
rename(from: string, to: string): Promise<void>;
|
|
6333
|
+
/**
|
|
6334
|
+
* Refuse to move the directory at `src` to `dst` when something in it
|
|
6335
|
+
* would then be deeper than MAX_DEPTH from the root. Writes nothing.
|
|
6336
|
+
*
|
|
6337
|
+
* Measured only moving deeper, because it reads the whole subtree: one
|
|
6338
|
+
* move of a 40-deep tree under a 30-deep directory was accepted when only
|
|
6339
|
+
* the moved directory was measured, and every walk of the root threw from
|
|
6340
|
+
* then on. A part that cannot be read cannot be measured, and does not
|
|
6341
|
+
* stop the move - that record stops every walk above it already.
|
|
6342
|
+
*/
|
|
6343
|
+
private assertFitsAt;
|
|
6204
6344
|
/**
|
|
6205
6345
|
* Copy a file or a directory tree.
|
|
6206
6346
|
*
|
|
@@ -6262,25 +6402,158 @@ declare class VfsNamespace {
|
|
|
6262
6402
|
/** Open a directory by path, creating nothing. Throws if it is missing. */
|
|
6263
6403
|
private openDir;
|
|
6264
6404
|
private openDirOrNull;
|
|
6405
|
+
/** Open a directory by path, along with the id of every directory on the way to it. */
|
|
6406
|
+
private openChain;
|
|
6407
|
+
/**
|
|
6408
|
+
* `path` is only for error messages. The cache is keyed by id, so when two
|
|
6409
|
+
* paths reach one record - a move interrupted between attach and detach -
|
|
6410
|
+
* the error names whichever asked first.
|
|
6411
|
+
*/
|
|
6265
6412
|
private openDirById;
|
|
6413
|
+
/**
|
|
6414
|
+
* Turn a decrypted record into an OpenDir, or throw.
|
|
6415
|
+
*
|
|
6416
|
+
* The record is THROWN on, never read as empty, when its shape is wrong -
|
|
6417
|
+
* see VfsCorruptRecordError. An individual entry of the wrong shape is set
|
|
6418
|
+
* aside in `hidden` instead: out of every read, but kept for the write.
|
|
6419
|
+
*/
|
|
6420
|
+
private readRecord;
|
|
6266
6421
|
/** Apply an edit to a directory record and persist it. */
|
|
6267
6422
|
private mutate;
|
|
6268
6423
|
private createDir;
|
|
6269
|
-
/**
|
|
6424
|
+
/**
|
|
6425
|
+
* Every directory record in a subtree, each once, opened - and nothing
|
|
6426
|
+
* changed. The first half of a recursive delete; see `delete`.
|
|
6427
|
+
*
|
|
6428
|
+
* Once per id, so a record that references another inside the subtree
|
|
6429
|
+
* cannot recurse forever, and a subtree reachable twice is not released
|
|
6430
|
+
* twice. And never a directory in `above` - the root and everything else
|
|
6431
|
+
* on the way down to the target - nor the root by any route. Deduplicating
|
|
6432
|
+
* alone let an entry naming the root pull the whole filesystem into the
|
|
6433
|
+
* delete, the root record included; a walk shows the same pointer as a
|
|
6434
|
+
* cycle and skips it, so this skips it too.
|
|
6435
|
+
*
|
|
6436
|
+
* `moving` says whether anything in it is marked as half of an
|
|
6437
|
+
* interrupted move, which is what makes a delete look for the other half.
|
|
6438
|
+
*/
|
|
6439
|
+
private subtree;
|
|
6440
|
+
/**
|
|
6441
|
+
* Delete these records and let go of every file in them. The second half
|
|
6442
|
+
* of a recursive delete, run only once the subtree is detached. Cannot
|
|
6443
|
+
* throw: every step is best-effort, because unreachable is not fatal.
|
|
6444
|
+
*
|
|
6445
|
+
* With `elsewhere` - what the rest of the tree still names, read because
|
|
6446
|
+
* something here is half of an interrupted move - a record still named
|
|
6447
|
+
* elsewhere is kept, and so is a file.
|
|
6448
|
+
*/
|
|
6270
6449
|
private purge;
|
|
6450
|
+
/**
|
|
6451
|
+
* Unmark what is left of an interrupted move once a delete has removed
|
|
6452
|
+
* the other copy. Marked, a file keeps every version that falls off its
|
|
6453
|
+
* history, because the other copy might hold it - for good, once there
|
|
6454
|
+
* is no other copy - and every delete of the entry, or of a directory
|
|
6455
|
+
* above it, reads the whole tree. Only when exactly one marked copy is
|
|
6456
|
+
* left: more, and they are still shared. Best-effort, like everything
|
|
6457
|
+
* after a detach; failing, it stays marked, which costs only that.
|
|
6458
|
+
*/
|
|
6459
|
+
private settle;
|
|
6460
|
+
/**
|
|
6461
|
+
* Let go of files that are leaving the tree: each one's content, every
|
|
6462
|
+
* version its history holds, and the history record. Best-effort, like
|
|
6463
|
+
* everything after a detach.
|
|
6464
|
+
*
|
|
6465
|
+
* A file id still named elsewhere is one file with two names, left by an
|
|
6466
|
+
* interrupted move: its content and history belong to the name that is
|
|
6467
|
+
* staying, and all that changes hands is the key its history opens with.
|
|
6468
|
+
* `keepContent` keeps every file's content and drops only its history
|
|
6469
|
+
* record, as a checkout needs.
|
|
6470
|
+
*/
|
|
6471
|
+
private letGo;
|
|
6472
|
+
/**
|
|
6473
|
+
* What the tree still names with one entry left out: every directory
|
|
6474
|
+
* record, and every file id with a directory that holds it. Null when
|
|
6475
|
+
* part of the tree cannot be read or followed, so the answer is unknown.
|
|
6476
|
+
*/
|
|
6477
|
+
private namedElsewhere;
|
|
6478
|
+
/**
|
|
6479
|
+
* Everything reachable from the root: every directory record's id and
|
|
6480
|
+
* key, and every file id with a directory that names it - following the
|
|
6481
|
+
* entries hidden only for their name, which still reference what they
|
|
6482
|
+
* point at. `skip` leaves one entry out: one about to be detached.
|
|
6483
|
+
*
|
|
6484
|
+
* Fetches up to WALK_CONCURRENCY records at once, each record once
|
|
6485
|
+
* however often it is named. Throws VfsCorruptRecordError for a record a
|
|
6486
|
+
* path reaches that cannot be read, unless `lenient`. `unknown` counts
|
|
6487
|
+
* what could not be followed at all: an entry this version cannot read,
|
|
6488
|
+
* and a record behind an unusable name that does not open - which no path
|
|
6489
|
+
* can reach, and so no recursive delete can remove - or, `lenient`, any
|
|
6490
|
+
* record that does not open.
|
|
6491
|
+
*/
|
|
6492
|
+
private references;
|
|
6271
6493
|
/**
|
|
6272
6494
|
* Deep-copy an entry. Files reuse their manifest (no bytes move); each
|
|
6273
6495
|
* directory gets a fresh id and key, so the copy is independent of the
|
|
6274
6496
|
* original — writing into one must never appear in the other.
|
|
6497
|
+
*
|
|
6498
|
+
* `at` is the entry's SOURCE path, and `depth` how many directories deep
|
|
6499
|
+
* from the root the copy of it will be. With `run.write` false this is the
|
|
6500
|
+
* dry run: every check, no reference taken and no record stored.
|
|
6275
6501
|
*/
|
|
6276
6502
|
private cloneEntry;
|
|
6277
6503
|
/**
|
|
6278
|
-
* Let go of
|
|
6279
|
-
*
|
|
6504
|
+
* Let go of one file's bytes: its content, every version its history
|
|
6505
|
+
* retains, and the history record itself.
|
|
6506
|
+
*
|
|
6507
|
+
* Each distinct manifest once. `copies` is every entry naming the file -
|
|
6508
|
+
* two after an interrupted move, which may by now hold different
|
|
6509
|
+
* versions - and `restore` puts a version back without taking a second
|
|
6510
|
+
* reference, so its manifest is in the entry and in the history both.
|
|
6511
|
+
* Releasing per mention released one reference twice, and so freed bytes
|
|
6512
|
+
* a copy elsewhere, holding its own reference, still needed.
|
|
6280
6513
|
*/
|
|
6281
6514
|
private releaseFile;
|
|
6515
|
+
/**
|
|
6516
|
+
* A file's history record, opened with the first of `keys` that opens
|
|
6517
|
+
* it, and that key. Null when there is none, or none of them does.
|
|
6518
|
+
*/
|
|
6519
|
+
private openHistory;
|
|
6520
|
+
/**
|
|
6521
|
+
* Seal a file's history with the key of the directory that holds it now.
|
|
6522
|
+
*
|
|
6523
|
+
* A history record is sealed with its directory's key, so a file moved
|
|
6524
|
+
* to another directory carried a history its new directory could not
|
|
6525
|
+
* open: every read of it, and every write to the file, failed from then
|
|
6526
|
+
* on. Nothing to do when there is no history, when it opens with `to`
|
|
6527
|
+
* already, or when none of the keys opens it.
|
|
6528
|
+
*/
|
|
6529
|
+
private rekeyHistory;
|
|
6530
|
+
/**
|
|
6531
|
+
* The history of the file `entry` names as `name` in `parent`, and the
|
|
6532
|
+
* key to seal it with from now on.
|
|
6533
|
+
*
|
|
6534
|
+
* A history is sealed with its directory's key - usually. The two halves
|
|
6535
|
+
* of an interrupted move share one history, sealed with ONE of their
|
|
6536
|
+
* directories' keys, and a file moved between directories by a version
|
|
6537
|
+
* before `rename` re-sealed it still has its old directory's. So when the
|
|
6538
|
+
* directory's own key does not open it, every key in the tree is tried,
|
|
6539
|
+
* the other half's first: a read of the whole tree, and only then. It
|
|
6540
|
+
* need not be read in full, or understood - an entry this version cannot
|
|
6541
|
+
* follow may hide a key, but a key that opens the record is proof
|
|
6542
|
+
* enough. Found, it is re-sealed with this directory's key, so the search
|
|
6543
|
+
* is made once - except for half of a move, which keeps the key that
|
|
6544
|
+
* opened it and so keeps working for both halves.
|
|
6545
|
+
*
|
|
6546
|
+
* No record, or a value that is not a sealed record at all, is an empty
|
|
6547
|
+
* history, as it always was. One that no key opens is thrown on, with a
|
|
6548
|
+
* message rather than a bare decryption error: writing an empty history
|
|
6549
|
+
* over it would lose every version it holds.
|
|
6550
|
+
*/
|
|
6282
6551
|
private readHistory;
|
|
6283
|
-
/**
|
|
6552
|
+
/**
|
|
6553
|
+
* Push `entry` onto its history record. Returns the new version count.
|
|
6554
|
+
* `next` is the manifest the entry will hold once the caller has written
|
|
6555
|
+
* it.
|
|
6556
|
+
*/
|
|
6284
6557
|
private pushHistory;
|
|
6285
6558
|
}
|
|
6286
6559
|
|
|
@@ -6386,21 +6659,88 @@ interface VcsNamespaceDeps {
|
|
|
6386
6659
|
key: () => Promise<Uint8Array>;
|
|
6387
6660
|
/** Who to record as the author. */
|
|
6388
6661
|
author: () => string;
|
|
6662
|
+
/**
|
|
6663
|
+
* `entries` is the most tree entries one read of history may visit - one
|
|
6664
|
+
* `status`, `diff` or `checkout` - and `pathChars` the most characters of
|
|
6665
|
+
* path those entries may add up to. The defaults are far past any real
|
|
6666
|
+
* project; tests lower them so a hostile tree hits them in milliseconds.
|
|
6667
|
+
* `Client` does not pass these, so `client.vcs` always has the defaults.
|
|
6668
|
+
*/
|
|
6669
|
+
limits?: {
|
|
6670
|
+
entries?: number;
|
|
6671
|
+
pathChars?: number;
|
|
6672
|
+
};
|
|
6389
6673
|
}
|
|
6390
6674
|
declare class Repo {
|
|
6391
6675
|
private readonly slug;
|
|
6392
6676
|
private readonly deps;
|
|
6677
|
+
private readonly maxEntries;
|
|
6678
|
+
private readonly maxPathChars;
|
|
6679
|
+
/**
|
|
6680
|
+
* How many directories deep below the project a tree may nest. The
|
|
6681
|
+
* working tree may be written MAX_DEPTH directories below the root, and
|
|
6682
|
+
* the project itself is some of those: a deeper tree would check out into
|
|
6683
|
+
* something no walk will read, and `status` - and every checkout after,
|
|
6684
|
+
* which walks the tree first - would throw from then on.
|
|
6685
|
+
*/
|
|
6686
|
+
private readonly maxTreeDepth;
|
|
6393
6687
|
constructor(slug: string, deps: VcsNamespaceDeps);
|
|
6394
6688
|
private get root();
|
|
6395
6689
|
/** Store an object, returning its hash and whether it was new. */
|
|
6396
6690
|
private put;
|
|
6691
|
+
/** Does this stored record open to an object with this hash? */
|
|
6692
|
+
private holds;
|
|
6693
|
+
/**
|
|
6694
|
+
* Fetch an object, and prove it is the one that was asked for.
|
|
6695
|
+
*
|
|
6696
|
+
* Content addressing is only a guarantee if the address is checked. Without
|
|
6697
|
+
* this a stored object could claim any hash - including its own, so a tree
|
|
6698
|
+
* could contain itself and `status` would follow it for ever. Every object
|
|
6699
|
+
* this repository has ever written verifies: `put` hashes exactly the value
|
|
6700
|
+
* it seals, `canonical` is independent of key order and drops `undefined`
|
|
6701
|
+
* exactly as JSON does, and hashing has never been versioned.
|
|
6702
|
+
*/
|
|
6397
6703
|
private get;
|
|
6704
|
+
/** A commit, checked to be one. See `commitProblem`. */
|
|
6705
|
+
private readCommit;
|
|
6706
|
+
/**
|
|
6707
|
+
* Start a traversal of history: a budget shared by every branch of it, and
|
|
6708
|
+
* a cache of the tree objects it has fetched.
|
|
6709
|
+
*
|
|
6710
|
+
* The cache matters for the same reason the budget does. Identical
|
|
6711
|
+
* subtrees are one object, so a tree of honest-but-hostile shape is a
|
|
6712
|
+
* handful of fetches and a vast number of paths; caching keeps it to the
|
|
6713
|
+
* handful, and the budget stops the paths. It caches OBJECTS, never output
|
|
6714
|
+
* - each name a shared subtree appears at is still listed.
|
|
6715
|
+
*/
|
|
6716
|
+
private treeWalk;
|
|
6717
|
+
/**
|
|
6718
|
+
* A tree object's entries, checked and ready to walk.
|
|
6719
|
+
*
|
|
6720
|
+
* Returned in a null-prototype map, so a name like `constructor` is looked
|
|
6721
|
+
* up as an entry and not found as an inherited property.
|
|
6722
|
+
*/
|
|
6723
|
+
private readTree;
|
|
6724
|
+
/**
|
|
6725
|
+
* A record that is not an object - HEAD, a branch ref, the branch list,
|
|
6726
|
+
* MERGE - opened. Null when there is none; `problem` when there is one
|
|
6727
|
+
* that does not open. What is inside is the caller's to check.
|
|
6728
|
+
*/
|
|
6729
|
+
private openRecord;
|
|
6398
6730
|
private head;
|
|
6399
6731
|
private setHead;
|
|
6400
6732
|
private readRef;
|
|
6733
|
+
/** A branch's commit, null when there is no such branch, or "unreadable". */
|
|
6734
|
+
private refState;
|
|
6401
6735
|
private writeRef;
|
|
6402
6736
|
/** Every branch name in this repository. */
|
|
6403
6737
|
branches(): Promise<string[]>;
|
|
6738
|
+
/**
|
|
6739
|
+
* The branch list, less any name a branch could not have been created
|
|
6740
|
+
* with - left out with a warning, like an unreadable entry in a tree, so
|
|
6741
|
+
* one planted name does not hide every real one.
|
|
6742
|
+
*/
|
|
6743
|
+
private readIndex;
|
|
6404
6744
|
/** The commit HEAD resolves to, or null in an empty repository. */
|
|
6405
6745
|
current(): Promise<string | null>;
|
|
6406
6746
|
/**
|
|
@@ -6418,7 +6758,27 @@ declare class Repo {
|
|
|
6418
6758
|
theirs: string;
|
|
6419
6759
|
name: string;
|
|
6420
6760
|
} | null>;
|
|
6421
|
-
/**
|
|
6761
|
+
/**
|
|
6762
|
+
* Give up on a merge that stopped for conflicts: the next commit is an
|
|
6763
|
+
* ordinary one, with one parent. The working tree is left as it is,
|
|
6764
|
+
* conflict markers and all. To put it back, switch to the current branch
|
|
6765
|
+
* with `discardChanges` — not `checkout`, which always leaves HEAD
|
|
6766
|
+
* detached, so later commits would stop moving the branch.
|
|
6767
|
+
*
|
|
6768
|
+
* Also the way out when the record of the merge cannot be read, which
|
|
6769
|
+
* would otherwise stop every commit.
|
|
6770
|
+
*/
|
|
6771
|
+
abortMerge(): Promise<void>;
|
|
6772
|
+
/**
|
|
6773
|
+
* Write a directory and everything under it, returning the tree's hash.
|
|
6774
|
+
*
|
|
6775
|
+
* Reads the working tree through ONE `walkEntries`, rather than listing
|
|
6776
|
+
* each directory by path and recursing. The recursion had no guard at all:
|
|
6777
|
+
* a directory record that names itself - which anything holding the seed
|
|
6778
|
+
* can plant - sent `commit` down /loop/loop/loop/... for ever. The walk has
|
|
6779
|
+
* the cycle guard, the budget and the depth ceiling, so a commit records
|
|
6780
|
+
* exactly the tree `status` compares it against.
|
|
6781
|
+
*/
|
|
6422
6782
|
private writeTree;
|
|
6423
6783
|
/** Commits reachable from HEAD, newest first. */
|
|
6424
6784
|
log(limit?: number): Promise<LogEntry[]>;
|
|
@@ -6446,8 +6806,6 @@ declare class Repo {
|
|
|
6446
6806
|
* trees for states nobody chose to keep.
|
|
6447
6807
|
*/
|
|
6448
6808
|
status(): Promise<Change[]>;
|
|
6449
|
-
/** The working tree as a path → entry map, mirroring `filesOf`. */
|
|
6450
|
-
private workingFiles;
|
|
6451
6809
|
/**
|
|
6452
6810
|
* Turn what a person typed into a commit hash.
|
|
6453
6811
|
*
|
|
@@ -6539,6 +6897,11 @@ interface VcsNamespaceOptions {
|
|
|
6539
6897
|
/** The in-memory master seed, or null when locked. Read per call. */
|
|
6540
6898
|
seed: () => Uint8Array | null;
|
|
6541
6899
|
author: () => string;
|
|
6900
|
+
/** See `VcsNamespaceDeps.limits`. */
|
|
6901
|
+
limits?: {
|
|
6902
|
+
entries?: number;
|
|
6903
|
+
pathChars?: number;
|
|
6904
|
+
};
|
|
6542
6905
|
}
|
|
6543
6906
|
|
|
6544
6907
|
/** The hosted Muhkoo Accelerator — the default {@link ClientOptions.baseUrl}. */
|
|
@@ -7865,7 +8228,7 @@ declare function getId(row: {
|
|
|
7865
8228
|
* expect (and isn't serving a stale cached bundle). Keep this in sync with
|
|
7866
8229
|
* `package.json` `version`.
|
|
7867
8230
|
*/
|
|
7868
|
-
declare const VERSION = "0.14.0-alpha.
|
|
8231
|
+
declare const VERSION = "0.14.0-alpha.9";
|
|
7869
8232
|
|
|
7870
8233
|
/**
|
|
7871
8234
|
* The SDK's process-global logger.
|
|
@@ -7897,5 +8260,5 @@ declare global {
|
|
|
7897
8260
|
}
|
|
7898
8261
|
declare const appLogger: InstanceType<typeof Logger>;
|
|
7899
8262
|
|
|
7900
|
-
export { ACCESS_TOKEN_SCOPES, AES_GCM_IV_BYTES, AES_GCM_KEY_BYTES, AES_GCM_TAG_BYTES, AccessTokensNamespace, AgentsNamespace, AuthClient, AuthNamespace, AuthPublicInput, Authenticator, BlockEngine, BroadcastChannel, BroadcastChannelEvents, ChannelExistsError, ChannelNotFoundError, ChunkCipher, CircuitIntegrityError, Client, ConnectivityManager, DEFAULT_AUTH_BASE_URL, DEFAULT_BASE_URL, DEFAULT_BRANCH, DEFAULT_FN_HOST_SUFFIX, DEVICE_IDENTITY_STORAGE_KEY, DEVICE_KEY_DB_NAME, DbCache, DbNamespace, DbTable, DevicePairingError, DeviceRevokedError, DeviceStoreUnavailableError, DoubleRatchet, DoubleRatchetCipher, DoubleRatchetManager, EncryptedSession, EventCore, EventCoreEvents, Field, Field as FieldElement, FileStorage, FunctionsNamespace, HLC, HashKnowledge, HostedAuth, HttpClient, HttpError, IndexedDbStore, KEEPER_MEMBER_ID, KeyStore, KeyringClient, KvCache, KvNamespace, LocalEngineHost, LocalStorageSessionStore, Logger, MemorySessionStore, Message, Message as MessageDefault, MessageNamespace, MuhkooAgent, MuhkooDB, MuhkooFunction, MuhkooSpace, NoopStore, OfflineLockedError, OfflineManager, OutboundQueue, P2P_SUBJECT, PAIRING_CODE_ALPHABET, PAIRING_CODE_LENGTH, PBKDF2_DEFAULT_ITERATIONS, PINNED_CIRCUIT_DIGESTS, PREIMAGE_POK_VERIFICATION_KEY, Packet, PasskeyOriginError, PeerExchange, PeerNetwork, PersonalSpaceClient, Poseidon, PreimagePoK, ROOT_ID, Ready, ReauthRequiredError, ReedSolomonCodec, Repo, Retry, Space as Room, SerializeMessage, SessionState, ShardCache, ShardClient, SharedSpaceClient, SnapshotNamespace, Space, SpaceCache, SpaceKeyring, SpaceNamespace, SpacePacketCipher, SpaceSignaler, StorageNamespace, SyncEngine, VERSION, VFS_ROOT_INFO, VaultUnavailableError, VcsError, VcsNamespace, VfsConflictError, VfsLockedError, VfsNamespace, VfsNotFoundError, WSTransport, WebRtcTransport, WorkerEngineHost, ZERO_HLC, ZkAuth, _accountId, _formatBytes, _messageId, _objectId, _packetId, _socketId, _userId, appLogger, assertType, base58Decode, base58Encode, buildCommitment, canonicalUserCode, clearDeviceIdentity, compareHlc, compilePrograms, concatBytes, configureDeviceStore, createPasskeyWithPrf, decodeFromHex, decorators, decryptAesGcm, defaultCircuitUrls, defaultRpId, defaultSessionStore, deleteBeatsWrite, deleteRegister, deriveAesKeyFromPassphrase, deriveBitsHkdf, deriveIdentity, deriveIdentityFromSeed, deriveMasterSeedFromPassword, deserialize, deviceFingerprint, deviceIdentityIsEphemeral, deviceIdentityKey, dirKey, ejectAgentPrompt, ejectAgentTools, emptyMap, emptyRegister, encodeToHex, encryptAesGcm, evaluatePasskeyPrf, exportPublicKeyBase64, exportPublicKeyHex, formatUserCode, fromBase64, fromBase64Url, fromHex, generateAuthProof, generateChecksum, generateDevicePairingKeypair, generateId, generatePkce, getIPAddress, getId, getMuhkooAppDescriptor, getSubtle, hasDeviceIdentity, headKey, historyKey, initBn128Wasm, initRsWasm, initializeCircuits, isNewer, isNumber, isOfflineCapable, isP2pCapable, isProvisional, loadDeviceIdentity, log, manifestToStat, materializeRow, merge3, merge3Text, mergeKey, mergeMap, mergeMessage, mergeRegister, messageKey, objectKey, pack, padHandle, pairingVerificationCode, passkeyPrfCapable, passkeySupported, passkeyUsableFromOrigin, persistDeviceIdentity, poseidonHash, protocol, provisionalHandle, quickVerify, randomBytes, randomState, refKey, refsIndexKey, rpIdUsableForOrigin, sealSeed, sealSeedToDevice, serialize, shardHash, signMessage, stableStringify, toBase64, toBase64Url, toField, toHex, tombstoneRow, unpack, unsealSeed, unsealSeedFromDevice, unwrapWithPassphrase, utf8Decode, utf8Encode, verify, verifyChecksum, verifyGroth16, verifyHashKnowledge, verifyPreimagePoK, wrapWithPassphrase, writeBeatsTombstone, writeColumns, writeRegister };
|
|
8263
|
+
export { ACCESS_TOKEN_SCOPES, AES_GCM_IV_BYTES, AES_GCM_KEY_BYTES, AES_GCM_TAG_BYTES, AccessTokensNamespace, AgentsNamespace, AuthClient, AuthNamespace, AuthPublicInput, Authenticator, BlockEngine, BroadcastChannel, BroadcastChannelEvents, ChannelExistsError, ChannelNotFoundError, ChunkCipher, CircuitIntegrityError, Client, ConnectivityManager, DEFAULT_AUTH_BASE_URL, DEFAULT_BASE_URL, DEFAULT_BRANCH, DEFAULT_FN_HOST_SUFFIX, DEVICE_IDENTITY_STORAGE_KEY, DEVICE_KEY_DB_NAME, DbCache, DbNamespace, DbTable, DevicePairingError, DeviceRevokedError, DeviceStoreUnavailableError, DoubleRatchet, DoubleRatchetCipher, DoubleRatchetManager, EncryptedSession, EventCore, EventCoreEvents, Field, Field as FieldElement, FileStorage, FunctionsNamespace, HLC, HashKnowledge, HostedAuth, HttpClient, HttpError, IndexedDbStore, KEEPER_MEMBER_ID, KeyStore, KeyringClient, KvCache, KvNamespace, LocalEngineHost, LocalStorageSessionStore, Logger, MemorySessionStore, Message, Message as MessageDefault, MessageNamespace, MuhkooAgent, MuhkooDB, MuhkooFunction, MuhkooSpace, NoopStore, OfflineLockedError, OfflineManager, OutboundQueue, P2P_SUBJECT, PAIRING_CODE_ALPHABET, PAIRING_CODE_LENGTH, PBKDF2_DEFAULT_ITERATIONS, PINNED_CIRCUIT_DIGESTS, PREIMAGE_POK_VERIFICATION_KEY, Packet, PasskeyOriginError, PeerExchange, PeerNetwork, PersonalSpaceClient, Poseidon, PreimagePoK, ROOT_ID, Ready, ReauthRequiredError, ReedSolomonCodec, Repo, Retry, Space as Room, SerializeMessage, SessionState, ShardCache, ShardClient, SharedSpaceClient, SnapshotNamespace, Space, SpaceCache, SpaceKeyring, SpaceNamespace, SpacePacketCipher, SpaceSignaler, StorageNamespace, SyncEngine, VERSION, VFS_ROOT_INFO, VaultUnavailableError, VcsError, VcsNamespace, VfsConflictError, VfsCorruptRecordError, VfsLimitError, VfsLockedError, VfsNamespace, VfsNotFoundError, WSTransport, WebRtcTransport, WorkerEngineHost, ZERO_HLC, ZkAuth, _accountId, _formatBytes, _messageId, _objectId, _packetId, _socketId, _userId, appLogger, assertType, base58Decode, base58Encode, buildCommitment, canonicalUserCode, clearDeviceIdentity, compareHlc, compilePrograms, concatBytes, configureDeviceStore, createPasskeyWithPrf, decodeFromHex, decorators, decryptAesGcm, defaultCircuitUrls, defaultRpId, defaultSessionStore, deleteBeatsWrite, deleteRegister, deriveAesKeyFromPassphrase, deriveBitsHkdf, deriveIdentity, deriveIdentityFromSeed, deriveMasterSeedFromPassword, deserialize, deviceFingerprint, deviceIdentityIsEphemeral, deviceIdentityKey, dirKey, ejectAgentPrompt, ejectAgentTools, emptyMap, emptyRegister, encodeToHex, encryptAesGcm, evaluatePasskeyPrf, exportPublicKeyBase64, exportPublicKeyHex, formatUserCode, fromBase64, fromBase64Url, fromHex, generateAuthProof, generateChecksum, generateDevicePairingKeypair, generateId, generatePkce, getIPAddress, getId, getMuhkooAppDescriptor, getSubtle, hasDeviceIdentity, headKey, historyKey, initBn128Wasm, initRsWasm, initializeCircuits, isNewer, isNumber, isOfflineCapable, isP2pCapable, isProvisional, loadDeviceIdentity, log, manifestToStat, materializeRow, merge3, merge3Text, mergeKey, mergeMap, mergeMessage, mergeRegister, messageKey, objectKey, pack, padHandle, pairingVerificationCode, passkeyPrfCapable, passkeySupported, passkeyUsableFromOrigin, persistDeviceIdentity, poseidonHash, protocol, provisionalHandle, quickVerify, randomBytes, randomState, refKey, refsIndexKey, rpIdUsableForOrigin, sealSeed, sealSeedToDevice, serialize, shardHash, signMessage, stableStringify, toBase64, toBase64Url, toField, toHex, tombstoneRow, unpack, unsealSeed, unsealSeedFromDevice, unwrapWithPassphrase, utf8Decode, utf8Encode, verify, verifyChecksum, verifyGroth16, verifyHashKnowledge, verifyPreimagePoK, wrapWithPassphrase, writeBeatsTombstone, writeColumns, writeRegister };
|
|
7901
8264
|
export type { ACL, ACLEntry, AccessTokenInfo, AccessTokensNamespaceDeps, AgentConfig, AgentCreateInput, AgentDbToolMode, AgentProvisioned, AgentScopeOpts, AgentSkill, AgentToolsConfig, AgentTrigger, AgentTriggerType, AgentUpdateInput, AgentsNamespaceDeps, AttachedPeerNetwork, AuthClientOptions, AuthKeyPair, AuthSuccess, AuthToken, AuthType, AuthUser, BlockStore, Bn128WasmInstance, BroadcastChannelEvent, BroadcastChannelOptions, CachedSpaceMessage, Change, ChannelLike, ChunkKeyMaterial, ChunkManifest, CipherFrame, CipherMessage, CipherMessageHeader, CircuitBufferConfig, CircuitIntegrity, CircuitUrls, ClientOptions, Commit, Conflict, ConnectivityOptions, ConnectivityState, CreateAccessTokenInput, CreatedAccessToken, DbFilterOp, DbNamespaceDeps, DbQuery, DbQueryPage, DbQueryResult, DbWhereCondition, DehydratedKeypair, DehydratedKeys, DeviceBlobStore, DeviceKeyVault, DevicePairingErrorReason, DevicePairingKeypair, DevicePairingPoll, DevicePairingRequest, DevicePairingSession, DirEntry, DirNode, DoubleRatchetCipherDeps, ECDHCurve, EncodeResult, EngineHandle, EngineHost, Entry, EphemeralEvent, EpochKeyProvider, FileEntry, FileManifest, FileNamespaceDeps, FileStat, FileStorageOptions, FunctionCaps, FunctionConfig, FunctionDeployInput, FunctionInvokeOptions, FunctionScopeOpts, FunctionTrigger, FunctionTriggerType, FunctionTriggers, FunctionUpdateInput, FunctionsNamespaceDeps, Groth16Proof, Hasher, Head, HistoryRecord, HlcParts, HlcState, HostedAuthDeps, HttpClientOptions, IncomingFrame, KeyExchangeFrame, KeyPair, Keypair, KeyringClientDeps, KeyringTransport, KvEntry, KvNamespaceDeps, LogEntry, LoginOptions, LwwMap, LwwRegister, Merge3Result, MergeRegionConflict, MergeResult, MessageBody, MessageDeletedEvent, MessageEntry, MessageEvent, MessageHeaders, MessageNamespaceDeps, MessageOp, MessageOptions, MessageSubscription, MuhkooAgentMeta, MuhkooAgentToolsConfig, MuhkooAppDescriptor, MuhkooDBAccess, MuhkooDBMeta, MuhkooFunctionMeta, MuhkooKeystoreBridge, MuhkooMessageEvent, MuhkooSpaceMeta, OAuthProvider, OfflineEntry, OfflineManagerDeps, OfflineStore, OutSink, PacketCipher, PacketHeaders, PacketOptions, PairedDevice, Participant, PasskeyEnrollment, PeerBlockSource, PeerExchangeOptions, PeerId, PeerNetworkOptions, PeerTransport, Permission, PermissionCheckRequest, PermissionCheckResult, PersistedDeviceIdentity, PersonalSpaceClientOptions, Pkce, PublicKeyJWK, QueueEntry, RatchetState, ReceiveResult, RegisterParams, Replayer, Role, SpaceDeps as RoomDeps, SpaceFileMetadata as RoomFileMetadata, Scope, SealedHandoff, SealedHeaders, SealedRecord, Session, SessionOptions, SessionStore, SetOptions, ShardByteCache, ShardClientOptions, SharedSpaceClientOptions, SignalEnvelope, SignalKind, SignalingSpace, SnapshotNamespaceDeps, SnarkProof, SpaceChannelLike, SpaceCursor, SpaceDeps, SpaceFileMetadata, SpaceKeyCache, SpaceKeyringDeps, SpaceMessageEvent, SpaceNamespaceDeps, SpaceOfflineAdapter, StartDevicePairingOptions, StorageChangeEvent, StoreName, StoredSession, Subscription, Tree, TreeDir, TreeEntry, TreeFile, UserIdentity, VaultFactor, VcsNamespaceDeps, VcsNamespaceOptions, VerificationKey, VfsContentStore, VfsNamespaceDeps, VfsStat, VfsStore, WSMessage, WSMessageType, WSTransportOptions, WaitForDevicePairingOptions, WebRtcTransportOptions, WrappedPayload, WriteFileInput, WriteFileOptions, WriteToShardsInput, ZkAuthDeps, ZkAuthenticateRequest, ZkChallengeResponse, ZkCompiled, ZkIdentity, ZkRegisterRequest, ZkRegisterResponse };
|