wapi-client 0.8.13 → 0.9.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.
Files changed (77) hide show
  1. package/dist/api/base-client.browser.cjs +9 -14
  2. package/dist/api/base-client.browser.js +10 -17
  3. package/dist/api/base-client.cjs +9 -14
  4. package/dist/api/base-client.js +10 -17
  5. package/dist/api/jsonrpc/jsonrpc.enums.d.ts +5 -4
  6. package/dist/api/ws-client.browser.cjs +3 -11
  7. package/dist/api/ws-client.browser.js +4 -16
  8. package/dist/api/ws-client.cjs +4 -12
  9. package/dist/api/ws-client.js +5 -17
  10. package/dist/client.browser.cjs +2 -5
  11. package/dist/client.browser.js +3 -6
  12. package/dist/client.cjs +3 -6
  13. package/dist/client.js +4 -7
  14. package/dist/fns/create-deposit/create-deposit.browser.cjs +1 -4
  15. package/dist/fns/create-deposit/create-deposit.browser.js +2 -5
  16. package/dist/fns/create-deposit/create-deposit.cjs +1 -4
  17. package/dist/fns/create-deposit/create-deposit.js +2 -5
  18. package/dist/fns/create-withdrawal/create-withdrawal.browser.cjs +1 -4
  19. package/dist/fns/create-withdrawal/create-withdrawal.browser.js +2 -5
  20. package/dist/fns/create-withdrawal/create-withdrawal.cjs +1 -4
  21. package/dist/fns/create-withdrawal/create-withdrawal.js +2 -5
  22. package/dist/fns/find-transfers/find-transfers.browser.cjs +8 -20
  23. package/dist/fns/find-transfers/find-transfers.browser.js +9 -21
  24. package/dist/fns/find-transfers/find-transfers.cjs +8 -20
  25. package/dist/fns/find-transfers/find-transfers.js +9 -21
  26. package/dist/fns/get-balance/get-balance.browser.cjs +2 -8
  27. package/dist/fns/get-balance/get-balance.browser.js +3 -9
  28. package/dist/fns/get-balance/get-balance.cjs +2 -8
  29. package/dist/fns/get-balance/get-balance.js +3 -9
  30. package/dist/fns/get-balance-history/get-balance-history.browser.cjs +1 -4
  31. package/dist/fns/get-balance-history/get-balance-history.browser.js +2 -5
  32. package/dist/fns/get-balance-history/get-balance-history.cjs +1 -4
  33. package/dist/fns/get-balance-history/get-balance-history.js +2 -5
  34. package/dist/fns/get-token/get-token.browser.cjs +1 -4
  35. package/dist/fns/get-token/get-token.browser.js +2 -5
  36. package/dist/fns/get-token/get-token.cjs +1 -4
  37. package/dist/fns/get-token/get-token.js +2 -5
  38. package/dist/fns/import-data/import-data.cjs +2 -5
  39. package/dist/fns/import-data/import-data.js +3 -6
  40. package/dist/fns/import-data/import-data.node.browser.cjs +2 -5
  41. package/dist/fns/import-data/import-data.node.browser.js +3 -6
  42. package/dist/fns/import-data/import-data.node.cjs +2 -5
  43. package/dist/fns/import-data/import-data.node.js +3 -6
  44. package/dist/fns/set-flags/set-flags.browser.cjs +3 -3
  45. package/dist/fns/set-flags/set-flags.browser.js +3 -3
  46. package/dist/fns/set-flags/set-flags.cjs +3 -3
  47. package/dist/fns/set-flags/set-flags.js +3 -3
  48. package/dist/index.browser.cjs +13 -1
  49. package/dist/index.browser.js +25 -1
  50. package/dist/index.cjs +25 -1
  51. package/dist/index.d.ts +2 -2
  52. package/dist/index.js +25 -1
  53. package/dist/lib/errors.browser.cjs +642 -214
  54. package/dist/lib/errors.browser.js +645 -214
  55. package/dist/lib/errors.cjs +652 -218
  56. package/dist/lib/errors.d.ts +1411 -342
  57. package/dist/lib/errors.js +645 -214
  58. package/dist/lib/query-builder.browser.cjs +2 -2
  59. package/dist/lib/query-builder.browser.js +2 -2
  60. package/dist/lib/query-builder.cjs +2 -2
  61. package/dist/lib/query-builder.js +2 -2
  62. package/dist/lib/stream-promise.browser.cjs +3 -4
  63. package/dist/lib/stream-promise.browser.js +4 -5
  64. package/dist/lib/stream-promise.cjs +3 -4
  65. package/dist/lib/stream-promise.js +4 -5
  66. package/dist/lib/utils.browser.cjs +9 -13
  67. package/dist/lib/utils.browser.js +9 -13
  68. package/dist/lib/utils.cjs +9 -13
  69. package/dist/lib/utils.js +9 -13
  70. package/dist/lib/validator.browser.cjs +6 -4
  71. package/dist/lib/validator.browser.js +6 -4
  72. package/dist/lib/validator.cjs +6 -4
  73. package/dist/lib/validator.js +6 -4
  74. package/dist/types/index.d.ts +2374 -1304
  75. package/dist/wapi-client-web.iife.js +6 -6
  76. package/dist/wapi-client.iife.js +6 -6
  77. package/package.json +1 -1
@@ -125,9 +125,7 @@ var BaseClient = class {
125
125
  this._requests.forEach((responseObject, key) => {
126
126
  if ("stream" in responseObject) {
127
127
  responseObject.stream.destroy(
128
- new import_errors.ConnectionError({
129
- message: "connection lost"
130
- })
128
+ new import_errors.StreamError("CONNECTION_LOST", { method: "connectionLost" })
131
129
  );
132
130
  }
133
131
  this._requests.delete(key);
@@ -294,9 +292,7 @@ var BaseClient = class {
294
292
  }
295
293
  let timeout = setTimeout(() => {
296
294
  stream.push({
297
- error: new import_errors.InputError({
298
- message: import_errors.ERROR_MESSAGES.INPUT_STREAM_TIMEOUT
299
- })
295
+ error: new import_errors.StreamError("INPUT_STREAM_TIMEOUT", { streamId })
300
296
  });
301
297
  }, 3e4);
302
298
  this._requests.set(streamStartMessage.id, {
@@ -328,9 +324,9 @@ var BaseClient = class {
328
324
  if (!isInputChunk(chunk)) {
329
325
  sendErrorToStream(
330
326
  stream,
331
- new import_errors.ValidationError({
332
- message: import_errors.ERROR_MESSAGES.INPUT_INVALID,
333
- data: chunk
327
+ new import_errors.StreamError("INVALID_INPUT_STREAM_CHUNK", {
328
+ streamId,
329
+ chunk
334
330
  })
335
331
  );
336
332
  return;
@@ -356,9 +352,9 @@ var BaseClient = class {
356
352
  }
357
353
  });
358
354
  stream.push({
359
- error: new import_errors.InputError({
360
- message: import_errors.ERROR_MESSAGES.INPUT_STREAM_ERROR,
361
- data: error
355
+ error: new import_errors.StreamError("INPUT_STREAM_ERROR", {
356
+ streamId,
357
+ error
362
358
  })
363
359
  });
364
360
  }).on("end", () => {
@@ -731,8 +727,7 @@ var BaseClient = class {
731
727
  importActionsStream(input, transform) {
732
728
  if (input !== void 0 && !(0, import_import_actions.isImportActionsTxOptions)(input)) {
733
729
  throw new import_errors.ValidationError({
734
- message: import_errors.ERROR_MESSAGES.INPUT_INVALID,
735
- data: input
730
+ input
736
731
  });
737
732
  }
738
733
  return this._streamTransaction(import_txs.APIFunctions.importActions, import_import_actions.isImportActionsTxInput, input, transform);
@@ -38,9 +38,7 @@ var __async = (__this, __arguments, generator) => {
38
38
  // src/api/base-client.ts
39
39
  import { debugLog } from "../lib/debug.browser.js";
40
40
  import {
41
- ConnectionError,
42
- ERROR_MESSAGES,
43
- InputError,
41
+ StreamError,
44
42
  ValidationError
45
43
  } from "../lib/errors.browser.js";
46
44
  import { StreamPromise } from "../lib/stream-promise.browser.js";
@@ -117,9 +115,7 @@ var BaseClient = class {
117
115
  this._requests.forEach((responseObject, key) => {
118
116
  if ("stream" in responseObject) {
119
117
  responseObject.stream.destroy(
120
- new ConnectionError({
121
- message: "connection lost"
122
- })
118
+ new StreamError("CONNECTION_LOST", { method: "connectionLost" })
123
119
  );
124
120
  }
125
121
  this._requests.delete(key);
@@ -286,9 +282,7 @@ var BaseClient = class {
286
282
  }
287
283
  let timeout = setTimeout(() => {
288
284
  stream.push({
289
- error: new InputError({
290
- message: ERROR_MESSAGES.INPUT_STREAM_TIMEOUT
291
- })
285
+ error: new StreamError("INPUT_STREAM_TIMEOUT", { streamId })
292
286
  });
293
287
  }, 3e4);
294
288
  this._requests.set(streamStartMessage.id, {
@@ -320,9 +314,9 @@ var BaseClient = class {
320
314
  if (!isInputChunk(chunk)) {
321
315
  sendErrorToStream(
322
316
  stream,
323
- new ValidationError({
324
- message: ERROR_MESSAGES.INPUT_INVALID,
325
- data: chunk
317
+ new StreamError("INVALID_INPUT_STREAM_CHUNK", {
318
+ streamId,
319
+ chunk
326
320
  })
327
321
  );
328
322
  return;
@@ -348,9 +342,9 @@ var BaseClient = class {
348
342
  }
349
343
  });
350
344
  stream.push({
351
- error: new InputError({
352
- message: ERROR_MESSAGES.INPUT_STREAM_ERROR,
353
- data: error
345
+ error: new StreamError("INPUT_STREAM_ERROR", {
346
+ streamId,
347
+ error
354
348
  })
355
349
  });
356
350
  }).on("end", () => {
@@ -723,8 +717,7 @@ var BaseClient = class {
723
717
  importActionsStream(input, transform) {
724
718
  if (input !== void 0 && !isImportActionsTxOptions(input)) {
725
719
  throw new ValidationError({
726
- message: ERROR_MESSAGES.INPUT_INVALID,
727
- data: input
720
+ input
728
721
  });
729
722
  }
730
723
  return this._streamTransaction(APIFunctions.importActions, isImportActionsTxInput, input, transform);
@@ -125,9 +125,7 @@ var BaseClient = class {
125
125
  this._requests.forEach((responseObject, key) => {
126
126
  if ("stream" in responseObject) {
127
127
  responseObject.stream.destroy(
128
- new import_errors.ConnectionError({
129
- message: "connection lost"
130
- })
128
+ new import_errors.StreamError("CONNECTION_LOST", { method: "connectionLost" })
131
129
  );
132
130
  }
133
131
  this._requests.delete(key);
@@ -294,9 +292,7 @@ var BaseClient = class {
294
292
  }
295
293
  let timeout = setTimeout(() => {
296
294
  stream.push({
297
- error: new import_errors.InputError({
298
- message: import_errors.ERROR_MESSAGES.INPUT_STREAM_TIMEOUT
299
- })
295
+ error: new import_errors.StreamError("INPUT_STREAM_TIMEOUT", { streamId })
300
296
  });
301
297
  }, 3e4);
302
298
  this._requests.set(streamStartMessage.id, {
@@ -328,9 +324,9 @@ var BaseClient = class {
328
324
  if (!isInputChunk(chunk)) {
329
325
  sendErrorToStream(
330
326
  stream,
331
- new import_errors.ValidationError({
332
- message: import_errors.ERROR_MESSAGES.INPUT_INVALID,
333
- data: chunk
327
+ new import_errors.StreamError("INVALID_INPUT_STREAM_CHUNK", {
328
+ streamId,
329
+ chunk
334
330
  })
335
331
  );
336
332
  return;
@@ -356,9 +352,9 @@ var BaseClient = class {
356
352
  }
357
353
  });
358
354
  stream.push({
359
- error: new import_errors.InputError({
360
- message: import_errors.ERROR_MESSAGES.INPUT_STREAM_ERROR,
361
- data: error
355
+ error: new import_errors.StreamError("INPUT_STREAM_ERROR", {
356
+ streamId,
357
+ error
362
358
  })
363
359
  });
364
360
  }).on("end", () => {
@@ -731,8 +727,7 @@ var BaseClient = class {
731
727
  importActionsStream(input, transform) {
732
728
  if (input !== void 0 && !(0, import_import_actions.isImportActionsTxOptions)(input)) {
733
729
  throw new import_errors.ValidationError({
734
- message: import_errors.ERROR_MESSAGES.INPUT_INVALID,
735
- data: input
730
+ input
736
731
  });
737
732
  }
738
733
  return this._streamTransaction(import_txs.APIFunctions.importActions, import_import_actions.isImportActionsTxInput, input, transform);
@@ -38,9 +38,7 @@ var __async = (__this, __arguments, generator) => {
38
38
  // src/api/base-client.ts
39
39
  import { debugLog } from "../lib/debug";
40
40
  import {
41
- ConnectionError,
42
- ERROR_MESSAGES,
43
- InputError,
41
+ StreamError,
44
42
  ValidationError
45
43
  } from "../lib/errors";
46
44
  import { StreamPromise } from "../lib/stream-promise";
@@ -117,9 +115,7 @@ var BaseClient = class {
117
115
  this._requests.forEach((responseObject, key) => {
118
116
  if ("stream" in responseObject) {
119
117
  responseObject.stream.destroy(
120
- new ConnectionError({
121
- message: "connection lost"
122
- })
118
+ new StreamError("CONNECTION_LOST", { method: "connectionLost" })
123
119
  );
124
120
  }
125
121
  this._requests.delete(key);
@@ -286,9 +282,7 @@ var BaseClient = class {
286
282
  }
287
283
  let timeout = setTimeout(() => {
288
284
  stream.push({
289
- error: new InputError({
290
- message: ERROR_MESSAGES.INPUT_STREAM_TIMEOUT
291
- })
285
+ error: new StreamError("INPUT_STREAM_TIMEOUT", { streamId })
292
286
  });
293
287
  }, 3e4);
294
288
  this._requests.set(streamStartMessage.id, {
@@ -320,9 +314,9 @@ var BaseClient = class {
320
314
  if (!isInputChunk(chunk)) {
321
315
  sendErrorToStream(
322
316
  stream,
323
- new ValidationError({
324
- message: ERROR_MESSAGES.INPUT_INVALID,
325
- data: chunk
317
+ new StreamError("INVALID_INPUT_STREAM_CHUNK", {
318
+ streamId,
319
+ chunk
326
320
  })
327
321
  );
328
322
  return;
@@ -348,9 +342,9 @@ var BaseClient = class {
348
342
  }
349
343
  });
350
344
  stream.push({
351
- error: new InputError({
352
- message: ERROR_MESSAGES.INPUT_STREAM_ERROR,
353
- data: error
345
+ error: new StreamError("INPUT_STREAM_ERROR", {
346
+ streamId,
347
+ error
354
348
  })
355
349
  });
356
350
  }).on("end", () => {
@@ -723,8 +717,7 @@ var BaseClient = class {
723
717
  importActionsStream(input, transform) {
724
718
  if (input !== void 0 && !isImportActionsTxOptions(input)) {
725
719
  throw new ValidationError({
726
- message: ERROR_MESSAGES.INPUT_INVALID,
727
- data: input
720
+ input
728
721
  });
729
722
  }
730
723
  return this._streamTransaction(APIFunctions.importActions, isImportActionsTxInput, input, transform);
@@ -1,4 +1,4 @@
1
- import { DatabaseError, InputError, ValidationError } from '../../lib/errors';
1
+ import { WAPIError } from '../../lib/errors';
2
2
  export interface JSONRPCRequest {
3
3
  jsonrpc: '2.0';
4
4
  method: string;
@@ -14,14 +14,15 @@ export interface JSONRPCRequestParams {
14
14
  };
15
15
  [key: string]: unknown;
16
16
  }
17
- export interface JSONRPCError {
17
+ export interface IJSONRPCError {
18
18
  code: number;
19
19
  message: string;
20
+ data?: unknown;
20
21
  }
21
22
  export interface JSONRPCResponse {
22
23
  jsonrpc: '2.0';
23
24
  result?: unknown;
24
- error?: JSONRPCError;
25
+ error?: IJSONRPCError;
25
26
  id: string | number | null;
26
27
  }
27
28
  export interface JSONRPCResponseObject extends JSONRPCResponse {
@@ -49,5 +50,5 @@ export interface JSONRPCResponseStream {
49
50
  };
50
51
  error?: unknown;
51
52
  }) => void;
52
- destroy: (error?: Error | DatabaseError | ValidationError | InputError) => void;
53
+ destroy: (error?: Error | WAPIError) => void;
53
54
  }
@@ -83,12 +83,7 @@ function createConnection(opts) {
83
83
  `createConnection>close(reason:${event.reason},code:${event.code},wasClean:${event.wasClean})`
84
84
  );
85
85
  if (event.code === import_connection.SocketStatuses.authError) {
86
- return clean(
87
- new import_errors.AuthenticationError({
88
- message: import_errors.ERROR_MESSAGES.AUTHENTICATION_FAILED,
89
- code: import_errors.ERROR_TYPES.AuthenticationError
90
- })
91
- );
86
+ return clean(new import_errors.AuthenticationError());
92
87
  }
93
88
  clean(new Error("WS closed"));
94
89
  }
@@ -156,10 +151,7 @@ var WsClient = class extends import_base_client.BaseClient {
156
151
  }
157
152
  _setErrored(err) {
158
153
  super._setErrored(err);
159
- if (
160
- // eslint-disable-next-line no-prototype-builtins
161
- err.hasOwnProperty("code") && err.code === import_errors.ERROR_TYPES.AuthenticationError
162
- ) {
154
+ if (err instanceof import_errors.AuthenticationError || "code" in err && err.code === import_errors.ERROR_GROUPS.AUTH.ERRORS.AUTHENTICATION_ERROR.code) {
163
155
  this._tryToReconnect = false;
164
156
  }
165
157
  }
@@ -211,7 +203,7 @@ var WsClient = class extends import_base_client.BaseClient {
211
203
  this._ready();
212
204
  break;
213
205
  } catch (err) {
214
- if (err.code === import_errors.ERROR_TYPES.AuthenticationError) {
206
+ if (err.code === import_errors.ERROR_GROUPS.AUTH.ERRORS.AUTHENTICATION_ERROR.code) {
215
207
  throw err;
216
208
  }
217
209
  if (i > nrOfAttempts - 1) {
@@ -24,11 +24,7 @@ var browser_default = WebSocket;
24
24
 
25
25
  // src/api/ws-client.ts
26
26
  import { debugLog } from "../lib/debug.browser.js";
27
- import {
28
- AuthenticationError,
29
- ERROR_MESSAGES,
30
- ERROR_TYPES
31
- } from "../lib/errors.browser.js";
27
+ import { AuthenticationError, ERROR_GROUPS } from "../lib/errors.browser.js";
32
28
  import { getConnectionParams, wait } from "../lib/utils.browser.js";
33
29
  import { BaseClient } from "./base-client.browser.js";
34
30
  import {
@@ -65,12 +61,7 @@ function createConnection(opts) {
65
61
  `createConnection>close(reason:${event.reason},code:${event.code},wasClean:${event.wasClean})`
66
62
  );
67
63
  if (event.code === SocketStatuses.authError) {
68
- return clean(
69
- new AuthenticationError({
70
- message: ERROR_MESSAGES.AUTHENTICATION_FAILED,
71
- code: ERROR_TYPES.AuthenticationError
72
- })
73
- );
64
+ return clean(new AuthenticationError());
74
65
  }
75
66
  clean(new Error("WS closed"));
76
67
  }
@@ -138,10 +129,7 @@ var WsClient = class extends BaseClient {
138
129
  }
139
130
  _setErrored(err) {
140
131
  super._setErrored(err);
141
- if (
142
- // eslint-disable-next-line no-prototype-builtins
143
- err.hasOwnProperty("code") && err.code === ERROR_TYPES.AuthenticationError
144
- ) {
132
+ if (err instanceof AuthenticationError || "code" in err && err.code === ERROR_GROUPS.AUTH.ERRORS.AUTHENTICATION_ERROR.code) {
145
133
  this._tryToReconnect = false;
146
134
  }
147
135
  }
@@ -193,7 +181,7 @@ var WsClient = class extends BaseClient {
193
181
  this._ready();
194
182
  break;
195
183
  } catch (err) {
196
- if (err.code === ERROR_TYPES.AuthenticationError) {
184
+ if (err.code === ERROR_GROUPS.AUTH.ERRORS.AUTHENTICATION_ERROR.code) {
197
185
  throw err;
198
186
  }
199
187
  if (i > nrOfAttempts - 1) {
@@ -61,7 +61,7 @@ var import_base_client = require('./base-client.cjs');
61
61
  var import_connection = require('./connection/connection.enums.cjs');
62
62
  var import__ = require('../index.cjs');
63
63
  var _a;
64
- var CLIENT_VERSION = (_a = '0.8.13') != null ? _a : "";
64
+ var CLIENT_VERSION = (_a = '0.9.0') != null ? _a : "";
65
65
  function createWsClient(opts) {
66
66
  const initialConnection = createConnection(opts);
67
67
  return new WsClient(initialConnection, opts);
@@ -89,12 +89,7 @@ function createConnection(opts) {
89
89
  `createConnection>close(reason:${event.reason},code:${event.code},wasClean:${event.wasClean})`
90
90
  );
91
91
  if (event.code === import_connection.SocketStatuses.authError) {
92
- return clean(
93
- new import_errors.AuthenticationError({
94
- message: import_errors.ERROR_MESSAGES.AUTHENTICATION_FAILED,
95
- code: import_errors.ERROR_TYPES.AuthenticationError
96
- })
97
- );
92
+ return clean(new import_errors.AuthenticationError());
98
93
  }
99
94
  clean(new Error("WS closed"));
100
95
  }
@@ -162,10 +157,7 @@ var WsClient = class extends import_base_client.BaseClient {
162
157
  }
163
158
  _setErrored(err) {
164
159
  super._setErrored(err);
165
- if (
166
- // eslint-disable-next-line no-prototype-builtins
167
- err.hasOwnProperty("code") && err.code === import_errors.ERROR_TYPES.AuthenticationError
168
- ) {
160
+ if (err instanceof import_errors.AuthenticationError || "code" in err && err.code === import_errors.ERROR_GROUPS.AUTH.ERRORS.AUTHENTICATION_ERROR.code) {
169
161
  this._tryToReconnect = false;
170
162
  }
171
163
  }
@@ -217,7 +209,7 @@ var WsClient = class extends import_base_client.BaseClient {
217
209
  this._ready();
218
210
  break;
219
211
  } catch (err) {
220
- if (err.code === import_errors.ERROR_TYPES.AuthenticationError) {
212
+ if (err.code === import_errors.ERROR_GROUPS.AUTH.ERRORS.AUTHENTICATION_ERROR.code) {
221
213
  throw err;
222
214
  }
223
215
  if (i > nrOfAttempts - 1) {
@@ -22,11 +22,7 @@ var __async = (__this, __arguments, generator) => {
22
22
  // src/api/ws-client.ts
23
23
  import WebSocket from "modern-isomorphic-ws";
24
24
  import { debugLog } from "../lib/debug";
25
- import {
26
- AuthenticationError,
27
- ERROR_MESSAGES,
28
- ERROR_TYPES
29
- } from "../lib/errors";
25
+ import { AuthenticationError, ERROR_GROUPS } from "../lib/errors";
30
26
  import { getConnectionParams, wait } from "../lib/utils";
31
27
  import { BaseClient } from "./base-client";
32
28
  import {
@@ -35,7 +31,7 @@ import {
35
31
  } from "./connection/connection.enums";
36
32
  import { WapiClientType } from "../index";
37
33
  var _a;
38
- var CLIENT_VERSION = (_a = '0.8.13') != null ? _a : "";
34
+ var CLIENT_VERSION = (_a = '0.9.0') != null ? _a : "";
39
35
  function createWsClient(opts) {
40
36
  const initialConnection = createConnection(opts);
41
37
  return new WsClient(initialConnection, opts);
@@ -63,12 +59,7 @@ function createConnection(opts) {
63
59
  `createConnection>close(reason:${event.reason},code:${event.code},wasClean:${event.wasClean})`
64
60
  );
65
61
  if (event.code === SocketStatuses.authError) {
66
- return clean(
67
- new AuthenticationError({
68
- message: ERROR_MESSAGES.AUTHENTICATION_FAILED,
69
- code: ERROR_TYPES.AuthenticationError
70
- })
71
- );
62
+ return clean(new AuthenticationError());
72
63
  }
73
64
  clean(new Error("WS closed"));
74
65
  }
@@ -136,10 +127,7 @@ var WsClient = class extends BaseClient {
136
127
  }
137
128
  _setErrored(err) {
138
129
  super._setErrored(err);
139
- if (
140
- // eslint-disable-next-line no-prototype-builtins
141
- err.hasOwnProperty("code") && err.code === ERROR_TYPES.AuthenticationError
142
- ) {
130
+ if (err instanceof AuthenticationError || "code" in err && err.code === ERROR_GROUPS.AUTH.ERRORS.AUTHENTICATION_ERROR.code) {
143
131
  this._tryToReconnect = false;
144
132
  }
145
133
  }
@@ -191,7 +179,7 @@ var WsClient = class extends BaseClient {
191
179
  this._ready();
192
180
  break;
193
181
  } catch (err) {
194
- if (err.code === ERROR_TYPES.AuthenticationError) {
182
+ if (err.code === ERROR_GROUPS.AUTH.ERRORS.AUTHENTICATION_ERROR.code) {
195
183
  throw err;
196
184
  }
197
185
  if (i > nrOfAttempts - 1) {
@@ -1123,11 +1123,8 @@ var Client = class {
1123
1123
  return import_fns.ClientFunctions.importData({ client: this }, input, options);
1124
1124
  }
1125
1125
  throw new import_errors.ValidationError({
1126
- message: import_errors.ERROR_MESSAGES.INPUT_INVALID,
1127
- data: {
1128
- input,
1129
- options
1130
- }
1126
+ input,
1127
+ options
1131
1128
  });
1132
1129
  }
1133
1130
  /**
@@ -43,7 +43,7 @@ import {
43
43
  createHttpClient,
44
44
  createWsClient
45
45
  } from "./api/index.browser.js";
46
- import { ERROR_MESSAGES, ValidationError } from "./lib/errors.browser.js";
46
+ import { ValidationError } from "./lib/errors.browser.js";
47
47
  import { ClientFunctions } from "./fns/index.browser.js";
48
48
  import {
49
49
  isImportDataFnOptions,
@@ -1107,11 +1107,8 @@ var Client = class {
1107
1107
  return ClientFunctions.importData({ client: this }, input, options);
1108
1108
  }
1109
1109
  throw new ValidationError({
1110
- message: ERROR_MESSAGES.INPUT_INVALID,
1111
- data: {
1112
- input,
1113
- options
1114
- }
1110
+ input,
1111
+ options
1115
1112
  });
1116
1113
  }
1117
1114
  /**
package/dist/client.cjs CHANGED
@@ -66,7 +66,7 @@ var import_errors = require('./lib/errors.cjs');
66
66
  var import_fns = require('./fns/index.cjs');
67
67
  var import_import_data = require('./fns/import-data/import-data.guards.cjs');
68
68
  var _a;
69
- var CLIENT_VERSION = (_a = '0.8.13') != null ? _a : "";
69
+ var CLIENT_VERSION = (_a = '0.9.0') != null ? _a : "";
70
70
  var Client = class {
71
71
  /**
72
72
  * @internal
@@ -1123,11 +1123,8 @@ var Client = class {
1123
1123
  return import_fns.ClientFunctions.importData({ client: this }, input, options);
1124
1124
  }
1125
1125
  throw new import_errors.ValidationError({
1126
- message: import_errors.ERROR_MESSAGES.INPUT_INVALID,
1127
- data: {
1128
- input,
1129
- options
1130
- }
1126
+ input,
1127
+ options
1131
1128
  });
1132
1129
  }
1133
1130
  /**
package/dist/client.js CHANGED
@@ -43,14 +43,14 @@ import {
43
43
  createHttpClient,
44
44
  createWsClient
45
45
  } from "./api";
46
- import { ERROR_MESSAGES, ValidationError } from "./lib/errors";
46
+ import { ValidationError } from "./lib/errors";
47
47
  import { ClientFunctions } from "./fns";
48
48
  import {
49
49
  isImportDataFnOptions,
50
50
  isImportDataFnInput
51
51
  } from "./fns/import-data/import-data.guards";
52
52
  var _a;
53
- var CLIENT_VERSION = (_a = '0.8.13') != null ? _a : "";
53
+ var CLIENT_VERSION = (_a = '0.9.0') != null ? _a : "";
54
54
  var Client = class {
55
55
  /**
56
56
  * @internal
@@ -1107,11 +1107,8 @@ var Client = class {
1107
1107
  return ClientFunctions.importData({ client: this }, input, options);
1108
1108
  }
1109
1109
  throw new ValidationError({
1110
- message: ERROR_MESSAGES.INPUT_INVALID,
1111
- data: {
1112
- input,
1113
- options
1114
- }
1110
+ input,
1111
+ options
1115
1112
  });
1116
1113
  }
1117
1114
  /**
@@ -61,10 +61,7 @@ function createDeposit(options, input, fnOptions) {
61
61
  }
62
62
  const token = inputCopy.token || client.getConfig("token");
63
63
  if (token === void 0) {
64
- throw new import_errors.InputError({
65
- message: import_errors.ERROR_MESSAGES.INPUT_NEEDS_TOKEN,
66
- data: input
67
- });
64
+ throw new import_errors.InputError("INPUT_NEEDS_TOKEN", { input });
68
65
  }
69
66
  const validatedOptions = inputCopy.options;
70
67
  delete inputCopy.options;
@@ -28,7 +28,7 @@ import {
28
28
  modifyObject,
29
29
  validateClientFnInput
30
30
  } from "../../lib/utils.browser.js";
31
- import { ERROR_MESSAGES, InputError } from "../../lib/errors.browser.js";
31
+ import { InputError } from "../../lib/errors.browser.js";
32
32
  var validate = getValidator(SchemaNames.CreateDepositFnInput);
33
33
  function createDeposit(options, input, fnOptions) {
34
34
  const { client } = options;
@@ -47,10 +47,7 @@ function createDeposit(options, input, fnOptions) {
47
47
  }
48
48
  const token = inputCopy.token || client.getConfig("token");
49
49
  if (token === void 0) {
50
- throw new InputError({
51
- message: ERROR_MESSAGES.INPUT_NEEDS_TOKEN,
52
- data: input
53
- });
50
+ throw new InputError("INPUT_NEEDS_TOKEN", { input });
54
51
  }
55
52
  const validatedOptions = inputCopy.options;
56
53
  delete inputCopy.options;
@@ -61,10 +61,7 @@ function createDeposit(options, input, fnOptions) {
61
61
  }
62
62
  const token = inputCopy.token || client.getConfig("token");
63
63
  if (token === void 0) {
64
- throw new import_errors.InputError({
65
- message: import_errors.ERROR_MESSAGES.INPUT_NEEDS_TOKEN,
66
- data: input
67
- });
64
+ throw new import_errors.InputError("INPUT_NEEDS_TOKEN", { input });
68
65
  }
69
66
  const validatedOptions = inputCopy.options;
70
67
  delete inputCopy.options;
@@ -28,7 +28,7 @@ import {
28
28
  modifyObject,
29
29
  validateClientFnInput
30
30
  } from "../../lib/utils";
31
- import { ERROR_MESSAGES, InputError } from "../../lib/errors";
31
+ import { InputError } from "../../lib/errors";
32
32
  var validate = getValidator(SchemaNames.CreateDepositFnInput);
33
33
  function createDeposit(options, input, fnOptions) {
34
34
  const { client } = options;
@@ -47,10 +47,7 @@ function createDeposit(options, input, fnOptions) {
47
47
  }
48
48
  const token = inputCopy.token || client.getConfig("token");
49
49
  if (token === void 0) {
50
- throw new InputError({
51
- message: ERROR_MESSAGES.INPUT_NEEDS_TOKEN,
52
- data: input
53
- });
50
+ throw new InputError("INPUT_NEEDS_TOKEN", { input });
54
51
  }
55
52
  const validatedOptions = inputCopy.options;
56
53
  delete inputCopy.options;
@@ -67,10 +67,7 @@ function createWithdrawal(options, input, fnOptions) {
67
67
  }
68
68
  const token = inputCopy.token || client.getConfig("token");
69
69
  if (token === void 0) {
70
- throw new import_errors.InputError({
71
- message: import_errors.ERROR_MESSAGES.INPUT_NEEDS_TOKEN,
72
- data: input
73
- });
70
+ throw new import_errors.InputError("INPUT_NEEDS_TOKEN", { input });
74
71
  }
75
72
  const withdrawal = __spreadProps(__spreadValues({}, inputCopy), {
76
73
  identifier: inputCopy.identifier,
@@ -19,7 +19,7 @@ var __spreadValues = (a, b) => {
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
 
21
21
  // src/fns/create-withdrawal/create-withdrawal.ts
22
- import { ERROR_MESSAGES, InputError } from "../../lib/errors.browser.js";
22
+ import { InputError } from "../../lib/errors.browser.js";
23
23
  import { getValidator, SchemaNames } from "../../lib/validator.browser.js";
24
24
  import {
25
25
  checkCopyObject,
@@ -53,10 +53,7 @@ function createWithdrawal(options, input, fnOptions) {
53
53
  }
54
54
  const token = inputCopy.token || client.getConfig("token");
55
55
  if (token === void 0) {
56
- throw new InputError({
57
- message: ERROR_MESSAGES.INPUT_NEEDS_TOKEN,
58
- data: input
59
- });
56
+ throw new InputError("INPUT_NEEDS_TOKEN", { input });
60
57
  }
61
58
  const withdrawal = __spreadProps(__spreadValues({}, inputCopy), {
62
59
  identifier: inputCopy.identifier,