ccxt 4.2.94 → 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.
Files changed (43) hide show
  1. package/README.md +3 -3
  2. package/build.sh +1 -1
  3. package/dist/ccxt.browser.js +964 -406
  4. package/dist/ccxt.browser.min.js +2 -2
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/base/errors.js +25 -64
  7. package/dist/cjs/src/base/functions/crypto.js +15 -2
  8. package/dist/cjs/src/base/functions/rsa.js +2 -2
  9. package/dist/cjs/src/base/ws/OrderBookSide.js +5 -0
  10. package/dist/cjs/src/bitstamp.js +6 -0
  11. package/dist/cjs/src/coinbase.js +615 -102
  12. package/dist/cjs/src/coinex.js +61 -55
  13. package/dist/cjs/src/gemini.js +29 -10
  14. package/dist/cjs/src/htx.js +127 -125
  15. package/dist/cjs/src/okx.js +40 -40
  16. package/dist/cjs/src/pro/coinbase.js +37 -4
  17. package/js/ccxt.d.ts +3 -3
  18. package/js/ccxt.js +3 -3
  19. package/js/src/abstract/bitstamp.d.ts +6 -0
  20. package/js/src/abstract/coinbase.d.ts +1 -0
  21. package/js/src/base/errorHierarchy.d.ts +1 -1
  22. package/js/src/base/errorHierarchy.js +1 -1
  23. package/js/src/base/errors.d.ts +26 -26
  24. package/js/src/base/errors.js +26 -66
  25. package/js/src/base/functions/crypto.d.ts +1 -1
  26. package/js/src/base/functions/crypto.js +15 -2
  27. package/js/src/base/functions/rsa.js +2 -2
  28. package/js/src/base/types.d.ts +1 -0
  29. package/js/src/base/ws/OrderBook.d.ts +8 -0
  30. package/js/src/base/ws/OrderBook.js +1 -6
  31. package/js/src/base/ws/OrderBookSide.d.ts +9 -3
  32. package/js/src/base/ws/OrderBookSide.js +6 -1
  33. package/js/src/bitstamp.js +6 -0
  34. package/js/src/coinbase.d.ts +8 -1
  35. package/js/src/coinbase.js +616 -103
  36. package/js/src/coinex.js +61 -55
  37. package/js/src/gemini.js +29 -10
  38. package/js/src/htx.d.ts +1 -0
  39. package/js/src/htx.js +128 -126
  40. package/js/src/okx.js +40 -40
  41. package/js/src/pro/coinbase.js +37 -4
  42. package/package.json +1 -1
  43. package/skip-tests.json +2 -0
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.94';
185
+ const version = '4.2.96';
186
186
  Exchange["default"].ccxtVersion = version;
187
187
  const exchanges = {
188
188
  'ace': ace,
@@ -3,74 +3,37 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  /* eslint-disable max-classes-per-file */
6
- // import { errorHierarchy } from './errorHierarchy.js';
7
- // Commented out since I'm not sure this is mandatory anymore
8
- // and does not work out of the box with esm
9
- // /* ------------------------------------------------------------------------ */
10
- // function subclass (BaseClass, classes, namespace = {}) {
11
- // for (const [className, subclasses] of Object.entries (classes)) {
12
- // const Class = Object.assign (namespace, {
13
- // /* By creating a named property, we trick compiler to assign our class constructor function a name.
14
- // Otherwise, all our error constructors would be shown as [Function: Error] in the debugger! And
15
- // the super-useful `e.constructor.name` magic wouldn't work — we then would have no chance to
16
- // obtain a error type string from an error instance programmatically! */
17
- // [className]: class extends BaseClass {
18
- // constructor (message) {
19
- // super (message)
20
- // /* A workaround to make `instanceof` work on custom Error classes in transpiled ES5.
21
- // See my blog post for the explanation of this hack:
22
- // https://medium.com/@xpl/javascript-deriving-from-error-properly-8d2f8f315801 */
23
- // this.constructor = Class
24
- // this.__proto__ = Class.prototype
25
- // this.name = className
26
- // this.message = message
27
- // // https://github.com/Microsoft/TypeScript/wiki/FAQ#why-doesnt-extending-built-ins-like-error-array-and-map-work
28
- // Object.setPrototypeOf (this, Class.prototype)
29
- // }
30
- // }
31
- // })[className]
32
- // subclass (Class, subclasses, namespace)
33
- // }
34
- // return namespace
35
- // }
36
6
  class BaseError extends Error {
37
7
  constructor(message) {
38
8
  super(message);
39
9
  this.name = 'BaseError';
40
10
  }
41
11
  }
42
- // Exchange Error errors
43
- class ExchangeError extends Error {
12
+ class ExchangeError extends BaseError {
44
13
  constructor(message) {
45
14
  super(message);
46
15
  this.name = 'ExchangeError';
47
16
  }
48
17
  }
49
- class ExchangeClosedByUser extends Error {
50
- constructor(message) {
51
- super(message);
52
- this.name = 'ExchangeClosedByUser';
53
- }
54
- }
55
18
  class AuthenticationError extends ExchangeError {
56
19
  constructor(message) {
57
20
  super(message);
58
21
  this.name = 'AuthenticationError';
59
22
  }
60
23
  }
61
- class PermissionDenied extends ExchangeError {
24
+ class PermissionDenied extends AuthenticationError {
62
25
  constructor(message) {
63
26
  super(message);
64
27
  this.name = 'PermissionDenied';
65
28
  }
66
29
  }
67
- class AccountNotEnabled extends ExchangeError {
30
+ class AccountNotEnabled extends PermissionDenied {
68
31
  constructor(message) {
69
32
  super(message);
70
33
  this.name = 'AccountNotEnabled';
71
34
  }
72
35
  }
73
- class AccountSuspended extends ExchangeError {
36
+ class AccountSuspended extends AuthenticationError {
74
37
  constructor(message) {
75
38
  super(message);
76
39
  this.name = 'AccountSuspended';
@@ -88,16 +51,16 @@ class BadRequest extends ExchangeError {
88
51
  this.name = 'BadRequest';
89
52
  }
90
53
  }
91
- class OperationRejected extends ExchangeError {
54
+ class BadSymbol extends BadRequest {
92
55
  constructor(message) {
93
56
  super(message);
94
- this.name = 'OperationRejected';
57
+ this.name = 'BadSymbol';
95
58
  }
96
59
  }
97
- class BadSymbol extends BadRequest {
60
+ class OperationRejected extends ExchangeError {
98
61
  constructor(message) {
99
62
  super(message);
100
- this.name = 'BadSymbol';
63
+ this.name = 'OperationRejected';
101
64
  }
102
65
  }
103
66
  class NoChange extends OperationRejected {
@@ -118,7 +81,7 @@ class BadResponse extends ExchangeError {
118
81
  this.name = 'BadResponse';
119
82
  }
120
83
  }
121
- class NullResponse extends ExchangeError {
84
+ class NullResponse extends BadResponse {
122
85
  constructor(message) {
123
86
  super(message);
124
87
  this.name = 'NullResponse';
@@ -148,12 +111,6 @@ class InvalidOrder extends ExchangeError {
148
111
  this.name = 'InvalidOrder';
149
112
  }
150
113
  }
151
- class ContractUnavailable extends InvalidOrder {
152
- constructor(message) {
153
- super(message);
154
- this.name = 'ContractUnavailable';
155
- }
156
- }
157
114
  class OrderNotFound extends InvalidOrder {
158
115
  constructor(message) {
159
116
  super(message);
@@ -190,25 +147,36 @@ class DuplicateOrderId extends InvalidOrder {
190
147
  this.name = 'DuplicateOrderId';
191
148
  }
192
149
  }
150
+ class ContractUnavailable extends InvalidOrder {
151
+ constructor(message) {
152
+ super(message);
153
+ this.name = 'ContractUnavailable';
154
+ }
155
+ }
193
156
  class NotSupported extends ExchangeError {
194
157
  constructor(message) {
195
158
  super(message);
196
159
  this.name = 'NotSupported';
197
160
  }
198
161
  }
199
- class OperationFailed extends BaseError {
162
+ class ProxyError extends ExchangeError {
200
163
  constructor(message) {
201
164
  super(message);
202
- this.name = 'OperationFailed';
165
+ this.name = 'ProxyError';
203
166
  }
204
167
  }
205
- class ProxyError extends ExchangeError {
168
+ class ExchangeClosedByUser extends ExchangeError {
169
+ constructor(message) {
170
+ super(message);
171
+ this.name = 'ExchangeClosedByUser';
172
+ }
173
+ }
174
+ class OperationFailed extends BaseError {
206
175
  constructor(message) {
207
176
  super(message);
208
177
  this.name = 'OperationFailed';
209
178
  }
210
179
  }
211
- // Network error
212
180
  class NetworkError extends OperationFailed {
213
181
  constructor(message) {
214
182
  super(message);
@@ -251,14 +219,7 @@ class RequestTimeout extends NetworkError {
251
219
  this.name = 'RequestTimeout';
252
220
  }
253
221
  }
254
- /* ------------------------------------------------------------------------ */
255
- // export default subclass (
256
- // // Root class
257
- // Error,
258
- // // Derived class hierarchy
259
- // errorHierarchy
260
- // )
261
- const errors = { BaseError, ExchangeClosedByUser, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, ContractUnavailable, NoChange, OperationRejected, OperationFailed, ProxyError };
222
+ var errors = { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, ProxyError, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout };
262
223
 
263
224
  exports.AccountNotEnabled = AccountNotEnabled;
264
225
  exports.AccountSuspended = AccountSuspended;
@@ -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('.');
@@ -10,6 +10,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
10
10
  // Author: github.com/frosty00
11
11
  // Email: carlo.revelli@berkeley.edu
12
12
  //
13
+ /**
14
+ *
15
+ * @param array
16
+ * @param x
17
+ */
13
18
  function bisectLeft(array, x) {
14
19
  let low = 0;
15
20
  let high = array.length - 1;
@@ -357,6 +357,12 @@ class bitstamp extends bitstamp$1 {
357
357
  'blur_address/': 1,
358
358
  'vext_withdrawal/': 1,
359
359
  'vext_address/': 1,
360
+ 'cspr_withdrawal/': 1,
361
+ 'cspr_address/': 1,
362
+ 'vchf_withdrawal/': 1,
363
+ 'vchf_address/': 1,
364
+ 'veur_withdrawal/': 1,
365
+ 'veur_address/': 1,
360
366
  },
361
367
  },
362
368
  },