@atbash/sdk 0.9.0 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.mts +49 -14
- package/dist/browser.mjs +124 -192
- package/dist/index.d.mts +49 -14
- package/dist/index.d.ts +49 -14
- package/dist/index.js +338 -92
- package/dist/index.mjs +342 -93
- package/package.json +6 -6
package/dist/browser.mjs
CHANGED
|
@@ -10054,8 +10054,8 @@ Reporter$3.prototype.wrapResult = function wrapResult(result) {
|
|
|
10054
10054
|
errors: state2.errors
|
|
10055
10055
|
};
|
|
10056
10056
|
};
|
|
10057
|
-
function ReporterError$1(
|
|
10058
|
-
this.path =
|
|
10057
|
+
function ReporterError$1(path3, msg) {
|
|
10058
|
+
this.path = path3;
|
|
10059
10059
|
this.rethrow(msg);
|
|
10060
10060
|
}
|
|
10061
10061
|
inherits$v(ReporterError$1, Error);
|
|
@@ -12126,7 +12126,7 @@ function requireBuffer_list() {
|
|
|
12126
12126
|
}
|
|
12127
12127
|
}, {
|
|
12128
12128
|
key: "join",
|
|
12129
|
-
value: function
|
|
12129
|
+
value: function join2(s2) {
|
|
12130
12130
|
if (this.length === 0) return "";
|
|
12131
12131
|
var p = this.head;
|
|
12132
12132
|
var ret = "" + p.data;
|
|
@@ -16208,7 +16208,7 @@ function requireBufferList() {
|
|
|
16208
16208
|
this.head = this.tail = null;
|
|
16209
16209
|
this.length = 0;
|
|
16210
16210
|
};
|
|
16211
|
-
BufferList2.prototype.join = function
|
|
16211
|
+
BufferList2.prototype.join = function join2(s2) {
|
|
16212
16212
|
if (this.length === 0) return "";
|
|
16213
16213
|
var p = this.head;
|
|
16214
16214
|
var ret = "" + p.data;
|
|
@@ -30276,8 +30276,8 @@ Reporter.prototype.wrapResult = function wrapResult2(result) {
|
|
|
30276
30276
|
errors: state2.errors
|
|
30277
30277
|
};
|
|
30278
30278
|
};
|
|
30279
|
-
function ReporterError(
|
|
30280
|
-
this.path =
|
|
30279
|
+
function ReporterError(path3, msg) {
|
|
30280
|
+
this.path = path3;
|
|
30281
30281
|
this.rethrow(msg);
|
|
30282
30282
|
}
|
|
30283
30283
|
inherits(ReporterError, Error);
|
|
@@ -30372,7 +30372,7 @@ function requireBuffer() {
|
|
|
30372
30372
|
}
|
|
30373
30373
|
}
|
|
30374
30374
|
buffer.EncoderBuffer = EncoderBuffer2;
|
|
30375
|
-
EncoderBuffer2.prototype.join = function
|
|
30375
|
+
EncoderBuffer2.prototype.join = function join2(out, offset) {
|
|
30376
30376
|
if (!out)
|
|
30377
30377
|
out = new Buffer5(this.length);
|
|
30378
30378
|
if (!offset)
|
|
@@ -33307,8 +33307,8 @@ var parseUtil = {};
|
|
|
33307
33307
|
const errors_js_12 = errors$3;
|
|
33308
33308
|
const en_js_12 = __importDefault2(en);
|
|
33309
33309
|
const makeIssue = (params) => {
|
|
33310
|
-
const { data, path:
|
|
33311
|
-
const fullPath = [...
|
|
33310
|
+
const { data, path: path3, errorMaps, issueData } = params;
|
|
33311
|
+
const fullPath = [...path3, ...issueData.path || []];
|
|
33312
33312
|
const fullIssue = {
|
|
33313
33313
|
...issueData,
|
|
33314
33314
|
path: fullPath
|
|
@@ -33445,11 +33445,11 @@ var errorUtil_js_1 = errorUtil$1;
|
|
|
33445
33445
|
var parseUtil_js_1 = parseUtil;
|
|
33446
33446
|
var util_js_1 = util;
|
|
33447
33447
|
var ParseInputLazyPath = class {
|
|
33448
|
-
constructor(parent, value,
|
|
33448
|
+
constructor(parent, value, path3, key3) {
|
|
33449
33449
|
this._cachedPath = [];
|
|
33450
33450
|
this.parent = parent;
|
|
33451
33451
|
this.data = value;
|
|
33452
|
-
this._path =
|
|
33452
|
+
this._path = path3;
|
|
33453
33453
|
this._key = key3;
|
|
33454
33454
|
}
|
|
33455
33455
|
get path() {
|
|
@@ -40355,21 +40355,21 @@ function createTimeoutController(timeout) {
|
|
|
40355
40355
|
const timeoutId = setTimeout(() => controller.abort(timeoutError), timeout);
|
|
40356
40356
|
return { controller, timeoutId };
|
|
40357
40357
|
}
|
|
40358
|
-
function handleRequest(method,
|
|
40358
|
+
function handleRequest(method, path3, endpoint, timeout, postObject) {
|
|
40359
40359
|
return __awaiter$2(this, void 0, void 0, function* () {
|
|
40360
40360
|
if (method == enums_1$2.Method.GET) {
|
|
40361
|
-
return yield get(
|
|
40361
|
+
return yield get(path3, endpoint, timeout);
|
|
40362
40362
|
} else {
|
|
40363
|
-
return yield post(
|
|
40363
|
+
return yield post(path3, endpoint, timeout, postObject);
|
|
40364
40364
|
}
|
|
40365
40365
|
});
|
|
40366
40366
|
}
|
|
40367
|
-
function get(
|
|
40367
|
+
function get(path3, endpoint, timeout) {
|
|
40368
40368
|
return __awaiter$2(this, void 0, void 0, function* () {
|
|
40369
|
-
logger.debug(`GET URL ${new URL(
|
|
40369
|
+
logger.debug(`GET URL ${new URL(path3, endpoint).href}`);
|
|
40370
40370
|
try {
|
|
40371
40371
|
const { controller, timeoutId } = createTimeoutController(timeout);
|
|
40372
|
-
const response = yield fetch(new URL(
|
|
40372
|
+
const response = yield fetch(new URL(path3, endpoint).href, {
|
|
40373
40373
|
signal: controller === null || controller === void 0 ? void 0 : controller.signal
|
|
40374
40374
|
});
|
|
40375
40375
|
if (timeoutId)
|
|
@@ -40407,9 +40407,9 @@ function constructBufferResponseBody(response) {
|
|
|
40407
40407
|
return responseText ? responseText : response.statusText;
|
|
40408
40408
|
});
|
|
40409
40409
|
}
|
|
40410
|
-
function post(
|
|
40410
|
+
function post(path3, endpoint, timeout, requestBody) {
|
|
40411
40411
|
return __awaiter$2(this, void 0, void 0, function* () {
|
|
40412
|
-
logger.debug(`POST URL ${new URL(
|
|
40412
|
+
logger.debug(`POST URL ${new URL(path3, endpoint).href}`);
|
|
40413
40413
|
logger.debug(`POST body ${JSON.stringify(requestBody)}`);
|
|
40414
40414
|
if (buffer_1.Buffer.isBuffer(requestBody)) {
|
|
40415
40415
|
try {
|
|
@@ -40423,7 +40423,7 @@ function post(path4, endpoint, timeout, requestBody) {
|
|
|
40423
40423
|
},
|
|
40424
40424
|
signal: controller === null || controller === void 0 ? void 0 : controller.signal
|
|
40425
40425
|
};
|
|
40426
|
-
const response = yield fetch(new URL(
|
|
40426
|
+
const response = yield fetch(new URL(path3, endpoint).href, requestOptions);
|
|
40427
40427
|
if (timeoutId)
|
|
40428
40428
|
clearTimeout(timeoutId);
|
|
40429
40429
|
const transactionTimestamp = response.headers.get("X-Transaction-Timestamp");
|
|
@@ -40434,7 +40434,7 @@ function post(path4, endpoint, timeout, requestBody) {
|
|
|
40434
40434
|
} else {
|
|
40435
40435
|
try {
|
|
40436
40436
|
const { controller, timeoutId } = createTimeoutController(timeout);
|
|
40437
|
-
const response = yield fetch(new URL(
|
|
40437
|
+
const response = yield fetch(new URL(path3, endpoint).href, {
|
|
40438
40438
|
method: "post",
|
|
40439
40439
|
body: JSON.stringify(requestBody),
|
|
40440
40440
|
headers: {
|
|
@@ -40614,10 +40614,10 @@ function requireFailoverStrategies() {
|
|
|
40614
40614
|
}
|
|
40615
40615
|
}
|
|
40616
40616
|
function abortOnError(_a2) {
|
|
40617
|
-
return __awaiter2(this, arguments, void 0, function* ({ method, path:
|
|
40617
|
+
return __awaiter2(this, arguments, void 0, function* ({ method, path: path3, config: config2, postObject, timeoutOverride }) {
|
|
40618
40618
|
return yield retryRequest({
|
|
40619
40619
|
method,
|
|
40620
|
-
path:
|
|
40620
|
+
path: path3,
|
|
40621
40621
|
config: config2,
|
|
40622
40622
|
postObject,
|
|
40623
40623
|
timeoutOverride,
|
|
@@ -40628,10 +40628,10 @@ function requireFailoverStrategies() {
|
|
|
40628
40628
|
});
|
|
40629
40629
|
}
|
|
40630
40630
|
function tryNextOnError(_a2) {
|
|
40631
|
-
return __awaiter2(this, arguments, void 0, function* ({ method, path:
|
|
40631
|
+
return __awaiter2(this, arguments, void 0, function* ({ method, path: path3, config: config2, postObject, timeoutOverride }) {
|
|
40632
40632
|
return yield retryRequest({
|
|
40633
40633
|
method,
|
|
40634
|
-
path:
|
|
40634
|
+
path: path3,
|
|
40635
40635
|
config: config2,
|
|
40636
40636
|
postObject,
|
|
40637
40637
|
timeoutOverride,
|
|
@@ -40647,7 +40647,7 @@ function requireFailoverStrategies() {
|
|
|
40647
40647
|
return endpointPoolLength - (endpointPoolLength - 1) / 3;
|
|
40648
40648
|
}
|
|
40649
40649
|
function queryMajority(_a2) {
|
|
40650
|
-
return __awaiter2(this, arguments, void 0, function* ({ method, path:
|
|
40650
|
+
return __awaiter2(this, arguments, void 0, function* ({ method, path: path3, config: config2, postObject, timeoutOverride }) {
|
|
40651
40651
|
var _b;
|
|
40652
40652
|
const bftMajorityThreshold = calculateBftMajorityThreshold(config2.endpointPool.length);
|
|
40653
40653
|
const failureThreshold = config2.endpointPool.length - bftMajorityThreshold + 1;
|
|
@@ -40658,7 +40658,7 @@ function requireFailoverStrategies() {
|
|
|
40658
40658
|
const promises = availableNodes.map((node2) => __awaiter2(this, void 0, void 0, function* () {
|
|
40659
40659
|
try {
|
|
40660
40660
|
const requestTimeout = timeoutOverride !== null && timeoutOverride !== void 0 ? timeoutOverride : config2.responseTimeout;
|
|
40661
|
-
const response = yield (0, httpUtil_1.handleRequest)(method,
|
|
40661
|
+
const response = yield (0, httpUtil_1.handleRequest)(method, path3, node2.url, requestTimeout, postObject);
|
|
40662
40662
|
const { statusCode } = response;
|
|
40663
40663
|
if (statusCode && (0, http_utils_1.isSuccessfulStatusCode)(statusCode)) {
|
|
40664
40664
|
outcomes.push({ type: "SUCCESS", result: response });
|
|
@@ -40705,7 +40705,7 @@ function requireFailoverStrategies() {
|
|
|
40705
40705
|
});
|
|
40706
40706
|
}
|
|
40707
40707
|
function singleEndpoint(_a2) {
|
|
40708
|
-
return __awaiter2(this, arguments, void 0, function* ({ method, path:
|
|
40708
|
+
return __awaiter2(this, arguments, void 0, function* ({ method, path: path3, config: config2, postObject, timeoutOverride }) {
|
|
40709
40709
|
let statusCode = null;
|
|
40710
40710
|
let rspBody = null;
|
|
40711
40711
|
let error4 = null;
|
|
@@ -40716,7 +40716,7 @@ function requireFailoverStrategies() {
|
|
|
40716
40716
|
}
|
|
40717
40717
|
for (let attempt = 0; attempt < config2.attemptsPerEndpoint; attempt++) {
|
|
40718
40718
|
const requestTimeout = timeoutOverride !== null && timeoutOverride !== void 0 ? timeoutOverride : config2.responseTimeout;
|
|
40719
|
-
const response = yield (0, httpUtil_1.handleRequest)(method,
|
|
40719
|
+
const response = yield (0, httpUtil_1.handleRequest)(method, path3, endpoint.url, requestTimeout, postObject);
|
|
40720
40720
|
if (response) {
|
|
40721
40721
|
({ error: error4, statusCode, rspBody, transactionTimestamp } = response);
|
|
40722
40722
|
}
|
|
@@ -40731,7 +40731,7 @@ function requireFailoverStrategies() {
|
|
|
40731
40731
|
});
|
|
40732
40732
|
}
|
|
40733
40733
|
function retryRequest(_a2) {
|
|
40734
|
-
return __awaiter2(this, arguments, void 0, function* ({ method, path:
|
|
40734
|
+
return __awaiter2(this, arguments, void 0, function* ({ method, path: path3, config: config2, postObject, useNextNodeOnError, recoveryThreshold, timeoutOverride }) {
|
|
40735
40735
|
var _b, _c, _d;
|
|
40736
40736
|
let statusCode = null;
|
|
40737
40737
|
let rspBody = null;
|
|
@@ -40742,7 +40742,7 @@ function requireFailoverStrategies() {
|
|
|
40742
40742
|
for (const node2 of availableNodes) {
|
|
40743
40743
|
for (let attempt = 0; attempt < config2.attemptsPerEndpoint; attempt++) {
|
|
40744
40744
|
const requestTimeout = timeoutOverride !== null && timeoutOverride !== void 0 ? timeoutOverride : config2.responseTimeout;
|
|
40745
|
-
const response = yield (0, httpUtil_1.handleRequest)(method,
|
|
40745
|
+
const response = yield (0, httpUtil_1.handleRequest)(method, path3, node2.url, requestTimeout, postObject);
|
|
40746
40746
|
error4 = (_b = response === null || response === void 0 ? void 0 : response.error) !== null && _b !== void 0 ? _b : null;
|
|
40747
40747
|
statusCode = (_c = response === null || response === void 0 ? void 0 : response.statusCode) !== null && _c !== void 0 ? _c : null;
|
|
40748
40748
|
rspBody = (_d = response === null || response === void 0 ? void 0 : response.rspBody) !== null && _d !== void 0 ? _d : null;
|
|
@@ -40885,19 +40885,19 @@ function requireRequestWithFailoverStrategy() {
|
|
|
40885
40885
|
const enums_12 = enums;
|
|
40886
40886
|
const failoverStrategies_1 = requireFailoverStrategies();
|
|
40887
40887
|
function requestWithFailoverStrategy$1(method_1, path_1, config_1, postObject_1) {
|
|
40888
|
-
return __awaiter2(this, arguments, void 0, function* (method,
|
|
40888
|
+
return __awaiter2(this, arguments, void 0, function* (method, path3, config2, postObject, forceSingleEndpoint = false, timeoutOverride) {
|
|
40889
40889
|
switch (config2.failoverStrategy) {
|
|
40890
40890
|
case enums_12.FailoverStrategy.AbortOnError:
|
|
40891
|
-
return yield (0, failoverStrategies_1.abortOnError)({ method, path:
|
|
40891
|
+
return yield (0, failoverStrategies_1.abortOnError)({ method, path: path3, config: config2, postObject, timeoutOverride });
|
|
40892
40892
|
case enums_12.FailoverStrategy.TryNextOnError:
|
|
40893
|
-
return yield (0, failoverStrategies_1.tryNextOnError)({ method, path:
|
|
40893
|
+
return yield (0, failoverStrategies_1.tryNextOnError)({ method, path: path3, config: config2, postObject, timeoutOverride });
|
|
40894
40894
|
case enums_12.FailoverStrategy.SingleEndpoint:
|
|
40895
|
-
return yield (0, failoverStrategies_1.singleEndpoint)({ method, path:
|
|
40895
|
+
return yield (0, failoverStrategies_1.singleEndpoint)({ method, path: path3, config: config2, postObject, timeoutOverride });
|
|
40896
40896
|
case enums_12.FailoverStrategy.QueryMajority:
|
|
40897
40897
|
if (forceSingleEndpoint) {
|
|
40898
|
-
return yield (0, failoverStrategies_1.singleEndpoint)({ method, path:
|
|
40898
|
+
return yield (0, failoverStrategies_1.singleEndpoint)({ method, path: path3, config: config2, postObject, timeoutOverride });
|
|
40899
40899
|
}
|
|
40900
|
-
return yield (0, failoverStrategies_1.queryMajority)({ method, path:
|
|
40900
|
+
return yield (0, failoverStrategies_1.queryMajority)({ method, path: path3, config: config2, postObject, timeoutOverride });
|
|
40901
40901
|
default:
|
|
40902
40902
|
throw new Error(`Unsupported failover strategy: ${config2.failoverStrategy}`);
|
|
40903
40903
|
}
|
|
@@ -42096,7 +42096,7 @@ var networkSettings = {};
|
|
|
42096
42096
|
const restNetworkSettingsValidationContext = RestNetworkSettingsSchema.safeParse(networkSettings2);
|
|
42097
42097
|
if ("error" in restNetworkSettingsValidationContext) {
|
|
42098
42098
|
const { error: { issues } = {} } = restNetworkSettingsValidationContext;
|
|
42099
|
-
const errorMessage2 = issues === null || issues === void 0 ? void 0 : issues.map(({ message, path:
|
|
42099
|
+
const errorMessage2 = issues === null || issues === void 0 ? void 0 : issues.map(({ message, path: path3 }) => `${path3[0]}: ${message}`).join(", ");
|
|
42100
42100
|
if (throwOnError) {
|
|
42101
42101
|
throw new Error(errorMessage2);
|
|
42102
42102
|
}
|
|
@@ -44360,6 +44360,13 @@ function buildAllowedJudgeHosts() {
|
|
|
44360
44360
|
]);
|
|
44361
44361
|
}
|
|
44362
44362
|
var ALLOWED_JUDGE_HOSTS = buildAllowedJudgeHosts();
|
|
44363
|
+
function isAllowlistedJudgeHost(endpoint) {
|
|
44364
|
+
try {
|
|
44365
|
+
return ALLOWED_JUDGE_HOSTS.has(new URL(endpoint).hostname.toLowerCase());
|
|
44366
|
+
} catch {
|
|
44367
|
+
return false;
|
|
44368
|
+
}
|
|
44369
|
+
}
|
|
44363
44370
|
function validateJudgeEndpoint(judge) {
|
|
44364
44371
|
const policy = judge?.policy === "self-hosted" ? "self-hosted" : "default";
|
|
44365
44372
|
const candidate = judge?.endpoint?.trim() || DEFAULT_ENDPOINT;
|
|
@@ -44409,11 +44416,23 @@ var AtbashAPIError = class extends Error {
|
|
|
44409
44416
|
status;
|
|
44410
44417
|
/** Raw response body text (may be empty). */
|
|
44411
44418
|
body;
|
|
44412
|
-
|
|
44413
|
-
|
|
44419
|
+
/**
|
|
44420
|
+
* Request path this status came from, e.g. `/api/v1/judge` — absent when the
|
|
44421
|
+
* request never reached a response (transport failures carry status 0).
|
|
44422
|
+
*
|
|
44423
|
+
* A status alone does not say what failed. Several routes answer one call, and
|
|
44424
|
+
* more than one of them can 404: a caller reading only `404` cannot tell "this
|
|
44425
|
+
* agent is not registered" from "the chain-routing lookup did not resolve", and
|
|
44426
|
+
* has to guess from the body's prose — which a 404 raised before any handler
|
|
44427
|
+
* ran does not carry. The path is the fact that settles it.
|
|
44428
|
+
*/
|
|
44429
|
+
path;
|
|
44430
|
+
constructor(status, body, statusText = "", endpoint = DEFAULT_ENDPOINT, path3) {
|
|
44431
|
+
super(enrich(status, body, statusText, endpoint, path3));
|
|
44414
44432
|
this.name = "AtbashAPIError";
|
|
44415
44433
|
this.status = status;
|
|
44416
44434
|
this.body = body;
|
|
44435
|
+
this.path = path3;
|
|
44417
44436
|
}
|
|
44418
44437
|
};
|
|
44419
44438
|
var SignatureVerificationError = class extends Error {
|
|
@@ -44422,9 +44441,9 @@ var SignatureVerificationError = class extends Error {
|
|
|
44422
44441
|
this.name = "SignatureVerificationError";
|
|
44423
44442
|
}
|
|
44424
44443
|
};
|
|
44425
|
-
function enrich(status, body, statusText, endpoint) {
|
|
44444
|
+
function enrich(status, body, statusText, endpoint, path3) {
|
|
44426
44445
|
const dashboard = endpoint.replace(/\/+$/, "") || DEFAULT_ENDPOINT;
|
|
44427
|
-
let msg = `API error ${status}: ${body || statusText}`;
|
|
44446
|
+
let msg = `API error ${status}${path3 ? ` from ${path3}` : ""}: ${body || statusText}`;
|
|
44428
44447
|
const lowered = body.toLowerCase();
|
|
44429
44448
|
if (lowered.includes("agent not registered")) {
|
|
44430
44449
|
msg += `
|
|
@@ -44455,8 +44474,8 @@ var HttpClient = class {
|
|
|
44455
44474
|
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
44456
44475
|
this.timeoutMs = timeoutMs;
|
|
44457
44476
|
}
|
|
44458
|
-
buildUrl(
|
|
44459
|
-
const url = new URL(this.baseUrl +
|
|
44477
|
+
buildUrl(path3, query) {
|
|
44478
|
+
const url = new URL(this.baseUrl + path3);
|
|
44460
44479
|
if (query) {
|
|
44461
44480
|
for (const [k, v] of Object.entries(query)) {
|
|
44462
44481
|
if (v !== void 0 && v !== null && v !== "") {
|
|
@@ -44466,14 +44485,14 @@ var HttpClient = class {
|
|
|
44466
44485
|
}
|
|
44467
44486
|
return url.toString();
|
|
44468
44487
|
}
|
|
44469
|
-
async get(
|
|
44470
|
-
return this.fetch(this.buildUrl(
|
|
44488
|
+
async get(path3, query, headers) {
|
|
44489
|
+
return this.fetch(this.buildUrl(path3, query), {
|
|
44471
44490
|
method: "GET",
|
|
44472
44491
|
...headers && { headers }
|
|
44473
44492
|
});
|
|
44474
44493
|
}
|
|
44475
|
-
async post(
|
|
44476
|
-
return this.fetch(this.buildUrl(
|
|
44494
|
+
async post(path3, body, headers) {
|
|
44495
|
+
return this.fetch(this.buildUrl(path3), {
|
|
44477
44496
|
method: "POST",
|
|
44478
44497
|
headers: { "Content-Type": "application/json", ...headers },
|
|
44479
44498
|
body: JSON.stringify(body)
|
|
@@ -44516,6 +44535,13 @@ function classifyTransportError(err, url, method, timeoutMs) {
|
|
|
44516
44535
|
{ cause: err }
|
|
44517
44536
|
);
|
|
44518
44537
|
}
|
|
44538
|
+
if (code2 === "UND_ERR_CONNECT_TIMEOUT") {
|
|
44539
|
+
return new HttpTransportError(
|
|
44540
|
+
"timeout",
|
|
44541
|
+
`${method} ${url} could not establish a connection before the transport deadline \u2014 check the endpoint and network`,
|
|
44542
|
+
{ cause: err }
|
|
44543
|
+
);
|
|
44544
|
+
}
|
|
44519
44545
|
if (code2 === "ENOTFOUND" || code2 === "EAI_AGAIN") {
|
|
44520
44546
|
return new HttpTransportError(
|
|
44521
44547
|
"dns",
|
|
@@ -44777,17 +44803,23 @@ var Atbash = class _Atbash {
|
|
|
44777
44803
|
verifying: this.verifyPubKey ? "with response-signature pubkey configured" : "without signature verification"
|
|
44778
44804
|
});
|
|
44779
44805
|
}
|
|
44780
|
-
|
|
44781
|
-
|
|
44782
|
-
|
|
44783
|
-
|
|
44784
|
-
|
|
44785
|
-
|
|
44786
|
-
|
|
44787
|
-
|
|
44788
|
-
|
|
44789
|
-
|
|
44790
|
-
|
|
44806
|
+
if (isAllowlistedJudgeHost(this.endpoint)) {
|
|
44807
|
+
try {
|
|
44808
|
+
setupTelemetry({
|
|
44809
|
+
enabled: true,
|
|
44810
|
+
endpoint: this.endpoint,
|
|
44811
|
+
getAuthHeaders: () => this.authHeaders()
|
|
44812
|
+
});
|
|
44813
|
+
} catch (err) {
|
|
44814
|
+
this.logger.warn?.(
|
|
44815
|
+
"[atbash] telemetry setup failed \u2014 continuing without metrics",
|
|
44816
|
+
{ error: String(err) }
|
|
44817
|
+
);
|
|
44818
|
+
}
|
|
44819
|
+
} else {
|
|
44820
|
+
this.logger.info?.(
|
|
44821
|
+
"[atbash] telemetry disabled \u2014 the agent bearer is only sent to hosts that already receive it, and this judge endpoint is not one",
|
|
44822
|
+
{ endpoint: this.endpoint }
|
|
44791
44823
|
);
|
|
44792
44824
|
}
|
|
44793
44825
|
}
|
|
@@ -45607,8 +45639,8 @@ var Atbash = class _Atbash {
|
|
|
45607
45639
|
async riskEnginePost(body, network, brid) {
|
|
45608
45640
|
let resp;
|
|
45609
45641
|
try {
|
|
45610
|
-
const
|
|
45611
|
-
resp = await this.http.post(
|
|
45642
|
+
const path3 = network ? `/api/risk-engine?network=${encodeURIComponent(network)}` : "/api/risk-engine";
|
|
45643
|
+
resp = await this.http.post(path3, body, this.authHeaders(brid));
|
|
45612
45644
|
} catch (err) {
|
|
45613
45645
|
throw this.transportError(err);
|
|
45614
45646
|
}
|
|
@@ -45668,7 +45700,8 @@ var Atbash = class _Atbash {
|
|
|
45668
45700
|
resp.status,
|
|
45669
45701
|
await safeText(resp),
|
|
45670
45702
|
resp.statusText,
|
|
45671
|
-
this.endpoint
|
|
45703
|
+
this.endpoint,
|
|
45704
|
+
requestPath(resp.url)
|
|
45672
45705
|
);
|
|
45673
45706
|
}
|
|
45674
45707
|
/**
|
|
@@ -45810,6 +45843,14 @@ function parseJson(bytes) {
|
|
|
45810
45843
|
const parsed = tryParseJson(bytes.toString("utf-8"));
|
|
45811
45844
|
return parsed === void 0 ? {} : parsed;
|
|
45812
45845
|
}
|
|
45846
|
+
function requestPath(url) {
|
|
45847
|
+
if (!url) return void 0;
|
|
45848
|
+
try {
|
|
45849
|
+
return new URL(url).pathname || void 0;
|
|
45850
|
+
} catch {
|
|
45851
|
+
return void 0;
|
|
45852
|
+
}
|
|
45853
|
+
}
|
|
45813
45854
|
async function safeText(resp) {
|
|
45814
45855
|
try {
|
|
45815
45856
|
return await resp.text();
|
|
@@ -45839,27 +45880,18 @@ function truncate(text, limit = MAX_ACTION_LEN) {
|
|
|
45839
45880
|
return text.slice(0, limit) + "\u2026";
|
|
45840
45881
|
}
|
|
45841
45882
|
|
|
45842
|
-
// src-ts/key-path.ts
|
|
45883
|
+
// src-ts/browser/key-path.ts
|
|
45843
45884
|
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
45844
45885
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
45845
|
-
import { homedir } from "os";
|
|
45846
|
-
import { join as join2 } from "path";
|
|
45847
|
-
var KEY_DIR_REL = ".config/atbash";
|
|
45848
45886
|
var KEY_FILENAMES = ["guard-client-key", "atbash-client-key"];
|
|
45849
|
-
|
|
45850
|
-
|
|
45851
|
-
}
|
|
45852
|
-
function expandHome(p) {
|
|
45853
|
-
if (!p.startsWith("~/")) return p;
|
|
45854
|
-
return join2(home(), p.slice(2));
|
|
45855
|
-
}
|
|
45887
|
+
var unavailable = (name2) => {
|
|
45888
|
+
throw new Error(`${name2} is not available in the browser bundle`);
|
|
45889
|
+
};
|
|
45856
45890
|
function keyPathCandidates() {
|
|
45857
|
-
return
|
|
45891
|
+
return unavailable("keyPathCandidates");
|
|
45858
45892
|
}
|
|
45859
|
-
function chooseKeyPath(
|
|
45860
|
-
|
|
45861
|
-
const candidates = keyPathCandidates();
|
|
45862
|
-
return candidates.find(exists) ?? candidates[0];
|
|
45893
|
+
function chooseKeyPath(_input, _exists) {
|
|
45894
|
+
return unavailable("chooseKeyPath");
|
|
45863
45895
|
}
|
|
45864
45896
|
|
|
45865
45897
|
// src-ts/redact.ts
|
|
@@ -46079,112 +46111,12 @@ function classifyMemoryWrite(_event, _ctx, _opts = {}) {
|
|
|
46079
46111
|
throw new Error(`classifyMemoryWrite ${STUB_MSG4}`);
|
|
46080
46112
|
}
|
|
46081
46113
|
|
|
46082
|
-
// src-ts/memory
|
|
46114
|
+
// src-ts/browser/memory-guard.ts
|
|
46083
46115
|
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
46084
46116
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46085
|
-
|
|
46086
|
-
function
|
|
46087
|
-
|
|
46088
|
-
const ev = event ?? {};
|
|
46089
|
-
const c = ctx ?? {};
|
|
46090
|
-
const argsCandidate = ev.params ?? c.params ?? ev.args ?? c.args ?? ev.arguments ?? c.arguments;
|
|
46091
|
-
const argsObj = argsCandidate && typeof argsCandidate === "object" ? argsCandidate : {};
|
|
46092
|
-
const argsKeys = Object.keys(argsObj).slice(0, 20);
|
|
46093
|
-
const pickedPath = typeof argsObj.file_path === "string" && argsObj.file_path || typeof argsObj.path === "string" && argsObj.path || typeof argsObj.filename === "string" && argsObj.filename || null;
|
|
46094
|
-
const editsArr = Array.isArray(argsObj.edits) ? argsObj.edits : null;
|
|
46095
|
-
const firstEditKeys = editsArr && editsArr[0] && typeof editsArr[0] === "object" ? Object.keys(editsArr[0]).slice(0, 10) : null;
|
|
46096
|
-
const tool = ev.toolName ?? c.tool?.name ?? c.toolName ?? c.name ?? "(none)";
|
|
46097
|
-
logger2.info("[atbash][probe] before_tool_call", {
|
|
46098
|
-
toolName: tool,
|
|
46099
|
-
eventKeys: Object.keys(ev).slice(0, 20),
|
|
46100
|
-
ctxKeys: Object.keys(c).slice(0, 20),
|
|
46101
|
-
argsKeys,
|
|
46102
|
-
pickedPath,
|
|
46103
|
-
firstEditKeys,
|
|
46104
|
-
editsCount: editsArr?.length,
|
|
46105
|
-
memoryWrite: !!memEntry,
|
|
46106
|
-
memoryPath: memEntry?.key
|
|
46107
|
-
});
|
|
46108
|
-
}
|
|
46109
|
-
async function guardMemoryWrite(input) {
|
|
46110
|
-
const {
|
|
46111
|
-
event,
|
|
46112
|
-
ctx,
|
|
46113
|
-
auth,
|
|
46114
|
-
endpoint,
|
|
46115
|
-
verifyPubKey,
|
|
46116
|
-
orgName,
|
|
46117
|
-
threshold,
|
|
46118
|
-
patterns,
|
|
46119
|
-
toolNames,
|
|
46120
|
-
enforce = true,
|
|
46121
|
-
debug: debug2 = false,
|
|
46122
|
-
logger: logger2
|
|
46123
|
-
} = input;
|
|
46124
|
-
const memEntry = classifyMemoryWrite(event, ctx, { patterns, toolNames });
|
|
46125
|
-
if (debug2) emitDebugProbe(event, ctx, memEntry, logger2);
|
|
46126
|
-
if (!memEntry) return { handled: false };
|
|
46127
|
-
let scanResult;
|
|
46128
|
-
try {
|
|
46129
|
-
scanResult = await scanMemory(memEntry, auth, {
|
|
46130
|
-
endpoint,
|
|
46131
|
-
verifyPubKey,
|
|
46132
|
-
orgName,
|
|
46133
|
-
threshold
|
|
46134
|
-
});
|
|
46135
|
-
} catch (err) {
|
|
46136
|
-
const reason = err instanceof Error ? err.message : String(err);
|
|
46137
|
-
logger2?.warn?.("[atbash] memory scan failed", {
|
|
46138
|
-
path: memEntry.key,
|
|
46139
|
-
reason
|
|
46140
|
-
});
|
|
46141
|
-
return {
|
|
46142
|
-
handled: true,
|
|
46143
|
-
decision: enforce ? { allow: false, block: true, reason } : { allow: true }
|
|
46144
|
-
};
|
|
46145
|
-
}
|
|
46146
|
-
if (scanResult.verdict === "red") {
|
|
46147
|
-
logger2?.warn?.("[atbash] memory BLOCK", {
|
|
46148
|
-
path: memEntry.key,
|
|
46149
|
-
reason: scanResult.reason
|
|
46150
|
-
});
|
|
46151
|
-
return {
|
|
46152
|
-
handled: true,
|
|
46153
|
-
decision: enforce ? { allow: false, block: true, reason: scanResult.reason } : { allow: true },
|
|
46154
|
-
scanResult,
|
|
46155
|
-
committed: false
|
|
46156
|
-
};
|
|
46157
|
-
}
|
|
46158
|
-
const filePath = path3.basename(memEntry.key);
|
|
46159
|
-
commitMemoryVersion(memEntry.value, auth, {
|
|
46160
|
-
score: scanResult.score,
|
|
46161
|
-
filePath,
|
|
46162
|
-
orgName,
|
|
46163
|
-
endpoint,
|
|
46164
|
-
verifyPubKey
|
|
46165
|
-
}).catch((err) => {
|
|
46166
|
-
const reason = err instanceof Error ? err.message : String(err);
|
|
46167
|
-
logger2?.warn?.("[atbash] memory commit to chain failed", {
|
|
46168
|
-
path: memEntry.key,
|
|
46169
|
-
filePath,
|
|
46170
|
-
reason
|
|
46171
|
-
});
|
|
46172
|
-
});
|
|
46173
|
-
logger2?.info?.(
|
|
46174
|
-
scanResult.verdict === "yellow" ? "[atbash] memory HOLD" : "[atbash] memory ALLOW",
|
|
46175
|
-
{
|
|
46176
|
-
path: memEntry.key,
|
|
46177
|
-
filePath,
|
|
46178
|
-
score: scanResult.score,
|
|
46179
|
-
reason: scanResult.reason
|
|
46180
|
-
}
|
|
46181
|
-
);
|
|
46182
|
-
return {
|
|
46183
|
-
handled: true,
|
|
46184
|
-
decision: { allow: true },
|
|
46185
|
-
scanResult,
|
|
46186
|
-
committed: true
|
|
46187
|
-
};
|
|
46117
|
+
var STUB_MSG5 = "not available in @atbash/sdk browser bundle \u2014 guard memory writes agent-side";
|
|
46118
|
+
async function guardMemoryWrite(_input) {
|
|
46119
|
+
throw new Error(`guardMemoryWrite ${STUB_MSG5}`);
|
|
46188
46120
|
}
|
|
46189
46121
|
|
|
46190
46122
|
// src-ts/memory/sync.ts
|
|
@@ -46206,7 +46138,7 @@ async function syncLocalMemory(auth, pointer, opts = {}) {
|
|
|
46206
46138
|
if (withinTtl) {
|
|
46207
46139
|
return { drifted: false, checked: false, pointer };
|
|
46208
46140
|
}
|
|
46209
|
-
const currentId = await getActiveMemoryId(auth, opts.chainOpts);
|
|
46141
|
+
const currentId = await getActiveMemoryId(auth, opts.chainOpts, opts.filePath);
|
|
46210
46142
|
const nextPointer = { activeId: currentId, checkedAt: now };
|
|
46211
46143
|
if (currentId === pointer.activeId) {
|
|
46212
46144
|
return { drifted: false, checked: true, pointer: nextPointer };
|
|
@@ -46224,7 +46156,7 @@ async function syncLocalMemory(auth, pointer, opts = {}) {
|
|
|
46224
46156
|
// src-ts/browser/memory-pointer-store.ts
|
|
46225
46157
|
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
46226
46158
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46227
|
-
var
|
|
46159
|
+
var unavailable2 = (name2) => {
|
|
46228
46160
|
throw new Error(`${name2} is not available in the browser bundle`);
|
|
46229
46161
|
};
|
|
46230
46162
|
var PointerStore = class {
|
|
@@ -46238,38 +46170,38 @@ var PointerStore = class {
|
|
|
46238
46170
|
}
|
|
46239
46171
|
};
|
|
46240
46172
|
function defaultPointerPath(_workspaceDir) {
|
|
46241
|
-
return
|
|
46173
|
+
return unavailable2("defaultPointerPath");
|
|
46242
46174
|
}
|
|
46243
46175
|
|
|
46244
46176
|
// src-ts/browser/memory-file-logger.ts
|
|
46245
46177
|
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
46246
46178
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46247
|
-
var
|
|
46179
|
+
var unavailable3 = (name2) => {
|
|
46248
46180
|
throw new Error(`${name2} is not available in the browser bundle`);
|
|
46249
46181
|
};
|
|
46250
46182
|
function createFileLogger(_logFilePath, _hostLogger) {
|
|
46251
|
-
return
|
|
46183
|
+
return unavailable3("createFileLogger");
|
|
46252
46184
|
}
|
|
46253
46185
|
function defaultPluginLogPath(_workspaceDir) {
|
|
46254
|
-
return
|
|
46186
|
+
return unavailable3("defaultPluginLogPath");
|
|
46255
46187
|
}
|
|
46256
46188
|
|
|
46257
46189
|
// src-ts/browser/memory-read-classifier.ts
|
|
46258
46190
|
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
46259
46191
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46260
|
-
var
|
|
46192
|
+
var STUB_MSG6 = "not available in @atbash/sdk browser bundle \u2014 classify memory reads server-side";
|
|
46261
46193
|
var DEFAULT_MEMORY_READ_TOOL_NAMES = [
|
|
46262
46194
|
"memory_search",
|
|
46263
46195
|
"memory_get"
|
|
46264
46196
|
];
|
|
46265
46197
|
function classifyMemoryRead(_event, _ctx, _opts = {}) {
|
|
46266
|
-
throw new Error(`classifyMemoryRead ${
|
|
46198
|
+
throw new Error(`classifyMemoryRead ${STUB_MSG6}`);
|
|
46267
46199
|
}
|
|
46268
46200
|
|
|
46269
46201
|
// src-ts/browser/memory-guard-manager.ts
|
|
46270
46202
|
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
46271
46203
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46272
|
-
var
|
|
46204
|
+
var unavailable4 = (name2) => {
|
|
46273
46205
|
throw new Error(`${name2} is not available in the browser bundle`);
|
|
46274
46206
|
};
|
|
46275
46207
|
var MemoryGuardManager = class {
|
|
@@ -46289,7 +46221,7 @@ var MemoryGuardManager = class {
|
|
|
46289
46221
|
}
|
|
46290
46222
|
};
|
|
46291
46223
|
function createMemoryGuardManager(_opts) {
|
|
46292
|
-
return
|
|
46224
|
+
return unavailable4("createMemoryGuardManager");
|
|
46293
46225
|
}
|
|
46294
46226
|
|
|
46295
46227
|
// src-ts/index.ts
|