@happyvertical/smrt-vault-relay 0.0.0-stage → 0.60.16
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/AGENTS.md +51 -0
- package/CLAUDE.md +1 -0
- package/LICENSE +7 -0
- package/README.md +361 -2
- package/dist/auth.d.ts +66 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/chunks/server-0ITpMTMD.js +2358 -0
- package/dist/chunks/server-0ITpMTMD.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +43 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +86 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/encoding.d.ts +20 -0
- package/dist/encoding.d.ts.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/lease-store.d.ts +108 -0
- package/dist/lease-store.d.ts.map +1 -0
- package/dist/lease.d.ts +60 -0
- package/dist/lease.d.ts.map +1 -0
- package/dist/manifest.json +15 -0
- package/dist/metadata-store.d.ts +212 -0
- package/dist/metadata-store.d.ts.map +1 -0
- package/dist/node-server.d.ts +14 -0
- package/dist/node-server.d.ts.map +1 -0
- package/dist/object-store.d.ts +60 -0
- package/dist/object-store.d.ts.map +1 -0
- package/dist/relay.d.ts +268 -0
- package/dist/relay.d.ts.map +1 -0
- package/dist/server.d.ts +46 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/smrt-knowledge.json +73 -0
- package/dist/smrt-knowledge.okf.md +56 -0
- package/package.json +54 -3
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relay policy: per-account quotas, retention, and request bounds.
|
|
3
|
+
*
|
|
4
|
+
* Quotas and retention are owner decisions and have no defaults. The request
|
|
5
|
+
* bounds are technical limits with defaults that match the snapshot format.
|
|
6
|
+
*/
|
|
7
|
+
/** Hard ceiling on one chunk, whatever the configuration says. */
|
|
8
|
+
export declare const MAX_CHUNK_BYTES_CEILING: number;
|
|
9
|
+
/** Default chunk bound: one 8 MiB v1 vault envelope plus framing headroom. */
|
|
10
|
+
export declare const DEFAULT_MAX_CHUNK_BYTES: number;
|
|
11
|
+
/** Object keys allow at most six decimal digits for the chunk index. */
|
|
12
|
+
export declare const MAX_CHUNKS_PER_SNAPSHOT = 999999;
|
|
13
|
+
export declare const DEFAULT_UPLOAD_TTL_MS: number;
|
|
14
|
+
export declare const DEFAULT_MAX_CLOCK_SKEW_MS: number;
|
|
15
|
+
/**
|
|
16
|
+
* How far above the account's sequence high-water mark one upload may begin
|
|
17
|
+
* or commit. Sequences are chosen by the device, and a commit raises the mark
|
|
18
|
+
* permanently, so an unbounded jump (one commit at 2^53-1) would make every
|
|
19
|
+
* later upload `stale_sequence`. A device that makes a backup every few
|
|
20
|
+
* minutes needs a few thousand sequences in a decade; 1000 per step leaves
|
|
21
|
+
* room for a device that skipped sequences while offline. An owner decision
|
|
22
|
+
* may raise it with `VAULT_RELAY_MAX_SEQUENCE_JUMP`.
|
|
23
|
+
*/
|
|
24
|
+
export declare const DEFAULT_MAX_SEQUENCE_JUMP = 1000;
|
|
25
|
+
/** Default primary-writer lease lifetime (#4805). */
|
|
26
|
+
export declare const DEFAULT_LEASE_TTL_MS: number;
|
|
27
|
+
/** Bounds of the configured lease lifetime. */
|
|
28
|
+
export declare const MIN_CONFIGURED_LEASE_TTL_MS: number;
|
|
29
|
+
export declare const MAX_CONFIGURED_LEASE_TTL_MS: number;
|
|
30
|
+
/**
|
|
31
|
+
* Default time a lapsed account's snapshots stay restorable, measured from the
|
|
32
|
+
* moment the relay first observed the `backup.vault` entitlement as lapsed
|
|
33
|
+
* (#4819). An owner decision (90 days), configurable per deployment.
|
|
34
|
+
*/
|
|
35
|
+
export declare const DEFAULT_LAPSE_RETENTION_DAYS = 90;
|
|
36
|
+
/** Upper bound of the configured lapse window (ten years). */
|
|
37
|
+
export declare const MAX_LAPSE_RETENTION_DAYS = 3650;
|
|
38
|
+
/** Upper bound of a JSON request body (begin upload, device registration). */
|
|
39
|
+
export declare const MAX_JSON_BODY_BYTES = 4096;
|
|
40
|
+
export interface VaultRelayQuota {
|
|
41
|
+
/** Bytes per account, counting committed snapshots and pending uploads. */
|
|
42
|
+
maxBytes: number;
|
|
43
|
+
/** Snapshots per account, counting pending uploads. */
|
|
44
|
+
maxSnapshots: number;
|
|
45
|
+
}
|
|
46
|
+
export interface VaultRelayRetention {
|
|
47
|
+
/** Always keep this many newest committed snapshots (at least 1). */
|
|
48
|
+
keepLast: number;
|
|
49
|
+
/** Also keep committed snapshots younger than this many milliseconds. */
|
|
50
|
+
keepWithinMs: number;
|
|
51
|
+
/**
|
|
52
|
+
* Days a lapsed account stays restorable (list, latest, download, abort)
|
|
53
|
+
* after the lapse is first observed; afterwards the operator sweep may
|
|
54
|
+
* delete its snapshots. Default 90.
|
|
55
|
+
*/
|
|
56
|
+
lapseRetentionDays: number;
|
|
57
|
+
/** `lapseRetentionDays` in milliseconds. */
|
|
58
|
+
lapseRetentionMs: number;
|
|
59
|
+
}
|
|
60
|
+
export interface VaultRelayLimits {
|
|
61
|
+
maxChunkBytes: number;
|
|
62
|
+
uploadTtlMs: number;
|
|
63
|
+
maxClockSkewMs: number;
|
|
64
|
+
/** Largest `sequence - highWaterSequence` a begin or commit may carry. */
|
|
65
|
+
maxSequenceJump: number;
|
|
66
|
+
/** Primary-writer lease lifetime; holders renew before it lapses. */
|
|
67
|
+
leaseTtlMs: number;
|
|
68
|
+
}
|
|
69
|
+
export interface VaultRelayPolicy {
|
|
70
|
+
quota: VaultRelayQuota;
|
|
71
|
+
retention: VaultRelayRetention;
|
|
72
|
+
limits: VaultRelayLimits;
|
|
73
|
+
}
|
|
74
|
+
export interface VaultRelayPolicyInput {
|
|
75
|
+
quota: VaultRelayQuota;
|
|
76
|
+
retention: Omit<VaultRelayRetention, 'lapseRetentionDays' | 'lapseRetentionMs'> & {
|
|
77
|
+
lapseRetentionDays?: number;
|
|
78
|
+
};
|
|
79
|
+
limits?: Partial<VaultRelayLimits>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Validate and complete a policy. Retention must leave room for one upload
|
|
83
|
+
* under the snapshot quota, or steady-state accounts could never back up.
|
|
84
|
+
*/
|
|
85
|
+
export declare function resolvePolicy(input: VaultRelayPolicyInput): VaultRelayPolicy;
|
|
86
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,kEAAkE;AAClE,eAAO,MAAM,uBAAuB,QAAmB,CAAC;AACxD,8EAA8E;AAC9E,eAAO,MAAM,uBAAuB,QAA8B,CAAC;AACnE,wEAAwE;AACxE,eAAO,MAAM,uBAAuB,SAAU,CAAC;AAC/C,eAAO,MAAM,qBAAqB,QAAsB,CAAC;AACzD,eAAO,MAAM,yBAAyB,QAAgB,CAAC;AACvD;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAC9C,qDAAqD;AACrD,eAAO,MAAM,oBAAoB,QAAgB,CAAC;AAClD,+CAA+C;AAC/C,eAAO,MAAM,2BAA2B,QAAY,CAAC;AACrD,eAAO,MAAM,2BAA2B,QAAiB,CAAC;AAC1D;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAC/C,8DAA8D;AAC9D,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAE7C,8EAA8E;AAC9E,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC,MAAM,WAAW,eAAe;IAC9B,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,mBAAmB;IAClC,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B,4CAA4C;IAC5C,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,eAAe,EAAE,MAAM,CAAC;IACxB,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,eAAe,CAAC;IACvB,SAAS,EAAE,mBAAmB,CAAC;IAC/B,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,eAAe,CAAC;IACvB,SAAS,EAAE,IAAI,CACb,mBAAmB,EACnB,oBAAoB,GAAG,kBAAkB,CAC1C,GAAG;QAAE,kBAAkB,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACpC,MAAM,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACpC;AAgCD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,qBAAqB,GAAG,gBAAgB,CAyD5E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** SHA-256 of the empty body, the content hash of a bodiless request. */
|
|
2
|
+
export declare const EMPTY_SHA256: string;
|
|
3
|
+
export declare function isIdentifier(value: unknown): value is string;
|
|
4
|
+
export declare function isNonce(value: unknown): value is string;
|
|
5
|
+
export declare function isSha256Hex(value: unknown): value is string;
|
|
6
|
+
export declare function isUploadId(value: unknown): value is string;
|
|
7
|
+
export declare function sha256Hex(data: Uint8Array | string): string;
|
|
8
|
+
/**
|
|
9
|
+
* The account's storage and log handle: a hash, so object keys and log lines
|
|
10
|
+
* never carry the account identifier itself.
|
|
11
|
+
*/
|
|
12
|
+
export declare function accountHandle(accountId: string): string;
|
|
13
|
+
export declare function encodeBase64Url(bytes: Uint8Array): string;
|
|
14
|
+
/** Strict base64url decode; `null` for anything not canonical base64url. */
|
|
15
|
+
export declare function decodeBase64Url(value: string): Uint8Array | null;
|
|
16
|
+
/** Parse a non-negative safe integer written in canonical decimal. */
|
|
17
|
+
export declare function parseCanonicalInteger(value: string): number | null;
|
|
18
|
+
/** Coerce a database integer (BIGINT may arrive as a string) to a safe number. */
|
|
19
|
+
export declare function toSafeInteger(value: unknown, field: string): number;
|
|
20
|
+
//# sourceMappingURL=encoding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../src/encoding.ts"],"names":[],"mappings":"AAiBA,yEAAyE;AACzE,eAAO,MAAM,YAAY,QAAqC,CAAC;AAE/D,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE5D;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEvD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE3D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE1D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,CAE3D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAEzD;AAED,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAKhE;AAED,sEAAsE;AACtE,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIlE;AAED,kFAAkF;AAClF,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAanE"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { canonicalRequest, exportDevicePublicKey, HEADER_ACCOUNT, HEADER_CONTENT_SHA256, HEADER_DEVICE, HEADER_NONCE, HEADER_SIGNATURE, HEADER_TIMESTAMP, importDevicePrivateKey, importDevicePublicKey, SIGNATURE_PROTOCOL, type SignedRequestFields, signRelayRequest, } from './auth.js';
|
|
2
|
+
export { DEFAULT_LAPSE_RETENTION_DAYS, DEFAULT_LEASE_TTL_MS, DEFAULT_MAX_CHUNK_BYTES, DEFAULT_MAX_CLOCK_SKEW_MS, DEFAULT_MAX_SEQUENCE_JUMP, DEFAULT_UPLOAD_TTL_MS, MAX_CHUNK_BYTES_CEILING, MAX_LAPSE_RETENTION_DAYS, resolvePolicy, type VaultRelayLimits, type VaultRelayPolicy, type VaultRelayPolicyInput, type VaultRelayQuota, type VaultRelayRetention, } from './config.js';
|
|
3
|
+
export { accountHandle, EMPTY_SHA256, sha256Hex } from './encoding.js';
|
|
4
|
+
export { type LeaseRefusal, type LeaseStatus, MIN_LEASE_TTL_MS, } from './lease.js';
|
|
5
|
+
export { type LeaseGrant, type LeaseRecord, migrateVaultRelayLeasesV1, VAULT_RELAY_LEASE_TABLES, VaultRelayLeaseStore, } from './lease-store.js';
|
|
6
|
+
export { type AccountUsage, type AuditEntry, type DeviceRecord, type LapseRecord, migrateVaultRelayV1, type SnapshotRecord, VAULT_RELAY_TABLES, VaultRelayStore, } from './metadata-store.js';
|
|
7
|
+
export { createRelayHttpServer, type FetchHandler } from './node-server.js';
|
|
8
|
+
export { assertObjectKey, createS3ObjectStore, FilesObjectStore, FilesystemObjectStore, type S3ObjectStoreOptions, type VaultObjectStore, } from './object-store.js';
|
|
9
|
+
export { jsonLineLogger, type LapseSweepAccount, type LapseSweepOptions, type LapseSweepResult, type OperatorAccountView, VaultRelay, type VaultRelayEntitlements, type VaultRelayLogger, type VaultRelayOptions, } from './relay.js';
|
|
10
|
+
export { loadServerConfig, openRelayDatabase, runMigrations, startVaultRelayServer, VaultRelayConfigError, type VaultRelayServerConfig, type VaultRelayStorageConfig, } from './server.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,KAAK,mBAAmB,EACxB,gBAAgB,GACjB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,4BAA4B,EAC5B,oBAAoB,EACpB,uBAAuB,EACvB,yBAAyB,EACzB,yBAAyB,EACzB,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,aAAa,EACb,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,mBAAmB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,mBAAmB,EACnB,KAAK,cAAc,EACnB,kBAAkB,EAClB,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,cAAc,EACd,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,UAAU,EACV,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,GACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,GAC7B,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as HEADER_CONTENT_SHA256, B as signRelayRequest, C as DEFAULT_MAX_CLOCK_SKEW_MS, D as MAX_LAPSE_RETENTION_DAYS, E as MAX_CHUNK_BYTES_CEILING, F as SIGNATURE_PROTOCOL, H as accountHandle, I as canonicalRequest, L as exportDevicePublicKey, M as HEADER_NONCE, N as HEADER_SIGNATURE, O as resolvePolicy, P as HEADER_TIMESTAMP, R as importDevicePrivateKey, S as DEFAULT_MAX_CHUNK_BYTES, T as DEFAULT_UPLOAD_TTL_MS, U as sha256Hex, V as EMPTY_SHA256, _ as VaultRelayLeaseStore, a as startVaultRelayServer, b as DEFAULT_LAPSE_RETENTION_DAYS, c as FilesObjectStore, d as createS3ObjectStore, f as createRelayHttpServer, g as VAULT_RELAY_LEASE_TABLES, h as migrateVaultRelayV1, i as runMigrations, j as HEADER_DEVICE, k as HEADER_ACCOUNT, l as FilesystemObjectStore, m as VaultRelayStore, n as loadServerConfig, o as VaultRelay, p as VAULT_RELAY_TABLES, r as openRelayDatabase, s as jsonLineLogger, t as VaultRelayConfigError, u as assertObjectKey, v as migrateVaultRelayLeasesV1, w as DEFAULT_MAX_SEQUENCE_JUMP, x as DEFAULT_LEASE_TTL_MS, y as MIN_LEASE_TTL_MS, z as importDevicePublicKey } from "./chunks/server-0ITpMTMD.js";
|
|
2
|
+
export { DEFAULT_LAPSE_RETENTION_DAYS, DEFAULT_LEASE_TTL_MS, DEFAULT_MAX_CHUNK_BYTES, DEFAULT_MAX_CLOCK_SKEW_MS, DEFAULT_MAX_SEQUENCE_JUMP, DEFAULT_UPLOAD_TTL_MS, EMPTY_SHA256, FilesObjectStore, FilesystemObjectStore, HEADER_ACCOUNT, HEADER_CONTENT_SHA256, HEADER_DEVICE, HEADER_NONCE, HEADER_SIGNATURE, HEADER_TIMESTAMP, MAX_CHUNK_BYTES_CEILING, MAX_LAPSE_RETENTION_DAYS, MIN_LEASE_TTL_MS, SIGNATURE_PROTOCOL, VAULT_RELAY_LEASE_TABLES, VAULT_RELAY_TABLES, VaultRelay, VaultRelayConfigError, VaultRelayLeaseStore, VaultRelayStore, accountHandle, assertObjectKey, canonicalRequest, createRelayHttpServer, createS3ObjectStore, exportDevicePublicKey, importDevicePrivateKey, importDevicePublicKey, jsonLineLogger, loadServerConfig, migrateVaultRelayLeasesV1, migrateVaultRelayV1, openRelayDatabase, resolvePolicy, runMigrations, sha256Hex, signRelayRequest, startVaultRelayServer };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Primary-writer lease (#4805): one row per account naming the device that
|
|
3
|
+
* may publish, a fencing token, and the account's head sequence.
|
|
4
|
+
*
|
|
5
|
+
* `head_sequence` is the sequence the account's data line is at. Only the
|
|
6
|
+
* lease holder advances it (at commit, before the snapshot is published), so
|
|
7
|
+
* holding a current token means the holder's local root is at the head. Every
|
|
8
|
+
* lease decision is one conditional statement on this row, which serializes
|
|
9
|
+
* acquire, renew, release, revoke and the commit-time head advance on SQLite
|
|
10
|
+
* and PostgreSQL alike.
|
|
11
|
+
*
|
|
12
|
+
* A *hole* is a head whose upload never committed (aborted or expired after
|
|
13
|
+
* the head advanced). Committed snapshots at or above the head, and the latest
|
|
14
|
+
* committed snapshot, can never be deleted (see
|
|
15
|
+
* {@link VaultRelayLeaseStore.deleteCommittedBelowHead}), so a missing row at
|
|
16
|
+
* the head is always a hole, and acquire then accepts the latest committed
|
|
17
|
+
* sequence as the base.
|
|
18
|
+
*/
|
|
19
|
+
import type { DatabaseInterface } from '@happyvertical/sql';
|
|
20
|
+
import type { SnapshotRecord } from './metadata-store.js';
|
|
21
|
+
export declare const VAULT_RELAY_LEASE_TABLES: readonly ["vault_relay_leases", "vault_relay_upload_fences"];
|
|
22
|
+
/**
|
|
23
|
+
* Create the lease tables. Idempotent; run from the deployment's migration
|
|
24
|
+
* step together with `migrateVaultRelayV1`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function migrateVaultRelayLeasesV1(db: DatabaseInterface): Promise<void>;
|
|
27
|
+
/** Current lease state of one account. */
|
|
28
|
+
export interface LeaseRecord {
|
|
29
|
+
accountId: string;
|
|
30
|
+
holderDeviceId: string | null;
|
|
31
|
+
fencingToken: number;
|
|
32
|
+
headSequence: number;
|
|
33
|
+
expiresAt: number;
|
|
34
|
+
}
|
|
35
|
+
/** A granted or renewed lease. */
|
|
36
|
+
export interface LeaseGrant {
|
|
37
|
+
fencingToken: number;
|
|
38
|
+
expiresAt: number;
|
|
39
|
+
headSequence: number;
|
|
40
|
+
}
|
|
41
|
+
/** Typed access to the lease tables. */
|
|
42
|
+
export declare class VaultRelayLeaseStore {
|
|
43
|
+
readonly db: DatabaseInterface;
|
|
44
|
+
constructor(db: DatabaseInterface);
|
|
45
|
+
/**
|
|
46
|
+
* Create the account's lease row if missing, with no holder and the head at
|
|
47
|
+
* the account's published high-water mark (publishing always needs the
|
|
48
|
+
* lease, so no upload can be in flight before the row exists). When the
|
|
49
|
+
* newest published snapshots were deleted before the lease existed, the
|
|
50
|
+
* head is then a hole and acquire accepts the latest committed base.
|
|
51
|
+
*/
|
|
52
|
+
ensureLease(accountId: string): Promise<void>;
|
|
53
|
+
getLease(accountId: string): Promise<LeaseRecord | null>;
|
|
54
|
+
/** Latest committed sequence of the account (0 when none). */
|
|
55
|
+
latestCommittedSequence(accountId: string): Promise<number>;
|
|
56
|
+
/** Status of the snapshot row at `sequence`, or `null` when none exists. */
|
|
57
|
+
snapshotStatusAt(accountId: string, sequence: number): Promise<SnapshotRecord['status'] | null>;
|
|
58
|
+
/**
|
|
59
|
+
* Grant the lease to `deviceId`, in one statement, when it is free, expired
|
|
60
|
+
* or already this device's, and the device's `baseSequence` is the head:
|
|
61
|
+
* either the head itself with no publish in flight, or, for a hole, the
|
|
62
|
+
* latest committed sequence. Every grant increments the fencing token, so a
|
|
63
|
+
* re-acquire also fences an earlier process on the same device.
|
|
64
|
+
*/
|
|
65
|
+
acquire(accountId: string, deviceId: string, baseSequence: number, now: number, expiresAt: number): Promise<LeaseGrant | null>;
|
|
66
|
+
/** Extend an unexpired lease held by this device with this exact token. */
|
|
67
|
+
renew(accountId: string, deviceId: string, fencingToken: number, now: number, expiresAt: number): Promise<LeaseGrant | null>;
|
|
68
|
+
/** Give up the lease; only the holder with the current token can. */
|
|
69
|
+
release(accountId: string, deviceId: string, fencingToken: number): Promise<boolean>;
|
|
70
|
+
/**
|
|
71
|
+
* Clear a lease held by a revoked device and bump the token, so nothing
|
|
72
|
+
* recorded under the old token can publish. Run after the revocation.
|
|
73
|
+
*/
|
|
74
|
+
clearHolder(accountId: string, deviceId: string): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Advisory begin-time check: this device holds an unexpired lease with this
|
|
77
|
+
* token and `sequence` is above the head. Begin is several statements, so
|
|
78
|
+
* only {@link advanceHead} at commit enforces the lease.
|
|
79
|
+
*/
|
|
80
|
+
holds(accountId: string, deviceId: string, fencingToken: number, sequence: number, now: number): Promise<boolean>;
|
|
81
|
+
/**
|
|
82
|
+
* Move the head to `sequence` for a pending upload, in one statement: only
|
|
83
|
+
* the holder with the token recorded at begin, only while the upload is
|
|
84
|
+
* still pending, and only forward under an unexpired lease. A head already
|
|
85
|
+
* at `sequence` (a commit retried after the relay failed between the head
|
|
86
|
+
* advance and the publish) is accepted without the expiry check: nobody
|
|
87
|
+
* else can have acquired while that upload is pending at the head.
|
|
88
|
+
*/
|
|
89
|
+
advanceHead(accountId: string, deviceId: string, uploadId: string, fencingToken: number, sequence: number, now: number): Promise<boolean>;
|
|
90
|
+
recordFence(accountId: string, uploadId: string, fencingToken: number): Promise<void>;
|
|
91
|
+
getFence(accountId: string, uploadId: string): Promise<number | null>;
|
|
92
|
+
deleteFence(uploadId: string): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Operator reset of the account's high-water mark (the one way the head
|
|
95
|
+
* moves back): the head becomes the latest committed sequence that remains
|
|
96
|
+
* and the holder is cleared with a bumped token, so nothing recorded under
|
|
97
|
+
* the old position can publish and the next acquire starts from the
|
|
98
|
+
* restored head.
|
|
99
|
+
*/
|
|
100
|
+
resetHead(accountId: string): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Delete a committed snapshot only when it is below the head and below the
|
|
103
|
+
* latest committed snapshot, in one statement. The head never moves back,
|
|
104
|
+
* so a stale read can only refuse more. Returns the row when removed.
|
|
105
|
+
*/
|
|
106
|
+
deleteCommittedBelowHead(accountId: string, uploadId: string): Promise<SnapshotRecord | null>;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=lease-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lease-store.d.ts","sourceRoot":"","sources":["../src/lease-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,eAAO,MAAM,wBAAwB,8DAG3B,CAAC;AAkB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
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Primary-writer lease decisions (#4805). The relay maps these results to
|
|
3
|
+
* HTTP; every state change is a single conditional statement in
|
|
4
|
+
* {@link VaultRelayLeaseStore}. Expiry uses the relay clock only.
|
|
5
|
+
*/
|
|
6
|
+
import type { LeaseGrant, VaultRelayLeaseStore } from './lease-store.js';
|
|
7
|
+
/** Smallest lease a client may request, in milliseconds. */
|
|
8
|
+
export declare const MIN_LEASE_TTL_MS = 30000;
|
|
9
|
+
/** Why a lease or publish request was refused. */
|
|
10
|
+
export type LeaseRefusal = {
|
|
11
|
+
error: 'must_restore_first';
|
|
12
|
+
headSequence: number;
|
|
13
|
+
latestSequence: number;
|
|
14
|
+
} | {
|
|
15
|
+
error: 'lease_held';
|
|
16
|
+
holder: string;
|
|
17
|
+
expiresAt: number;
|
|
18
|
+
} | {
|
|
19
|
+
error: 'publish_in_progress';
|
|
20
|
+
headSequence: number;
|
|
21
|
+
} | {
|
|
22
|
+
error: 'lease_lost';
|
|
23
|
+
};
|
|
24
|
+
/** Public lease state. The fencing token is never part of it. */
|
|
25
|
+
export interface LeaseStatus {
|
|
26
|
+
holder: string | null;
|
|
27
|
+
expiresAt: number | null;
|
|
28
|
+
headSequence: number;
|
|
29
|
+
latestCommittedSequence: number;
|
|
30
|
+
/** The head's upload never committed; acquire accepts the latest instead. */
|
|
31
|
+
headIsHole: boolean;
|
|
32
|
+
}
|
|
33
|
+
export type LeaseResult = {
|
|
34
|
+
ok: true;
|
|
35
|
+
grant: LeaseGrant;
|
|
36
|
+
} | {
|
|
37
|
+
ok: false;
|
|
38
|
+
refusal: LeaseRefusal;
|
|
39
|
+
};
|
|
40
|
+
export declare class LeaseService {
|
|
41
|
+
private readonly store;
|
|
42
|
+
private readonly ttlMs;
|
|
43
|
+
constructor(store: VaultRelayLeaseStore, ttlMs: number);
|
|
44
|
+
/** The granted lifetime: the policy TTL, or a shorter one the client asks. */
|
|
45
|
+
private lifetime;
|
|
46
|
+
status(accountId: string, now: number): Promise<LeaseStatus>;
|
|
47
|
+
/** Explain a refused acquire or publish from the current row. */
|
|
48
|
+
private refusal;
|
|
49
|
+
acquire(accountId: string, deviceId: string, baseSequence: number, requestedTtlMs: number | undefined, now: number): Promise<LeaseResult>;
|
|
50
|
+
renew(accountId: string, deviceId: string, fencingToken: number, requestedTtlMs: number | undefined, now: number): Promise<LeaseResult>;
|
|
51
|
+
release(accountId: string, deviceId: string, fencingToken: number): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Begin-time admission (advisory; the commit-time head advance enforces).
|
|
54
|
+
* `null` admits the upload.
|
|
55
|
+
*/
|
|
56
|
+
admitUpload(accountId: string, deviceId: string, fencingToken: number, sequence: number, now: number): Promise<LeaseRefusal | null>;
|
|
57
|
+
/** The `must_restore_first` answer for a publish that lost its lease. */
|
|
58
|
+
mustRestore(accountId: string): Promise<LeaseRefusal>;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=lease.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lease.d.ts","sourceRoot":"","sources":["../src/lease.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAEzE,4DAA4D;AAC5D,eAAO,MAAM,gBAAgB,QAAS,CAAC;AAEvC,kDAAkD;AAClD,MAAM,MAAM,YAAY,GACpB;IACE,KAAK,EAAE,oBAAoB,CAAC;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB,GACD;IAAE,KAAK,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAC1D;IAAE,KAAK,EAAE,qBAAqB,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GACtD;IAAE,KAAK,EAAE,YAAY,CAAA;CA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WAAW,CACf,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAY/B,yEAAyE;IACnE,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CAS5D"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"timestamp": 0,
|
|
4
|
+
"packageName": "@happyvertical/smrt-vault-relay",
|
|
5
|
+
"packageVersion": "0.60.16",
|
|
6
|
+
"objects": {},
|
|
7
|
+
"moduleType": "smrt",
|
|
8
|
+
"smrtDependencies": [
|
|
9
|
+
"@happyvertical/smrt-app-runtime",
|
|
10
|
+
"@happyvertical/smrt-core",
|
|
11
|
+
"@happyvertical/smrt-features",
|
|
12
|
+
"@happyvertical/smrt-subscriptions"
|
|
13
|
+
],
|
|
14
|
+
"stampsConstructors": true
|
|
15
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relay metadata in the service database: accounts (sequence high-water mark
|
|
3
|
+
* and quota counters), registered device keys, consumed request nonces,
|
|
4
|
+
* snapshot rows, and per-chunk rows. Content is never stored here, only
|
|
5
|
+
* sizes, dates, sequences, and ciphertext SHA-256 digests.
|
|
6
|
+
*
|
|
7
|
+
* Every state change that guards a security property is one conditional
|
|
8
|
+
* statement, so it holds on SQLite and PostgreSQL without an explicit
|
|
9
|
+
* transaction: quota reservation (`used + n <= max`), sequence advance
|
|
10
|
+
* (`high_water <= sequence`), publish (`status = 'pending'`), and nonce
|
|
11
|
+
* consumption (primary-key insert). Counter updates that follow a delete can
|
|
12
|
+
* be lost on a crash; they only ever over-count, which denies rather than
|
|
13
|
+
* grants, and {@link VaultRelayStore.reconcileUsage} repairs them.
|
|
14
|
+
*/
|
|
15
|
+
import type { DatabaseInterface } from '@happyvertical/sql';
|
|
16
|
+
export declare const VAULT_RELAY_TABLES: readonly ["vault_relay_accounts", "vault_relay_devices", "vault_relay_nonces", "vault_relay_snapshots", "vault_relay_chunks", "vault_relay_supersessions", "vault_relay_lapses", "vault_relay_audit"];
|
|
17
|
+
/**
|
|
18
|
+
* Create the relay tables. Idempotent (`IF NOT EXISTS`); run it from the
|
|
19
|
+
* deployment's migration step, never from request handling. Works on SQLite
|
|
20
|
+
* and PostgreSQL.
|
|
21
|
+
*/
|
|
22
|
+
export declare function migrateVaultRelayV1(db: DatabaseInterface): Promise<void>;
|
|
23
|
+
export type DeviceStatus = 'active' | 'revoked';
|
|
24
|
+
export interface DeviceRecord {
|
|
25
|
+
accountId: string;
|
|
26
|
+
deviceId: string;
|
|
27
|
+
/** Raw Ed25519 public key, base64url. */
|
|
28
|
+
publicKey: string;
|
|
29
|
+
status: DeviceStatus;
|
|
30
|
+
registeredAt: number;
|
|
31
|
+
revokedAt: number | null;
|
|
32
|
+
}
|
|
33
|
+
export type SnapshotStatus = 'pending' | 'committed';
|
|
34
|
+
export interface SnapshotRecord {
|
|
35
|
+
accountId: string;
|
|
36
|
+
sequence: number;
|
|
37
|
+
uploadId: string;
|
|
38
|
+
deviceId: string;
|
|
39
|
+
status: SnapshotStatus;
|
|
40
|
+
byteSize: number;
|
|
41
|
+
/** Size of every chunk but the last, which holds the remainder. */
|
|
42
|
+
chunkSize: number;
|
|
43
|
+
chunkCount: number;
|
|
44
|
+
sha256: string;
|
|
45
|
+
createdAt: number;
|
|
46
|
+
committedAt: number | null;
|
|
47
|
+
}
|
|
48
|
+
export interface ChunkRecord {
|
|
49
|
+
index: number;
|
|
50
|
+
byteSize: number;
|
|
51
|
+
sha256: string;
|
|
52
|
+
/** Random id of the stored object attempt this row points at. */
|
|
53
|
+
objectId: string;
|
|
54
|
+
}
|
|
55
|
+
export interface AccountUsage {
|
|
56
|
+
accountId: string;
|
|
57
|
+
highWaterSequence: number;
|
|
58
|
+
usedBytes: number;
|
|
59
|
+
usedSnapshots: number;
|
|
60
|
+
}
|
|
61
|
+
export type RegisterDeviceResult = 'registered' | 'unchanged' | 'conflict';
|
|
62
|
+
/** An account the account layer replaced with a new one (#4817). */
|
|
63
|
+
export interface SupersessionRecord {
|
|
64
|
+
accountId: string;
|
|
65
|
+
supersededBy: string;
|
|
66
|
+
supersededAt: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* When the relay first observed an account's `backup.vault` entitlement as
|
|
70
|
+
* lapsed (#4819); `sweptAt` is set once the operator sweep deleted its data.
|
|
71
|
+
*/
|
|
72
|
+
export interface LapseRecord {
|
|
73
|
+
accountId: string;
|
|
74
|
+
lapsedAt: number;
|
|
75
|
+
sweptAt: number | null;
|
|
76
|
+
}
|
|
77
|
+
/** One append-only operator audit record. */
|
|
78
|
+
export interface AuditEntry {
|
|
79
|
+
id: string;
|
|
80
|
+
at: number;
|
|
81
|
+
action: string;
|
|
82
|
+
operator: string;
|
|
83
|
+
/** Hashed account handle, never the account id. */
|
|
84
|
+
accountHandle: string;
|
|
85
|
+
snapshots: number;
|
|
86
|
+
bytes: number;
|
|
87
|
+
detail: string | null;
|
|
88
|
+
}
|
|
89
|
+
/** Typed access to the relay tables. */
|
|
90
|
+
export declare class VaultRelayStore {
|
|
91
|
+
readonly db: DatabaseInterface;
|
|
92
|
+
constructor(db: DatabaseInterface);
|
|
93
|
+
/** Names of relay tables that do not exist (empty when migrated). */
|
|
94
|
+
missingTables(): Promise<string[]>;
|
|
95
|
+
ensureAccount(accountId: string, now: number): Promise<void>;
|
|
96
|
+
getUsage(accountId: string): Promise<AccountUsage | null>;
|
|
97
|
+
registerDevice(accountId: string, deviceId: string, publicKey: string, now: number): Promise<RegisterDeviceResult>;
|
|
98
|
+
revokeDevice(accountId: string, deviceId: string, now: number): Promise<boolean>;
|
|
99
|
+
getDevice(accountId: string, deviceId: string): Promise<DeviceRecord | null>;
|
|
100
|
+
listDevices(accountId: string): Promise<DeviceRecord[]>;
|
|
101
|
+
getSupersession(accountId: string): Promise<SupersessionRecord | null>;
|
|
102
|
+
/**
|
|
103
|
+
* Record that `accountId` is replaced by `supersededBy`. One conditional
|
|
104
|
+
* insert: an existing record for the same target is `unchanged`, for
|
|
105
|
+
* another target a `conflict`; it is never overwritten.
|
|
106
|
+
*/
|
|
107
|
+
setSupersession(accountId: string, supersededBy: string, now: number): Promise<'superseded' | 'unchanged' | 'conflict'>;
|
|
108
|
+
/** True when some account was replaced by `accountId`. */
|
|
109
|
+
isSupersessionTarget(accountId: string): Promise<boolean>;
|
|
110
|
+
clearSupersession(accountId: string): Promise<boolean>;
|
|
111
|
+
countActiveDevices(accountId: string): Promise<number>;
|
|
112
|
+
getLapse(accountId: string): Promise<LapseRecord | null>;
|
|
113
|
+
/**
|
|
114
|
+
* Record the first observation of a lapse. One conditional insert: a lapse
|
|
115
|
+
* already recorded keeps its original time, so the window never slides.
|
|
116
|
+
*/
|
|
117
|
+
recordLapse(accountId: string, now: number): Promise<LapseRecord>;
|
|
118
|
+
/** Forget a lapse (the entitlement is active again); `true` if one existed. */
|
|
119
|
+
clearLapse(accountId: string): Promise<boolean>;
|
|
120
|
+
/** Mark a lapse swept, once; `false` when it was swept or cleared. */
|
|
121
|
+
markLapseSwept(accountId: string, now: number): Promise<boolean>;
|
|
122
|
+
/** Unswept lapses recorded at or before `cutoff`, oldest first. */
|
|
123
|
+
listDueLapses(cutoff: number, limit: number): Promise<LapseRecord[]>;
|
|
124
|
+
/** True when the account holds at least one committed snapshot. */
|
|
125
|
+
hasCommitted(accountId: string): Promise<boolean>;
|
|
126
|
+
/**
|
|
127
|
+
* Accounts above `afterAccountId` (ordered) that hold a committed snapshot
|
|
128
|
+
* and have no lapse record: the candidates for the sweep's discovery pass.
|
|
129
|
+
*/
|
|
130
|
+
listUnrecordedAccounts(afterAccountId: string, limit: number): Promise<string[]>;
|
|
131
|
+
/** Append an audit record. The audit table is never updated or deleted. */
|
|
132
|
+
appendAudit(entry: AuditEntry): Promise<void>;
|
|
133
|
+
/** Newest audit records first. */
|
|
134
|
+
listAudit(limit: number): Promise<AuditEntry[]>;
|
|
135
|
+
/** Record a nonce; `false` when it was already used (a replay). */
|
|
136
|
+
consumeNonce(accountId: string, deviceId: string, nonce: string, expiresAt: number): Promise<boolean>;
|
|
137
|
+
pruneNonces(now: number): Promise<void>;
|
|
138
|
+
/** Reserve bytes and one snapshot slot; `false` when it would exceed quota. */
|
|
139
|
+
reserve(accountId: string, bytes: number, maxBytes: number, maxSnapshots: number): Promise<boolean>;
|
|
140
|
+
release(accountId: string, bytes: number): Promise<void>;
|
|
141
|
+
/** Recompute the quota counters from the snapshot rows, in one statement. */
|
|
142
|
+
reconcileUsage(accountId: string): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* Insert a pending snapshot. `false` when the sequence already exists or is
|
|
145
|
+
* at or below the account's high-water mark (it was published before, even
|
|
146
|
+
* if since deleted).
|
|
147
|
+
*/
|
|
148
|
+
createPending(record: {
|
|
149
|
+
accountId: string;
|
|
150
|
+
sequence: number;
|
|
151
|
+
uploadId: string;
|
|
152
|
+
deviceId: string;
|
|
153
|
+
byteSize: number;
|
|
154
|
+
chunkSize: number;
|
|
155
|
+
chunkCount: number;
|
|
156
|
+
sha256: string;
|
|
157
|
+
createdAt: number;
|
|
158
|
+
}): Promise<boolean>;
|
|
159
|
+
getByUpload(accountId: string, uploadId: string): Promise<SnapshotRecord | null>;
|
|
160
|
+
getCommitted(accountId: string, sequence: number): Promise<SnapshotRecord | null>;
|
|
161
|
+
latestCommitted(accountId: string): Promise<SnapshotRecord | null>;
|
|
162
|
+
/** Every snapshot of the account, newest sequence first. */
|
|
163
|
+
listSnapshots(accountId: string, status?: SnapshotStatus): Promise<SnapshotRecord[]>;
|
|
164
|
+
/** Pending uploads created before `cutoff`, across accounts. */
|
|
165
|
+
stalePending(cutoff: number, limit: number): Promise<SnapshotRecord[]>;
|
|
166
|
+
/**
|
|
167
|
+
* Raise the account's sequence high-water mark to `sequence`. Fails when a
|
|
168
|
+
* higher sequence is already published, so a stale upload can never become
|
|
169
|
+
* latest and an old sequence can never be republished, and when `sequence`
|
|
170
|
+
* is more than `maxJump` above the mark, so one commit can never push the
|
|
171
|
+
* mark out of reach of every later upload.
|
|
172
|
+
*/
|
|
173
|
+
advanceHighWater(accountId: string, sequence: number, maxJump: number): Promise<boolean>;
|
|
174
|
+
/**
|
|
175
|
+
* Operator reset: lower the high-water mark to `sequence`, only while the
|
|
176
|
+
* mark is not already below it and no snapshot row (pending or committed)
|
|
177
|
+
* sits above it, so the mark never ends up beneath a stored sequence.
|
|
178
|
+
*/
|
|
179
|
+
resetHighWater(accountId: string, sequence: number): Promise<boolean>;
|
|
180
|
+
/** Publish a pending upload; `false` when it is not pending any more. */
|
|
181
|
+
markCommitted(accountId: string, uploadId: string, now: number): Promise<boolean>;
|
|
182
|
+
/**
|
|
183
|
+
* Delete the snapshot row only while it still has `status`, so removing a
|
|
184
|
+
* pending upload can never delete a snapshot that was published meanwhile.
|
|
185
|
+
* Returns the row when this call removed it.
|
|
186
|
+
*/
|
|
187
|
+
deleteSnapshotRow(accountId: string, uploadId: string, status: SnapshotStatus): Promise<SnapshotRecord | null>;
|
|
188
|
+
/**
|
|
189
|
+
* Delete a committed snapshot row only while another committed snapshot of
|
|
190
|
+
* the account remains, in one statement. Returns the row when this call
|
|
191
|
+
* removed it, `null` when it is gone or is the account's last committed
|
|
192
|
+
* snapshot. Two devices deleting the final two snapshots at the same
|
|
193
|
+
* instant can still both pass on PostgreSQL (each sees the other), which
|
|
194
|
+
* the device API accepts as a residual risk; retention never goes through
|
|
195
|
+
* here and always keeps at least one.
|
|
196
|
+
*/
|
|
197
|
+
deleteCommittedUnlessLast(accountId: string, uploadId: string): Promise<SnapshotRecord | null>;
|
|
198
|
+
/**
|
|
199
|
+
* Record a stored chunk object, only while its upload is still pending for
|
|
200
|
+
* the account and only if the index has no object yet. Returns `false`
|
|
201
|
+
* otherwise; the caller then removes the object it wrote, so a late write
|
|
202
|
+
* after an abort, expiry, or commit leaves nothing behind.
|
|
203
|
+
*/
|
|
204
|
+
addChunk(accountId: string, uploadId: string, chunk: ChunkRecord): Promise<boolean>;
|
|
205
|
+
listChunks(uploadId: string): Promise<ChunkRecord[]>;
|
|
206
|
+
getChunk(uploadId: string, index: number): Promise<ChunkRecord | null>;
|
|
207
|
+
/** Delete one recorded chunk attempt; `true` when this call removed it. */
|
|
208
|
+
deleteChunkAttempt(uploadId: string, index: number, objectId: string): Promise<boolean>;
|
|
209
|
+
/** Delete every chunk row of an upload; returns the removed rows. */
|
|
210
|
+
deleteChunks(uploadId: string): Promise<ChunkRecord[]>;
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=metadata-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata-store.d.ts","sourceRoot":"","sources":["../src/metadata-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAG5D,eAAO,MAAM,kBAAkB,uMASrB,CAAC;AAkFX;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,EAAE,EAAE,iBAAiB,GACpB,OAAO,CAAC,IAAI,CAAC,CAIf;AAED,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEhD,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,YAAY,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,WAAW,CAAC;AAErD,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE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OAAO,CAAC,OAAO,CAAC;IAenB;;;;OAIG;IACG,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAiB3E,yEAAyE;IACnE,aAAa,CACjB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,OAAO,CAAC;IAYnB;;;;OAIG;IACG,iBAAiB,CACrB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAYjC;;;;;;;;OAQG;IACG,yBAAyB,CAC7B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAmBjC;;;;;OAKG;IACG,QAAQ,CACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,WAAW,GACjB,OAAO,CAAC,OAAO,CAAC;IAqBb,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IASpD,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAU5E,2EAA2E;IACrE,kBAAkB,CACtB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC;IAYnB,qEAAqE;IAC/D,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;CAQ7D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node `http` adapter for the relay's fetch-style handlers. The request URL is
|
|
3
|
+
* built from the request target on a fixed origin, so the Host header never
|
|
4
|
+
* influences routing or the signed path.
|
|
5
|
+
*/
|
|
6
|
+
import { type Server } from 'node:http';
|
|
7
|
+
export type FetchHandler = (request: Request) => Promise<Response>;
|
|
8
|
+
export interface NodeServerOptions {
|
|
9
|
+
/** Whole-request deadline in milliseconds (slow-body protection). */
|
|
10
|
+
requestTimeoutMs?: number;
|
|
11
|
+
}
|
|
12
|
+
/** Create (not start) an HTTP server around a fetch-style handler. */
|
|
13
|
+
export declare function createRelayHttpServer(handler: FetchHandler, options?: NodeServerOptions): Server;
|
|
14
|
+
//# sourceMappingURL=node-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-server.d.ts","sourceRoot":"","sources":["../src/node-server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAGL,KAAK,MAAM,EAEZ,MAAM,WAAW,CAAC;AAGnB,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAiDnE,MAAM,WAAW,iBAAiB;IAChC,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,sEAAsE;AACtE,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,YAAY,EACrB,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAeR"}
|