bitget-api 3.0.11 → 3.1.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/README.md +25 -26
- package/dist/cjs/index.d.ts +0 -10
- package/dist/cjs/index.js +0 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/rest-client-v2.d.ts +1 -1
- package/dist/cjs/rest-client-v3.d.ts +1 -1
- package/dist/cjs/types/request/v2/futures.d.ts +1 -1
- package/dist/cjs/types/shared.d.ts +6 -0
- package/dist/cjs/types/websockets/ws-general.d.ts +3 -1
- package/dist/cjs/util/BaseRestClient.js +5 -0
- package/dist/cjs/util/BaseRestClient.js.map +1 -1
- package/dist/mjs/index.d.ts +0 -10
- package/dist/mjs/index.js +0 -10
- package/dist/mjs/index.js.map +1 -1
- package/dist/mjs/rest-client-v2.d.ts +1 -1
- package/dist/mjs/rest-client-v3.d.ts +1 -1
- package/dist/mjs/types/request/v2/futures.d.ts +1 -1
- package/dist/mjs/types/shared.d.ts +6 -0
- package/dist/mjs/types/websockets/ws-general.d.ts +3 -1
- package/dist/mjs/util/BaseRestClient.js +5 -0
- package/dist/mjs/util/BaseRestClient.js.map +1 -1
- package/package.json +4 -3
- package/dist/cjs/broker-client.d.ts +0 -127
- package/dist/cjs/broker-client.js +0 -165
- package/dist/cjs/broker-client.js.map +0 -1
- package/dist/cjs/futures-client.d.ts +0 -184
- package/dist/cjs/futures-client.js +0 -480
- package/dist/cjs/futures-client.js.map +0 -1
- package/dist/cjs/spot-client.d.ts +0 -154
- package/dist/cjs/spot-client.js +0 -280
- package/dist/cjs/spot-client.js.map +0 -1
- package/dist/cjs/types/request/v1/brokerV1.d.ts +0 -23
- package/dist/cjs/types/request/v1/brokerV1.js +0 -3
- package/dist/cjs/types/request/v1/brokerV1.js.map +0 -1
- package/dist/cjs/types/request/v1/futuresV1.d.ts +0 -168
- package/dist/cjs/types/request/v1/futuresV1.js +0 -3
- package/dist/cjs/types/request/v1/futuresV1.js.map +0 -1
- package/dist/cjs/types/request/v1/spotV1.d.ts +0 -105
- package/dist/cjs/types/request/v1/spotV1.js +0 -3
- package/dist/cjs/types/request/v1/spotV1.js.map +0 -1
- package/dist/cjs/types/response/v1/futures.d.ts +0 -72
- package/dist/cjs/types/response/v1/futures.js +0 -3
- package/dist/cjs/types/response/v1/futures.js.map +0 -1
- package/dist/cjs/types/response/v1/shared.d.ts +0 -15
- package/dist/cjs/types/response/v1/shared.js +0 -3
- package/dist/cjs/types/response/v1/shared.js.map +0 -1
- package/dist/cjs/types/response/v1/spot.d.ts +0 -65
- package/dist/cjs/types/response/v1/spot.js +0 -3
- package/dist/cjs/types/response/v1/spot.js.map +0 -1
- package/dist/cjs/websocket-client-legacy-v1.d.ts +0 -127
- package/dist/cjs/websocket-client-legacy-v1.js +0 -509
- package/dist/cjs/websocket-client-legacy-v1.js.map +0 -1
- package/dist/mjs/broker-client.d.ts +0 -127
- package/dist/mjs/broker-client.js +0 -158
- package/dist/mjs/broker-client.js.map +0 -1
- package/dist/mjs/futures-client.d.ts +0 -184
- package/dist/mjs/futures-client.js +0 -473
- package/dist/mjs/futures-client.js.map +0 -1
- package/dist/mjs/spot-client.d.ts +0 -154
- package/dist/mjs/spot-client.js +0 -273
- package/dist/mjs/spot-client.js.map +0 -1
- package/dist/mjs/types/request/v1/brokerV1.d.ts +0 -23
- package/dist/mjs/types/request/v1/brokerV1.js +0 -2
- package/dist/mjs/types/request/v1/brokerV1.js.map +0 -1
- package/dist/mjs/types/request/v1/futuresV1.d.ts +0 -168
- package/dist/mjs/types/request/v1/futuresV1.js +0 -2
- package/dist/mjs/types/request/v1/futuresV1.js.map +0 -1
- package/dist/mjs/types/request/v1/spotV1.d.ts +0 -105
- package/dist/mjs/types/request/v1/spotV1.js +0 -2
- package/dist/mjs/types/request/v1/spotV1.js.map +0 -1
- package/dist/mjs/types/response/v1/futures.d.ts +0 -72
- package/dist/mjs/types/response/v1/futures.js +0 -2
- package/dist/mjs/types/response/v1/futures.js.map +0 -1
- package/dist/mjs/types/response/v1/shared.d.ts +0 -15
- package/dist/mjs/types/response/v1/shared.js +0 -2
- package/dist/mjs/types/response/v1/shared.js.map +0 -1
- package/dist/mjs/types/response/v1/spot.d.ts +0 -65
- package/dist/mjs/types/response/v1/spot.js +0 -2
- package/dist/mjs/types/response/v1/spot.js.map +0 -1
- package/dist/mjs/websocket-client-legacy-v1.d.ts +0 -127
- package/dist/mjs/websocket-client-legacy-v1.js +0 -502
- package/dist/mjs/websocket-client-legacy-v1.js.map +0 -1
|
@@ -1,509 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.WebsocketClientLegacyV1 = void 0;
|
|
7
|
-
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
|
|
8
|
-
const events_1 = require("events");
|
|
9
|
-
const isomorphic_ws_1 = __importDefault(require("isomorphic-ws"));
|
|
10
|
-
const logger_js_1 = require("./util/logger.js");
|
|
11
|
-
const requestUtils_js_1 = require("./util/requestUtils.js");
|
|
12
|
-
const webCryptoAPI_js_1 = require("./util/webCryptoAPI.js");
|
|
13
|
-
const websocket_util_js_1 = require("./util/websocket-util.js");
|
|
14
|
-
const WsStore_js_1 = __importDefault(require("./util/WsStore.js"));
|
|
15
|
-
const WsStore_types_js_1 = require("./util/WsStore.types.js");
|
|
16
|
-
const LOGGER_CATEGORY = { category: 'bitget-ws' };
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated use WebsocketClientV2 instead
|
|
19
|
-
*/
|
|
20
|
-
class WebsocketClientLegacyV1 extends events_1.EventEmitter {
|
|
21
|
-
logger;
|
|
22
|
-
options;
|
|
23
|
-
wsStore;
|
|
24
|
-
constructor(options, logger) {
|
|
25
|
-
super();
|
|
26
|
-
this.logger = logger || logger_js_1.DefaultLogger;
|
|
27
|
-
this.wsStore = new WsStore_js_1.default(this.logger);
|
|
28
|
-
this.options = {
|
|
29
|
-
pongTimeout: 1000,
|
|
30
|
-
pingInterval: 10000,
|
|
31
|
-
reconnectTimeout: 500,
|
|
32
|
-
recvWindow: 0,
|
|
33
|
-
authPrivateConnectionsOnConnect: true,
|
|
34
|
-
authPrivateRequests: false,
|
|
35
|
-
...options,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Subscribe to topics & track/persist them. They will be automatically resubscribed to if the connection drops/reconnects.
|
|
40
|
-
* @param wsTopics topic or list of topics
|
|
41
|
-
* @param isPrivateTopic optional - the library will try to detect private topics, you can use this to mark a topic as private (if the topic isn't recognised yet)
|
|
42
|
-
*/
|
|
43
|
-
subscribe(wsTopics, isPrivateTopic) {
|
|
44
|
-
const topics = Array.isArray(wsTopics) ? wsTopics : [wsTopics];
|
|
45
|
-
topics.forEach((topic) => {
|
|
46
|
-
const wsKey = (0, websocket_util_js_1.getWsKeyForTopicV1)(topic, isPrivateTopic);
|
|
47
|
-
// Persist this topic to the expected topics list
|
|
48
|
-
this.wsStore.addTopic(wsKey, topic);
|
|
49
|
-
// if connected, send subscription request
|
|
50
|
-
if (this.wsStore.isConnectionState(wsKey, WsStore_types_js_1.WsConnectionStateEnum.CONNECTED)) {
|
|
51
|
-
// if not authenticated, dont sub to private topics yet.
|
|
52
|
-
// This'll happen automatically once authenticated
|
|
53
|
-
const isAuthenticated = this.wsStore.get(wsKey)?.isAuthenticated;
|
|
54
|
-
if (!isAuthenticated) {
|
|
55
|
-
return this.requestSubscribeTopics(wsKey, topics.filter((topic) => !(0, websocket_util_js_1.isPrivateChannel)(topic.channel)));
|
|
56
|
-
}
|
|
57
|
-
return this.requestSubscribeTopics(wsKey, topics);
|
|
58
|
-
}
|
|
59
|
-
// start connection process if it hasn't yet begun. Topics are automatically subscribed to on-connect
|
|
60
|
-
if (!this.wsStore.isConnectionState(wsKey, WsStore_types_js_1.WsConnectionStateEnum.CONNECTING) &&
|
|
61
|
-
!this.wsStore.isConnectionState(wsKey, WsStore_types_js_1.WsConnectionStateEnum.RECONNECTING)) {
|
|
62
|
-
return this.connect(wsKey);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Unsubscribe from topics & remove them from memory. They won't be re-subscribed to if the connection reconnects.
|
|
68
|
-
* @param wsTopics topic or list of topics
|
|
69
|
-
* @param isPrivateTopic optional - the library will try to detect private topics, you can use this to mark a topic as private (if the topic isn't recognised yet)
|
|
70
|
-
*/
|
|
71
|
-
unsubscribe(wsTopics, isPrivateTopic) {
|
|
72
|
-
const topics = Array.isArray(wsTopics) ? wsTopics : [wsTopics];
|
|
73
|
-
topics.forEach((topic) => this.wsStore.deleteTopic((0, websocket_util_js_1.getWsKeyForTopicV1)(topic, isPrivateTopic), topic));
|
|
74
|
-
this.wsStore.getKeys().forEach((wsKey) => {
|
|
75
|
-
// unsubscribe request only necessary if active connection exists
|
|
76
|
-
if (this.wsStore.isConnectionState(wsKey, WsStore_types_js_1.WsConnectionStateEnum.CONNECTED)) {
|
|
77
|
-
this.requestUnsubscribeTopics(wsKey, topics);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
/** Get the WsStore that tracks websockets & topics */
|
|
82
|
-
getWsStore() {
|
|
83
|
-
return this.wsStore;
|
|
84
|
-
}
|
|
85
|
-
close(wsKey, force) {
|
|
86
|
-
this.logger.info('Closing connection', { ...LOGGER_CATEGORY, wsKey });
|
|
87
|
-
this.setWsState(wsKey, WsStore_types_js_1.WsConnectionStateEnum.CLOSING);
|
|
88
|
-
this.clearTimers(wsKey);
|
|
89
|
-
const ws = this.getWs(wsKey);
|
|
90
|
-
ws?.close();
|
|
91
|
-
if (force) {
|
|
92
|
-
(0, websocket_util_js_1.safeTerminateWs)(ws);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
closeAll(force) {
|
|
96
|
-
this.wsStore.getKeys().forEach((key) => {
|
|
97
|
-
this.close(key, force);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Request connection of all dependent (public & private) websockets, instead of waiting for automatic connection by library
|
|
102
|
-
*/
|
|
103
|
-
connectAll() {
|
|
104
|
-
return [this.connect(websocket_util_js_1.WS_KEY_MAP.spotv1), this.connect(websocket_util_js_1.WS_KEY_MAP.mixv1)];
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Request connection to a specific websocket, instead of waiting for automatic connection.
|
|
108
|
-
*/
|
|
109
|
-
async connect(wsKey) {
|
|
110
|
-
try {
|
|
111
|
-
if (this.wsStore.isWsOpen(wsKey)) {
|
|
112
|
-
this.logger.error('Refused to connect to ws with existing active connection', { ...LOGGER_CATEGORY, wsKey });
|
|
113
|
-
return this.wsStore.getWs(wsKey);
|
|
114
|
-
}
|
|
115
|
-
if (this.wsStore.isConnectionState(wsKey, WsStore_types_js_1.WsConnectionStateEnum.CONNECTING)) {
|
|
116
|
-
this.logger.error('Refused to connect to ws, connection attempt already active', { ...LOGGER_CATEGORY, wsKey });
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
if (!this.wsStore.getConnectionState(wsKey) ||
|
|
120
|
-
this.wsStore.isConnectionState(wsKey, WsStore_types_js_1.WsConnectionStateEnum.INITIAL)) {
|
|
121
|
-
this.setWsState(wsKey, WsStore_types_js_1.WsConnectionStateEnum.CONNECTING);
|
|
122
|
-
}
|
|
123
|
-
const url = this.getWsUrl(wsKey); // + authParams;
|
|
124
|
-
const ws = this.connectToWsUrl(url, wsKey);
|
|
125
|
-
return this.wsStore.setWs(wsKey, ws);
|
|
126
|
-
}
|
|
127
|
-
catch (err) {
|
|
128
|
-
this.parseWsError('Connection failed', err, wsKey);
|
|
129
|
-
this.reconnectWithDelay(wsKey, this.options.reconnectTimeout);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
parseWsError(context, error, wsKey) {
|
|
133
|
-
if (!error.message) {
|
|
134
|
-
this.logger.error(`${context} due to unexpected error: `, error);
|
|
135
|
-
this.emit('response', { ...error, wsKey });
|
|
136
|
-
this.emit('exception', { ...error, wsKey });
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
switch (error.message) {
|
|
140
|
-
case 'Unexpected server response: 401':
|
|
141
|
-
this.logger.error(`${context} due to 401 authorization failure.`, {
|
|
142
|
-
...LOGGER_CATEGORY,
|
|
143
|
-
wsKey,
|
|
144
|
-
});
|
|
145
|
-
break;
|
|
146
|
-
default:
|
|
147
|
-
this.logger.error(`${context} due to unexpected response error: "${error?.msg || error?.message || error}"`, { ...LOGGER_CATEGORY, wsKey, error });
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
150
|
-
this.emit('response', { ...error, wsKey });
|
|
151
|
-
this.emit('exception', { ...error, wsKey });
|
|
152
|
-
}
|
|
153
|
-
async getWsAuthSignature(apiKey, apiSecret, apiPass, recvWindow = 0) {
|
|
154
|
-
if (!apiKey || !apiSecret || !apiPass) {
|
|
155
|
-
throw new Error('Cannot auth - missing api key, secret or passcode in config');
|
|
156
|
-
}
|
|
157
|
-
const signatureExpiresAt = ((Date.now() + recvWindow) / 1000).toFixed(0);
|
|
158
|
-
const signature = await (0, webCryptoAPI_js_1.signMessage)(signatureExpiresAt + 'GET' + '/user/verify', apiSecret, 'base64', 'SHA-256');
|
|
159
|
-
return {
|
|
160
|
-
expiresAt: Number(signatureExpiresAt),
|
|
161
|
-
signature,
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
/** Get a signature, build the auth request and send it */
|
|
165
|
-
async sendAuthRequest(wsKey) {
|
|
166
|
-
try {
|
|
167
|
-
const { apiKey, apiSecret, apiPass, recvWindow } = this.options;
|
|
168
|
-
const { signature, expiresAt } = await this.getWsAuthSignature(apiKey, apiSecret, apiPass, recvWindow);
|
|
169
|
-
this.logger.info('Sending auth request...', {
|
|
170
|
-
...LOGGER_CATEGORY,
|
|
171
|
-
wsKey,
|
|
172
|
-
});
|
|
173
|
-
const request = {
|
|
174
|
-
op: 'login',
|
|
175
|
-
args: [
|
|
176
|
-
{
|
|
177
|
-
apiKey: this.options.apiKey,
|
|
178
|
-
passphrase: this.options.apiPass,
|
|
179
|
-
timestamp: expiresAt,
|
|
180
|
-
sign: signature,
|
|
181
|
-
},
|
|
182
|
-
],
|
|
183
|
-
};
|
|
184
|
-
// console.log('ws auth req', request);
|
|
185
|
-
return this.tryWsSend(wsKey, JSON.stringify(request));
|
|
186
|
-
}
|
|
187
|
-
catch (e) {
|
|
188
|
-
this.logger.trace(e, { ...LOGGER_CATEGORY, wsKey });
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
reconnectWithDelay(wsKey, connectionDelayMs) {
|
|
192
|
-
this.clearTimers(wsKey);
|
|
193
|
-
if (this.wsStore.getConnectionState(wsKey) !==
|
|
194
|
-
WsStore_types_js_1.WsConnectionStateEnum.CONNECTING) {
|
|
195
|
-
this.setWsState(wsKey, WsStore_types_js_1.WsConnectionStateEnum.RECONNECTING);
|
|
196
|
-
}
|
|
197
|
-
this.wsStore.get(wsKey, true).activeReconnectTimer = setTimeout(() => {
|
|
198
|
-
this.logger.info('Reconnecting to websocket', {
|
|
199
|
-
...LOGGER_CATEGORY,
|
|
200
|
-
wsKey,
|
|
201
|
-
});
|
|
202
|
-
this.connect(wsKey);
|
|
203
|
-
}, connectionDelayMs);
|
|
204
|
-
}
|
|
205
|
-
ping(wsKey) {
|
|
206
|
-
if (this.wsStore.get(wsKey, true).activePongTimer) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
this.clearPongTimer(wsKey);
|
|
210
|
-
this.logger.trace('Sending ping', { ...LOGGER_CATEGORY, wsKey });
|
|
211
|
-
this.tryWsSend(wsKey, 'ping');
|
|
212
|
-
this.wsStore.get(wsKey, true).activePongTimer = setTimeout(() => {
|
|
213
|
-
this.logger.info('Pong timeout - closing socket to reconnect', {
|
|
214
|
-
...LOGGER_CATEGORY,
|
|
215
|
-
wsKey,
|
|
216
|
-
});
|
|
217
|
-
(0, websocket_util_js_1.safeTerminateWs)(this.getWs(wsKey), true);
|
|
218
|
-
delete this.wsStore.get(wsKey, true).activePongTimer;
|
|
219
|
-
}, this.options.pongTimeout);
|
|
220
|
-
}
|
|
221
|
-
clearTimers(wsKey) {
|
|
222
|
-
this.clearPingTimer(wsKey);
|
|
223
|
-
this.clearPongTimer(wsKey);
|
|
224
|
-
const wsState = this.wsStore.get(wsKey);
|
|
225
|
-
if (wsState?.activeReconnectTimer) {
|
|
226
|
-
clearTimeout(wsState.activeReconnectTimer);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
// Send a ping at intervals
|
|
230
|
-
clearPingTimer(wsKey) {
|
|
231
|
-
const wsState = this.wsStore.get(wsKey);
|
|
232
|
-
if (wsState?.activePingTimer) {
|
|
233
|
-
clearInterval(wsState.activePingTimer);
|
|
234
|
-
wsState.activePingTimer = undefined;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
// Expect a pong within a time limit
|
|
238
|
-
clearPongTimer(wsKey) {
|
|
239
|
-
const wsState = this.wsStore.get(wsKey);
|
|
240
|
-
if (wsState?.activePongTimer) {
|
|
241
|
-
clearTimeout(wsState.activePongTimer);
|
|
242
|
-
wsState.activePongTimer = undefined;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* @private Use the `subscribe(topics)` method to subscribe to topics. Send WS message to subscribe to topics.
|
|
247
|
-
*/
|
|
248
|
-
requestSubscribeTopics(wsKey, topics) {
|
|
249
|
-
if (!topics.length) {
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
const maxTopicsPerEvent = (0, websocket_util_js_1.getMaxTopicsPerSubscribeEvent)(wsKey);
|
|
253
|
-
if (maxTopicsPerEvent && topics.length > maxTopicsPerEvent) {
|
|
254
|
-
this.logger.trace(`Subscribing to topics in batches of ${maxTopicsPerEvent}`);
|
|
255
|
-
for (let i = 0; i < topics.length; i += maxTopicsPerEvent) {
|
|
256
|
-
const batch = topics.slice(i, i + maxTopicsPerEvent);
|
|
257
|
-
this.logger.trace(`Subscribing to batch of ${batch.length}`);
|
|
258
|
-
this.requestSubscribeTopics(wsKey, batch);
|
|
259
|
-
}
|
|
260
|
-
this.logger.trace(`Finished batch subscribing to ${topics.length} topics`);
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
const wsMessage = JSON.stringify({
|
|
264
|
-
op: 'subscribe',
|
|
265
|
-
args: topics,
|
|
266
|
-
});
|
|
267
|
-
this.tryWsSend(wsKey, wsMessage);
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* @private Use the `unsubscribe(topics)` method to unsubscribe from topics. Send WS message to unsubscribe from topics.
|
|
271
|
-
*/
|
|
272
|
-
requestUnsubscribeTopics(wsKey, topics) {
|
|
273
|
-
if (!topics.length) {
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
const maxTopicsPerEvent = (0, websocket_util_js_1.getMaxTopicsPerSubscribeEvent)(wsKey);
|
|
277
|
-
if (maxTopicsPerEvent && topics.length > maxTopicsPerEvent) {
|
|
278
|
-
this.logger.trace(`Unsubscribing to topics in batches of ${maxTopicsPerEvent}`);
|
|
279
|
-
for (let i = 0; i < topics.length; i += maxTopicsPerEvent) {
|
|
280
|
-
const batch = topics.slice(i, i + maxTopicsPerEvent);
|
|
281
|
-
this.logger.trace(`Unsubscribing to batch of ${batch.length}`);
|
|
282
|
-
this.requestUnsubscribeTopics(wsKey, batch);
|
|
283
|
-
}
|
|
284
|
-
this.logger.trace(`Finished batch unsubscribing to ${topics.length} topics`);
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
const wsMessage = JSON.stringify({
|
|
288
|
-
op: 'unsubscribe',
|
|
289
|
-
args: topics,
|
|
290
|
-
});
|
|
291
|
-
this.tryWsSend(wsKey, wsMessage);
|
|
292
|
-
}
|
|
293
|
-
tryWsSend(wsKey, wsMessage) {
|
|
294
|
-
try {
|
|
295
|
-
this.logger.trace('Sending upstream ws message: ', {
|
|
296
|
-
...LOGGER_CATEGORY,
|
|
297
|
-
wsMessage,
|
|
298
|
-
wsKey,
|
|
299
|
-
});
|
|
300
|
-
if (!wsKey) {
|
|
301
|
-
throw new Error('Cannot send message due to no known websocket for this wsKey');
|
|
302
|
-
}
|
|
303
|
-
const ws = this.getWs(wsKey);
|
|
304
|
-
if (!ws) {
|
|
305
|
-
throw new Error(`${wsKey} socket not connected yet, call "connectAll()" first then try again when the "open" event arrives`);
|
|
306
|
-
}
|
|
307
|
-
ws.send(wsMessage);
|
|
308
|
-
}
|
|
309
|
-
catch (e) {
|
|
310
|
-
this.logger.error('Failed to send WS message', {
|
|
311
|
-
...LOGGER_CATEGORY,
|
|
312
|
-
wsMessage,
|
|
313
|
-
wsKey,
|
|
314
|
-
exception: e,
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
connectToWsUrl(url, wsKey) {
|
|
319
|
-
this.logger.trace(`Opening WS connection to URL: ${url}`, {
|
|
320
|
-
...LOGGER_CATEGORY,
|
|
321
|
-
wsKey,
|
|
322
|
-
});
|
|
323
|
-
const { protocols = [], ...wsOptions } = this.options.wsOptions || {};
|
|
324
|
-
const ws = new isomorphic_ws_1.default(url, protocols, wsOptions);
|
|
325
|
-
ws.onopen = (event) => this.onWsOpen(event, wsKey);
|
|
326
|
-
ws.onmessage = (event) => this.onWsMessage(event, wsKey);
|
|
327
|
-
ws.onerror = (event) => this.parseWsError('websocket error', event, wsKey);
|
|
328
|
-
ws.onclose = (event) => this.onWsClose(event, wsKey);
|
|
329
|
-
return ws;
|
|
330
|
-
}
|
|
331
|
-
async onWsOpen(event, wsKey) {
|
|
332
|
-
if (this.wsStore.isConnectionState(wsKey, WsStore_types_js_1.WsConnectionStateEnum.CONNECTING)) {
|
|
333
|
-
this.logger.info('Websocket connected', {
|
|
334
|
-
...LOGGER_CATEGORY,
|
|
335
|
-
wsKey,
|
|
336
|
-
});
|
|
337
|
-
this.emit('open', { wsKey, event });
|
|
338
|
-
}
|
|
339
|
-
else if (this.wsStore.isConnectionState(wsKey, WsStore_types_js_1.WsConnectionStateEnum.RECONNECTING)) {
|
|
340
|
-
this.logger.info('Websocket reconnected', { ...LOGGER_CATEGORY, wsKey });
|
|
341
|
-
this.emit('reconnected', { wsKey, event });
|
|
342
|
-
}
|
|
343
|
-
this.setWsState(wsKey, WsStore_types_js_1.WsConnectionStateEnum.CONNECTED);
|
|
344
|
-
// Some websockets require an auth packet to be sent after opening the connection
|
|
345
|
-
if (websocket_util_js_1.WS_AUTH_ON_CONNECT_KEYS.includes(wsKey)) {
|
|
346
|
-
await this.sendAuthRequest(wsKey);
|
|
347
|
-
}
|
|
348
|
-
// Reconnect to topics known before it connected
|
|
349
|
-
// Private topics will be resubscribed to once reconnected
|
|
350
|
-
const topics = [...this.wsStore.getTopics(wsKey)];
|
|
351
|
-
const publicTopics = topics.filter((topic) => !(0, websocket_util_js_1.isPrivateChannel)(topic.channel));
|
|
352
|
-
this.requestSubscribeTopics(wsKey, publicTopics);
|
|
353
|
-
this.wsStore.get(wsKey, true).activePingTimer = setInterval(() => this.ping(wsKey), this.options.pingInterval);
|
|
354
|
-
}
|
|
355
|
-
/** Handle subscription to private topics _after_ authentication successfully completes asynchronously */
|
|
356
|
-
onWsAuthenticated(wsKey) {
|
|
357
|
-
const wsState = this.wsStore.get(wsKey, true);
|
|
358
|
-
wsState.isAuthenticated = true;
|
|
359
|
-
const topics = [...this.wsStore.getTopics(wsKey)];
|
|
360
|
-
const privateTopics = topics.filter((topic) => (0, websocket_util_js_1.isPrivateChannel)(topic.channel));
|
|
361
|
-
if (privateTopics.length) {
|
|
362
|
-
this.subscribe(privateTopics, true);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
onWsMessage(event, wsKey) {
|
|
366
|
-
try {
|
|
367
|
-
// any message can clear the pong timer - wouldn't get a message if the ws wasn't working
|
|
368
|
-
this.clearPongTimer(wsKey);
|
|
369
|
-
if ((0, requestUtils_js_1.isWsPong)(event)) {
|
|
370
|
-
this.logger.trace('Received pong', { ...LOGGER_CATEGORY, wsKey });
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
const msg = JSON.parse((event && event['data']) || event);
|
|
374
|
-
const emittableEvent = { ...msg, wsKey };
|
|
375
|
-
if (typeof msg === 'object') {
|
|
376
|
-
if (typeof msg['code'] === 'number') {
|
|
377
|
-
if (msg.event === 'login' && msg.code === 0) {
|
|
378
|
-
this.logger.info('Successfully authenticated WS client', {
|
|
379
|
-
...LOGGER_CATEGORY,
|
|
380
|
-
wsKey,
|
|
381
|
-
});
|
|
382
|
-
this.emit('response', emittableEvent);
|
|
383
|
-
this.emit('authenticated', emittableEvent);
|
|
384
|
-
this.onWsAuthenticated(wsKey);
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
if (msg['event']) {
|
|
389
|
-
if (msg.event === 'error') {
|
|
390
|
-
this.logger.error('WS Error received', {
|
|
391
|
-
...LOGGER_CATEGORY,
|
|
392
|
-
wsKey,
|
|
393
|
-
message: msg || 'no message',
|
|
394
|
-
// messageType: typeof msg,
|
|
395
|
-
// messageString: JSON.stringify(msg),
|
|
396
|
-
event,
|
|
397
|
-
});
|
|
398
|
-
this.emit('exception', emittableEvent);
|
|
399
|
-
this.emit('response', emittableEvent);
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
return this.emit('response', emittableEvent);
|
|
403
|
-
}
|
|
404
|
-
if (msg['arg']) {
|
|
405
|
-
return this.emit('update', emittableEvent);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
this.logger.info('Unhandled/unrecognised ws event message', {
|
|
409
|
-
...LOGGER_CATEGORY,
|
|
410
|
-
message: msg || 'no message',
|
|
411
|
-
// messageType: typeof msg,
|
|
412
|
-
// messageString: JSON.stringify(msg),
|
|
413
|
-
event,
|
|
414
|
-
wsKey,
|
|
415
|
-
});
|
|
416
|
-
// fallback emit anyway
|
|
417
|
-
return this.emit('update', emittableEvent);
|
|
418
|
-
}
|
|
419
|
-
catch (e) {
|
|
420
|
-
this.logger.error('Failed to parse ws event message', {
|
|
421
|
-
...LOGGER_CATEGORY,
|
|
422
|
-
error: e,
|
|
423
|
-
event,
|
|
424
|
-
wsKey,
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
onWsClose(event, wsKey) {
|
|
429
|
-
this.logger.info('Websocket connection closed', {
|
|
430
|
-
...LOGGER_CATEGORY,
|
|
431
|
-
wsKey,
|
|
432
|
-
});
|
|
433
|
-
if (this.wsStore.getConnectionState(wsKey) !== WsStore_types_js_1.WsConnectionStateEnum.CLOSING) {
|
|
434
|
-
this.reconnectWithDelay(wsKey, this.options.reconnectTimeout);
|
|
435
|
-
this.emit('reconnect', { wsKey, event });
|
|
436
|
-
}
|
|
437
|
-
else {
|
|
438
|
-
this.setWsState(wsKey, WsStore_types_js_1.WsConnectionStateEnum.INITIAL);
|
|
439
|
-
this.emit('close', { wsKey, event });
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
getWs(wsKey) {
|
|
443
|
-
return this.wsStore.getWs(wsKey);
|
|
444
|
-
}
|
|
445
|
-
setWsState(wsKey, state) {
|
|
446
|
-
this.wsStore.setConnectionState(wsKey, state);
|
|
447
|
-
}
|
|
448
|
-
getWsUrl(wsKey) {
|
|
449
|
-
if (this.options.wsUrl) {
|
|
450
|
-
return this.options.wsUrl;
|
|
451
|
-
}
|
|
452
|
-
const networkKey = 'livenet';
|
|
453
|
-
switch (wsKey) {
|
|
454
|
-
case websocket_util_js_1.WS_KEY_MAP.spotv1: {
|
|
455
|
-
return websocket_util_js_1.WS_BASE_URL_MAP.spotv1.all[networkKey];
|
|
456
|
-
}
|
|
457
|
-
case websocket_util_js_1.WS_KEY_MAP.mixv1: {
|
|
458
|
-
return websocket_util_js_1.WS_BASE_URL_MAP.mixv1.all[networkKey];
|
|
459
|
-
}
|
|
460
|
-
case websocket_util_js_1.WS_KEY_MAP.v2Private:
|
|
461
|
-
case websocket_util_js_1.WS_KEY_MAP.v2Public: {
|
|
462
|
-
throw new Error('Use the WebsocketClientV2 for V2 websockets');
|
|
463
|
-
}
|
|
464
|
-
case websocket_util_js_1.WS_KEY_MAP.v3Private:
|
|
465
|
-
case websocket_util_js_1.WS_KEY_MAP.v3Public: {
|
|
466
|
-
throw new Error('Use the WebsocketClientV3 for V3 websockets');
|
|
467
|
-
}
|
|
468
|
-
default: {
|
|
469
|
-
this.logger.error('getWsUrl(): Unhandled wsKey: ', {
|
|
470
|
-
...LOGGER_CATEGORY,
|
|
471
|
-
wsKey,
|
|
472
|
-
});
|
|
473
|
-
throw (0, websocket_util_js_1.neverGuard)(wsKey, 'getWsUrl(): Unhandled wsKey');
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
* Subscribe to a topic
|
|
479
|
-
* @param instType instrument type (refer to API docs).
|
|
480
|
-
* @param topic topic name (e.g. "ticker").
|
|
481
|
-
* @param instId instrument ID (e.g. "BTCUSDT"). Use "default" for private topics.
|
|
482
|
-
*
|
|
483
|
-
* @deprecated use WebsocketClientV2 instead
|
|
484
|
-
*/
|
|
485
|
-
subscribeTopic(instType, topic, instId = 'default') {
|
|
486
|
-
return this.subscribe({
|
|
487
|
-
instType,
|
|
488
|
-
instId,
|
|
489
|
-
channel: topic,
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* Unsubscribe from a topic
|
|
494
|
-
* @param instType instrument type (refer to API docs).
|
|
495
|
-
* @param topic topic name (e.g. "ticker").
|
|
496
|
-
* @param instId instrument ID (e.g. "BTCUSDT"). Use "default" for private topics to get all symbols.
|
|
497
|
-
*
|
|
498
|
-
* @deprecated use WebsocketClientV2 instead
|
|
499
|
-
*/
|
|
500
|
-
unsubscribeTopic(instType, topic, instId = 'default') {
|
|
501
|
-
return this.unsubscribe({
|
|
502
|
-
instType,
|
|
503
|
-
instId,
|
|
504
|
-
channel: topic,
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
exports.WebsocketClientLegacyV1 = WebsocketClientLegacyV1;
|
|
509
|
-
//# sourceMappingURL=websocket-client-legacy-v1.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"websocket-client-legacy-v1.js","sourceRoot":"","sources":["../../src/websocket-client-legacy-v1.ts"],"names":[],"mappings":";;;;;;AAAA,qEAAqE;AACrE,mCAAsC;AACtC,kEAAsC;AAUtC,gDAAiD;AACjD,4DAAkD;AAClD,4DAAqD;AACrD,gEASkC;AAClC,mEAAwC;AACxC,8DAAgE;AAEhE,MAAM,eAAe,GAAG,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;AA2ClD;;GAEG;AACH,MAAa,uBAAwB,SAAQ,qBAAY;IAC/C,MAAM,CAAuB;IAE7B,OAAO,CAAyB;IAEhC,OAAO,CAA4C;IAE3D,YACE,OAAoC,EACpC,MAA6B;QAE7B,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,yBAAa,CAAC;QACtC,IAAI,CAAC,OAAO,GAAG,IAAI,oBAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAExC,IAAI,CAAC,OAAO,GAAG;YACb,WAAW,EAAE,IAAI;YACjB,YAAY,EAAE,KAAK;YACnB,gBAAgB,EAAE,GAAG;YACrB,UAAU,EAAE,CAAC;YACb,+BAA+B,EAAE,IAAI;YACrC,mBAAmB,EAAE,KAAK;YAC1B,GAAG,OAAO;SACX,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACI,SAAS,CACd,QAAiE,EACjE,cAAwB;QAExB,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC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SAAS;QAE1B,OAAO,IAAI,CAAC,WAAW,CAAC;YACtB,QAAQ;YACR,MAAM;YACN,OAAO,EAAE,KAAK;SACf,CAAC,CAAC;IACL,CAAC;CACF;AA3pBD,0DA2pBC"}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { BrokerProductType, BrokerSubAPIKeyModifyRequest, BrokerSubListRequest, BrokerSubWithdrawalRequest } from './types/request/v1/brokerV1.js';
|
|
2
|
-
import { APIResponse } from './types/response/v1/shared.js';
|
|
3
|
-
import BaseRestClient from './util/BaseRestClient.js';
|
|
4
|
-
/**
|
|
5
|
-
* REST API client for the V1 bitget Broker APIs. These are the previous generation of Bitget's APIs and should be considered deprecated.
|
|
6
|
-
* These will be removed in a future release, once Bitget formally deprecates them.
|
|
7
|
-
*
|
|
8
|
-
* @deprecated use RestClientV2 instead
|
|
9
|
-
*/
|
|
10
|
-
export declare class BrokerClient extends BaseRestClient {
|
|
11
|
-
getClientType(): "broker";
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* Sub Account Interface
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
/** Get Broker Info */
|
|
18
|
-
getBrokerInfo(): Promise<APIResponse<any>>;
|
|
19
|
-
/** Create Sub Account */
|
|
20
|
-
createSubAccount(subName: string, remark?: string): Promise<APIResponse<any>>;
|
|
21
|
-
/** Get Sub List */
|
|
22
|
-
getSubAccounts(params?: BrokerSubListRequest): Promise<APIResponse<any>>;
|
|
23
|
-
/** Modify Sub Account */
|
|
24
|
-
modifySubAccount(subUid: string, perm: string, status: 'normal' | 'freeze' | 'del'): Promise<APIResponse<any>>;
|
|
25
|
-
/** Modify Sub Email */
|
|
26
|
-
modifySubEmail(subUid: string, subEmail: string): Promise<APIResponse<any>>;
|
|
27
|
-
/** Get Sub Email */
|
|
28
|
-
getSubEmail(subUid: string): Promise<APIResponse<any>>;
|
|
29
|
-
/** Get Sub Spot Assets */
|
|
30
|
-
getSubSpotAssets(subUid: string): Promise<APIResponse<any>>;
|
|
31
|
-
/** Get Sub Future Assets */
|
|
32
|
-
getSubFutureAssets(subUid: string, productType: BrokerProductType): Promise<APIResponse<any>>;
|
|
33
|
-
/** Get Sub Deposit Address (Only Broker) */
|
|
34
|
-
getSubDepositAddress(subUid: string, coin: string, chain?: string): Promise<APIResponse<any>>;
|
|
35
|
-
/** Sub Withdrawal (Only Broker) */
|
|
36
|
-
subWithdrawal(params: BrokerSubWithdrawalRequest): Promise<APIResponse<any>>;
|
|
37
|
-
/** Sub Deposit Auto Transfer (Only Broker) */
|
|
38
|
-
setSubDepositAutoTransfer(subUid: string, coin: string, toAccountType: 'spot' | 'mix_usdt' | 'mix_usd' | 'mix_usdc'): Promise<APIResponse<any>>;
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
* Sub API Interface
|
|
42
|
-
*
|
|
43
|
-
*/
|
|
44
|
-
/** Create Sub ApiKey (Only Broker) */
|
|
45
|
-
createSubAPIKey(subUid: string, passphrase: string, remark: string, ip: string, perm?: string): Promise<APIResponse<any>>;
|
|
46
|
-
/** Get Sub ApiKey List */
|
|
47
|
-
getSubAPIKeys(subUid: string): Promise<APIResponse<any>>;
|
|
48
|
-
/** Modify Sub ApiKey (Only Broker) */
|
|
49
|
-
modifySubAPIKey(params: BrokerSubAPIKeyModifyRequest): Promise<APIResponse<any>>;
|
|
50
|
-
/**
|
|
51
|
-
* Undocumented endpoints
|
|
52
|
-
*/
|
|
53
|
-
getAgentCommissionDetail(params?: {
|
|
54
|
-
startTime?: string;
|
|
55
|
-
endTime?: string;
|
|
56
|
-
limit?: string;
|
|
57
|
-
idLessThan?: string;
|
|
58
|
-
}): Promise<APIResponse<any>>;
|
|
59
|
-
/** Get Agent Customer List */
|
|
60
|
-
getAgentCustomerList(params?: {
|
|
61
|
-
startTime?: string;
|
|
62
|
-
endTime?: string;
|
|
63
|
-
pageNo?: string;
|
|
64
|
-
pageSize?: string;
|
|
65
|
-
uid?: string;
|
|
66
|
-
referralCode?: string;
|
|
67
|
-
}): Promise<APIResponse<any>>;
|
|
68
|
-
/**
|
|
69
|
-
* Get Agent Customer Deposit List
|
|
70
|
-
* Includes both on-chain deposits and internal transfers
|
|
71
|
-
* Note: Can only query data within the last 90 days
|
|
72
|
-
*/
|
|
73
|
-
getAgentCustomerDepositList(params?: {
|
|
74
|
-
startTime?: string;
|
|
75
|
-
endTime?: string;
|
|
76
|
-
pageNo?: string;
|
|
77
|
-
pageSize?: string;
|
|
78
|
-
uid?: string;
|
|
79
|
-
}): Promise<APIResponse<any>>;
|
|
80
|
-
/**
|
|
81
|
-
* Get Agent Customer Trade Volume List
|
|
82
|
-
* Includes trading volume for both spot and futures
|
|
83
|
-
* Note: Data updates every 10 minutes and can only query last 90 days
|
|
84
|
-
*/
|
|
85
|
-
getAgentCustomerTradeVolumeList(params?: {
|
|
86
|
-
startTime?: string;
|
|
87
|
-
endTime?: string;
|
|
88
|
-
pageNo?: string;
|
|
89
|
-
pageSize?: string;
|
|
90
|
-
uid?: string;
|
|
91
|
-
}): Promise<APIResponse<any>>;
|
|
92
|
-
/**
|
|
93
|
-
* Get Agent Customer Assets List
|
|
94
|
-
* Returns account balances for customer accounts
|
|
95
|
-
* Note: Data updates every 10 minutes
|
|
96
|
-
*/
|
|
97
|
-
getAgentCustomerAssetsList(params?: {
|
|
98
|
-
pageNo?: string;
|
|
99
|
-
pageSize?: string;
|
|
100
|
-
uid?: string;
|
|
101
|
-
}): Promise<APIResponse<any>>;
|
|
102
|
-
/**
|
|
103
|
-
* Get Agent Direct Commissions
|
|
104
|
-
* Returns commission data for direct customers
|
|
105
|
-
* Note: Data updates on T+1 (UTC+8) basis and can only query last 90 days
|
|
106
|
-
*/
|
|
107
|
-
getAgentCustomerCommissions(params?: {
|
|
108
|
-
startTime?: string;
|
|
109
|
-
endTime?: string;
|
|
110
|
-
idLessThan?: string;
|
|
111
|
-
limit?: string;
|
|
112
|
-
uid?: string;
|
|
113
|
-
coin?: string;
|
|
114
|
-
symbol?: string;
|
|
115
|
-
}): Promise<APIResponse<any>>;
|
|
116
|
-
/**
|
|
117
|
-
* Get Agent Customer KYC Result
|
|
118
|
-
* Returns KYC verification status for customers
|
|
119
|
-
*/
|
|
120
|
-
getAgentCustomerKycResult(params?: {
|
|
121
|
-
startTime?: string;
|
|
122
|
-
endTime?: string;
|
|
123
|
-
pageNo?: string;
|
|
124
|
-
pageSize?: string;
|
|
125
|
-
uid?: string;
|
|
126
|
-
}): Promise<APIResponse<any>>;
|
|
127
|
-
}
|