ccxt 4.2.95 → 4.2.96

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/cjs/ccxt.js CHANGED
@@ -182,7 +182,7 @@ var woo$1 = require('./src/pro/woo.js');
182
182
 
183
183
  //-----------------------------------------------------------------------------
184
184
  // this is updated by vss.js when building
185
- const version = '4.2.95';
185
+ const version = '4.2.96';
186
186
  Exchange["default"].ccxtVersion = version;
187
187
  const exchanges = {
188
188
  'ace': ace,
@@ -8,6 +8,7 @@ var base64 = require('../../static_dependencies/jsencrypt/lib/asn1js/base64.js')
8
8
  var asn1 = require('../../static_dependencies/jsencrypt/lib/asn1js/asn1.js');
9
9
  var secp256k1 = require('../../static_dependencies/noble-curves/secp256k1.js');
10
10
  var p256 = require('../../static_dependencies/noble-curves/p256.js');
11
+ var utils = require('../../static_dependencies/noble-curves/abstract/utils.js');
11
12
 
12
13
  /* ------------------------------------------------------------------------ */
13
14
  /* ------------------------------------------------------------------------ */
@@ -31,7 +32,7 @@ const hmac = (request, secret, hash, digest = 'hex') => {
31
32
  return encoders[digest](binary);
32
33
  };
33
34
  /* ............................................. */
34
- function ecdsa(request, secret, curve, prehash = null) {
35
+ function ecdsa(request, secret, curve, prehash = null, fixedLength = false) {
35
36
  if (prehash) {
36
37
  request = hash(request, prehash, 'hex');
37
38
  }
@@ -65,7 +66,19 @@ function ecdsa(request, secret, curve, prehash = null) {
65
66
  throw new Error('Unsupported key format');
66
67
  }
67
68
  }
68
- const signature = curve.sign(request, secret);
69
+ let signature = curve.sign(request, secret, {
70
+ lowS: true,
71
+ });
72
+ const minimumSize = (BigInt(1) << (BigInt(8) * BigInt(31))) - BigInt(1);
73
+ const halfOrder = curve.CURVE.n / BigInt(2);
74
+ let counter = 0;
75
+ while (fixedLength && (signature.r > halfOrder || signature.r <= minimumSize || signature.s <= minimumSize)) {
76
+ signature = curve.sign(request, secret, {
77
+ lowS: true,
78
+ extraEntropy: utils.numberToBytesLE(BigInt(counter), 32)
79
+ });
80
+ counter += 1;
81
+ }
69
82
  return {
70
83
  'r': signature.r.toString(16),
71
84
  's': signature.s.toString(16),
@@ -38,8 +38,8 @@ function jwt(request, secret, hash, isRSA = false, opts = {}) {
38
38
  }
39
39
  else if (algoType === 'ES') {
40
40
  const signedHash = crypto.ecdsa(token, index.utf8.encode(secret), p256.P256, hash);
41
- const r = (signedHash.r.length === 64) ? signedHash.r : '0' + signedHash.r;
42
- const s = (signedHash.s.length === 64) ? signedHash.s : '0' + signedHash.s;
41
+ const r = signedHash.r.padStart(64, '0');
42
+ const s = signedHash.s.padStart(64, '0');
43
43
  signature = encode.urlencodeBase64(encode.binaryToBase64(encode.base16ToBinary(r + s)));
44
44
  }
45
45
  return [token, signature].join('.');