wapi-client 0.8.12 → 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.
- package/dist/api/base-client.browser.cjs +12 -15
- package/dist/api/base-client.browser.js +13 -18
- package/dist/api/base-client.cjs +12 -15
- package/dist/api/base-client.js +13 -18
- package/dist/api/jsonrpc/jsonrpc.enums.d.ts +5 -4
- package/dist/api/ws-client.browser.cjs +3 -11
- package/dist/api/ws-client.browser.js +4 -16
- package/dist/api/ws-client.cjs +4 -12
- package/dist/api/ws-client.js +5 -17
- package/dist/client.browser.cjs +2 -5
- package/dist/client.browser.js +3 -6
- package/dist/client.cjs +3 -6
- package/dist/client.js +4 -7
- package/dist/fns/create-deposit/create-deposit.browser.cjs +1 -4
- package/dist/fns/create-deposit/create-deposit.browser.js +2 -5
- package/dist/fns/create-deposit/create-deposit.cjs +1 -4
- package/dist/fns/create-deposit/create-deposit.js +2 -5
- package/dist/fns/create-withdrawal/create-withdrawal.browser.cjs +1 -4
- package/dist/fns/create-withdrawal/create-withdrawal.browser.js +2 -5
- package/dist/fns/create-withdrawal/create-withdrawal.cjs +1 -4
- package/dist/fns/create-withdrawal/create-withdrawal.js +2 -5
- package/dist/fns/find-transfers/find-transfers.browser.cjs +8 -20
- package/dist/fns/find-transfers/find-transfers.browser.js +9 -21
- package/dist/fns/find-transfers/find-transfers.cjs +8 -20
- package/dist/fns/find-transfers/find-transfers.js +9 -21
- package/dist/fns/get-balance/get-balance.browser.cjs +2 -8
- package/dist/fns/get-balance/get-balance.browser.js +3 -9
- package/dist/fns/get-balance/get-balance.cjs +2 -8
- package/dist/fns/get-balance/get-balance.js +3 -9
- package/dist/fns/get-balance-history/get-balance-history.browser.cjs +1 -4
- package/dist/fns/get-balance-history/get-balance-history.browser.js +2 -5
- package/dist/fns/get-balance-history/get-balance-history.cjs +1 -4
- package/dist/fns/get-balance-history/get-balance-history.js +2 -5
- package/dist/fns/get-token/get-token.browser.cjs +1 -4
- package/dist/fns/get-token/get-token.browser.js +2 -5
- package/dist/fns/get-token/get-token.cjs +1 -4
- package/dist/fns/get-token/get-token.js +2 -5
- package/dist/fns/import-data/import-data.cjs +2 -5
- package/dist/fns/import-data/import-data.js +3 -6
- package/dist/fns/import-data/import-data.node.browser.cjs +2 -5
- package/dist/fns/import-data/import-data.node.browser.js +3 -6
- package/dist/fns/import-data/import-data.node.cjs +2 -5
- package/dist/fns/import-data/import-data.node.js +3 -6
- package/dist/fns/set-flags/set-flags.browser.cjs +3 -3
- package/dist/fns/set-flags/set-flags.browser.js +3 -3
- package/dist/fns/set-flags/set-flags.cjs +3 -3
- package/dist/fns/set-flags/set-flags.js +3 -3
- package/dist/index.browser.cjs +13 -1
- package/dist/index.browser.js +25 -1
- package/dist/index.cjs +25 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +25 -1
- package/dist/lib/errors.browser.cjs +642 -214
- package/dist/lib/errors.browser.js +645 -214
- package/dist/lib/errors.cjs +652 -218
- package/dist/lib/errors.d.ts +1411 -342
- package/dist/lib/errors.js +645 -214
- package/dist/lib/isomorphic/web/streams.browser.cjs +3 -0
- package/dist/lib/isomorphic/web/streams.browser.js +3 -0
- package/dist/lib/query-builder.browser.cjs +2 -2
- package/dist/lib/query-builder.browser.js +2 -2
- package/dist/lib/query-builder.cjs +2 -2
- package/dist/lib/query-builder.js +2 -2
- package/dist/lib/stream-promise.browser.cjs +3 -4
- package/dist/lib/stream-promise.browser.js +4 -5
- package/dist/lib/stream-promise.cjs +3 -4
- package/dist/lib/stream-promise.js +4 -5
- package/dist/lib/utils.browser.cjs +9 -13
- package/dist/lib/utils.browser.js +9 -13
- package/dist/lib/utils.cjs +9 -13
- package/dist/lib/utils.js +9 -13
- package/dist/lib/validator.browser.cjs +6 -4
- package/dist/lib/validator.browser.js +6 -4
- package/dist/lib/validator.cjs +6 -4
- package/dist/lib/validator.js +6 -4
- package/dist/types/index.d.ts +2374 -1304
- package/dist/wapi-client-web.iife.js +6 -6
- package/dist/wapi-client.iife.js +6 -6
- 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.
|
|
129
|
-
message: "connection lost"
|
|
130
|
-
})
|
|
128
|
+
new import_errors.StreamError("CONNECTION_LOST", { method: "connectionLost" })
|
|
131
129
|
);
|
|
132
130
|
}
|
|
133
131
|
this._requests.delete(key);
|
|
@@ -192,7 +190,9 @@ var BaseClient = class {
|
|
|
192
190
|
return;
|
|
193
191
|
}
|
|
194
192
|
stream.push(message);
|
|
195
|
-
stream.
|
|
193
|
+
if (!stream.destroyed) {
|
|
194
|
+
stream.push(null);
|
|
195
|
+
}
|
|
196
196
|
this._requests.delete(message.id);
|
|
197
197
|
if (this.connectionType === import__.WapiClientType.ws) {
|
|
198
198
|
this._send({
|
|
@@ -292,9 +292,7 @@ var BaseClient = class {
|
|
|
292
292
|
}
|
|
293
293
|
let timeout = setTimeout(() => {
|
|
294
294
|
stream.push({
|
|
295
|
-
error: new import_errors.
|
|
296
|
-
message: import_errors.ERROR_MESSAGES.INPUT_STREAM_TIMEOUT
|
|
297
|
-
})
|
|
295
|
+
error: new import_errors.StreamError("INPUT_STREAM_TIMEOUT", { streamId })
|
|
298
296
|
});
|
|
299
297
|
}, 3e4);
|
|
300
298
|
this._requests.set(streamStartMessage.id, {
|
|
@@ -326,9 +324,9 @@ var BaseClient = class {
|
|
|
326
324
|
if (!isInputChunk(chunk)) {
|
|
327
325
|
sendErrorToStream(
|
|
328
326
|
stream,
|
|
329
|
-
new import_errors.
|
|
330
|
-
|
|
331
|
-
|
|
327
|
+
new import_errors.StreamError("INVALID_INPUT_STREAM_CHUNK", {
|
|
328
|
+
streamId,
|
|
329
|
+
chunk
|
|
332
330
|
})
|
|
333
331
|
);
|
|
334
332
|
return;
|
|
@@ -354,9 +352,9 @@ var BaseClient = class {
|
|
|
354
352
|
}
|
|
355
353
|
});
|
|
356
354
|
stream.push({
|
|
357
|
-
error: new import_errors.
|
|
358
|
-
|
|
359
|
-
|
|
355
|
+
error: new import_errors.StreamError("INPUT_STREAM_ERROR", {
|
|
356
|
+
streamId,
|
|
357
|
+
error
|
|
360
358
|
})
|
|
361
359
|
});
|
|
362
360
|
}).on("end", () => {
|
|
@@ -729,8 +727,7 @@ var BaseClient = class {
|
|
|
729
727
|
importActionsStream(input, transform) {
|
|
730
728
|
if (input !== void 0 && !(0, import_import_actions.isImportActionsTxOptions)(input)) {
|
|
731
729
|
throw new import_errors.ValidationError({
|
|
732
|
-
|
|
733
|
-
data: input
|
|
730
|
+
input
|
|
734
731
|
});
|
|
735
732
|
}
|
|
736
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
|
-
|
|
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
|
|
121
|
-
message: "connection lost"
|
|
122
|
-
})
|
|
118
|
+
new StreamError("CONNECTION_LOST", { method: "connectionLost" })
|
|
123
119
|
);
|
|
124
120
|
}
|
|
125
121
|
this._requests.delete(key);
|
|
@@ -184,7 +180,9 @@ var BaseClient = class {
|
|
|
184
180
|
return;
|
|
185
181
|
}
|
|
186
182
|
stream.push(message);
|
|
187
|
-
stream.
|
|
183
|
+
if (!stream.destroyed) {
|
|
184
|
+
stream.push(null);
|
|
185
|
+
}
|
|
188
186
|
this._requests.delete(message.id);
|
|
189
187
|
if (this.connectionType === WapiClientType.ws) {
|
|
190
188
|
this._send({
|
|
@@ -284,9 +282,7 @@ var BaseClient = class {
|
|
|
284
282
|
}
|
|
285
283
|
let timeout = setTimeout(() => {
|
|
286
284
|
stream.push({
|
|
287
|
-
error: new
|
|
288
|
-
message: ERROR_MESSAGES.INPUT_STREAM_TIMEOUT
|
|
289
|
-
})
|
|
285
|
+
error: new StreamError("INPUT_STREAM_TIMEOUT", { streamId })
|
|
290
286
|
});
|
|
291
287
|
}, 3e4);
|
|
292
288
|
this._requests.set(streamStartMessage.id, {
|
|
@@ -318,9 +314,9 @@ var BaseClient = class {
|
|
|
318
314
|
if (!isInputChunk(chunk)) {
|
|
319
315
|
sendErrorToStream(
|
|
320
316
|
stream,
|
|
321
|
-
new
|
|
322
|
-
|
|
323
|
-
|
|
317
|
+
new StreamError("INVALID_INPUT_STREAM_CHUNK", {
|
|
318
|
+
streamId,
|
|
319
|
+
chunk
|
|
324
320
|
})
|
|
325
321
|
);
|
|
326
322
|
return;
|
|
@@ -346,9 +342,9 @@ var BaseClient = class {
|
|
|
346
342
|
}
|
|
347
343
|
});
|
|
348
344
|
stream.push({
|
|
349
|
-
error: new
|
|
350
|
-
|
|
351
|
-
|
|
345
|
+
error: new StreamError("INPUT_STREAM_ERROR", {
|
|
346
|
+
streamId,
|
|
347
|
+
error
|
|
352
348
|
})
|
|
353
349
|
});
|
|
354
350
|
}).on("end", () => {
|
|
@@ -721,8 +717,7 @@ var BaseClient = class {
|
|
|
721
717
|
importActionsStream(input, transform) {
|
|
722
718
|
if (input !== void 0 && !isImportActionsTxOptions(input)) {
|
|
723
719
|
throw new ValidationError({
|
|
724
|
-
|
|
725
|
-
data: input
|
|
720
|
+
input
|
|
726
721
|
});
|
|
727
722
|
}
|
|
728
723
|
return this._streamTransaction(APIFunctions.importActions, isImportActionsTxInput, input, transform);
|
package/dist/api/base-client.cjs
CHANGED
|
@@ -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.
|
|
129
|
-
message: "connection lost"
|
|
130
|
-
})
|
|
128
|
+
new import_errors.StreamError("CONNECTION_LOST", { method: "connectionLost" })
|
|
131
129
|
);
|
|
132
130
|
}
|
|
133
131
|
this._requests.delete(key);
|
|
@@ -192,7 +190,9 @@ var BaseClient = class {
|
|
|
192
190
|
return;
|
|
193
191
|
}
|
|
194
192
|
stream.push(message);
|
|
195
|
-
stream.
|
|
193
|
+
if (!stream.destroyed) {
|
|
194
|
+
stream.push(null);
|
|
195
|
+
}
|
|
196
196
|
this._requests.delete(message.id);
|
|
197
197
|
if (this.connectionType === import__.WapiClientType.ws) {
|
|
198
198
|
this._send({
|
|
@@ -292,9 +292,7 @@ var BaseClient = class {
|
|
|
292
292
|
}
|
|
293
293
|
let timeout = setTimeout(() => {
|
|
294
294
|
stream.push({
|
|
295
|
-
error: new import_errors.
|
|
296
|
-
message: import_errors.ERROR_MESSAGES.INPUT_STREAM_TIMEOUT
|
|
297
|
-
})
|
|
295
|
+
error: new import_errors.StreamError("INPUT_STREAM_TIMEOUT", { streamId })
|
|
298
296
|
});
|
|
299
297
|
}, 3e4);
|
|
300
298
|
this._requests.set(streamStartMessage.id, {
|
|
@@ -326,9 +324,9 @@ var BaseClient = class {
|
|
|
326
324
|
if (!isInputChunk(chunk)) {
|
|
327
325
|
sendErrorToStream(
|
|
328
326
|
stream,
|
|
329
|
-
new import_errors.
|
|
330
|
-
|
|
331
|
-
|
|
327
|
+
new import_errors.StreamError("INVALID_INPUT_STREAM_CHUNK", {
|
|
328
|
+
streamId,
|
|
329
|
+
chunk
|
|
332
330
|
})
|
|
333
331
|
);
|
|
334
332
|
return;
|
|
@@ -354,9 +352,9 @@ var BaseClient = class {
|
|
|
354
352
|
}
|
|
355
353
|
});
|
|
356
354
|
stream.push({
|
|
357
|
-
error: new import_errors.
|
|
358
|
-
|
|
359
|
-
|
|
355
|
+
error: new import_errors.StreamError("INPUT_STREAM_ERROR", {
|
|
356
|
+
streamId,
|
|
357
|
+
error
|
|
360
358
|
})
|
|
361
359
|
});
|
|
362
360
|
}).on("end", () => {
|
|
@@ -729,8 +727,7 @@ var BaseClient = class {
|
|
|
729
727
|
importActionsStream(input, transform) {
|
|
730
728
|
if (input !== void 0 && !(0, import_import_actions.isImportActionsTxOptions)(input)) {
|
|
731
729
|
throw new import_errors.ValidationError({
|
|
732
|
-
|
|
733
|
-
data: input
|
|
730
|
+
input
|
|
734
731
|
});
|
|
735
732
|
}
|
|
736
733
|
return this._streamTransaction(import_txs.APIFunctions.importActions, import_import_actions.isImportActionsTxInput, input, transform);
|
package/dist/api/base-client.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
121
|
-
message: "connection lost"
|
|
122
|
-
})
|
|
118
|
+
new StreamError("CONNECTION_LOST", { method: "connectionLost" })
|
|
123
119
|
);
|
|
124
120
|
}
|
|
125
121
|
this._requests.delete(key);
|
|
@@ -184,7 +180,9 @@ var BaseClient = class {
|
|
|
184
180
|
return;
|
|
185
181
|
}
|
|
186
182
|
stream.push(message);
|
|
187
|
-
stream.
|
|
183
|
+
if (!stream.destroyed) {
|
|
184
|
+
stream.push(null);
|
|
185
|
+
}
|
|
188
186
|
this._requests.delete(message.id);
|
|
189
187
|
if (this.connectionType === WapiClientType.ws) {
|
|
190
188
|
this._send({
|
|
@@ -284,9 +282,7 @@ var BaseClient = class {
|
|
|
284
282
|
}
|
|
285
283
|
let timeout = setTimeout(() => {
|
|
286
284
|
stream.push({
|
|
287
|
-
error: new
|
|
288
|
-
message: ERROR_MESSAGES.INPUT_STREAM_TIMEOUT
|
|
289
|
-
})
|
|
285
|
+
error: new StreamError("INPUT_STREAM_TIMEOUT", { streamId })
|
|
290
286
|
});
|
|
291
287
|
}, 3e4);
|
|
292
288
|
this._requests.set(streamStartMessage.id, {
|
|
@@ -318,9 +314,9 @@ var BaseClient = class {
|
|
|
318
314
|
if (!isInputChunk(chunk)) {
|
|
319
315
|
sendErrorToStream(
|
|
320
316
|
stream,
|
|
321
|
-
new
|
|
322
|
-
|
|
323
|
-
|
|
317
|
+
new StreamError("INVALID_INPUT_STREAM_CHUNK", {
|
|
318
|
+
streamId,
|
|
319
|
+
chunk
|
|
324
320
|
})
|
|
325
321
|
);
|
|
326
322
|
return;
|
|
@@ -346,9 +342,9 @@ var BaseClient = class {
|
|
|
346
342
|
}
|
|
347
343
|
});
|
|
348
344
|
stream.push({
|
|
349
|
-
error: new
|
|
350
|
-
|
|
351
|
-
|
|
345
|
+
error: new StreamError("INPUT_STREAM_ERROR", {
|
|
346
|
+
streamId,
|
|
347
|
+
error
|
|
352
348
|
})
|
|
353
349
|
});
|
|
354
350
|
}).on("end", () => {
|
|
@@ -721,8 +717,7 @@ var BaseClient = class {
|
|
|
721
717
|
importActionsStream(input, transform) {
|
|
722
718
|
if (input !== void 0 && !isImportActionsTxOptions(input)) {
|
|
723
719
|
throw new ValidationError({
|
|
724
|
-
|
|
725
|
-
data: input
|
|
720
|
+
input
|
|
726
721
|
});
|
|
727
722
|
}
|
|
728
723
|
return this._streamTransaction(APIFunctions.importActions, isImportActionsTxInput, input, transform);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
|
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?:
|
|
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 |
|
|
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.
|
|
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 ===
|
|
184
|
+
if (err.code === ERROR_GROUPS.AUTH.ERRORS.AUTHENTICATION_ERROR.code) {
|
|
197
185
|
throw err;
|
|
198
186
|
}
|
|
199
187
|
if (i > nrOfAttempts - 1) {
|
package/dist/api/ws-client.cjs
CHANGED
|
@@ -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.
|
|
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.
|
|
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) {
|
package/dist/api/ws-client.js
CHANGED
|
@@ -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.
|
|
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 ===
|
|
182
|
+
if (err.code === ERROR_GROUPS.AUTH.ERRORS.AUTHENTICATION_ERROR.code) {
|
|
195
183
|
throw err;
|
|
196
184
|
}
|
|
197
185
|
if (i > nrOfAttempts - 1) {
|
package/dist/client.browser.cjs
CHANGED
|
@@ -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
|
-
|
|
1127
|
-
|
|
1128
|
-
input,
|
|
1129
|
-
options
|
|
1130
|
-
}
|
|
1126
|
+
input,
|
|
1127
|
+
options
|
|
1131
1128
|
});
|
|
1132
1129
|
}
|
|
1133
1130
|
/**
|
package/dist/client.browser.js
CHANGED
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
createHttpClient,
|
|
44
44
|
createWsClient
|
|
45
45
|
} from "./api/index.browser.js";
|
|
46
|
-
import {
|
|
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
|
-
|
|
1111
|
-
|
|
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.
|
|
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
|
-
|
|
1127
|
-
|
|
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 {
|
|
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.
|
|
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
|
-
|
|
1111
|
-
|
|
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 {
|
|
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 {
|
|
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;
|