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,46 @@
|
|
|
1
|
+
import type { BindOptionsInput } from "./network-policy.js";
|
|
2
|
+
import { operatorErrors, type OperatorErrorCode } from "./operator-error.js";
|
|
3
|
+
|
|
4
|
+
export function parseStartOptions(args: readonly string[]): BindOptionsInput {
|
|
5
|
+
let host: string | undefined;
|
|
6
|
+
let port: number | undefined;
|
|
7
|
+
let lanConsent = false;
|
|
8
|
+
|
|
9
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
10
|
+
const argument = args[index];
|
|
11
|
+
if (argument === "--lan") {
|
|
12
|
+
if (lanConsent) throw operatorErrors.START_LAN_DUPLICATE;
|
|
13
|
+
lanConsent = true;
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (argument === "--host") {
|
|
17
|
+
if (host !== undefined) throw operatorErrors.START_HOST_DUPLICATE;
|
|
18
|
+
host = requiredValue(args, index, "START_HOST_MISSING");
|
|
19
|
+
index += 1;
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (argument === "--port") {
|
|
23
|
+
if (port !== undefined) throw operatorErrors.START_PORT_DUPLICATE;
|
|
24
|
+
const value = requiredValue(args, index, "START_PORT_MISSING");
|
|
25
|
+
if (!/^\d+$/u.test(value)) throw operatorErrors.START_PORT_INVALID;
|
|
26
|
+
port = Number(value);
|
|
27
|
+
index += 1;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
throw operatorErrors.START_OPTION_UNKNOWN;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
...(host === undefined ? {} : { host }),
|
|
35
|
+
...(port === undefined ? {} : { port }),
|
|
36
|
+
...(lanConsent ? { lanConsent: true } : {}),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function requiredValue(args: readonly string[], index: number, code: OperatorErrorCode): string {
|
|
41
|
+
const value = args[index + 1];
|
|
42
|
+
if (value === undefined || value.startsWith("--")) {
|
|
43
|
+
throw operatorErrors[code];
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
46
|
+
}
|