@decionis/agentsafe 0.7.0 → 0.8.0
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 +6 -1
- package/dist/Cli.js +13 -3
- package/dist/Cli.js.map +1 -1
- package/dist/acceptance/AcceptancePlan.d.ts +109 -0
- package/dist/acceptance/AcceptancePlan.d.ts.map +1 -0
- package/dist/acceptance/AcceptancePlan.js +128 -0
- package/dist/acceptance/AcceptancePlan.js.map +1 -0
- package/dist/acceptance/AcceptanceReport.d.ts +596 -0
- package/dist/acceptance/AcceptanceReport.d.ts.map +1 -0
- package/dist/acceptance/AcceptanceReport.js +361 -0
- package/dist/acceptance/AcceptanceReport.js.map +1 -0
- package/dist/acceptance/AcceptanceRun.d.ts +118 -0
- package/dist/acceptance/AcceptanceRun.d.ts.map +1 -0
- package/dist/acceptance/AcceptanceRun.js +419 -0
- package/dist/acceptance/AcceptanceRun.js.map +1 -0
- package/dist/acceptance/Coverage.d.ts +12 -0
- package/dist/acceptance/Coverage.d.ts.map +1 -0
- package/dist/acceptance/Coverage.js +48 -0
- package/dist/acceptance/Coverage.js.map +1 -0
- package/dist/acceptance/OutageDoubles.d.ts +34 -0
- package/dist/acceptance/OutageDoubles.d.ts.map +1 -0
- package/dist/acceptance/OutageDoubles.js +67 -0
- package/dist/acceptance/OutageDoubles.js.map +1 -0
- package/dist/acceptance/ZoneProbes.d.ts +368 -0
- package/dist/acceptance/ZoneProbes.d.ts.map +1 -0
- package/dist/acceptance/ZoneProbes.js +488 -0
- package/dist/acceptance/ZoneProbes.js.map +1 -0
- package/dist/adapters/JcsDigest.d.ts +6 -5
- package/dist/adapters/JcsDigest.d.ts.map +1 -1
- package/dist/adapters/JcsDigest.js +9 -8
- package/dist/adapters/JcsDigest.js.map +1 -1
- package/dist/cli/Accept.d.ts +9 -0
- package/dist/cli/Accept.d.ts.map +1 -0
- package/dist/cli/Accept.js +209 -0
- package/dist/cli/Accept.js.map +1 -0
- package/dist/cli/Actions.d.ts +6 -4
- package/dist/cli/Actions.d.ts.map +1 -1
- package/dist/cli/Actions.js +33 -7
- package/dist/cli/Actions.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/ConfigCommand.d.ts.map +1 -1
- package/dist/cli/ConfigCommand.js +5 -0
- package/dist/cli/ConfigCommand.js.map +1 -1
- package/dist/cli/Doctor.d.ts.map +1 -1
- package/dist/cli/Doctor.js +67 -1
- package/dist/cli/Doctor.js.map +1 -1
- package/dist/cli/Help.d.ts.map +1 -1
- package/dist/cli/Help.js +6 -1
- package/dist/cli/Help.js.map +1 -1
- package/dist/cli/Identity.d.ts +13 -1
- package/dist/cli/Identity.d.ts.map +1 -1
- package/dist/cli/Identity.js +25 -2
- package/dist/cli/Identity.js.map +1 -1
- package/dist/cli/Status.d.ts +23 -0
- package/dist/cli/Status.d.ts.map +1 -1
- package/dist/cli/Status.js +80 -18
- package/dist/cli/Status.js.map +1 -1
- package/dist/cli/VerifyAcceptance.d.ts +38 -0
- package/dist/cli/VerifyAcceptance.d.ts.map +1 -0
- package/dist/cli/VerifyAcceptance.js +143 -0
- package/dist/cli/VerifyAcceptance.js.map +1 -0
- package/dist/config/ExecutorConfig.d.ts +6 -1
- package/dist/config/ExecutorConfig.d.ts.map +1 -1
- package/dist/config/ExecutorConfig.js.map +1 -1
- package/dist/egress/ZoneHttpClient.d.ts +3 -0
- package/dist/egress/ZoneHttpClient.d.ts.map +1 -0
- package/dist/egress/ZoneHttpClient.js +72 -0
- package/dist/egress/ZoneHttpClient.js.map +1 -0
- package/dist/exposure/DecionisExposureLedger.d.ts +44 -0
- package/dist/exposure/DecionisExposureLedger.d.ts.map +1 -0
- package/dist/exposure/DecionisExposureLedger.js +175 -0
- package/dist/exposure/DecionisExposureLedger.js.map +1 -0
- package/dist/exposure/ExposureDeclaration.d.ts +68 -0
- package/dist/exposure/ExposureDeclaration.d.ts.map +1 -0
- package/dist/exposure/ExposureDeclaration.js +83 -0
- package/dist/exposure/ExposureDeclaration.js.map +1 -0
- package/dist/exposure/ExposureFacts.d.ts +61 -0
- package/dist/exposure/ExposureFacts.d.ts.map +1 -0
- package/dist/exposure/ExposureFacts.js +201 -0
- package/dist/exposure/ExposureFacts.js.map +1 -0
- package/dist/exposure/ExposureGate.d.ts +144 -0
- package/dist/exposure/ExposureGate.d.ts.map +1 -0
- package/dist/exposure/ExposureGate.js +446 -0
- package/dist/exposure/ExposureGate.js.map +1 -0
- package/dist/exposure/ExposureLedger.d.ts +93 -0
- package/dist/exposure/ExposureLedger.d.ts.map +1 -0
- package/dist/exposure/ExposureLedger.js +24 -0
- package/dist/exposure/ExposureLedger.js.map +1 -0
- package/dist/gateway/AttemptStore.d.ts +83 -0
- package/dist/gateway/AttemptStore.d.ts.map +1 -0
- package/dist/gateway/AttemptStore.js +229 -0
- package/dist/gateway/AttemptStore.js.map +1 -0
- package/dist/gateway/ForwardHandler.d.ts +29 -3
- package/dist/gateway/ForwardHandler.d.ts.map +1 -1
- package/dist/gateway/ForwardHandler.js +32 -5
- package/dist/gateway/ForwardHandler.js.map +1 -1
- package/dist/gateway/Gateway.d.ts +229 -17
- package/dist/gateway/Gateway.d.ts.map +1 -1
- package/dist/gateway/Gateway.js +1045 -81
- package/dist/gateway/Gateway.js.map +1 -1
- package/dist/gateway/GatewayConfig.d.ts +186 -0
- package/dist/gateway/GatewayConfig.d.ts.map +1 -1
- package/dist/gateway/GatewayConfig.js +219 -5
- package/dist/gateway/GatewayConfig.js.map +1 -1
- package/dist/gateway/GatewayManifest.d.ts +18 -0
- package/dist/gateway/GatewayManifest.d.ts.map +1 -0
- package/dist/gateway/GatewayManifest.js +42 -0
- package/dist/gateway/GatewayManifest.js.map +1 -0
- package/dist/gateway/GatewayMetrics.d.ts +12 -4
- package/dist/gateway/GatewayMetrics.d.ts.map +1 -1
- package/dist/gateway/GatewayMetrics.js +5 -0
- package/dist/gateway/GatewayMetrics.js.map +1 -1
- package/dist/gateway/GatewayReport.d.ts +34 -1
- package/dist/gateway/GatewayReport.d.ts.map +1 -1
- package/dist/gateway/GatewayReport.js +11 -0
- package/dist/gateway/GatewayReport.js.map +1 -1
- package/dist/gateway/HoldStore.d.ts +89 -0
- package/dist/gateway/HoldStore.d.ts.map +1 -0
- package/dist/gateway/HoldStore.js +280 -0
- package/dist/gateway/HoldStore.js.map +1 -0
- package/dist/gateway/InterceptedRequest.d.ts +10 -0
- package/dist/gateway/InterceptedRequest.d.ts.map +1 -1
- package/dist/gateway/InterceptedRequest.js +20 -0
- package/dist/gateway/InterceptedRequest.js.map +1 -1
- package/dist/gateway/RouteTable.d.ts +33 -5
- package/dist/gateway/RouteTable.d.ts.map +1 -1
- package/dist/gateway/RouteTable.js +76 -1
- package/dist/gateway/RouteTable.js.map +1 -1
- package/dist/gateway/ShadowLedger.d.ts +11 -0
- package/dist/gateway/ShadowLedger.d.ts.map +1 -1
- package/dist/gateway/ShadowLedger.js +11 -0
- package/dist/gateway/ShadowLedger.js.map +1 -1
- package/dist/gateway/TargetEffect.d.ts +74 -0
- package/dist/gateway/TargetEffect.d.ts.map +1 -0
- package/dist/gateway/TargetEffect.js +95 -0
- package/dist/gateway/TargetEffect.js.map +1 -0
- package/dist/gateway/TargetReader.d.ts +70 -0
- package/dist/gateway/TargetReader.d.ts.map +1 -0
- package/dist/gateway/TargetReader.js +106 -0
- package/dist/gateway/TargetReader.js.map +1 -0
- package/dist/gateway/Upstream.d.ts +15 -0
- package/dist/gateway/Upstream.d.ts.map +1 -1
- package/dist/gateway/Upstream.js +24 -2
- package/dist/gateway/Upstream.js.map +1 -1
- package/dist/hosted/TenantHost.d.ts +3 -2
- package/dist/hosted/TenantHost.d.ts.map +1 -1
- package/dist/hosted/TenantHost.js +7 -1
- package/dist/hosted/TenantHost.js.map +1 -1
- package/dist/hosted/TenantRegistry.d.ts +8 -0
- package/dist/hosted/TenantRegistry.d.ts.map +1 -1
- package/dist/hosted/TenantRegistry.js +14 -1
- package/dist/hosted/TenantRegistry.js.map +1 -1
- package/dist/http/GatewayHttpServer.d.ts +7 -0
- package/dist/http/GatewayHttpServer.d.ts.map +1 -1
- package/dist/http/GatewayHttpServer.js +57 -1
- package/dist/http/GatewayHttpServer.js.map +1 -1
- package/dist/outcomes/OutcomeEvidence.d.ts +4 -4
- package/dist/posture/ActionSpaceDrift.d.ts +40 -0
- package/dist/posture/ActionSpaceDrift.d.ts.map +1 -0
- package/dist/posture/ActionSpaceDrift.js +67 -0
- package/dist/posture/ActionSpaceDrift.js.map +1 -0
- package/dist/posture/DeploymentFingerprint.d.ts +88 -0
- package/dist/posture/DeploymentFingerprint.d.ts.map +1 -0
- package/dist/posture/DeploymentFingerprint.js +78 -0
- package/dist/posture/DeploymentFingerprint.js.map +1 -0
- package/dist/secrets/SecretStore.d.ts +6 -1
- package/dist/secrets/SecretStore.d.ts.map +1 -1
- package/dist/secrets/SecretStore.js.map +1 -1
- package/dist/service/EscalationResolver.d.ts +6 -6
- package/dist/service/EscalationResolver.d.ts.map +1 -1
- package/dist/service/EscalationResolver.js +8 -4
- package/dist/service/EscalationResolver.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
import { generateKeyPairSync, randomBytes, randomUUID } from "node:crypto";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { delimiter, join } from "node:path";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { verdictFor } from "../containment/ContainmentProbe.js";
|
|
6
|
+
import { SignedRequestCredential } from "../credential/SignedRequestCredential.js";
|
|
7
|
+
import { SecretHandle } from "../secrets/SecretHandle.js";
|
|
8
|
+
/** Bounds on what the zone may report, which `zoneFindingsSchema` enforces. */
|
|
9
|
+
export const ZONE_LIMITS = Object.freeze({
|
|
10
|
+
/** Origins, providers and MCP servers, each. */
|
|
11
|
+
targets: 64,
|
|
12
|
+
credentials: 512,
|
|
13
|
+
/** A plan label. */
|
|
14
|
+
name: 256,
|
|
15
|
+
/** A host and port, IPv6 brackets included. */
|
|
16
|
+
address: 300,
|
|
17
|
+
/** An environment variable's name, or a file's. */
|
|
18
|
+
credentialName: 1_024,
|
|
19
|
+
});
|
|
20
|
+
/** What a finding says a credential is. A fixed word, never derived from the value's text. */
|
|
21
|
+
export const CREDENTIAL_KINDS = [
|
|
22
|
+
"jwt",
|
|
23
|
+
"pem-private-key",
|
|
24
|
+
"url-with-userinfo",
|
|
25
|
+
"aws-access-key",
|
|
26
|
+
"aws-secret-key",
|
|
27
|
+
"aws-session-token",
|
|
28
|
+
"azure-client-secret",
|
|
29
|
+
"github-token",
|
|
30
|
+
"credential-file-path",
|
|
31
|
+
"secret-like",
|
|
32
|
+
"service-account-token",
|
|
33
|
+
"web-identity-token",
|
|
34
|
+
"aws-credentials",
|
|
35
|
+
"gcp-credentials",
|
|
36
|
+
"azure-cli-credentials",
|
|
37
|
+
"kubeconfig",
|
|
38
|
+
"docker-config",
|
|
39
|
+
"netrc",
|
|
40
|
+
"npmrc",
|
|
41
|
+
];
|
|
42
|
+
export const METADATA_URL = "http://169.254.169.254/";
|
|
43
|
+
const DEFAULT_TIMEOUT_MS = 5_000;
|
|
44
|
+
const METADATA_TIMEOUT_MS = 2_000;
|
|
45
|
+
/** Enough for a refusal's JSON; the rest of a body is not read. */
|
|
46
|
+
const REFUSAL_BODY_BYTES = 4_096;
|
|
47
|
+
const ANSWERED = "ANSWERED";
|
|
48
|
+
const UNKNOWN = "UNKNOWN";
|
|
49
|
+
const CODE = /^[A-Z][A-Z0-9_]{0,63}$/;
|
|
50
|
+
const KEY_ID = /^agentsafe-acceptance-[0-9a-f]{32}$/;
|
|
51
|
+
const SCHEMES = new Set(["http:", "https:"]);
|
|
52
|
+
/** A value that is a code, or null. A message, a value or anything else is not kept. */
|
|
53
|
+
function code(value) {
|
|
54
|
+
return typeof value === "string" && CODE.test(value) ? value : null;
|
|
55
|
+
}
|
|
56
|
+
function codeOf(error) {
|
|
57
|
+
return code(error?.code) ?? UNKNOWN;
|
|
58
|
+
}
|
|
59
|
+
/** The status's class, `2` for `2xx`; `0` for no answer. */
|
|
60
|
+
function classOf(status) {
|
|
61
|
+
return Math.floor((status ?? 0) / 100);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A target the zone can probe: an `http` or `https` URL with no userinfo. One
|
|
65
|
+
* the operator cannot spell is refused rather than probed, and the error names
|
|
66
|
+
* the plan's label, never the URL, which could carry a credential.
|
|
67
|
+
*/
|
|
68
|
+
function targetOf(target) {
|
|
69
|
+
const url = URL.parse(target.url);
|
|
70
|
+
if (url === null || !SCHEMES.has(url.protocol) || url.username !== "" || url.password !== "") {
|
|
71
|
+
throw new Error(`ZONE_TARGET_INVALID: ${target.name}`);
|
|
72
|
+
}
|
|
73
|
+
const port = url.port === "" ? (url.protocol === "https:" ? 443 : 80) : Number(url.port);
|
|
74
|
+
const host = url.hostname.startsWith("[") ? url.hostname.slice(1, -1) : url.hostname;
|
|
75
|
+
return { url, host, port, address: `${url.hostname}:${String(port)}` };
|
|
76
|
+
}
|
|
77
|
+
/** A base URL's origin and path prefix, with a path and query appended. */
|
|
78
|
+
function under(base, pathAndQuery) {
|
|
79
|
+
const { url } = targetOf(base);
|
|
80
|
+
const prefix = url.pathname.endsWith("/") ? url.pathname.slice(0, -1) : url.pathname;
|
|
81
|
+
return `${url.origin}${prefix}${pathAndQuery}`;
|
|
82
|
+
}
|
|
83
|
+
async function exchange(http, request) {
|
|
84
|
+
try {
|
|
85
|
+
const response = await http(request);
|
|
86
|
+
return { status: response.status, detail: ANSWERED, body: response.body };
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
return { status: null, detail: codeOf(error), body: null };
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Dial, then read only if the dial connected. The verdict is the dial's: a
|
|
94
|
+
* connection that answered is a hole whatever the read did next, and a read is
|
|
95
|
+
* never sent where the dial met silence or a refusal.
|
|
96
|
+
*/
|
|
97
|
+
async function directRead(target, options, timeoutMs) {
|
|
98
|
+
const outcome = await options.dial(target.host, target.port, timeoutMs);
|
|
99
|
+
if (outcome.state !== "CONNECTED") {
|
|
100
|
+
const { verdict, detail } = verdictFor(outcome);
|
|
101
|
+
return { status: null, detail: code(detail) ?? UNKNOWN, verdict };
|
|
102
|
+
}
|
|
103
|
+
const read = await exchange(options.http, {
|
|
104
|
+
method: "GET",
|
|
105
|
+
url: target.url.href,
|
|
106
|
+
headers: {},
|
|
107
|
+
body: null,
|
|
108
|
+
timeoutMs,
|
|
109
|
+
maxBodyBytes: 0,
|
|
110
|
+
});
|
|
111
|
+
return { status: read.status, detail: read.detail, verdict: "REACHABLE" };
|
|
112
|
+
}
|
|
113
|
+
const now = (options) => (options.clock ?? (() => new Date()))().toISOString();
|
|
114
|
+
/**
|
|
115
|
+
* Read one origin directly and through the gateway. The direct read is a
|
|
116
|
+
* `GET` of the plan's read URL with no header the probe sets, after a dial to
|
|
117
|
+
* its host and port; the control is the same path and query through the
|
|
118
|
+
* gateway, with the gateway's headers. Both are sent whatever the first one
|
|
119
|
+
* did, so the report shows the gateway path working beside every verdict.
|
|
120
|
+
*
|
|
121
|
+
* It establishes that an origin answered from the zone (`REACHABLE`). It
|
|
122
|
+
* never establishes that the origin is unreachable: `CONTAINED` says only that
|
|
123
|
+
* the zone met silence while the gateway's path worked.
|
|
124
|
+
*/
|
|
125
|
+
export async function probeOrigin(origin, options) {
|
|
126
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
127
|
+
const target = targetOf(origin);
|
|
128
|
+
const controlUrl = under({ name: "gateway", url: options.gateway }, `${target.url.pathname}${target.url.search}`);
|
|
129
|
+
const direct = await directRead(target, options, timeoutMs);
|
|
130
|
+
const control = await exchange(options.http, {
|
|
131
|
+
method: "GET",
|
|
132
|
+
url: controlUrl,
|
|
133
|
+
headers: options.gatewayHeaders ?? {},
|
|
134
|
+
body: null,
|
|
135
|
+
timeoutMs,
|
|
136
|
+
maxBodyBytes: 0,
|
|
137
|
+
});
|
|
138
|
+
const verdict = direct.verdict !== "CONTAINED"
|
|
139
|
+
? direct.verdict
|
|
140
|
+
: classOf(control.status) === 2
|
|
141
|
+
? "CONTAINED"
|
|
142
|
+
: "INCONCLUSIVE";
|
|
143
|
+
return {
|
|
144
|
+
name: origin.name,
|
|
145
|
+
address: target.address,
|
|
146
|
+
direct: { status: direct.status, detail: direct.detail },
|
|
147
|
+
control: { status: control.status, detail: control.detail },
|
|
148
|
+
verdict,
|
|
149
|
+
at: now(options),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
async function attempt(http, request) {
|
|
153
|
+
const answer = await exchange(http, request);
|
|
154
|
+
return { status: answer.status, reason_code: reasonCodeOf(answer.body), detail: answer.detail };
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The `reason_code` a refusal's JSON body names, when it is a code. Nothing
|
|
158
|
+
* else of the body survives. No body reads as the text `null`, which, like a
|
|
159
|
+
* body that is not JSON, throws on the way and names none.
|
|
160
|
+
*/
|
|
161
|
+
function reasonCodeOf(body) {
|
|
162
|
+
try {
|
|
163
|
+
return code(JSON.parse(String(body)).reason_code);
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Headers for one write, signed (RFC 9421, Ed25519) with a key generated here
|
|
171
|
+
* for this request alone. The provider has never seen the key, so a provider
|
|
172
|
+
* that verifies refuses it; the signature is otherwise well formed, so the
|
|
173
|
+
* refusal is about the key and not the shape.
|
|
174
|
+
*/
|
|
175
|
+
async function unknownKeyHeaders(request, clock) {
|
|
176
|
+
const keyId = `agentsafe-acceptance-${randomBytes(16).toString("hex")}`;
|
|
177
|
+
// The key lives in this call's scope and nowhere else. Its public half is
|
|
178
|
+
// never exported, so no provider could have registered it.
|
|
179
|
+
const pem = generateKeyPairSync("ed25519").privateKey.export({ type: "pkcs8", format: "pem" });
|
|
180
|
+
const handle = SecretHandle.fromString(keyId, String(pem));
|
|
181
|
+
const credential = new SignedRequestCredential({ algorithm: "ed25519", keyId }, () => handle, () => clock().getTime());
|
|
182
|
+
const headers = await credential.headersFor({
|
|
183
|
+
// The credential covers whatever method it is handed; the type names the
|
|
184
|
+
// two a handler sends, and a plan's write may use another.
|
|
185
|
+
method: request.method,
|
|
186
|
+
url: request.url,
|
|
187
|
+
body: request.body,
|
|
188
|
+
idempotencyKey: randomUUID(),
|
|
189
|
+
intentHash: `sha256:${randomBytes(32).toString("hex")}`,
|
|
190
|
+
});
|
|
191
|
+
return { keyId, headers };
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Send the plan's write to a verifying provider twice, from the zone: first
|
|
195
|
+
* with no signature, then signed with a key the provider cannot know. A
|
|
196
|
+
* provider that holds the boundary refuses both with a `4xx`.
|
|
197
|
+
*
|
|
198
|
+
* It establishes how this provider answered these two requests. It does not
|
|
199
|
+
* establish that the provider refuses a grant replayed or altered after
|
|
200
|
+
* issuance: the zone holds no grant to try, and those refusals are the
|
|
201
|
+
* build's to show (the provider conformance vectors).
|
|
202
|
+
*/
|
|
203
|
+
export async function probeProvider(provider, options) {
|
|
204
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
205
|
+
const clock = options.clock ?? (() => new Date());
|
|
206
|
+
if (!provider.write.path.startsWith("/"))
|
|
207
|
+
throw new Error(`ZONE_TARGET_INVALID: ${provider.name}`);
|
|
208
|
+
const write = {
|
|
209
|
+
method: provider.write.method.toUpperCase(),
|
|
210
|
+
url: under(provider, provider.write.path),
|
|
211
|
+
body: provider.write.body,
|
|
212
|
+
};
|
|
213
|
+
const base = { ...write, timeoutMs, maxBodyBytes: REFUSAL_BODY_BYTES };
|
|
214
|
+
const json = write.body === null ? {} : { "content-type": "application/json" };
|
|
215
|
+
const unattested = await attempt(options.http, { ...base, headers: json });
|
|
216
|
+
if (classOf(unattested.status) === 2) {
|
|
217
|
+
return {
|
|
218
|
+
name: provider.name,
|
|
219
|
+
unattested,
|
|
220
|
+
signed: null,
|
|
221
|
+
verdict: "ACCEPTED",
|
|
222
|
+
at: clock().toISOString(),
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
const { keyId, headers } = await unknownKeyHeaders(write, clock);
|
|
226
|
+
const signed = {
|
|
227
|
+
...(await attempt(options.http, { ...base, headers: { ...json, ...headers } })),
|
|
228
|
+
key_id: keyId,
|
|
229
|
+
};
|
|
230
|
+
const verdict = classOf(signed.status) === 2
|
|
231
|
+
? "ACCEPTED"
|
|
232
|
+
: classOf(unattested.status) === 4 && classOf(signed.status) === 4
|
|
233
|
+
? "REFUSED"
|
|
234
|
+
: "INCONCLUSIVE";
|
|
235
|
+
return { name: provider.name, unattested, signed, verdict, at: clock().toISOString() };
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Dial every MCP server's host and port once, in order. No MCP message is
|
|
239
|
+
* sent, so a finding says a server answered the zone, never that it would
|
|
240
|
+
* serve a tool call.
|
|
241
|
+
*/
|
|
242
|
+
export async function probeMcp(servers, options) {
|
|
243
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
244
|
+
const findings = [];
|
|
245
|
+
for (const server of servers) {
|
|
246
|
+
const target = targetOf(server);
|
|
247
|
+
const { verdict, detail } = verdictFor(await options.dial(target.host, target.port, timeoutMs));
|
|
248
|
+
findings.push({
|
|
249
|
+
name: server.name,
|
|
250
|
+
address: target.address,
|
|
251
|
+
verdict,
|
|
252
|
+
detail: code(detail) ?? UNKNOWN,
|
|
253
|
+
at: now(options),
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
return findings;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Read the cloud metadata endpoint with a bare `GET /`: no header, no token,
|
|
260
|
+
* no path, and a short timeout. Run only when the plan names it. A metadata
|
|
261
|
+
* service that answers at all is reported as `REACHABLE`, since the headers
|
|
262
|
+
* it would need to hand out credentials are the zone's to send.
|
|
263
|
+
*/
|
|
264
|
+
export async function probeMetadata(options) {
|
|
265
|
+
const target = targetOf({ name: "metadata", url: options.url ?? METADATA_URL });
|
|
266
|
+
const read = await directRead(target, options, options.timeoutMs ?? METADATA_TIMEOUT_MS);
|
|
267
|
+
return {
|
|
268
|
+
address: target.address,
|
|
269
|
+
status: read.status,
|
|
270
|
+
detail: read.detail,
|
|
271
|
+
verdict: read.verdict,
|
|
272
|
+
at: now(options),
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
/** Variables whose name says what they hold. */
|
|
276
|
+
const NAMED_KINDS = new Map([
|
|
277
|
+
["AWS_ACCESS_KEY_ID", "aws-access-key"],
|
|
278
|
+
["AWS_SECRET_ACCESS_KEY", "aws-secret-key"],
|
|
279
|
+
["AWS_SESSION_TOKEN", "aws-session-token"],
|
|
280
|
+
["AZURE_CLIENT_SECRET", "azure-client-secret"],
|
|
281
|
+
["GITHUB_TOKEN", "github-token"],
|
|
282
|
+
["GH_TOKEN", "github-token"],
|
|
283
|
+
["GOOGLE_APPLICATION_CREDENTIALS", "credential-file-path"],
|
|
284
|
+
["AWS_SHARED_CREDENTIALS_FILE", "credential-file-path"],
|
|
285
|
+
["AWS_WEB_IDENTITY_TOKEN_FILE", "credential-file-path"],
|
|
286
|
+
["AZURE_FEDERATED_TOKEN_FILE", "credential-file-path"],
|
|
287
|
+
]);
|
|
288
|
+
/**
|
|
289
|
+
* What a variable's name ends a word with when it holds a credential, the
|
|
290
|
+
* name split into words at anything not a letter and where a lower case
|
|
291
|
+
* letter meets a capital. A term matches the end of a word, so `AUTHTOKEN`
|
|
292
|
+
* and `TOKEN2` match and `TOKENIZERS` does not; `TOKENS` is left out because
|
|
293
|
+
* `MAX_TOKENS` is a model setting, not a secret.
|
|
294
|
+
*/
|
|
295
|
+
const NAME_TERMS = [
|
|
296
|
+
"TOKEN",
|
|
297
|
+
"SECRET",
|
|
298
|
+
"SECRETS",
|
|
299
|
+
"PASSWORD",
|
|
300
|
+
"PASSWORDS",
|
|
301
|
+
"PASSWD",
|
|
302
|
+
"CREDENTIAL",
|
|
303
|
+
"CREDENTIALS",
|
|
304
|
+
"APIKEY",
|
|
305
|
+
"API_KEY",
|
|
306
|
+
"ACCESSKEY",
|
|
307
|
+
"ACCESS_KEY",
|
|
308
|
+
"PRIVATEKEY",
|
|
309
|
+
"PRIVATE_KEY",
|
|
310
|
+
"SESSION_KEY",
|
|
311
|
+
"COOKIE",
|
|
312
|
+
"COOKIES",
|
|
313
|
+
"AUTH",
|
|
314
|
+
"AUTHORIZATION",
|
|
315
|
+
];
|
|
316
|
+
function credentialName(name) {
|
|
317
|
+
const words = `${name
|
|
318
|
+
.replace(/([a-z])([A-Z])/g, "$1_$2")
|
|
319
|
+
.toUpperCase()
|
|
320
|
+
.split(/[^A-Z]+/)
|
|
321
|
+
.join("_")}_`;
|
|
322
|
+
// A session is a credential when it ends the name (`APP_SESSION`), not when
|
|
323
|
+
// it qualifies something else (`TERM_SESSION_ID`).
|
|
324
|
+
return NAME_TERMS.some((term) => words.includes(`${term}_`)) || words.endsWith("SESSION_");
|
|
325
|
+
}
|
|
326
|
+
const JWT = /^eyJ[\w-]+\.[\w-]+\.[\w-]*$/;
|
|
327
|
+
const AWS_KEY_ID = /^(?:AKIA|ASIA)[A-Z0-9]{16}$/;
|
|
328
|
+
/** What a value's shape says it is, or null. Only the kind leaves this function. */
|
|
329
|
+
function shapeOf(value) {
|
|
330
|
+
if (JWT.test(value))
|
|
331
|
+
return "jwt";
|
|
332
|
+
if (value.includes("-----BEGIN ") && value.includes("PRIVATE KEY-----"))
|
|
333
|
+
return "pem-private-key";
|
|
334
|
+
if (AWS_KEY_ID.test(value))
|
|
335
|
+
return "aws-access-key";
|
|
336
|
+
const url = URL.parse(value);
|
|
337
|
+
return url !== null && (url.username !== "" || url.password !== "") ? "url-with-userinfo" : null;
|
|
338
|
+
}
|
|
339
|
+
/** Files that hold a credential wherever they exist. */
|
|
340
|
+
const WELL_KNOWN_FILES = [
|
|
341
|
+
{
|
|
342
|
+
path: "/var/run/secrets/kubernetes.io/serviceaccount/token",
|
|
343
|
+
home: false,
|
|
344
|
+
kind: "service-account-token",
|
|
345
|
+
},
|
|
346
|
+
{ path: ".aws/credentials", home: true, kind: "aws-credentials" },
|
|
347
|
+
{
|
|
348
|
+
path: ".config/gcloud/application_default_credentials.json",
|
|
349
|
+
home: true,
|
|
350
|
+
kind: "gcp-credentials",
|
|
351
|
+
},
|
|
352
|
+
{ path: ".azure/msal_token_cache.json", home: true, kind: "azure-cli-credentials" },
|
|
353
|
+
{ path: ".azure/accessTokens.json", home: true, kind: "azure-cli-credentials" },
|
|
354
|
+
{ path: ".azure/service_principal_entries.json", home: true, kind: "azure-cli-credentials" },
|
|
355
|
+
{ path: ".kube/config", home: true, kind: "kubeconfig" },
|
|
356
|
+
{ path: ".docker/config.json", home: true, kind: "docker-config" },
|
|
357
|
+
{ path: ".netrc", home: true, kind: "netrc" },
|
|
358
|
+
{ path: ".npmrc", home: true, kind: "npmrc" },
|
|
359
|
+
];
|
|
360
|
+
/** Variables that name a credential file, or a list of them. */
|
|
361
|
+
const NAMED_FILES = [
|
|
362
|
+
["GOOGLE_APPLICATION_CREDENTIALS", "gcp-credentials"],
|
|
363
|
+
["AWS_SHARED_CREDENTIALS_FILE", "aws-credentials"],
|
|
364
|
+
["AWS_WEB_IDENTITY_TOKEN_FILE", "web-identity-token"],
|
|
365
|
+
["AZURE_FEDERATED_TOKEN_FILE", "web-identity-token"],
|
|
366
|
+
["KUBECONFIG", "kubeconfig"],
|
|
367
|
+
];
|
|
368
|
+
/**
|
|
369
|
+
* List the credentials the zone holds, by name and kind, environment first in
|
|
370
|
+
* name order, then files in a fixed order.
|
|
371
|
+
*
|
|
372
|
+
* An environment variable is reported when its value is shaped like a JWT, a
|
|
373
|
+
* PEM private key, an AWS access key id or a URL with userinfo, when its name
|
|
374
|
+
* is one whose meaning is known, when its name reads as a credential's, or
|
|
375
|
+
* when the caller names it as the run's own. A variable with an empty value is
|
|
376
|
+
* not. The kind is the value's shape when it has one, then the known name's,
|
|
377
|
+
* then `secret-like`.
|
|
378
|
+
*
|
|
379
|
+
* A file is reported when it exists at a path where a credential is kept: the
|
|
380
|
+
* Kubernetes service-account token, the AWS, gcloud and Azure CLI stores,
|
|
381
|
+
* `~/.kube/config`, `~/.docker/config.json`, `~/.netrc`, `~/.npmrc`, and the
|
|
382
|
+
* files `GOOGLE_APPLICATION_CREDENTIALS` and its kin name. Files are never
|
|
383
|
+
* opened, so a file that holds no credential is reported too; and a variable
|
|
384
|
+
* that names a file is reported as `$VARIABLE`, since its value could be the
|
|
385
|
+
* credential itself rather than a path.
|
|
386
|
+
*
|
|
387
|
+
* It establishes what the zone holds at those names. It does not establish
|
|
388
|
+
* that the zone holds nothing else: a credential under an ordinary name, in an
|
|
389
|
+
* ordinary file, or in a process's memory is not seen.
|
|
390
|
+
*/
|
|
391
|
+
export function scanCredentials(options) {
|
|
392
|
+
const own = new Set(options.own);
|
|
393
|
+
const exists = options.exists ?? existsSync;
|
|
394
|
+
const findings = [];
|
|
395
|
+
for (const name of Object.keys(options.env).sort()) {
|
|
396
|
+
const value = options.env[name];
|
|
397
|
+
if (value === undefined || value === "")
|
|
398
|
+
continue;
|
|
399
|
+
const kind = shapeOf(value) ??
|
|
400
|
+
NAMED_KINDS.get(name) ??
|
|
401
|
+
(credentialName(name) || own.has(name) ? "secret-like" : null);
|
|
402
|
+
if (kind !== null)
|
|
403
|
+
findings.push({ source: "environment", name, kind, own: own.has(name) });
|
|
404
|
+
}
|
|
405
|
+
for (const file of WELL_KNOWN_FILES) {
|
|
406
|
+
const name = file.home ? `~/${file.path}` : file.path;
|
|
407
|
+
if (exists(file.home ? join(options.home, file.path) : file.path)) {
|
|
408
|
+
findings.push({ source: "file", name, kind: file.kind, own: own.has(name) });
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
for (const [variable, kind] of NAMED_FILES) {
|
|
412
|
+
const value = options.env[variable];
|
|
413
|
+
if (value === undefined)
|
|
414
|
+
continue;
|
|
415
|
+
const name = `$${variable}`;
|
|
416
|
+
if (value.split(delimiter).some((path) => exists(path))) {
|
|
417
|
+
findings.push({ source: "file", name, kind, own: own.has(name) });
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return findings;
|
|
421
|
+
}
|
|
422
|
+
const zoneName = z.string().min(1).max(ZONE_LIMITS.name);
|
|
423
|
+
const zoneAddress = z.string().min(1).max(ZONE_LIMITS.address);
|
|
424
|
+
const zoneCode = z.string().regex(CODE);
|
|
425
|
+
const zoneStatus = z.int().min(100).max(999).nullable();
|
|
426
|
+
const zoneVerdict = z.enum(["REACHABLE", "CONTAINED", "INCONCLUSIVE"]);
|
|
427
|
+
const zoneAt = z.iso.datetime();
|
|
428
|
+
const zoneExchange = z.strictObject({ status: zoneStatus, detail: zoneCode });
|
|
429
|
+
const providerAttempt = {
|
|
430
|
+
status: zoneStatus,
|
|
431
|
+
reason_code: zoneCode.nullable(),
|
|
432
|
+
detail: zoneCode,
|
|
433
|
+
};
|
|
434
|
+
/**
|
|
435
|
+
* The zone's findings, as the gateway parses them when a run closes. Closed
|
|
436
|
+
* at every level, bounded in every array and string, and with no field that
|
|
437
|
+
* can carry a credential's value: a kind is one of `CREDENTIAL_KINDS`, a
|
|
438
|
+
* detail and a reason are codes. It checks the form of what the zone said,
|
|
439
|
+
* not its truth.
|
|
440
|
+
*/
|
|
441
|
+
export const zoneFindingsSchema = z.strictObject({
|
|
442
|
+
origins: z
|
|
443
|
+
.array(z.strictObject({
|
|
444
|
+
name: zoneName,
|
|
445
|
+
address: zoneAddress,
|
|
446
|
+
direct: zoneExchange,
|
|
447
|
+
control: zoneExchange,
|
|
448
|
+
verdict: zoneVerdict,
|
|
449
|
+
at: zoneAt,
|
|
450
|
+
}))
|
|
451
|
+
.max(ZONE_LIMITS.targets),
|
|
452
|
+
providers: z
|
|
453
|
+
.array(z.strictObject({
|
|
454
|
+
name: zoneName,
|
|
455
|
+
unattested: z.strictObject(providerAttempt),
|
|
456
|
+
signed: z.strictObject({ ...providerAttempt, key_id: z.string().regex(KEY_ID) }).nullable(),
|
|
457
|
+
verdict: z.enum(["REFUSED", "ACCEPTED", "INCONCLUSIVE"]),
|
|
458
|
+
at: zoneAt,
|
|
459
|
+
}))
|
|
460
|
+
.max(ZONE_LIMITS.targets),
|
|
461
|
+
mcp: z
|
|
462
|
+
.array(z.strictObject({
|
|
463
|
+
name: zoneName,
|
|
464
|
+
address: zoneAddress,
|
|
465
|
+
verdict: zoneVerdict,
|
|
466
|
+
detail: zoneCode,
|
|
467
|
+
at: zoneAt,
|
|
468
|
+
}))
|
|
469
|
+
.max(ZONE_LIMITS.targets),
|
|
470
|
+
credentials: z
|
|
471
|
+
.array(z.strictObject({
|
|
472
|
+
source: z.enum(["environment", "file"]),
|
|
473
|
+
name: z.string().min(1).max(ZONE_LIMITS.credentialName),
|
|
474
|
+
kind: z.enum(CREDENTIAL_KINDS),
|
|
475
|
+
own: z.boolean(),
|
|
476
|
+
}))
|
|
477
|
+
.max(ZONE_LIMITS.credentials),
|
|
478
|
+
metadata: z
|
|
479
|
+
.strictObject({
|
|
480
|
+
address: zoneAddress,
|
|
481
|
+
status: zoneStatus,
|
|
482
|
+
detail: zoneCode,
|
|
483
|
+
verdict: zoneVerdict,
|
|
484
|
+
at: zoneAt,
|
|
485
|
+
})
|
|
486
|
+
.nullable(),
|
|
487
|
+
});
|
|
488
|
+
//# sourceMappingURL=ZoneProbes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZoneProbes.js","sourceRoot":"","sources":["../../src/acceptance/ZoneProbes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAA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,CAAC,SAAS,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC;QACxD,EAAE,EAAE,MAAM;KACX,CAAC,CACH;SACA,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC;IAC3B,GAAG,EAAE,CAAC;SACH,KAAK,CACJ,CAAC,CAAC,YAAY,CAAC;QACb,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,WAAW;QACpB,OAAO,EAAE,WAAW;QACpB,MAAM,EAAE,QAAQ;QAChB,EAAE,EAAE,MAAM;KACX,CAAC,CACH;SACA,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC;IAC3B,WAAW,EAAE,CAAC;SACX,KAAK,CACJ,CAAC,CAAC,YAAY,CAAC;QACb,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QACvC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,cAAc,CAAC;QACvD,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC;QAC9B,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE;KACjB,CAAC,CACH;SACA,GAAG,CAAC,WAAW,CAAC,WAAW,CAAC;IAC/B,QAAQ,EAAE,CAAC;SACR,YAAY,CAAC;QACZ,OAAO,EAAE,WAAW;QACpB,MAAM,EAAE,UAAU;QAClB,MAAM,EAAE,QAAQ;QAChB,OAAO,EAAE,WAAW;QACpB,EAAE,EAAE,MAAM;KACX,CAAC;SACD,QAAQ,EAAE;CACd,CAAC,CAAC"}
|
|
@@ -7,11 +7,12 @@ export declare class JcsError extends Error {
|
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* The canonical digest BEAP asks for: SHA-256 over the RFC 8785 canonical
|
|
10
|
-
* form of the value. The canonicaliser is the pipeline's
|
|
11
|
-
*
|
|
12
|
-
* ECMAScript does; for I-JSON input those
|
|
13
|
-
*
|
|
14
|
-
*
|
|
10
|
+
* form of the value. The canonicaliser is the pipeline's `Rfc8785`, which
|
|
11
|
+
* sorts every key by UTF-16 code unit and serialises numbers and strings the
|
|
12
|
+
* way ECMAScript does; for I-JSON input those are RFC 8785's rules, and the
|
|
13
|
+
* authority's payload digest and every verifier in another language apply
|
|
14
|
+
* them. It is not the intent's canonical form, which puts array-index keys
|
|
15
|
+
* first (spec/intent/v1 §4), so `{"10":…,"9":…}` keeps that order here.
|
|
15
16
|
*
|
|
16
17
|
* What the canonicaliser does not do is refuse input that is not I-JSON, so
|
|
17
18
|
* this adds that gate: a lone surrogate would serialise differently in
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JcsDigest.d.ts","sourceRoot":"","sources":["../../src/adapters/JcsDigest.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"JcsDigest.d.ts","sourceRoot":"","sources":["../../src/adapters/JcsDigest.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAExE,yEAAyE;AACzE,MAAM,MAAM,MAAM,GAAG,UAAU,MAAM,EAAE,CAAC;AAExC,qBAAa,QAAS,SAAQ,KAAK;aACE,IAAI,EAAE,gBAAgB,GAAG,uBAAuB;gBAAhD,IAAI,EAAE,gBAAgB,GAAG,uBAAuB;CAIpF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAIlD;AAED,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAGrD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAQxD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAmBlD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import {
|
|
2
|
+
import { Rfc8785 } from "@decionis/agent-safe-pipeline";
|
|
3
3
|
export class JcsError extends Error {
|
|
4
4
|
code;
|
|
5
5
|
constructor(code) {
|
|
@@ -10,11 +10,12 @@ export class JcsError extends Error {
|
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* The canonical digest BEAP asks for: SHA-256 over the RFC 8785 canonical
|
|
13
|
-
* form of the value. The canonicaliser is the pipeline's
|
|
14
|
-
*
|
|
15
|
-
* ECMAScript does; for I-JSON input those
|
|
16
|
-
*
|
|
17
|
-
*
|
|
13
|
+
* form of the value. The canonicaliser is the pipeline's `Rfc8785`, which
|
|
14
|
+
* sorts every key by UTF-16 code unit and serialises numbers and strings the
|
|
15
|
+
* way ECMAScript does; for I-JSON input those are RFC 8785's rules, and the
|
|
16
|
+
* authority's payload digest and every verifier in another language apply
|
|
17
|
+
* them. It is not the intent's canonical form, which puts array-index keys
|
|
18
|
+
* first (spec/intent/v1 §4), so `{"10":…,"9":…}` keeps that order here.
|
|
18
19
|
*
|
|
19
20
|
* What the canonicaliser does not do is refuse input that is not I-JSON, so
|
|
20
21
|
* this adds that gate: a lone surrogate would serialise differently in
|
|
@@ -24,13 +25,13 @@ export class JcsError extends Error {
|
|
|
24
25
|
*/
|
|
25
26
|
export function jcsDigest(value) {
|
|
26
27
|
assertIJson(value);
|
|
27
|
-
const canonical =
|
|
28
|
+
const canonical = Rfc8785.stringify(value);
|
|
28
29
|
return `sha256:${createHash("sha256").update(canonical).digest("hex")}`;
|
|
29
30
|
}
|
|
30
31
|
/** The canonical text itself, for a caller that wants to see what was hashed. */
|
|
31
32
|
export function jcsCanonical(value) {
|
|
32
33
|
assertIJson(value);
|
|
33
|
-
return
|
|
34
|
+
return Rfc8785.stringify(value);
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
36
37
|
* Whether a string is well-formed UTF-16: every surrogate paired. Written
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JcsDigest.js","sourceRoot":"","sources":["../../src/adapters/JcsDigest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"JcsDigest.js","sourceRoot":"","sources":["../../src/adapters/JcsDigest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAkB,MAAM,+BAA+B,CAAC;AAKxE,MAAM,OAAO,QAAS,SAAQ,KAAK;IACE;IAAnC,YAAmC,IAAgD;QACjF,KAAK,CAAC,IAAI,CAAC,CAAC;QADqB,SAAI,GAAJ,IAAI,CAA4C;QAEjF,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,SAAS,CAAC,KAAgB;IACxC,WAAW,CAAC,KAAK,CAAC,CAAC;IACnB,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,UAAU,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AAC1E,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,YAAY,CAAC,KAAgB;IAC3C,WAAW,CAAC,KAAK,CAAC,CAAC;IACnB,OAAO,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,KAAK,MAAM,SAAS,IAAI,KAAK,EAAE,CAAC;QAC9B,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACrC,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM;gBAAE,OAAO,KAAK,CAAC;QACrD,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAgB;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC;YAAE,MAAM,IAAI,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QACpE,OAAO;IACT,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,MAAM,IAAI,QAAQ,CAAC,uBAAuB,CAAC,CAAC;QACzE,OAAO;IACT,CAAC;IACD,0EAA0E;IAC1E,0EAA0E;IAC1E,6DAA6D;IAC7D,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO;IAC3B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC;YAAE,MAAM,IAAI,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QAClE,sEAAsE;QACtE,yCAAyC;QACzC,IAAI,KAAK,KAAK,SAAS;YAAE,WAAW,CAAC,KAAkB,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CliProcess } from "./CliProcess.js";
|
|
2
|
+
export declare const ACCEPT_ARGUMENTS: {
|
|
3
|
+
readonly valued: readonly ["plan", "token-file", "tenant-key-file", "out", "timeout-ms"];
|
|
4
|
+
readonly flags: readonly ["json"];
|
|
5
|
+
};
|
|
6
|
+
/** Where the report goes unless `--out` says otherwise. */
|
|
7
|
+
export declare const DEFAULT_REPORT_FILE = "acceptance.jws";
|
|
8
|
+
export declare function runAccept(io: CliProcess, argv: readonly string[]): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=Accept.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Accept.d.ts","sourceRoot":"","sources":["../../src/cli/Accept.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,eAAO,MAAM,gBAAgB;;;CAGnB,CAAC;AAEX,2DAA2D;AAC3D,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AAcpD,wBAAsB,SAAS,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA4LtF"}
|