borgmcp-server 0.1.1
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/LICENSE +105 -0
- package/NOTICE +8 -0
- package/README.md +119 -0
- package/SECURITY.md +38 -0
- package/THIRD_PARTY_NOTICES.md +35 -0
- package/dist/bootstrap.d.ts +18 -0
- package/dist/bootstrap.js +104 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.js +96 -0
- package/dist/cli.js.map +1 -0
- package/dist/coordination-api.d.ts +25 -0
- package/dist/coordination-api.js +457 -0
- package/dist/coordination-api.js.map +1 -0
- package/dist/credentials.d.ts +58 -0
- package/dist/credentials.js +244 -0
- package/dist/credentials.js.map +1 -0
- package/dist/enrollment.d.ts +17 -0
- package/dist/enrollment.js +122 -0
- package/dist/enrollment.js.map +1 -0
- package/dist/https-server.d.ts +94 -0
- package/dist/https-server.js +814 -0
- package/dist/https-server.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.js +67 -0
- package/dist/main.js.map +1 -0
- package/dist/migrations.d.ts +8 -0
- package/dist/migrations.js +366 -0
- package/dist/migrations.js.map +1 -0
- package/dist/network-policy.d.ts +13 -0
- package/dist/network-policy.js +49 -0
- package/dist/network-policy.js.map +1 -0
- package/dist/operator-error.d.ts +3 -0
- package/dist/operator-error.js +63 -0
- package/dist/operator-error.js.map +1 -0
- package/dist/principal.d.ts +32 -0
- package/dist/principal.js +64 -0
- package/dist/principal.js.map +1 -0
- package/dist/protocol-draft.d.ts +2 -0
- package/dist/protocol-draft.js +31 -0
- package/dist/protocol-draft.js.map +1 -0
- package/dist/service.d.ts +61 -0
- package/dist/service.js +455 -0
- package/dist/service.js.map +1 -0
- package/dist/start-options.d.ts +2 -0
- package/dist/start-options.js +46 -0
- package/dist/start-options.js.map +1 -0
- package/dist/store.d.ts +327 -0
- package/dist/store.js +1729 -0
- package/dist/store.js.map +1 -0
- package/npm-shrinkwrap.json +1942 -0
- package/package.json +60 -0
- package/src/bootstrap.ts +127 -0
- package/src/cli.ts +102 -0
- package/src/coordination-api.ts +508 -0
- package/src/credentials.ts +319 -0
- package/src/enrollment.ts +156 -0
- package/src/https-server.ts +962 -0
- package/src/index.ts +3 -0
- package/src/main.ts +73 -0
- package/src/migrations.ts +394 -0
- package/src/network-policy.ts +65 -0
- package/src/operator-error.ts +97 -0
- package/src/principal.ts +106 -0
- package/src/protocol-draft.ts +32 -0
- package/src/service.ts +525 -0
- package/src/start-options.ts +46 -0
- package/src/store.ts +2316 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const publicMessages = Object.freeze({
|
|
2
|
+
START_LAN_DUPLICATE: "Provide --lan only once.",
|
|
3
|
+
START_HOST_DUPLICATE: "Provide --host only once.",
|
|
4
|
+
START_PORT_DUPLICATE: "Provide --port only once.",
|
|
5
|
+
START_HOST_MISSING: "Provide an IP address after --host.",
|
|
6
|
+
START_PORT_MISSING: "Provide a port number after --port.",
|
|
7
|
+
START_PORT_INVALID: "Provide --port as an integer from 0 to 65535.",
|
|
8
|
+
START_OPTION_UNKNOWN: "Use only documented start options; run borg-mcp-server help.",
|
|
9
|
+
BIND_PORT_INVALID: "Configure the listen port as an integer from 0 to 65535.",
|
|
10
|
+
BIND_HOST_INVALID: "Configure --host as an explicit IP address.",
|
|
11
|
+
BIND_WILDCARD: "Choose a specific loopback or private-LAN IP; wildcard binds are prohibited.",
|
|
12
|
+
BIND_PUBLIC: "Choose a loopback or private-LAN IP; public-routable binds are unsupported.",
|
|
13
|
+
BIND_LAN_CONSENT: "Add --lan to consent to this private-LAN start.",
|
|
14
|
+
SERVER_FILES_MISSING: "Configure BORG_SERVER_DATA_DIR or the required TLS file variables.",
|
|
15
|
+
DATA_PATH_SYMLINK: "Choose a BORG_SERVER_DATA_DIR path that contains no symbolic links.",
|
|
16
|
+
LAN_CA_KEY_ONLINE: "Move ca.key out of the runtime data directory before private-LAN startup.",
|
|
17
|
+
RUNTIME_ACTIVE: "Stop the server before running offline client administration.",
|
|
18
|
+
RUNTIME_LOCK_UNSAFE: "Ensure runtime.lock is a private regular file before retrying.",
|
|
19
|
+
RUNTIME_LOCK_INVALID: "Confirm the server is stopped, then remove the invalid runtime.lock.",
|
|
20
|
+
RUNTIME_LOCK_STALE: "Confirm the recorded server process is stopped, then remove runtime.lock.",
|
|
21
|
+
ACTIVITY_LIMIT_INVALID: "Set BORG_SERVER_MAX_ACTIVITY_ENTRIES_PER_CUBE to a positive integer.",
|
|
22
|
+
DATABASE_LIMIT_INVALID: "Set BORG_SERVER_MAX_DATABASE_BYTES to a positive integer.",
|
|
23
|
+
DISK_RESERVE_INVALID: "Set BORG_SERVER_MIN_FREE_DISK_BYTES to a positive integer.",
|
|
24
|
+
CLIENT_NOT_FOUND: "Provide an existing active client ID.",
|
|
25
|
+
GRANT_NOT_FOUND: "Provide an existing client cube grant.",
|
|
26
|
+
RECOVERY_INVALID: "Provide the active recovery credential through the private prompt.",
|
|
27
|
+
});
|
|
28
|
+
const operatorErrorCodes = new WeakMap();
|
|
29
|
+
const operatorErrorCapability = Object.freeze({});
|
|
30
|
+
class OperatorError extends Error {
|
|
31
|
+
#operatorCode;
|
|
32
|
+
constructor(capability, code) {
|
|
33
|
+
super(Object.hasOwn(publicMessages, code) ? publicMessages[code] : "Operator error rejected.");
|
|
34
|
+
if (capability !== operatorErrorCapability || !Object.hasOwn(publicMessages, code)) {
|
|
35
|
+
throw new Error("Operator error construction is unavailable.");
|
|
36
|
+
}
|
|
37
|
+
this.name = "OperatorError";
|
|
38
|
+
this.#operatorCode = code;
|
|
39
|
+
operatorErrorCodes.set(this, code);
|
|
40
|
+
Object.freeze(this);
|
|
41
|
+
}
|
|
42
|
+
get code() {
|
|
43
|
+
return this.#operatorCode;
|
|
44
|
+
}
|
|
45
|
+
get publicMessage() {
|
|
46
|
+
return publicMessages[this.#operatorCode];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export const operatorErrors = Object.freeze(Object.fromEntries(Object.keys(publicMessages).map((code) => [
|
|
50
|
+
code,
|
|
51
|
+
new OperatorError(operatorErrorCapability, code),
|
|
52
|
+
])));
|
|
53
|
+
export function operatorPublicMessage(error) {
|
|
54
|
+
if (typeof error !== "object" || error === null)
|
|
55
|
+
return null;
|
|
56
|
+
const code = operatorErrorCodes.get(error);
|
|
57
|
+
if (code === undefined)
|
|
58
|
+
return null;
|
|
59
|
+
if (Object.getPrototypeOf(error) !== OperatorError.prototype || !Object.isFrozen(error))
|
|
60
|
+
return null;
|
|
61
|
+
return publicMessages[code];
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=operator-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operator-error.js","sourceRoot":"","sources":["../src/operator-error.ts"],"names":[],"mappings":"AA2BA,MAAM,cAAc,GAAgD,MAAM,CAAC,MAAM,CAAC;IAChF,mBAAmB,EAAE,0BAA0B;IAC/C,oBAAoB,EAAE,2BAA2B;IACjD,oBAAoB,EAAE,2BAA2B;IACjD,kBAAkB,EAAE,qCAAqC;IACzD,kBAAkB,EAAE,qCAAqC;IACzD,kBAAkB,EAAE,+CAA+C;IACnE,oBAAoB,EAAE,8DAA8D;IACpF,iBAAiB,EAAE,0DAA0D;IAC7E,iBAAiB,EAAE,6CAA6C;IAChE,aAAa,EAAE,8EAA8E;IAC7F,WAAW,EAAE,6EAA6E;IAC1F,gBAAgB,EAAE,iDAAiD;IACnE,oBAAoB,EAAE,oEAAoE;IAC1F,iBAAiB,EAAE,qEAAqE;IACxF,iBAAiB,EAAE,2EAA2E;IAC9F,cAAc,EAAE,+DAA+D;IAC/E,mBAAmB,EAAE,gEAAgE;IACrF,oBAAoB,EAAE,sEAAsE;IAC5F,kBAAkB,EAAE,2EAA2E;IAC/F,sBAAsB,EAAE,sEAAsE;IAC9F,sBAAsB,EAAE,2DAA2D;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AAI,CAAC;CACjD,CAAC,CAC4C,CACjD,CAAC;AAEF,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC7D,MAAM,IAAI,GAAG,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3C,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACpC,IAAI,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,aAAa,CAAC,SAAS,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACrG,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
declare const principalBrand: unique symbol;
|
|
2
|
+
interface ServerDerivedPrincipal {
|
|
3
|
+
readonly [principalBrand]: true;
|
|
4
|
+
}
|
|
5
|
+
export interface OperatorPrincipal extends ServerDerivedPrincipal {
|
|
6
|
+
readonly kind: "operator";
|
|
7
|
+
readonly id: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ClientPrincipal extends ServerDerivedPrincipal {
|
|
10
|
+
readonly kind: "client";
|
|
11
|
+
readonly id: string;
|
|
12
|
+
}
|
|
13
|
+
export interface DroneSessionPrincipal extends ServerDerivedPrincipal {
|
|
14
|
+
readonly kind: "drone-session";
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly clientId: string;
|
|
17
|
+
readonly cubeId: string;
|
|
18
|
+
readonly droneId: string;
|
|
19
|
+
}
|
|
20
|
+
export interface DroneSessionPrincipalInput {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly clientId: string;
|
|
23
|
+
readonly cubeId: string;
|
|
24
|
+
readonly droneId: string;
|
|
25
|
+
}
|
|
26
|
+
export type Principal = OperatorPrincipal | ClientPrincipal | DroneSessionPrincipal;
|
|
27
|
+
export declare function operatorPrincipal(id: string): OperatorPrincipal;
|
|
28
|
+
export declare function clientPrincipal(id: string): ClientPrincipal;
|
|
29
|
+
export declare function droneSessionPrincipal(input: DroneSessionPrincipalInput): DroneSessionPrincipal;
|
|
30
|
+
export declare function assertServerDerivedPrincipal(value: unknown): asserts value is Principal;
|
|
31
|
+
export declare function assertCanonicalUuid(value: string, label: string): void;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const canonicalUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u;
|
|
2
|
+
const principalBrand = Symbol("server-derived-principal");
|
|
3
|
+
const derivedPrincipals = new WeakSet();
|
|
4
|
+
export function operatorPrincipal(id) {
|
|
5
|
+
assertCanonicalUuid(id, "Principal id");
|
|
6
|
+
return branded({ kind: "operator", id });
|
|
7
|
+
}
|
|
8
|
+
export function clientPrincipal(id) {
|
|
9
|
+
assertCanonicalUuid(id, "Principal id");
|
|
10
|
+
return branded({ kind: "client", id });
|
|
11
|
+
}
|
|
12
|
+
export function droneSessionPrincipal(input) {
|
|
13
|
+
assertCanonicalUuid(input.id, "Principal id");
|
|
14
|
+
assertCanonicalUuid(input.clientId, "Client id");
|
|
15
|
+
assertCanonicalUuid(input.cubeId, "Cube id");
|
|
16
|
+
assertCanonicalUuid(input.droneId, "Drone id");
|
|
17
|
+
return branded({ kind: "drone-session", ...input });
|
|
18
|
+
}
|
|
19
|
+
export function assertServerDerivedPrincipal(value) {
|
|
20
|
+
if (typeof value !== "object" || value === null || !derivedPrincipals.has(value)) {
|
|
21
|
+
throw new Error("Principal must be created by the server authentication boundary.");
|
|
22
|
+
}
|
|
23
|
+
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
24
|
+
const kind = frozenDataValue(descriptors, "kind");
|
|
25
|
+
const expectedKeys = kind === "drone-session"
|
|
26
|
+
? ["kind", "id", "clientId", "cubeId", "droneId"]
|
|
27
|
+
: kind === "operator" || kind === "client" ? ["kind", "id"] : [];
|
|
28
|
+
const ownNames = Object.getOwnPropertyNames(value);
|
|
29
|
+
const brand = Object.getOwnPropertyDescriptor(value, principalBrand);
|
|
30
|
+
if (Object.getPrototypeOf(value) !== Object.prototype || !Object.isFrozen(value) ||
|
|
31
|
+
!Object.hasOwn(value, principalBrand) || brand?.value !== true || brand.get !== undefined ||
|
|
32
|
+
brand.set !== undefined || brand.enumerable || brand.configurable || brand.writable ||
|
|
33
|
+
Object.getOwnPropertySymbols(value).length !== 1 || ownNames.length !== expectedKeys.length ||
|
|
34
|
+
expectedKeys.some((key) => !Object.hasOwn(value, key)) ||
|
|
35
|
+
ownNames.some((key) => !expectedKeys.includes(key)) ||
|
|
36
|
+
expectedKeys.some((key) => frozenDataValue(descriptors, key) === undefined)) {
|
|
37
|
+
throw new Error("Principal must be created by the server authentication boundary.");
|
|
38
|
+
}
|
|
39
|
+
for (const key of expectedKeys.filter((key) => key !== "kind")) {
|
|
40
|
+
if (!canonicalUuid.test(frozenDataValue(descriptors, key))) {
|
|
41
|
+
throw new Error("Principal must be created by the server authentication boundary.");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function assertCanonicalUuid(value, label) {
|
|
46
|
+
if (!canonicalUuid.test(value)) {
|
|
47
|
+
throw new Error(`${label} must be a canonical UUID.`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function branded(value) {
|
|
51
|
+
Object.defineProperty(value, principalBrand, { value: true });
|
|
52
|
+
const principal = Object.freeze(value);
|
|
53
|
+
derivedPrincipals.add(principal);
|
|
54
|
+
return principal;
|
|
55
|
+
}
|
|
56
|
+
function frozenDataValue(descriptors, key) {
|
|
57
|
+
const descriptor = descriptors[key];
|
|
58
|
+
return descriptor !== undefined && typeof descriptor.value === "string" &&
|
|
59
|
+
descriptor.get === undefined && descriptor.set === undefined && descriptor.enumerable === true &&
|
|
60
|
+
descriptor.configurable === false && descriptor.writable === false
|
|
61
|
+
? descriptor.value
|
|
62
|
+
: undefined;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=principal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"principal.js","sourceRoot":"","sources":["../src/principal.ts"],"names":[],"mappings":"AAAA,MAAM,aAAa,GAAG,4EAA4E,CAAC;AACnG,MAAM,cAAc,GAAkB,MAAM,CAAC,0BAA0B,CAAC,CAAC;AACzE,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAU,CAAC;AAiChD,MAAM,UAAU,iBAAiB,CAAC,EAAU;IAC1C,mBAAmB,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;IACxC,OAAO,OAAO,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,EAAU;IACxC,mBAAmB,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;IACxC,OAAO,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,KAAiC;IAEjC,mBAAmB,CAAC,KAAK,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;IAC9C,mBAAmB,CAAC,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IACjD,mBAAmB,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC7C,mBAAmB,CAAC,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC/C,OAAO,OAAO,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,KAAc;IACzD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,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OAAO,UAAU,CAAC,KAAK,KAAK,QAAQ;QACrE,UAAU,CAAC,GAAG,KAAK,SAAS,IAAI,UAAU,CAAC,GAAG,KAAK,SAAS,IAAI,UAAU,CAAC,UAAU,KAAK,IAAI;QAC9F,UAAU,CAAC,YAAY,KAAK,KAAK,IAAI,UAAU,CAAC,QAAQ,KAAK,KAAK;QAClE,CAAC,CAAC,UAAU,CAAC,KAAK;QAClB,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function createPart2ProtocolInfo(limits) {
|
|
2
|
+
return {
|
|
3
|
+
protocol_version: "1",
|
|
4
|
+
package: {
|
|
5
|
+
name: "borgmcp-shared",
|
|
6
|
+
version: "0.3.0",
|
|
7
|
+
},
|
|
8
|
+
capabilities: [
|
|
9
|
+
"coordination.core",
|
|
10
|
+
"auth.bearer",
|
|
11
|
+
"auth.revocation",
|
|
12
|
+
"auth.retry-safe-enrollment",
|
|
13
|
+
"scope.cube-isolation",
|
|
14
|
+
"transport.tls",
|
|
15
|
+
"authority.no-cloud-fallback",
|
|
16
|
+
"log.cursor",
|
|
17
|
+
"stream.sse",
|
|
18
|
+
"stream.replay",
|
|
19
|
+
"acks",
|
|
20
|
+
"claims",
|
|
21
|
+
"decisions",
|
|
22
|
+
],
|
|
23
|
+
limits: {
|
|
24
|
+
max_request_bytes: limits.maxRequestBodyBytes,
|
|
25
|
+
max_log_message_bytes: 10_240,
|
|
26
|
+
max_read_page_size: 500,
|
|
27
|
+
max_replay_page_size: 200,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=protocol-draft.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-draft.js","sourceRoot":"","sources":["../src/protocol-draft.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,uBAAuB,CAAC,MAAqB;IAC3D,OAAO;QACL,gBAAgB,EAAE,GAAG;QACrB,OAAO,EAAE;YACP,IAAI,EAAE,gBAAgB;YACtB,OAAO,EAAE,OAAO;SACjB;QACD,YAAY,EAAE;YACZ,mBAAmB;YACnB,aAAa;YACb,iBAAiB;YACjB,4BAA4B;YAC5B,sBAAsB;YACtB,eAAe;YACf,6BAA6B;YAC7B,YAAY;YACZ,YAAY;YACZ,eAAe;YACf,MAAM;YACN,QAAQ;YACR,WAAW;SACZ;QACD,MAAM,EAAE;YACN,iBAAiB,EAAE,MAAM,CAAC,mBAAmB;YAC7C,qBAAqB,EAAE,MAAM;YAC7B,kBAAkB,EAAE,GAAG;YACvB,oBAAoB,EAAE,GAAG;SAC1B;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type BootstrapResult } from "./bootstrap.js";
|
|
2
|
+
import { type HttpsServerOptions, type RunningServer } from "./https-server.js";
|
|
3
|
+
import { openStore, type StorageLimits } from "./store.js";
|
|
4
|
+
import type { CubeAccess } from "./store.js";
|
|
5
|
+
export interface ServerService {
|
|
6
|
+
readonly start: (args: readonly string[]) => Promise<void>;
|
|
7
|
+
readonly setup?: () => Promise<BootstrapResult>;
|
|
8
|
+
readonly rotateClient?: (clientId: string) => Promise<string>;
|
|
9
|
+
readonly revokeClient?: (clientId: string) => Promise<void>;
|
|
10
|
+
readonly grantClient?: (clientId: string, cubeId: string, access: CubeAccess) => Promise<void>;
|
|
11
|
+
readonly ungrantClient?: (clientId: string, cubeId: string) => Promise<void>;
|
|
12
|
+
readonly createClientInvitation?: (recoveryCredential: string) => Promise<string>;
|
|
13
|
+
readonly replaceOwnerInvitation?: (recoveryCredential: string) => Promise<string>;
|
|
14
|
+
}
|
|
15
|
+
export interface ServerEnvironment {
|
|
16
|
+
readonly BORG_SERVER_TLS_KEY_FILE?: string;
|
|
17
|
+
readonly BORG_SERVER_TLS_CERT_FILE?: string;
|
|
18
|
+
readonly BORG_SERVER_TLS_CA_FILE?: string;
|
|
19
|
+
readonly BORG_SERVER_DATA_DIR?: string;
|
|
20
|
+
readonly BORG_SERVER_BIND_HOST?: string;
|
|
21
|
+
readonly BORG_SERVER_MAX_ACTIVITY_ENTRIES_PER_CUBE?: string;
|
|
22
|
+
readonly BORG_SERVER_MAX_DATABASE_BYTES?: string;
|
|
23
|
+
readonly BORG_SERVER_MIN_FREE_DISK_BYTES?: string;
|
|
24
|
+
}
|
|
25
|
+
interface ServiceDependencies {
|
|
26
|
+
readonly environment: ServerEnvironment;
|
|
27
|
+
readonly readFile: (path: string) => Promise<Buffer>;
|
|
28
|
+
readonly readPrivateKey: (path: string) => Promise<Buffer>;
|
|
29
|
+
readonly startServer: (options: HttpsServerOptions) => Promise<RunningServer>;
|
|
30
|
+
readonly onStarted: (origin: string) => void;
|
|
31
|
+
readonly waitForShutdown: (server: RunningServer, signal?: AbortSignal) => Promise<void>;
|
|
32
|
+
readonly installShutdownHandlers?: () => {
|
|
33
|
+
readonly signal: AbortSignal;
|
|
34
|
+
readonly dispose: () => void;
|
|
35
|
+
};
|
|
36
|
+
readonly openStore?: typeof openStore;
|
|
37
|
+
readonly onStartupPhase?: (phase: "pre-lock" | "post-lock" | "pre-listen") => Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
export interface NodeServerTestHooks {
|
|
40
|
+
readonly onStartupPhase?: (phase: "pre-lock" | "post-lock" | "pre-listen") => Promise<void>;
|
|
41
|
+
readonly onSignalObserved?: () => void;
|
|
42
|
+
readonly onListening?: (origin: string) => void;
|
|
43
|
+
readonly wrapRunningServer?: (running: RunningServer) => RunningServer;
|
|
44
|
+
}
|
|
45
|
+
export declare function installNodeServerTestHooks(hooks: NodeServerTestHooks): () => void;
|
|
46
|
+
export declare function createNodeServerService(dependencies: ServiceDependencies): ServerService;
|
|
47
|
+
export declare function assertLanCaKeyOffline(runtimeDataDirectory: string): Promise<void>;
|
|
48
|
+
export declare function selectServerEnvironment(environment: NodeJS.ProcessEnv): ServerEnvironment;
|
|
49
|
+
export declare function resolveStorageLimits(environment: ServerEnvironment): StorageLimits;
|
|
50
|
+
export declare const nodeServerService: ServerService;
|
|
51
|
+
export declare function createOfflineCredentialService(offlineDataDirectory: string): Pick<Required<ServerService>, "rotateClient" | "revokeClient" | "grantClient" | "ungrantClient" | "createClientInvitation" | "replaceOwnerInvitation">;
|
|
52
|
+
interface RuntimeLock {
|
|
53
|
+
readonly release: () => Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
export declare function isFatalTeardownError(error: unknown): boolean;
|
|
56
|
+
export declare function acquireRuntimeLock(runtimeDataDirectory: string): Promise<RuntimeLock>;
|
|
57
|
+
export declare function installProcessShutdownHandlers(): {
|
|
58
|
+
readonly signal: AbortSignal;
|
|
59
|
+
readonly dispose: () => void;
|
|
60
|
+
};
|
|
61
|
+
export {};
|