@decionis/agentsafe 0.2.0 → 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.
- package/README.md +10 -1
- package/dist/Cli.js +16 -7
- package/dist/Cli.js.map +1 -1
- package/dist/Index.d.ts +5 -1
- package/dist/Index.d.ts.map +1 -1
- package/dist/Index.js +5 -1
- package/dist/Index.js.map +1 -1
- package/dist/cli/CliProcess.d.ts +2 -0
- package/dist/cli/CliProcess.d.ts.map +1 -1
- package/dist/cli/CliProcess.js +9 -1
- package/dist/cli/CliProcess.js.map +1 -1
- package/dist/cli/Commands.d.ts +1 -1
- package/dist/cli/Commands.d.ts.map +1 -1
- package/dist/cli/Commands.js +5 -0
- package/dist/cli/Commands.js.map +1 -1
- package/dist/cli/Credentials.d.ts.map +1 -1
- package/dist/cli/Credentials.js +8 -1
- package/dist/cli/Credentials.js.map +1 -1
- package/dist/cli/Help.d.ts.map +1 -1
- package/dist/cli/Help.js +4 -1
- package/dist/cli/Help.js.map +1 -1
- package/dist/cli/Intercept.d.ts +66 -0
- package/dist/cli/Intercept.d.ts.map +1 -0
- package/dist/cli/Intercept.js +374 -0
- package/dist/cli/Intercept.js.map +1 -0
- package/dist/cli/Login.d.ts +7 -2
- package/dist/cli/Login.d.ts.map +1 -1
- package/dist/cli/Login.js +106 -3
- package/dist/cli/Login.js.map +1 -1
- package/dist/cli/Status.d.ts.map +1 -1
- package/dist/cli/Status.js +18 -1
- package/dist/cli/Status.js.map +1 -1
- package/dist/cli/TestCommand.d.ts +33 -2
- package/dist/cli/TestCommand.d.ts.map +1 -1
- package/dist/cli/TestCommand.js +130 -4
- package/dist/cli/TestCommand.js.map +1 -1
- package/dist/cli/VerifyIntent.d.ts +28 -0
- package/dist/cli/VerifyIntent.d.ts.map +1 -0
- package/dist/cli/VerifyIntent.js +136 -0
- package/dist/cli/VerifyIntent.js.map +1 -0
- package/dist/egress/TransparentDial.d.ts +18 -0
- package/dist/egress/TransparentDial.d.ts.map +1 -0
- package/dist/egress/TransparentDial.js +33 -0
- package/dist/egress/TransparentDial.js.map +1 -0
- package/dist/gateway/Activation.d.ts +10 -3
- package/dist/gateway/Activation.d.ts.map +1 -1
- package/dist/gateway/Activation.js +17 -2
- package/dist/gateway/Activation.js.map +1 -1
- package/dist/gateway/BoundaryTest.d.ts +54 -0
- package/dist/gateway/BoundaryTest.d.ts.map +1 -1
- package/dist/gateway/BoundaryTest.js +19 -7
- package/dist/gateway/BoundaryTest.js.map +1 -1
- package/dist/gateway/Gateway.d.ts +39 -0
- package/dist/gateway/Gateway.d.ts.map +1 -1
- package/dist/gateway/Gateway.js +62 -4
- package/dist/gateway/Gateway.js.map +1 -1
- package/dist/gateway/GatewayConfig.d.ts +7 -0
- package/dist/gateway/GatewayConfig.d.ts.map +1 -1
- package/dist/gateway/GatewayConfig.js +12 -7
- package/dist/gateway/GatewayConfig.js.map +1 -1
- package/dist/gateway/GatewayReport.d.ts +2 -1
- package/dist/gateway/GatewayReport.d.ts.map +1 -1
- package/dist/gateway/GatewayReport.js +3 -0
- package/dist/gateway/GatewayReport.js.map +1 -1
- package/dist/gateway/HostedBoundaryTest.d.ts +118 -0
- package/dist/gateway/HostedBoundaryTest.d.ts.map +1 -0
- package/dist/gateway/HostedBoundaryTest.js +235 -0
- package/dist/gateway/HostedBoundaryTest.js.map +1 -0
- package/dist/gateway/InstallSurface.d.ts +26 -0
- package/dist/gateway/InstallSurface.d.ts.map +1 -0
- package/dist/gateway/InstallSurface.js +53 -0
- package/dist/gateway/InstallSurface.js.map +1 -0
- package/dist/gateway/ShadowLedger.d.ts +74 -0
- package/dist/gateway/ShadowLedger.d.ts.map +1 -0
- package/dist/gateway/ShadowLedger.js +112 -0
- package/dist/gateway/ShadowLedger.js.map +1 -0
- package/dist/http/GatewayHttpServer.d.ts +7 -0
- package/dist/http/GatewayHttpServer.d.ts.map +1 -1
- package/dist/http/GatewayHttpServer.js +8 -0
- package/dist/http/GatewayHttpServer.js.map +1 -1
- package/dist/http/InterceptGovernor.d.ts +71 -0
- package/dist/http/InterceptGovernor.d.ts.map +1 -0
- package/dist/http/InterceptGovernor.js +128 -0
- package/dist/http/InterceptGovernor.js.map +1 -0
- package/dist/http/InterceptServer.d.ts +124 -0
- package/dist/http/InterceptServer.d.ts.map +1 -0
- package/dist/http/InterceptServer.js +303 -0
- package/dist/http/InterceptServer.js.map +1 -0
- package/dist/intercept/ClientHello.d.ts +37 -0
- package/dist/intercept/ClientHello.d.ts.map +1 -0
- package/dist/intercept/ClientHello.js +216 -0
- package/dist/intercept/ClientHello.js.map +1 -0
- package/dist/intercept/Der.d.ts +59 -0
- package/dist/intercept/Der.d.ts.map +1 -0
- package/dist/intercept/Der.js +140 -0
- package/dist/intercept/Der.js.map +1 -0
- package/dist/intercept/Destination.d.ts +35 -0
- package/dist/intercept/Destination.d.ts.map +1 -0
- package/dist/intercept/Destination.js +66 -0
- package/dist/intercept/Destination.js.map +1 -0
- package/dist/intercept/InterceptLedger.d.ts +103 -0
- package/dist/intercept/InterceptLedger.d.ts.map +1 -0
- package/dist/intercept/InterceptLedger.js +101 -0
- package/dist/intercept/InterceptLedger.js.map +1 -0
- package/dist/intercept/LeafIssuer.d.ts +40 -0
- package/dist/intercept/LeafIssuer.d.ts.map +1 -0
- package/dist/intercept/LeafIssuer.js +124 -0
- package/dist/intercept/LeafIssuer.js.map +1 -0
- package/dist/intercept/RequestHead.d.ts +48 -0
- package/dist/intercept/RequestHead.d.ts.map +1 -0
- package/dist/intercept/RequestHead.js +163 -0
- package/dist/intercept/RequestHead.js.map +1 -0
- package/dist/verify/VerifyIntentVector.d.ts +25 -0
- package/dist/verify/VerifyIntentVector.d.ts.map +1 -0
- package/dist/verify/VerifyIntentVector.js +188 -0
- package/dist/verify/VerifyIntentVector.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agentsafe test --hosted`: the boundary test with Decionis deciding. The
|
|
3
|
+
* same fixed requests as the local test, sent two ways at the same synthetic
|
|
4
|
+
* loopback target: directly, and through the gateway in shadow against the
|
|
5
|
+
* Decionis workspace this machine is logged into. Nothing real is called and
|
|
6
|
+
* nothing is enforced; what the run produces is what the local test cannot:
|
|
7
|
+
* a first governed action against Decionis for this workspace, one signed
|
|
8
|
+
* Decision Dossier per consequential request, and the record itself,
|
|
9
|
+
* fetched with the run's own key and shown by its proof.
|
|
10
|
+
*
|
|
11
|
+
* This is the one test that reads the stored login and the `DECIONIS_*`
|
|
12
|
+
* variables, and it says so; the local test reads neither. A provisional
|
|
13
|
+
* workspace evaluates in shadow only, which is the one lane this test runs,
|
|
14
|
+
* so the free workspace `agentsafe login --provision` mints is enough.
|
|
15
|
+
*/
|
|
16
|
+
import { DossierFetchError, fetchSignedDossier, } from "@decionis/agent-safe-pipeline";
|
|
17
|
+
import { GatewayHttpServer } from "../http/GatewayHttpServer.js";
|
|
18
|
+
import { RecordingTarget } from "../http/RecordingTarget.js";
|
|
19
|
+
import { awaitObservation, BOUNDARY_CASES, closeLane, send, } from "./BoundaryTest.js";
|
|
20
|
+
import { Gateway } from "./Gateway.js";
|
|
21
|
+
import { GatewayConfigError, GatewayConfigLoader, } from "./GatewayConfig.js";
|
|
22
|
+
export const HOSTED_BOUNDARY_TEST_VERSION = "agent-safe.hosted-boundary-test/1";
|
|
23
|
+
export class HostedTestError extends Error {
|
|
24
|
+
code;
|
|
25
|
+
detail;
|
|
26
|
+
constructor(code, detail) {
|
|
27
|
+
super(`${code}: ${detail}`);
|
|
28
|
+
this.code = code;
|
|
29
|
+
this.detail = detail;
|
|
30
|
+
this.name = "HostedTestError";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** The variables the hosted test reads from the environment, and no others. */
|
|
34
|
+
export const HOSTED_TEST_ENVIRONMENT = [
|
|
35
|
+
"DECIONIS_API_KEY",
|
|
36
|
+
"DECIONIS_API_KEY_FILE",
|
|
37
|
+
"DECIONIS_API_URL",
|
|
38
|
+
"DECIONIS_TENANT_ID",
|
|
39
|
+
"DECIONIS_TIMEOUT_MS",
|
|
40
|
+
"DECIONIS_ALLOW_INSECURE_LOOPBACK",
|
|
41
|
+
"NODE_ENV",
|
|
42
|
+
];
|
|
43
|
+
const DEFAULT_OBSERVATION_TIMEOUT_MS = 15_000;
|
|
44
|
+
/**
|
|
45
|
+
* The configuration of the shadow lane: the synthetic target as upstream,
|
|
46
|
+
* shadow mode, and the authority from the stored login and the `DECIONIS_*`
|
|
47
|
+
* variables alone. No file, no `AGENTSAFE_*` variable, so nothing of the
|
|
48
|
+
* operator's own gateway is in play; a provisional login is shadow by rule.
|
|
49
|
+
*/
|
|
50
|
+
export function hostedConfig(options, target) {
|
|
51
|
+
const env = {};
|
|
52
|
+
for (const name of HOSTED_TEST_ENVIRONMENT) {
|
|
53
|
+
if (options.env[name] !== undefined)
|
|
54
|
+
env[name] = options.env[name];
|
|
55
|
+
}
|
|
56
|
+
let config;
|
|
57
|
+
try {
|
|
58
|
+
config = GatewayConfigLoader.load({
|
|
59
|
+
flags: { upstream: target, mode: "shadow", json: true },
|
|
60
|
+
env,
|
|
61
|
+
file: null,
|
|
62
|
+
credentials: options.credentials,
|
|
63
|
+
version: options.version,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (error instanceof GatewayConfigError && error.setting === "DECIONIS_API_KEY") {
|
|
68
|
+
throw new HostedTestError("NO_LOGIN", error.message);
|
|
69
|
+
}
|
|
70
|
+
throw new HostedTestError("CONFIG_INVALID", error instanceof Error ? error.message : "CONFIG_INVALID");
|
|
71
|
+
}
|
|
72
|
+
if (config.authority.kind !== "DECIONIS") {
|
|
73
|
+
throw new HostedTestError("NO_LOGIN", "no Decionis key: run `agentsafe login --provision` for a free workspace, or `agentsafe login` with your organization's key");
|
|
74
|
+
}
|
|
75
|
+
const login = options.credentials;
|
|
76
|
+
const keyFromLogin = login !== null &&
|
|
77
|
+
env["DECIONIS_API_KEY"] === undefined &&
|
|
78
|
+
env["DECIONIS_API_KEY_FILE"] === undefined;
|
|
79
|
+
return {
|
|
80
|
+
config,
|
|
81
|
+
env: keyFromLogin ? { ...env, DECIONIS_API_KEY: login.apiKey } : env,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function milestonesOf(lines) {
|
|
85
|
+
const milestones = [];
|
|
86
|
+
for (const line of lines) {
|
|
87
|
+
let parsed;
|
|
88
|
+
try {
|
|
89
|
+
parsed = JSON.parse(line);
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
95
|
+
continue;
|
|
96
|
+
const report = parsed;
|
|
97
|
+
if (report.event === "ACTIVATION" && typeof report.milestone === "string") {
|
|
98
|
+
milestones.push(report.milestone);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return milestones;
|
|
102
|
+
}
|
|
103
|
+
/** Runs the hosted test and returns the report; nothing is printed here. */
|
|
104
|
+
export async function runHostedBoundaryTest(options) {
|
|
105
|
+
const clock = options.clock ?? (() => Date.now());
|
|
106
|
+
const cases = (options.cases ?? BOUNDARY_CASES).filter((testCase) => !testCase.outage);
|
|
107
|
+
const observationTimeoutMs = options.observationTimeoutMs ?? DEFAULT_OBSERVATION_TIMEOUT_MS;
|
|
108
|
+
const target = new RecordingTarget();
|
|
109
|
+
await target.start();
|
|
110
|
+
let lane = null;
|
|
111
|
+
try {
|
|
112
|
+
const resolved = hostedConfig(options, target.baseUrl);
|
|
113
|
+
const lines = [];
|
|
114
|
+
const example = `agentsafe-test@${options.version}`;
|
|
115
|
+
const gateway = await Gateway.create(resolved.config, {
|
|
116
|
+
env: resolved.env,
|
|
117
|
+
version: options.version,
|
|
118
|
+
clock,
|
|
119
|
+
surface: options.surface,
|
|
120
|
+
clientExample: example,
|
|
121
|
+
...(options.gateway ?? {}),
|
|
122
|
+
io: {
|
|
123
|
+
stdout: (line) => {
|
|
124
|
+
lines.push(line);
|
|
125
|
+
},
|
|
126
|
+
stderr: (line) => {
|
|
127
|
+
lines.push(line);
|
|
128
|
+
},
|
|
129
|
+
color: false,
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
const server = new GatewayHttpServer(gateway);
|
|
133
|
+
const address = await server.listen(0, "127.0.0.1");
|
|
134
|
+
lane = { gateway, server, url: `http://127.0.0.1:${String(address.port)}`, lines };
|
|
135
|
+
gateway.started(lane.url);
|
|
136
|
+
const results = [];
|
|
137
|
+
let observed = 0;
|
|
138
|
+
for (const testCase of cases) {
|
|
139
|
+
const direct = await send(target.baseUrl, testCase, target);
|
|
140
|
+
const sent = await send(lane.url, testCase, target);
|
|
141
|
+
// A request the gateway forwarded in shadow was captured as an intent
|
|
142
|
+
// and asked about; one it answered itself (a read it passed through
|
|
143
|
+
// untouched, or a body it could not read as an intent) was not.
|
|
144
|
+
const consequential = sent.state === "SHADOW";
|
|
145
|
+
let decision = {
|
|
146
|
+
consequential,
|
|
147
|
+
status: sent.status,
|
|
148
|
+
state: sent.state,
|
|
149
|
+
verdict: null,
|
|
150
|
+
reason_codes: [],
|
|
151
|
+
decision_id: null,
|
|
152
|
+
dossier_id: null,
|
|
153
|
+
};
|
|
154
|
+
if (consequential) {
|
|
155
|
+
observed += 1;
|
|
156
|
+
const observation = await awaitObservation(lane, observed, observationTimeoutMs, clock);
|
|
157
|
+
decision = {
|
|
158
|
+
...decision,
|
|
159
|
+
verdict: observation.verdict,
|
|
160
|
+
reason_codes: observation.reasonCodes,
|
|
161
|
+
decision_id: observation.decisionId,
|
|
162
|
+
dossier_id: observation.dossierId,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
results.push({
|
|
166
|
+
id: testCase.id,
|
|
167
|
+
title: testCase.title,
|
|
168
|
+
adversarial: testCase.adversarial,
|
|
169
|
+
request: { method: testCase.method, path: testCase.path, body: testCase.body },
|
|
170
|
+
direct,
|
|
171
|
+
decionis: decision,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
const consequential = results.filter((result) => result.decionis.consequential);
|
|
175
|
+
const would = { ALLOW: 0, ESCALATE: 0, BLOCK: 0, NONE: 0 };
|
|
176
|
+
for (const result of consequential)
|
|
177
|
+
would[result.decionis.verdict ?? "NONE"] += 1;
|
|
178
|
+
const dossiers = consequential
|
|
179
|
+
.map((result) => result.decionis.dossier_id)
|
|
180
|
+
.filter((id) => id !== null);
|
|
181
|
+
const decidedCount = consequential.length - would.NONE;
|
|
182
|
+
const verdict = consequential.length > 0 && decidedCount === consequential.length
|
|
183
|
+
? "DECIONIS_DECIDED"
|
|
184
|
+
: decidedCount === 0
|
|
185
|
+
? "AUTHORITY_UNREACHABLE"
|
|
186
|
+
: "PARTLY_DECIDED";
|
|
187
|
+
let signed = null;
|
|
188
|
+
let signedUnavailable = null;
|
|
189
|
+
const first = dossiers[0];
|
|
190
|
+
if (first !== undefined) {
|
|
191
|
+
try {
|
|
192
|
+
const fetched = await (options.fetchDossier ?? fetchSignedDossier)({
|
|
193
|
+
baseUrl: resolved.config.authority.endpoint,
|
|
194
|
+
apiKey: resolved.env["DECIONIS_API_KEY"] ?? "",
|
|
195
|
+
tenantId: resolved.config.authority.tenantId,
|
|
196
|
+
dossierId: first,
|
|
197
|
+
allowInsecureLoopback: resolved.config.authority.allowInsecureLoopback,
|
|
198
|
+
timeoutMs: resolved.config.authority.timeoutMs,
|
|
199
|
+
source: { example, ...(options.surface === null ? {} : { surface: options.surface }) },
|
|
200
|
+
});
|
|
201
|
+
signed = fetched.summary;
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
signedUnavailable = error instanceof DossierFetchError ? error.code : "DOSSIER_UNAVAILABLE";
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
gateway.stopped("test");
|
|
208
|
+
return {
|
|
209
|
+
version: HOSTED_BOUNDARY_TEST_VERSION,
|
|
210
|
+
at: new Date(clock()).toISOString(),
|
|
211
|
+
runtime: options.version,
|
|
212
|
+
authority: {
|
|
213
|
+
kind: "decionis",
|
|
214
|
+
endpoint: resolved.config.authority.endpoint,
|
|
215
|
+
tenant: resolved.config.authority.tenantId,
|
|
216
|
+
provisional: resolved.config.authority.provisional,
|
|
217
|
+
mode: "SHADOW",
|
|
218
|
+
},
|
|
219
|
+
target: "synthetic loopback",
|
|
220
|
+
cases: results,
|
|
221
|
+
decided: { consequential: consequential.length, would },
|
|
222
|
+
dossiers,
|
|
223
|
+
signed,
|
|
224
|
+
signedUnavailable,
|
|
225
|
+
milestones: milestonesOf(lines),
|
|
226
|
+
verdict,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
finally {
|
|
230
|
+
if (lane !== null)
|
|
231
|
+
await closeLane(lane);
|
|
232
|
+
await target.stop();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=HostedBoundaryTest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HostedBoundaryTest.js","sourceRoot":"","sources":["../../src/gateway/HostedBoundaryTest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACL,iBAAiB,EACjB,kBAAkB,GAEnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,SAAS,EACT,IAAI,GAIL,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,OAAO,EAA4B,MAAM,cAAc,CAAC;AACjE,OAAO,EACL,kBAAkB,EAClB,mBAAmB,GAGpB,MAAM,oBAAoB,CAAC;AAI5B,MAAM,CAAC,MAAM,4BAA4B,GAAG,mCAAmC,CAAC;AAmEhF,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAEtB;IACA;IAFlB,YACkB,IAAmC,EACnC,MAAc;QAE9B,KAAK,CAAC,G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AC;QACxB,OAAO;YACL,OAAO,EAAE,4BAA4B;YACrC,EAAE,EAAE,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,WAAW,EAAE;YACnC,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,SAAS,EAAE;gBACT,IAAI,EAAE,UAAU;gBAChB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ;gBAC5C,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ;gBAC1C,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW;gBAClD,IAAI,EAAE,QAAQ;aACf;YACD,MAAM,EAAE,oBAAoB;YAC5B,KAAK,EAAE,OAAO;YACd,OAAO,EAAE,EAAE,aAAa,EAAE,aAAa,CAAC,MAAM,EAAE,KAAK,EAAE;YACvD,QAAQ;YACR,MAAM;YACN,iBAAiB;YACjB,UAAU,EAAE,YAAY,CAAC,KAAK,CAAC;YAC/B,OAAO;SACR,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,IAAI,IAAI,KAAK,IAAI;YAAE,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which distribution this process was installed from, as one closed token,
|
|
3
|
+
* so a hosted call can say `surface=homebrew` beside the version it already
|
|
4
|
+
* carries and the funnel can be read per surface: installs from the release
|
|
5
|
+
* downloads, first governed actions from the authority's own record. The
|
|
6
|
+
* token is the whole of what is derived: the paths looked at to derive it
|
|
7
|
+
* are never reported, and nothing is derived from the network, the user or
|
|
8
|
+
* the machine. A distribution that runs the process itself names the
|
|
9
|
+
* surface in `AGENTSAFE_SURFACE` (the image, the chart, the systemd unit);
|
|
10
|
+
* the others are recognised by where the executable sits. An unknown value
|
|
11
|
+
* in the variable, or a location that is none of these, is no surface at
|
|
12
|
+
* all rather than a guess.
|
|
13
|
+
*/
|
|
14
|
+
export declare const INSTALL_SURFACES: readonly ["homebrew", "linux", "installer", "docker", "kubernetes", "npm", "source"];
|
|
15
|
+
export type InstallSurface = (typeof INSTALL_SURFACES)[number];
|
|
16
|
+
export declare const SURFACE_ENVIRONMENT = "AGENTSAFE_SURFACE";
|
|
17
|
+
/** What the derivation reads: the environment, the executable, and the entry script when there is one. */
|
|
18
|
+
export interface SurfaceFacts {
|
|
19
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
20
|
+
readonly execPath: string;
|
|
21
|
+
readonly script: string | undefined;
|
|
22
|
+
}
|
|
23
|
+
export declare function installSurface(facts: SurfaceFacts): InstallSurface | null;
|
|
24
|
+
/** The surface of the running process, from its own environment and location. */
|
|
25
|
+
export declare function processSurface(env?: Readonly<Record<string, string | undefined>>): InstallSurface | null;
|
|
26
|
+
//# sourceMappingURL=InstallSurface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InstallSurface.d.ts","sourceRoot":"","sources":["../../src/gateway/InstallSurface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB,sFAQnB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAEvD,0GAA0G;AAC1G,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC3D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC;AAMD,wBAAgB,cAAc,CAAC,KAAK,EAAE,YAAY,GAAG,cAAc,GAAG,IAAI,CAezE;AAED,iFAAiF;AACjF,wBAAgB,cAAc,CAC5B,GAAG,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAe,GAC9D,cAAc,GAAG,IAAI,CAEvB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which distribution this process was installed from, as one closed token,
|
|
3
|
+
* so a hosted call can say `surface=homebrew` beside the version it already
|
|
4
|
+
* carries and the funnel can be read per surface: installs from the release
|
|
5
|
+
* downloads, first governed actions from the authority's own record. The
|
|
6
|
+
* token is the whole of what is derived: the paths looked at to derive it
|
|
7
|
+
* are never reported, and nothing is derived from the network, the user or
|
|
8
|
+
* the machine. A distribution that runs the process itself names the
|
|
9
|
+
* surface in `AGENTSAFE_SURFACE` (the image, the chart, the systemd unit);
|
|
10
|
+
* the others are recognised by where the executable sits. An unknown value
|
|
11
|
+
* in the variable, or a location that is none of these, is no surface at
|
|
12
|
+
* all rather than a guess.
|
|
13
|
+
*/
|
|
14
|
+
export const INSTALL_SURFACES = [
|
|
15
|
+
"homebrew",
|
|
16
|
+
"linux",
|
|
17
|
+
"installer",
|
|
18
|
+
"docker",
|
|
19
|
+
"kubernetes",
|
|
20
|
+
"npm",
|
|
21
|
+
"source",
|
|
22
|
+
];
|
|
23
|
+
export const SURFACE_ENVIRONMENT = "AGENTSAFE_SURFACE";
|
|
24
|
+
function isSurface(value) {
|
|
25
|
+
return INSTALL_SURFACES.includes(value ?? "");
|
|
26
|
+
}
|
|
27
|
+
export function installSurface(facts) {
|
|
28
|
+
const named = facts.env[SURFACE_ENVIRONMENT]?.trim().toLowerCase();
|
|
29
|
+
if (named !== undefined && named !== "")
|
|
30
|
+
return isSurface(named) ? named : null;
|
|
31
|
+
const locations = [facts.execPath, facts.script ?? ""].map((path) => path.replace(/\\/g, "/"));
|
|
32
|
+
const at = (fragment) => locations.some((path) => path.includes(fragment));
|
|
33
|
+
// Homebrew keeps the release archive under the Cellar and links the bin.
|
|
34
|
+
if (at("/Cellar/agentsafe/"))
|
|
35
|
+
return "homebrew";
|
|
36
|
+
// The installer puts the archive under <prefix>/lib/agentsafe/<version>/.
|
|
37
|
+
if (at("/lib/agentsafe/"))
|
|
38
|
+
return "installer";
|
|
39
|
+
// The .deb and .rpm place the one executable at /usr/bin/agentsafe.
|
|
40
|
+
if (locations.some((path) => path.endsWith("/usr/bin/agentsafe")))
|
|
41
|
+
return "linux";
|
|
42
|
+
// A package install runs the bin out of node_modules; a checkout out of packages/.
|
|
43
|
+
if (at("/node_modules/"))
|
|
44
|
+
return "npm";
|
|
45
|
+
if (at("/packages/agentsafe/"))
|
|
46
|
+
return "source";
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
/** The surface of the running process, from its own environment and location. */
|
|
50
|
+
export function processSurface(env = process.env) {
|
|
51
|
+
return installSurface({ env, execPath: process.execPath, script: process.argv[1] });
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=InstallSurface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InstallSurface.js","sourceRoot":"","sources":["../../src/gateway/InstallSurface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,UAAU;IACV,OAAO;IACP,WAAW;IACX,QAAQ;IACR,YAAY;IACZ,KAAK;IACL,QAAQ;CACA,CAAC;AAIX,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AASvD,SAAS,SAAS,CAAC,KAAyB;IAC1C,OAAQ,gBAAsC,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAmB;IAChD,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACnE,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,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
* What shadow mode found, kept by the gateway itself: for every consequential
|
|
3
|
+
* request it forwarded unchanged, what the authority said it would have
|
|
4
|
+
* decided, counted by verdict and by action name, with the first and last
|
|
5
|
+
* time. It is the report an operator reads before turning enforcement on,
|
|
6
|
+
* and it is counts only: the action names are the route table's, the
|
|
7
|
+
* verdicts are the authority's, and no path, body, parameter or identifier
|
|
8
|
+
* is kept. The authority keeps its own record of the same observations, with
|
|
9
|
+
* the dossiers; this is the gateway's, available where the gateway runs.
|
|
10
|
+
*/
|
|
11
|
+
import type { GatewayConfig } from "./GatewayConfig.js";
|
|
12
|
+
export type ShadowVerdict = "ALLOW" | "ESCALATE" | "BLOCK" | "NONE";
|
|
13
|
+
export interface ShadowCounts {
|
|
14
|
+
readonly ALLOW: number;
|
|
15
|
+
readonly ESCALATE: number;
|
|
16
|
+
readonly BLOCK: number;
|
|
17
|
+
/** The authority could not be asked, or did not answer in time: no verdict to count. */
|
|
18
|
+
readonly NONE: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Of the would-be holds and refusals, how many the upstream accepted as sent
|
|
22
|
+
* (a 2xx): each is a request that passed every credential and permission
|
|
23
|
+
* check on its way and would not have passed the authority, which is the
|
|
24
|
+
* Compromised Principal Test observed rather than stated.
|
|
25
|
+
*/
|
|
26
|
+
export interface AcceptedCounts {
|
|
27
|
+
readonly ESCALATE: number;
|
|
28
|
+
readonly BLOCK: number;
|
|
29
|
+
}
|
|
30
|
+
export interface ShadowSummary {
|
|
31
|
+
/** When the first and the last observation settled; null before any did. */
|
|
32
|
+
readonly since: string | null;
|
|
33
|
+
readonly until: string | null;
|
|
34
|
+
readonly observed: number;
|
|
35
|
+
readonly would: ShadowCounts;
|
|
36
|
+
readonly accepted: AcceptedCounts;
|
|
37
|
+
readonly by_action: Readonly<Record<string, ShadowCounts>>;
|
|
38
|
+
}
|
|
39
|
+
/** What `agentsafe` prints on a terminal for a shadow summary, and the switch it ends with. */
|
|
40
|
+
export interface ShadowReport {
|
|
41
|
+
readonly event: "SHADOW_REPORT";
|
|
42
|
+
readonly at: string;
|
|
43
|
+
readonly shadow: ShadowSummary;
|
|
44
|
+
/** How enforcement is turned on for this configuration, in the operator's own terms. */
|
|
45
|
+
readonly enforce: string;
|
|
46
|
+
}
|
|
47
|
+
export declare class ShadowLedger {
|
|
48
|
+
private since;
|
|
49
|
+
private until;
|
|
50
|
+
private count;
|
|
51
|
+
private would;
|
|
52
|
+
private accepted;
|
|
53
|
+
private readonly byAction;
|
|
54
|
+
/** How many observations have settled so far. */
|
|
55
|
+
get observed(): number;
|
|
56
|
+
/**
|
|
57
|
+
* One settled observation: the action, what the authority would have
|
|
58
|
+
* decided (null when it could not be asked), when, and the status the
|
|
59
|
+
* upstream answered the forwarded request with (null when it did not).
|
|
60
|
+
*/
|
|
61
|
+
record(action: string, verdict: ShadowVerdict | null, at: string, upstreamStatus?: number | null): void;
|
|
62
|
+
summary(): ShadowSummary;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The one control the report ends with, in the terms this gateway was
|
|
66
|
+
* configured in: a provisional workspace cannot enforce at all, a file
|
|
67
|
+
* changes its own line, and the flag or the variable serves the rest.
|
|
68
|
+
*/
|
|
69
|
+
export declare function enforcementSwitch(config: GatewayConfig): string;
|
|
70
|
+
/** The report for a terminal: the counts, the actions, what enforcement would have changed, and the switch. */
|
|
71
|
+
export declare function renderShadowReport(report: ShadowReport, options: {
|
|
72
|
+
readonly color: boolean;
|
|
73
|
+
}): string;
|
|
74
|
+
//# sourceMappingURL=ShadowLedger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShadowLedger.d.ts","sourceRoot":"","sources":["../../src/gateway/ShadowLedger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM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IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED;;;;OAIG;IACI,MAAM,CACX,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,aAAa,GAAG,IAAI,EAC7B,EAAE,EAAE,MAAM,EACV,cAAc,GAAE,MAAM,GAAG,IAAW,GACnC,IAAI;IAgBA,OAAO,IAAI,aAAa;CAYhC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAoB/D;AAWD,+GAA+G;AAC/G,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACnC,MAAM,CAwER"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
const ZERO = { ALLOW: 0, ESCALATE: 0, BLOCK: 0, NONE: 0 };
|
|
2
|
+
/** The most action names the ledger keeps apart; the route table bounds them long before this. */
|
|
3
|
+
const MAX_ACTIONS = 1_000;
|
|
4
|
+
export class ShadowLedger {
|
|
5
|
+
since = null;
|
|
6
|
+
until = null;
|
|
7
|
+
count = 0;
|
|
8
|
+
would = ZERO;
|
|
9
|
+
accepted = { ESCALATE: 0, BLOCK: 0 };
|
|
10
|
+
byAction = new Map();
|
|
11
|
+
/** How many observations have settled so far. */
|
|
12
|
+
get observed() {
|
|
13
|
+
return this.count;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* One settled observation: the action, what the authority would have
|
|
17
|
+
* decided (null when it could not be asked), when, and the status the
|
|
18
|
+
* upstream answered the forwarded request with (null when it did not).
|
|
19
|
+
*/
|
|
20
|
+
record(action, verdict, at, upstreamStatus = null) {
|
|
21
|
+
const outcome = verdict ?? "NONE";
|
|
22
|
+
this.since ??= at;
|
|
23
|
+
this.until = at;
|
|
24
|
+
this.count += 1;
|
|
25
|
+
this.would = { ...this.would, [outcome]: this.would[outcome] + 1 };
|
|
26
|
+
const acceptedUpstream = upstreamStatus !== null && upstreamStatus >= 200 && upstreamStatus < 300;
|
|
27
|
+
if (acceptedUpstream && (outcome === "BLOCK" || outcome === "ESCALATE")) {
|
|
28
|
+
this.accepted = { ...this.accepted, [outcome]: this.accepted[outcome] + 1 };
|
|
29
|
+
}
|
|
30
|
+
const name = this.byAction.has(action) || this.byAction.size < MAX_ACTIONS ? action : "other";
|
|
31
|
+
const counts = this.byAction.get(name) ?? ZERO;
|
|
32
|
+
this.byAction.set(name, { ...counts, [outcome]: counts[outcome] + 1 });
|
|
33
|
+
}
|
|
34
|
+
summary() {
|
|
35
|
+
return {
|
|
36
|
+
since: this.since,
|
|
37
|
+
until: this.until,
|
|
38
|
+
observed: this.count,
|
|
39
|
+
would: this.would,
|
|
40
|
+
accepted: this.accepted,
|
|
41
|
+
by_action: Object.fromEntries([...this.byAction.entries()].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The one control the report ends with, in the terms this gateway was
|
|
47
|
+
* configured in: a provisional workspace cannot enforce at all, a file
|
|
48
|
+
* changes its own line, and the flag or the variable serves the rest.
|
|
49
|
+
*/
|
|
50
|
+
export function enforcementSwitch(config) {
|
|
51
|
+
if (config.authority.provisional) {
|
|
52
|
+
return "a provisional workspace evaluates in shadow only; for enforcement, run `agentsafe login` with a key from your Decionis organization, then `agentsafe proxy --mode enforcement`";
|
|
53
|
+
}
|
|
54
|
+
const mode = (() => {
|
|
55
|
+
switch (config.sources["authority.mode"]) {
|
|
56
|
+
case "file":
|
|
57
|
+
return "set `authority.mode: enforcement` in agentsafe.yaml (`gateway.mode: enforcement` in the chart's values) and restart";
|
|
58
|
+
case "environment":
|
|
59
|
+
return "set `AGENTSAFE_MODE=enforcement` and restart";
|
|
60
|
+
default:
|
|
61
|
+
return "`agentsafe proxy --mode enforcement`, or `AGENTSAFE_MODE=enforcement`, or `authority.mode: enforcement` in agentsafe.yaml";
|
|
62
|
+
}
|
|
63
|
+
})();
|
|
64
|
+
// The demo authority is not policy: the switch enforces its synthetic
|
|
65
|
+
// limits, and the report says how Decionis comes to decide instead.
|
|
66
|
+
if (config.authority.kind === "LOCAL") {
|
|
67
|
+
return `${mode}; that enforces the local demo authority's synthetic policy. For Decionis to decide: \`agentsafe login --provision\` mints a free workspace (no account; it decides in shadow), and \`agentsafe login\` with a key from your organization enables enforcement`;
|
|
68
|
+
}
|
|
69
|
+
return mode;
|
|
70
|
+
}
|
|
71
|
+
const ESC = String.fromCharCode(27);
|
|
72
|
+
const RESET = `${ESC}[0m`;
|
|
73
|
+
const BOLD = `${ESC}[1m`;
|
|
74
|
+
const DIM = `${ESC}[2m`;
|
|
75
|
+
function plural(count, noun) {
|
|
76
|
+
return `${String(count)} ${noun}${count === 1 ? "" : "s"}`;
|
|
77
|
+
}
|
|
78
|
+
/** The report for a terminal: the counts, the actions, what enforcement would have changed, and the switch. */
|
|
79
|
+
export function renderShadowReport(report, options) {
|
|
80
|
+
const bold = (text) => (options.color ? `${BOLD}${text}${RESET}` : text);
|
|
81
|
+
const dim = (text) => (options.color ? `${DIM}${text}${RESET}` : text);
|
|
82
|
+
const row = (label, value) => `${label.padEnd(12)} ${value}`;
|
|
83
|
+
const { shadow } = report;
|
|
84
|
+
const lines = [bold("Shadow report"), ""];
|
|
85
|
+
if (shadow.observed === 0) {
|
|
86
|
+
lines.push(row("Observed", "no consequential action yet; every one will be forwarded unchanged and counted here"), "", row("Turn it on", report.enforce), "");
|
|
87
|
+
return lines.join("\n");
|
|
88
|
+
}
|
|
89
|
+
const { would } = shadow;
|
|
90
|
+
lines.push(row("Since", `${shadow.since ?? ""}${shadow.until === shadow.since ? "" : ` until ${shadow.until ?? ""}`}`), row("Observed", `${plural(shadow.observed, "consequential action")}, every one forwarded unchanged`), row("Would ALLOW", String(would.ALLOW)), row("Would hold", `${String(would.ESCALATE)}${would.ESCALATE === 0 ? "" : dim(" ESCALATE: a person would have been asked first")}`), row("Would BLOCK", `${String(would.BLOCK)}${would.BLOCK === 0 ? "" : dim(" nothing would have reached the upstream")}`), row("No verdict", `${String(would.NONE)}${would.NONE === 0 ? "" : dim(" the authority could not be asked, or not in time")}`));
|
|
91
|
+
const actions = Object.entries(shadow.by_action);
|
|
92
|
+
if (actions.length > 0) {
|
|
93
|
+
const width = Math.max(...actions.map(([name]) => name.length));
|
|
94
|
+
actions.forEach(([name, counts], index) => {
|
|
95
|
+
const total = counts.ALLOW + counts.ESCALATE + counts.BLOCK + counts.NONE;
|
|
96
|
+
lines.push(row(index === 0 ? "By action" : "", `${name.padEnd(width)} ${String(total).padStart(5)} ${dim(`allow ${String(counts.ALLOW)} hold ${String(counts.ESCALATE)} block ${String(counts.BLOCK)}${counts.NONE === 0 ? "" : ` none ${String(counts.NONE)}`}`)}`));
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
const changed = would.ESCALATE + would.BLOCK;
|
|
100
|
+
lines.push("", changed === 0
|
|
101
|
+
? `Enforcement would have changed nothing: all ${String(shadow.observed)} would have gone through as they did.`
|
|
102
|
+
: `Enforcement would have held ${String(would.ESCALATE)} and refused ${String(would.BLOCK)} of ${String(shadow.observed)}; ${String(would.ALLOW)} would have gone through as they did.`);
|
|
103
|
+
// A refusal the upstream accepted as sent is the test this repository
|
|
104
|
+
// states, met in the wild: the credential was valid, the API permitted it,
|
|
105
|
+
// and the intent was one nobody authorized.
|
|
106
|
+
if (shadow.accepted.BLOCK > 0) {
|
|
107
|
+
lines.push(`${plural(shadow.accepted.BLOCK, "would-be refusal")} ${shadow.accepted.BLOCK === 1 ? "was" : "were"} accepted by the upstream as sent: a valid credential, a permitted API, an intent nobody authorized. That is the Compromised Principal Test, observed (docs/compromised-principal-test.md).`);
|
|
108
|
+
}
|
|
109
|
+
lines.push(row("Turn it on", report.enforce), "");
|
|
110
|
+
return lines.join("\n");
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=ShadowLedger.js.map
|
|
@@ -0,0 +1 @@
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@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AddressInfo } from "node:net";
|
|
2
|
+
import type { Duplex } from "node:stream";
|
|
2
3
|
import { type Gateway } from "../gateway/Gateway.js";
|
|
3
4
|
export interface GatewayHttpServerOptions {
|
|
4
5
|
/** A bearer token the metrics route requires; open when null, which is the local default. */
|
|
@@ -26,6 +27,12 @@ export declare class GatewayHttpServer {
|
|
|
26
27
|
private readonly select;
|
|
27
28
|
constructor(gateway: Gateway | GatewaySelector, options?: GatewayHttpServerOptions);
|
|
28
29
|
listen(port: number, host: string): Promise<AddressInfo>;
|
|
30
|
+
/**
|
|
31
|
+
* Hands the listener a connection it did not accept itself: the transparent
|
|
32
|
+
* interceptor's, already terminated where TLS was spoken. The stream is read
|
|
33
|
+
* as any accepted socket is, and closed with the rest on `close`.
|
|
34
|
+
*/
|
|
35
|
+
accept(connection: Duplex): void;
|
|
29
36
|
/** Stops accepting, lets requests in flight finish for a grace period, then closes what is left. */
|
|
30
37
|
close(graceMs?: number): Promise<void>;
|
|
31
38
|
private handle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GatewayHttpServer.d.ts","sourceRoot":"","sources":["../../src/http/GatewayHttpServer.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAkB,KAAK,OAAO,EAAwB,MAAM,uBAAuB,CAAC;AAsB3F,MAAM,WAAW,wBAAwB;IACvC,6FAA6F;IAC7F,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC;AAED;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,GAAG,IAAI,CAAC;AAE1E;;;;;;;GAOG;AACH,qBAAa,iBAAiB;IAM1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAL1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;I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AAE,wBAA6B;IAY5C,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAMrE;;;;OAIG;IACI,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAIvC,oGAAoG;IACvF,KAAK,CAAC,OAAO,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;YAQrC,MAAM;IAwCpB,oGAAoG;IACpG,OAAO,CAAC,MAAM,CAAC,UAAU;YAQX,GAAG;IAkDjB,kFAAkF;mBAC7D,QAAQ;IAgB7B,+FAA+F;IAC/F,OAAO,CAAC,MAAM,CAAC,SAAS;IASxB,OAAO,CAAC,MAAM,CAAC,KAAK;IASpB,OAAO,CAAC,MAAM,CAAC,KAAK;CAMrB"}
|
|
@@ -47,6 +47,14 @@ export class GatewayHttpServer {
|
|
|
47
47
|
await once(this.server, "listening");
|
|
48
48
|
return this.server.address();
|
|
49
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Hands the listener a connection it did not accept itself: the transparent
|
|
52
|
+
* interceptor's, already terminated where TLS was spoken. The stream is read
|
|
53
|
+
* as any accepted socket is, and closed with the rest on `close`.
|
|
54
|
+
*/
|
|
55
|
+
accept(connection) {
|
|
56
|
+
this.server.emit("connection", connection);
|
|
57
|
+
}
|
|
50
58
|
/** Stops accepting, lets requests in flight finish for a grace period, then closes what is left. */
|
|
51
59
|
async close(graceMs = 10_000) {
|
|
52
60
|
const closed = new Promise((resolve) => this.server.close(() => resolve()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GatewayHttpServer.js","sourceRoot":"","sources":["../../src/http/GatewayHttpServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EACL,YAAY,GAKb,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"GatewayHttpServer.js","sourceRoot":"","sources":["../../src/http/GatewayHttpServer.ts"],"names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