@atbash/sdk 0.16.3-dev.0 → 0.16.4-dev.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/browser.mjs +71 -195
- package/package.json +7 -7
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
|
}
|
|
@@ -44420,12 +44420,12 @@ var AtbashAPIError = class extends Error {
|
|
|
44420
44420
|
* ran does not carry. The path is the fact that settles it.
|
|
44421
44421
|
*/
|
|
44422
44422
|
path;
|
|
44423
|
-
constructor(status, body, statusText = "", endpoint = DEFAULT_ENDPOINT,
|
|
44424
|
-
super(enrich(status, body, statusText, endpoint,
|
|
44423
|
+
constructor(status, body, statusText = "", endpoint = DEFAULT_ENDPOINT, path3) {
|
|
44424
|
+
super(enrich(status, body, statusText, endpoint, path3));
|
|
44425
44425
|
this.name = "AtbashAPIError";
|
|
44426
44426
|
this.status = status;
|
|
44427
44427
|
this.body = body;
|
|
44428
|
-
this.path =
|
|
44428
|
+
this.path = path3;
|
|
44429
44429
|
}
|
|
44430
44430
|
};
|
|
44431
44431
|
var SignatureVerificationError = class extends Error {
|
|
@@ -44434,9 +44434,9 @@ var SignatureVerificationError = class extends Error {
|
|
|
44434
44434
|
this.name = "SignatureVerificationError";
|
|
44435
44435
|
}
|
|
44436
44436
|
};
|
|
44437
|
-
function enrich(status, body, statusText, endpoint,
|
|
44437
|
+
function enrich(status, body, statusText, endpoint, path3) {
|
|
44438
44438
|
const dashboard = endpoint.replace(/\/+$/, "") || DEFAULT_ENDPOINT;
|
|
44439
|
-
let msg = `API error ${status}${
|
|
44439
|
+
let msg = `API error ${status}${path3 ? ` from ${path3}` : ""}: ${body || statusText}`;
|
|
44440
44440
|
const lowered = body.toLowerCase();
|
|
44441
44441
|
if (lowered.includes("agent not registered")) {
|
|
44442
44442
|
msg += `
|
|
@@ -44467,8 +44467,8 @@ var HttpClient = class {
|
|
|
44467
44467
|
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
44468
44468
|
this.timeoutMs = timeoutMs;
|
|
44469
44469
|
}
|
|
44470
|
-
buildUrl(
|
|
44471
|
-
const url = new URL(this.baseUrl +
|
|
44470
|
+
buildUrl(path3, query) {
|
|
44471
|
+
const url = new URL(this.baseUrl + path3);
|
|
44472
44472
|
if (query) {
|
|
44473
44473
|
for (const [k, v] of Object.entries(query)) {
|
|
44474
44474
|
if (v !== void 0 && v !== null && v !== "") {
|
|
@@ -44478,14 +44478,14 @@ var HttpClient = class {
|
|
|
44478
44478
|
}
|
|
44479
44479
|
return url.toString();
|
|
44480
44480
|
}
|
|
44481
|
-
async get(
|
|
44482
|
-
return this.fetch(this.buildUrl(
|
|
44481
|
+
async get(path3, query, headers) {
|
|
44482
|
+
return this.fetch(this.buildUrl(path3, query), {
|
|
44483
44483
|
method: "GET",
|
|
44484
44484
|
...headers && { headers }
|
|
44485
44485
|
});
|
|
44486
44486
|
}
|
|
44487
|
-
async post(
|
|
44488
|
-
return this.fetch(this.buildUrl(
|
|
44487
|
+
async post(path3, body, headers) {
|
|
44488
|
+
return this.fetch(this.buildUrl(path3), {
|
|
44489
44489
|
method: "POST",
|
|
44490
44490
|
headers: { "Content-Type": "application/json", ...headers },
|
|
44491
44491
|
body: JSON.stringify(body)
|
|
@@ -45625,8 +45625,8 @@ var Atbash = class _Atbash {
|
|
|
45625
45625
|
async riskEnginePost(body, network, brid) {
|
|
45626
45626
|
let resp;
|
|
45627
45627
|
try {
|
|
45628
|
-
const
|
|
45629
|
-
resp = await this.http.post(
|
|
45628
|
+
const path3 = network ? `/api/risk-engine?network=${encodeURIComponent(network)}` : "/api/risk-engine";
|
|
45629
|
+
resp = await this.http.post(path3, body, this.authHeaders(brid));
|
|
45630
45630
|
} catch (err) {
|
|
45631
45631
|
throw this.transportError(err);
|
|
45632
45632
|
}
|
|
@@ -45866,27 +45866,18 @@ function truncate(text, limit = MAX_ACTION_LEN) {
|
|
|
45866
45866
|
return text.slice(0, limit) + "\u2026";
|
|
45867
45867
|
}
|
|
45868
45868
|
|
|
45869
|
-
// src-ts/key-path.ts
|
|
45869
|
+
// src-ts/browser/key-path.ts
|
|
45870
45870
|
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
45871
45871
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
45872
|
-
import { homedir } from "os";
|
|
45873
|
-
import { join as join2 } from "path";
|
|
45874
|
-
var KEY_DIR_REL = ".config/atbash";
|
|
45875
45872
|
var KEY_FILENAMES = ["guard-client-key", "atbash-client-key"];
|
|
45876
|
-
|
|
45877
|
-
|
|
45878
|
-
}
|
|
45879
|
-
function expandHome(p) {
|
|
45880
|
-
if (!p.startsWith("~/")) return p;
|
|
45881
|
-
return join2(home(), p.slice(2));
|
|
45882
|
-
}
|
|
45873
|
+
var unavailable = (name2) => {
|
|
45874
|
+
throw new Error(`${name2} is not available in the browser bundle`);
|
|
45875
|
+
};
|
|
45883
45876
|
function keyPathCandidates() {
|
|
45884
|
-
return
|
|
45877
|
+
return unavailable("keyPathCandidates");
|
|
45885
45878
|
}
|
|
45886
|
-
function chooseKeyPath(
|
|
45887
|
-
|
|
45888
|
-
const candidates = keyPathCandidates();
|
|
45889
|
-
return candidates.find(exists) ?? candidates[0];
|
|
45879
|
+
function chooseKeyPath(_input, _exists) {
|
|
45880
|
+
return unavailable("chooseKeyPath");
|
|
45890
45881
|
}
|
|
45891
45882
|
|
|
45892
45883
|
// src-ts/redact.ts
|
|
@@ -46106,127 +46097,12 @@ function classifyMemoryWrite(_event, _ctx, _opts = {}) {
|
|
|
46106
46097
|
throw new Error(`classifyMemoryWrite ${STUB_MSG4}`);
|
|
46107
46098
|
}
|
|
46108
46099
|
|
|
46109
|
-
// src-ts/memory
|
|
46100
|
+
// src-ts/browser/memory-guard.ts
|
|
46110
46101
|
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
46111
46102
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46112
|
-
|
|
46113
|
-
function
|
|
46114
|
-
|
|
46115
|
-
const ev = event ?? {};
|
|
46116
|
-
const c = ctx ?? {};
|
|
46117
|
-
const argsCandidate = ev.params ?? c.params ?? ev.args ?? c.args ?? ev.arguments ?? c.arguments;
|
|
46118
|
-
const argsObj = argsCandidate && typeof argsCandidate === "object" ? argsCandidate : {};
|
|
46119
|
-
const argsKeys = Object.keys(argsObj).slice(0, 20);
|
|
46120
|
-
const pickedPath = typeof argsObj.file_path === "string" && argsObj.file_path || typeof argsObj.path === "string" && argsObj.path || typeof argsObj.filename === "string" && argsObj.filename || null;
|
|
46121
|
-
const editsArr = Array.isArray(argsObj.edits) ? argsObj.edits : null;
|
|
46122
|
-
const firstEditKeys = editsArr && editsArr[0] && typeof editsArr[0] === "object" ? Object.keys(editsArr[0]).slice(0, 10) : null;
|
|
46123
|
-
const tool = ev.toolName ?? c.tool?.name ?? c.toolName ?? c.name ?? "(none)";
|
|
46124
|
-
logger2.info("[atbash][probe] before_tool_call", {
|
|
46125
|
-
toolName: tool,
|
|
46126
|
-
eventKeys: Object.keys(ev).slice(0, 20),
|
|
46127
|
-
ctxKeys: Object.keys(c).slice(0, 20),
|
|
46128
|
-
argsKeys,
|
|
46129
|
-
pickedPath,
|
|
46130
|
-
firstEditKeys,
|
|
46131
|
-
editsCount: editsArr?.length,
|
|
46132
|
-
memoryWrite: !!memEntry,
|
|
46133
|
-
memoryPath: memEntry?.key
|
|
46134
|
-
});
|
|
46135
|
-
}
|
|
46136
|
-
async function guardMemoryWrite(input) {
|
|
46137
|
-
const {
|
|
46138
|
-
event,
|
|
46139
|
-
ctx,
|
|
46140
|
-
auth,
|
|
46141
|
-
endpoint,
|
|
46142
|
-
verifyPubKey,
|
|
46143
|
-
orgName,
|
|
46144
|
-
threshold,
|
|
46145
|
-
patterns,
|
|
46146
|
-
toolNames,
|
|
46147
|
-
enforce = true,
|
|
46148
|
-
debug: debug2 = false,
|
|
46149
|
-
logger: logger2
|
|
46150
|
-
} = input;
|
|
46151
|
-
let memEntry;
|
|
46152
|
-
try {
|
|
46153
|
-
memEntry = classifyMemoryWrite(event, ctx, { patterns, toolNames });
|
|
46154
|
-
} catch (err) {
|
|
46155
|
-
const why = err instanceof Error ? err.message : String(err);
|
|
46156
|
-
logger2?.warn?.("[atbash] memory classifier refused this tool call's input", { reason: why });
|
|
46157
|
-
if (!enforce) return { handled: false };
|
|
46158
|
-
return {
|
|
46159
|
-
handled: true,
|
|
46160
|
-
decision: {
|
|
46161
|
-
allow: false,
|
|
46162
|
-
block: true,
|
|
46163
|
-
reason: `Memory protection could not read this tool call (${why}); blocked because it could not be checked.`
|
|
46164
|
-
}
|
|
46165
|
-
};
|
|
46166
|
-
}
|
|
46167
|
-
if (debug2) emitDebugProbe(event, ctx, memEntry, logger2);
|
|
46168
|
-
if (!memEntry) return { handled: false };
|
|
46169
|
-
let scanResult;
|
|
46170
|
-
try {
|
|
46171
|
-
scanResult = await scanMemory(memEntry, auth, {
|
|
46172
|
-
endpoint,
|
|
46173
|
-
verifyPubKey,
|
|
46174
|
-
orgName,
|
|
46175
|
-
threshold
|
|
46176
|
-
});
|
|
46177
|
-
} catch (err) {
|
|
46178
|
-
const reason = err instanceof Error ? err.message : String(err);
|
|
46179
|
-
logger2?.warn?.("[atbash] memory scan failed", {
|
|
46180
|
-
path: memEntry.key,
|
|
46181
|
-
reason
|
|
46182
|
-
});
|
|
46183
|
-
return {
|
|
46184
|
-
handled: true,
|
|
46185
|
-
decision: enforce ? { allow: false, block: true, reason } : { allow: true }
|
|
46186
|
-
};
|
|
46187
|
-
}
|
|
46188
|
-
if (scanResult.verdict === "red") {
|
|
46189
|
-
logger2?.warn?.("[atbash] memory BLOCK", {
|
|
46190
|
-
path: memEntry.key,
|
|
46191
|
-
reason: scanResult.reason
|
|
46192
|
-
});
|
|
46193
|
-
return {
|
|
46194
|
-
handled: true,
|
|
46195
|
-
decision: enforce ? { allow: false, block: true, reason: scanResult.reason } : { allow: true },
|
|
46196
|
-
scanResult,
|
|
46197
|
-
committed: false
|
|
46198
|
-
};
|
|
46199
|
-
}
|
|
46200
|
-
const filePath = path3.basename(memEntry.key);
|
|
46201
|
-
commitMemoryVersion(memEntry.value, auth, {
|
|
46202
|
-
score: scanResult.score,
|
|
46203
|
-
filePath,
|
|
46204
|
-
orgName,
|
|
46205
|
-
endpoint,
|
|
46206
|
-
verifyPubKey
|
|
46207
|
-
}).catch((err) => {
|
|
46208
|
-
const reason = err instanceof Error ? err.message : String(err);
|
|
46209
|
-
logger2?.warn?.("[atbash] memory commit to chain failed", {
|
|
46210
|
-
path: memEntry.key,
|
|
46211
|
-
filePath,
|
|
46212
|
-
reason
|
|
46213
|
-
});
|
|
46214
|
-
});
|
|
46215
|
-
logger2?.info?.(
|
|
46216
|
-
scanResult.verdict === "yellow" ? "[atbash] memory HOLD" : "[atbash] memory ALLOW",
|
|
46217
|
-
{
|
|
46218
|
-
path: memEntry.key,
|
|
46219
|
-
filePath,
|
|
46220
|
-
score: scanResult.score,
|
|
46221
|
-
reason: scanResult.reason
|
|
46222
|
-
}
|
|
46223
|
-
);
|
|
46224
|
-
return {
|
|
46225
|
-
handled: true,
|
|
46226
|
-
decision: { allow: true },
|
|
46227
|
-
scanResult,
|
|
46228
|
-
committed: true
|
|
46229
|
-
};
|
|
46103
|
+
var STUB_MSG5 = "not available in @atbash/sdk browser bundle \u2014 guard memory writes agent-side";
|
|
46104
|
+
async function guardMemoryWrite(_input) {
|
|
46105
|
+
throw new Error(`guardMemoryWrite ${STUB_MSG5}`);
|
|
46230
46106
|
}
|
|
46231
46107
|
|
|
46232
46108
|
// src-ts/memory/sync.ts
|
|
@@ -46266,7 +46142,7 @@ async function syncLocalMemory(auth, pointer, opts = {}) {
|
|
|
46266
46142
|
// src-ts/browser/memory-pointer-store.ts
|
|
46267
46143
|
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
46268
46144
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46269
|
-
var
|
|
46145
|
+
var unavailable2 = (name2) => {
|
|
46270
46146
|
throw new Error(`${name2} is not available in the browser bundle`);
|
|
46271
46147
|
};
|
|
46272
46148
|
var PointerStore = class {
|
|
@@ -46280,38 +46156,38 @@ var PointerStore = class {
|
|
|
46280
46156
|
}
|
|
46281
46157
|
};
|
|
46282
46158
|
function defaultPointerPath(_workspaceDir) {
|
|
46283
|
-
return
|
|
46159
|
+
return unavailable2("defaultPointerPath");
|
|
46284
46160
|
}
|
|
46285
46161
|
|
|
46286
46162
|
// src-ts/browser/memory-file-logger.ts
|
|
46287
46163
|
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
46288
46164
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46289
|
-
var
|
|
46165
|
+
var unavailable3 = (name2) => {
|
|
46290
46166
|
throw new Error(`${name2} is not available in the browser bundle`);
|
|
46291
46167
|
};
|
|
46292
46168
|
function createFileLogger(_logFilePath, _hostLogger) {
|
|
46293
|
-
return
|
|
46169
|
+
return unavailable3("createFileLogger");
|
|
46294
46170
|
}
|
|
46295
46171
|
function defaultPluginLogPath(_workspaceDir) {
|
|
46296
|
-
return
|
|
46172
|
+
return unavailable3("defaultPluginLogPath");
|
|
46297
46173
|
}
|
|
46298
46174
|
|
|
46299
46175
|
// src-ts/browser/memory-read-classifier.ts
|
|
46300
46176
|
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
46301
46177
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46302
|
-
var
|
|
46178
|
+
var STUB_MSG6 = "not available in @atbash/sdk browser bundle \u2014 classify memory reads server-side";
|
|
46303
46179
|
var DEFAULT_MEMORY_READ_TOOL_NAMES = [
|
|
46304
46180
|
"memory_search",
|
|
46305
46181
|
"memory_get"
|
|
46306
46182
|
];
|
|
46307
46183
|
function classifyMemoryRead(_event, _ctx, _opts = {}) {
|
|
46308
|
-
throw new Error(`classifyMemoryRead ${
|
|
46184
|
+
throw new Error(`classifyMemoryRead ${STUB_MSG6}`);
|
|
46309
46185
|
}
|
|
46310
46186
|
|
|
46311
46187
|
// src-ts/browser/memory-guard-manager.ts
|
|
46312
46188
|
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
46313
46189
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46314
|
-
var
|
|
46190
|
+
var unavailable4 = (name2) => {
|
|
46315
46191
|
throw new Error(`${name2} is not available in the browser bundle`);
|
|
46316
46192
|
};
|
|
46317
46193
|
var MemoryGuardManager = class {
|
|
@@ -46331,7 +46207,7 @@ var MemoryGuardManager = class {
|
|
|
46331
46207
|
}
|
|
46332
46208
|
};
|
|
46333
46209
|
function createMemoryGuardManager(_opts) {
|
|
46334
|
-
return
|
|
46210
|
+
return unavailable4("createMemoryGuardManager");
|
|
46335
46211
|
}
|
|
46336
46212
|
|
|
46337
46213
|
// src-ts/index.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atbash/sdk",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.4-dev.0",
|
|
4
4
|
"description": "TypeScript SDK for Atbash — the safety layer that evaluates AI agent actions against operator-defined policies before execution.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atbash",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"build:native": "napi build --platform --release",
|
|
55
55
|
"build:native:debug": "napi build --platform",
|
|
56
56
|
"gen:http": "openapi-typescript ../../spec/openapi.yaml -o src-ts/http/schema.ts",
|
|
57
|
-
"build:ts": "tsup",
|
|
57
|
+
"build:ts": "tsup && node scripts/assert-browser-bundle-clean.mjs",
|
|
58
58
|
"build": "npm run build:native && npm run build:ts",
|
|
59
59
|
"test:native": "node --test __test__/vector_parity.test.mjs",
|
|
60
60
|
"test:sdk": "node --test __test__/*.sdk.test.mjs",
|
|
@@ -89,10 +89,10 @@
|
|
|
89
89
|
"typescript-eslint": "^8.62.1"
|
|
90
90
|
},
|
|
91
91
|
"optionalDependencies": {
|
|
92
|
-
"@atbash/sdk-linux-x64-gnu": "0.16.
|
|
93
|
-
"@atbash/sdk-linux-arm64-gnu": "0.16.
|
|
94
|
-
"@atbash/sdk-linux-x64-musl": "0.16.
|
|
95
|
-
"@atbash/sdk-darwin-arm64": "0.16.
|
|
96
|
-
"@atbash/sdk-win32-x64-msvc": "0.16.
|
|
92
|
+
"@atbash/sdk-linux-x64-gnu": "0.16.4-dev.0",
|
|
93
|
+
"@atbash/sdk-linux-arm64-gnu": "0.16.4-dev.0",
|
|
94
|
+
"@atbash/sdk-linux-x64-musl": "0.16.4-dev.0",
|
|
95
|
+
"@atbash/sdk-darwin-arm64": "0.16.4-dev.0",
|
|
96
|
+
"@atbash/sdk-win32-x64-msvc": "0.16.4-dev.0"
|
|
97
97
|
}
|
|
98
98
|
}
|