@tensorix/metahub 0.3.2 → 0.4.0
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 +23 -10
- package/README.zh-CN.md +23 -10
- package/dist/cli/edge-worker-script.d.ts +4 -0
- package/dist/cli/edge-worker-script.d.ts.map +1 -0
- package/dist/cli.js +16882 -8691
- package/dist/cli.js.map +109 -59
- package/dist/core/access-policy.d.ts +82 -0
- package/dist/core/access-policy.d.ts.map +1 -0
- package/dist/core/blobs-core.d.ts +19 -0
- package/dist/core/blobs-core.d.ts.map +1 -1
- package/dist/core/blobs.d.ts.map +1 -1
- package/dist/core/compact.d.ts.map +1 -1
- package/dist/core/config.d.ts +13 -0
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/crdt.d.ts +29 -2
- package/dist/core/crdt.d.ts.map +1 -1
- package/dist/core/data-map.d.ts +105 -0
- package/dist/core/data-map.d.ts.map +1 -0
- package/dist/core/db.d.ts +1 -1
- package/dist/core/db.d.ts.map +1 -1
- package/dist/core/documents.d.ts.map +1 -1
- package/dist/core/errors.d.ts +2 -0
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/grants-core.d.ts +132 -0
- package/dist/core/grants-core.d.ts.map +1 -0
- package/dist/core/guest-intent.d.ts +33 -0
- package/dist/core/guest-intent.d.ts.map +1 -0
- package/dist/core/hash.d.ts +4 -0
- package/dist/core/hash.d.ts.map +1 -0
- package/dist/core/history.d.ts.map +1 -1
- package/dist/core/hlc.d.ts +5 -0
- package/dist/core/hlc.d.ts.map +1 -1
- package/dist/core/ids.d.ts +1 -1
- package/dist/core/ids.d.ts.map +1 -1
- package/dist/core/inject-runtime.d.ts +8 -0
- package/dist/core/inject-runtime.d.ts.map +1 -0
- package/dist/core/intent-retention.d.ts +23 -0
- package/dist/core/intent-retention.d.ts.map +1 -0
- package/dist/core/md/inline.d.ts +6 -2
- package/dist/core/md/inline.d.ts.map +1 -1
- package/dist/core/node.d.ts +13 -0
- package/dist/core/node.d.ts.map +1 -1
- package/dist/core/records.d.ts +31 -0
- package/dist/core/records.d.ts.map +1 -1
- package/dist/core/schema-init.d.ts +19 -2
- package/dist/core/schema-init.d.ts.map +1 -1
- package/dist/core/schema.d.ts +1 -1
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/core/shares.d.ts +15 -0
- package/dist/core/shares.d.ts.map +1 -1
- package/dist/core/site-channel-lifecycle.d.ts +10 -0
- package/dist/core/site-channel-lifecycle.d.ts.map +1 -0
- package/dist/core/site-channel-store.d.ts +120 -0
- package/dist/core/site-channel-store.d.ts.map +1 -0
- package/dist/core/site-channels.d.ts +65 -0
- package/dist/core/site-channels.d.ts.map +1 -0
- package/dist/core/sites-core.d.ts +100 -7
- package/dist/core/sites-core.d.ts.map +1 -1
- package/dist/core/sites.d.ts +65 -2
- package/dist/core/sites.d.ts.map +1 -1
- package/dist/core/sync/anti-abuse.d.ts +26 -0
- package/dist/core/sync/anti-abuse.d.ts.map +1 -0
- package/dist/core/sync/auth.d.ts +30 -2
- package/dist/core/sync/auth.d.ts.map +1 -1
- package/dist/core/sync/blob-routes.d.ts.map +1 -1
- package/dist/core/sync/cf-api.d.ts +54 -0
- package/dist/core/sync/cf-api.d.ts.map +1 -0
- package/dist/core/sync/cf-oauth.d.ts +91 -0
- package/dist/core/sync/cf-oauth.d.ts.map +1 -0
- package/dist/core/sync/client.d.ts +12 -0
- package/dist/core/sync/client.d.ts.map +1 -1
- package/dist/core/sync/data-map-db.d.ts +8 -0
- package/dist/core/sync/data-map-db.d.ts.map +1 -0
- package/dist/core/sync/devices.d.ts +65 -0
- package/dist/core/sync/devices.d.ts.map +1 -0
- package/dist/core/sync/drop-host.d.ts +40 -0
- package/dist/core/sync/drop-host.d.ts.map +1 -0
- package/dist/core/sync/drop-keys.d.ts +64 -0
- package/dist/core/sync/drop-keys.d.ts.map +1 -0
- package/dist/core/sync/drop-protocol.d.ts +94 -0
- package/dist/core/sync/drop-protocol.d.ts.map +1 -0
- package/dist/core/sync/drop-pull.d.ts +67 -0
- package/dist/core/sync/drop-pull.d.ts.map +1 -0
- package/dist/core/sync/drop-wire.d.ts +39 -0
- package/dist/core/sync/drop-wire.d.ts.map +1 -0
- package/dist/core/sync/e2ee.d.ts +3 -0
- package/dist/core/sync/e2ee.d.ts.map +1 -1
- package/dist/core/sync/edge-config.d.ts +77 -0
- package/dist/core/sync/edge-config.d.ts.map +1 -0
- package/dist/core/sync/edge-connect.d.ts +13 -0
- package/dist/core/sync/edge-connect.d.ts.map +1 -0
- package/dist/core/sync/edge-service.d.ts +100 -0
- package/dist/core/sync/edge-service.d.ts.map +1 -0
- package/dist/core/sync/grants-routes.d.ts +46 -0
- package/dist/core/sync/grants-routes.d.ts.map +1 -0
- package/dist/core/sync/guest-session.d.ts +29 -0
- package/dist/core/sync/guest-session.d.ts.map +1 -0
- package/dist/core/sync/html-escape.d.ts +2 -0
- package/dist/core/sync/html-escape.d.ts.map +1 -0
- package/dist/core/sync/http-status.d.ts +14 -0
- package/dist/core/sync/http-status.d.ts.map +1 -0
- package/dist/core/sync/http-util.d.ts +6 -0
- package/dist/core/sync/http-util.d.ts.map +1 -0
- package/dist/core/sync/pairing.d.ts +9 -9
- package/dist/core/sync/pairing.d.ts.map +1 -1
- package/dist/core/sync/partition.d.ts +77 -0
- package/dist/core/sync/partition.d.ts.map +1 -0
- package/dist/core/sync/peers-routes.d.ts.map +1 -1
- package/dist/core/sync/peers.d.ts +77 -0
- package/dist/core/sync/peers.d.ts.map +1 -1
- package/dist/core/sync/protocol.d.ts +2 -0
- package/dist/core/sync/protocol.d.ts.map +1 -1
- package/dist/core/sync/rate-limit.d.ts +20 -0
- package/dist/core/sync/rate-limit.d.ts.map +1 -0
- package/dist/core/sync/recovery.d.ts +9 -0
- package/dist/core/sync/recovery.d.ts.map +1 -0
- package/dist/core/sync/room-client.d.ts +50 -0
- package/dist/core/sync/room-client.d.ts.map +1 -0
- package/dist/core/sync/room-peer.d.ts +62 -0
- package/dist/core/sync/room-peer.d.ts.map +1 -0
- package/dist/core/sync/room-protocol.d.ts +130 -0
- package/dist/core/sync/room-protocol.d.ts.map +1 -0
- package/dist/core/sync/room-serve.d.ts +38 -0
- package/dist/core/sync/room-serve.d.ts.map +1 -0
- package/dist/core/sync/room-url.d.ts +4 -0
- package/dist/core/sync/room-url.d.ts.map +1 -0
- package/dist/core/sync/routes.d.ts +4 -1
- package/dist/core/sync/routes.d.ts.map +1 -1
- package/dist/core/sync/seal.d.ts +22 -0
- package/dist/core/sync/seal.d.ts.map +1 -0
- package/dist/core/sync/server.d.ts +7 -0
- package/dist/core/sync/server.d.ts.map +1 -1
- package/dist/core/sync/share-actions.d.ts +55 -6
- package/dist/core/sync/share-actions.d.ts.map +1 -1
- package/dist/core/sync/share-export.d.ts +14 -0
- package/dist/core/sync/share-export.d.ts.map +1 -1
- package/dist/core/sync/share-render.d.ts +9 -1
- package/dist/core/sync/share-render.d.ts.map +1 -1
- package/dist/core/sync/share-serve.d.ts +5 -1
- package/dist/core/sync/share-serve.d.ts.map +1 -1
- package/dist/core/sync/site-channel-reconcile.d.ts +26 -0
- package/dist/core/sync/site-channel-reconcile.d.ts.map +1 -0
- package/dist/core/sync/site-publish-recovery.d.ts +32 -0
- package/dist/core/sync/site-publish-recovery.d.ts.map +1 -0
- package/dist/core/sync/site-reachability.d.ts +13 -0
- package/dist/core/sync/site-reachability.d.ts.map +1 -0
- package/dist/core/sync/sites-routes.d.ts.map +1 -1
- package/dist/core/sync/sites-serve.d.ts +24 -1
- package/dist/core/sync/sites-serve.d.ts.map +1 -1
- package/dist/core/sync/storage-s3-bun.d.ts +1 -24
- package/dist/core/sync/storage-s3-bun.d.ts.map +1 -1
- package/dist/core/sync/storage-s3-sign.d.ts +43 -0
- package/dist/core/sync/storage-s3-sign.d.ts.map +1 -0
- package/dist/core/sync/storage.d.ts +59 -0
- package/dist/core/sync/storage.d.ts.map +1 -1
- package/dist/db-worker.js +206 -76
- package/dist/edge-worker.js +3960 -0
- package/dist/index.js +13175 -6670
- package/dist/index.js.map +87 -41
- package/dist/metahub-sdk.js +10 -1
- package/dist/mh-runtime.js +1 -1
- package/dist/room/do-driver.d.ts +30 -0
- package/dist/room/do-driver.d.ts.map +1 -0
- package/dist/sw.js +10 -1
- package/dist/webui/server/edge-routes.d.ts +3 -0
- package/dist/webui/server/edge-routes.d.ts.map +1 -0
- package/dist/webui/server/json-handler.d.ts +4 -0
- package/dist/webui/server/json-handler.d.ts.map +1 -0
- package/dist/webui/server/routes.d.ts.map +1 -1
- package/dist/webui/server/share-routes.d.ts.map +1 -1
- package/dist/webui/server/site-hosting-routes.d.ts +7 -0
- package/dist/webui/server/site-hosting-routes.d.ts.map +1 -0
- package/dist/webui.js +192 -137
- package/dist/workers/edge-worker.d.ts +66 -0
- package/dist/workers/edge-worker.d.ts.map +1 -0
- package/dist/workers/room.d.ts +34 -0
- package/dist/workers/room.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -1,33 +1,10 @@
|
|
|
1
1
|
import { type S3Config } from "./storage.ts";
|
|
2
|
-
/** SigV4 presigned GET cap: 7 days (604800s) is the protocol maximum. */
|
|
3
|
-
export declare const MAX_PRESIGN_SECONDS = 604800;
|
|
4
|
-
/**
|
|
5
|
-
* Build a presigned GET URL for one object (used by the object-storage share
|
|
6
|
-
* path — the recipient fetches the ciphertext directly from the bucket, no
|
|
7
|
-
* credential in the link). Addressing mirrors corsEndpoint (virtual-hosted vs
|
|
8
|
-
* path-style). `expiresSec` is clamped to the 7-day SigV4 maximum.
|
|
9
|
-
*/
|
|
10
|
-
export declare function presignGet(config: S3Config, key: string, expiresSec: number): Promise<string>;
|
|
11
|
-
/** Read the bucket's current CORS config (raw XML), or null if none is set. */
|
|
12
|
-
export declare function getBucketCors(config: S3Config): Promise<string | null>;
|
|
13
|
-
/**
|
|
14
|
-
* Build the PutBucketCors XML body from the bucket's current config. PutBucketCors
|
|
15
|
-
* replaces the whole config, so we keep every rule that isn't ours and re-emit our
|
|
16
|
-
* managed rule (id=metahub-pwa). `merge` decides our rule's origins:
|
|
17
|
-
* - false (CLI `peer cors`): SET — exactly `origins` (lets the user shrink/reset).
|
|
18
|
-
* - true (auto-open on bucket-attach): UNION with the managed rule's existing
|
|
19
|
-
* origins, so attaching the same bucket from a second shell/origin (a homelab
|
|
20
|
-
* server origin alongside the official PWA shell) adds to the allow-list
|
|
21
|
-
* instead of clobbering it.
|
|
22
|
-
* A wildcard `*` collapses the set. Pure (no I/O) so it's unit-testable.
|
|
23
|
-
*/
|
|
24
|
-
export declare function buildCorsXml(existing: string | null, origins: string[], merge: boolean): string;
|
|
25
2
|
/**
|
|
26
3
|
* Allow a browser shell served from `origins` to talk to the bucket directly
|
|
27
4
|
* (GET/PUT/HEAD/DELETE) via GET-merge-PUT (see buildCorsXml). `opts.merge` unions
|
|
28
5
|
* with existing managed origins instead of replacing them — used when a second
|
|
29
6
|
* origin attaches the same bucket. Content-MD5 is required by the CORS API
|
|
30
|
-
* (S3 and COS both).
|
|
7
|
+
* (S3 and COS both) — the reason this one operation is Bun-only.
|
|
31
8
|
*/
|
|
32
9
|
export declare function putBucketCors(config: S3Config, origins: string[], opts?: {
|
|
33
10
|
merge?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-s3-bun.d.ts","sourceRoot":"","sources":["../../../src/core/sync/storage-s3-bun.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage-s3-bun.d.ts","sourceRoot":"","sources":["../../../src/core/sync/storage-s3-bun.ts"],"names":[],"mappings":"AAgBA,OAAO,EAOL,KAAK,QAAQ,EACd,MAAM,cAAc,CAAC;AA8FtB;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,QAAQ,EAChB,OAAO,EAAE,MAAM,EAAE,EACjB,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAC7B,OAAO,CAAC,IAAI,CAAC,CAmBf"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AwsClient } from "aws4fetch";
|
|
2
|
+
import { type S3Config } from "./storage.ts";
|
|
3
|
+
/** THE aws4fetch signer for this config — one construction shared by the CAS
|
|
4
|
+
* put, the CORS bootstrap and presignGet, so a signer-config fix can't land in
|
|
5
|
+
* one call site and 403 the others. */
|
|
6
|
+
export declare function awsSigner(config: S3Config): AwsClient;
|
|
7
|
+
/** Bucket-level base URL: virtual-hosted has the bucket in the host already
|
|
8
|
+
* (COS), path-style puts it in the path (R2/MinIO/S3). */
|
|
9
|
+
export declare function bucketBase(config: S3Config): string;
|
|
10
|
+
/** Object URL for one key. Each segment is encoded but the slashes are kept;
|
|
11
|
+
* aws4fetch decodes then canonically re-encodes for the signature, so a valid
|
|
12
|
+
* URL round-trips. One definition, so the signed URL and the fetched URL can't
|
|
13
|
+
* drift apart across runtimes. */
|
|
14
|
+
export declare function objectUrlOf(config: S3Config, key: string): string;
|
|
15
|
+
export declare const MANAGED_CORS_RULE_ID = "metahub-pwa";
|
|
16
|
+
export declare function corsEndpoint(config: S3Config): {
|
|
17
|
+
aws: AwsClient;
|
|
18
|
+
url: string;
|
|
19
|
+
};
|
|
20
|
+
/** SigV4 presigned GET cap: 7 days (604800s) is the protocol maximum. */
|
|
21
|
+
export declare const MAX_PRESIGN_SECONDS = 604800;
|
|
22
|
+
/**
|
|
23
|
+
* Build a presigned GET URL for one object (used by the object-storage share
|
|
24
|
+
* path — the recipient fetches the ciphertext directly from the bucket, no
|
|
25
|
+
* credential in the link). Addressing mirrors corsEndpoint (virtual-hosted vs
|
|
26
|
+
* path-style). `expiresSec` is clamped to the 7-day SigV4 maximum.
|
|
27
|
+
*/
|
|
28
|
+
export declare function presignGet(config: S3Config, key: string, expiresSec: number): Promise<string>;
|
|
29
|
+
/** Read the bucket's current CORS config (raw XML), or null if none is set. */
|
|
30
|
+
export declare function getBucketCors(config: S3Config): Promise<string | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Build the PutBucketCors XML body from the bucket's current config. PutBucketCors
|
|
33
|
+
* replaces the whole config, so we keep every rule that isn't ours and re-emit our
|
|
34
|
+
* managed rule (id=metahub-pwa). `merge` decides our rule's origins:
|
|
35
|
+
* - false (CLI `peer cors`): SET — exactly `origins` (lets the user shrink/reset).
|
|
36
|
+
* - true (auto-open on bucket-attach): UNION with the managed rule's existing
|
|
37
|
+
* origins, so attaching the same bucket from a second shell/origin (a homelab
|
|
38
|
+
* server origin alongside the official PWA shell) adds to the allow-list
|
|
39
|
+
* instead of clobbering it.
|
|
40
|
+
* A wildcard `*` collapses the set. Pure (no I/O) so it's unit-testable.
|
|
41
|
+
*/
|
|
42
|
+
export declare function buildCorsXml(existing: string | null, origins: string[], merge: boolean): string;
|
|
43
|
+
//# sourceMappingURL=storage-s3-sign.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-s3-sign.d.ts","sourceRoot":"","sources":["../../../src/core/sync/storage-s3-sign.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAwB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEnE;;wCAEwC;AACxC,wBAAgB,SAAS,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,CAOrD;AAED;2DAC2D;AAC3D,wBAAgB,UAAU,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,CAGnD;AAED;;;mCAGmC;AACnC,wBAAgB,WAAW,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjE;AAWD,eAAO,MAAM,oBAAoB,gBAAgB,CAAC;AAElD,wBAAgB,YAAY,CAAC,MAAM,EAAE,QAAQ,GAAG;IAAE,GAAG,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAE9E;AA6BD,yEAAyE;AACzE,eAAO,MAAM,mBAAmB,SAAS,CAAC;AAE1C;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAMnG;AAED,+EAA+E;AAC/E,wBAAsB,aAAa,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAS5E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAoB/F"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DbDriver } from "../driver.ts";
|
|
2
2
|
import type { SyncResult } from "./client.ts";
|
|
3
|
+
import { type KeyEnvelope } from "./e2ee.ts";
|
|
3
4
|
/** An 's3' peer's bucket settings, stored as JSON in peers.config (local-only). */
|
|
4
5
|
export interface S3Config {
|
|
5
6
|
endpoint: string;
|
|
@@ -48,6 +49,12 @@ export interface StoragePutOpts {
|
|
|
48
49
|
* compare-and-set so two devices initializing the same empty bucket can't
|
|
49
50
|
* clobber each other's master key. */
|
|
50
51
|
ifNoneMatch?: boolean;
|
|
52
|
+
/** Conditional overwrite (S3 `If-Match: <etag>`): fail with MhError("conflict")
|
|
53
|
+
* if the object's current ETag differs from this one — a compare-and-set for
|
|
54
|
+
* read-modify-write updates (drop-key rotation) so a concurrent writer can't
|
|
55
|
+
* silently clobber the loser's freshly-appended key. Both real clients honor
|
|
56
|
+
* it; a mock that ignores it simply performs an unconditional put. */
|
|
57
|
+
ifMatch?: string;
|
|
51
58
|
}
|
|
52
59
|
/** The minimal object-store surface storage-sync needs. Implemented per runtime:
|
|
53
60
|
* Bun.S3Client on the CLI/desktop (storage-s3-bun.ts), aws4fetch SigV4 + fetch
|
|
@@ -67,6 +74,26 @@ type StorageClientFactory = (config: S3Config) => StorageClient;
|
|
|
67
74
|
/** Register this runtime's S3 client builder (see the per-runtime impls). */
|
|
68
75
|
export declare function setStorageClientFactory(f: StorageClientFactory): void;
|
|
69
76
|
export declare function storageClientFor(config: S3Config): StorageClient;
|
|
77
|
+
/** Open a bucket's CORS for browser origins (PutBucketCors). Same runtime-adapter
|
|
78
|
+
* shape as the client factory, but unlike list/get/put/del this one has NO
|
|
79
|
+
* browser implementation and never will: PutBucketCors needs a Content-MD5 that
|
|
80
|
+
* WebCrypto can't produce, and the call would itself be a cross-origin request
|
|
81
|
+
* the bucket hasn't whitelisted yet. So a device holding the credentials opens
|
|
82
|
+
* CORS on the browser's behalf (see storage-s3-bun.ts). */
|
|
83
|
+
export type BucketCorsAdmin = (config: S3Config, origins: string[], opts?: {
|
|
84
|
+
merge?: boolean;
|
|
85
|
+
}) => Promise<void>;
|
|
86
|
+
export declare function setBucketCorsAdmin(f: BucketCorsAdmin): void;
|
|
87
|
+
/** null on runtimes that structurally can't do this (the browser replica) —
|
|
88
|
+
* callers report that honestly instead of pretending CORS was opened. */
|
|
89
|
+
export declare function bucketCorsAdmin(): BucketCorsAdmin | null;
|
|
90
|
+
/** The bucket's normalized namespace root for a configured prefix — exported so
|
|
91
|
+
* sibling namespaces (drop keys, publisher lease) key off the same layout. */
|
|
92
|
+
export declare function storageBasePrefix(prefix: string): string;
|
|
93
|
+
/** Object key of the write-inbox recipient keyring (drop-keys.ts): the wrapped
|
|
94
|
+
* P-256 private keys live next to keys/main.json, bucket-authoritative so any
|
|
95
|
+
* elected device can decrypt inbox envelopes. */
|
|
96
|
+
export declare function dropKeysObjectKey(prefix: string): string;
|
|
70
97
|
/** Upload a blob's bytes to the bucket (idempotent via If-None-Match). Returns
|
|
71
98
|
* true when actually written, false when the object already existed. */
|
|
72
99
|
export declare function putBucketBlob(config: S3Config, hash: string, bytes: Uint8Array): Promise<boolean>;
|
|
@@ -78,6 +105,12 @@ export declare function putBucketBlob(config: S3Config, hash: string, bytes: Uin
|
|
|
78
105
|
export declare function listBucketBlobHashes(config: S3Config): Promise<Set<string>>;
|
|
79
106
|
/** Fetch a blob's bytes from the bucket, or null if absent. */
|
|
80
107
|
export declare function getBucketBlob(config: S3Config, hash: string): Promise<Uint8Array | null>;
|
|
108
|
+
/** Discover the node prefixes under oplog/. Asks for a delimited (one-level)
|
|
109
|
+
* listing so a backend that honors it returns just the "<node>/" folders
|
|
110
|
+
* instead of every segment; nodesFromKeys derives the same node set whether the
|
|
111
|
+
* backend collapsed them or returned full keys. Exported for the device roster
|
|
112
|
+
* (sync/devices.ts refreshBucketPresence). */
|
|
113
|
+
export declare function listRemoteNodes(client: StorageClient, base: string): Promise<string[]>;
|
|
81
114
|
/**
|
|
82
115
|
* Resolve the master key for a bucket at setup: read keys/main.json and unwrap
|
|
83
116
|
* with the passphrase, or — when absent — generate a key, wrap it, and upload
|
|
@@ -86,6 +119,32 @@ export declare function getBucketBlob(config: S3Config, hash: string): Promise<U
|
|
|
86
119
|
* Wrong passphrase throws `auth` (from unwrapMasterKey).
|
|
87
120
|
*/
|
|
88
121
|
export declare function provisionMasterKey(client: StorageClient, config: S3Config, passphrase: string): Promise<string | null>;
|
|
122
|
+
/** Current ETag of one object via a targeted list, or null when absent / the
|
|
123
|
+
* client doesn't surface etags (callers then forgo CAS). */
|
|
124
|
+
export declare function objectEtag(client: StorageClient, key: string): Promise<string | null>;
|
|
125
|
+
/** The bucket's wrapped-master-key envelope, or null when absent. Read-only —
|
|
126
|
+
* unlike provisionMasterKey this never creates one (rotate flows must not
|
|
127
|
+
* mint a fresh K that mismatches existing ciphertext). */
|
|
128
|
+
export declare function readMasterKeyEnvelope(client: StorageClient, config: S3Config): Promise<KeyEnvelope | null>;
|
|
129
|
+
/**
|
|
130
|
+
* Prove `rawKey` is THIS bucket's master key by decrypting a small existing
|
|
131
|
+
* ciphertext object (a snapshot's .vc sidecar, else any segment, else a
|
|
132
|
+
* snapshot body) — the GCM tag makes success a cryptographic verdict. Returns
|
|
133
|
+
* "no_ciphertext" for a bucket holding no encrypted objects yet (fresh/empty);
|
|
134
|
+
* callers proceed with a warning. Throws MhError("auth") on a mismatch — the
|
|
135
|
+
* guard that keeps a *valid key for the wrong bucket* (recovery-code mixups)
|
|
136
|
+
* from rewrapping this bucket's envelope and bricking future joins.
|
|
137
|
+
*/
|
|
138
|
+
export declare function verifyMasterKey(client: StorageClient, config: S3Config, rawKey: Uint8Array): Promise<"verified" | "no_ciphertext">;
|
|
139
|
+
/**
|
|
140
|
+
* Rewrap keys/main.json under a NEW passphrase, keeping K unchanged — all
|
|
141
|
+
* ciphertext and every device's cached K stay valid; only devices joining
|
|
142
|
+
* later need the new passphrase. Compare-and-set: If-Match on the current
|
|
143
|
+
* envelope's ETag (If-None-Match create when absent — which also restores a
|
|
144
|
+
* deleted envelope). Throws "conflict" when a concurrent rewrap won; callers
|
|
145
|
+
* retry against the winner (idempotent — same K).
|
|
146
|
+
*/
|
|
147
|
+
export declare function rewrapMasterKey(client: StorageClient, config: S3Config, rawKey: Uint8Array, newPassphrase: string): Promise<void>;
|
|
89
148
|
/**
|
|
90
149
|
* Publish a winners-only snapshot and truncate this node's own segments. Every
|
|
91
150
|
* op we've uploaded so far is in the local oplog now, so the snapshot (winners
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/core/sync/storage.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAK7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/core/sync/storage.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAK7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAQL,KAAK,WAAW,EACjB,MAAM,WAAW,CAAC;AAQnB,mFAAmF;AACnF,MAAM,WAAW,QAAQ;IACvB,QAA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