@sjawhar/pi-envoy 17.25.0 → 17.27.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/dist/dispatch.js +919 -80
- package/dist/envoy.js +951 -110
- package/package.json +1 -1
package/dist/envoy.js
CHANGED
|
@@ -30219,6 +30219,14 @@ var handoffValidation = {
|
|
|
30219
30219
|
message: HANDOFF_RULE,
|
|
30220
30220
|
refusal: (value) => handoffProblem(value) ?? HANDOFF_RULE
|
|
30221
30221
|
};
|
|
30222
|
+
var REVIEW_REASON_RULE = "verdict changes_requested requires reason, a non-empty note saying what must change before the document can be approved.";
|
|
30223
|
+
var reviewValidation = {
|
|
30224
|
+
check: (value) => {
|
|
30225
|
+
const input = value;
|
|
30226
|
+
return input.verdict !== "changes_requested" || typeof input.reason === "string" && input.reason.trim() !== "";
|
|
30227
|
+
},
|
|
30228
|
+
message: REVIEW_REASON_RULE
|
|
30229
|
+
};
|
|
30222
30230
|
var RESULT_REQUIRED_FIELDS = ["issue", "check", "role", "verdict", "commit"];
|
|
30223
30231
|
var RESULT_RECORD_FIELDS = [
|
|
30224
30232
|
...RESULT_REQUIRED_FIELDS,
|
|
@@ -30602,6 +30610,20 @@ var dispatchToolSpecs = [
|
|
|
30602
30610
|
version: z.number({ int: true, min: 1 }).describe("The plan version the review read and approved.")
|
|
30603
30611
|
})
|
|
30604
30612
|
},
|
|
30613
|
+
{
|
|
30614
|
+
name: "dispatch_review",
|
|
30615
|
+
example: { issue: "DSP-1", version: 2, verdict: "approved" },
|
|
30616
|
+
description: "Approve one version of an issue's document, or request changes on it, as the person your " + "token names: what the document header's Approve and Request changes record. A review " + "records an approval or a changes request in the person's name at that version, so it " + "works only with a token that names a person who holds approve; Dispatch refuses it to " + "any other token, with 403 OAUTH_SCOPE_REQUIRED or 403 SIGN_IN_REQUIRED. --version is the " + "version you read, sent in the review route's path, and it must be the version the review " + "would record: the document's latest settled version, or, while an approval request is " + "open on it, the version that request names for it. Any other is refused 409 " + "REVIEW_VERSION_MOVED, which names the version to read, and nothing is recorded. A " + "Dispatch build without the versioned review route answers no route and records nothing; " + "the command then says so and names /healthz, which names the commit of the build that " + "answers it when that build was stamped with one. With a request open the review answers " + "it, and records the same verdict on every document the " + "request names, each at the version the request names. A later version makes an approval " + "stale. A review is the one browser action this command takes for a person; every other " + "browser action is dispatch://INFRA-910's. " + ISSUE_REFERENCE,
|
|
30617
|
+
arguments: (z) => ({
|
|
30618
|
+
issue: z.string().describe(ISSUE_REFERENCE),
|
|
30619
|
+
artifact: z.string().describe("Document artifact id, slug, or filename; the issue's spec by default.").optional(),
|
|
30620
|
+
version: z.number({ int: true, min: 1 }).describe("The document version you read and review, sent as a segment of the review route's path: the version the review would record, or Dispatch refuses it 409 REVIEW_VERSION_MOVED naming the version to read."),
|
|
30621
|
+
verdict: z.enum(["approved", "changes_requested"]).describe("approved records an approval; changes_requested records a request for changes and requires reason."),
|
|
30622
|
+
reason: z.string().describe("What must change before the document can be approved. changes_requested requires it; an approval may carry one.").optional()
|
|
30623
|
+
}),
|
|
30624
|
+
validation: reviewValidation,
|
|
30625
|
+
strict: true
|
|
30626
|
+
},
|
|
30605
30627
|
{
|
|
30606
30628
|
name: "dispatch_result",
|
|
30607
30629
|
example: {
|
|
@@ -33084,6 +33106,9 @@ function mintMarker(store, input, now) {
|
|
|
33084
33106
|
return file;
|
|
33085
33107
|
}
|
|
33086
33108
|
|
|
33109
|
+
// ../broker-client/src/dpop.ts
|
|
33110
|
+
import { createPrivateKey, createPublicKey } from "crypto";
|
|
33111
|
+
|
|
33087
33112
|
// ../../node_modules/.bun/jose@6.2.9/node_modules/jose/dist/webapi/lib/buffer_utils.js
|
|
33088
33113
|
var encoder2 = new TextEncoder;
|
|
33089
33114
|
var decoder = new TextDecoder;
|
|
@@ -33930,6 +33955,112 @@ function keyAlgorithm(alg, source) {
|
|
|
33930
33955
|
return (typeof alg === "string" ? JWS[alg] ?? JWE[alg] : undefined) ?? unsupportedAlg(source);
|
|
33931
33956
|
}
|
|
33932
33957
|
|
|
33958
|
+
// ../../node_modules/.bun/jose@6.2.9/node_modules/jose/dist/webapi/lib/asn1.js
|
|
33959
|
+
var bytesEqual = (a, b) => {
|
|
33960
|
+
if (a.byteLength !== b.length)
|
|
33961
|
+
return false;
|
|
33962
|
+
for (let i = 0;i < a.byteLength; i++) {
|
|
33963
|
+
if (a[i] !== b[i])
|
|
33964
|
+
return false;
|
|
33965
|
+
}
|
|
33966
|
+
return true;
|
|
33967
|
+
};
|
|
33968
|
+
var createASN1State = (data) => ({ data, pos: 0 });
|
|
33969
|
+
var readByte = (state) => {
|
|
33970
|
+
const byte = state.data[state.pos++];
|
|
33971
|
+
if (byte === undefined) {
|
|
33972
|
+
throw new Error("Unexpected end of ASN.1 input");
|
|
33973
|
+
}
|
|
33974
|
+
return byte;
|
|
33975
|
+
};
|
|
33976
|
+
var parseLength = (state) => {
|
|
33977
|
+
const first = readByte(state);
|
|
33978
|
+
if (first & 128) {
|
|
33979
|
+
const lengthOfLen = first & 127;
|
|
33980
|
+
let length = 0;
|
|
33981
|
+
for (let i = 0;i < lengthOfLen; i++) {
|
|
33982
|
+
length = length << 8 | readByte(state);
|
|
33983
|
+
}
|
|
33984
|
+
return length;
|
|
33985
|
+
}
|
|
33986
|
+
return first;
|
|
33987
|
+
};
|
|
33988
|
+
var expectTag = (state, expectedTag, errorMessage) => {
|
|
33989
|
+
if (readByte(state) !== expectedTag) {
|
|
33990
|
+
throw new Error(errorMessage);
|
|
33991
|
+
}
|
|
33992
|
+
};
|
|
33993
|
+
var getSubarray = (state, length) => {
|
|
33994
|
+
if (length < 0 || state.pos + length > state.data.length) {
|
|
33995
|
+
throw new Error("Unexpected end of ASN.1 input");
|
|
33996
|
+
}
|
|
33997
|
+
const result = state.data.subarray(state.pos, state.pos + length);
|
|
33998
|
+
state.pos += length;
|
|
33999
|
+
return result;
|
|
34000
|
+
};
|
|
34001
|
+
var parseAlgorithmOID = (state) => {
|
|
34002
|
+
expectTag(state, 6, "Expected algorithm OID");
|
|
34003
|
+
const oidLen = parseLength(state);
|
|
34004
|
+
return getSubarray(state, oidLen);
|
|
34005
|
+
};
|
|
34006
|
+
function parseKeyHeader(state, keyFormat) {
|
|
34007
|
+
expectTag(state, 48, `Invalid ${keyFormat === "spki" ? "SPKI" : "PKCS#8"} structure`);
|
|
34008
|
+
parseLength(state);
|
|
34009
|
+
if (keyFormat === "pkcs8") {
|
|
34010
|
+
expectTag(state, 2, "Expected version field");
|
|
34011
|
+
const length = parseLength(state);
|
|
34012
|
+
state.pos += length;
|
|
34013
|
+
}
|
|
34014
|
+
expectTag(state, 48, "Expected algorithm identifier");
|
|
34015
|
+
parseLength(state);
|
|
34016
|
+
}
|
|
34017
|
+
var parseECAlgorithmIdentifier = (state) => {
|
|
34018
|
+
const algOid = parseAlgorithmOID(state);
|
|
34019
|
+
if (bytesEqual(algOid, [43, 101, 110])) {
|
|
34020
|
+
return "X25519";
|
|
34021
|
+
}
|
|
34022
|
+
if (!bytesEqual(algOid, [42, 134, 72, 206, 61, 2, 1])) {
|
|
34023
|
+
throw new Error("Unsupported key algorithm");
|
|
34024
|
+
}
|
|
34025
|
+
expectTag(state, 6, "Expected curve OID");
|
|
34026
|
+
const curveOidLen = parseLength(state);
|
|
34027
|
+
const curveOid = getSubarray(state, curveOidLen);
|
|
34028
|
+
if (bytesEqual(curveOid, [42, 134, 72, 206, 61, 3, 1, 7]))
|
|
34029
|
+
return "P-256";
|
|
34030
|
+
if (bytesEqual(curveOid, [43, 129, 4, 0, 34]))
|
|
34031
|
+
return "P-384";
|
|
34032
|
+
if (bytesEqual(curveOid, [43, 129, 4, 0, 35]))
|
|
34033
|
+
return "P-521";
|
|
34034
|
+
throw new Error("Unsupported named curve");
|
|
34035
|
+
};
|
|
34036
|
+
var genericImport = async (keyFormat, keyData, alg, options) => {
|
|
34037
|
+
const entry = keyAlgorithm(alg, algArgument);
|
|
34038
|
+
if (entry.secret) {
|
|
34039
|
+
unsupportedAlg(algArgument);
|
|
34040
|
+
}
|
|
34041
|
+
const isPublic = keyFormat === "spki";
|
|
34042
|
+
let algorithm;
|
|
34043
|
+
if (entry.resolve) {
|
|
34044
|
+
try {
|
|
34045
|
+
const state = createASN1State(keyData);
|
|
34046
|
+
parseKeyHeader(state, keyFormat);
|
|
34047
|
+
algorithm = entry.resolve({ crv: parseECAlgorithmIdentifier(state) });
|
|
34048
|
+
} catch {
|
|
34049
|
+
throw new JOSENotSupported("Invalid or unsupported key format");
|
|
34050
|
+
}
|
|
34051
|
+
} else {
|
|
34052
|
+
algorithm = entry.subtle;
|
|
34053
|
+
}
|
|
34054
|
+
return crypto.subtle.importKey(keyFormat, keyData, algorithm, options?.extractable ?? isPublic, entry.usages[isPublic ? 0 : 1]);
|
|
34055
|
+
};
|
|
34056
|
+
var processPEMData = (pem, pattern) => {
|
|
34057
|
+
return decodeBase64(pem.replace(pattern, ""));
|
|
34058
|
+
};
|
|
34059
|
+
var fromPKCS8 = (pem, alg, options) => {
|
|
34060
|
+
const keyData = processPEMData(pem, /(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);
|
|
34061
|
+
return genericImport("pkcs8", keyData, alg, options);
|
|
34062
|
+
};
|
|
34063
|
+
|
|
33933
34064
|
// ../../node_modules/.bun/jose@6.2.9/node_modules/jose/dist/webapi/key/export.js
|
|
33934
34065
|
function omitUndefinedProperties(jwk) {
|
|
33935
34066
|
return Object.fromEntries(Object.entries(jwk).filter(([, value]) => value !== undefined));
|
|
@@ -33963,6 +34094,13 @@ async function keyToJWK(key) {
|
|
|
33963
34094
|
function exportJWK(key) {
|
|
33964
34095
|
return keyToJWK(key);
|
|
33965
34096
|
}
|
|
34097
|
+
// ../../node_modules/.bun/jose@6.2.9/node_modules/jose/dist/webapi/key/import.js
|
|
34098
|
+
async function importPKCS8(pkcs8, alg, options) {
|
|
34099
|
+
if (typeof pkcs8 !== "string" || pkcs8.indexOf("-----BEGIN PRIVATE KEY-----") !== 0) {
|
|
34100
|
+
throw new TypeError('"pkcs8" must be PKCS#8 formatted string');
|
|
34101
|
+
}
|
|
34102
|
+
return fromPKCS8(pkcs8, alg, options);
|
|
34103
|
+
}
|
|
33966
34104
|
// ../../node_modules/.bun/jose@6.2.9/node_modules/jose/dist/webapi/key/generate_key_pair.js
|
|
33967
34105
|
function getModulusLengthOption(options) {
|
|
33968
34106
|
const modulusLength = options?.modulusLength ?? 2048;
|
|
@@ -34006,6 +34144,11 @@ async function generateKeyPair(alg, options) {
|
|
|
34006
34144
|
...entry.usages[0]
|
|
34007
34145
|
]);
|
|
34008
34146
|
}
|
|
34147
|
+
// ../broker-client/src/error-text.ts
|
|
34148
|
+
function messageOf(error) {
|
|
34149
|
+
return error instanceof Error ? error.message : String(error);
|
|
34150
|
+
}
|
|
34151
|
+
|
|
34009
34152
|
// ../broker-client/src/dpop.ts
|
|
34010
34153
|
var ALGORITHM = "ES256";
|
|
34011
34154
|
function targetUri(url) {
|
|
@@ -34018,9 +34161,7 @@ async function accessTokenHash(accessToken) {
|
|
|
34018
34161
|
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(accessToken));
|
|
34019
34162
|
return Buffer.from(digest).toString("base64url");
|
|
34020
34163
|
}
|
|
34021
|
-
|
|
34022
|
-
const { privateKey, publicKey } = await generateKeyPair(ALGORITHM, { extractable: false });
|
|
34023
|
-
const publicJwk = await exportJWK(publicKey);
|
|
34164
|
+
function dpopKey(privateKey, publicJwk) {
|
|
34024
34165
|
return {
|
|
34025
34166
|
publicJwk,
|
|
34026
34167
|
async proof(request) {
|
|
@@ -34039,6 +34180,30 @@ async function newDpopKey() {
|
|
|
34039
34180
|
}
|
|
34040
34181
|
};
|
|
34041
34182
|
}
|
|
34183
|
+
async function newDpopKey() {
|
|
34184
|
+
const { privateKey, publicKey } = await generateKeyPair(ALGORITHM, { extractable: false });
|
|
34185
|
+
return dpopKey(privateKey, await exportJWK(publicKey));
|
|
34186
|
+
}
|
|
34187
|
+
async function importDpopKey(pkcs8Pem, name) {
|
|
34188
|
+
const unreadable = (error) => new Error(`read ${name}: ${messageOf(error)}`, { cause: error });
|
|
34189
|
+
let exported;
|
|
34190
|
+
try {
|
|
34191
|
+
exported = createPublicKey(createPrivateKey(pkcs8Pem)).export({ format: "jwk" });
|
|
34192
|
+
} catch (error) {
|
|
34193
|
+
throw unreadable(error);
|
|
34194
|
+
}
|
|
34195
|
+
const { kty, crv, x, y } = exported;
|
|
34196
|
+
if (kty !== "EC" || crv !== "P-256" || typeof x !== "string" || typeof y !== "string") {
|
|
34197
|
+
throw new Error(`${name} is not a P-256 key (${kty} ${crv ?? "with no curve"}), and a DPoP proof is signed ${ALGORITHM}`);
|
|
34198
|
+
}
|
|
34199
|
+
let privateKey;
|
|
34200
|
+
try {
|
|
34201
|
+
privateKey = await importPKCS8(pkcs8Pem, ALGORITHM, { extractable: false });
|
|
34202
|
+
} catch (error) {
|
|
34203
|
+
throw unreadable(error);
|
|
34204
|
+
}
|
|
34205
|
+
return dpopKey(privateKey, { kty, crv, x, y });
|
|
34206
|
+
}
|
|
34042
34207
|
|
|
34043
34208
|
// ../broker-client/src/metadata-identity.ts
|
|
34044
34209
|
import { Agent, request } from "http";
|
|
@@ -34052,6 +34217,7 @@ var FORM_LAUNCHER_CREDENTIAL = "launcher_credential";
|
|
|
34052
34217
|
var FORM_LAUNCHER_CREDENTIAL_DECLINED = "false";
|
|
34053
34218
|
var SUBJECT_TOKEN_TYPE_KUBERNETES = "urn:envoy:params:oauth:token-type:kubernetes-service-account";
|
|
34054
34219
|
var SUBJECT_TOKEN_TYPE_GOOGLE = "urn:envoy:params:oauth:token-type:google-identity";
|
|
34220
|
+
var SUBJECT_TOKEN_TYPE_PERSON = "urn:envoy:params:oauth:token-type:person-google-identity";
|
|
34055
34221
|
var ACTOR_TOKEN_TYPE_MACHINE = "urn:envoy:params:oauth:token-type:machine-google-identity";
|
|
34056
34222
|
var TOKEN_TYPE_DPOP = "DPoP";
|
|
34057
34223
|
|
|
@@ -34113,37 +34279,6 @@ function metadataIdentity(audience, env = process.env) {
|
|
|
34113
34279
|
};
|
|
34114
34280
|
}
|
|
34115
34281
|
|
|
34116
|
-
// ../broker-client/src/projected-token.ts
|
|
34117
|
-
import { readFile } from "fs/promises";
|
|
34118
|
-
function projectedToken(path) {
|
|
34119
|
-
return {
|
|
34120
|
-
async read(signal) {
|
|
34121
|
-
let contents;
|
|
34122
|
-
try {
|
|
34123
|
-
contents = await readFile(path, {
|
|
34124
|
-
encoding: "utf8",
|
|
34125
|
-
...signal === undefined ? {} : { signal }
|
|
34126
|
-
});
|
|
34127
|
-
} catch (error) {
|
|
34128
|
-
throw new Error(`read the projected service-account token ${path}: ${error.message}`);
|
|
34129
|
-
}
|
|
34130
|
-
const token = contents.trim();
|
|
34131
|
-
if (token === "")
|
|
34132
|
-
throw new Error(`the projected service-account token ${path} is empty`);
|
|
34133
|
-
return { token, tokenType: SUBJECT_TOKEN_TYPE_KUBERNETES };
|
|
34134
|
-
},
|
|
34135
|
-
describe: () => `the projected service-account token ${path}`
|
|
34136
|
-
};
|
|
34137
|
-
}
|
|
34138
|
-
|
|
34139
|
-
// ../contracts/src/trailing-slash.ts
|
|
34140
|
-
function withoutTrailingSlashes(url) {
|
|
34141
|
-
let end = url.length;
|
|
34142
|
-
while (end > 0 && url[end - 1] === "/")
|
|
34143
|
-
end -= 1;
|
|
34144
|
-
return url.slice(0, end);
|
|
34145
|
-
}
|
|
34146
|
-
|
|
34147
34282
|
// ../../node_modules/.bun/oauth4webapi@3.8.8/node_modules/oauth4webapi/build/index.js
|
|
34148
34283
|
var USER_AGENT;
|
|
34149
34284
|
if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) {
|
|
@@ -34289,6 +34424,56 @@ function signal(url, value) {
|
|
|
34289
34424
|
}
|
|
34290
34425
|
return;
|
|
34291
34426
|
}
|
|
34427
|
+
function replaceDoubleSlash(pathname) {
|
|
34428
|
+
if (pathname.includes("//")) {
|
|
34429
|
+
return pathname.replace("//", "/");
|
|
34430
|
+
}
|
|
34431
|
+
return pathname;
|
|
34432
|
+
}
|
|
34433
|
+
function prependWellKnown(url, wellKnown, allowTerminatingSlash = false) {
|
|
34434
|
+
if (url.pathname === "/") {
|
|
34435
|
+
url.pathname = wellKnown;
|
|
34436
|
+
} else {
|
|
34437
|
+
url.pathname = replaceDoubleSlash(`${wellKnown}/${allowTerminatingSlash ? url.pathname : url.pathname.replace(/(\/)$/, "")}`);
|
|
34438
|
+
}
|
|
34439
|
+
return url;
|
|
34440
|
+
}
|
|
34441
|
+
function appendWellKnown(url, wellKnown) {
|
|
34442
|
+
url.pathname = replaceDoubleSlash(`${url.pathname}/${wellKnown}`);
|
|
34443
|
+
return url;
|
|
34444
|
+
}
|
|
34445
|
+
async function performDiscovery(input, urlName, transform, options) {
|
|
34446
|
+
if (!(input instanceof URL)) {
|
|
34447
|
+
throw CodedTypeError(`"${urlName}" must be an instance of URL`, ERR_INVALID_ARG_TYPE);
|
|
34448
|
+
}
|
|
34449
|
+
checkProtocol(input, options?.[allowInsecureRequests] !== true);
|
|
34450
|
+
const url = transform(new URL(input.href));
|
|
34451
|
+
const headers = prepareHeaders(options?.headers);
|
|
34452
|
+
headers.set("accept", "application/json");
|
|
34453
|
+
return (options?.[customFetch] || fetch)(url.href, {
|
|
34454
|
+
body: undefined,
|
|
34455
|
+
headers: Object.fromEntries(headers.entries()),
|
|
34456
|
+
method: "GET",
|
|
34457
|
+
redirect: "manual",
|
|
34458
|
+
signal: signal(url, options?.signal)
|
|
34459
|
+
});
|
|
34460
|
+
}
|
|
34461
|
+
async function discoveryRequest(issuerIdentifier, options) {
|
|
34462
|
+
return performDiscovery(issuerIdentifier, "issuerIdentifier", (url) => {
|
|
34463
|
+
switch (options?.algorithm) {
|
|
34464
|
+
case undefined:
|
|
34465
|
+
case "oidc":
|
|
34466
|
+
appendWellKnown(url, ".well-known/openid-configuration");
|
|
34467
|
+
break;
|
|
34468
|
+
case "oauth2":
|
|
34469
|
+
prependWellKnown(url, ".well-known/oauth-authorization-server");
|
|
34470
|
+
break;
|
|
34471
|
+
default:
|
|
34472
|
+
throw CodedTypeError('"options.algorithm" must be "oidc" (default), or "oauth2"', ERR_INVALID_ARG_VALUE);
|
|
34473
|
+
}
|
|
34474
|
+
return url;
|
|
34475
|
+
}, options);
|
|
34476
|
+
}
|
|
34292
34477
|
function assertNumber(input, allow0, it, code, cause) {
|
|
34293
34478
|
try {
|
|
34294
34479
|
if (typeof input !== "number" || !Number.isFinite(input)) {
|
|
@@ -34325,6 +34510,25 @@ function assertString(input, it, code, cause) {
|
|
|
34325
34510
|
throw err;
|
|
34326
34511
|
}
|
|
34327
34512
|
}
|
|
34513
|
+
async function processDiscoveryResponse(expectedIssuerIdentifier, response) {
|
|
34514
|
+
const expected = expectedIssuerIdentifier;
|
|
34515
|
+
if (!(expected instanceof URL) && expected !== _nodiscoverycheck) {
|
|
34516
|
+
throw CodedTypeError('"expectedIssuerIdentifier" must be an instance of URL', ERR_INVALID_ARG_TYPE);
|
|
34517
|
+
}
|
|
34518
|
+
if (!looseInstanceOf(response, Response)) {
|
|
34519
|
+
throw CodedTypeError('"response" must be an instance of Response', ERR_INVALID_ARG_TYPE);
|
|
34520
|
+
}
|
|
34521
|
+
if (response.status !== 200) {
|
|
34522
|
+
throw OPE('"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)', RESPONSE_IS_NOT_CONFORM, response);
|
|
34523
|
+
}
|
|
34524
|
+
assertReadableResponse(response);
|
|
34525
|
+
const json = await getResponseJsonBody(response);
|
|
34526
|
+
assertString(json.issuer, '"response" body "issuer" property', INVALID_RESPONSE, { body: json });
|
|
34527
|
+
if (expected !== _nodiscoverycheck && new URL(json.issuer).href !== expected.href) {
|
|
34528
|
+
throw OPE('"response" body "issuer" property does not match the expected value', JSON_ATTRIBUTE_COMPARISON, { expected: expected.href, body: json, attribute: "issuer" });
|
|
34529
|
+
}
|
|
34530
|
+
return json;
|
|
34531
|
+
}
|
|
34328
34532
|
function assertApplicationJson(response) {
|
|
34329
34533
|
assertContentType(response, "application/json");
|
|
34330
34534
|
}
|
|
@@ -34604,6 +34808,14 @@ async function tokenEndpointRequest(as, client, clientAuthentication, grantType,
|
|
|
34604
34808
|
options?.DPoP?.cacheNonce(response, url);
|
|
34605
34809
|
return response;
|
|
34606
34810
|
}
|
|
34811
|
+
async function refreshTokenGrantRequest(as, client, clientAuthentication, refreshToken, options) {
|
|
34812
|
+
assertAs(as);
|
|
34813
|
+
assertClient(client);
|
|
34814
|
+
assertString(refreshToken, '"refreshToken"');
|
|
34815
|
+
const parameters = new URLSearchParams(options?.additionalParameters);
|
|
34816
|
+
parameters.set("refresh_token", refreshToken);
|
|
34817
|
+
return tokenEndpointRequest(as, client, clientAuthentication, "refresh_token", parameters, options);
|
|
34818
|
+
}
|
|
34607
34819
|
var idTokenClaims = new WeakMap;
|
|
34608
34820
|
var jwtRefs = new WeakMap;
|
|
34609
34821
|
function getValidatedIdTokenClaims(ref) {
|
|
@@ -34681,6 +34893,9 @@ function checkAuthenticationChallenges(response) {
|
|
|
34681
34893
|
throw new WWWAuthenticateChallengeError("server responded with a challenge in the WWW-Authenticate HTTP Header", { cause: challenges, response });
|
|
34682
34894
|
}
|
|
34683
34895
|
}
|
|
34896
|
+
async function processRefreshTokenResponse(as, client, response, options) {
|
|
34897
|
+
return processGenericAccessTokenResponse(as, client, response, undefined, options?.[jweDecrypt], options?.recognizedTokenTypes);
|
|
34898
|
+
}
|
|
34684
34899
|
function validateAudience(expected, result) {
|
|
34685
34900
|
if (Array.isArray(result.claims.aud)) {
|
|
34686
34901
|
if (!result.claims.aud.includes(expected)) {
|
|
@@ -35033,6 +35248,73 @@ function errorHandler(err) {
|
|
|
35033
35248
|
}
|
|
35034
35249
|
throw new ClientError("something went wrong", { cause: err });
|
|
35035
35250
|
}
|
|
35251
|
+
function handleEntraId(server, as, options) {
|
|
35252
|
+
if (server.origin === "https://login.microsoftonline.com" && (!options?.algorithm || options.algorithm === "oidc")) {
|
|
35253
|
+
as[kEntraId] = true;
|
|
35254
|
+
return true;
|
|
35255
|
+
}
|
|
35256
|
+
return false;
|
|
35257
|
+
}
|
|
35258
|
+
function handleB2Clogin(server, options) {
|
|
35259
|
+
if (server.hostname.endsWith(".b2clogin.com") && (!options?.algorithm || options.algorithm === "oidc")) {
|
|
35260
|
+
return true;
|
|
35261
|
+
}
|
|
35262
|
+
return false;
|
|
35263
|
+
}
|
|
35264
|
+
async function discovery(server, clientId, metadata, clientAuthentication, options) {
|
|
35265
|
+
const as = await performDiscovery2(server, options);
|
|
35266
|
+
const instance = new Configuration(as, clientId, metadata, clientAuthentication);
|
|
35267
|
+
let internals = int2(instance);
|
|
35268
|
+
if (options?.[customFetch2]) {
|
|
35269
|
+
internals.fetch = options[customFetch2];
|
|
35270
|
+
}
|
|
35271
|
+
if (options?.timeout) {
|
|
35272
|
+
internals.timeout = options.timeout;
|
|
35273
|
+
}
|
|
35274
|
+
if (options?.execute) {
|
|
35275
|
+
for (const extension of options.execute) {
|
|
35276
|
+
extension(instance);
|
|
35277
|
+
}
|
|
35278
|
+
}
|
|
35279
|
+
return instance;
|
|
35280
|
+
}
|
|
35281
|
+
async function performDiscovery2(server, options) {
|
|
35282
|
+
if (!(server instanceof URL)) {
|
|
35283
|
+
throw CodedTypeError2('"server" must be an instance of URL', ERR_INVALID_ARG_TYPE2);
|
|
35284
|
+
}
|
|
35285
|
+
const resolve = !server.href.includes("/.well-known/");
|
|
35286
|
+
const timeout = options?.timeout ?? 30;
|
|
35287
|
+
const signal = AbortSignal.timeout(timeout * 1000);
|
|
35288
|
+
const as = await (resolve ? discoveryRequest(server, {
|
|
35289
|
+
algorithm: options?.algorithm,
|
|
35290
|
+
[customFetch]: options?.[customFetch2],
|
|
35291
|
+
[allowInsecureRequests]: options?.execute?.includes(allowInsecureRequests2),
|
|
35292
|
+
signal,
|
|
35293
|
+
headers: new Headers(headers)
|
|
35294
|
+
}) : (options?.[customFetch2] || fetch)((() => {
|
|
35295
|
+
checkProtocol(server, options?.execute?.includes(allowInsecureRequests2) ? false : true);
|
|
35296
|
+
return server.href;
|
|
35297
|
+
})(), {
|
|
35298
|
+
headers: Object.fromEntries(new Headers({ accept: "application/json", ...headers }).entries()),
|
|
35299
|
+
body: undefined,
|
|
35300
|
+
method: "GET",
|
|
35301
|
+
redirect: "manual",
|
|
35302
|
+
signal
|
|
35303
|
+
})).then((response) => processDiscoveryResponse(_nodiscoverycheck, response)).catch(errorHandler);
|
|
35304
|
+
if (resolve && new URL(as.issuer).href !== server.href) {
|
|
35305
|
+
handleEntraId(server, as, options) || handleB2Clogin(server, options) || (() => {
|
|
35306
|
+
throw new ClientError("discovered metadata issuer does not match the expected issuer", {
|
|
35307
|
+
code: JSON_ATTRIBUTE_COMPARISON,
|
|
35308
|
+
cause: {
|
|
35309
|
+
expected: server.href,
|
|
35310
|
+
body: as,
|
|
35311
|
+
attribute: "issuer"
|
|
35312
|
+
}
|
|
35313
|
+
});
|
|
35314
|
+
})();
|
|
35315
|
+
}
|
|
35316
|
+
return as;
|
|
35317
|
+
}
|
|
35036
35318
|
function getServerHelpers(metadata) {
|
|
35037
35319
|
return {
|
|
35038
35320
|
supportsPKCE: {
|
|
@@ -35149,6 +35431,37 @@ function addHelpers(response) {
|
|
|
35149
35431
|
function allowInsecureRequests2(config) {
|
|
35150
35432
|
int2(config).tlsOnly = false;
|
|
35151
35433
|
}
|
|
35434
|
+
async function refreshTokenGrant(config, refreshToken, parameters, options) {
|
|
35435
|
+
checkConfig(config);
|
|
35436
|
+
parameters = new URLSearchParams(parameters);
|
|
35437
|
+
const { as, c, auth, fetch: fetch2, tlsOnly, nonRepudiation, timeout, decrypt } = int2(config);
|
|
35438
|
+
const response = await refreshTokenGrantRequest(as, c, auth, refreshToken, {
|
|
35439
|
+
[customFetch]: fetch2,
|
|
35440
|
+
[allowInsecureRequests]: !tlsOnly,
|
|
35441
|
+
additionalParameters: parameters,
|
|
35442
|
+
DPoP: options?.DPoP,
|
|
35443
|
+
headers: new Headers(headers),
|
|
35444
|
+
signal: signal2(timeout)
|
|
35445
|
+
}).catch(errorHandler);
|
|
35446
|
+
const p = processRefreshTokenResponse(as, c, response, {
|
|
35447
|
+
[jweDecrypt]: decrypt
|
|
35448
|
+
});
|
|
35449
|
+
let result;
|
|
35450
|
+
try {
|
|
35451
|
+
result = await p;
|
|
35452
|
+
} catch (err) {
|
|
35453
|
+
if (retryable(err, options)) {
|
|
35454
|
+
return refreshTokenGrant(config, refreshToken, parameters, {
|
|
35455
|
+
...options,
|
|
35456
|
+
flag: retry
|
|
35457
|
+
});
|
|
35458
|
+
}
|
|
35459
|
+
errorHandler(err);
|
|
35460
|
+
}
|
|
35461
|
+
result.id_token && await nonRepudiation?.(response);
|
|
35462
|
+
addHelpers(result);
|
|
35463
|
+
return result;
|
|
35464
|
+
}
|
|
35152
35465
|
function checkConfig(input) {
|
|
35153
35466
|
if (!(input instanceof Configuration)) {
|
|
35154
35467
|
throw CodedTypeError2('"config" must be an instance of Configuration', ERR_INVALID_ARG_TYPE2);
|
|
@@ -35202,6 +35515,146 @@ async function genericGrantRequest(config, grantType, parameters, options) {
|
|
|
35202
35515
|
return result;
|
|
35203
35516
|
}
|
|
35204
35517
|
|
|
35518
|
+
// ../broker-client/src/signins.ts
|
|
35519
|
+
import { readdir, readFile } from "fs/promises";
|
|
35520
|
+
import { join as join2 } from "path";
|
|
35521
|
+
|
|
35522
|
+
// ../contracts/src/trailing-slash.ts
|
|
35523
|
+
function withoutTrailingSlashes(url) {
|
|
35524
|
+
let end = url.length;
|
|
35525
|
+
while (end > 0 && url[end - 1] === "/")
|
|
35526
|
+
end -= 1;
|
|
35527
|
+
return url.slice(0, end);
|
|
35528
|
+
}
|
|
35529
|
+
|
|
35530
|
+
// ../broker-client/src/signins.ts
|
|
35531
|
+
var SIGNIN_DIR_VAR = "AGENT_SECRETS_SIGNIN_DIR";
|
|
35532
|
+
var PERSON_VAR = "AGENT_SECRETS_PERSON";
|
|
35533
|
+
var PERSON_TRADE_VAR = "PERSON_SIGNIN_TRADE";
|
|
35534
|
+
var SIGNIN_ISSUER_VAR = "AGENT_SECRETS_SIGNIN_ISSUER";
|
|
35535
|
+
var SIGNIN_CLIENT_ID_VAR = "AGENT_SECRETS_SIGNIN_CLIENT_ID";
|
|
35536
|
+
var SIGNIN_CLIENT_SECRET_FILE_VAR = "AGENT_SECRETS_SIGNIN_CLIENT_SECRET_FILE";
|
|
35537
|
+
var DEFAULT_SIGNIN_ISSUER = "https://accounts.google.com";
|
|
35538
|
+
var SIGNIN_COMMAND = "agent-secrets login";
|
|
35539
|
+
var SIGNINS_DIR = "signins";
|
|
35540
|
+
var RECORD_MEMBERS = [
|
|
35541
|
+
"person",
|
|
35542
|
+
"issuer",
|
|
35543
|
+
"client_id",
|
|
35544
|
+
"refresh_token",
|
|
35545
|
+
"box_key",
|
|
35546
|
+
"thumbprint",
|
|
35547
|
+
"enrollment_id",
|
|
35548
|
+
"signed_in_at"
|
|
35549
|
+
];
|
|
35550
|
+
function signInDirectory(env) {
|
|
35551
|
+
const named = env[SIGNIN_DIR_VAR] ?? "";
|
|
35552
|
+
if (named !== "")
|
|
35553
|
+
return named;
|
|
35554
|
+
const state = env.XDG_STATE_HOME ?? "";
|
|
35555
|
+
const base = state !== "" ? state : join2(env.HOME ?? "", ".local", "state");
|
|
35556
|
+
return join2(base, "agent-secrets", SIGNINS_DIR);
|
|
35557
|
+
}
|
|
35558
|
+
async function readSignIn(path) {
|
|
35559
|
+
let text;
|
|
35560
|
+
try {
|
|
35561
|
+
text = await readFile(path, "utf8");
|
|
35562
|
+
} catch (error) {
|
|
35563
|
+
throw new Error(`read the sign-in at ${path}: ${messageOf(error)}`, { cause: error });
|
|
35564
|
+
}
|
|
35565
|
+
let parsed;
|
|
35566
|
+
try {
|
|
35567
|
+
parsed = JSON.parse(text);
|
|
35568
|
+
} catch {
|
|
35569
|
+
throw new Error(`read the sign-in at ${path}: it is not JSON; run: ${SIGNIN_COMMAND}`);
|
|
35570
|
+
}
|
|
35571
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
35572
|
+
throw new Error(`read the sign-in at ${path}: it holds no JSON object; run: ${SIGNIN_COMMAND}`);
|
|
35573
|
+
}
|
|
35574
|
+
const fields = parsed;
|
|
35575
|
+
const record = {};
|
|
35576
|
+
for (const member of RECORD_MEMBERS) {
|
|
35577
|
+
const given = fields[member] ?? "";
|
|
35578
|
+
if (typeof given !== "string") {
|
|
35579
|
+
throw new Error(`read the sign-in at ${path}: its ${member} is not a string; run: ${SIGNIN_COMMAND}`);
|
|
35580
|
+
}
|
|
35581
|
+
record[member] = given;
|
|
35582
|
+
}
|
|
35583
|
+
const read = record;
|
|
35584
|
+
if (read.person === "" || read.refresh_token === "" || read.box_key === "") {
|
|
35585
|
+
throw new Error(`the sign-in at ${path} names no person, no refresh token or no box key; run: ${SIGNIN_COMMAND}`);
|
|
35586
|
+
}
|
|
35587
|
+
return read;
|
|
35588
|
+
}
|
|
35589
|
+
async function listSignIns(dir) {
|
|
35590
|
+
let entries;
|
|
35591
|
+
try {
|
|
35592
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
35593
|
+
} catch (error) {
|
|
35594
|
+
if (error.code === "ENOENT")
|
|
35595
|
+
return [];
|
|
35596
|
+
throw new Error(`read this machine's sign-ins: ${messageOf(error)}`, { cause: error });
|
|
35597
|
+
}
|
|
35598
|
+
const names = entries.filter((entry) => !entry.isDirectory() && entry.name.endsWith(".json")).map((entry) => entry.name).sort();
|
|
35599
|
+
const records = [];
|
|
35600
|
+
for (const name of names)
|
|
35601
|
+
records.push(await readSignIn(join2(dir, name)));
|
|
35602
|
+
return records.sort((a, b) => a.person < b.person ? -1 : a.person > b.person ? 1 : 0);
|
|
35603
|
+
}
|
|
35604
|
+
function namesOf(records) {
|
|
35605
|
+
return records.map((record) => record.person).join(", ");
|
|
35606
|
+
}
|
|
35607
|
+
function personTradeOff(env) {
|
|
35608
|
+
const written = (env[PERSON_TRADE_VAR] ?? "").trim();
|
|
35609
|
+
if (written === "")
|
|
35610
|
+
return false;
|
|
35611
|
+
if (written === "off")
|
|
35612
|
+
return true;
|
|
35613
|
+
throw new Error(`${PERSON_TRADE_VAR} is "${written}" and takes off or nothing: set it to off where this process's own credentials trade this machine and never a person signed in on it, and leave it unset where they trade the person signed in here`);
|
|
35614
|
+
}
|
|
35615
|
+
async function chooseSignIn(env) {
|
|
35616
|
+
if (personTradeOff(env))
|
|
35617
|
+
return;
|
|
35618
|
+
const records = await listSignIns(signInDirectory(env));
|
|
35619
|
+
const person = (env[PERSON_VAR] ?? "").trim().toLowerCase();
|
|
35620
|
+
if (records.length === 0)
|
|
35621
|
+
return;
|
|
35622
|
+
if (person !== "") {
|
|
35623
|
+
const named = records.find((record) => record.person.toLowerCase() === person);
|
|
35624
|
+
if (named !== undefined)
|
|
35625
|
+
return named;
|
|
35626
|
+
throw new Error(`${PERSON_VAR} names ${person}, who is not signed in on this machine; signed in here: ${namesOf(records)}; run: ${SIGNIN_COMMAND}`);
|
|
35627
|
+
}
|
|
35628
|
+
if (records.length === 1)
|
|
35629
|
+
return records[0];
|
|
35630
|
+
throw new Error(`${records.length} people are signed in on this machine (${namesOf(records)}), so this session must say which one it acts for: set ${PERSON_VAR} to one of them`);
|
|
35631
|
+
}
|
|
35632
|
+
function signInSessionName(record) {
|
|
35633
|
+
const name = `signin-${record.person}`;
|
|
35634
|
+
return record.thumbprint === "" ? name : `${name}-${record.thumbprint.slice(0, 12)}`;
|
|
35635
|
+
}
|
|
35636
|
+
async function signInFlow(env) {
|
|
35637
|
+
const clientId = (env[SIGNIN_CLIENT_ID_VAR] ?? "").trim();
|
|
35638
|
+
const secretFile = (env[SIGNIN_CLIENT_SECRET_FILE_VAR] ?? "").trim();
|
|
35639
|
+
if (clientId === "" && secretFile === "")
|
|
35640
|
+
return;
|
|
35641
|
+
if (clientId === "" || secretFile === "") {
|
|
35642
|
+
throw new Error(`a person's sign-in needs both ${SIGNIN_CLIENT_ID_VAR} and ${SIGNIN_CLIENT_SECRET_FILE_VAR}; this machine has one of them`);
|
|
35643
|
+
}
|
|
35644
|
+
let secret;
|
|
35645
|
+
try {
|
|
35646
|
+
secret = await readFile(secretFile, "utf8");
|
|
35647
|
+
} catch (error) {
|
|
35648
|
+
throw new Error(`read the sign-in client's secret (${SIGNIN_CLIENT_SECRET_FILE_VAR}): ${messageOf(error)}`, { cause: error });
|
|
35649
|
+
}
|
|
35650
|
+
const issuer = (env[SIGNIN_ISSUER_VAR] ?? "").trim();
|
|
35651
|
+
return {
|
|
35652
|
+
issuer: withoutTrailingSlashes(issuer === "" ? DEFAULT_SIGNIN_ISSUER : issuer),
|
|
35653
|
+
clientId,
|
|
35654
|
+
clientSecret: secret.trim()
|
|
35655
|
+
};
|
|
35656
|
+
}
|
|
35657
|
+
|
|
35205
35658
|
// ../broker-client/src/token-client.ts
|
|
35206
35659
|
var DEFAULT_RENEW_BEFORE_MS = 5 * 60000;
|
|
35207
35660
|
var TOO_MANY_REQUESTS = 429;
|
|
@@ -35212,8 +35665,8 @@ class BrokerRefusedError extends Error {
|
|
|
35212
35665
|
status;
|
|
35213
35666
|
code;
|
|
35214
35667
|
description;
|
|
35215
|
-
constructor(status, code, description) {
|
|
35216
|
-
super(description === "" ? `the secrets broker refused
|
|
35668
|
+
constructor(status, code, description, refused) {
|
|
35669
|
+
super(description === "" ? `the secrets broker refused ${refused}: HTTP ${status} ${code}` : `the secrets broker refused ${refused}: HTTP ${status} ${code}: ${description}`);
|
|
35217
35670
|
this.status = status;
|
|
35218
35671
|
this.code = code;
|
|
35219
35672
|
this.description = description;
|
|
@@ -35223,6 +35676,20 @@ class BrokerRefusedError extends Error {
|
|
|
35223
35676
|
return this.status !== TOO_MANY_REQUESTS && this.code !== INVALID_DPOP_PROOF && this.code !== USE_DPOP_NONCE;
|
|
35224
35677
|
}
|
|
35225
35678
|
}
|
|
35679
|
+
|
|
35680
|
+
class SignInEndedError extends Error {
|
|
35681
|
+
issuer;
|
|
35682
|
+
person;
|
|
35683
|
+
constructor(issuer, person, options) {
|
|
35684
|
+
super(`${issuer} no longer honours ${person}'s sign-in on this machine; run: ${SIGNIN_COMMAND}`, options);
|
|
35685
|
+
this.issuer = issuer;
|
|
35686
|
+
this.person = person;
|
|
35687
|
+
this.name = "SignInEndedError";
|
|
35688
|
+
}
|
|
35689
|
+
}
|
|
35690
|
+
function isFinalRefusal(error) {
|
|
35691
|
+
return error instanceof BrokerRefusedError && error.permanent || error instanceof SignInEndedError;
|
|
35692
|
+
}
|
|
35226
35693
|
function statusOf(error) {
|
|
35227
35694
|
let cause = error;
|
|
35228
35695
|
for (let depth = 0;depth < 4; depth += 1) {
|
|
@@ -35234,6 +35701,16 @@ function statusOf(error) {
|
|
|
35234
35701
|
}
|
|
35235
35702
|
return 0;
|
|
35236
35703
|
}
|
|
35704
|
+
function requestInit(options, signal, headers) {
|
|
35705
|
+
const signals = [options.signal, signal].filter((one) => one !== undefined);
|
|
35706
|
+
return {
|
|
35707
|
+
method: options.method,
|
|
35708
|
+
headers,
|
|
35709
|
+
body: options.body,
|
|
35710
|
+
redirect: options.redirect,
|
|
35711
|
+
...signals.length === 0 ? {} : { signal: AbortSignal.any(signals) }
|
|
35712
|
+
};
|
|
35713
|
+
}
|
|
35237
35714
|
|
|
35238
35715
|
class BrokerTokenClient {
|
|
35239
35716
|
#brokerUrl;
|
|
@@ -35282,6 +35759,9 @@ class BrokerTokenClient {
|
|
|
35282
35759
|
this.#trading = null;
|
|
35283
35760
|
}
|
|
35284
35761
|
}
|
|
35762
|
+
drop() {
|
|
35763
|
+
this.#held = null;
|
|
35764
|
+
}
|
|
35285
35765
|
async#renew(signal) {
|
|
35286
35766
|
try {
|
|
35287
35767
|
const token = await this.#trade(signal);
|
|
@@ -35289,7 +35769,7 @@ class BrokerTokenClient {
|
|
|
35289
35769
|
return token;
|
|
35290
35770
|
} catch (error) {
|
|
35291
35771
|
const held = this.#held;
|
|
35292
|
-
if (!(error
|
|
35772
|
+
if (!isFinalRefusal(error) && held !== null && this.#now() < held.expiresAt.getTime()) {
|
|
35293
35773
|
return held;
|
|
35294
35774
|
}
|
|
35295
35775
|
this.#held = null;
|
|
@@ -35312,8 +35792,9 @@ class BrokerTokenClient {
|
|
|
35312
35792
|
try {
|
|
35313
35793
|
actor = await this.#actor.read(signal);
|
|
35314
35794
|
} catch (error) {
|
|
35315
|
-
|
|
35316
|
-
|
|
35795
|
+
throw new Error(`read the machine this person signed in on: ${messageOf(error)}`, {
|
|
35796
|
+
cause: error
|
|
35797
|
+
});
|
|
35317
35798
|
}
|
|
35318
35799
|
form["actor_token"] = actor.token;
|
|
35319
35800
|
form["actor_token_type"] = actor.tokenType === SUBJECT_TOKEN_TYPE_GOOGLE ? ACTOR_TOKEN_TYPE_MACHINE : actor.tokenType;
|
|
@@ -35333,10 +35814,10 @@ class BrokerTokenClient {
|
|
|
35333
35814
|
}
|
|
35334
35815
|
#refusal(endpoint, error) {
|
|
35335
35816
|
if (error instanceof ResponseBodyError && error.status >= 400 && error.status < 500) {
|
|
35336
|
-
return new BrokerRefusedError(error.status, error.error, error.error_description ?? "");
|
|
35817
|
+
return new BrokerRefusedError(error.status, error.error, error.error_description ?? "", this.#subject.describe());
|
|
35337
35818
|
}
|
|
35338
35819
|
const status = statusOf(error);
|
|
35339
|
-
const message =
|
|
35820
|
+
const message = messageOf(error);
|
|
35340
35821
|
const said = status === 0 ? message : `HTTP ${status}: ${message}`;
|
|
35341
35822
|
return new Error(`trade ${this.#subject.describe()} at ${endpoint}: ${said}`, {
|
|
35342
35823
|
cause: error
|
|
@@ -35346,15 +35827,7 @@ class BrokerTokenClient {
|
|
|
35346
35827
|
const send = async () => {
|
|
35347
35828
|
const headers = new Headers(options.headers);
|
|
35348
35829
|
headers.set("DPoP", await this.#key.proof({ method: options.method, url, nonce: this.#nonce }));
|
|
35349
|
-
|
|
35350
|
-
const body = options.body;
|
|
35351
|
-
return await this.#fetch(url, {
|
|
35352
|
-
method: options.method,
|
|
35353
|
-
headers,
|
|
35354
|
-
body,
|
|
35355
|
-
redirect: options.redirect,
|
|
35356
|
-
...signals.length === 0 ? {} : { signal: AbortSignal.any(signals) }
|
|
35357
|
-
});
|
|
35830
|
+
return await this.#fetch(url, requestInit(options, signal, headers));
|
|
35358
35831
|
};
|
|
35359
35832
|
let answer = await send();
|
|
35360
35833
|
const given = answer.headers.get("DPoP-Nonce") ?? "";
|
|
@@ -35402,15 +35875,241 @@ class BrokerTokenClient {
|
|
|
35402
35875
|
}
|
|
35403
35876
|
}
|
|
35404
35877
|
|
|
35878
|
+
// ../broker-client/src/person-identity.ts
|
|
35879
|
+
var ISSUER_TIMEOUT_SECONDS = 30;
|
|
35880
|
+
var INVALID_GRANT = "invalid_grant";
|
|
35881
|
+
function issuerSaid(error) {
|
|
35882
|
+
if (error instanceof ResponseBodyError) {
|
|
35883
|
+
const description = error.error_description ?? "";
|
|
35884
|
+
return `HTTP ${error.status} ${error.error}${description === "" ? "" : `: ${description}`}`;
|
|
35885
|
+
}
|
|
35886
|
+
let message = messageOf(error);
|
|
35887
|
+
const cause = error instanceof Error ? error.cause : undefined;
|
|
35888
|
+
if (cause instanceof Error && cause.message !== message)
|
|
35889
|
+
message += `: ${cause.message}`;
|
|
35890
|
+
const status = statusOf(error);
|
|
35891
|
+
return status === 0 ? message : `HTTP ${status}: ${message}`;
|
|
35892
|
+
}
|
|
35893
|
+
function personIdentity(record, flow, options = {}) {
|
|
35894
|
+
const { person, refresh_token: refreshToken, client_id: clientId } = record;
|
|
35895
|
+
if (clientId !== "" && clientId !== flow.clientId) {
|
|
35896
|
+
throw new Error(`${person} signed in with another client than this machine now has (${clientId}), so their sign-in cannot be renewed; run: ${SIGNIN_COMMAND}`);
|
|
35897
|
+
}
|
|
35898
|
+
const send = options.fetch ?? fetch;
|
|
35899
|
+
const insecure = flow.issuer.startsWith("http:");
|
|
35900
|
+
let discovered = null;
|
|
35901
|
+
const through = (signal) => (url, init) => send(url, requestInit(init, signal, init.headers));
|
|
35902
|
+
const discover = async (signal) => {
|
|
35903
|
+
try {
|
|
35904
|
+
const config = await discovery(new URL(flow.issuer), flow.clientId, undefined, undefined, {
|
|
35905
|
+
[customFetch2]: through(signal),
|
|
35906
|
+
timeout: ISSUER_TIMEOUT_SECONDS,
|
|
35907
|
+
...insecure ? { execute: [allowInsecureRequests2] } : {}
|
|
35908
|
+
});
|
|
35909
|
+
return config.serverMetadata();
|
|
35910
|
+
} catch (error) {
|
|
35911
|
+
throw new Error(`read the sign-in issuer ${flow.issuer}: ${issuerSaid(error)}`, {
|
|
35912
|
+
cause: error
|
|
35913
|
+
});
|
|
35914
|
+
}
|
|
35915
|
+
};
|
|
35916
|
+
return {
|
|
35917
|
+
async read(signal) {
|
|
35918
|
+
discovered ??= discover(signal);
|
|
35919
|
+
const discovering = discovered;
|
|
35920
|
+
let metadata;
|
|
35921
|
+
try {
|
|
35922
|
+
metadata = await discovering;
|
|
35923
|
+
} catch (error) {
|
|
35924
|
+
if (discovered === discovering)
|
|
35925
|
+
discovered = null;
|
|
35926
|
+
throw error;
|
|
35927
|
+
}
|
|
35928
|
+
let answered;
|
|
35929
|
+
try {
|
|
35930
|
+
const config = new Configuration(metadata, flow.clientId, undefined, ClientSecretPost2(flow.clientSecret));
|
|
35931
|
+
if (insecure)
|
|
35932
|
+
allowInsecureRequests2(config);
|
|
35933
|
+
config.timeout = ISSUER_TIMEOUT_SECONDS;
|
|
35934
|
+
config[customFetch2] = through(signal);
|
|
35935
|
+
answered = await refreshTokenGrant(config, refreshToken);
|
|
35936
|
+
} catch (error) {
|
|
35937
|
+
if (error instanceof ResponseBodyError && error.error === INVALID_GRANT) {
|
|
35938
|
+
throw new SignInEndedError(flow.issuer, person, { cause: error });
|
|
35939
|
+
}
|
|
35940
|
+
throw new Error(`renew ${person}'s sign-in at ${flow.issuer}: ${issuerSaid(error)}`);
|
|
35941
|
+
}
|
|
35942
|
+
const idToken = answered.id_token ?? "";
|
|
35943
|
+
if (idToken === "") {
|
|
35944
|
+
throw new Error(`${flow.issuer} answered no id_token: the sign-in asked for the "openid" scope and must be answered one`);
|
|
35945
|
+
}
|
|
35946
|
+
return { token: idToken, tokenType: SUBJECT_TOKEN_TYPE_PERSON };
|
|
35947
|
+
},
|
|
35948
|
+
describe: () => `${person}'s sign-in on this machine`
|
|
35949
|
+
};
|
|
35950
|
+
}
|
|
35951
|
+
|
|
35952
|
+
// ../broker-client/src/pool-identity.ts
|
|
35953
|
+
var DEFAULT_SECURITY_TOKEN_SERVICE_URL = "https://sts.googleapis.com/v1/token";
|
|
35954
|
+
var DEFAULT_IAM_CREDENTIALS_URL = "https://iamcredentials.googleapis.com";
|
|
35955
|
+
var REQUESTED_TOKEN_TYPE = "urn:ietf:params:oauth:token-type:access_token";
|
|
35956
|
+
var SCOPE = "https://www.googleapis.com/auth/cloud-platform";
|
|
35957
|
+
var SUBJECT_TOKEN_TYPE_JWT = "urn:ietf:params:oauth:token-type:jwt";
|
|
35958
|
+
var POOL_TIMEOUT_MS = 20000;
|
|
35959
|
+
var MAX_ANSWER_BYTES2 = 1 << 20;
|
|
35960
|
+
function poolSubjectTokenType(brokerType) {
|
|
35961
|
+
return brokerType === SUBJECT_TOKEN_TYPE_KUBERNETES ? SUBJECT_TOKEN_TYPE_JWT : brokerType;
|
|
35962
|
+
}
|
|
35963
|
+
function pathEscape(segment) {
|
|
35964
|
+
return encodeURIComponent(segment).replace(/[!'()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%(?:24|26|2B|3A|3D|40)/g, decodeURIComponent);
|
|
35965
|
+
}
|
|
35966
|
+
async function answerText(answer) {
|
|
35967
|
+
const reader = answer.body?.getReader();
|
|
35968
|
+
if (reader === undefined)
|
|
35969
|
+
return "";
|
|
35970
|
+
const chunks = [];
|
|
35971
|
+
let read = 0;
|
|
35972
|
+
while (read < MAX_ANSWER_BYTES2) {
|
|
35973
|
+
const { done, value } = await reader.read();
|
|
35974
|
+
if (done)
|
|
35975
|
+
break;
|
|
35976
|
+
const kept = value.subarray(0, MAX_ANSWER_BYTES2 - read);
|
|
35977
|
+
chunks.push(kept);
|
|
35978
|
+
read += kept.length;
|
|
35979
|
+
}
|
|
35980
|
+
await reader.cancel().catch(() => {
|
|
35981
|
+
return;
|
|
35982
|
+
});
|
|
35983
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
35984
|
+
}
|
|
35985
|
+
function poolIdentity(options) {
|
|
35986
|
+
const securityTokenService = options.securityTokenServiceUrl ?? DEFAULT_SECURITY_TOKEN_SERVICE_URL;
|
|
35987
|
+
const iamCredentials = (options.iamCredentialsUrl ?? DEFAULT_IAM_CREDENTIALS_URL).replace(/\/$/, "");
|
|
35988
|
+
const account = pathEscape(options.serviceAccount);
|
|
35989
|
+
const mintEndpoint = `${iamCredentials}/v1/projects/-/serviceAccounts/${account}:generateIdToken`;
|
|
35990
|
+
const call = async (endpoint, bearer, body, member, signal) => {
|
|
35991
|
+
const signals = [AbortSignal.timeout(POOL_TIMEOUT_MS), signal].filter((one) => one !== undefined);
|
|
35992
|
+
const answer = await fetch(endpoint, {
|
|
35993
|
+
method: "POST",
|
|
35994
|
+
headers: {
|
|
35995
|
+
"Content-Type": "application/json",
|
|
35996
|
+
...bearer === "" ? {} : { Authorization: `Bearer ${bearer}` }
|
|
35997
|
+
},
|
|
35998
|
+
body: JSON.stringify(body),
|
|
35999
|
+
signal: AbortSignal.any(signals)
|
|
36000
|
+
});
|
|
36001
|
+
const text = await answerText(answer);
|
|
36002
|
+
if (answer.status < 200 || answer.status > 299) {
|
|
36003
|
+
throw new Error(`HTTP ${answer.status}: ${text.trim()}`);
|
|
36004
|
+
}
|
|
36005
|
+
let parsed;
|
|
36006
|
+
try {
|
|
36007
|
+
parsed = JSON.parse(text);
|
|
36008
|
+
} catch {
|
|
36009
|
+
throw new Error(`HTTP ${answer.status}: the answer is not JSON`);
|
|
36010
|
+
}
|
|
36011
|
+
const value = typeof parsed === "object" && parsed !== null ? parsed[member] : undefined;
|
|
36012
|
+
return typeof value === "string" ? value : "";
|
|
36013
|
+
};
|
|
36014
|
+
const federate = async (subject, signal) => {
|
|
36015
|
+
let federated;
|
|
36016
|
+
try {
|
|
36017
|
+
federated = await call(securityTokenService, "", {
|
|
36018
|
+
audience: options.audience,
|
|
36019
|
+
grantType: GRANT_TYPE_TOKEN_EXCHANGE,
|
|
36020
|
+
requestedTokenType: REQUESTED_TOKEN_TYPE,
|
|
36021
|
+
scope: SCOPE,
|
|
36022
|
+
subjectTokenType: poolSubjectTokenType(subject.tokenType),
|
|
36023
|
+
subjectToken: subject.token
|
|
36024
|
+
}, "access_token", signal);
|
|
36025
|
+
} catch (error) {
|
|
36026
|
+
throw new Error(`trade this machine's credential at the security token service ${securityTokenService}: ${messageOf(error)}`, { cause: error });
|
|
36027
|
+
}
|
|
36028
|
+
if (federated === "") {
|
|
36029
|
+
throw new Error(`the security token service ${securityTokenService} answered no access_token`);
|
|
36030
|
+
}
|
|
36031
|
+
return federated;
|
|
36032
|
+
};
|
|
36033
|
+
const generateIdToken = async (federated, signal) => {
|
|
36034
|
+
let token;
|
|
36035
|
+
try {
|
|
36036
|
+
token = await call(mintEndpoint, federated, { audience: options.tokenAudience, includeEmail: true }, "token", signal);
|
|
36037
|
+
} catch (error) {
|
|
36038
|
+
throw new Error(`mint this machine's identity token at ${mintEndpoint}: ${messageOf(error)}`, { cause: error });
|
|
36039
|
+
}
|
|
36040
|
+
if (token === "")
|
|
36041
|
+
throw new Error(`generateIdToken at ${mintEndpoint} answered no token`);
|
|
36042
|
+
return token;
|
|
36043
|
+
};
|
|
36044
|
+
return {
|
|
36045
|
+
async read(signal) {
|
|
36046
|
+
let subject;
|
|
36047
|
+
try {
|
|
36048
|
+
subject = await options.subject.read(signal);
|
|
36049
|
+
} catch (error) {
|
|
36050
|
+
throw new Error(`read the credential the workload identity pool federates: ${messageOf(error)}`, { cause: error });
|
|
36051
|
+
}
|
|
36052
|
+
const federated = await federate(subject, signal);
|
|
36053
|
+
return {
|
|
36054
|
+
token: await generateIdToken(federated, signal),
|
|
36055
|
+
tokenType: SUBJECT_TOKEN_TYPE_GOOGLE
|
|
36056
|
+
};
|
|
36057
|
+
},
|
|
36058
|
+
describe: () => `a Google identity token for ${options.tokenAudience} minted through the workload identity pool ${options.audience} as ${options.serviceAccount}`
|
|
36059
|
+
};
|
|
36060
|
+
}
|
|
36061
|
+
|
|
36062
|
+
// ../broker-client/src/projected-token.ts
|
|
36063
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
36064
|
+
function projectedToken(path) {
|
|
36065
|
+
return {
|
|
36066
|
+
async read(signal) {
|
|
36067
|
+
let contents;
|
|
36068
|
+
try {
|
|
36069
|
+
contents = await readFile2(path, {
|
|
36070
|
+
encoding: "utf8",
|
|
36071
|
+
...signal === undefined ? {} : { signal }
|
|
36072
|
+
});
|
|
36073
|
+
} catch (error) {
|
|
36074
|
+
throw new Error(`read the projected service-account token ${path}: ${error.message}`);
|
|
36075
|
+
}
|
|
36076
|
+
const token = contents.trim();
|
|
36077
|
+
if (token === "")
|
|
36078
|
+
throw new Error(`the projected service-account token ${path} is empty`);
|
|
36079
|
+
return { token, tokenType: SUBJECT_TOKEN_TYPE_KUBERNETES };
|
|
36080
|
+
},
|
|
36081
|
+
describe: () => `the projected service-account token ${path}`
|
|
36082
|
+
};
|
|
36083
|
+
}
|
|
36084
|
+
|
|
35405
36085
|
// ../broker-client/src/environment.ts
|
|
35406
36086
|
var BROKER_URL_VAR = "AGENT_SECRETS_URL";
|
|
35407
36087
|
var IDENTITY_VAR = "AGENT_SECRETS_MACHINE_IDENTITY";
|
|
35408
36088
|
var MACHINE_TOKEN_FILE_VAR = "AGENT_SECRETS_MACHINE_TOKEN_FILE";
|
|
35409
36089
|
var MACHINE_AUDIENCE_VAR = "AGENT_SECRETS_MACHINE_AUDIENCE";
|
|
35410
36090
|
var SESSION_VAR = "AGENT_SECRETS_SESSION";
|
|
36091
|
+
var POOL_AUDIENCE_VAR = "AGENT_SECRETS_POOL_AUDIENCE";
|
|
36092
|
+
var POOL_ACCOUNT_VAR = "AGENT_SECRETS_POOL_ACCOUNT";
|
|
35411
36093
|
var IDENTITY_KUBERNETES = "kubernetes";
|
|
35412
36094
|
var IDENTITY_METADATA = "metadata";
|
|
35413
36095
|
var IDENTITY_POOL = "pool";
|
|
36096
|
+
var BROKER_VARIABLES = [
|
|
36097
|
+
BROKER_URL_VAR,
|
|
36098
|
+
IDENTITY_VAR,
|
|
36099
|
+
MACHINE_TOKEN_FILE_VAR,
|
|
36100
|
+
MACHINE_AUDIENCE_VAR,
|
|
36101
|
+
SESSION_VAR,
|
|
36102
|
+
POOL_AUDIENCE_VAR,
|
|
36103
|
+
POOL_ACCOUNT_VAR,
|
|
36104
|
+
SIGNIN_DIR_VAR,
|
|
36105
|
+
"XDG_STATE_HOME",
|
|
36106
|
+
"HOME",
|
|
36107
|
+
PERSON_VAR,
|
|
36108
|
+
PERSON_TRADE_VAR,
|
|
36109
|
+
SIGNIN_ISSUER_VAR,
|
|
36110
|
+
SIGNIN_CLIENT_ID_VAR,
|
|
36111
|
+
SIGNIN_CLIENT_SECRET_FILE_VAR
|
|
36112
|
+
];
|
|
35414
36113
|
function value(env, name) {
|
|
35415
36114
|
return (env[name] ?? "").trim();
|
|
35416
36115
|
}
|
|
@@ -35429,10 +36128,20 @@ function machineIdentity(env) {
|
|
|
35429
36128
|
return projectedToken(required2(env, MACHINE_TOKEN_FILE_VAR, kind));
|
|
35430
36129
|
case IDENTITY_METADATA:
|
|
35431
36130
|
return metadataIdentity(required2(env, MACHINE_AUDIENCE_VAR, kind));
|
|
35432
|
-
case IDENTITY_POOL:
|
|
35433
|
-
|
|
36131
|
+
case IDENTITY_POOL: {
|
|
36132
|
+
const subject = required2(env, MACHINE_TOKEN_FILE_VAR, kind);
|
|
36133
|
+
const tokenAudience = required2(env, MACHINE_AUDIENCE_VAR, kind);
|
|
36134
|
+
const audience = required2(env, POOL_AUDIENCE_VAR, kind);
|
|
36135
|
+
const serviceAccount = required2(env, POOL_ACCOUNT_VAR, kind);
|
|
36136
|
+
return poolIdentity({
|
|
36137
|
+
subject: projectedToken(subject),
|
|
36138
|
+
audience,
|
|
36139
|
+
serviceAccount,
|
|
36140
|
+
tokenAudience
|
|
36141
|
+
});
|
|
36142
|
+
}
|
|
35434
36143
|
default:
|
|
35435
|
-
throw new Error(`${IDENTITY_VAR}="${kind}" names no identity this machine can prove; it takes ${IDENTITY_KUBERNETES} or ${
|
|
36144
|
+
throw new Error(`${IDENTITY_VAR}="${kind}" names no identity this machine can prove; it takes ${IDENTITY_KUBERNETES}, ${IDENTITY_METADATA} or ${IDENTITY_POOL}`);
|
|
35436
36145
|
}
|
|
35437
36146
|
}
|
|
35438
36147
|
function tradeSession(env, own = "") {
|
|
@@ -35441,16 +36150,32 @@ function tradeSession(env, own = "") {
|
|
|
35441
36150
|
}
|
|
35442
36151
|
async function brokerTokenClient(env, own = "") {
|
|
35443
36152
|
const brokerUrl = value(env, BROKER_URL_VAR);
|
|
35444
|
-
const
|
|
35445
|
-
if (brokerUrl === "" ||
|
|
36153
|
+
const machine = machineIdentity(env);
|
|
36154
|
+
if (brokerUrl === "" || machine === undefined)
|
|
35446
36155
|
return;
|
|
35447
|
-
|
|
36156
|
+
const record = await chooseSignIn(env);
|
|
36157
|
+
if (record === undefined) {
|
|
36158
|
+
const client = new BrokerTokenClient({
|
|
36159
|
+
brokerUrl,
|
|
36160
|
+
key: await newDpopKey(),
|
|
36161
|
+
subject: machine,
|
|
36162
|
+
session: tradeSession(env, own),
|
|
36163
|
+
launcherCredential: false
|
|
36164
|
+
});
|
|
36165
|
+
return { client, signIn: undefined };
|
|
36166
|
+
}
|
|
36167
|
+
const flow = await signInFlow(env);
|
|
36168
|
+
if (flow === undefined) {
|
|
36169
|
+
throw new Error(`${record.person} is signed in on this machine, and this machine configures no sign-in client to renew that sign-in with: set ${SIGNIN_CLIENT_ID_VAR} and ${SIGNIN_CLIENT_SECRET_FILE_VAR}`);
|
|
36170
|
+
}
|
|
36171
|
+
const client = new BrokerTokenClient({
|
|
35448
36172
|
brokerUrl,
|
|
35449
|
-
key: await
|
|
35450
|
-
subject,
|
|
35451
|
-
|
|
35452
|
-
|
|
36173
|
+
key: await importDpopKey(record.box_key, `${record.person}'s box key`),
|
|
36174
|
+
subject: personIdentity(record, flow),
|
|
36175
|
+
actor: machine,
|
|
36176
|
+
session: own.trim() || signInSessionName(record)
|
|
35453
36177
|
});
|
|
36178
|
+
return { client, signIn: { person: record.person, thumbprint: record.thumbprint } };
|
|
35454
36179
|
}
|
|
35455
36180
|
|
|
35456
36181
|
// ../envoy-client/src/broker-credential.ts
|
|
@@ -35463,12 +36188,6 @@ function brokerRouteConfigured(env) {
|
|
|
35463
36188
|
if ((env[BROKER_URL_VAR] ?? "").trim() === "") {
|
|
35464
36189
|
return { traded: false, gap: `${BROKER_URL_VAR} names no secrets broker to trade it at` };
|
|
35465
36190
|
}
|
|
35466
|
-
if ((env[IDENTITY_VAR] ?? "").trim() === IDENTITY_POOL) {
|
|
35467
|
-
return {
|
|
35468
|
-
traded: false,
|
|
35469
|
-
gap: `${IDENTITY_VAR}=${IDENTITY_POOL} is traded by the Go client alone (agent-secrets), never by this process`
|
|
35470
|
-
};
|
|
35471
|
-
}
|
|
35472
36191
|
if (machineIdentity(env) === undefined) {
|
|
35473
36192
|
return { traded: false, gap: `${IDENTITY_VAR} names no identity this machine proves` };
|
|
35474
36193
|
}
|
|
@@ -35478,37 +36197,91 @@ var CLIENTS = new Map;
|
|
|
35478
36197
|
function forgetBrokerSession(session) {
|
|
35479
36198
|
CLIENTS.delete(session.trim());
|
|
35480
36199
|
}
|
|
35481
|
-
function
|
|
35482
|
-
|
|
35483
|
-
|
|
35484
|
-
|
|
35485
|
-
|
|
35486
|
-
|
|
35487
|
-
env
|
|
35488
|
-
|
|
35489
|
-
|
|
35490
|
-
|
|
35491
|
-
|
|
35492
|
-
|
|
35493
|
-
|
|
36200
|
+
function signInName(record) {
|
|
36201
|
+
return `${record.person}\x00${record.thumbprint}`;
|
|
36202
|
+
}
|
|
36203
|
+
function keyOf(env, own) {
|
|
36204
|
+
return {
|
|
36205
|
+
session: own.trim(),
|
|
36206
|
+
variables: JSON.stringify(BROKER_VARIABLES.map((name) => env[name]))
|
|
36207
|
+
};
|
|
36208
|
+
}
|
|
36209
|
+
function entryFor(key) {
|
|
36210
|
+
let sessions = CLIENTS.get(key.session);
|
|
36211
|
+
if (sessions === undefined) {
|
|
36212
|
+
sessions = new Map;
|
|
36213
|
+
CLIENTS.set(key.session, sessions);
|
|
36214
|
+
}
|
|
36215
|
+
let entry = sessions.get(key.variables);
|
|
36216
|
+
if (entry === undefined) {
|
|
36217
|
+
entry = { making: undefined, made: undefined, refused: new Map };
|
|
36218
|
+
sessions.set(key.variables, entry);
|
|
36219
|
+
}
|
|
36220
|
+
return entry;
|
|
36221
|
+
}
|
|
36222
|
+
async function make(env, own) {
|
|
36223
|
+
const made = await brokerTokenClient(env, own);
|
|
36224
|
+
const signIn = made?.signIn;
|
|
36225
|
+
return { client: made?.client, signIn: signIn === undefined ? "" : signInName(signIn) };
|
|
36226
|
+
}
|
|
36227
|
+
async function clientFor(env, own) {
|
|
36228
|
+
const key = keyOf(env, own);
|
|
36229
|
+
const entry = entryFor(key);
|
|
36230
|
+
if (entry.refused.size > 0) {
|
|
36231
|
+
const record = await chooseSignIn(env);
|
|
36232
|
+
const chosen = record === undefined ? "" : signInName(record);
|
|
36233
|
+
if (entry.refused.has(chosen))
|
|
36234
|
+
throw entry.refused.get(chosen);
|
|
36235
|
+
if (entry.made !== undefined && entry.made.signIn !== chosen) {
|
|
36236
|
+
entry.making = undefined;
|
|
36237
|
+
entry.made = undefined;
|
|
36238
|
+
}
|
|
36239
|
+
}
|
|
36240
|
+
let making = entry.making;
|
|
36241
|
+
if (making === undefined) {
|
|
36242
|
+
const started = make(env, key.session);
|
|
36243
|
+
making = started;
|
|
36244
|
+
entry.making = started;
|
|
36245
|
+
started.then((made) => {
|
|
36246
|
+
if (entry.making === started)
|
|
36247
|
+
entry.made = made;
|
|
36248
|
+
}, () => {
|
|
36249
|
+
if (entry.making === started)
|
|
36250
|
+
entry.making = undefined;
|
|
36251
|
+
});
|
|
36252
|
+
}
|
|
36253
|
+
return { entry, made: await making };
|
|
35494
36254
|
}
|
|
35495
36255
|
function brokerCredential(env, session) {
|
|
35496
|
-
let
|
|
36256
|
+
let presented = "";
|
|
36257
|
+
const own = (acting) => (acting ?? "").trim() || sessionName(session);
|
|
35497
36258
|
return {
|
|
35498
36259
|
scheme: "DPoP",
|
|
35499
36260
|
async headers(method, url, acting) {
|
|
35500
|
-
const
|
|
36261
|
+
const { entry, made } = await clientFor(env, own(acting));
|
|
36262
|
+
const { client } = made;
|
|
35501
36263
|
if (client === undefined) {
|
|
35502
36264
|
throw new Error("AGENT_SECRETS_URL and AGENT_SECRETS_MACHINE_IDENTITY no longer name a broker and an identity to trade");
|
|
35503
36265
|
}
|
|
35504
|
-
|
|
35505
|
-
|
|
36266
|
+
let token;
|
|
36267
|
+
try {
|
|
36268
|
+
token = await client.token();
|
|
36269
|
+
} catch (error) {
|
|
36270
|
+
if (made.signIn !== "" && isFinalRefusal(error))
|
|
36271
|
+
entry.refused.set(made.signIn, error);
|
|
36272
|
+
throw error;
|
|
36273
|
+
}
|
|
36274
|
+
presented = token.accessToken;
|
|
35506
36275
|
return {
|
|
35507
36276
|
Authorization: `DPoP ${token.accessToken}`,
|
|
35508
36277
|
DPoP: await client.key.proof({ method, url, accessToken: token.accessToken })
|
|
35509
36278
|
};
|
|
35510
36279
|
},
|
|
35511
|
-
|
|
36280
|
+
stale(acting) {
|
|
36281
|
+
const key = keyOf(env, own(acting));
|
|
36282
|
+
CLIENTS.get(key.session)?.get(key.variables)?.made?.client?.drop();
|
|
36283
|
+
},
|
|
36284
|
+
secret: () => presented
|
|
35512
36285
|
};
|
|
35513
36286
|
}
|
|
35514
36287
|
|
|
@@ -36436,6 +37209,9 @@ class DispatchNoRouteError extends DispatchServiceError {
|
|
|
36436
37209
|
super("NOT_FOUND", 404, NO_ROUTE_ROLLING_RELEASE_MESSAGE);
|
|
36437
37210
|
}
|
|
36438
37211
|
}
|
|
37212
|
+
function reviewNoRouteRefusal(baseUrl, route, version) {
|
|
37213
|
+
return new DispatchServiceError("NOT_FOUND", 404, `Dispatch at ${baseUrl} answered no route for ${route} each time the review was sent, and an ` + "answer of no route records no review. This build is older than that route. No other review " + "route was asked: the review route an older build serves takes no version, and it " + `would record the review at a version that build chooses, which may not be version ${version}. ` + `The no-route answer does not name the build; GET ${baseUrl}/healthz names the commit of the ` + "build that answers it, when that build was stamped with one.");
|
|
37214
|
+
}
|
|
36439
37215
|
var ISSUE_EVENTS_PAGE_MAX = 200;
|
|
36440
37216
|
var DISPATCH_TOOL_DEADLINE_MS = 60000;
|
|
36441
37217
|
function requestSignal(signal) {
|
|
@@ -36540,6 +37316,15 @@ async function writeAnswer(response, key) {
|
|
|
36540
37316
|
unjudged: !echoed && typeof shape.error === "string"
|
|
36541
37317
|
};
|
|
36542
37318
|
}
|
|
37319
|
+
var BROKER_TOKEN_NOT_ACTIVE = "BROKER_TOKEN_NOT_ACTIVE";
|
|
37320
|
+
async function tokenNotLive(response) {
|
|
37321
|
+
if (response.status !== 401 || !isJson(response))
|
|
37322
|
+
return false;
|
|
37323
|
+
const body = await response.clone().json().catch(() => {
|
|
37324
|
+
return;
|
|
37325
|
+
});
|
|
37326
|
+
return asErrorShape(body).code === BROKER_TOKEN_NOT_ACTIVE;
|
|
37327
|
+
}
|
|
36543
37328
|
function whyNotAPage(answer) {
|
|
36544
37329
|
if (typeof answer === "string") {
|
|
36545
37330
|
return `text that is not a JSON page, ${GATEWAY_PAGE}, so a retry may succeed.`;
|
|
@@ -36862,6 +37647,18 @@ class DispatchClient {
|
|
|
36862
37647
|
async planApprove(artifactID, input) {
|
|
36863
37648
|
return this.#json("POST", ["api", "v1", "artifacts", artifactID, "plan-reviews"], input);
|
|
36864
37649
|
}
|
|
37650
|
+
async reviewArtifact(artifactID, version, input) {
|
|
37651
|
+
const path = ["api", "v1", "artifacts", artifactID, "versions", String(version), "reviews"];
|
|
37652
|
+
const body = { state: input.state, reason: input.reason };
|
|
37653
|
+
try {
|
|
37654
|
+
return await this.#json("POST", path, body);
|
|
37655
|
+
} catch (error) {
|
|
37656
|
+
if (!(error instanceof DispatchNoRouteError) && !isNoRoute(error))
|
|
37657
|
+
throw error;
|
|
37658
|
+
const route = `POST /${path.map((segment) => encodeURIComponent(segment)).join("/")}`;
|
|
37659
|
+
throw reviewNoRouteRefusal(this.#baseUrl, route, version);
|
|
37660
|
+
}
|
|
37661
|
+
}
|
|
36865
37662
|
async recordResult(issue, input) {
|
|
36866
37663
|
return this.#json("POST", ["api", "v1", "issues", await this.#resolveIssue(issue), "results"], input);
|
|
36867
37664
|
}
|
|
@@ -37097,11 +37894,20 @@ class DispatchClient {
|
|
|
37097
37894
|
});
|
|
37098
37895
|
}
|
|
37099
37896
|
async#send(method, url, body, accept = "application/json", signal, callerKey) {
|
|
37897
|
+
const key = method === "POST" || method === "PATCH" ? callerKey ?? crypto.randomUUID() : undefined;
|
|
37898
|
+
const send = async () => this.#sendPresenting(method, url, body, accept, signal, key);
|
|
37899
|
+
const answer = await send();
|
|
37900
|
+
if (this.#credential.stale === undefined || !await tokenNotLive(answer))
|
|
37901
|
+
return answer;
|
|
37902
|
+
this.#credential.stale();
|
|
37903
|
+
return await send();
|
|
37904
|
+
}
|
|
37905
|
+
async#sendPresenting(method, url, body, accept, signal, key) {
|
|
37100
37906
|
const headers = { Accept: accept };
|
|
37101
37907
|
let presented = await this.#credential.headers(method, url);
|
|
37102
37908
|
if (body !== undefined)
|
|
37103
37909
|
headers["Content-Type"] = body.type;
|
|
37104
|
-
if (
|
|
37910
|
+
if (key === undefined) {
|
|
37105
37911
|
return this.fetchImpl(url, {
|
|
37106
37912
|
method,
|
|
37107
37913
|
headers: { ...headers, ...presented },
|
|
@@ -37109,7 +37915,6 @@ class DispatchClient {
|
|
|
37109
37915
|
...body === undefined ? {} : { body: body.content }
|
|
37110
37916
|
});
|
|
37111
37917
|
}
|
|
37112
|
-
const key = callerKey ?? crypto.randomUUID();
|
|
37113
37918
|
headers[IDEMPOTENCY_KEY_HEADER] = key;
|
|
37114
37919
|
const { pausesMs, withinMs, silenceMs, inFlightPauseMs, inFlightWithinMs } = this.writeRetry;
|
|
37115
37920
|
const pause = this.writeRetry.pause ?? pauseFor;
|
|
@@ -40175,7 +40980,7 @@ function brokerRouteForced(env) {
|
|
|
40175
40980
|
return false;
|
|
40176
40981
|
if (written === "1")
|
|
40177
40982
|
return true;
|
|
40178
|
-
return offWithError(`DISPATCH_TOKEN_BROKER is "${written}" and takes 1: set it to 1 where this session's Dispatch credential is
|
|
40983
|
+
return offWithError(`DISPATCH_TOKEN_BROKER is "${written}" and takes 1: set it to 1 where this session's Dispatch credential is traded at the secrets broker (the person signed in on this machine, else the machine's own identity), and leave it unset where a bearer is read as usual`);
|
|
40179
40984
|
}
|
|
40180
40985
|
function dispatchTarget(env, config) {
|
|
40181
40986
|
if (config.kind === "failed")
|
|
@@ -40226,7 +41031,7 @@ function dispatchTarget(env, config) {
|
|
|
40226
41031
|
return { enabled: true, url: brokered, source: { kind: "broker" } };
|
|
40227
41032
|
}
|
|
40228
41033
|
if (forced) {
|
|
40229
|
-
return offWithError(`DISPATCH_TOKEN_BROKER is set, so this session's Dispatch credential is
|
|
41034
|
+
return offWithError(`DISPATCH_TOKEN_BROKER is set, so this session's Dispatch credential is traded at the secrets broker (the person signed in on this machine, else the machine's own identity), and ${route.gap}: Dispatch is off rather than written with whatever bearer this box holds`);
|
|
40230
41035
|
}
|
|
40231
41036
|
return offWithError(explicitUrl === undefined ? `${config.path}: dispatch is enabled and no token is: set dispatch.token, or DISPATCH_TOKEN or DISPATCH_TOKEN_FILE` : `DISPATCH_URL is set and no token is: set DISPATCH_TOKEN or DISPATCH_TOKEN_FILE, or dispatch.token in ${config.path}`);
|
|
40232
41037
|
}
|
|
@@ -40325,10 +41130,10 @@ async function resolveCwdRepo(cwd, exec) {
|
|
|
40325
41130
|
|
|
40326
41131
|
// ../envoy-client/src/dispatch-first.ts
|
|
40327
41132
|
import { readFileSync as readFileSync4 } from "fs";
|
|
40328
|
-
import { join as
|
|
41133
|
+
import { join as join4 } from "path";
|
|
40329
41134
|
var DISPATCH_FIRST_MARKER = "<dispatch-first-skill>";
|
|
40330
41135
|
function dispatchFirstSkillFile(skillsDirectory) {
|
|
40331
|
-
return
|
|
41136
|
+
return join4(skillsDirectory, "dispatch-first", "SKILL.md");
|
|
40332
41137
|
}
|
|
40333
41138
|
function readDispatchFirstContext(skillFile) {
|
|
40334
41139
|
let skill;
|
|
@@ -40551,20 +41356,20 @@ async function readPictures(client, addresses, shown) {
|
|
|
40551
41356
|
import { randomUUID } from "crypto";
|
|
40552
41357
|
import { renameSync as renameSync2, rmSync as rmSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
40553
41358
|
import { homedir as homedir2 } from "os";
|
|
40554
|
-
import { join as
|
|
41359
|
+
import { join as join5 } from "path";
|
|
40555
41360
|
var SESSION_ID_PATH_SEGMENT = /^[A-Za-z0-9._-]{1,128}$/;
|
|
40556
41361
|
var PRIVATE_FILE2 = 384;
|
|
40557
41362
|
function sessionStateRoot(env) {
|
|
40558
41363
|
const stateDir = env["DISPATCH_STATE_DIR"];
|
|
40559
41364
|
if (stateDir)
|
|
40560
41365
|
return stateDir;
|
|
40561
|
-
return
|
|
41366
|
+
return join5(env["XDG_STATE_HOME"] || join5(homedir2(), ".local", "state"), "dispatch");
|
|
40562
41367
|
}
|
|
40563
41368
|
function sessionDirectory(env, sessionId) {
|
|
40564
41369
|
if (!SESSION_ID_PATH_SEGMENT.test(sessionId) || sessionId === "." || sessionId === "..") {
|
|
40565
41370
|
throw new Error(`dispatch: the session id ${JSON.stringify(sessionId)} is not 1-128 letters, digits, ".", "_" or "-"`);
|
|
40566
41371
|
}
|
|
40567
|
-
return
|
|
41372
|
+
return join5(sessionStateRoot(env), "sessions", sessionId);
|
|
40568
41373
|
}
|
|
40569
41374
|
function writeAtomically2(path, text) {
|
|
40570
41375
|
const temporary = `${path}.${process.pid}.${randomUUID()}.tmp`;
|
|
@@ -40591,7 +41396,7 @@ import {
|
|
|
40591
41396
|
statSync as statSync3,
|
|
40592
41397
|
writeFileSync as writeFileSync3
|
|
40593
41398
|
} from "fs";
|
|
40594
|
-
import { join as
|
|
41399
|
+
import { join as join7 } from "path";
|
|
40595
41400
|
|
|
40596
41401
|
// ../envoy-client/src/tool-input-errors.ts
|
|
40597
41402
|
class ToolInputError extends Error {
|
|
@@ -44458,9 +45263,44 @@ async function readCommand(context) {
|
|
|
44458
45263
|
};
|
|
44459
45264
|
}
|
|
44460
45265
|
|
|
45266
|
+
// ../envoy-client/src/dispatch-commands/reviews.ts
|
|
45267
|
+
async function reviewCommand(context) {
|
|
45268
|
+
const { args, client, documentOwner, resolveDocument } = context;
|
|
45269
|
+
const resolved = await resolveDocument(documentOwner(), optionalString(args, "artifact"));
|
|
45270
|
+
const { artifact } = resolved;
|
|
45271
|
+
let review;
|
|
45272
|
+
try {
|
|
45273
|
+
review = await client.reviewArtifact(artifact.id, numberArg(args, "version"), {
|
|
45274
|
+
state: stringArg(args, "verdict"),
|
|
45275
|
+
...defined("reason", optionalString(args, "reason"))
|
|
45276
|
+
});
|
|
45277
|
+
} catch (error) {
|
|
45278
|
+
throw refusalWithCode(error);
|
|
45279
|
+
}
|
|
45280
|
+
const issue = resolved.issue?.key;
|
|
45281
|
+
const answered = review.ask_id === null ? [] : [
|
|
45282
|
+
`It also answered the open approval request (ask ${review.ask_id}), so Dispatch recorded the same verdict on every document that request named, each at the version the request named for it. Dispatch answered with the review of ${artifact.name} alone, so no other document's review is shown here; ${commandLine("dispatch_doc_read", { issue })} --artifact <document> prints the approval each of them now reads.`
|
|
45283
|
+
];
|
|
45284
|
+
return {
|
|
45285
|
+
text: [
|
|
45286
|
+
`Recorded the review of ${artifact.name} (document id ${artifact.id}): ${review.state} at version ${review.version}, by ${actorText(review.actor)}.`,
|
|
45287
|
+
...review.reason === null ? [] : [`Reason: ${JSON.stringify(review.reason)}`],
|
|
45288
|
+
...answered
|
|
45289
|
+
].join(`
|
|
45290
|
+
`),
|
|
45291
|
+
details: {
|
|
45292
|
+
issue,
|
|
45293
|
+
artifact: artifact.id,
|
|
45294
|
+
version: review.version,
|
|
45295
|
+
state: review.state,
|
|
45296
|
+
...review.ask_id === null ? {} : { ask: review.ask_id }
|
|
45297
|
+
}
|
|
45298
|
+
};
|
|
45299
|
+
}
|
|
45300
|
+
|
|
44461
45301
|
// ../envoy-client/src/session-answers.ts
|
|
44462
45302
|
import { mkdirSync as mkdirSync2, readFileSync as readFileSync5 } from "fs";
|
|
44463
|
-
import { join as
|
|
45303
|
+
import { join as join6 } from "path";
|
|
44464
45304
|
var SESSION_ANSWERS_WINDOW_MS = 72 * 3600000;
|
|
44465
45305
|
var SESSION_ANSWERS_MAX_CHARS = 8000;
|
|
44466
45306
|
var SESSION_ANSWERS_DEADLINE_MS = 800;
|
|
@@ -44591,7 +45431,7 @@ processGlobal2[STATE_KEY] = state;
|
|
|
44591
45431
|
var CACHE_FILE = "answers.json";
|
|
44592
45432
|
function readCacheFile(directory, url) {
|
|
44593
45433
|
try {
|
|
44594
|
-
const value = JSON.parse(readFileSync5(
|
|
45434
|
+
const value = JSON.parse(readFileSync5(join6(directory, CACHE_FILE), "utf-8"));
|
|
44595
45435
|
if (typeof value === "object" && value !== null && "dispatch_url" in value && typeof value.dispatch_url === "string" && value.dispatch_url === url && "read_at" in value && typeof value.read_at === "string" && "total" in value && typeof value.total === "number" && "items" in value && Array.isArray(value.items)) {
|
|
44596
45436
|
return {
|
|
44597
45437
|
dispatch_url: value.dispatch_url,
|
|
@@ -44709,7 +45549,7 @@ async function readSessionAnswers(options) {
|
|
|
44709
45549
|
if (directory !== undefined) {
|
|
44710
45550
|
try {
|
|
44711
45551
|
mkdirSync2(directory, { recursive: true, mode: 448 });
|
|
44712
|
-
writeAtomically2(
|
|
45552
|
+
writeAtomically2(join6(directory, CACHE_FILE), JSON.stringify(cache));
|
|
44713
45553
|
} catch {}
|
|
44714
45554
|
}
|
|
44715
45555
|
return { cache };
|
|
@@ -44985,6 +45825,7 @@ var dispatchCommands = {
|
|
|
44985
45825
|
dispatch_doc_read: acting(docReadCommand),
|
|
44986
45826
|
dispatch_request_approval: acting(requestApprovalCommand),
|
|
44987
45827
|
dispatch_plan_approve: acting(planApproveCommand),
|
|
45828
|
+
dispatch_review: acting(reviewCommand),
|
|
44988
45829
|
dispatch_result: acting(resultCommand),
|
|
44989
45830
|
dispatch_results: acting(resultsCommand),
|
|
44990
45831
|
dispatch_artifact: acting(artifactCommand),
|
|
@@ -45003,7 +45844,7 @@ function ensureDirectory(dir) {
|
|
|
45003
45844
|
mkdirSync3(dir, { recursive: true, mode: PRIVATE_DIR2 });
|
|
45004
45845
|
}
|
|
45005
45846
|
function readResultsSince(dir, offset, onMalformed) {
|
|
45006
|
-
const path =
|
|
45847
|
+
const path = join7(dir, "results.jsonl");
|
|
45007
45848
|
let fd;
|
|
45008
45849
|
try {
|
|
45009
45850
|
fd = openSync3(path, "r");
|
|
@@ -45050,7 +45891,7 @@ function linesBefore(fd, offset) {
|
|
|
45050
45891
|
}
|
|
45051
45892
|
function resultsEnd(dir) {
|
|
45052
45893
|
try {
|
|
45053
|
-
return statSync3(
|
|
45894
|
+
return statSync3(join7(dir, "results.jsonl")).size;
|
|
45054
45895
|
} catch (error) {
|
|
45055
45896
|
if (hasErrnoCode(error, "ENOENT"))
|
|
45056
45897
|
return 0;
|
|
@@ -45059,7 +45900,7 @@ function resultsEnd(dir) {
|
|
|
45059
45900
|
}
|
|
45060
45901
|
function writeSessionTitle(dir, title) {
|
|
45061
45902
|
ensureDirectory(dir);
|
|
45062
|
-
writeAtomically2(
|
|
45903
|
+
writeAtomically2(join7(dir, "title"), title);
|
|
45063
45904
|
}
|
|
45064
45905
|
|
|
45065
45906
|
// ../envoy-client/src/envoy-settings.ts
|
|
@@ -46787,7 +47628,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
|
|
|
46787
47628
|
|
|
46788
47629
|
// package.json
|
|
46789
47630
|
var name = "@sjawhar/pi-envoy";
|
|
46790
|
-
var version2 = "17.
|
|
47631
|
+
var version2 = "17.27.0";
|
|
46791
47632
|
var package_default = {
|
|
46792
47633
|
name,
|
|
46793
47634
|
version: version2,
|
|
@@ -49884,7 +50725,7 @@ function sameAccount(primary, gate, shared) {
|
|
|
49884
50725
|
return shared.includes(primary) && shared.includes(gate);
|
|
49885
50726
|
}
|
|
49886
50727
|
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
49887
|
-
var
|
|
50728
|
+
var messageOf2 = (error) => error instanceof Error ? error.message : String(error);
|
|
49888
50729
|
function parseMode(raw) {
|
|
49889
50730
|
const value = raw?.trim();
|
|
49890
50731
|
return MODES.includes(value) ? value : undefined;
|
|
@@ -50941,7 +51782,7 @@ ${body}
|
|
|
50941
51782
|
</advisor-gate>` : body;
|
|
50942
51783
|
}
|
|
50943
51784
|
function loadFailureGate(error, deps, pi) {
|
|
50944
|
-
const message =
|
|
51785
|
+
const message = messageOf2(error);
|
|
50945
51786
|
const reason = `AskGate did not send this call: it reviews each Dispatch write before it posts, and it did not load: ${message}. Send the call again once AskGate loads. To turn AskGate off for this session, set askgate.enabled to false in ${deps.configFile}.`;
|
|
50946
51787
|
const envMode = parseMode(deps.env.OMP_ASKGATE);
|
|
50947
51788
|
return (event, ctx) => {
|
|
@@ -51142,7 +51983,7 @@ ${rule_check_default.trim()}`;
|
|
|
51142
51983
|
id: entry.toolCallId
|
|
51143
51984
|
});
|
|
51144
51985
|
} catch (error) {
|
|
51145
|
-
recordError =
|
|
51986
|
+
recordError = messageOf2(error);
|
|
51146
51987
|
}
|
|
51147
51988
|
if (recordError !== undefined)
|
|
51148
51989
|
noteRecordFailure(entry, recordError);
|
|
@@ -51477,7 +52318,7 @@ ${user}
|
|
|
51477
52318
|
clearTimeout(graceTimer);
|
|
51478
52319
|
return { kind: first, usage: settled?.usage };
|
|
51479
52320
|
} catch (error) {
|
|
51480
|
-
return { kind: "error", reason:
|
|
52321
|
+
return { kind: "error", reason: messageOf2(error) };
|
|
51481
52322
|
}
|
|
51482
52323
|
};
|
|
51483
52324
|
const readArgs = async (scoped, input, ctx, stop, readsEnd) => {
|
|
@@ -51573,7 +52414,7 @@ ${user}
|
|
|
51573
52414
|
file: {
|
|
51574
52415
|
flag: relativeFile.flag,
|
|
51575
52416
|
path: relativeFile.operand,
|
|
51576
|
-
reason: `could not resolve the tool directory: ${
|
|
52417
|
+
reason: `could not resolve the tool directory: ${messageOf2(error)}`
|
|
51577
52418
|
}
|
|
51578
52419
|
}
|
|
51579
52420
|
};
|
|
@@ -51636,7 +52477,7 @@ ${user}
|
|
|
51636
52477
|
file: {
|
|
51637
52478
|
flag: file.flag,
|
|
51638
52479
|
path: file.operand,
|
|
51639
|
-
reason: error.code === "ENOENT" ? "does not exist" : `could not be read: ${
|
|
52480
|
+
reason: error.code === "ENOENT" ? "does not exist" : `could not be read: ${messageOf2(error)}`,
|
|
51640
52481
|
inMessage: true
|
|
51641
52482
|
}
|
|
51642
52483
|
}
|
|
@@ -51691,7 +52532,7 @@ ${user}
|
|
|
51691
52532
|
markers.set(toolCallId, mintMarker(deps.markerStore, { argv, args: bound?.args ?? null, files: bound?.files ?? [], toolCallId, outcome }, deps.now()));
|
|
51692
52533
|
return;
|
|
51693
52534
|
} catch (error) {
|
|
51694
|
-
return { block: true, reason: mintFailureRefusal(
|
|
52535
|
+
return { block: true, reason: mintFailureRefusal(messageOf2(error), deps.configFile) };
|
|
51695
52536
|
}
|
|
51696
52537
|
};
|
|
51697
52538
|
const handleCall = async (event, ctx) => {
|
|
@@ -51813,7 +52654,7 @@ ${user}
|
|
|
51813
52654
|
}
|
|
51814
52655
|
}
|
|
51815
52656
|
} catch (error) {
|
|
51816
|
-
decision = pass("error", { reason:
|
|
52657
|
+
decision = pass("error", { reason: messageOf2(error) });
|
|
51817
52658
|
}
|
|
51818
52659
|
try {
|
|
51819
52660
|
settle(decision.effect, ctx);
|
|
@@ -51849,7 +52690,7 @@ ${user}
|
|
|
51849
52690
|
notices.delete(event.toolCallId);
|
|
51850
52691
|
refusal = {
|
|
51851
52692
|
block: true,
|
|
51852
|
-
reason: recordFailureRefusal(
|
|
52693
|
+
reason: recordFailureRefusal(messageOf2(error), deps.configFile)
|
|
51853
52694
|
};
|
|
51854
52695
|
}
|
|
51855
52696
|
}
|