@atbash/sdk 0.19.2-dev.0 → 0.20.0-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 CHANGED
@@ -21769,23 +21769,23 @@ Splitter$1.prototype.flush = function() {
21769
21769
  return Buffer$9.concat([this.cache, padBuff]);
21770
21770
  };
21771
21771
  function createCipheriv$1(suite, password, iv) {
21772
- var config2 = MODES$1[suite.toLowerCase()];
21773
- if (!config2) throw new TypeError("invalid suite type");
21772
+ var config3 = MODES$1[suite.toLowerCase()];
21773
+ if (!config3) throw new TypeError("invalid suite type");
21774
21774
  if (typeof password === "string") password = Buffer$9.from(password);
21775
- if (password.length !== config2.key / 8) throw new TypeError("invalid key length " + password.length);
21775
+ if (password.length !== config3.key / 8) throw new TypeError("invalid key length " + password.length);
21776
21776
  if (typeof iv === "string") iv = Buffer$9.from(iv);
21777
- if (config2.mode !== "GCM" && iv.length !== config2.iv) throw new TypeError("invalid iv length " + iv.length);
21778
- if (config2.type === "stream") {
21779
- return new StreamCipher$1(config2.module, password, iv);
21780
- } else if (config2.type === "auth") {
21781
- return new AuthCipher$1(config2.module, password, iv);
21777
+ if (config3.mode !== "GCM" && iv.length !== config3.iv) throw new TypeError("invalid iv length " + iv.length);
21778
+ if (config3.type === "stream") {
21779
+ return new StreamCipher$1(config3.module, password, iv);
21780
+ } else if (config3.type === "auth") {
21781
+ return new AuthCipher$1(config3.module, password, iv);
21782
21782
  }
21783
- return new Cipher(config2.module, password, iv);
21783
+ return new Cipher(config3.module, password, iv);
21784
21784
  }
21785
21785
  function createCipher$1(suite, password) {
21786
- var config2 = MODES$1[suite.toLowerCase()];
21787
- if (!config2) throw new TypeError("invalid suite type");
21788
- var keys2 = ebtk$2(password, false, config2.key, config2.iv);
21786
+ var config3 = MODES$1[suite.toLowerCase()];
21787
+ if (!config3) throw new TypeError("invalid suite type");
21788
+ var keys2 = ebtk$2(password, false, config3.key, config3.iv);
21789
21789
  return createCipheriv$1(suite, keys2.key, keys2.iv);
21790
21790
  }
21791
21791
  encrypter.createCipheriv = createCipheriv$1;
@@ -21873,23 +21873,23 @@ function unpad(last) {
21873
21873
  return last.slice(0, 16 - padded);
21874
21874
  }
21875
21875
  function createDecipheriv$1(suite, password, iv) {
21876
- var config2 = MODES[suite.toLowerCase()];
21877
- if (!config2) throw new TypeError("invalid suite type");
21876
+ var config3 = MODES[suite.toLowerCase()];
21877
+ if (!config3) throw new TypeError("invalid suite type");
21878
21878
  if (typeof iv === "string") iv = Buffer$8.from(iv);
21879
- if (config2.mode !== "GCM" && iv.length !== config2.iv) throw new TypeError("invalid iv length " + iv.length);
21879
+ if (config3.mode !== "GCM" && iv.length !== config3.iv) throw new TypeError("invalid iv length " + iv.length);
21880
21880
  if (typeof password === "string") password = Buffer$8.from(password);
21881
- if (password.length !== config2.key / 8) throw new TypeError("invalid key length " + password.length);
21882
- if (config2.type === "stream") {
21883
- return new StreamCipher(config2.module, password, iv, true);
21884
- } else if (config2.type === "auth") {
21885
- return new AuthCipher(config2.module, password, iv, true);
21881
+ if (password.length !== config3.key / 8) throw new TypeError("invalid key length " + password.length);
21882
+ if (config3.type === "stream") {
21883
+ return new StreamCipher(config3.module, password, iv, true);
21884
+ } else if (config3.type === "auth") {
21885
+ return new AuthCipher(config3.module, password, iv, true);
21886
21886
  }
21887
- return new Decipher(config2.module, password, iv);
21887
+ return new Decipher(config3.module, password, iv);
21888
21888
  }
21889
21889
  function createDecipher$1(suite, password) {
21890
- var config2 = MODES[suite.toLowerCase()];
21891
- if (!config2) throw new TypeError("invalid suite type");
21892
- var keys2 = ebtk$1(password, false, config2.key, config2.iv);
21890
+ var config3 = MODES[suite.toLowerCase()];
21891
+ if (!config3) throw new TypeError("invalid suite type");
21892
+ var keys2 = ebtk$1(password, false, config3.key, config3.iv);
21893
21893
  return createDecipheriv$1(suite, keys2.key, keys2.iv);
21894
21894
  }
21895
21895
  decrypter.createDecipher = createDecipher$1;
@@ -40614,29 +40614,29 @@ function requireFailoverStrategies() {
40614
40614
  }
40615
40615
  }
40616
40616
  function abortOnError(_a2) {
40617
- return __awaiter2(this, arguments, void 0, function* ({ method, path: path3, config: config2, postObject, timeoutOverride }) {
40617
+ return __awaiter2(this, arguments, void 0, function* ({ method, path: path3, config: config3, postObject, timeoutOverride }) {
40618
40618
  return yield retryRequest({
40619
40619
  method,
40620
40620
  path: path3,
40621
- config: config2,
40621
+ config: config3,
40622
40622
  postObject,
40623
40623
  timeoutOverride,
40624
40624
  useNextNodeOnError: false,
40625
- recoveryThreshold: config2.recoveryThreshold
40625
+ recoveryThreshold: config3.recoveryThreshold
40626
40626
  // Use user config or let nodeManager use default
40627
40627
  });
40628
40628
  });
40629
40629
  }
40630
40630
  function tryNextOnError(_a2) {
40631
- return __awaiter2(this, arguments, void 0, function* ({ method, path: path3, config: config2, postObject, timeoutOverride }) {
40631
+ return __awaiter2(this, arguments, void 0, function* ({ method, path: path3, config: config3, postObject, timeoutOverride }) {
40632
40632
  return yield retryRequest({
40633
40633
  method,
40634
40634
  path: path3,
40635
- config: config2,
40635
+ config: config3,
40636
40636
  postObject,
40637
40637
  timeoutOverride,
40638
40638
  useNextNodeOnError: true,
40639
- recoveryThreshold: config2.recoveryThreshold
40639
+ recoveryThreshold: config3.recoveryThreshold
40640
40640
  });
40641
40641
  });
40642
40642
  }
@@ -40647,17 +40647,17 @@ 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: path3, config: config2, postObject, timeoutOverride }) {
40650
+ return __awaiter2(this, arguments, void 0, function* ({ method, path: path3, config: config3, postObject, timeoutOverride }) {
40651
40651
  var _b;
40652
- const bftMajorityThreshold = calculateBftMajorityThreshold(config2.endpointPool.length);
40653
- const failureThreshold = config2.endpointPool.length - bftMajorityThreshold + 1;
40654
- const { nodeManager: nodeManager2 } = config2;
40652
+ const bftMajorityThreshold = calculateBftMajorityThreshold(config3.endpointPool.length);
40653
+ const failureThreshold = config3.endpointPool.length - bftMajorityThreshold + 1;
40654
+ const { nodeManager: nodeManager2 } = config3;
40655
40655
  const timeout = 15e3;
40656
- const availableNodes = nodeManager2.getAvailableNodes((_b = config2.recoveryThreshold) !== null && _b !== void 0 ? _b : bftMajorityThreshold);
40656
+ const availableNodes = nodeManager2.getAvailableNodes((_b = config3.recoveryThreshold) !== null && _b !== void 0 ? _b : bftMajorityThreshold);
40657
40657
  const outcomes = [];
40658
40658
  const promises = availableNodes.map((node2) => __awaiter2(this, void 0, void 0, function* () {
40659
40659
  try {
40660
- const requestTimeout = timeoutOverride !== null && timeoutOverride !== void 0 ? timeoutOverride : config2.responseTimeout;
40660
+ const requestTimeout = timeoutOverride !== null && timeoutOverride !== void 0 ? timeoutOverride : config3.responseTimeout;
40661
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)) {
@@ -40697,7 +40697,7 @@ function requireFailoverStrategies() {
40697
40697
  throw errorOutcomes[0].result;
40698
40698
  }
40699
40699
  }
40700
- if (outcomes.length >= config2.endpointPool.length) {
40700
+ if (outcomes.length >= config3.endpointPool.length) {
40701
40701
  throw new Error(exports.errorMessages.NO_CONSENSUS);
40702
40702
  }
40703
40703
  remainingPromises = yield racePromisesWithTimeout(remainingPromises, timeout);
@@ -40705,17 +40705,17 @@ function requireFailoverStrategies() {
40705
40705
  });
40706
40706
  }
40707
40707
  function singleEndpoint(_a2) {
40708
- return __awaiter2(this, arguments, void 0, function* ({ method, path: path3, config: config2, postObject, timeoutOverride }) {
40708
+ return __awaiter2(this, arguments, void 0, function* ({ method, path: path3, config: config3, postObject, timeoutOverride }) {
40709
40709
  let statusCode = null;
40710
40710
  let rspBody = null;
40711
40711
  let error4 = null;
40712
40712
  let transactionTimestamp = void 0;
40713
- const endpoint = config2.nodeManager.getNode();
40713
+ const endpoint = config3.nodeManager.getNode();
40714
40714
  if (!endpoint) {
40715
40715
  throw new Error("No nodes available after recovery attempt. Check node configuration.");
40716
40716
  }
40717
- for (let attempt = 0; attempt < config2.attemptsPerEndpoint; attempt++) {
40718
- const requestTimeout = timeoutOverride !== null && timeoutOverride !== void 0 ? timeoutOverride : config2.responseTimeout;
40717
+ for (let attempt = 0; attempt < config3.attemptsPerEndpoint; attempt++) {
40718
+ const requestTimeout = timeoutOverride !== null && timeoutOverride !== void 0 ? timeoutOverride : config3.responseTimeout;
40719
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);
@@ -40724,24 +40724,24 @@ function requireFailoverStrategies() {
40724
40724
  if (!isError4 && !error4) {
40725
40725
  return { error: error4, statusCode, rspBody, transactionTimestamp };
40726
40726
  }
40727
- logger3.info(`${method} request failed on ${endpoint.url}. Attempt: ${attempt + 1} / ${config2.attemptsPerEndpoint}`);
40728
- yield (0, utils_12.sleep)(config2.attemptInterval);
40727
+ logger3.info(`${method} request failed on ${endpoint.url}. Attempt: ${attempt + 1} / ${config3.attemptsPerEndpoint}`);
40728
+ yield (0, utils_12.sleep)(config3.attemptInterval);
40729
40729
  }
40730
40730
  return { error: error4, statusCode, rspBody, transactionTimestamp };
40731
40731
  });
40732
40732
  }
40733
40733
  function retryRequest(_a2) {
40734
- return __awaiter2(this, arguments, void 0, function* ({ method, path: path3, config: config2, postObject, useNextNodeOnError, recoveryThreshold, timeoutOverride }) {
40734
+ return __awaiter2(this, arguments, void 0, function* ({ method, path: path3, config: config3, postObject, useNextNodeOnError, recoveryThreshold, timeoutOverride }) {
40735
40735
  var _b, _c, _d;
40736
40736
  let statusCode = null;
40737
40737
  let rspBody = null;
40738
40738
  let error4 = null;
40739
40739
  let transactionTimestamp = void 0;
40740
- const { nodeManager: nodeManager2 } = config2;
40740
+ const { nodeManager: nodeManager2 } = config3;
40741
40741
  const availableNodes = nodeManager2.getAvailableNodes(recoveryThreshold);
40742
40742
  for (const node2 of availableNodes) {
40743
- for (let attempt = 0; attempt < config2.attemptsPerEndpoint; attempt++) {
40744
- const requestTimeout = timeoutOverride !== null && timeoutOverride !== void 0 ? timeoutOverride : config2.responseTimeout;
40743
+ for (let attempt = 0; attempt < config3.attemptsPerEndpoint; attempt++) {
40744
+ const requestTimeout = timeoutOverride !== null && timeoutOverride !== void 0 ? timeoutOverride : config3.responseTimeout;
40745
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;
@@ -40772,9 +40772,9 @@ function requireFailoverStrategies() {
40772
40772
  break;
40773
40773
  }
40774
40774
  }
40775
- logger3.info(`${method} request failed on ${node2.url}. Attempt: ${attempt + 1} / ${config2.attemptsPerEndpoint}`);
40776
- if (config2.attemptInterval > 0) {
40777
- yield (0, utils_12.sleep)(config2.attemptInterval);
40775
+ logger3.info(`${method} request failed on ${node2.url}. Attempt: ${attempt + 1} / ${config3.attemptsPerEndpoint}`);
40776
+ if (config3.attemptInterval > 0) {
40777
+ yield (0, utils_12.sleep)(config3.attemptInterval);
40778
40778
  }
40779
40779
  }
40780
40780
  }
@@ -40885,21 +40885,21 @@ 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, path3, config2, postObject, forceSingleEndpoint = false, timeoutOverride) {
40889
- switch (config2.failoverStrategy) {
40888
+ return __awaiter2(this, arguments, void 0, function* (method, path3, config3, postObject, forceSingleEndpoint = false, timeoutOverride) {
40889
+ switch (config3.failoverStrategy) {
40890
40890
  case enums_12.FailoverStrategy.AbortOnError:
40891
- return yield (0, failoverStrategies_1.abortOnError)({ method, path: path3, config: config2, postObject, timeoutOverride });
40891
+ return yield (0, failoverStrategies_1.abortOnError)({ method, path: path3, config: config3, postObject, timeoutOverride });
40892
40892
  case enums_12.FailoverStrategy.TryNextOnError:
40893
- return yield (0, failoverStrategies_1.tryNextOnError)({ method, path: path3, config: config2, postObject, timeoutOverride });
40893
+ return yield (0, failoverStrategies_1.tryNextOnError)({ method, path: path3, config: config3, postObject, timeoutOverride });
40894
40894
  case enums_12.FailoverStrategy.SingleEndpoint:
40895
- return yield (0, failoverStrategies_1.singleEndpoint)({ method, path: path3, config: config2, postObject, timeoutOverride });
40895
+ return yield (0, failoverStrategies_1.singleEndpoint)({ method, path: path3, config: config3, postObject, timeoutOverride });
40896
40896
  case enums_12.FailoverStrategy.QueryMajority:
40897
40897
  if (forceSingleEndpoint) {
40898
- return yield (0, failoverStrategies_1.singleEndpoint)({ method, path: path3, config: config2, postObject, timeoutOverride });
40898
+ return yield (0, failoverStrategies_1.singleEndpoint)({ method, path: path3, config: config3, postObject, timeoutOverride });
40899
40899
  }
40900
- return yield (0, failoverStrategies_1.queryMajority)({ method, path: path3, config: config2, postObject, timeoutOverride });
40900
+ return yield (0, failoverStrategies_1.queryMajority)({ method, path: path3, config: config3, postObject, timeoutOverride });
40901
40901
  default:
40902
- throw new Error(`Unsupported failover strategy: ${config2.failoverStrategy}`);
40902
+ throw new Error(`Unsupported failover strategy: ${config3.failoverStrategy}`);
40903
40903
  }
40904
40904
  });
40905
40905
  }
@@ -41068,11 +41068,11 @@ function requireUtils$1() {
41068
41068
  return Object.assign(Object.assign(Object.assign({ endpointPool, nodeManager: nodeManager2 }, settings.blockedNodeUrlSubstrings !== void 0 ? { blockedNodeUrlSubstrings: settings.blockedNodeUrlSubstrings } : {}), settings.nodeUrlFilter !== void 0 ? { nodeUrlFilter: settings.nodeUrlFilter } : {}), { blockchainRid: blockchainRidToUse, merkleHashVersion: (_e = settings.merkleHashVersion) !== null && _e !== void 0 ? _e : constants_12.MERKLE_HASH_VERSIONS.UNSET, dappStatusPolling: setStatusPolling(settings.dappStatusPolling), clusterAnchoringStatusPolling: setStatusPolling(settings.clusterAnchoringStatusPolling), systemAnchoringStatusPolling: setStatusPolling(settings.systemAnchoringStatusPolling), retryTransactionPolling: setRetryTransactionPolling(settings.retryTransactionPolling), failoverStrategy: ((_f = settings.failOverConfig) === null || _f === void 0 ? void 0 : _f.strategy) || exports.defaultFailoverConfig.strategy, attemptsPerEndpoint: ((_g = settings.failOverConfig) === null || _g === void 0 ? void 0 : _g.attemptsPerEndpoint) || exports.defaultFailoverConfig.attemptsPerEndpoint, attemptInterval: ((_h = settings.failOverConfig) === null || _h === void 0 ? void 0 : _h.attemptInterval) || exports.defaultFailoverConfig.attemptInterval, unreachableDuration: ((_j = settings.failOverConfig) === null || _j === void 0 ? void 0 : _j.unreachableDuration) || exports.defaultFailoverConfig.unreachableDuration, directoryChainRid: settings.directoryChainRid || directoryChainRid, connectTimeout: settings.connectTimeout, responseTimeout: settings.responseTimeout });
41069
41069
  });
41070
41070
  }
41071
- function getMerkleHashVersionFromDapp(config2) {
41071
+ function getMerkleHashVersionFromDapp(config3) {
41072
41072
  return __awaiter2(this, void 0, void 0, function* () {
41073
41073
  var _a2;
41074
41074
  try {
41075
- const response = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `/config/${config2.blockchainRid}/features`, config2, void 0, false, (_a2 = config2.connectTimeout) !== null && _a2 !== void 0 ? _a2 : config2.responseTimeout);
41075
+ const response = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `/config/${config3.blockchainRid}/features`, config3, void 0, false, (_a2 = config3.connectTimeout) !== null && _a2 !== void 0 ? _a2 : config3.responseTimeout);
41076
41076
  const validatedResponse = (0, merkleHash_1.validateMerkleHash)(response.rspBody);
41077
41077
  return validatedResponse.merkle_hash_version;
41078
41078
  } catch (error4) {
@@ -41528,7 +41528,7 @@ function requireUtils$1() {
41528
41528
  return __awaiter2(this, arguments, void 0, function* ({ endpointPool, chainId, failOverConfig = {}, nodeManager: nodeManager2, connectTimeout, responseTimeout }) {
41529
41529
  var _b;
41530
41530
  const mergedFailOverConfig = Object.assign(Object.assign({}, exports.defaultFailoverConfig), failOverConfig);
41531
- const config2 = {
41531
+ const config3 = {
41532
41532
  endpointPool,
41533
41533
  nodeManager: nodeManager2,
41534
41534
  dappStatusPolling: setStatusPolling(),
@@ -41543,7 +41543,7 @@ function requireUtils$1() {
41543
41543
  connectTimeout,
41544
41544
  responseTimeout
41545
41545
  };
41546
- const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `/brid/iid_${chainId}`, config2, void 0, false, (_b = config2.connectTimeout) !== null && _b !== void 0 ? _b : config2.responseTimeout);
41546
+ const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `/brid/iid_${chainId}`, config3, void 0, false, (_b = config3.connectTimeout) !== null && _b !== void 0 ? _b : config3.responseTimeout);
41547
41547
  const blockchainRid = (0, requests_1.isString)(rspBody);
41548
41548
  if (!blockchainRid) {
41549
41549
  throw error4;
@@ -42279,10 +42279,10 @@ function requireBlockchainClient() {
42279
42279
  function createClient(settings) {
42280
42280
  return __awaiter2(this, void 0, void 0, function* () {
42281
42281
  (0, networkSettings_1.isNetworkSettingValid)(settings, { throwOnError: true });
42282
- const config2 = yield (0, utils_12.getClientConfigFromSettings)(settings);
42283
- config2.merkleHashVersion = yield getMerkleHashVersion(settings);
42282
+ const config3 = yield (0, utils_12.getClientConfigFromSettings)(settings);
42283
+ config3.merkleHashVersion = yield getMerkleHashVersion(settings);
42284
42284
  return {
42285
- config: config2,
42285
+ config: config3,
42286
42286
  query(nameOrQueryObject, args, callback) {
42287
42287
  return __awaiter2(this, void 0, void 0, function* () {
42288
42288
  let _name, _args;
@@ -42293,7 +42293,7 @@ function requireBlockchainClient() {
42293
42293
  _name = nameOrQueryObject === null || nameOrQueryObject === void 0 ? void 0 : nameOrQueryObject.name;
42294
42294
  _args = nameOrQueryObject === null || nameOrQueryObject === void 0 ? void 0 : nameOrQueryObject.args;
42295
42295
  }
42296
- const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.POST, `query_gtv/${config2.blockchainRid}`, config2, (0, serialization_12.encodeValue)((0, formatter_12.toQueryObjectGTV)(_name, _args)));
42296
+ const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.POST, `query_gtv/${config3.blockchainRid}`, config3, (0, serialization_12.encodeValue)((0, formatter_12.toQueryObjectGTV)(_name, _args)));
42297
42297
  return new Promise((resolve2, reject) => {
42298
42298
  (0, utils_12.handlePostResponse)(error4, statusCode, (0, requests_1.isRawGtv)(rspBody), (0, utils_12.callbackPromiseBuilder)(reject, resolve2, callback));
42299
42299
  });
@@ -42302,9 +42302,9 @@ function requireBlockchainClient() {
42302
42302
  signTransaction(transaction, signMethod2, callback) {
42303
42303
  return __awaiter2(this, void 0, void 0, function* () {
42304
42304
  logger3.debug(`Signing transaction with ${!(0, utils_12.isKeyPair)(signMethod2) ? "signature provider containing " : ""}pubKey: ${(0, formatter_12.toString)(signMethod2.pubKey)}`);
42305
- const gtx2 = (0, utils_12.getGTXFromBufferOrTransactionOrOperation)(transaction, config2.blockchainRid);
42305
+ const gtx2 = (0, utils_12.getGTXFromBufferOrTransactionOrOperation)(transaction, config3.blockchainRid);
42306
42306
  try {
42307
- const signedTx = yield (0, utils_12.isKeyPair)(signMethod2) ? gtxTool.sign(gtx2, signMethod2.privKey, config2.merkleHashVersion, signMethod2.pubKey) : gtxTool.sign(gtx2, signMethod2, config2.merkleHashVersion);
42307
+ const signedTx = yield (0, utils_12.isKeyPair)(signMethod2) ? gtxTool.sign(gtx2, signMethod2.privKey, config3.merkleHashVersion, signMethod2.pubKey) : gtxTool.sign(gtx2, signMethod2, config3.merkleHashVersion);
42308
42308
  const gtxBytes = (0, utils_12.getSerializedGTX)(signedTx);
42309
42309
  if (typeof callback === "function") {
42310
42310
  callback(null, gtxBytes);
@@ -42325,8 +42325,8 @@ function requireBlockchainClient() {
42325
42325
  }
42326
42326
  const promiEvent = new promiEvents_12.Web3PromiEvent((resolve2, reject) => __awaiter2(this, void 0, void 0, function* () {
42327
42327
  let error4 = null;
42328
- for (let i = 0; i < config2.retryTransactionPolling.count; i++) {
42329
- logger3.info(`sendTransactionWithRetries attempt ${i + 1} of ${config2.retryTransactionPolling.count}`);
42328
+ for (let i = 0; i < config3.retryTransactionPolling.count; i++) {
42329
+ logger3.info(`sendTransactionWithRetries attempt ${i + 1} of ${config3.retryTransactionPolling.count}`);
42330
42330
  const tmpPromiEvent = sendOnce().on(enums_12.TransactionEvent.ClusterAnchoringConfirmation, (receipt) => {
42331
42331
  promiEvent.emit(enums_12.TransactionEvent.ClusterAnchoringConfirmation, receipt);
42332
42332
  }).on(enums_12.TransactionEvent.SystemAnchoringConfirmation, (receipt) => {
@@ -42338,7 +42338,7 @@ function requireBlockchainClient() {
42338
42338
  }).on(enums_12.TransactionEvent.DappConfirmed, (receipt) => {
42339
42339
  promiEvent.emit(enums_12.TransactionEvent.DappConfirmed, receipt);
42340
42340
  }).catch((tmpError) => {
42341
- logger3.warning(`sendTransactionWithRetries error on attempt ${i + 1} of ${config2.retryTransactionPolling.count}: ${tmpError}`);
42341
+ logger3.warning(`sendTransactionWithRetries error on attempt ${i + 1} of ${config3.retryTransactionPolling.count}: ${tmpError}`);
42342
42342
  promiEvent.emit(enums_12.TransactionEvent.Rejected, tmpError);
42343
42343
  error4 = tmpError;
42344
42344
  });
@@ -42347,7 +42347,7 @@ function requireBlockchainClient() {
42347
42347
  resolve2(tmpReceipt);
42348
42348
  return;
42349
42349
  }
42350
- yield (0, utils_12.sleep)(config2.retryTransactionPolling.interval);
42350
+ yield (0, utils_12.sleep)(config3.retryTransactionPolling.interval);
42351
42351
  }
42352
42352
  reject(error4);
42353
42353
  }));
@@ -42357,13 +42357,13 @@ function requireBlockchainClient() {
42357
42357
  const promiEvent = new promiEvents_12.Web3PromiEvent((resolve2, reject) => __awaiter2(this, void 0, void 0, function* () {
42358
42358
  var _a2, _b;
42359
42359
  try {
42360
- const gtx2 = (0, utils_12.getGTXFromBufferOrTransactionOrOperation)(transaction, config2.blockchainRid);
42360
+ const gtx2 = (0, utils_12.getGTXFromBufferOrTransactionOrOperation)(transaction, config3.blockchainRid);
42361
42361
  if (gtx2.signers.length !== ((_a2 = gtx2.signatures) === null || _a2 === void 0 ? void 0 : _a2.length)) {
42362
42362
  reject(new errors_12.NumberOfSignersAndSignaturesException());
42363
42363
  }
42364
42364
  const gtxBytes = (0, utils_12.getSerializedGTX)(gtx2);
42365
- const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.POST, `tx/${config2.blockchainRid}`, config2, gtxBytes);
42366
- const transactionRid = gtxTool.getDigestToSign(gtx2, config2.merkleHashVersion);
42365
+ const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.POST, `tx/${config3.blockchainRid}`, config3, gtxBytes);
42366
+ const transactionRid = gtxTool.getDigestToSign(gtx2, config3.merkleHashVersion);
42367
42367
  try {
42368
42368
  yield (0, utils_12.handlePostResponsePromisified)(error4, statusCode, (0, requests_1.isRawGtv)(rspBody));
42369
42369
  if (typeof callback === "function") {
@@ -42371,7 +42371,7 @@ function requireBlockchainClient() {
42371
42371
  status: enums_12.ResponseStatus.Waiting,
42372
42372
  statusCode,
42373
42373
  transactionRid,
42374
- node: (_b = config2.nodeManager.lastUsedNode) === null || _b === void 0 ? void 0 : _b.url
42374
+ node: (_b = config3.nodeManager.lastUsedNode) === null || _b === void 0 ? void 0 : _b.url
42375
42375
  });
42376
42376
  }
42377
42377
  } catch (_error) {
@@ -42434,7 +42434,7 @@ function requireBlockchainClient() {
42434
42434
  callback === null || callback === void 0 ? void 0 : callback(error5, null);
42435
42435
  throw error5;
42436
42436
  }
42437
- const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `tx/${config2.blockchainRid}/${(0, formatter_12.ensureString)(transactionRid)}`, config2);
42437
+ const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `tx/${config3.blockchainRid}/${(0, formatter_12.ensureString)(transactionRid)}`, config3);
42438
42438
  const transaction = (0, requests_1.isTransaction)(rspBody);
42439
42439
  return new Promise((resolve2, reject) => {
42440
42440
  (0, utils_12.handleGetResponse)(error4, statusCode, statusCode === 200 && transaction ? (0, formatter_12.toBuffer)(transaction.tx) : (0, requests_1.isRawGtv)(rspBody), (0, utils_12.callbackPromiseBuilder)(reject, resolve2, callback));
@@ -42449,7 +42449,7 @@ function requireBlockchainClient() {
42449
42449
  callback === null || callback === void 0 ? void 0 : callback(error5, null);
42450
42450
  throw error5;
42451
42451
  }
42452
- const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `tx/${config2.blockchainRid}/${transactionRid.toString("hex")}/status`, config2);
42452
+ const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `tx/${config3.blockchainRid}/${transactionRid.toString("hex")}/status`, config3);
42453
42453
  return new Promise((resolve2, reject) => {
42454
42454
  (0, utils_12.handleGetResponse)(error4, statusCode, (0, requests_1.isRawGtv)(rspBody), (0, utils_12.callbackPromiseBuilder)(reject, (result) => resolve2((0, transactionStatusReponse_1.validateTransactionStatusReponse)({
42455
42455
  statusCode,
@@ -42472,7 +42472,7 @@ function requireBlockchainClient() {
42472
42472
  const beforeTimeQueryParam = beforeTime ? `&before-time=${beforeTime.getTime()}` : "";
42473
42473
  const afterTimeQueryParam = afterTime ? `&after-time=${afterTime.getTime()}` : "";
42474
42474
  const signerQueryParam = signerPubKey ? `&signer=${signerPubKey}` : "";
42475
- const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `transactions/${config2.blockchainRid}?limit=${limit}${beforeTimeQueryParam}${afterTimeQueryParam}${signerQueryParam}`, config2);
42475
+ const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `transactions/${config3.blockchainRid}?limit=${limit}${beforeTimeQueryParam}${afterTimeQueryParam}${signerQueryParam}`, config3);
42476
42476
  const transactionsInfoResponseArray = (0, requests_1.isTransactionInfoResponseArray)(rspBody);
42477
42477
  const body = statusCode === 200 && transactionsInfoResponseArray ? transactionsInfoResponseArray.map(utils_12.formatTransactionInfoResponse) : rspBody;
42478
42478
  return new Promise((resolve2, reject) => {
@@ -42488,7 +42488,7 @@ function requireBlockchainClient() {
42488
42488
  callback === null || callback === void 0 ? void 0 : callback(error5, null);
42489
42489
  throw error5;
42490
42490
  }
42491
- const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `transactions/${config2.blockchainRid}/${(0, formatter_12.ensureString)(transactionRid)}`, config2);
42491
+ const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `transactions/${config3.blockchainRid}/${(0, formatter_12.ensureString)(transactionRid)}`, config3);
42492
42492
  const transactionInfoResponse = (0, requests_1.isTransactionInfoResponse)(rspBody);
42493
42493
  const body = statusCode === 200 && transactionInfoResponse ? (0, utils_12.formatTransactionInfoResponse)(transactionInfoResponse) : rspBody;
42494
42494
  return new Promise((resolve2, reject) => {
@@ -42500,7 +42500,7 @@ function requireBlockchainClient() {
42500
42500
  return __awaiter2(this, void 0, void 0, function* () {
42501
42501
  const client = this;
42502
42502
  const result = { status: enums_12.AnchoringStatus.NotAnchored };
42503
- const clusterAnchoredTx = yield (0, utils_2.awaitGetAnchoringTransactionForBlockRid)(anchoringClient, (0, formatter_12.ensureBuffer)(client.config.blockchainRid), (0, formatter_12.ensureBuffer)(blockRid), config2.clusterAnchoringStatusPolling);
42503
+ const clusterAnchoredTx = yield (0, utils_2.awaitGetAnchoringTransactionForBlockRid)(anchoringClient, (0, formatter_12.ensureBuffer)(client.config.blockchainRid), (0, formatter_12.ensureBuffer)(blockRid), config3.clusterAnchoringStatusPolling);
42504
42504
  if (!clusterAnchoredTx) {
42505
42505
  return result;
42506
42506
  }
@@ -42510,7 +42510,7 @@ function requireBlockchainClient() {
42510
42510
  }
42511
42511
  result.status = enums_12.AnchoringStatus.ClusterAnchored;
42512
42512
  result.clusterAnchoredTx = anchoringTransactionValidation.data;
42513
- const systemAnchoredTransaction = yield (0, utils_12.getSystemAnchoringTransaction)(config2.endpointPool, anchoringTransactionValidation.data.txRid, anchoringClient, systemAnchoringChainRid, config2.systemAnchoringStatusPolling, config2.merkleHashVersion, config2.blockedNodeUrlSubstrings, config2.nodeUrlFilter);
42513
+ const systemAnchoredTransaction = yield (0, utils_12.getSystemAnchoringTransaction)(config3.endpointPool, anchoringTransactionValidation.data.txRid, anchoringClient, systemAnchoringChainRid, config3.systemAnchoringStatusPolling, config3.merkleHashVersion, config3.blockedNodeUrlSubstrings, config3.nodeUrlFilter);
42514
42514
  if (!systemAnchoredTransaction) {
42515
42515
  return result;
42516
42516
  }
@@ -42574,7 +42574,7 @@ function requireBlockchainClient() {
42574
42574
  },
42575
42575
  getTransactionCount(callback) {
42576
42576
  return __awaiter2(this, void 0, void 0, function* () {
42577
- const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `transactions/${config2.blockchainRid}/count`, config2, void 0, true);
42577
+ const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `transactions/${config3.blockchainRid}/count`, config3, void 0, true);
42578
42578
  const transactionsCount = (0, requests_1.isTransactionsCount)(rspBody);
42579
42579
  return new Promise((resolve2, reject) => {
42580
42580
  (0, utils_12.handleGetResponse)(error4, statusCode, statusCode === 200 ? transactionsCount === null || transactionsCount === void 0 ? void 0 : transactionsCount.transactionsCount : (0, requests_1.isRawGtv)(rspBody), (0, utils_12.callbackPromiseBuilder)(reject, resolve2, callback));
@@ -42585,7 +42585,7 @@ function requireBlockchainClient() {
42585
42585
  return __awaiter2(this, arguments, void 0, function* (blockIdentifier2, txs = false, callback) {
42586
42586
  (0, blockIdentifier_1.isBlockIdentifierValid)(blockIdentifier2, { throwOnError: true });
42587
42587
  const queryString = typeof blockIdentifier2 === "string" ? blockIdentifier2 : `height/${blockIdentifier2}`;
42588
- const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `blocks/${config2.blockchainRid}/${queryString}?txs=${txs}`, config2);
42588
+ const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `blocks/${config3.blockchainRid}/${queryString}?txs=${txs}`, config3);
42589
42589
  const blockInfoResponse = (0, requests_1.isBlockInfoResponse)(rspBody);
42590
42590
  return new Promise((resolve2, reject) => {
42591
42591
  (0, utils_12.handleGetResponse)(error4, statusCode, statusCode === 200 && blockInfoResponse !== null && blockInfoResponse ? (0, utils_12.formatBlockInfoResponse)(blockInfoResponse) : (0, requests_1.isRawGtv)(rspBody), (0, utils_12.callbackPromiseBuilder)(reject, resolve2, callback));
@@ -42595,7 +42595,7 @@ function requireBlockchainClient() {
42595
42595
  getLatestBlock() {
42596
42596
  return __awaiter2(this, arguments, void 0, function* (txs = false, callback) {
42597
42597
  const shouldIncludeFullTransaction = txs ? `&txs=${txs}` : "";
42598
- const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `blocks/${config2.blockchainRid}?limit=1${shouldIncludeFullTransaction}`, config2, void 0, true);
42598
+ const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `blocks/${config3.blockchainRid}?limit=1${shouldIncludeFullTransaction}`, config3, void 0, true);
42599
42599
  const indexOfLatestBlock = 0;
42600
42600
  const blockInfoResponseArray = (0, requests_1.isBlockInfoResponseArray)(rspBody);
42601
42601
  return new Promise((resolve2, reject) => {
@@ -42620,7 +42620,7 @@ function requireBlockchainClient() {
42620
42620
  searchParams.append(key3, value.toString());
42621
42621
  }
42622
42622
  }
42623
- const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `blocks/${config2.blockchainRid}?${searchParams}`, config2);
42623
+ const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `blocks/${config3.blockchainRid}?${searchParams}`, config3);
42624
42624
  const blockInfoResponseArray = (0, requests_1.isBlockInfoResponseArray)(rspBody);
42625
42625
  return new Promise((resolve2, reject) => {
42626
42626
  (0, utils_12.handleGetResponse)(error4, statusCode, statusCode === 200 && blockInfoResponseArray ? blockInfoResponseArray.map(utils_12.formatBlockInfoResponse) : (0, requests_1.isRawGtv)(rspBody), (0, utils_12.callbackPromiseBuilder)(reject, resolve2, callback));
@@ -42628,7 +42628,7 @@ function requireBlockchainClient() {
42628
42628
  });
42629
42629
  },
42630
42630
  getClientNodeUrlPool() {
42631
- return config2.endpointPool.map((endpoint) => endpoint.url);
42631
+ return config3.endpointPool.map((endpoint) => endpoint.url);
42632
42632
  },
42633
42633
  /**
42634
42634
  * Retrieves a confirmation proof for a transaction with the specified sha256
@@ -42663,7 +42663,7 @@ function requireBlockchainClient() {
42663
42663
  callback === null || callback === void 0 ? void 0 : callback(error5, null);
42664
42664
  throw error5;
42665
42665
  }
42666
- const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `tx/${config2.blockchainRid}/${(0, formatter_12.ensureString)(txRid2)}/confirmationProof`, config2);
42666
+ const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `tx/${config3.blockchainRid}/${(0, formatter_12.ensureString)(txRid2)}/confirmationProof`, config3);
42667
42667
  const confirmationProof = {
42668
42668
  merkleProofTree: "",
42669
42669
  txIndex: 0
@@ -42727,13 +42727,13 @@ function requireBlockchainClient() {
42727
42727
  callback === null || callback === void 0 ? void 0 : callback(error4, null);
42728
42728
  throw error4;
42729
42729
  }
42730
- const systemAnchoringTransactionTransaction = yield (0, utils_12.getSystemAnchoringTransaction)(config2.endpointPool, anchoredTxRid, anchoringClient, systemAnchoringChainRid, config2.systemAnchoringStatusPolling, config2.merkleHashVersion, config2.blockedNodeUrlSubstrings, config2.nodeUrlFilter);
42730
+ const systemAnchoringTransactionTransaction = yield (0, utils_12.getSystemAnchoringTransaction)(config3.endpointPool, anchoredTxRid, anchoringClient, systemAnchoringChainRid, config3.systemAnchoringStatusPolling, config3.merkleHashVersion, config3.blockedNodeUrlSubstrings, config3.nodeUrlFilter);
42731
42731
  return systemAnchoringTransactionTransaction;
42732
42732
  });
42733
42733
  },
42734
42734
  getWaitingTransactions(blockchainRid, callback) {
42735
42735
  return __awaiter2(this, void 0, void 0, function* () {
42736
- const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `/tx/${(0, formatter_12.ensureString)(blockchainRid)}/waiting`, config2);
42736
+ const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `/tx/${(0, formatter_12.ensureString)(blockchainRid)}/waiting`, config3);
42737
42737
  return new Promise((resolve2, reject) => {
42738
42738
  (0, utils_12.handleGetResponse)(error4, statusCode, (0, requests_1.isRawGtv)(rspBody), (0, utils_12.callbackPromiseBuilder)(reject, resolve2, callback));
42739
42739
  });
@@ -42741,7 +42741,7 @@ function requireBlockchainClient() {
42741
42741
  },
42742
42742
  getWaitingTransaction(blockchainRid, txRid2, callback) {
42743
42743
  return __awaiter2(this, void 0, void 0, function* () {
42744
- const { error: error4, statusCode, rspBody, transactionTimestamp } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `/tx/${(0, formatter_12.ensureString)(blockchainRid)}/waiting/${(0, formatter_12.ensureString)(txRid2)}`, config2);
42744
+ const { error: error4, statusCode, rspBody, transactionTimestamp } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `/tx/${(0, formatter_12.ensureString)(blockchainRid)}/waiting/${(0, formatter_12.ensureString)(txRid2)}`, config3);
42745
42745
  const transaction = (0, requests_1.isTransaction)(rspBody);
42746
42746
  const result = transaction ? (0, formatter_12.toBuffer)(transaction.tx) : (0, requests_1.isRawGtv)(rspBody);
42747
42747
  return new Promise((resolve2, reject) => {
@@ -42754,7 +42754,7 @@ function requireBlockchainClient() {
42754
42754
  },
42755
42755
  getRejectedTransactions(blockchainRid, callback) {
42756
42756
  return __awaiter2(this, void 0, void 0, function* () {
42757
- const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `/tx/${(0, formatter_12.ensureString)(blockchainRid)}/rejected`, config2);
42757
+ const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `/tx/${(0, formatter_12.ensureString)(blockchainRid)}/rejected`, config3);
42758
42758
  const rejectedTransactionsArray = (0, requests_1.isRejectedTransactionResponseArray)(rspBody);
42759
42759
  const validResponseBody = statusCode === 200 && rejectedTransactionsArray ? rejectedTransactionsArray.map((rejectedTransaction) => (0, utils_12.formatRejectedTransactionFromResponse)(rejectedTransaction)) : rspBody;
42760
42760
  return new Promise((resolve2, reject) => {
@@ -42768,7 +42768,7 @@ function requireBlockchainClient() {
42768
42768
  */
42769
42769
  getAppStructure(callback) {
42770
42770
  return __awaiter2(this, void 0, void 0, function* () {
42771
- const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `/query/${config2.blockchainRid}?type=rell.get_app_structure`, config2);
42771
+ const { error: error4, statusCode, rspBody } = yield (0, requestWithFailoverStrategy_1.requestWithFailoverStrategy)(enums_12.Method.GET, `/query/${config3.blockchainRid}?type=rell.get_app_structure`, config3);
42772
42772
  return new Promise((resolve2, reject) => {
42773
42773
  (0, utils_12.handleGetResponse)(error4, statusCode, (0, requests_1.isRawGtv)(rspBody), (0, utils_12.callbackPromiseBuilder)(reject, resolve2, callback));
42774
42774
  });
@@ -42781,7 +42781,7 @@ function requireBlockchainClient() {
42781
42781
  if (settings2.merkleHashVersion !== void 0) {
42782
42782
  merkleHashVersion = settings2.merkleHashVersion;
42783
42783
  } else {
42784
- merkleHashVersion = yield (0, utils_12.getMerkleHashVersionFromDapp)(config2);
42784
+ merkleHashVersion = yield (0, utils_12.getMerkleHashVersionFromDapp)(config3);
42785
42785
  }
42786
42786
  return merkleHashVersion;
42787
42787
  });
@@ -44478,6 +44478,15 @@ var SignatureVerificationError = class extends Error {
44478
44478
  this.name = "SignatureVerificationError";
44479
44479
  }
44480
44480
  };
44481
+ var JudgeRefusalError = class extends Error {
44482
+ constructor(message) {
44483
+ super(message);
44484
+ this.name = "JudgeRefusalError";
44485
+ }
44486
+ };
44487
+ function isRefusalStatus(status) {
44488
+ return status >= 400 && status < 500 && status !== 408;
44489
+ }
44481
44490
  function enrich(status, body, statusText, endpoint, path3) {
44482
44491
  const dashboard = endpoint.replace(/\/+$/, "") || DEFAULT_ENDPOINT;
44483
44492
  let msg = `API error ${status}${path3 ? ` from ${path3}` : ""}: ${body || statusText}`;
@@ -44501,6 +44510,63 @@ function enrich(status, body, statusText, endpoint, path3) {
44501
44510
  return msg;
44502
44511
  }
44503
44512
 
44513
+ // src-ts/jail-hold.ts
44514
+ init_define_ATBASH_CHROMIA_NODE_URLS();
44515
+ init_define_ATBASH_PRIVATE_NODE_URLS();
44516
+ var DEFAULTS = { ceilingMs: 3e4, pollMs: 1e3 };
44517
+ var holds = /* @__PURE__ */ new Map();
44518
+ var blockedAt = /* @__PURE__ */ new Map();
44519
+ var BLOCK_MEMORY_MS = 10 * 6e4;
44520
+ var config2 = { ...DEFAULTS };
44521
+ function isJailHeld(pubkey) {
44522
+ return holds.has(pubkey);
44523
+ }
44524
+ function recordBlock(pubkey) {
44525
+ const now = Date.now();
44526
+ for (const [key3, at] of blockedAt) if (now - at > BLOCK_MEMORY_MS) blockedAt.delete(key3);
44527
+ blockedAt.set(pubkey, now);
44528
+ }
44529
+ function blockedSince(pubkey, startedAt) {
44530
+ const at = blockedAt.get(pubkey);
44531
+ return at !== void 0 && startedAt <= at;
44532
+ }
44533
+ function holdJail(pubkey, confirmJailed, onGiveUp) {
44534
+ if (holds.has(pubkey)) return;
44535
+ const hold = { timer: null };
44536
+ holds.set(pubkey, hold);
44537
+ const deadline = Date.now() + config2.ceilingMs;
44538
+ const tick = async () => {
44539
+ if (holds.get(pubkey) !== hold) return;
44540
+ let jailed = false;
44541
+ try {
44542
+ jailed = await confirmJailed();
44543
+ } catch {
44544
+ }
44545
+ if (holds.get(pubkey) !== hold) return;
44546
+ if (jailed) {
44547
+ holds.delete(pubkey);
44548
+ return;
44549
+ }
44550
+ if (Date.now() >= deadline) {
44551
+ holds.delete(pubkey);
44552
+ onGiveUp?.();
44553
+ return;
44554
+ }
44555
+ const timer = setTimeout(() => void tick(), config2.pollMs);
44556
+ timer.unref?.();
44557
+ hold.timer = timer;
44558
+ };
44559
+ void tick();
44560
+ }
44561
+ function releaseJailHolds() {
44562
+ for (const hold of holds.values()) if (hold.timer) clearTimeout(hold.timer);
44563
+ holds.clear();
44564
+ blockedAt.clear();
44565
+ }
44566
+ function configureJailHold(next) {
44567
+ config2 = { ...DEFAULTS, ...next };
44568
+ }
44569
+
44504
44570
  // src-ts/http/client.ts
44505
44571
  init_define_ATBASH_CHROMIA_NODE_URLS();
44506
44572
  init_define_ATBASH_PRIVATE_NODE_URLS();
@@ -44834,6 +44900,7 @@ function strandedAgentKey() {
44834
44900
  }
44835
44901
 
44836
44902
  // src-ts/client.ts
44903
+ var AGENT_NOT_REGISTERED = "Agent not registered. Onboard the agent at the dashboard before submitting actions.";
44837
44904
  function generateToolCallId() {
44838
44905
  return `tc-${Date.now()}-${randomHex(4)}`;
44839
44906
  }
@@ -45182,6 +45249,15 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
45182
45249
  * return the signed tx hex. The server broadcasts to chain.
45183
45250
  */
45184
45251
  async logToolCall(action, context = "", options = {}) {
45252
+ return this._logToolCall(action, context, options, false);
45253
+ }
45254
+ /**
45255
+ * `raisePreflightErrors` (the judge path, like Python's
45256
+ * `raise_preflight_errors`): a failed registration check throws instead of
45257
+ * becoming `{ success: false }`, so the caller can tell Atbash's "no"
45258
+ * (not registered, or a 4xx) from an outage.
45259
+ */
45260
+ async _logToolCall(action, context, options, raisePreflightErrors) {
45185
45261
  const start = performance.now();
45186
45262
  recordCall("logToolCall", void 0, this.auth.pubkey);
45187
45263
  let exists;
@@ -45191,18 +45267,20 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
45191
45267
  });
45192
45268
  } catch (err) {
45193
45269
  recordDuration("logToolCall", performance.now() - start, "error");
45270
+ if (raisePreflightErrors) throw err;
45194
45271
  return { success: false, toolCallId: null, error: errorMessage(err) };
45195
45272
  }
45196
45273
  if (!exists) {
45197
45274
  recordDuration("logToolCall", performance.now() - start, "error");
45275
+ if (raisePreflightErrors) throw new JudgeRefusalError(AGENT_NOT_REGISTERED);
45198
45276
  return {
45199
45277
  success: false,
45200
45278
  toolCallId: null,
45201
- error: "Agent not registered. Onboard the agent at the dashboard before submitting actions."
45279
+ error: AGENT_NOT_REGISTERED
45202
45280
  };
45203
45281
  }
45204
45282
  const toolCallId = generateToolCallId();
45205
- const brid = options.chainOpts?.blockchainRid || options.chainOpts?.network ? this.bridFromChainOpts(options.chainOpts) : await this.defaultOrgBrid() ?? this.blockchainRid;
45283
+ const brid = await this.callBrid(options.chainOpts);
45206
45284
  const orgKey = options.orgEncryptionPubKey ?? this.orgEncryptionPubKey ?? this._orgKeyFromChain;
45207
45285
  try {
45208
45286
  const signedHex = orgKey ? signEncryptedToolCall(
@@ -45252,6 +45330,8 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
45252
45330
  if (!action?.trim()) {
45253
45331
  throw new Error("action is required and cannot be empty.");
45254
45332
  }
45333
+ if (isJailHeld(this.auth.pubkey)) return this.localJailBlock();
45334
+ const startedAt = Date.now();
45255
45335
  let chainOpts = options.chainOpts;
45256
45336
  if (options.orgName && this._explicitChain) {
45257
45337
  chainOpts = options.chainOpts ?? { network: this._defaultChain.network };
@@ -45276,12 +45356,13 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
45276
45356
  }
45277
45357
  }
45278
45358
  }
45279
- const brid = this.bridFromChainOpts(chainOpts);
45280
- const logResult = await this.logToolCall(action, context, {
45281
- toolName: options.toolName,
45282
- toolArgsJson: options.toolArgsJson,
45283
- chainOpts
45284
- });
45359
+ const brid = await this.callBrid(chainOpts);
45360
+ const logResult = await this._logToolCall(
45361
+ action,
45362
+ context,
45363
+ { toolName: options.toolName, toolArgsJson: options.toolArgsJson, chainOpts },
45364
+ true
45365
+ );
45285
45366
  if (!logResult.success || !logResult.toolCallId || !logResult.signedHex) {
45286
45367
  throw new Error(logResult.error || "Failed to sign log_tool_call");
45287
45368
  }
@@ -45318,10 +45399,16 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
45318
45399
  if (verifyPubKey !== void 0) {
45319
45400
  verifyResponseSignature(bodyBytes, resp, verifyPubKey);
45320
45401
  }
45321
- const data = parseJson(bodyBytes);
45402
+ const parsed = tryParseJson(bodyBytes.toString("utf-8"));
45403
+ if (!isRecord2(parsed)) {
45404
+ throw new JudgeRefusalError(
45405
+ "The judge's reply could not be read, so the action was not approved."
45406
+ );
45407
+ }
45408
+ const data = parsed;
45322
45409
  const rawScore = data.score;
45323
45410
  const score = typeof rawScore === "number" && Number.isInteger(rawScore) && rawScore >= 1 && rawScore <= 10 ? rawScore : void 0;
45324
- return {
45411
+ const result = {
45325
45412
  verdict: normalizeVerdict(data.verdict),
45326
45413
  allow: this.executable(data),
45327
45414
  actionType: normalizeActionType(data.action_type),
@@ -45337,6 +45424,45 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
45337
45424
  score,
45338
45425
  refusal: explicitRefusal(data)
45339
45426
  };
45427
+ return this.applyJailHold(result, startedAt);
45428
+ }
45429
+ /**
45430
+ * Start a local hold on an enforced, on-chain BLOCK (the verdict that jails).
45431
+ * Refuse any other result that lands while the agent is held, or whose
45432
+ * request was already in flight when the block arrived: the server judged it
45433
+ * on pre-jail state.
45434
+ */
45435
+ applyJailHold(result, startedAt) {
45436
+ const pubkey = this.auth.pubkey;
45437
+ if (result.verdict === "BLOCK" && result.enforced && result.onChain) {
45438
+ recordBlock(pubkey);
45439
+ holdJail(
45440
+ pubkey,
45441
+ () => this.getAgentPolicy(pubkey).then((p) => p.isJailed),
45442
+ () => this.logger.warn?.("[atbash] local jail hold released: the chain did not confirm the jail in time")
45443
+ );
45444
+ return result;
45445
+ }
45446
+ return isJailHeld(pubkey) || blockedSince(pubkey, startedAt) ? this.localJailBlock(result.toolCallId) : result;
45447
+ }
45448
+ /** The server's jailed refusal, produced locally while the agent is held. */
45449
+ localJailBlock(toolCallId = generateToolCallId()) {
45450
+ return {
45451
+ verdict: "BLOCK",
45452
+ allow: false,
45453
+ actionType: "block",
45454
+ reason: "Agent is jailed. All actions are blocked until the organization owner unjails this agent.",
45455
+ confidence: 1,
45456
+ provider: "policy",
45457
+ latencyMs: 0,
45458
+ toolCallId,
45459
+ onChain: false,
45460
+ enforced: true,
45461
+ enforcementMode: "enforce",
45462
+ status: "",
45463
+ score: void 0,
45464
+ refusal: "BLOCK"
45465
+ };
45340
45466
  }
45341
45467
  /* ── audit_tool_call (redact → judge → decision) ───────────────────────── */
45342
45468
  /**
@@ -45388,6 +45514,9 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
45388
45514
  reason: `The judge's reply failed its signature check (${errorMessage(err)}), so it was not trusted.`
45389
45515
  };
45390
45516
  }
45517
+ if (err instanceof JudgeRefusalError || err instanceof AtbashAPIError && isRefusalStatus(err.status)) {
45518
+ return { ...this.failJudge(errorMessage(err), err), allow: false };
45519
+ }
45391
45520
  return this.failJudge(errorMessage(err), err);
45392
45521
  }
45393
45522
  }
@@ -45417,6 +45546,15 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
45417
45546
  * never overrides a refusal.
45418
45547
  */
45419
45548
  decide(result) {
45549
+ const inner = this.decideInner(result);
45550
+ if (!result.enforcementMode) return inner;
45551
+ return {
45552
+ ...inner,
45553
+ enforced: result.enforced,
45554
+ enforcementMode: result.enforcementMode
45555
+ };
45556
+ }
45557
+ decideInner(result) {
45420
45558
  const toolCallId = result.toolCallId;
45421
45559
  const deny = (verdict, reason) => ({
45422
45560
  allow: false,
@@ -45530,17 +45668,17 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
45530
45668
  /**
45531
45669
  * Return the current status of a previously submitted judgment.
45532
45670
  *
45533
- * `chainOpts` names which chain the judgment was signed against. The
45534
- * server's GET /api/v1/judge routes to that chain when the SDK sends
45535
- * a `brid` query param; without it, the server falls back to public.
45536
- * Callers on the private chain must pass a `chainOpts` (or configure
45537
- * the client on the private chain) — otherwise polling a POSTed
45538
- * judgment on the private chain 404s at the server.
45671
+ * `chainOpts` names which chain the judgment was signed against; the SDK
45672
+ * sends it as the `brid` query param the server routes by. Without it the
45673
+ * read uses the same chain `judgeAction` signs for (see `callBrid`): the
45674
+ * client's org chain when it has an `orgName`, else the client default.
45675
+ * A judgment signed with an explicit per-call `chainOpts` (or a per-call
45676
+ * `orgName` on another chain) must be polled with that same `chainOpts`.
45539
45677
  */
45540
45678
  async getJudgmentStatus(judgmentId, agentPubkey, chainOpts) {
45541
45679
  const pk = agentPubkey ?? this.auth.pubkey;
45542
- const brid = this.bridFromChainOpts(chainOpts);
45543
45680
  return this.track("getJudgmentStatus", pk, async () => {
45681
+ const brid = await this.callBrid(chainOpts);
45544
45682
  const resp = await this.http.get(
45545
45683
  "/api/v1/judge",
45546
45684
  { tool_call_id: judgmentId, agent_pubkey: pk, brid },
@@ -45878,6 +46016,18 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
45878
46016
  if (chainOpts?.network === "public") return PUBLIC_CHAIN.blockchainRid;
45879
46017
  return this.blockchainRid;
45880
46018
  }
46019
+ /**
46020
+ * The chain one call's transactions are signed for: the per-call override
46021
+ * when given, otherwise the client's org, otherwise the client default.
46022
+ * log_tool_call, judge_action and the judgment-status read all use this, so
46023
+ * a request never pairs transactions signed for two different chains.
46024
+ */
46025
+ async callBrid(chainOpts) {
46026
+ if (chainOpts?.blockchainRid || chainOpts?.network) {
46027
+ return this.bridFromChainOpts(chainOpts);
46028
+ }
46029
+ return await this.defaultOrgBrid() ?? this.blockchainRid;
46030
+ }
45881
46031
  /**
45882
46032
  * Resolve the dashboard chain used by agent metadata/policy reads.
45883
46033
  * Explicit per-call network overrides win; otherwise use the supplied org
@@ -46185,10 +46335,6 @@ function tryParseJson(text) {
46185
46335
  return void 0;
46186
46336
  }
46187
46337
  }
46188
- function parseJson(bytes) {
46189
- const parsed = tryParseJson(bytes.toString("utf-8"));
46190
- return parsed === void 0 ? {} : parsed;
46191
- }
46192
46338
  function requestPath(url) {
46193
46339
  if (!url) return void 0;
46194
46340
  try {
@@ -46449,6 +46595,16 @@ async function guardMemoryWrite(_input) {
46449
46595
  throw new Error(`guardMemoryWrite ${STUB_MSG5}`);
46450
46596
  }
46451
46597
 
46598
+ // src-ts/browser/memory-slot.ts
46599
+ init_define_ATBASH_CHROMIA_NODE_URLS();
46600
+ init_define_ATBASH_PRIVATE_NODE_URLS();
46601
+ var unavailable2 = (name2) => {
46602
+ throw new Error(`${name2} is not available in the browser bundle`);
46603
+ };
46604
+ function memorySlotOf(_target, _home, _root2, _extraHomes, _p) {
46605
+ return unavailable2("memorySlotOf");
46606
+ }
46607
+
46452
46608
  // src-ts/memory/sync.ts
46453
46609
  init_define_ATBASH_CHROMIA_NODE_URLS();
46454
46610
  init_define_ATBASH_PRIVATE_NODE_URLS();
@@ -46486,7 +46642,7 @@ async function syncLocalMemory(auth, pointer, opts = {}) {
46486
46642
  // src-ts/browser/memory-pointer-store.ts
46487
46643
  init_define_ATBASH_CHROMIA_NODE_URLS();
46488
46644
  init_define_ATBASH_PRIVATE_NODE_URLS();
46489
- var unavailable2 = (name2) => {
46645
+ var unavailable3 = (name2) => {
46490
46646
  throw new Error(`${name2} is not available in the browser bundle`);
46491
46647
  };
46492
46648
  var PointerStore = class {
@@ -46500,20 +46656,20 @@ var PointerStore = class {
46500
46656
  }
46501
46657
  };
46502
46658
  function defaultPointerPath(_workspaceDir) {
46503
- return unavailable2("defaultPointerPath");
46659
+ return unavailable3("defaultPointerPath");
46504
46660
  }
46505
46661
 
46506
46662
  // src-ts/browser/memory-file-logger.ts
46507
46663
  init_define_ATBASH_CHROMIA_NODE_URLS();
46508
46664
  init_define_ATBASH_PRIVATE_NODE_URLS();
46509
- var unavailable3 = (name2) => {
46665
+ var unavailable4 = (name2) => {
46510
46666
  throw new Error(`${name2} is not available in the browser bundle`);
46511
46667
  };
46512
46668
  function createFileLogger(_logFilePath, _hostLogger) {
46513
- return unavailable3("createFileLogger");
46669
+ return unavailable4("createFileLogger");
46514
46670
  }
46515
46671
  function defaultPluginLogPath(_workspaceDir) {
46516
- return unavailable3("defaultPluginLogPath");
46672
+ return unavailable4("defaultPluginLogPath");
46517
46673
  }
46518
46674
 
46519
46675
  // src-ts/browser/memory-read-classifier.ts
@@ -46531,7 +46687,7 @@ function classifyMemoryRead(_event, _ctx, _opts = {}) {
46531
46687
  // src-ts/browser/memory-guard-manager.ts
46532
46688
  init_define_ATBASH_CHROMIA_NODE_URLS();
46533
46689
  init_define_ATBASH_PRIVATE_NODE_URLS();
46534
- var unavailable4 = (name2) => {
46690
+ var unavailable5 = (name2) => {
46535
46691
  throw new Error(`${name2} is not available in the browser bundle`);
46536
46692
  };
46537
46693
  var MemoryGuardManager = class {
@@ -46551,7 +46707,7 @@ var MemoryGuardManager = class {
46551
46707
  }
46552
46708
  };
46553
46709
  function createMemoryGuardManager(_opts) {
46554
- return unavailable4("createMemoryGuardManager");
46710
+ return unavailable5("createMemoryGuardManager");
46555
46711
  }
46556
46712
 
46557
46713
  // src-ts/index.ts
@@ -46622,6 +46778,7 @@ export {
46622
46778
  EciesDomain,
46623
46779
  HttpClient,
46624
46780
  HttpTransportError,
46781
+ JudgeRefusalError,
46625
46782
  KEY_FILENAMES,
46626
46783
  MemoryGuardManager,
46627
46784
  MemoryIntegrityError,
@@ -46640,6 +46797,7 @@ export {
46640
46797
  columnAad,
46641
46798
  commitMemoryVersion,
46642
46799
  configureEvents,
46800
+ configureJailHold,
46643
46801
  containsEvasionCharacters2 as containsEvasionCharacters,
46644
46802
  containsSecret2 as containsSecret,
46645
46803
  createFileLogger,
@@ -46668,12 +46826,14 @@ export {
46668
46826
  getRollbackHistory,
46669
46827
  guardMemoryWrite,
46670
46828
  isEnvelope,
46829
+ isJailHeld,
46671
46830
  isValidPrivateKey2 as isValidPrivateKey,
46672
46831
  keyFingerprintOf,
46673
46832
  keyPathCandidates,
46674
46833
  loadAgent2 as loadAgent,
46675
46834
  loadAgentFromFile,
46676
46835
  loadUserConfig,
46836
+ memorySlotOf,
46677
46837
  normalizeActionForHash,
46678
46838
  normalizeActionType,
46679
46839
  normalizeForMatching2 as normalizeForMatching,
@@ -46687,6 +46847,7 @@ export {
46687
46847
  recordEvent,
46688
46848
  redactJsonStrings,
46689
46849
  redactSecrets2 as redactSecrets,
46850
+ releaseJailHolds,
46690
46851
  resolve,
46691
46852
  resolveKeyPath,
46692
46853
  rollbackMemory,