@strixgov/mcp-proxy 0.2.4 → 0.3.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/CHANGELOG.md +92 -1
- package/README.md +277 -38
- package/bin/strix-mcp-proxy.mjs +100 -5
- package/examples/controlled-launcher/README.md +33 -0
- package/examples/controlled-launcher/acceptance.mjs +337 -0
- package/examples/controlled-launcher/agent-client.mjs +18 -0
- package/examples/controlled-launcher/approval-relay.mjs +19 -0
- package/examples/controlled-launcher/approver.mjs +27 -0
- package/examples/controlled-launcher/authorizer.mjs +73 -0
- package/examples/controlled-launcher/bridge-client.mjs +8 -0
- package/examples/controlled-launcher/destination.mjs +18 -0
- package/examples/controlled-launcher/executor.mjs +74 -0
- package/examples/controlled-launcher/kernel-authority/acceptance.mjs +627 -0
- package/examples/controlled-launcher/kernel-authority/broker.mjs +83 -0
- package/examples/controlled-launcher/kernel-authority/derive.mjs +12 -0
- package/examples/controlled-launcher/kernel-authority/executor.mjs +105 -0
- package/examples/controlled-launcher/kernel-authority/reconcile.mjs +43 -0
- package/examples/controlled-launcher/kernel-authority/shim.mjs +38 -0
- package/examples/controlled-launcher/kernel-authority/signing-provider.mjs +137 -0
- package/examples/controlled-launcher/kernel-authority/strix-approver.mjs +73 -0
- package/examples/controlled-launcher/lib.mjs +63 -0
- package/examples/controlled-launcher/make-config.mjs +16 -0
- package/examples/controlled-launcher/proxy-host.mjs +19 -0
- package/examples/controlled-launcher/reconcile.mjs +30 -0
- package/examples/controlled-launcher/shim.mjs +32 -0
- package/examples/github-reference/README.md +1 -1
- package/examples/github-reference/acceptance.mjs +10 -3
- package/examples/github-reference/claims-matrix.md +3 -3
- package/examples/github-reference/package-lock.json +48 -44
- package/examples/github-reference/package.json +4 -4
- package/examples/github-reference/reuse-inventory.md +4 -4
- package/examples/synthetic-server/proxy-config.json +16 -0
- package/examples/synthetic-server/quickstart.mjs +98 -0
- package/examples/synthetic-server/server.mjs +54 -0
- package/package.json +5 -4
- package/src/config.mjs +152 -2
- package/src/content-guard.mjs +432 -0
- package/src/http-upstream.mjs +431 -0
- package/src/index.mjs +11 -2
- package/src/proxy.mjs +241 -33
- package/src/tool-guard.mjs +183 -0
- package/src/types.d.ts +83 -1
- package/test/content-guard-hardening.test.mjs +159 -0
- package/test/content-guard.test.mjs +387 -0
- package/test/http-upstream-config.test.mjs +115 -0
- package/test/http-upstream-e2e.test.mjs +279 -0
- package/test/http-upstream.test.mjs +304 -0
- package/test/synthetic-quickstart.test.mjs +44 -0
- package/test/tool-guard.test.mjs +243 -0
- package/test/validate-cli.test.mjs +171 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Copies bytes between the proxy's private approvals dir (0700, files 0600) and the approver's dir.
|
|
3
|
+
// It cannot approve anything: the proxy requires an approver-signed response over the request's exact bytes.
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
const [proxyDir, approverDir] = process.argv.slice(2);
|
|
7
|
+
const seen = new Set();
|
|
8
|
+
setInterval(() => {
|
|
9
|
+
for (const n of fs.readdirSync(proxyDir).filter((x) => x.endsWith(".request.json"))) {
|
|
10
|
+
const dst = path.join(approverDir, n);
|
|
11
|
+
if (!fs.existsSync(dst)) { try { fs.writeFileSync(dst, fs.readFileSync(path.join(proxyDir, n)), { mode: 0o640 }); } catch {} }
|
|
12
|
+
}
|
|
13
|
+
for (const n of fs.readdirSync(approverDir).filter((x) => x.endsWith(".response.json"))) {
|
|
14
|
+
const id = n.replace(/\.response\.json$/, "");
|
|
15
|
+
const src = path.join(approverDir, n);
|
|
16
|
+
if (seen.has(n) || !fs.existsSync(path.join(proxyDir, id + ".request.json"))) continue;
|
|
17
|
+
try { fs.writeFileSync(path.join(proxyDir, n), fs.readFileSync(src), { mode: 0o600 }); seen.add(n); } catch {}
|
|
18
|
+
}
|
|
19
|
+
}, 100);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Human-approver stand-in (separate OS identity). Uses @strixgov/guard's own approveSigned (signs the exact
|
|
3
|
+
// request bytes), then submits request+signed response to the authorizer so a payload-bound token can be minted.
|
|
4
|
+
// In a real deployment a person types the passphrase at a TTY; here a 0400 file stands in. Test approver only.
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { approveSigned, createApproverKey, readApproverPublic } from "@strixgov/guard";
|
|
8
|
+
import { call } from "./lib.mjs";
|
|
9
|
+
const [cmd, home, ...rest] = process.argv.slice(2);
|
|
10
|
+
process.env.STRIX_GUARD_HOME = home;
|
|
11
|
+
const passFile = path.join(home, "passphrase");
|
|
12
|
+
if (cmd === "init") {
|
|
13
|
+
const pub = await createApproverKey({ passphrase: fs.readFileSync(passFile, "utf8").trim(), label: "synthetic-approver", force: true });
|
|
14
|
+
fs.writeFileSync(path.join(home, "approver-public.json"), JSON.stringify(pub), { mode: 0o644 });
|
|
15
|
+
} else if (cmd === "approve") {
|
|
16
|
+
const [requestId, registerSock] = rest;
|
|
17
|
+
const reqPath = path.join(home, "approvals", `${requestId}.request.json`);
|
|
18
|
+
const requestText = fs.readFileSync(reqPath, "utf8");
|
|
19
|
+
const r = await approveSigned(requestId, { io: { isTty: true, confirm: async () => true, secret: async () => fs.readFileSync(passFile, "utf8").trim(), print: () => {} } });
|
|
20
|
+
fs.chmodSync(r.responsePath, 0o640);
|
|
21
|
+
const response = JSON.parse(fs.readFileSync(r.responsePath, "utf8"));
|
|
22
|
+
const reg = await call(registerSock, { op: "register", requestText, response });
|
|
23
|
+
console.log(JSON.stringify({ requestId, signed: true, registered: reg }));
|
|
24
|
+
} else if (cmd === "pending") {
|
|
25
|
+
const dir = path.join(home, "approvals");
|
|
26
|
+
console.log(fs.readdirSync(dir).filter((n) => n.endsWith(".request.json")).map((n) => n.replace(".request.json", "")).join("\n"));
|
|
27
|
+
} else { console.error("usage: init|approve|pending"); process.exit(2); }
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// TEST-KEY authorization service (stands in for the Strix kernel; NOT a production minter).
|
|
3
|
+
// Mints an execution_authorization_v1 token only from an approver-signed approval of the EXACT request,
|
|
4
|
+
// pinned to the Guard approver public key. The token binds payloadHash = SHA-256(SCJ v1(args)).
|
|
5
|
+
// Tokens are claimed once (atomic rename); an approval request id can be registered once.
|
|
6
|
+
import fs from "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import crypto from "node:crypto";
|
|
9
|
+
import { serve, payloadHash, sha256hex, signCanonical, jwkPublic, pubFromX, canonicalizeJSON } from "./lib.mjs";
|
|
10
|
+
|
|
11
|
+
const [registerSock, claimSock, stateDir, approverPubFile, tenantId, environment] = process.argv.slice(2);
|
|
12
|
+
const KID = "mode3-authz-test-1";
|
|
13
|
+
for (const d of ["unclaimed", "claimed", "registered"]) fs.mkdirSync(path.join(stateDir, d), { recursive: true, mode: 0o700 });
|
|
14
|
+
const keyFile = path.join(stateDir, "private.pem");
|
|
15
|
+
let priv;
|
|
16
|
+
if (fs.existsSync(keyFile)) priv = crypto.createPrivateKey(fs.readFileSync(keyFile));
|
|
17
|
+
else {
|
|
18
|
+
const kp = crypto.generateKeyPairSync("ed25519");
|
|
19
|
+
fs.writeFileSync(keyFile, kp.privateKey.export({ format: "pem", type: "pkcs8" }), { mode: 0o400 });
|
|
20
|
+
priv = kp.privateKey;
|
|
21
|
+
}
|
|
22
|
+
const pub = crypto.createPublicKey(priv);
|
|
23
|
+
fs.writeFileSync(path.join(stateDir, "jwks.json"), JSON.stringify({ keys: [jwkPublic(pub, KID)] }, null, 2), { mode: 0o644 });
|
|
24
|
+
const approver = JSON.parse(fs.readFileSync(approverPubFile, "utf8"));
|
|
25
|
+
const approverKey = pubFromX(approver.publicKey);
|
|
26
|
+
const log = (o) => fs.appendFileSync(path.join(stateDir, "authorizer-log.jsonl"), JSON.stringify({ t: new Date().toISOString(), ...o }) + "\n");
|
|
27
|
+
|
|
28
|
+
// Mirrors @strixgov/guard approvalPreimage (strix-guard-approval/v1).
|
|
29
|
+
const preimage = ({ requestId, requestSha256, approved, decidedAt, kid }) =>
|
|
30
|
+
["strix-guard-approval/v1", `request:${requestId}`, `requestSha256:${requestSha256}`, `approved:${approved === true ? "true" : "false"}`, `decidedAt:${decidedAt}`, `kid:${kid}`].join("\n");
|
|
31
|
+
|
|
32
|
+
serve(registerSock, async (m) => {
|
|
33
|
+
if (m.op !== "register") return { ok: false, error: "UNKNOWN_OP" };
|
|
34
|
+
const { requestText, response } = m;
|
|
35
|
+
let req;
|
|
36
|
+
try { req = JSON.parse(requestText); } catch { return { ok: false, error: "REQUEST_NOT_JSON" }; }
|
|
37
|
+
if (!response || response.approved !== true) return { ok: false, error: "NOT_APPROVED" };
|
|
38
|
+
if (response.kid !== approver.kid) return { ok: false, error: "UNKNOWN_APPROVER_KEY" };
|
|
39
|
+
if (response.requestSha256 !== sha256hex(requestText)) return { ok: false, error: "REQUEST_HASH_MISMATCH" };
|
|
40
|
+
const ok = crypto.verify(null, Buffer.from(preimage({ requestId: req.requestId, requestSha256: response.requestSha256, approved: true, decidedAt: response.decidedAt, kid: response.kid }), "utf8"), approverKey, Buffer.from(response.signature ?? "", "base64url"));
|
|
41
|
+
if (!ok) { log({ ev: "register-refused", reason: "BAD_SIGNATURE", requestId: req.requestId }); return { ok: false, error: "BAD_SIGNATURE" }; }
|
|
42
|
+
if (Date.now() - Date.parse(response.decidedAt) > 5 * 60_000) return { ok: false, error: "APPROVAL_STALE" };
|
|
43
|
+
try { fs.writeFileSync(path.join(stateDir, "registered", req.requestId), "", { flag: "wx" }); }
|
|
44
|
+
catch { log({ ev: "register-refused", reason: "APPROVAL_ALREADY_USED", requestId: req.requestId }); return { ok: false, error: "APPROVAL_ALREADY_USED" }; }
|
|
45
|
+
const args = req.invocation?.args ?? {};
|
|
46
|
+
const now = Date.now();
|
|
47
|
+
const payload = {
|
|
48
|
+
schemaVersion: 1, authorizationId: "authz_" + crypto.randomBytes(8).toString("hex"), decisionId: "dec_" + req.requestId,
|
|
49
|
+
capabilityId: req.capability.id, actorId: "agent:controlled-launcher-demo", actorClass: "agent",
|
|
50
|
+
payloadHash: payloadHash(args), tenantId, environment, nonce: crypto.randomBytes(16).toString("hex"),
|
|
51
|
+
issuedAt: new Date(now).toISOString().replace(/\.\d+Z$/, "Z"), expiresAt: new Date(now + Number(process.env.AUTHZ_TTL_MS ?? 60000)).toISOString().replace(/\.\d+Z$/, "Z"),
|
|
52
|
+
};
|
|
53
|
+
const token = { ...payload, signingKeyId: KID, signature: signCanonical(payload, priv) };
|
|
54
|
+
const file = path.join(stateDir, "unclaimed", `${payload.payloadHash.slice(7)}.${payload.authorizationId}.json`);
|
|
55
|
+
fs.writeFileSync(file, JSON.stringify(token), { mode: 0o600 });
|
|
56
|
+
log({ ev: "minted", requestId: req.requestId, authorizationId: payload.authorizationId, payloadHash: payload.payloadHash, capabilityId: payload.capabilityId });
|
|
57
|
+
return { ok: true, authorizationId: payload.authorizationId, payloadHash: payload.payloadHash };
|
|
58
|
+
}, 0o660);
|
|
59
|
+
|
|
60
|
+
serve(claimSock, async (m) => {
|
|
61
|
+
if (m.op !== "claim" || typeof m.payloadHash !== "string" || !/^sha256:[0-9a-f]{64}$/.test(m.payloadHash)) return { ok: false, error: "BAD_CLAIM" };
|
|
62
|
+
const prefix = m.payloadHash.slice(7) + ".";
|
|
63
|
+
for (const name of fs.readdirSync(path.join(stateDir, "unclaimed")).filter((n) => n.startsWith(prefix))) {
|
|
64
|
+
try { fs.renameSync(path.join(stateDir, "unclaimed", name), path.join(stateDir, "claimed", name)); }
|
|
65
|
+
catch { continue; } // lost the race: another claimant took it
|
|
66
|
+
const token = JSON.parse(fs.readFileSync(path.join(stateDir, "claimed", name), "utf8"));
|
|
67
|
+
if (m.capabilityId && token.capabilityId !== m.capabilityId) { log({ ev: "claim-capability-mismatch", name }); continue; }
|
|
68
|
+
log({ ev: "claimed", authorizationId: token.authorizationId, payloadHash: m.payloadHash });
|
|
69
|
+
return { ok: true, token };
|
|
70
|
+
}
|
|
71
|
+
log({ ev: "claim-none", payloadHash: m.payloadHash });
|
|
72
|
+
return { ok: false, error: "NO_AUTHORIZATION" };
|
|
73
|
+
}, 0o660);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// What the unprivileged MCP client launches as its "server command". It is only a stdio<->socket pipe to the
|
|
3
|
+
// trusted proxy service. It carries no configuration and no credentials.
|
|
4
|
+
import net from "node:net";
|
|
5
|
+
const c = net.connect(process.argv[2]);
|
|
6
|
+
process.stdin.pipe(c); c.pipe(process.stdout);
|
|
7
|
+
c.on("error", (e) => { process.stderr.write("bridge: " + e.code + "\n"); process.exit(1); });
|
|
8
|
+
c.on("close", () => process.exit(0));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Synthetic GitHub-shaped destination. Logs EVERY request independently of any proxy.
|
|
2
|
+
import http from "node:http"; import fs from "node:fs";
|
|
3
|
+
const [port, log] = process.argv.slice(2); const execTok = process.env.DEST_EXEC, obsTok = process.env.DEST_OBS;
|
|
4
|
+
const branches = new Set(["main"]);
|
|
5
|
+
http.createServer((req, res) => {
|
|
6
|
+
let body = ""; req.on("data", d => body += d); req.on("end", () => {
|
|
7
|
+
const auth = (req.headers.authorization || "").replace(/^Bearer /, "");
|
|
8
|
+
const role = auth === execTok ? "executor" : auth === obsTok ? "observer" : auth ? "unknown-token" : "none";
|
|
9
|
+
let status = 401, out = { error: "unauthorized" };
|
|
10
|
+
if (req.method === "POST" && req.url === "/repos/synthetic/fixture/git/refs" && role === "executor") {
|
|
11
|
+
const ref = JSON.parse(body || "{}").ref; branches.add(ref); status = 201; out = { created: ref };
|
|
12
|
+
} else if (req.method === "GET" && req.url === "/repos/synthetic/fixture/branches" && (role === "observer" || role === "executor")) {
|
|
13
|
+
status = 200; out = { branches: [...branches] };
|
|
14
|
+
} else if (role !== "none" && role !== "unknown-token") { status = 403; out = { error: "role not permitted" }; }
|
|
15
|
+
fs.appendFileSync(log, JSON.stringify({ t: new Date().toISOString(), method: req.method, url: req.url, role, status, body: body.slice(0, 200) }) + "\n");
|
|
16
|
+
res.writeHead(status, { "content-type": "application/json" }); res.end(JSON.stringify(out));
|
|
17
|
+
});
|
|
18
|
+
}).listen(+port, "127.0.0.1");
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Credential-holding destination executor (separate OS identity). Accepts ONLY:
|
|
3
|
+
// reads -> performed with its own credential (no token needed)
|
|
4
|
+
// create_branch -> requires a valid, exact-payload, single-use execution_authorization_v1 token
|
|
5
|
+
// Everything else is refused. It trusts neither the shim nor the proxy: the token is validated here with
|
|
6
|
+
// the published @strixgov/mcp-token-validator against the authorizer's JWKS.
|
|
7
|
+
// Write-ahead attempt accounting: STARTED is fsynced BEFORE the destination is called. A crash leaves STARTED
|
|
8
|
+
// with no outcome; on restart it is recorded UNKNOWN (never auto-retried) and reconciled by the observer.
|
|
9
|
+
import fs from "node:fs";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
import crypto from "node:crypto";
|
|
12
|
+
import { validateAuthorization } from "@strixgov/mcp-token-validator";
|
|
13
|
+
import { serve, payloadHash, appendDurable, burnOnce, signCanonical, jwkPublic } from "./lib.mjs";
|
|
14
|
+
|
|
15
|
+
const [sock, stateDir, authzJwksFile, destUrl, tenantId, environment] = process.argv.slice(2);
|
|
16
|
+
const credential = process.env.EXECUTOR_TOKEN; // delivered only to this process's environment
|
|
17
|
+
if (!credential) { console.error("executor: EXECUTOR_TOKEN missing"); process.exit(2); }
|
|
18
|
+
delete process.env.EXECUTOR_TOKEN;
|
|
19
|
+
fs.mkdirSync(path.join(stateDir, "nonces"), { recursive: true, mode: 0o755 });
|
|
20
|
+
const attemptsFile = path.join(stateDir, "attempts.jsonl");
|
|
21
|
+
const outcomesFile = path.join(stateDir, "outcomes.jsonl");
|
|
22
|
+
const keyFile = path.join(stateDir, "outcome-key.pem");
|
|
23
|
+
let priv;
|
|
24
|
+
if (fs.existsSync(keyFile)) priv = crypto.createPrivateKey(fs.readFileSync(keyFile));
|
|
25
|
+
else { const kp = crypto.generateKeyPairSync("ed25519"); fs.writeFileSync(keyFile, kp.privateKey.export({ format: "pem", type: "pkcs8" }), { mode: 0o400 }); priv = kp.privateKey; }
|
|
26
|
+
const OUT_KID = "executor-outcome-test-1";
|
|
27
|
+
fs.writeFileSync(path.join(stateDir, "outcome-jwks.json"), JSON.stringify({ keys: [jwkPublic(crypto.createPublicKey(priv), OUT_KID)] }, null, 2), { mode: 0o644 });
|
|
28
|
+
|
|
29
|
+
// Crash recovery: STARTED without a terminal record -> UNKNOWN (reconcile against the destination; never retried here).
|
|
30
|
+
const readJsonl = (f) => (fs.existsSync(f) ? fs.readFileSync(f, "utf8").trim().split("\n").filter(Boolean).map(JSON.parse) : []);
|
|
31
|
+
{
|
|
32
|
+
const done = new Set(readJsonl(outcomesFile).map((o) => o.attemptId));
|
|
33
|
+
for (const a of readJsonl(attemptsFile).filter((x) => x.state === "STARTED" && !done.has(x.attemptId))) {
|
|
34
|
+
appendDurable(attemptsFile, { attemptId: a.attemptId, state: "RECOVERED_UNKNOWN", at: new Date().toISOString(), note: "no outcome recorded before restart; reconcile against destination" });
|
|
35
|
+
writeOutcome({ attemptId: a.attemptId, authorizationId: a.authorizationId, payloadHash: a.payloadHash, status: "UNKNOWN", destinationStatus: null });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function writeOutcome(o) {
|
|
40
|
+
const payload = { schemaVersion: 1, outcomeId: "out_" + crypto.randomBytes(8).toString("hex"), ...o, at: new Date().toISOString() };
|
|
41
|
+
appendDurable(outcomesFile, { ...payload, signingKeyId: OUT_KID, signature: signCanonical(payload, priv) });
|
|
42
|
+
return payload;
|
|
43
|
+
}
|
|
44
|
+
const authzJwks = () => JSON.parse(fs.readFileSync(authzJwksFile, "utf8"));
|
|
45
|
+
const refuse = (error, detail) => ({ ok: false, error, ...(detail ? { detail } : {}) });
|
|
46
|
+
const result = (text, isError = false) => ({ ok: true, content: [{ type: "text", text }], ...(isError ? { isError } : {}) });
|
|
47
|
+
const dest = (method, url, body) => fetch(destUrl + url, { method, headers: { authorization: "Bearer " + credential }, body: body ? JSON.stringify(body) : undefined });
|
|
48
|
+
|
|
49
|
+
serve(sock, async (m) => {
|
|
50
|
+
const { tool, args = {}, token } = m;
|
|
51
|
+
if (tool === "get_file_contents" || tool === "list_branches") {
|
|
52
|
+
const r = await dest("GET", "/repos/synthetic/fixture/branches");
|
|
53
|
+
return result(JSON.stringify(await r.json()));
|
|
54
|
+
}
|
|
55
|
+
if (tool !== "create_branch") return refuse("TOOL_NOT_PERMITTED_BY_EXECUTOR", tool);
|
|
56
|
+
if (!token) return refuse("AUTHORIZATION_REQUIRED");
|
|
57
|
+
if (args.owner !== "synthetic" || args.repo !== "fixture") return refuse("SCOPE_REFUSED", "owner/repo outside declared estate");
|
|
58
|
+
const ph = payloadHash(args);
|
|
59
|
+
const v = await validateAuthorization(token, {
|
|
60
|
+
jwks: authzJwks(), expectedTenantId: tenantId, expectedEnvironment: environment, expectedActorClass: "agent",
|
|
61
|
+
burnNonce: async (n) => burnOnce(path.join(stateDir, "nonces"), n),
|
|
62
|
+
});
|
|
63
|
+
if (!v.ok) return refuse("AUTHORIZATION_INVALID", v.reason);
|
|
64
|
+
if (v.capabilityId !== "mcp.github.create_branch") return refuse("AUTHORIZATION_CAPABILITY_MISMATCH");
|
|
65
|
+
if (v.payloadHash !== ph) return refuse("AUTHORIZATION_PAYLOAD_MISMATCH"); // nonce already burned: a mismatched use consumes the token
|
|
66
|
+
const attemptId = "att_" + crypto.randomBytes(8).toString("hex");
|
|
67
|
+
appendDurable(attemptsFile, { attemptId, state: "STARTED", authorizationId: v.authorizationId, payloadHash: ph, tool, ref: "refs/heads/" + args.branch, at: new Date().toISOString() });
|
|
68
|
+
if (process.env.EXECUTOR_TEST_CRASH_AFTER_STARTED === "1") process.exit(99); // test hook: crash-recovery scenario
|
|
69
|
+
let status = null, st = "FAILED";
|
|
70
|
+
try { const r = await dest("POST", "/repos/synthetic/fixture/git/refs", { ref: "refs/heads/" + args.branch }); status = r.status; st = r.status === 201 ? "SUCCEEDED" : "REJECTED"; } catch { st = "UNKNOWN"; }
|
|
71
|
+
const o = writeOutcome({ attemptId, authorizationId: v.authorizationId, payloadHash: ph, status: st, destinationStatus: status });
|
|
72
|
+
appendDurable(attemptsFile, { attemptId, state: "COMPLETED_" + st, at: o.at });
|
|
73
|
+
return result(JSON.stringify({ status: st, destinationStatus: status, attemptId }), st !== "SUCCEEDED");
|
|
74
|
+
}, 0o660);
|