bybit-api 2.4.0-beta.1 → 2.4.0-beta.2

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.
@@ -1,52 +1,63 @@
1
1
  /// <reference types="node" />
2
2
  import { EventEmitter } from 'events';
3
3
  import WebSocket from 'isomorphic-ws';
4
- import { DefaultLogger } from './util/logger';
5
4
  import { KlineInterval, WSClientConfigurableOptions, WsKey, WsTopic } from './types';
6
- export declare interface WebsocketClient {
7
- on(event: 'open' | 'reconnected', listener: ({ wsKey: WsKey, event: any }: {
8
- wsKey: any;
5
+ import { DefaultLogger } from './util';
6
+ export declare type WsClientEvent = 'open' | 'update' | 'close' | 'errorEvent' | 'reconnect' | 'reconnected' | 'response';
7
+ interface WebsocketClientEvents {
8
+ open: (evt: {
9
+ wsKey: WsKey;
10
+ event: any;
11
+ }) => void;
12
+ reconnect: (evt: {
13
+ wsKey: WsKey;
14
+ event: any;
15
+ }) => void;
16
+ reconnected: (evt: {
17
+ wsKey: WsKey;
18
+ event: any;
19
+ }) => void;
20
+ close: (evt: {
21
+ wsKey: WsKey;
9
22
  event: any;
10
- }) => void): this;
11
- on(event: 'response' | 'update' | 'error', listener: (response: any) => void): this;
12
- on(event: 'reconnect' | 'close', listener: ({ wsKey: WsKey }: {
13
- wsKey: any;
14
- }) => void): this;
23
+ }) => void;
24
+ response: (response: any) => void;
25
+ update: (response: any) => void;
26
+ errorEvent: (response: any) => void;
27
+ }
28
+ export declare interface WebsocketClient {
29
+ on<U extends keyof WebsocketClientEvents>(event: U, listener: WebsocketClientEvents[U]): this;
30
+ emit<U extends keyof WebsocketClientEvents>(event: U, ...args: Parameters<WebsocketClientEvents[U]>): boolean;
15
31
  }
16
32
  export declare class WebsocketClient extends EventEmitter {
17
33
  private logger;
18
- /** Purely used */
19
- private restClient;
34
+ private restClient?;
20
35
  private options;
21
36
  private wsStore;
22
37
  constructor(options: WSClientConfigurableOptions, logger?: typeof DefaultLogger);
23
- isLivenet(): boolean;
24
- isLinear(): boolean;
25
- isSpot(): boolean;
26
- isInverse(): boolean;
27
- /** USDC, spot v3, unified margin, account asset */
28
- isV3(): boolean;
29
- /**
30
- * Add topic/topics to WS subscription list
31
- */
32
- subscribe(wsTopics: WsTopic[] | WsTopic): void;
33
38
  /**
34
- * Remove topic/topics from WS subscription list
39
+ * Only used if we fetch exchange time before attempting auth.
40
+ * Disabled by default.
41
+ * I've removed this for ftx and it's working great, tempted to remove this here
35
42
  */
36
- unsubscribe(wsTopics: WsTopic[] | WsTopic): void;
43
+ prepareRESTClient(): void;
44
+ isTestnet(): boolean;
37
45
  close(wsKey: WsKey): void;
46
+ closeAll(): void;
38
47
  /**
39
48
  * Request connection of all dependent (public & private) websockets, instead of waiting for automatic connection by library
40
49
  */
41
- connectAll(): Promise<WebSocket | undefined>[] | undefined;
42
- connectPublic(): Promise<WebSocket | undefined> | undefined;
43
- connectPrivate(): Promise<WebSocket | undefined> | undefined;
50
+ connectAll(): Promise<WebSocket | undefined>[];
51
+ connectPublic(): Promise<WebSocket | undefined>;
52
+ connectPrivate(): Promise<WebSocket | undefined>;
44
53
  private connect;
45
54
  private parseWsError;
46
55
  /**
47
56
  * Return params required to make authorized request
48
57
  */
49
58
  private getAuthParams;
59
+ private sendAuthRequest;
60
+ private getWsAuthSignature;
50
61
  private reconnectWithDelay;
51
62
  private ping;
52
63
  private clearTimers;
@@ -60,20 +71,35 @@ export declare class WebsocketClient extends EventEmitter {
60
71
  * Send WS message to unsubscribe from topics.
61
72
  */
62
73
  private requestUnsubscribeTopics;
63
- private tryWsSend;
74
+ tryWsSend(wsKey: WsKey, wsMessage: string): void;
64
75
  private connectToWsUrl;
65
76
  private onWsOpen;
66
77
  private onWsMessage;
67
78
  private onWsError;
68
79
  private onWsClose;
69
- private onWsMessageResponse;
70
80
  private getWs;
71
81
  private setWsState;
72
82
  private getWsUrl;
73
- private getWsKeyForTopic;
74
83
  private wrongMarketError;
84
+ /**
85
+ * Add topic/topics to WS subscription list
86
+ * @param wsTopics topic or list of topics
87
+ * @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)
88
+ */
89
+ subscribe(wsTopics: WsTopic[] | WsTopic, isPrivateTopic?: boolean): void;
90
+ /**
91
+ * Remove topic/topics from WS subscription list
92
+ * @param wsTopics topic or list of topics
93
+ * @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)
94
+ */
95
+ unsubscribe(wsTopics: WsTopic[] | WsTopic, isPrivateTopic?: boolean): void;
96
+ /** @deprecated use "market: 'spotv3" client */
75
97
  subscribePublicSpotTrades(symbol: string, binary?: boolean): void;
98
+ /** @deprecated use "market: 'spotv3" client */
76
99
  subscribePublicSpotTradingPair(symbol: string, binary?: boolean): void;
100
+ /** @deprecated use "market: 'spotv3" client */
77
101
  subscribePublicSpotV1Kline(symbol: string, candleSize: KlineInterval, binary?: boolean): void;
102
+ /** @deprecated use "market: 'spotv3" client */
78
103
  subscribePublicSpotOrderbook(symbol: string, depth: 'full' | 'merge' | 'delta', dumpScale?: number, binary?: boolean): void;
79
104
  }
105
+ export {};