@atbash/sdk 0.10.0-dev.0 → 0.10.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.d.mts +50 -27
- package/dist/browser.mjs +90 -31
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.mts +50 -27
- package/dist/index.d.ts +50 -27
- package/dist/index.js +68 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -6
- package/dist/index.mjs.map +1 -1
- package/index.d.ts +5 -5
- package/index.js +193 -80
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -2899,6 +2899,9 @@ function chainForNetwork(network) {
|
|
|
2899
2899
|
}
|
|
2900
2900
|
|
|
2901
2901
|
// src-ts/encrypted-toolcall.ts
|
|
2902
|
+
function columnAad(toolCallId, column) {
|
|
2903
|
+
return `${toolCallId}:${column}`;
|
|
2904
|
+
}
|
|
2902
2905
|
function normalizeActionForHash(action) {
|
|
2903
2906
|
return native.normalizeActionForHash(action);
|
|
2904
2907
|
}
|
|
@@ -2919,11 +2922,14 @@ function signEncryptedToolCall(toolCallId, action, context, toolName, toolArgsJs
|
|
|
2919
2922
|
}
|
|
2920
2923
|
|
|
2921
2924
|
// src-ts/endpoint.ts
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2925
|
+
function buildAllowedJudgeHosts() {
|
|
2926
|
+
return /* @__PURE__ */ new Set([
|
|
2927
|
+
"atbash.ai",
|
|
2928
|
+
"www.atbash.ai",
|
|
2929
|
+
new URL(DEFAULT_ENDPOINT).hostname.toLowerCase()
|
|
2930
|
+
]);
|
|
2931
|
+
}
|
|
2932
|
+
var ALLOWED_JUDGE_HOSTS = buildAllowedJudgeHosts();
|
|
2927
2933
|
function validateJudgeEndpoint(judge) {
|
|
2928
2934
|
const policy = judge?.policy === "self-hosted" ? "self-hosted" : "default";
|
|
2929
2935
|
const candidate = judge?.endpoint?.trim() || DEFAULT_ENDPOINT;
|
|
@@ -3285,6 +3291,8 @@ var Atbash = class _Atbash {
|
|
|
3285
3291
|
orgEncryptionPubKey;
|
|
3286
3292
|
/** When true (default), `auditToolCall` denies on any error. */
|
|
3287
3293
|
failClosed;
|
|
3294
|
+
/** Org key learned from the last agent-exists check, for this agent only. */
|
|
3295
|
+
_orgKeyFromChain = null;
|
|
3288
3296
|
logger;
|
|
3289
3297
|
http;
|
|
3290
3298
|
/**
|
|
@@ -3369,6 +3377,10 @@ var Atbash = class _Atbash {
|
|
|
3369
3377
|
);
|
|
3370
3378
|
await this.raiseIfError(resp);
|
|
3371
3379
|
const data = await this.json(resp);
|
|
3380
|
+
if (pk === this.auth.pubkey) {
|
|
3381
|
+
const key3 = data?.org_encryption_pubkey;
|
|
3382
|
+
this._orgKeyFromChain = typeof key3 === "string" && key3 ? key3 : null;
|
|
3383
|
+
}
|
|
3372
3384
|
return Boolean(data?.registered);
|
|
3373
3385
|
});
|
|
3374
3386
|
}
|
|
@@ -3399,7 +3411,7 @@ var Atbash = class _Atbash {
|
|
|
3399
3411
|
}
|
|
3400
3412
|
const toolCallId = generateToolCallId();
|
|
3401
3413
|
const brid = this.bridFromChainOpts(options.chainOpts);
|
|
3402
|
-
const orgKey = options.orgEncryptionPubKey ?? this.orgEncryptionPubKey;
|
|
3414
|
+
const orgKey = options.orgEncryptionPubKey ?? this.orgEncryptionPubKey ?? this._orgKeyFromChain;
|
|
3403
3415
|
try {
|
|
3404
3416
|
const signedHex = orgKey ? signEncryptedToolCall(
|
|
3405
3417
|
toolCallId,
|
|
@@ -42940,6 +42952,44 @@ function encryptedLength(plaintextByteLength) {
|
|
|
42940
42952
|
return native.encryptedLength(plaintextByteLength);
|
|
42941
42953
|
}
|
|
42942
42954
|
|
|
42955
|
+
// src-ts/crypto/envelope.ts
|
|
42956
|
+
var PREFIX = "atb1";
|
|
42957
|
+
var SEPARATOR = ".";
|
|
42958
|
+
function toBase64(bytes) {
|
|
42959
|
+
let binary = "";
|
|
42960
|
+
for (const b of bytes) binary += String.fromCharCode(b);
|
|
42961
|
+
return btoa(binary);
|
|
42962
|
+
}
|
|
42963
|
+
function fromBase64(text) {
|
|
42964
|
+
const binary = atob(text);
|
|
42965
|
+
const out = new Uint8Array(binary.length);
|
|
42966
|
+
for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i);
|
|
42967
|
+
return out;
|
|
42968
|
+
}
|
|
42969
|
+
function packEnvelope(payload, keyFingerprint = "", claimHash = "") {
|
|
42970
|
+
return [PREFIX, keyFingerprint, claimHash, toBase64(payload)].join(SEPARATOR);
|
|
42971
|
+
}
|
|
42972
|
+
function fieldWidthOk(value, hexChars) {
|
|
42973
|
+
return value.length === 0 ? true : value.length === hexChars && /^[0-9a-f]+$/.test(value);
|
|
42974
|
+
}
|
|
42975
|
+
function isEnvelope(value) {
|
|
42976
|
+
if (typeof value !== "string" || !value.startsWith(PREFIX + SEPARATOR)) return false;
|
|
42977
|
+
const parts = value.split(SEPARATOR);
|
|
42978
|
+
return parts.length >= 4 && fieldWidthOk(parts[1], 16) && fieldWidthOk(parts[2], 64);
|
|
42979
|
+
}
|
|
42980
|
+
function parseEnvelope(value) {
|
|
42981
|
+
if (!isEnvelope(value)) return null;
|
|
42982
|
+
const [, keyFingerprint, claimHash, ...rest] = value.split(SEPARATOR);
|
|
42983
|
+
try {
|
|
42984
|
+
return { keyFingerprint, claimHash, payload: fromBase64(rest.join(SEPARATOR)) };
|
|
42985
|
+
} catch {
|
|
42986
|
+
return null;
|
|
42987
|
+
}
|
|
42988
|
+
}
|
|
42989
|
+
function keyFingerprintOf(pubKeyHex) {
|
|
42990
|
+
return pubKeyHex.trim().replace(/^0x/i, "").toLowerCase().slice(0, 16);
|
|
42991
|
+
}
|
|
42992
|
+
|
|
42943
42993
|
// src-ts/index.ts
|
|
42944
42994
|
function isValidPrivateKey(hex) {
|
|
42945
42995
|
return native.isValidPrivateKey(hex);
|
|
@@ -43009,9 +43059,11 @@ export {
|
|
|
43009
43059
|
MemoryIntegrityError,
|
|
43010
43060
|
PointerStore,
|
|
43011
43061
|
SignatureVerificationError,
|
|
43062
|
+
buildAllowedJudgeHosts,
|
|
43012
43063
|
claimHashHex,
|
|
43013
43064
|
classifyMemoryRead,
|
|
43014
43065
|
classifyMemoryWrite,
|
|
43066
|
+
columnAad,
|
|
43015
43067
|
commitMemoryVersion,
|
|
43016
43068
|
containsEvasionCharacters,
|
|
43017
43069
|
containsSecret,
|
|
@@ -43039,7 +43091,9 @@ export {
|
|
|
43039
43091
|
getMemoryHistory,
|
|
43040
43092
|
getRollbackHistory,
|
|
43041
43093
|
guardMemoryWrite,
|
|
43094
|
+
isEnvelope,
|
|
43042
43095
|
isValidPrivateKey,
|
|
43096
|
+
keyFingerprintOf,
|
|
43043
43097
|
loadAgent,
|
|
43044
43098
|
loadAgentFromFile,
|
|
43045
43099
|
loadUserConfig,
|
|
@@ -43047,6 +43101,8 @@ export {
|
|
|
43047
43101
|
normalizeForMatching,
|
|
43048
43102
|
normalizeStatus,
|
|
43049
43103
|
normalizeVerdict,
|
|
43104
|
+
packEnvelope,
|
|
43105
|
+
parseEnvelope,
|
|
43050
43106
|
pubkeyToHex,
|
|
43051
43107
|
recordCall,
|
|
43052
43108
|
recordDuration,
|