@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
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { GrantSet, GrantPrincipal, PayloadLimits } from "./grants-core.ts";
|
|
2
|
+
/** The Turnstile / password write gate, normalized from whichever store holds
|
|
3
|
+
* it. Both are optional; absent = open submission for that factor. */
|
|
4
|
+
export interface WriteGate {
|
|
5
|
+
turnstile?: {
|
|
6
|
+
sitekey?: string;
|
|
7
|
+
secret?: string;
|
|
8
|
+
};
|
|
9
|
+
/** PBKDF2 verifier + its published salt (the password itself never travels). */
|
|
10
|
+
password?: {
|
|
11
|
+
saltB64: string;
|
|
12
|
+
verifierB64: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface AccessPolicy {
|
|
16
|
+
/** Gates the relation-write policy in assertGuestPayload (public forbids). */
|
|
17
|
+
audience: GrantPrincipal["kind"];
|
|
18
|
+
grants: GrantSet;
|
|
19
|
+
writeGate: WriteGate;
|
|
20
|
+
limits: PayloadLimits;
|
|
21
|
+
/** Monotonic policy version — 0 until Stage 5 wires real revisions. */
|
|
22
|
+
revision: number;
|
|
23
|
+
/** epoch ms; null = never expires. */
|
|
24
|
+
expiresAt: number | null;
|
|
25
|
+
/** Base guest node id every write is attributed under (per-visitor sub ids
|
|
26
|
+
* hang off it); null on the public site surface (derived per serving node). */
|
|
27
|
+
guestBase: string | null;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A deterministic fingerprint of the CLIENT-OBSERVABLE policy content —
|
|
31
|
+
* grants, public write-gate configuration, expiry and audience. Secrets and
|
|
32
|
+
* password verifiers are deliberately excluded: policyRevision is published,
|
|
33
|
+
* and must not become an offline password oracle. Password rotations mint a new
|
|
34
|
+
* public salt; Turnstile client configuration is identified by its public
|
|
35
|
+
* sitekey. Secret-only rotation therefore leaves the client contract unchanged.
|
|
36
|
+
*
|
|
37
|
+
* Node-independent and content-addressed (not a monotonic counter): a revert to
|
|
38
|
+
* a prior public policy yields the prior revision. FNV-1a-32 over a canonical
|
|
39
|
+
* string (grants are already normalized + sorted by parseGrantSet).
|
|
40
|
+
*/
|
|
41
|
+
export declare function computeRevision(policy: Pick<AccessPolicy, "audience" | "grants" | "writeGate" | "expiresAt">): number;
|
|
42
|
+
/** Verify a candidate password against a policy's write gate (constant-time,
|
|
43
|
+
* same PBKDF2 params as share unlock). No password gate → always true. */
|
|
44
|
+
export declare function verifyPolicyPassword(policy: AccessPolicy, password: string): Promise<boolean>;
|
|
45
|
+
/** Shape needed to resolve a site policy without importing the whole site row
|
|
46
|
+
* reader here (keeps this module free of sites-core's heavier deps). */
|
|
47
|
+
export interface SitePolicySource {
|
|
48
|
+
publicGrants: string | null;
|
|
49
|
+
/** From getDropKnobs(db, siteId) — may be null. */
|
|
50
|
+
knobs: {
|
|
51
|
+
turnstileSitekey?: string;
|
|
52
|
+
turnstileSecret?: string;
|
|
53
|
+
passwordSalt?: string;
|
|
54
|
+
passwordVerifier?: string;
|
|
55
|
+
} | null;
|
|
56
|
+
}
|
|
57
|
+
/** Public site policy: grants from the synced register, write gate from the
|
|
58
|
+
* node-local drop knobs. No expiry (a site is public until unpublished);
|
|
59
|
+
* guestBase null (publicGuestNode is derived per serving node by the caller). */
|
|
60
|
+
export declare function policyForSite(src: SitePolicySource): AccessPolicy;
|
|
61
|
+
/** Shape needed to resolve a share policy (a subset of ShareRow). */
|
|
62
|
+
export interface SharePolicySource {
|
|
63
|
+
grants: string | null;
|
|
64
|
+
pw_salt: string | null;
|
|
65
|
+
pw_hash: string | null;
|
|
66
|
+
expires_at: number | null;
|
|
67
|
+
guest_node_id: string | null;
|
|
68
|
+
}
|
|
69
|
+
/** Share-link policy: grants + password from the node-local share row. A share
|
|
70
|
+
* has no Turnstile gate (the capability slug + optional password IS the gate). */
|
|
71
|
+
export declare function policyForShare(src: SharePolicySource): AccessPolicy;
|
|
72
|
+
/** Shape needed to resolve a room policy (a subset of RoomConfig). */
|
|
73
|
+
export interface RoomPolicySource {
|
|
74
|
+
grants: string;
|
|
75
|
+
pwHash?: string | null;
|
|
76
|
+
pwSalt?: string | null;
|
|
77
|
+
expiresAt?: number | null;
|
|
78
|
+
guestBase: string;
|
|
79
|
+
}
|
|
80
|
+
/** DO-room policy: same shape, sourced from the room config JSON. */
|
|
81
|
+
export declare function policyForRoom(src: RoomPolicySource): AccessPolicy;
|
|
82
|
+
//# sourceMappingURL=access-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access-policy.d.ts","sourceRoot":"","sources":["../../src/core/access-policy.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAKhF;uEACuE;AACvE,MAAM,WAAW,SAAS;IACxB,SAAS,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAClD,gFAAgF;IAChF,QAAQ,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,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C;IAC1B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED;mFACmF;AACnF,wBAAgB,cAAc,CAAC,GAAG,EAAE,iBAAiB,GAAG,YAAY,CAUnE;AAED,sEAAsE;AACtE,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qEAAqE;AACrE,wBAAgB,aAAa,CAAC,GAAG,EAAE,gBAAgB,GAAG,YAAY,CAUjE"}
|
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
import type { DbDriver } from "./driver.ts";
|
|
2
2
|
export declare const POLICY_ID = "default";
|
|
3
|
+
/** Fetch a blob's bytes by content hash, from wherever this runtime can reach
|
|
4
|
+
* them. Registered per runtime (same adapter shape as room-peer.ts's
|
|
5
|
+
* registerRoomBlobResolver): Bun resolves local cache → HTTP peers → buckets
|
|
6
|
+
* (blobs.ts resolveBlob), the browser replica resolves OPFS spool → buckets
|
|
7
|
+
* (db-worker.ts browserRoomBlob). Declared here, in the driver-only half, so
|
|
8
|
+
* runtime-neutral callers reachable from BOTH the server and the browser
|
|
9
|
+
* (share-export.ts) can ask for bytes without importing blobs.ts — which would
|
|
10
|
+
* drag node:fs / Bun.file into the browser bundle. */
|
|
11
|
+
export type BlobBytesResolver = (db: DbDriver, hash: string) => Promise<Uint8Array | null>;
|
|
12
|
+
/** `null` unregisters (tests restoring global state; a runtime tearing down). */
|
|
13
|
+
export declare function setBlobBytesResolver(f: BlobBytesResolver | null): void;
|
|
14
|
+
/** Bytes for `hash`, or null when unreachable — or when no resolver is
|
|
15
|
+
* registered (treated like "unreachable": callers already skip blobs they
|
|
16
|
+
* can't fetch rather than failing the whole operation). */
|
|
17
|
+
export declare function resolveBlobBytes(db: DbDriver, hash: string): Promise<Uint8Array | null>;
|
|
18
|
+
/** Whether this runtime wired up a resolver at all. Callers that would otherwise
|
|
19
|
+
* read "no resolver" as "every blob is unreachable" check this first, so a
|
|
20
|
+
* wiring mistake fails loudly instead of silently shipping a blob-less result. */
|
|
21
|
+
export declare function hasBlobBytesResolver(): boolean;
|
|
3
22
|
export type Redundancy = "all" | "any";
|
|
4
23
|
export interface BlobPolicy {
|
|
5
24
|
fullNodes: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blobs-core.d.ts","sourceRoot":"","sources":["../../src/core/blobs-core.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,eAAO,MAAM,SAAS,YAAY,CAAC;AAEnC,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,KAAK,CAAC;AAEvC,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,wEAAwE;IACxE,MAAM,EAAE,MAAM,CAAC;IACf,gFAAgF;IAChF,OAAO,EAAE,MAAM,CAAC;IAChB;uFACmF;IACnF,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,cAAc,EAAE,MAAM,CAAC;IACvB,kFAAkF;IAClF,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;CACxB;AAID,wBAAgB,UAAU,CAAC,EAAE,EAAE,QAAQ,G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ACf;AAED;oEACoE;AACpE,wBAAgB,UAAU,CAAC,EAAE,EAAE,QAAQ,GAAG,SAAS,EAAE,CAapD"}
|
package/dist/core/blobs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blobs.d.ts","sourceRoot":"","sources":["../../src/core/blobs.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"blobs.d.ts","sourceRoot":"","sources":["../../src/core/blobs.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAuB5C,cAAc,iBAAiB,CAAC;AAEhC,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED;;;8EAG8E;AAC9E,wBAAgB,YAAY,CAAC,EAAE,EAAE,QAAQ,GAAG,WAAW,EAAE,CAYxD;AAWD;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAgCxF;AAUD,MAAM,WAAW,YAAY;IAC3B,8EAA8E;IAC9E,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB;oFACgF;IAChF,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC;CACZ;AAqBD;;;;;;;;;;;GAWG;AACH,wBAAsB,oBAAoB,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,CAoD9E;AAED,MAAM,WAAW,qBAAqB;IACpC,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,OAAO,EAAE,MAA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oot":"","sources":["../../src/core/compact.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"compact.d.ts","sourceRoot":"","sources":["../../src/core/compact.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAkC3C,MAAM,WAAW,aAAa;IAC5B,oFAAoF;IACpF,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,yEAAyE;IACzE,QAAQ,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,yEAAyE;IACzE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,wCAAwC;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAsBD,wBAAgB,YAAY,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,cAAc,GAAG,aAAa,CAsD9E;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CACrB,EAAE,EAAE,QAAQ,EACZ,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC9B;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CA2DpC;AAED;0CAC0C;AAC1C,wBAAgB,eAAe,CAC7B,EAAE,EAAE,QAAQ,EACZ,QAAQ,EAAE,MAAM,EAChB,GAAG,SAAa,GACf;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAa1E"}
|
package/dist/core/config.d.ts
CHANGED
|
@@ -12,8 +12,21 @@ export interface ServerConfig {
|
|
|
12
12
|
/** Local blob cache quota in bytes. When the cache exceeds it, the sync tick
|
|
13
13
|
* auto-evicts clearable, unpinned blobs (LRU). <= 0 disables eviction. */
|
|
14
14
|
blobCacheQuotaBytes: number;
|
|
15
|
+
/** Reachable base used for site/share links. Node-local and never synced. */
|
|
16
|
+
publicBaseUrl: string | null;
|
|
15
17
|
}
|
|
16
18
|
export declare const DEFAULT_CONFIG: ServerConfig;
|
|
19
|
+
export type PublicBaseScope = "local" | "lan" | "public";
|
|
20
|
+
/** Literal metadata endpoints that must never be used as a hosting target.
|
|
21
|
+
* Hostname-based SSRF is still constrained by the owner-only route and the
|
|
22
|
+
* no-redirect policy in site-hosting-routes.ts. */
|
|
23
|
+
export declare function isCloudMetadataHost(hostInput: string): boolean;
|
|
24
|
+
/** Normalize and classify a site-hosting base. HTTP is deliberately limited
|
|
25
|
+
* to loopback/private networks; an Internet-facing base must terminate TLS. */
|
|
26
|
+
export declare function normalizePublicBaseUrl(input: string): {
|
|
27
|
+
url: string;
|
|
28
|
+
scope: PublicBaseScope;
|
|
29
|
+
};
|
|
17
30
|
/** Persisted server config, falling back to DEFAULT_CONFIG per field. */
|
|
18
31
|
export declare function getServerConfig(db: DbDriver): ServerConfig;
|
|
19
32
|
/** Persist a partial config update. Only provided fields are written. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C;;2FAE2F;AAC3F,eAAO,MAAM,qBAAqB,QAAmE,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C;;2FAE2F;AAC3F,eAAO,MAAM,qBAAqB,QAAmE,CAAC;AAStG,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB;+EAC2E;IAC3E,mBAAmB,EAAE,MAAM,CAAC;IAC5B,6EAA6E;IAC7E,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,eAAO,MAAM,cAAc,EAAE,YAO5B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;AA8CzD;;mDAEmD;AACnD,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAQ9D;AAED;gFACgF;AAChF,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG;IACrD,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,eAAe,CAAC;CACxB,CAqBA;AAeD,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,EAAE,EAAE,QAAQ,GAAG,YAAY,CAgB1D;AAED,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,YAAY,CAa1F"}
|
package/dist/core/crdt.d.ts
CHANGED
|
@@ -24,8 +24,29 @@ export declare function withNodeId<T>(node: string | null, fn: () => T): T;
|
|
|
24
24
|
* prefixes the id ("repair:", "revert:") so history can classify the source.
|
|
25
25
|
*/
|
|
26
26
|
export declare function withChangeGroup<T>(label: string | null, fn: () => T): T;
|
|
27
|
+
/**
|
|
28
|
+
* Run `fn` with all emits stamped with an EXPLICIT, caller-supplied txn id (no
|
|
29
|
+
* random suffix) — the deterministic sibling of withChangeGroup. A guest write
|
|
30
|
+
* carries a client-minted intentId; stamping its ops with the GuestIntent
|
|
31
|
+
* executor's guest-scoped txn key makes a retried submission idempotent instead
|
|
32
|
+
* of double-creating. Same single-threaded-mutator invariant as
|
|
33
|
+
* withNodeId/withChangeGroup — set/clear around one synchronous mutator call.
|
|
34
|
+
* Nested inside its own group (createRecord's grouped()) the explicit id wins,
|
|
35
|
+
* because withChangeGroup early-returns when a txn is already set.
|
|
36
|
+
*/
|
|
37
|
+
export declare function withTxnId<T>(txn: string, fn: () => T): T;
|
|
27
38
|
/** Wrap a mutator so its body runs inside one change group. */
|
|
28
39
|
export declare function grouped<A extends unknown[], R>(fn: (...args: A) => R, label?: string | null): (...args: A) => R;
|
|
40
|
+
export declare const DOMAIN: Record<string, {
|
|
41
|
+
table: string;
|
|
42
|
+
cols: Set<string>;
|
|
43
|
+
}>;
|
|
44
|
+
export declare const RECORD_META: Set<string>;
|
|
45
|
+
/** Replicated registers that intentionally have no materialized state table.
|
|
46
|
+
* They remain in the oplog/snapshots as protocol state; a protocol may impose
|
|
47
|
+
* its own retention window at the replication boundary. */
|
|
48
|
+
export declare const OPLOG_ONLY_DATASETS: ReadonlySet<string>;
|
|
49
|
+
export declare const NOT_NULL_ZERO_COLS: Set<string>;
|
|
29
50
|
/** Outcome of applying one change to the oplog. `inserted` reports whether the
|
|
30
51
|
* oplog actually gained a NEW row (false when we already had this exact change —
|
|
31
52
|
* the INSERT OR IGNORE was a no-op); it is the honest "did we receive new data"
|
|
@@ -53,9 +74,13 @@ export declare function emitFields(db: DbDriver, dataset: string, rowId: string,
|
|
|
53
74
|
* the honest "received" count. Re-ingesting data we already hold returns 0, so
|
|
54
75
|
* this is a reliable progress signal for the auto-sync backoff (a round that
|
|
55
76
|
* only re-reads known data must not count as activity). */
|
|
56
|
-
export declare function ingest(db: DbDriver, changes: Change[]
|
|
77
|
+
export declare function ingest(db: DbDriver, changes: Change[], opts?: {
|
|
78
|
+
now?: number;
|
|
79
|
+
}): number;
|
|
57
80
|
/** All oplog changes with HLC strictly greater than `since` (test/debug helper). */
|
|
58
|
-
export declare function changesSince(db: DbDriver, since: string
|
|
81
|
+
export declare function changesSince(db: DbDriver, since: string, opts?: {
|
|
82
|
+
now?: number;
|
|
83
|
+
}): Change[];
|
|
59
84
|
export interface ChangeBatch {
|
|
60
85
|
changes: Change[];
|
|
61
86
|
cursor: number;
|
|
@@ -73,6 +98,8 @@ export interface ChangesAfterOpts {
|
|
|
73
98
|
* ops are skipped once, not rescanned every round.
|
|
74
99
|
*/
|
|
75
100
|
onlyNode?: string;
|
|
101
|
+
/** Test hook and receipt-retention reference time. */
|
|
102
|
+
now?: number;
|
|
76
103
|
}
|
|
77
104
|
/**
|
|
78
105
|
* Changes inserted after `seq` (a local rowid), in insertion order, plus the
|
package/dist/core/crdt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crdt.d.ts","sourceRoot":"","sources":["../../src/core/crdt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"crdt.d.ts","sourceRoot":"","sources":["../../src/core/crdt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAkB5C,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,kFAAkF;AAClF,eAAO,MAAM,WAAW,yEAA0E,CAAC;AAEnG,eAAO,MAAM,aAAa,QAAyB,CAAC;AAapD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,G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AU,CACxB,EAAE,EAAE,QAAQ,EACZ,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,MAAM,EAAE,CAMV;AAED;;;;4DAI4D;AAC5D,wBAAgB,MAAM,CACpB,EAAE,EAAE,QAAQ,EACZ,OAAO,EAAE,MAAM,EAAE,EACjB,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GAC1B,MAAM,CA4BR;AAED,oFAAoF;AACpF,wBAAgB,YAAY,CAC1B,EAAE,EAAE,QAAQ,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GAC1B,MAAM,EAAE,CAKV;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sDAAsD;IACtD,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,EAAE,EAAE,QAAQ,EACZ,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,gBAAqB,GAC1B,WAAW,CAuCb"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/** One outbound sync target, pre-fetched by the caller (peers row + parsed
|
|
2
|
+
* s3 config extras). Room peers must be excluded by the caller — a room holds
|
|
3
|
+
* one share's partition, not the workspace. */
|
|
4
|
+
export interface DataMapPeerInput {
|
|
5
|
+
url: string;
|
|
6
|
+
kind: "http" | "s3";
|
|
7
|
+
label: string | null;
|
|
8
|
+
nodeId: string | null;
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
/** Last successful sync (freshness gates use this, never last attempt). */
|
|
11
|
+
lastSuccessAt: number | null;
|
|
12
|
+
lastStatus: string | null;
|
|
13
|
+
lastError: string | null;
|
|
14
|
+
/** Highest local sequence durably acknowledged by this target. */
|
|
15
|
+
pushCursor: number;
|
|
16
|
+
/** s3 only: bucket name from config (display fallback). */
|
|
17
|
+
bucket?: string | null;
|
|
18
|
+
/** s3 only: this node is configured to publish full snapshots to it. */
|
|
19
|
+
publish?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface DataMapInput {
|
|
22
|
+
selfNodeId: string;
|
|
23
|
+
selfLabel: string | null;
|
|
24
|
+
peers: DataMapPeerInput[];
|
|
25
|
+
/** Count/bytes of blobs produced here not yet flushed to a durable anchor. */
|
|
26
|
+
pendingBlobCount: number;
|
|
27
|
+
pendingBlobBytes: number;
|
|
28
|
+
/** Designated full-blob anchors: node ids and/or bucket s3:// urls. */
|
|
29
|
+
blobFullNodes: string[];
|
|
30
|
+
/** Latest sequence in the whole local oplog (HTTP peers replicate this). */
|
|
31
|
+
globalHighWaterSeq: number;
|
|
32
|
+
/** Latest sequence authored by this node (S3 publishes per-node streams). */
|
|
33
|
+
ownHighWaterSeq: number;
|
|
34
|
+
/** A current copy older than this is shown as stale, not healthy. */
|
|
35
|
+
staleAfterMs?: number;
|
|
36
|
+
now?: number;
|
|
37
|
+
}
|
|
38
|
+
/** One place holding (or configured to hold) a copy of the workspace. */
|
|
39
|
+
export interface DataPlace {
|
|
40
|
+
kind: "self" | "device" | "bucket";
|
|
41
|
+
/** Peer url; null for self. */
|
|
42
|
+
url: string | null;
|
|
43
|
+
/** Display name: label ?? bucket ?? url host segment. */
|
|
44
|
+
label: string;
|
|
45
|
+
/**
|
|
46
|
+
* live — this node's own library (always current)
|
|
47
|
+
* current — target acknowledged the relevant local high-water mark
|
|
48
|
+
* behind — target holds an older copy but local changes are unacknowledged
|
|
49
|
+
* stale — cursor is current, but the last confirmation is too old
|
|
50
|
+
* error — last sync failed (lastError says why); may still hold old data
|
|
51
|
+
* never — configured but no successful sync yet (holds nothing)
|
|
52
|
+
* disabled — configured but turned off
|
|
53
|
+
*/
|
|
54
|
+
freshness: "live" | "current" | "behind" | "stale" | "error" | "never" | "disabled";
|
|
55
|
+
syncedAt: number | null;
|
|
56
|
+
error: string | null;
|
|
57
|
+
acknowledgedSeq: number;
|
|
58
|
+
highWaterSeq: number;
|
|
59
|
+
lag: number;
|
|
60
|
+
/**
|
|
61
|
+
* replica — a full node (device) holding the whole workspace
|
|
62
|
+
* backend — a dumb bucket store (holds segments/snapshots, not queryable)
|
|
63
|
+
* blob_anchor — designated durable full-blob library
|
|
64
|
+
* publisher — bucket only: THIS node is configured as its snapshot
|
|
65
|
+
* publisher (static config flag; live election is bucket-side
|
|
66
|
+
* and not knowable offline — surfaces say "configured as").
|
|
67
|
+
*/
|
|
68
|
+
roles: ("replica" | "backend" | "blob_anchor" | "publisher")[];
|
|
69
|
+
}
|
|
70
|
+
/** Precedence-ordered summary. Attention states first (something needs the
|
|
71
|
+
* user), then transitional, then quiescent. */
|
|
72
|
+
export type DataMapStateKind = "no_backup" | "pending_blobs" | "unsynced_changes" | "peer_error" | "syncing" | "stale" | "healthy";
|
|
73
|
+
/** One concrete problem, kept alongside the single headline `state` so
|
|
74
|
+
* concurrent issues (a failing peer AND unsynced changes) are never masked by
|
|
75
|
+
* precedence — the headline picks one, `issues` lists them all. */
|
|
76
|
+
export interface DataMapIssue {
|
|
77
|
+
kind: "no_backup" | "peer_error" | "never_synced" | "behind" | "stale" | "pending_blobs";
|
|
78
|
+
/** Peer url the issue is about; null for workspace-level issues. */
|
|
79
|
+
placeUrl: string | null;
|
|
80
|
+
placeLabel: string | null;
|
|
81
|
+
/** peer_error carries lastError; others null. */
|
|
82
|
+
message: string | null;
|
|
83
|
+
}
|
|
84
|
+
export interface DataMapState {
|
|
85
|
+
state: DataMapStateKind;
|
|
86
|
+
/** Places that actually hold data now (self + successfully-synced peers). */
|
|
87
|
+
places: number;
|
|
88
|
+
pendingBlobCount: number;
|
|
89
|
+
pendingBlobBytes: number;
|
|
90
|
+
/** Maximum replication-cursor gap. This is a health signal, not an exact
|
|
91
|
+
* user-edit count (filtered streams can contain sequence gaps). */
|
|
92
|
+
pendingChanges: number;
|
|
93
|
+
/** Oldest last-success among enabled synced places — the freshness anchor
|
|
94
|
+
* (null when self is the only place). */
|
|
95
|
+
oldestSyncedAt: number | null;
|
|
96
|
+
/** Every concurrent problem, most severe first (same order as the headline
|
|
97
|
+
* precedence). Empty when healthy. */
|
|
98
|
+
issues: DataMapIssue[];
|
|
99
|
+
}
|
|
100
|
+
/** Fold the scattered stores into the ordered place list: self first, then
|
|
101
|
+
* devices, then buckets; within a kind, synced before never/disabled. */
|
|
102
|
+
export declare function dataPlaces(input: DataMapInput): DataPlace[];
|
|
103
|
+
/** The single precedence everyone must agree on (mh status, settings header). */
|
|
104
|
+
export declare function dataMapState(input: DataMapInput): DataMapState;
|
|
105
|
+
//# sourceMappingURL=data-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-map.d.ts","sourceRoot":"","sources":["../../src/core/data-map.ts"],"names":[],"mappings":"AAaA;;gDAEgD;AAChD,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,kEAAkE;IAClE,UAAU,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,MAAM,CAAC,EAAE,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S,GACT,OAAO,GACP,SAAS,CAAC;AAEd;;oEAEoE;AACpE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,WAAW,GAAG,YAAY,GAAG,cAAc,GAAG,QAAQ,GAAG,OAAO,GAAG,eAAe,CAAC;IACzF,oEAAoE;IACpE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,iDAAiD;IACjD,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,gBAAgB,CAAC;IACxB,6EAA6E;IAC7E,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB;uEACmE;IACnE,cAAc,EAAE,MAAM,CAAC;IACvB;8CAC0C;IAC1C,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;2CACuC;IACvC,MAAM,EAAE,YAAY,EAAE,CAAC;CACxB;AAiDD;0EAC0E;AAC1E,wBAAgB,UAAU,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,EAAE,CA+C3D;AAED,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,YAAY,CAmD9D"}
|
package/dist/core/db.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Database } from "bun:sqlite";
|
|
2
|
-
export { runSchema, ftsAvailable, migrateRecords, migratePeers, migrateDocBlocks, migrateDocuments, migrateOplog, initSchema, } from "./schema-init.ts";
|
|
2
|
+
export { runSchema, ftsAvailable, migrateRecords, migratePeers, migrateDocBlocks, migrateDocuments, migrateOplog, migrateSiteChannels, initSchema, } from "./schema-init.ts";
|
|
3
3
|
export declare function ensureDirs(): void;
|
|
4
4
|
/** Open (and migrate) the on-disk metahub database for the resolved home. */
|
|
5
5
|
export declare function openMetahub(): Database;
|
package/dist/core/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/core/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAOtC,OAAO,EACL,SAAS,EACT,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,UAAU,GACX,MAAM,kBAAkB,CAAC;AAE1B,wBAAgB,UAAU,IAAI,IAAI,CAGjC;AAED,6EAA6E;AAC7E,wBAAgB,WAAW,IAAI,QAAQ,CAMtC"}
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/core/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAOtC,OAAO,EACL,SAAS,EACT,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,UAAU,GACX,MAAM,kBAAkB,CAAC;AAE1B,wBAAgB,UAAU,IAAI,IAAI,CAGjC;AAED,6EAA6E;AAC7E,wBAAgB,WAAW,IAAI,QAAQ,CAMtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../src/core/documents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAQ5C,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,MAAM,eAAe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AW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB;WAGb,QAAQ,EAAE;cAAY,MAAM;mBAkC3C,CAAC;AAEH,eAAO,MAAM,cAAc,2DAczB,CAAC;AAEH,eAAO,MAAM,eAAe,2DAc1B,CAAC;AAEH,eAAO,MAAM,cAAc,uCAUzB,CAAC"}
|
package/dist/core/errors.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export type MhErrorCode =
|
|
|
21
21
|
| "auth"
|
|
22
22
|
/** A remote peer was unreachable or replied non-OK — retryable (exit 7). */
|
|
23
23
|
| "network"
|
|
24
|
+
/** Too many requests in the window — retry later (HTTP 429, exit 8). */
|
|
25
|
+
| "rate_limited"
|
|
24
26
|
/** The requested listen port is taken (exit 98, historical). */
|
|
25
27
|
| "port_in_use";
|
|
26
28
|
export declare class MhError extends Error {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW;AACrB,uEAAuE;AACrE,eAAe;AACjB,2DAA2D;GACzD,WAAW;AACb,4EAA4E;GAC1E,WAAW;AACb,8EAA8E;GAC5E,OAAO;AACT,0EAA0E;GACxE,UAAU;AACZ,sDAAsD;GACpD,MAAM;AACR,4EAA4E;GAC1E,SAAS;AACX,gEAAgE;GAC9D,aAAa,CAAC;AAElB,qBAAa,OAAQ,SAAQ,KAAK;IAE9B,QAAQ,CAAC,IAAI,EAAE,WAAW;gBAAjB,IAAI,EAAE,WAAW,EAC1B,OAAO,EAAE,MAAM;CAKlB;AAED,+EAA+E;AAC/E,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS,CAE7D"}
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW;AACrB,uEAAuE;AACrE,eAAe;AACjB,2DAA2D;GACzD,WAAW;AACb,4EAA4E;GAC1E,WAAW;AACb,8EAA8E;GAC5E,OAAO;AACT,0EAA0E;GACxE,UAAU;AACZ,sDAAsD;GACpD,MAAM;AACR,4EAA4E;GAC1E,SAAS;AACX,wEAAwE;GACtE,cAAc;AAChB,gEAAgE;GAC9D,aAAa,CAAC;AAElB,qBAAa,OAAQ,SAAQ,KAAK;IAE9B,QAAQ,CAAC,IAAI,EAAE,WAAW;gBAAjB,IAAI,EAAE,WAAW,EAC1B,OAAO,EAAE,MAAM;CAKlB;AAED,+EAA+E;AAC/E,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS,CAE7D"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { DbDriver } from "./driver.ts";
|
|
2
|
+
import { type DatabaseRow } from "./databases.ts";
|
|
3
|
+
import { type PreparedRecordCell, type RecordRow } from "./records.ts";
|
|
4
|
+
import { type Change } from "./crdt.ts";
|
|
5
|
+
/** delete NEVER enters this enum — anonymous/guest deletion is not a thing. */
|
|
6
|
+
export type GrantOp = "read" | "create" | "update";
|
|
7
|
+
export interface GrantTable {
|
|
8
|
+
/** database ID (never a name — names rename, grants must not follow). */
|
|
9
|
+
db: string;
|
|
10
|
+
ops: GrantOp[];
|
|
11
|
+
}
|
|
12
|
+
export interface GrantSet {
|
|
13
|
+
v: 1;
|
|
14
|
+
tables: GrantTable[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Parse a stored grants register. DEFAULT-DENY: null/undefined, broken JSON, a
|
|
18
|
+
* version other than 1, unknown ops, or any malformed shape (the "five
|
|
19
|
+
* poisons") all yield the EMPTY set — a poisoned register closes the whole
|
|
20
|
+
* guest surface instead of opening any part of it.
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseGrantSet(raw: string | null | undefined): GrantSet;
|
|
23
|
+
/**
|
|
24
|
+
* Strictly validate a caller-supplied GrantSet (CLI/WebUI writes) — the loud
|
|
25
|
+
* twin of parseGrantSet's silent default-deny. Returns the normalized set;
|
|
26
|
+
* throws MhError("invalid_input") on any malformation.
|
|
27
|
+
*/
|
|
28
|
+
export declare function validateGrantSetInput(input: unknown): GrantSet;
|
|
29
|
+
/** Canonical serialized form for storage (register value / shares.grants). */
|
|
30
|
+
export declare function serializeGrantSet(set: GrantSet): string;
|
|
31
|
+
/**
|
|
32
|
+
* Parse the CLI grant spec syntax `<db>:<op>[,<op>...]`, e.g. "tasks:read,create".
|
|
33
|
+
* `db` comes back as the raw ref — the caller resolves it to a database ID.
|
|
34
|
+
*/
|
|
35
|
+
export declare function parseGrantSpec(spec: string): {
|
|
36
|
+
db: string;
|
|
37
|
+
ops: GrantOp[];
|
|
38
|
+
};
|
|
39
|
+
/** The grant entry for one database id, if any. */
|
|
40
|
+
export declare function grantFor(set: GrantSet, dbId: string): GrantTable | undefined;
|
|
41
|
+
export declare function grantAllows(set: GrantSet, dbId: string, op: GrantOp): boolean;
|
|
42
|
+
/** True when any table grants a write op — the trigger for minting a guest
|
|
43
|
+
* node id on shares (attribution needs an author identity). */
|
|
44
|
+
export declare function grantSetHasWrite(set: GrantSet): boolean;
|
|
45
|
+
/** Who is acting through the granted surface. The kind gates the relation-
|
|
46
|
+
* property policy (see assertGuestPayload); guestNode is the synthetic node id
|
|
47
|
+
* every write is attributed to (per-visitor, so rollback can target one
|
|
48
|
+
* author). */
|
|
49
|
+
export interface GrantPrincipal {
|
|
50
|
+
kind: "public" | "share";
|
|
51
|
+
guestNode: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The anonymous-public guest node id, DERIVED per (site × serving node) and
|
|
55
|
+
* never stored: `gp-<site8>-<node8>`. Two servers must NOT share one guest id —
|
|
56
|
+
* both would mint HLCs for the same register under the same node segment and
|
|
57
|
+
* the oplog UNIQUE would silently drop one write (data loss). Derivation keeps
|
|
58
|
+
* per-source bulk rollback possible (LIKE 'gp-<site8>-%').
|
|
59
|
+
*/
|
|
60
|
+
export declare function publicGuestNode(siteId: string, nodeId: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Resolve a database ref (id or name) WITHIN the granted set only, and require
|
|
63
|
+
* `op`. Any failure — unknown ref, existing-but-ungranted database, granted
|
|
64
|
+
* database missing the op — throws the identical MhError("auth"): resolution
|
|
65
|
+
* never consults ungranted databases, so this endpoint is useless as an
|
|
66
|
+
* existence oracle. A name matching several granted databases is the one
|
|
67
|
+
* distinguishable error (ambiguous): it only exposes what the caller was
|
|
68
|
+
* already granted.
|
|
69
|
+
*/
|
|
70
|
+
export declare function authorizeDbRef(db: DbDriver, set: GrantSet, dbRef: string, op: GrantOp): DatabaseRow;
|
|
71
|
+
/**
|
|
72
|
+
* Load a record by id and require `op` on its database. Nonexistent record and
|
|
73
|
+
* ungranted record answer identically (MhError("auth")).
|
|
74
|
+
*/
|
|
75
|
+
export declare function authorizeRecord(db: DbDriver, set: GrantSet, recordId: string, op: GrantOp): RecordRow;
|
|
76
|
+
export interface PayloadLimits {
|
|
77
|
+
/** Total serialized cell bytes per write. */
|
|
78
|
+
maxBodyBytes: number;
|
|
79
|
+
/** Serialized bytes of one cell value. */
|
|
80
|
+
maxValueBytes: number;
|
|
81
|
+
/** Cells per write. */
|
|
82
|
+
maxCells: number;
|
|
83
|
+
/** Live rows per table — creates refuse beyond this (spam ceiling). */
|
|
84
|
+
maxRows: number;
|
|
85
|
+
}
|
|
86
|
+
export declare const GUEST_LIMITS: PayloadLimits;
|
|
87
|
+
/**
|
|
88
|
+
* Guest payload guardrails, run BEFORE any write: property resolution,
|
|
89
|
+
* coercion, cell count, per-value and total size, and relation policy. Returns
|
|
90
|
+
* the prepared cells so the actual mutator does not resolve/coerce them again.
|
|
91
|
+
*
|
|
92
|
+
* The stateful create capacity check is separate: an exact idempotent replay
|
|
93
|
+
* must still succeed after the table reaches its row ceiling.
|
|
94
|
+
*/
|
|
95
|
+
export declare function assertGuestPayload(db: DbDriver, set: GrantSet, principal: GrantPrincipal, database: DatabaseRow, values: Record<string, unknown>, opts?: {
|
|
96
|
+
limits?: PayloadLimits;
|
|
97
|
+
}): PreparedRecordCell[];
|
|
98
|
+
export declare function assertGuestCreateCapacity(db: DbDriver, database: DatabaseRow, limits?: PayloadLimits): void;
|
|
99
|
+
/** Authorized, guarded, guest-attributed record creation. */
|
|
100
|
+
export declare function guestCreateRecord(db: DbDriver, set: GrantSet, principal: GrantPrincipal, dbRef: string, values: Record<string, unknown>, limits?: PayloadLimits): RecordRow;
|
|
101
|
+
/** Authorized, guarded, guest-attributed record update (any row of a granted
|
|
102
|
+
* table — aligned with share-edit semantics; `update:own` is a non-goal v1). */
|
|
103
|
+
export declare function guestUpdateRecord(db: DbDriver, set: GrantSet, principal: GrantPrincipal, recordId: string, values: Record<string, unknown>, limits?: PayloadLimits): RecordRow;
|
|
104
|
+
/** Property types coerce() knows how to validate. Anything else (including any
|
|
105
|
+
* future blob-carrying type) is REFUSED — an unvalidatable value must never
|
|
106
|
+
* ride a guest op into the oplog (dangling-hash / poisoning risk). Exported
|
|
107
|
+
* as the guest-writable allowlist (drop-wire publishes only these properties
|
|
108
|
+
* into mh-drop.json's offline schema). */
|
|
109
|
+
export declare const GUEST_COERCIBLE_TYPES: ReadonlySet<string>;
|
|
110
|
+
/**
|
|
111
|
+
* Validate a batch of PRE-SIGNED guest ops (Change rows authored by a
|
|
112
|
+
* viewer/site page under its guest node id) before ingest — the write-inbox
|
|
113
|
+
* isolation layer (spike ⑨ gap 1). Throws on the first violation; a valid
|
|
114
|
+
* batch returns silently. Checks, per change:
|
|
115
|
+
* - dataset is exactly "records" (nothing else is guest-writable);
|
|
116
|
+
* - node_id AND the HLC node segment equal `guestNode`;
|
|
117
|
+
* - no tombstones (__deleted — delete is never grantable);
|
|
118
|
+
* and per row (changes grouped by row_id):
|
|
119
|
+
* - the target database is resolvable (existing row, or the group's own
|
|
120
|
+
* database_id op) and granted: update for existing rows, create for new
|
|
121
|
+
* ones — so a create-only grant refuses ops against an existing row_id;
|
|
122
|
+
* - a database_id op must name the granted target (no cross-db moves);
|
|
123
|
+
* - every cell column is a live property of that database, of a coercible
|
|
124
|
+
* type, and its value passes coerce(); relations additionally require the
|
|
125
|
+
* target database to be in the set;
|
|
126
|
+
* - per-value / per-row / total size limits (GUEST_LIMITS);
|
|
127
|
+
* - creates respect the per-table row ceiling.
|
|
128
|
+
* HLC clamping deliberately does NOT live here — it belongs to the ingest/sync
|
|
129
|
+
* layer (clock hygiene, not authorization).
|
|
130
|
+
*/
|
|
131
|
+
export declare function checkGuestChanges(db: DbDriver, set: GrantSet, guestNode: string, changes: Change[], principalKind?: GrantPrincipal["kind"], limits?: PayloadLimits): void;
|
|
132
|
+
//# sourceMappingURL=grants-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grants-core.d.ts","sourceRoot":"","sources":["../../src/core/grants-core.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,EAML,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAc,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAIpD,+EAA+E;AAC/E,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEnD,MAAM,WAAW,UAAU;IACzB,yEAAyE;IACzE,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,OAAO,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE,CAAC,CAAC;IACL,MAAM,EAAE,UAAU,EAAE,CAAC;CACtB;A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;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,QAAQ,EACZ,GAAG,EAAE,QAAQ,EACb,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EAAE,EAIjB,aAAa,GAAE,cAAc,CAAC,MAAM,CAAY,EAChD,MAAM,GAAE,aAA4B,GACnC,IAAI,CAsEN"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { DbDriver } from "./driver.ts";
|
|
2
|
+
import { type RecordRow } from "./records.ts";
|
|
3
|
+
import type { AccessPolicy } from "./access-policy.ts";
|
|
4
|
+
/** Kept as a public re-export for callers/tests that treat receipts as protocol state. */
|
|
5
|
+
export { INTENT_RECEIPT_DATASET } from "./intent-retention.ts";
|
|
6
|
+
export interface GuestIntent {
|
|
7
|
+
v?: 1;
|
|
8
|
+
intentId: string;
|
|
9
|
+
action: "createRecord" | "updateRecord";
|
|
10
|
+
/** createRecord: database ref (id or granted name). */
|
|
11
|
+
table?: string;
|
|
12
|
+
/** updateRecord: target row. Submitted create: optional client row id. */
|
|
13
|
+
recordId?: string;
|
|
14
|
+
payload: Record<string, unknown>;
|
|
15
|
+
/** Epoch ms used only by submitted-clock execution. */
|
|
16
|
+
submittedAt: number;
|
|
17
|
+
}
|
|
18
|
+
export interface GuestSession {
|
|
19
|
+
guestNode: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ApplyIntentOpts {
|
|
22
|
+
clock: "authority" | "submitted";
|
|
23
|
+
now?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Apply one guest intent atomically. Authorization and payload validation run
|
|
27
|
+
* before every receipt lookup, so revocation is immediate. A matching receipt
|
|
28
|
+
* returns the immutable submitted projection unless current policy also grants
|
|
29
|
+
* read on the target table.
|
|
30
|
+
*/
|
|
31
|
+
export declare function applyGuestIntent(db: DbDriver, policy: AccessPolicy, session: GuestSession, intent: GuestIntent, opts: ApplyIntentOpts): RecordRow;
|
|
32
|
+
export declare function intentTxnPrefix(guestNode: string, intentId: string): string;
|
|
33
|
+
//# sourceMappingURL=guest-intent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guest-intent.d.ts","sourceRoot":"","sources":["../../src/core/guest-intent.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAWtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAcvD,0FAA0F;AAC1F,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAG/D,MAAM,WAAW,WAAW;IAC1B,CAAC,CAAC,EAAE,CAAC,CAAC;IACN,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,cAAc,GAAG,cAAc,CAAC;IACxC,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,WAAW,GAAG,WAAW,CAAC;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAsBD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,eAAe,GACpB,SAAS,CAoEX;AA4UD,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE3E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/core/hash.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAO/E,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ5C;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/core/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAyC5C,uEAAuE;AACvE,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;AA6FxD,MAAM,WAAW,WAAW;IAC1B,0FAA0F;IAC1F,OAAO,EAAE,MAAM,CAAC;IAChB,+DAA+D;IAC/D,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,yEAAyE;IACzE,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,oFAAoF;AACpF,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/core/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAyC5C,uEAAuE;AACvE,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;AA6FxD,MAAM,WAAW,WAAW;IAC1B,0FAA0F;IAC1F,OAAO,EAAE,M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