@decionis/agentsafe 0.2.1 → 0.2.2

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.
Files changed (77) hide show
  1. package/dist/cli/Credentials.d.ts.map +1 -1
  2. package/dist/cli/Credentials.js +8 -1
  3. package/dist/cli/Credentials.js.map +1 -1
  4. package/dist/cli/Help.d.ts.map +1 -1
  5. package/dist/cli/Help.js +3 -2
  6. package/dist/cli/Help.js.map +1 -1
  7. package/dist/cli/Intercept.d.ts +46 -10
  8. package/dist/cli/Intercept.d.ts.map +1 -1
  9. package/dist/cli/Intercept.js +255 -27
  10. package/dist/cli/Intercept.js.map +1 -1
  11. package/dist/cli/Login.d.ts +7 -2
  12. package/dist/cli/Login.d.ts.map +1 -1
  13. package/dist/cli/Login.js +106 -3
  14. package/dist/cli/Login.js.map +1 -1
  15. package/dist/cli/Status.d.ts.map +1 -1
  16. package/dist/cli/Status.js +9 -4
  17. package/dist/cli/Status.js.map +1 -1
  18. package/dist/cli/TestCommand.d.ts +24 -2
  19. package/dist/cli/TestCommand.d.ts.map +1 -1
  20. package/dist/cli/TestCommand.js +122 -1
  21. package/dist/cli/TestCommand.js.map +1 -1
  22. package/dist/egress/TransparentDial.d.ts +4 -3
  23. package/dist/egress/TransparentDial.d.ts.map +1 -1
  24. package/dist/egress/TransparentDial.js +4 -3
  25. package/dist/egress/TransparentDial.js.map +1 -1
  26. package/dist/gateway/BoundaryTest.d.ts +54 -0
  27. package/dist/gateway/BoundaryTest.d.ts.map +1 -1
  28. package/dist/gateway/BoundaryTest.js +19 -7
  29. package/dist/gateway/BoundaryTest.js.map +1 -1
  30. package/dist/gateway/Gateway.d.ts +23 -0
  31. package/dist/gateway/Gateway.d.ts.map +1 -1
  32. package/dist/gateway/Gateway.js +39 -10
  33. package/dist/gateway/Gateway.js.map +1 -1
  34. package/dist/gateway/HostedBoundaryTest.d.ts +118 -0
  35. package/dist/gateway/HostedBoundaryTest.d.ts.map +1 -0
  36. package/dist/gateway/HostedBoundaryTest.js +235 -0
  37. package/dist/gateway/HostedBoundaryTest.js.map +1 -0
  38. package/dist/gateway/ShadowLedger.d.ts +21 -2
  39. package/dist/gateway/ShadowLedger.d.ts.map +1 -1
  40. package/dist/gateway/ShadowLedger.js +42 -12
  41. package/dist/gateway/ShadowLedger.js.map +1 -1
  42. package/dist/http/GatewayHttpServer.d.ts +7 -0
  43. package/dist/http/GatewayHttpServer.d.ts.map +1 -1
  44. package/dist/http/GatewayHttpServer.js +8 -0
  45. package/dist/http/GatewayHttpServer.js.map +1 -1
  46. package/dist/http/InterceptGovernor.d.ts +71 -0
  47. package/dist/http/InterceptGovernor.d.ts.map +1 -0
  48. package/dist/http/InterceptGovernor.js +128 -0
  49. package/dist/http/InterceptGovernor.js.map +1 -0
  50. package/dist/http/InterceptServer.d.ts +31 -1
  51. package/dist/http/InterceptServer.d.ts.map +1 -1
  52. package/dist/http/InterceptServer.js +58 -7
  53. package/dist/http/InterceptServer.js.map +1 -1
  54. package/dist/intercept/ClientHello.d.ts.map +1 -1
  55. package/dist/intercept/ClientHello.js +76 -72
  56. package/dist/intercept/ClientHello.js.map +1 -1
  57. package/dist/intercept/Der.d.ts +59 -0
  58. package/dist/intercept/Der.d.ts.map +1 -0
  59. package/dist/intercept/Der.js +140 -0
  60. package/dist/intercept/Der.js.map +1 -0
  61. package/dist/intercept/Destination.d.ts +1 -1
  62. package/dist/intercept/Destination.d.ts.map +1 -1
  63. package/dist/intercept/Destination.js +28 -24
  64. package/dist/intercept/Destination.js.map +1 -1
  65. package/dist/intercept/InterceptLedger.d.ts +43 -7
  66. package/dist/intercept/InterceptLedger.d.ts.map +1 -1
  67. package/dist/intercept/InterceptLedger.js +39 -18
  68. package/dist/intercept/InterceptLedger.js.map +1 -1
  69. package/dist/intercept/LeafIssuer.d.ts +40 -0
  70. package/dist/intercept/LeafIssuer.d.ts.map +1 -0
  71. package/dist/intercept/LeafIssuer.js +124 -0
  72. package/dist/intercept/LeafIssuer.js.map +1 -0
  73. package/dist/intercept/RequestHead.d.ts +1 -1
  74. package/dist/intercept/RequestHead.d.ts.map +1 -1
  75. package/dist/intercept/RequestHead.js +78 -66
  76. package/dist/intercept/RequestHead.js.map +1 -1
  77. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"Credentials.d.ts","sourceRoot":"","sources":["../../src/cli/Credentials.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAkBlD,sGAAsG;AACtG,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,UAAU,GAAG,MAAM,CAE3D;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,UAAU,GAAG,MAAM,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,UAAU,GAAG,iBAAiB,GAAG,IAAI,CAIxE;AAED,qDAAqD;AACrD,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,GAAG,MAAM,CAEvF;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,UAAU,GAAG,MAAM,CAIxD"}
1
+ {"version":3,"file":"Credentials.d.ts","sourceRoot":"","sources":["../../src/cli/Credentials.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAkBlD,sGAAsG;AACtG,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,UAAU,GAAG,MAAM,CAE3D;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,UAAU,GAAG,MAAM,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,UAAU,GAAG,iBAAiB,GAAG,IAAI,CAWxE;AAED,qDAAqD;AACrD,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,GAAG,MAAM,CAEvF;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,UAAU,GAAG,MAAM,CAIxD"}
@@ -37,7 +37,14 @@ export function readCredentials(io) {
37
37
  const stored = readStoredCredentials(store(io));
38
38
  if (stored === null)
39
39
  return null;
40
- return { apiKey: stored.apiKey, tenantId: stored.tenantId, endpoint: stored.endpoint };
40
+ // Whether the key is a provisional workspace's travels with it: the loader
41
+ // runs such a key in shadow and refuses to enforce with it.
42
+ return {
43
+ apiKey: stored.apiKey,
44
+ tenantId: stored.tenantId,
45
+ endpoint: stored.endpoint,
46
+ ...(stored.provisional === undefined ? {} : { provisional: stored.provisional }),
47
+ };
41
48
  }
42
49
  /** Writes the login, readable by this user alone. */
43
50
  export function writeCredentials(io, credentials) {
@@ -1 +1 @@
1
- {"version":3,"file":"Credentials.js","sourceRoot":"","sources":["../../src/cli/Credentials.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,oBAAoB,IAAI,0BAA0B,EAClD,eAAe,IAAI,qBAAqB,EACxC,qBAAqB,EACrB,sBAAsB,GAEvB,MAAM,+BAA+B,CAAC;AAIvC,SAAS,KAAK,CAAC,EAAc;IAC3B,OAAO;QACL,GAAG,EAAE,EAAE,CAAC,GAAG;QACX,IAAI,EAAE,EAAE,CAAC,IAAI;QACb,KAAK,EAAE;YACL,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YACnC,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;gBAC1B,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;YACnC,CAAC;YACD,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE;gBACd,EAAE,CAAC,KAAK,CAAC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AED,qDAAqD;AACrD,MAAM,UAAU,gBAAgB,CAAC,EAAc,EAAE,WAA8B;IAC7E,OAAO,sBAAsB,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,EAAc;IAC9C,MAAM,IAAI,GAAG,eAAe,CAAC,EAAE,CAAC,CAAC;IACjC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACtB,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Help.d.ts","sourceRoot":"","sources":["../../src/cli/Help.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAqC7C"}
1
+ {"version":3,"file":"Help.d.ts","sourceRoot":"","sources":["../../src/cli/Help.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAsC7C"}
package/dist/cli/Help.js CHANGED
@@ -9,12 +9,12 @@ export function usage(version) {
9
9
  " init Write agentsafe.yaml for this directory",
10
10
  " proxy Run the gateway (--upstream URL, --port N, --mode shadow|enforcement)",
11
11
  " run Run the gateway from agentsafe.yaml (same command, file first)",
12
- " intercept Run the transparent interceptor the redirect rules point at (observe)",
12
+ " intercept Run the transparent interceptor: observe every destination, govern the listed ones",
13
13
  " status Ask a running gateway what it is doing",
14
14
  " doctor Check the binary, configuration, upstream, Decionis and credentials",
15
15
  " test Show what reaches a target without the boundary and what enforcement prevents",
16
16
  " config Print the effective configuration and where each setting came from",
17
- " login | logout Store or remove a Decionis key for this user",
17
+ " login | logout Store or remove a Decionis key for this user (--provision mints a free workspace)",
18
18
  " version Print the version",
19
19
  "",
20
20
  "Evidence",
@@ -27,6 +27,7 @@ export function usage(version) {
27
27
  " probe-containment Report whether a system of record answers the agent zone",
28
28
  "",
29
29
  " test [name=host:port]... also dials each real target: does it answer without the gateway?",
30
+ " test --hosted the same requests with Decionis deciding, in shadow, against your workspace",
30
31
  "",
31
32
  "Options shared by proxy, run, status, doctor and config:",
32
33
  " --config <file> --upstream <url> --port <n> --listen <host:port>",
@@ -1 +1 @@
1
- {"version":3,"file":"Help.js","sourceRoot":"","sources":["../../src/cli/Help.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,MAAM,UAAU,KAAK,CAAC,OAAe;IACnC,OAAO;QACL,aAAa,OAAO,2DAA2D;QAC/E,EAAE;QACF,sCAAsC;QACtC,EAAE;QACF,SAAS;QACT,gEAAgE;QAChE,8FAA8F;QAC9F,uFAAuF;QACvF,8FAA8F;QAC9F,+DAA+D;QAC/D,4FAA4F;QAC5F,sGAAsG;QACtG,2FAA2F;QAC3F,qEAAqE;QACrE,0CAA0C;QAC1C,EAAE;QACF,UAAU;QACV,2DAA2D;QAC3D,0DAA0D;QAC1D,oFAAoF;QACpF,EAAE;QACF,kBAAkB;QAClB,uEAAuE;QACvE,iFAAiF;QACjF,EAAE;QACF,8FAA8F;QAC9F,EAAE;QACF,0DAA0D;QAC1D,uEAAuE;QACvE,uEAAuE;QACvE,mDAAmD;QACnD,EAAE;QACF,oEAAoE;QACpE,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
1
+ {"version":3,"file":"Help.js","sourceRoot":"","sources":["../../src/cli/Help.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,MAAM,UAAU,KAAK,CAAC,OAAe;IACnC,OAAO;QACL,aAAa,OAAO,2DAA2D;QAC/E,EAAE;QACF,sCAAsC;QACtC,EAAE;QACF,SAAS;QACT,gEAAgE;QAChE,8FAA8F;QAC9F,uFAAuF;QACvF,2GAA2G;QAC3G,+DAA+D;QAC/D,4FAA4F;QAC5F,sGAAsG;QACtG,2FAA2F;QAC3F,0GAA0G;QAC1G,0CAA0C;QAC1C,EAAE;QACF,UAAU;QACV,2DAA2D;QAC3D,0DAA0D;QAC1D,oFAAoF;QACpF,EAAE;QACF,kBAAkB;QAClB,uEAAuE;QACvE,iFAAiF;QACjF,EAAE;QACF,8FAA8F;QAC9F,oGAAoG;QACpG,EAAE;QACF,0DAA0D;QAC1D,uEAAuE;QACvE,uEAAuE;QACvE,mDAAmD;QACnD,EAAE;QACF,oEAAoE;QACpE,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -1,30 +1,66 @@
1
+ import { type GatewayDependencies } from "../gateway/Gateway.js";
2
+ import { type GatewayConfig } from "../gateway/GatewayConfig.js";
3
+ import { type UnlistedPolicy } from "../http/InterceptGovernor.js";
1
4
  import { type InterceptEvent, type InterceptorDependencies, type InterceptorOptions } from "../http/InterceptServer.js";
5
+ import type { InterceptProtocol } from "../intercept/Destination.js";
6
+ import { type ParsedArguments } from "./Arguments.js";
2
7
  import type { CliProcess } from "./CliProcess.js";
3
8
  export declare const INTERCEPT_ARGUMENTS: {
4
- readonly valued: readonly ["http-port", "https-port", "bind"];
5
- readonly flags: readonly ["json"];
9
+ readonly valued: readonly ["http-port", "https-port", "bind", "govern", "unlisted", "ca-cert", "ca-key", "mode", "failure-policy", "authority", "config"];
10
+ readonly flags: readonly ["json", "verbose"];
6
11
  };
7
12
  /** The variables the sidecar is configured with; the flags win over them. */
8
13
  export declare const INTERCEPT_ENVIRONMENT: {
9
14
  readonly httpPort: "AGENTSAFE_INTERCEPT_HTTP_PORT";
10
15
  readonly httpsPort: "AGENTSAFE_INTERCEPT_HTTPS_PORT";
11
16
  readonly bind: "AGENTSAFE_INTERCEPT_BIND";
17
+ /** The destinations to govern, comma-separated host names; empty observes everything. */
18
+ readonly govern: "AGENTSAFE_INTERCEPT_GOVERN";
19
+ /** `passthrough` or `refuse` for a destination not governed. */
20
+ readonly unlisted: "AGENTSAFE_INTERCEPT_UNLISTED";
21
+ /** The operator authority's certificate, PEM, that governed TLS is terminated under. */
22
+ readonly caCertificateFile: "AGENTSAFE_INTERCEPT_CA_CERT_FILE";
23
+ /** The operator authority's private key, PEM. */
24
+ readonly caKeyFile: "AGENTSAFE_INTERCEPT_CA_KEY_FILE";
12
25
  };
13
26
  export declare class InterceptConfigError extends Error {
14
- readonly code: "CONFIG_INVALID";
27
+ readonly code: "CONFIG_INVALID" | "CONFIG_MISSING";
15
28
  readonly setting: string;
16
- constructor(code: "CONFIG_INVALID", setting: string);
29
+ constructor(code: "CONFIG_INVALID" | "CONFIG_MISSING", setting: string, detail?: string);
17
30
  }
18
- /** The interceptor's options from the flags and the environment, each named when refused. */
19
- export declare function resolveInterceptor(argv: readonly string[], env: Readonly<Record<string, string | undefined>>): InterceptorOptions;
31
+ /** What an operator asked the interceptor to govern, before any file is read. */
32
+ export interface GovernSettings {
33
+ readonly hosts: ReadonlySet<string>;
34
+ readonly unlisted: UnlistedPolicy;
35
+ /** Where the operator authority's certificate and key are; null when governed TLS is not to be terminated. */
36
+ readonly authority: {
37
+ readonly certificateFile: string;
38
+ readonly keyFile: string;
39
+ } | null;
40
+ }
41
+ export interface InterceptSettings {
42
+ readonly listeners: InterceptorOptions;
43
+ /** Null when nothing is governed and nothing is refused: the observe phase alone. */
44
+ readonly govern: GovernSettings | null;
45
+ }
46
+ /** The interceptor's settings from the flags and the environment, each named when refused. */
47
+ export declare function resolveIntercept(parsed: ParsedArguments, env: Readonly<Record<string, string | undefined>>): InterceptSettings;
20
48
  /** One line per event for a terminal; the JSON form is the event itself. */
21
49
  export declare function describe(event: InterceptEvent, version: string): string;
50
+ /** What a test hands in beneath the command: the sockets, the clock, and the gateways' own seams. */
51
+ export interface InterceptDependencies extends Partial<Omit<InterceptorDependencies, "emit" | "governor">> {
52
+ readonly gateway?: GatewayDependencies;
53
+ }
54
+ /** The configuration for one governed destination: the shared settings, with that host as the upstream. */
55
+ export declare function governedConfig(base: GatewayConfig, host: string, protocol: InterceptProtocol): GatewayConfig;
22
56
  /**
23
57
  * `agentsafe intercept`: the transparent interceptor as a process, the
24
58
  * sidecar the redirect rules point at. It binds its listeners, reports every
25
- * destination it places or refuses as one line, and on `SIGTERM` or `SIGINT`
26
- * prints the ledger's report, stops, and exits 0. It holds no key and asks
27
- * no authority: this is the observe phase.
59
+ * destination it places, governs or refuses as one line, and on `SIGTERM` or
60
+ * `SIGINT` prints the ledger's report, stops, and exits 0. With nothing to
61
+ * govern it holds no key and asks no authority; with governed destinations it
62
+ * runs the gateway for each, under the configuration `agentsafe proxy`
63
+ * takes, and terminates their TLS under the operator's authority.
28
64
  */
29
- export declare function runIntercept(io: CliProcess, argv: readonly string[], dependencies?: Partial<Omit<InterceptorDependencies, "emit">>): Promise<void>;
65
+ export declare function runIntercept(io: CliProcess, argv: readonly string[], dependencies?: InterceptDependencies): Promise<void>;
30
66
  //# sourceMappingURL=Intercept.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Intercept.d.ts","sourceRoot":"","sources":["../../src/cli/Intercept.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACxB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,eAAO,MAAM,mBAAmB;;;CAGtB,CAAC;AAEX,6EAA6E;AAC7E,eAAO,MAAM,qBAAqB;;;;CAIxB,CAAC;AAEX,qBAAa,oBAAqB,SAAQ,KAAK;aAE3B,IAAI,EAAE,gBAAgB;aACtB,OAAO,EAAE,MAAM;gBADf,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,MAAM;CAKlC;AAiBD,6FAA6F;AAC7F,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAChD,kBAAkB,CA6BpB;AAED,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,KAAK,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fig.js";
3
+ import { GatewayHttpServer } from "../http/GatewayHttpServer.js";
4
+ import { GOVERN_DEFAULTS, InterceptGovernor, } from "../http/InterceptGovernor.js";
1
5
  import { INTERCEPT_DEFAULTS, Interceptor, } from "../http/InterceptServer.js";
6
+ import { LeafIssuer, LeafIssuerError } from "../intercept/LeafIssuer.js";
7
+ import { parseAuthority } from "../intercept/RequestHead.js";
2
8
  import { packageVersion } from "../Version.js";
3
- import { ArgumentError, optionPort, optionValue, parseArguments } from "./Arguments.js";
9
+ import { ArgumentError, optionPort, optionValue, parseArguments, } from "./Arguments.js";
10
+ import { ConfigFileError, loadConfigFile } from "./ConfigFile.js";
11
+ import { readCredentials } from "./Credentials.js";
4
12
  import { refusalLine, speaksJson } from "./Proxy.js";
5
13
  export const INTERCEPT_ARGUMENTS = {
6
- valued: ["http-port", "https-port", "bind"],
7
- flags: ["json"],
14
+ valued: [
15
+ "http-port",
16
+ "https-port",
17
+ "bind",
18
+ "govern",
19
+ "unlisted",
20
+ "ca-cert",
21
+ "ca-key",
22
+ "mode",
23
+ "failure-policy",
24
+ "authority",
25
+ "config",
26
+ ],
27
+ flags: ["json", "verbose"],
8
28
  };
9
29
  /** The variables the sidecar is configured with; the flags win over them. */
10
30
  export const INTERCEPT_ENVIRONMENT = {
11
31
  httpPort: "AGENTSAFE_INTERCEPT_HTTP_PORT",
12
32
  httpsPort: "AGENTSAFE_INTERCEPT_HTTPS_PORT",
13
33
  bind: "AGENTSAFE_INTERCEPT_BIND",
34
+ /** The destinations to govern, comma-separated host names; empty observes everything. */
35
+ govern: "AGENTSAFE_INTERCEPT_GOVERN",
36
+ /** `passthrough` or `refuse` for a destination not governed. */
37
+ unlisted: "AGENTSAFE_INTERCEPT_UNLISTED",
38
+ /** The operator authority's certificate, PEM, that governed TLS is terminated under. */
39
+ caCertificateFile: "AGENTSAFE_INTERCEPT_CA_CERT_FILE",
40
+ /** The operator authority's private key, PEM. */
41
+ caKeyFile: "AGENTSAFE_INTERCEPT_CA_KEY_FILE",
14
42
  };
15
43
  export class InterceptConfigError extends Error {
16
44
  code;
17
45
  setting;
18
- constructor(code, setting) {
19
- super(`${code}: ${setting}`);
46
+ constructor(code, setting, detail) {
47
+ super(detail === undefined ? `${code}: ${setting}` : `${code}: ${setting} (${detail})`);
20
48
  this.code = code;
21
49
  this.setting = setting;
22
50
  this.name = "InterceptConfigError";
@@ -33,9 +61,19 @@ function portFrom(flag, env, variable, fallback) {
33
61
  }
34
62
  return Number(value);
35
63
  }
36
- /** The interceptor's options from the flags and the environment, each named when refused. */
37
- export function resolveInterceptor(argv, env) {
38
- const parsed = parseArguments(argv, INTERCEPT_ARGUMENTS);
64
+ /** A governed destination is a host name: the name a TLS hello or a Host header carries. */
65
+ function governedHost(value, setting) {
66
+ const authority = parseAuthority(value.trim());
67
+ if (authority === null ||
68
+ authority.port !== null ||
69
+ authority.host.startsWith("[") ||
70
+ /^[\d.]+$/.test(authority.host)) {
71
+ throw new InterceptConfigError("CONFIG_INVALID", setting, "a host name, no port, no address");
72
+ }
73
+ return authority.host;
74
+ }
75
+ /** The interceptor's settings from the flags and the environment, each named when refused. */
76
+ export function resolveIntercept(parsed, env) {
39
77
  const httpPort = portFrom(optionPort(parsed, "http-port"), env, INTERCEPT_ENVIRONMENT.httpPort, INTERCEPT_DEFAULTS.httpPort);
40
78
  const httpsPort = portFrom(optionPort(parsed, "https-port"), env, INTERCEPT_ENVIRONMENT.httpsPort, INTERCEPT_DEFAULTS.httpsPort);
41
79
  if (httpPort === httpsPort)
@@ -43,7 +81,7 @@ export function resolveInterceptor(argv, env) {
43
81
  const bind = optionValue(parsed, "bind") ?? env[INTERCEPT_ENVIRONMENT.bind] ?? INTERCEPT_DEFAULTS.bind;
44
82
  if (!/^[\d.:a-f]+$/i.test(bind))
45
83
  throw new InterceptConfigError("CONFIG_INVALID", "bind");
46
- return {
84
+ const listeners = {
47
85
  bind,
48
86
  listeners: [
49
87
  { port: httpPort, destinationPort: 80 },
@@ -54,6 +92,38 @@ export function resolveInterceptor(argv, env) {
54
92
  idleTimeoutMs: INTERCEPT_DEFAULTS.idleTimeoutMs,
55
93
  maxConnections: INTERCEPT_DEFAULTS.maxConnections,
56
94
  };
95
+ const governFlag = optionValue(parsed, "govern");
96
+ const governRaw = governFlag ?? env[INTERCEPT_ENVIRONMENT.govern] ?? "";
97
+ const governSetting = governFlag === undefined ? INTERCEPT_ENVIRONMENT.govern : "govern";
98
+ const hosts = new Set(governRaw
99
+ .split(",")
100
+ .map((entry) => entry.trim())
101
+ .filter((entry) => entry !== "")
102
+ .map((entry) => governedHost(entry, governSetting)));
103
+ const unlistedFlag = optionValue(parsed, "unlisted");
104
+ const unlisted = (unlistedFlag ?? env[INTERCEPT_ENVIRONMENT.unlisted] ?? GOVERN_DEFAULTS.unlisted)
105
+ .trim()
106
+ .toLowerCase();
107
+ if (unlisted !== "passthrough" && unlisted !== "refuse") {
108
+ throw new InterceptConfigError("CONFIG_INVALID", unlistedFlag === undefined ? INTERCEPT_ENVIRONMENT.unlisted : "unlisted", "passthrough or refuse");
109
+ }
110
+ const certificateFile = optionValue(parsed, "ca-cert") ?? env[INTERCEPT_ENVIRONMENT.caCertificateFile] ?? null;
111
+ const keyFile = optionValue(parsed, "ca-key") ?? env[INTERCEPT_ENVIRONMENT.caKeyFile] ?? null;
112
+ if ((certificateFile === null) !== (keyFile === null)) {
113
+ throw new InterceptConfigError("CONFIG_MISSING", certificateFile === null
114
+ ? INTERCEPT_ENVIRONMENT.caCertificateFile
115
+ : INTERCEPT_ENVIRONMENT.caKeyFile, "the authority's certificate and key come together");
116
+ }
117
+ if (hosts.size === 0 && unlisted === "passthrough")
118
+ return { listeners, govern: null };
119
+ return {
120
+ listeners,
121
+ govern: {
122
+ hosts,
123
+ unlisted,
124
+ authority: certificateFile === null || keyFile === null ? null : { certificateFile, keyFile },
125
+ },
126
+ };
57
127
  }
58
128
  /** One line per event for a terminal; the JSON form is the event itself. */
59
129
  export function describe(event, version) {
@@ -61,11 +131,17 @@ export function describe(event, version) {
61
131
  case "INTERCEPT_STARTED":
62
132
  return `AgentSafe intercept ${version} listening on ${event.listeners
63
133
  .map((listener) => `${listener.listen} (for :${listener.for_port})`)
64
- .join(" and ")}. Observing; nothing is decrypted or decided.`;
65
- case "INTERCEPT_OBSERVED":
134
+ .join(" and ")}.`;
135
+ case "INTERCEPT_GOVERNING":
136
+ return event.hosts.length === 0
137
+ ? `Governing nothing; destinations are ${event.unlisted === "refuse" ? "refused" : "observed"}.`
138
+ : `Governing ${event.hosts.join(", ")}${event.tls ? ", TLS terminated under the operator's authority" : ", plaintext only"}; other destinations are ${event.unlisted === "refuse" ? "refused" : "observed"}.`;
139
+ case "INTERCEPT_OBSERVED": {
140
+ const governed = event.governed ? " governed" : "";
66
141
  return event.protocol === "HTTP"
67
- ? `-> HTTP ${event.method ?? ""} ${event.host}:${event.port} ${event.target ?? ""}`.trimEnd()
68
- : `-> TLS ${event.host}:${event.port}${event.alpn === undefined ? "" : ` (${event.alpn.join(", ")})`}`;
142
+ ? `${`-> HTTP ${event.method ?? ""} ${event.host}:${event.port} ${event.target ?? ""}`.trimEnd()}${governed}`
143
+ : `-> TLS ${event.host}:${event.port}${event.alpn === undefined ? "" : ` (${event.alpn.join(", ")})`}${governed}`;
144
+ }
69
145
  case "INTERCEPT_REFUSED": {
70
146
  const where = event.host === undefined ? "" : ` ${event.host}:${event.port ?? ""}`;
71
147
  const detail = event.detail === undefined ? "" : ` (${event.detail})`;
@@ -80,7 +156,19 @@ export function describe(event, version) {
80
156
  const methods = Object.entries(counts.methods)
81
157
  .map(([method, count]) => `${method} x${count}`)
82
158
  .join(", ");
83
- lines.push(` ${destination} ${counts.protocol} ${counts.connections} connection(s), ${counts.bytes_to_destination} B out, ${counts.bytes_from_destination} B in${methods === "" ? "" : ` ${methods}`}`);
159
+ const tail = methods === "" ? "" : ` ${methods}`;
160
+ if (!counts.governed) {
161
+ lines.push(` ${destination} ${counts.protocol} ${counts.connections} connection(s), ${counts.bytes_to_destination} B out, ${counts.bytes_from_destination} B in${tail}`);
162
+ continue;
163
+ }
164
+ // The gateway's account of a governed destination: what it was handed
165
+ // and what became of it, in its own names.
166
+ const account = counts.gateway === null
167
+ ? "no request reached the gateway"
168
+ : `gateway ${counts.gateway.mode}: ${Object.entries(counts.gateway.requests)
169
+ .map(([name, count]) => `${name} x${count}`)
170
+ .join(", ") || "no request"}`;
171
+ lines.push(` ${destination} ${counts.protocol} governed ${counts.connections} connection(s), ${account}${tail}`);
84
172
  }
85
173
  for (const [reason, count] of Object.entries(summary.refused)) {
86
174
  lines.push(` refused ${reason} x${count}`);
@@ -92,53 +180,193 @@ export function describe(event, version) {
92
180
  return `Stopped on ${event.signal}.`;
93
181
  }
94
182
  }
183
+ /**
184
+ * Resolves the gateway configuration governed destinations share, the way
185
+ * `agentsafe proxy` resolves its own: flags, environment, file, stored login.
186
+ * The upstream is a placeholder here, replaced per governed host.
187
+ */
188
+ function resolveGovernedGateway(io, parsed) {
189
+ const file = loadConfigFile(io, optionValue(parsed, "config"));
190
+ const credentials = readCredentials(io);
191
+ const mode = optionValue(parsed, "mode");
192
+ const failurePolicy = optionValue(parsed, "failure-policy");
193
+ const authority = optionValue(parsed, "authority");
194
+ const config = GatewayConfigLoader.load({
195
+ flags: {
196
+ upstream: "https://governed.invalid",
197
+ ...(mode === undefined ? {} : { mode }),
198
+ ...(failurePolicy === undefined ? {} : { failurePolicy }),
199
+ ...(authority === undefined ? {} : { authority }),
200
+ ...(parsed.options.get("verbose") === true ? { verbose: true } : {}),
201
+ ...(parsed.options.get("json") === true ? { json: true } : {}),
202
+ },
203
+ env: io.env,
204
+ file: file.document,
205
+ credentials,
206
+ version: packageVersion(),
207
+ });
208
+ const keyFromLogin = credentials !== null &&
209
+ config.authority.kind === "DECIONIS" &&
210
+ io.env["DECIONIS_API_KEY"] === undefined &&
211
+ io.env["DECIONIS_API_KEY_FILE"] === undefined;
212
+ const env = keyFromLogin ? { ...io.env, DECIONIS_API_KEY: credentials.apiKey } : io.env;
213
+ return { config, env };
214
+ }
215
+ /** The configuration for one governed destination: the shared settings, with that host as the upstream. */
216
+ export function governedConfig(base, host, protocol) {
217
+ return {
218
+ ...base,
219
+ upstream: {
220
+ ...base.upstream,
221
+ url: protocol === "TLS" ? `https://${host}` : `http://${host}`,
222
+ // A workload that spoke plain HTTP to this host is not made safer by the
223
+ // hop refusing to; the request is forwarded as it was addressed.
224
+ insecure: protocol === "HTTP",
225
+ system: host,
226
+ },
227
+ sources: { ...base.sources, upstream: "environment" },
228
+ };
229
+ }
230
+ function refusal(error) {
231
+ if (error instanceof ArgumentError ||
232
+ error instanceof InterceptConfigError ||
233
+ error instanceof GatewayConfigError) {
234
+ return error.message;
235
+ }
236
+ if (error instanceof ConfigFileError)
237
+ return `${error.code}: ${error.path}`;
238
+ if (error instanceof LeafIssuerError) {
239
+ return `${error.code}: ${INTERCEPT_ENVIRONMENT.caCertificateFile}`;
240
+ }
241
+ return error instanceof Error ? error.message : "UNKNOWN";
242
+ }
95
243
  /**
96
244
  * `agentsafe intercept`: the transparent interceptor as a process, the
97
245
  * sidecar the redirect rules point at. It binds its listeners, reports every
98
- * destination it places or refuses as one line, and on `SIGTERM` or `SIGINT`
99
- * prints the ledger's report, stops, and exits 0. It holds no key and asks
100
- * no authority: this is the observe phase.
246
+ * destination it places, governs or refuses as one line, and on `SIGTERM` or
247
+ * `SIGINT` prints the ledger's report, stops, and exits 0. With nothing to
248
+ * govern it holds no key and asks no authority; with governed destinations it
249
+ * runs the gateway for each, under the configuration `agentsafe proxy`
250
+ * takes, and terminates their TLS under the operator's authority.
101
251
  */
102
252
  export async function runIntercept(io, argv, dependencies = {}) {
103
253
  const json = speaksJson(io, argv);
104
254
  const version = packageVersion();
105
- let options;
255
+ const refuse = (error) => json
256
+ ? refusalLine(new Error(refusal(error)))
257
+ : `AgentSafe refused to start.\n\n${refusal(error)}\n`;
258
+ let settings;
259
+ let governor = null;
260
+ const governed = new Map();
261
+ const gatewayIo = {
262
+ stdout: (line) => io.stdout(`${line}\n`),
263
+ stderr: (line) => io.stderr(`${line}\n`),
264
+ color: false,
265
+ };
106
266
  try {
107
- options = resolveInterceptor(argv, io.env);
267
+ const parsed = parseArguments(argv, INTERCEPT_ARGUMENTS);
268
+ settings = resolveIntercept(parsed, io.env);
269
+ if (settings.govern !== null) {
270
+ const govern = settings.govern;
271
+ let issuer = null;
272
+ if (govern.authority !== null) {
273
+ const certificatePem = io.files.read(govern.authority.certificateFile);
274
+ const keyPem = io.files.read(govern.authority.keyFile);
275
+ if (certificatePem === null) {
276
+ throw new InterceptConfigError("CONFIG_INVALID", INTERCEPT_ENVIRONMENT.caCertificateFile, "unreadable");
277
+ }
278
+ if (keyPem === null) {
279
+ throw new InterceptConfigError("CONFIG_INVALID", INTERCEPT_ENVIRONMENT.caKeyFile, "unreadable");
280
+ }
281
+ issuer = new LeafIssuer({ certificatePem, keyPem });
282
+ }
283
+ // The gateway's configuration is resolved now, so a missing key or a
284
+ // refused setting is a refusal to start rather than a first request that fails.
285
+ const shared = govern.hosts.size === 0 ? null : resolveGovernedGateway(io, parsed);
286
+ governor = new InterceptGovernor({
287
+ hosts: govern.hosts,
288
+ unlisted: govern.unlisted,
289
+ issuer,
290
+ handshakeTimeoutMs: GOVERN_DEFAULTS.handshakeTimeoutMs,
291
+ }, {
292
+ gatewayFor: async (host, protocol) => {
293
+ const key = `${protocol} ${host}`;
294
+ const existing = governed.get(key);
295
+ if (existing !== undefined)
296
+ return existing.server;
297
+ if (shared === null)
298
+ throw new Error("NOTHING_GOVERNED");
299
+ const config = governedConfig(shared.config, host, protocol);
300
+ const gateway = await Gateway.create(config, {
301
+ env: shared.env,
302
+ io: gatewayIo,
303
+ version,
304
+ ...dependencies.gateway,
305
+ });
306
+ gateway.started(config.upstream.url);
307
+ const server = new GatewayHttpServer(gateway);
308
+ governed.set(key, { gateway, server });
309
+ return server;
310
+ },
311
+ });
312
+ }
108
313
  }
109
314
  catch (error) {
110
- io.stderr(json
111
- ? refusalLine(error)
112
- : `AgentSafe refused to start.\n\n${error instanceof ArgumentError || error instanceof InterceptConfigError ? error.message : "UNKNOWN"}\n`);
315
+ io.stderr(refuse(error));
113
316
  io.exit(2);
114
317
  return;
115
318
  }
116
319
  const emit = (event) => {
117
320
  io.stdout(json ? `${JSON.stringify(event)}\n` : `${describe(event, version)}\n`);
118
321
  };
119
- const interceptor = new Interceptor(options, { ...dependencies, emit });
322
+ const interceptor = new Interceptor(settings.listeners, {
323
+ ...(dependencies.dial === undefined ? {} : { dial: dependencies.dial }),
324
+ ...(dependencies.now === undefined ? {} : { now: dependencies.now }),
325
+ emit,
326
+ governor,
327
+ // The report gives a governed destination its gateway's account of it.
328
+ governedCounts: (host, protocol) => {
329
+ const status = governed.get(`${protocol} ${host}`)?.gateway.status();
330
+ return status === undefined ? null : { mode: status.mode, requests: status.counts };
331
+ },
332
+ });
120
333
  try {
121
334
  await interceptor.listen();
122
335
  }
123
336
  catch (error) {
124
337
  const code = error.code ?? "LISTEN_FAILED";
125
- const ports = options.listeners.map((listener) => listener.port).join(",");
338
+ const ports = settings.listeners.listeners.map((listener) => listener.port).join(",");
126
339
  io.stderr(json
127
- ? refusalLine(new Error(`${code}: ${options.bind}:${ports}`))
128
- : `AgentSafe refused to start.\n\n${code}: ${options.bind}:${ports}${code === "EADDRINUSE"
340
+ ? refusalLine(new Error(`${code}: ${settings.listeners.bind}:${ports}`))
341
+ : `AgentSafe refused to start.\n\n${code}: ${settings.listeners.bind}:${ports}${code === "EADDRINUSE"
129
342
  ? "\n\nAnother process holds a port; choose with --http-port and --https-port."
130
343
  : ""}\n`);
131
344
  io.exit(1);
132
345
  return;
133
346
  }
347
+ if (governor !== null) {
348
+ emit({
349
+ event: "INTERCEPT_GOVERNING",
350
+ at: new Date().toISOString(),
351
+ hosts: [...governor.hosts].sort(),
352
+ unlisted: governor.unlisted,
353
+ tls: settings.govern?.authority !== null,
354
+ });
355
+ }
134
356
  let stopping = false;
135
357
  const stop = (signal) => {
136
358
  if (stopping)
137
359
  return;
138
360
  stopping = true;
139
361
  emit(interceptor.report());
362
+ for (const { gateway } of governed.values())
363
+ gateway.stopped(signal);
140
364
  emit({ event: "INTERCEPT_STOPPED", at: new Date().toISOString(), signal });
141
- void interceptor.close().then(() => io.exit(0));
365
+ void interceptor
366
+ .close()
367
+ .then(() => Promise.all([...governed.values()].map(({ server }) => server.close())))
368
+ .then(() => Promise.all([...governed.values()].map(({ gateway }) => gateway.close())))
369
+ .then(() => io.exit(0));
142
370
  };
143
371
  io.onSignal("SIGTERM", () => stop("SIGTERM"));
144
372
  io.onSignal("SIGINT", () => stop("SIGINT"));
@@ -1 +1 @@
1
- {"version":3,"file":"Intercept.js","sourceRoot":"","sources":["../../src/cli/Intercept.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,WAAW,GAIZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAExF,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,MAAM,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,MAAM,CAAC;IAC3C,KAAK,EAAE,CAAC,MAAM,CAAC;CACP,CAAC;AAEX,6EAA6E;AAC7E,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,QAAQ,EAAE,+BAA+B;IACzC,SAAS,EAAE,gCAAgC;IAC3C,IAAI,EAAE,0BAA0B;CACxB,CAAC;AAEX,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAE3B;IACA;IAFlB,YACkB,IAAsB,EACtB,OAAe;QAE/B,KAAK,CAAC,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;QAHb,SAAI,GAAJ,IAAI,CAAkB;QACtB,YAAO,GAAP,OAAO,C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only valued: readonly ["tenant", "endpoint"];
4
- readonly flags: readonly ["key-stdin"];
5
+ readonly flags: readonly ["key-stdin", "provision"];
5
6
  };
7
+ /** What a test hands in beneath the command: the call that mints a workspace. */
8
+ export interface LoginDependencies {
9
+ readonly provision?: typeof provisionWorkspace;
10
+ }
6
11
  /**
7
12
  * `agentsafe login`: stores a Decionis key for this user, readable by this
8
13
  * user alone, to be used when no `DECIONIS_API_KEY` is set. The key is read
@@ -10,7 +15,7 @@ export declare const LOGIN_ARGUMENTS: {
10
15
  * argument, so it appears in no shell history and no process list. Nothing
11
16
  * is sent anywhere; `agentsafe doctor` checks that Decionis accepts it.
12
17
  */
13
- export declare function runLogin(io: CliProcess, argv: readonly string[]): Promise<void>;
18
+ export declare function runLogin(io: CliProcess, argv: readonly string[], dependencies?: LoginDependencies): Promise<void>;
14
19
  /** `agentsafe logout`: removes the stored login; the environment is untouched. */
15
20
  export declare function runLogout(io: CliProcess): void;
16
21
  //# sourceMappingURL=Login.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Login.d.ts","sourceRoot":"","sources":["../../src/cli/Login.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAQlD,eAAO,MAAM,eAAe;;;CAGlB,CAAC;AAIX;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAmDrF;AAED,kFAAkF;AAClF,wBAAgB,SAAS,CAAC,EAAE,EAAE,UAAU,GAAG,IAAI,CAK9C"}
1
+ {"version":3,"file":"Login.d.ts","sourceRoot":"","sources":["../../src/cli/Login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAMnF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAQlD,eAAO,MAAM,eAAe;;;CAGlB,CAAC;AAEX,iFAAiF;AACjF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,kBAAkB,CAAC;CAChD;AAKD;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAC5B,EAAE,EAAE,UAAU,EACd,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,YAAY,GAAE,iBAAsB,GACnC,OAAO,CAAC,IAAI,CAAC,CAuDf;AA+GD,kFAAkF;AAClF,wBAAgB,SAAS,CAAC,EAAE,EAAE,UAAU,GAAG,IAAI,CAK9C"}