@wishknish/knishio-client-ts 0.9.2 → 0.9.3

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/index.js CHANGED
@@ -1843,11 +1843,15 @@ function hexToBase64(hexString) {
1843
1843
  try {
1844
1844
  const cleanHex = hexString.replace(/^0x/i, "");
1845
1845
  const bytes = hexStringToBuffer(cleanHex);
1846
- if (typeof btoa !== "undefined") {
1847
- return btoa(String.fromCharCode(...bytes));
1848
- } else {
1846
+ if (typeof Buffer !== "undefined") {
1849
1847
  return Buffer.from(bytes).toString("base64");
1850
1848
  }
1849
+ let binary = "";
1850
+ const CHUNK_SIZE = 32768;
1851
+ for (let i = 0; i < bytes.length; i += CHUNK_SIZE) {
1852
+ binary += String.fromCharCode(...bytes.subarray(i, i + CHUNK_SIZE));
1853
+ }
1854
+ return btoa(binary);
1851
1855
  } catch (error) {
1852
1856
  throw new Error(`Failed to convert hex to base64: ${error instanceof Error ? error.message : String(error)}`);
1853
1857
  }
@@ -3805,11 +3809,26 @@ var Wallet = class _Wallet {
3805
3809
  return new Uint8Array(decryptedContent);
3806
3810
  }
3807
3811
  serializeKey(key) {
3808
- return btoa(String.fromCharCode(...key));
3812
+ if (typeof Buffer !== "undefined") {
3813
+ return Buffer.from(key).toString("base64");
3814
+ }
3815
+ let binary = "";
3816
+ const CHUNK_SIZE = 32768;
3817
+ for (let i = 0; i < key.length; i += CHUNK_SIZE) {
3818
+ binary += String.fromCharCode(...key.subarray(i, i + CHUNK_SIZE));
3819
+ }
3820
+ return btoa(binary);
3809
3821
  }
3810
3822
  deserializeKey(serializedKey) {
3823
+ if (typeof Buffer !== "undefined") {
3824
+ return new Uint8Array(Buffer.from(serializedKey, "base64"));
3825
+ }
3811
3826
  const binaryString = atob(serializedKey);
3812
- return new Uint8Array([...binaryString].map((char) => char.charCodeAt(0)));
3827
+ const bytes = new Uint8Array(binaryString.length);
3828
+ for (let i = 0; i < binaryString.length; i++) {
3829
+ bytes[i] = binaryString.charCodeAt(i);
3830
+ }
3831
+ return bytes;
3813
3832
  }
3814
3833
  };
3815
3834
  var hexStringRegex = /^[0-9a-fA-F]+$/;
@@ -4176,10 +4195,11 @@ function deepCloning(o, h) {
4176
4195
  return r || o;
4177
4196
  }
4178
4197
  function chunkArray(arr, size) {
4179
- if (!arr.length) {
4180
- return [];
4198
+ const chunks = [];
4199
+ for (let i = 0; i < arr.length; i += size) {
4200
+ chunks.push(arr.slice(i, i + size));
4181
4201
  }
4182
- return [arr.slice(0, size)].concat(chunkArray(arr.slice(size), size));
4202
+ return chunks;
4183
4203
  }
4184
4204
  function diff(...arrays) {
4185
4205
  return [].concat(...arrays.map((arr, i) => {
@@ -7007,6 +7027,7 @@ var ValidationChainBuilder = class {
7007
7027
  constructor(service) {
7008
7028
  this.service = service;
7009
7029
  }
7030
+ service;
7010
7031
  validators = [];
7011
7032
  /**
7012
7033
  * Add a schema validation step