@siebly/kraken-api 0.0.9

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 (204) hide show
  1. package/LICENSE.md +7 -0
  2. package/README.md +624 -0
  3. package/dist/cjs/DerivativesClient.d.ts +657 -0
  4. package/dist/cjs/DerivativesClient.js +726 -0
  5. package/dist/cjs/DerivativesClient.js.map +1 -0
  6. package/dist/cjs/InstitutionalClient.d.ts +183 -0
  7. package/dist/cjs/InstitutionalClient.js +266 -0
  8. package/dist/cjs/InstitutionalClient.js.map +1 -0
  9. package/dist/cjs/PartnerClient.d.ts +257 -0
  10. package/dist/cjs/PartnerClient.js +344 -0
  11. package/dist/cjs/PartnerClient.js.map +1 -0
  12. package/dist/cjs/SpotClient.d.ts +547 -0
  13. package/dist/cjs/SpotClient.js +607 -0
  14. package/dist/cjs/SpotClient.js.map +1 -0
  15. package/dist/cjs/WebsocketAPIClient.d.ts +95 -0
  16. package/dist/cjs/WebsocketAPIClient.js +136 -0
  17. package/dist/cjs/WebsocketAPIClient.js.map +1 -0
  18. package/dist/cjs/WebsocketClient.d.ts +120 -0
  19. package/dist/cjs/WebsocketClient.js +669 -0
  20. package/dist/cjs/WebsocketClient.js.map +1 -0
  21. package/dist/cjs/index.d.ts +24 -0
  22. package/dist/cjs/index.js +41 -0
  23. package/dist/cjs/index.js.map +1 -0
  24. package/dist/cjs/lib/BaseRestClient.d.ts +66 -0
  25. package/dist/cjs/lib/BaseRestClient.js +548 -0
  26. package/dist/cjs/lib/BaseRestClient.js.map +1 -0
  27. package/dist/cjs/lib/BaseWSClient.d.ts +230 -0
  28. package/dist/cjs/lib/BaseWSClient.js +935 -0
  29. package/dist/cjs/lib/BaseWSClient.js.map +1 -0
  30. package/dist/cjs/lib/misc-util.d.ts +1 -0
  31. package/dist/cjs/lib/misc-util.js +7 -0
  32. package/dist/cjs/lib/misc-util.js.map +1 -0
  33. package/dist/cjs/lib/requestUtils.d.ts +68 -0
  34. package/dist/cjs/lib/requestUtils.js +82 -0
  35. package/dist/cjs/lib/requestUtils.js.map +1 -0
  36. package/dist/cjs/lib/webCryptoAPI.d.ts +15 -0
  37. package/dist/cjs/lib/webCryptoAPI.js +85 -0
  38. package/dist/cjs/lib/webCryptoAPI.js.map +1 -0
  39. package/dist/cjs/lib/websocket/WsStore.d.ts +75 -0
  40. package/dist/cjs/lib/websocket/WsStore.js +303 -0
  41. package/dist/cjs/lib/websocket/WsStore.js.map +1 -0
  42. package/dist/cjs/lib/websocket/WsStore.types.d.ts +51 -0
  43. package/dist/cjs/lib/websocket/WsStore.types.js +14 -0
  44. package/dist/cjs/lib/websocket/WsStore.types.js.map +1 -0
  45. package/dist/cjs/lib/websocket/logger.d.ts +7 -0
  46. package/dist/cjs/lib/websocket/logger.js +16 -0
  47. package/dist/cjs/lib/websocket/logger.js.map +1 -0
  48. package/dist/cjs/lib/websocket/rest-client-cache.d.ts +22 -0
  49. package/dist/cjs/lib/websocket/rest-client-cache.js +66 -0
  50. package/dist/cjs/lib/websocket/rest-client-cache.js.map +1 -0
  51. package/dist/cjs/lib/websocket/websocket-util.d.ts +76 -0
  52. package/dist/cjs/lib/websocket/websocket-util.js +59 -0
  53. package/dist/cjs/lib/websocket/websocket-util.js.map +1 -0
  54. package/dist/cjs/package.json +3 -0
  55. package/dist/cjs/types/request/derivatives.types.d.ts +186 -0
  56. package/dist/cjs/types/request/derivatives.types.js +6 -0
  57. package/dist/cjs/types/request/derivatives.types.js.map +1 -0
  58. package/dist/cjs/types/request/institutional.types.d.ts +313 -0
  59. package/dist/cjs/types/request/institutional.types.js +4 -0
  60. package/dist/cjs/types/request/institutional.types.js.map +1 -0
  61. package/dist/cjs/types/request/partner.types.d.ts +291 -0
  62. package/dist/cjs/types/request/partner.types.js +4 -0
  63. package/dist/cjs/types/request/partner.types.js.map +1 -0
  64. package/dist/cjs/types/request/spot.types.d.ts +324 -0
  65. package/dist/cjs/types/request/spot.types.js +6 -0
  66. package/dist/cjs/types/request/spot.types.js.map +1 -0
  67. package/dist/cjs/types/request/wsapi.types.d.ts +90 -0
  68. package/dist/cjs/types/request/wsapi.types.js +6 -0
  69. package/dist/cjs/types/request/wsapi.types.js.map +1 -0
  70. package/dist/cjs/types/response/derivatives.types.d.ts +712 -0
  71. package/dist/cjs/types/response/derivatives.types.js +6 -0
  72. package/dist/cjs/types/response/derivatives.types.js.map +1 -0
  73. package/dist/cjs/types/response/institutional.types.d.ts +318 -0
  74. package/dist/cjs/types/response/institutional.types.js +4 -0
  75. package/dist/cjs/types/response/institutional.types.js.map +1 -0
  76. package/dist/cjs/types/response/partner.types.d.ts +332 -0
  77. package/dist/cjs/types/response/partner.types.js +4 -0
  78. package/dist/cjs/types/response/partner.types.js.map +1 -0
  79. package/dist/cjs/types/response/shared.types.d.ts +27 -0
  80. package/dist/cjs/types/response/shared.types.js +3 -0
  81. package/dist/cjs/types/response/shared.types.js.map +1 -0
  82. package/dist/cjs/types/response/spot.types.d.ts +590 -0
  83. package/dist/cjs/types/response/spot.types.js +6 -0
  84. package/dist/cjs/types/response/spot.types.js.map +1 -0
  85. package/dist/cjs/types/response/ws.d.ts +11 -0
  86. package/dist/cjs/types/response/ws.js +3 -0
  87. package/dist/cjs/types/response/ws.js.map +1 -0
  88. package/dist/cjs/types/response/wsapi.types.d.ts +44 -0
  89. package/dist/cjs/types/response/wsapi.types.js +6 -0
  90. package/dist/cjs/types/response/wsapi.types.js.map +1 -0
  91. package/dist/cjs/types/websockets/ws-api.d.ts +71 -0
  92. package/dist/cjs/types/websockets/ws-api.js +18 -0
  93. package/dist/cjs/types/websockets/ws-api.js.map +1 -0
  94. package/dist/cjs/types/websockets/ws-events.d.ts +11 -0
  95. package/dist/cjs/types/websockets/ws-events.js +11 -0
  96. package/dist/cjs/types/websockets/ws-events.js.map +1 -0
  97. package/dist/cjs/types/websockets/ws-general.d.ts +67 -0
  98. package/dist/cjs/types/websockets/ws-general.js +3 -0
  99. package/dist/cjs/types/websockets/ws-general.js.map +1 -0
  100. package/dist/cjs/types/websockets/ws-subscriptions.d.ts +11 -0
  101. package/dist/cjs/types/websockets/ws-subscriptions.js +31 -0
  102. package/dist/cjs/types/websockets/ws-subscriptions.js.map +1 -0
  103. package/dist/mjs/DerivativesClient.d.ts +657 -0
  104. package/dist/mjs/DerivativesClient.js +722 -0
  105. package/dist/mjs/DerivativesClient.js.map +1 -0
  106. package/dist/mjs/InstitutionalClient.d.ts +183 -0
  107. package/dist/mjs/InstitutionalClient.js +262 -0
  108. package/dist/mjs/InstitutionalClient.js.map +1 -0
  109. package/dist/mjs/PartnerClient.d.ts +257 -0
  110. package/dist/mjs/PartnerClient.js +340 -0
  111. package/dist/mjs/PartnerClient.js.map +1 -0
  112. package/dist/mjs/SpotClient.d.ts +547 -0
  113. package/dist/mjs/SpotClient.js +603 -0
  114. package/dist/mjs/SpotClient.js.map +1 -0
  115. package/dist/mjs/WebsocketAPIClient.d.ts +95 -0
  116. package/dist/mjs/WebsocketAPIClient.js +132 -0
  117. package/dist/mjs/WebsocketAPIClient.js.map +1 -0
  118. package/dist/mjs/WebsocketClient.d.ts +120 -0
  119. package/dist/mjs/WebsocketClient.js +665 -0
  120. package/dist/mjs/WebsocketClient.js.map +1 -0
  121. package/dist/mjs/index.d.ts +24 -0
  122. package/dist/mjs/index.js +25 -0
  123. package/dist/mjs/index.js.map +1 -0
  124. package/dist/mjs/lib/BaseRestClient.d.ts +66 -0
  125. package/dist/mjs/lib/BaseRestClient.js +541 -0
  126. package/dist/mjs/lib/BaseRestClient.js.map +1 -0
  127. package/dist/mjs/lib/BaseWSClient.d.ts +230 -0
  128. package/dist/mjs/lib/BaseWSClient.js +928 -0
  129. package/dist/mjs/lib/BaseWSClient.js.map +1 -0
  130. package/dist/mjs/lib/misc-util.d.ts +1 -0
  131. package/dist/mjs/lib/misc-util.js +4 -0
  132. package/dist/mjs/lib/misc-util.js.map +1 -0
  133. package/dist/mjs/lib/requestUtils.d.ts +68 -0
  134. package/dist/mjs/lib/requestUtils.js +76 -0
  135. package/dist/mjs/lib/requestUtils.js.map +1 -0
  136. package/dist/mjs/lib/webCryptoAPI.d.ts +15 -0
  137. package/dist/mjs/lib/webCryptoAPI.js +80 -0
  138. package/dist/mjs/lib/webCryptoAPI.js.map +1 -0
  139. package/dist/mjs/lib/websocket/WsStore.d.ts +75 -0
  140. package/dist/mjs/lib/websocket/WsStore.js +298 -0
  141. package/dist/mjs/lib/websocket/WsStore.js.map +1 -0
  142. package/dist/mjs/lib/websocket/WsStore.types.d.ts +51 -0
  143. package/dist/mjs/lib/websocket/WsStore.types.js +11 -0
  144. package/dist/mjs/lib/websocket/WsStore.types.js.map +1 -0
  145. package/dist/mjs/lib/websocket/logger.d.ts +7 -0
  146. package/dist/mjs/lib/websocket/logger.js +13 -0
  147. package/dist/mjs/lib/websocket/logger.js.map +1 -0
  148. package/dist/mjs/lib/websocket/rest-client-cache.d.ts +22 -0
  149. package/dist/mjs/lib/websocket/rest-client-cache.js +62 -0
  150. package/dist/mjs/lib/websocket/rest-client-cache.js.map +1 -0
  151. package/dist/mjs/lib/websocket/websocket-util.d.ts +76 -0
  152. package/dist/mjs/lib/websocket/websocket-util.js +54 -0
  153. package/dist/mjs/lib/websocket/websocket-util.js.map +1 -0
  154. package/dist/mjs/package.json +3 -0
  155. package/dist/mjs/types/request/derivatives.types.d.ts +186 -0
  156. package/dist/mjs/types/request/derivatives.types.js +5 -0
  157. package/dist/mjs/types/request/derivatives.types.js.map +1 -0
  158. package/dist/mjs/types/request/institutional.types.d.ts +313 -0
  159. package/dist/mjs/types/request/institutional.types.js +3 -0
  160. package/dist/mjs/types/request/institutional.types.js.map +1 -0
  161. package/dist/mjs/types/request/partner.types.d.ts +291 -0
  162. package/dist/mjs/types/request/partner.types.js +3 -0
  163. package/dist/mjs/types/request/partner.types.js.map +1 -0
  164. package/dist/mjs/types/request/spot.types.d.ts +324 -0
  165. package/dist/mjs/types/request/spot.types.js +5 -0
  166. package/dist/mjs/types/request/spot.types.js.map +1 -0
  167. package/dist/mjs/types/request/wsapi.types.d.ts +90 -0
  168. package/dist/mjs/types/request/wsapi.types.js +5 -0
  169. package/dist/mjs/types/request/wsapi.types.js.map +1 -0
  170. package/dist/mjs/types/response/derivatives.types.d.ts +712 -0
  171. package/dist/mjs/types/response/derivatives.types.js +5 -0
  172. package/dist/mjs/types/response/derivatives.types.js.map +1 -0
  173. package/dist/mjs/types/response/institutional.types.d.ts +318 -0
  174. package/dist/mjs/types/response/institutional.types.js +3 -0
  175. package/dist/mjs/types/response/institutional.types.js.map +1 -0
  176. package/dist/mjs/types/response/partner.types.d.ts +332 -0
  177. package/dist/mjs/types/response/partner.types.js +3 -0
  178. package/dist/mjs/types/response/partner.types.js.map +1 -0
  179. package/dist/mjs/types/response/shared.types.d.ts +27 -0
  180. package/dist/mjs/types/response/shared.types.js +2 -0
  181. package/dist/mjs/types/response/shared.types.js.map +1 -0
  182. package/dist/mjs/types/response/spot.types.d.ts +590 -0
  183. package/dist/mjs/types/response/spot.types.js +5 -0
  184. package/dist/mjs/types/response/spot.types.js.map +1 -0
  185. package/dist/mjs/types/response/ws.d.ts +11 -0
  186. package/dist/mjs/types/response/ws.js +2 -0
  187. package/dist/mjs/types/response/ws.js.map +1 -0
  188. package/dist/mjs/types/response/wsapi.types.d.ts +44 -0
  189. package/dist/mjs/types/response/wsapi.types.js +5 -0
  190. package/dist/mjs/types/response/wsapi.types.js.map +1 -0
  191. package/dist/mjs/types/websockets/ws-api.d.ts +71 -0
  192. package/dist/mjs/types/websockets/ws-api.js +15 -0
  193. package/dist/mjs/types/websockets/ws-api.js.map +1 -0
  194. package/dist/mjs/types/websockets/ws-events.d.ts +11 -0
  195. package/dist/mjs/types/websockets/ws-events.js +8 -0
  196. package/dist/mjs/types/websockets/ws-events.js.map +1 -0
  197. package/dist/mjs/types/websockets/ws-general.d.ts +67 -0
  198. package/dist/mjs/types/websockets/ws-general.js +2 -0
  199. package/dist/mjs/types/websockets/ws-general.js.map +1 -0
  200. package/dist/mjs/types/websockets/ws-subscriptions.d.ts +11 -0
  201. package/dist/mjs/types/websockets/ws-subscriptions.js +28 -0
  202. package/dist/mjs/types/websockets/ws-subscriptions.js.map +1 -0
  203. package/llms.txt +10925 -0
  204. package/package.json +89 -0
@@ -0,0 +1,230 @@
1
+ import { EventEmitter } from 'events';
2
+ import WebSocket from 'isomorphic-ws';
3
+ import { MessageEventLike } from '../types/websockets/ws-events.js';
4
+ import { WebsocketClientOptions, WSClientConfigurableOptions } from '../types/websockets/ws-general.js';
5
+ import { WSTopic } from '../types/websockets/ws-subscriptions.js';
6
+ import { DefaultLogger } from './websocket/logger.js';
7
+ import { WSOperation, WSTopicRequest, WSTopicRequestOrStringTopic } from './websocket/websocket-util.js';
8
+ import { WsStore } from './websocket/WsStore.js';
9
+ import { WSConnectedResult } from './websocket/WsStore.types.js';
10
+ type UseTheExceptionEventInstead = never;
11
+ interface WSClientEventMap<WsKey extends string> {
12
+ /** Connection opened. If this connection was previously opened and reconnected, expect the reconnected event instead */
13
+ open: (evt: {
14
+ wsKey: WsKey;
15
+ event: any;
16
+ wsUrl: string;
17
+ ws: WebSocket;
18
+ }) => void;
19
+ /** Reconnecting a dropped connection */
20
+ reconnecting: (evt: {
21
+ wsKey: WsKey;
22
+ event: any;
23
+ }) => void;
24
+ /** Successfully reconnected a connection that dropped */
25
+ reconnected: (evt: {
26
+ wsKey: WsKey;
27
+ event: any;
28
+ wsUrl: string;
29
+ ws: WebSocket;
30
+ }) => void;
31
+ /** Connection closed */
32
+ close: (evt: {
33
+ wsKey: WsKey;
34
+ event: any;
35
+ }) => void;
36
+ /** Received reply to websocket command (e.g. after subscribing to topics) */
37
+ response: (response: any & {
38
+ wsKey: WsKey;
39
+ }) => void;
40
+ /** Received data for topic */
41
+ message: (response: any & {
42
+ wsKey: WsKey;
43
+ }) => void;
44
+ /** Exception from ws client OR custom listeners (e.g. if you throw inside your event handler) */
45
+ exception: (response: any & {
46
+ wsKey: WsKey;
47
+ }) => void;
48
+ /**
49
+ * See for more information: https://github.com/tiagosiebler/bybit-api/issues/413
50
+ * @deprecated Use the 'exception' event instead. The 'error' event had the unintended consequence of throwing an unhandled promise rejection.
51
+ */
52
+ error: UseTheExceptionEventInstead;
53
+ /** Confirmation that a connection successfully authenticated */
54
+ authenticated: (event: {
55
+ wsKey: WsKey;
56
+ event: any;
57
+ }) => void;
58
+ }
59
+ export interface EmittableEvent<TEventType extends keyof WSClientEventMap<string> = keyof WSClientEventMap<string>> {
60
+ eventType: TEventType | 'pong' | 'connectionReady' | 'connectionReadyForAuth';
61
+ event: Parameters<WSClientEventMap<string>[TEventType]>[0];
62
+ isWSAPIResponse?: boolean;
63
+ }
64
+ export interface BaseWebsocketClient<TWSKey extends string, TWSRequestEvent extends object> {
65
+ on<U extends keyof WSClientEventMap<TWSKey>>(event: U, listener: WSClientEventMap<TWSKey>[U]): this;
66
+ emit<U extends keyof WSClientEventMap<TWSKey>>(event: U, ...args: Parameters<WSClientEventMap<TWSKey>[U]>): boolean;
67
+ }
68
+ /**
69
+ * A midflight WS request event (e.g. subscribe to these topics).
70
+ *
71
+ * - requestKey: unique identifier for this request, if available. Can be anything as a string.
72
+ * - requestEvent: the raw request, as an object, that will be sent on the ws connection. This may contain multiple topics/requests in one object, if the exchange supports it.
73
+ */
74
+ export interface MidflightWsRequestEvent<TEvent = object> {
75
+ requestKey: string | number;
76
+ requestEvent: TEvent;
77
+ }
78
+ export declare abstract class BaseWebsocketClient<TWSKey extends string, TWSRequestEvent extends object> extends EventEmitter {
79
+ private wsStore;
80
+ protected logger: DefaultLogger;
81
+ protected options: WebsocketClientOptions;
82
+ private wsApiRequestId;
83
+ private timeOffsetMs;
84
+ private WS_LOGGER_CATEGORY;
85
+ constructor(options?: WSClientConfigurableOptions & {
86
+ wsLoggerCategory: string;
87
+ }, logger?: DefaultLogger);
88
+ /**
89
+ * Return true if this wsKey connection should automatically authenticate immediately after connecting
90
+ */
91
+ protected abstract isAuthOnConnectWsKey(wsKey: TWSKey): boolean;
92
+ protected abstract isCustomReconnectionNeeded(wsKey: TWSKey): boolean;
93
+ protected abstract triggerCustomReconnectionWorkflow(wsKey: TWSKey): Promise<void>;
94
+ protected abstract sendPingEvent(wsKey: TWSKey, ws: WebSocket): void;
95
+ protected abstract sendPongEvent(wsKey: TWSKey, ws: WebSocket): void;
96
+ protected abstract isWsPing(data: any): boolean;
97
+ protected abstract isWsPong(data: any): boolean;
98
+ protected abstract authPrivateConnectionsOnConnect(_wsKey: TWSKey): boolean;
99
+ /**
100
+ * Return the event sent to the server to trigger authentication. If the event requires waiting for another event first (e.g. a challenge), return 'waitForEvent' and the library will wait for that event before calling this method again.
101
+ *
102
+ * Usually only called once per connection, unless the connection drops/is reset.
103
+ */
104
+ protected abstract getWsAuthRequestEvent(wsKey: TWSKey, eventToAuth?: object): Promise<object | string | 'waitForEvent' | void>;
105
+ protected abstract isPrivateTopicRequest(request: WSTopicRequest<WSTopic>, wsKey: TWSKey): boolean;
106
+ /**
107
+ * Returns a list of string events that can be individually sent upstream to complete subscribing/unsubscribing/etc to these topics
108
+ */
109
+ protected abstract getPrivateWSKeys(): TWSKey[];
110
+ protected abstract getWsUrl(wsKey: TWSKey): Promise<string>;
111
+ protected abstract getMaxTopicsPerSubscribeEvent(wsKey: TWSKey): number | null;
112
+ /**
113
+ * @returns one or more correctly structured request events for performing a operations over WS. This can vary per exchange spec.
114
+ */
115
+ protected abstract getWsRequestEvents(wsKey: TWSKey, operation: WSOperation, requests: WSTopicRequest<WSTopic>[]): Promise<MidflightWsRequestEvent<TWSRequestEvent>[]>;
116
+ /**
117
+ * Abstraction called to sort ws events into emittable event types (response to a request, data update, etc)
118
+ */
119
+ protected abstract resolveEmittableEvents(wsKey: TWSKey, event: MessageEventLike): EmittableEvent[];
120
+ /**
121
+ * Request connection of all dependent (public & private) websockets, instead of waiting for automatic connection by library
122
+ */
123
+ protected abstract connectAll(): Promise<WSConnectedResult | undefined>[];
124
+ protected isPrivateWsKey(wsKey: TWSKey): boolean;
125
+ /** Returns auto-incrementing request ID, used to track promise references for async requests */
126
+ protected getNewRequestId(): number;
127
+ protected abstract sendWSAPIRequest(wsKey: TWSKey, operation: string, params?: any): Promise<unknown>;
128
+ protected abstract sendWSAPIRequest(wsKey: TWSKey, channel: string, params: any): Promise<unknown>;
129
+ getTimeOffsetMs(): number;
130
+ setTimeOffsetMs(newOffset: number): void;
131
+ /**
132
+ * Don't call directly! Use subscribe() instead!
133
+ *
134
+ * Subscribe to one or more topics on a WS connection (identified by WS Key).
135
+ *
136
+ * - Topics are automatically cached
137
+ * - Connections are automatically opened, if not yet connected
138
+ * - Authentication is automatically handled
139
+ * - Topics are automatically resubscribed to, if something happens to the connection, unless you call unsubsribeTopicsForWsKey(topics, key).
140
+ *
141
+ * @param wsTopicRequests array of topics to subscribe to
142
+ * @param wsKey ws key referring to the ws connection these topics should be subscribed on
143
+ */
144
+ protected subscribeTopicsForWsKey(wsTopicRequests: WSTopicRequestOrStringTopic<WSTopic>[], wsKey: TWSKey): Promise<boolean | void | WSConnectedResult>;
145
+ protected unsubscribeTopicsForWsKey(wsTopicRequests: WSTopicRequestOrStringTopic<WSTopic>[], wsKey: TWSKey): Promise<unknown>;
146
+ /**
147
+ * Splits topic requests into two groups, public & private topic requests
148
+ */
149
+ private sortTopicRequestsIntoPublicPrivate;
150
+ /** Get the WsStore that tracks websockets & topics */
151
+ getWsStore(): WsStore<TWSKey, WSTopicRequest<WSTopic>>;
152
+ close(wsKey: TWSKey, force?: boolean): void;
153
+ closeAll(force?: boolean): void;
154
+ isConnected(wsKey: TWSKey): boolean;
155
+ /**
156
+ * Request connection to a specific websocket, instead of waiting for automatic connection.
157
+ */
158
+ connect(wsKey: TWSKey, customUrl?: string | undefined, throwOnError?: boolean): Promise<WSConnectedResult | undefined>;
159
+ private connectToWsUrl;
160
+ private parseWsError;
161
+ /** Get a signature, build the auth request and send it */
162
+ private sendAuthRequest;
163
+ private reconnectWithDelay;
164
+ private ping;
165
+ /**
166
+ * Closes a connection, if it's even open. If open, this will trigger a reconnect asynchronously.
167
+ * If closed, trigger a reconnect immediately
168
+ */
169
+ protected executeReconnectableClose(wsKey: TWSKey, reason: string): void;
170
+ private clearTimers;
171
+ private clearPingTimer;
172
+ private clearPongTimer;
173
+ private clearReconnectTimer;
174
+ /**
175
+ * Returns a list of string events that can be individually sent upstream to complete subscribing/unsubscribing/etc to these topics
176
+ *
177
+ * If events are an object, these should be stringified (`return JSON.stringify(event);`)
178
+ * Each event returned by this will be sent one at a time
179
+ *
180
+ * Events are automatically split into smaller batches, by this method, if needed.
181
+ */
182
+ protected getWsOperationEventsForTopics(topics: WSTopicRequest<WSTopic>[], wsKey: TWSKey, operation: WSOperation): Promise<MidflightWsRequestEvent<TWSRequestEvent>[]>;
183
+ /**
184
+ * Simply builds and sends subscribe events for a list of topics for a ws key
185
+ *
186
+ * @private Use the `subscribe(topics)` or `subscribeTopicsForWsKey(topics, wsKey)` method to subscribe to topics. Send WS message to subscribe to topics.
187
+ */
188
+ private requestSubscribeTopics;
189
+ /**
190
+ * Simply builds and sends unsubscribe events for a list of topics for a ws key
191
+ *
192
+ * @private Use the `unsubscribe(topics)` method to unsubscribe from topics. Send WS message to unsubscribe from topics.
193
+ */
194
+ private requestUnsubscribeTopics;
195
+ /**
196
+ * Try sending a string event on a WS connection (identified by the WS Key)
197
+ */
198
+ tryWsSend(wsKey: TWSKey, wsMessage: string, throwExceptions?: boolean): void;
199
+ private onWsOpen;
200
+ private resolveConnectionInProgressPromise;
201
+ /**
202
+ * Called automatically once a connection is ready.
203
+ * - Some exchanges are ready immediately after the connections open.
204
+ * - Some exchanges send an event to confirm the connection is ready for us.
205
+ *
206
+ * This method is called to act when the connection is ready. Use `requireConnectionReadyConfirmation` to control how this is called.
207
+ */
208
+ private onWsReadyForEvents;
209
+ /**
210
+ * Handle subscription to private topics _after_ authentication successfully completes asynchronously.
211
+ *
212
+ * Only used for exchanges that require auth before sending private topic subscription requests
213
+ */
214
+ private onWsAuthenticated;
215
+ private onWsPing;
216
+ private onWsPong;
217
+ private onWsMessage;
218
+ private onWsClose;
219
+ private getWs;
220
+ private setWsState;
221
+ /**
222
+ * Promise-driven method to assert that a ws has successfully connected (will await until connection is open)
223
+ */
224
+ protected assertIsConnected(wsKey: TWSKey): Promise<unknown>;
225
+ /**
226
+ * Promise-driven method to assert that a ws has been successfully authenticated (will await until auth is confirmed)
227
+ */
228
+ assertIsAuthenticated(wsKey: TWSKey): Promise<unknown>;
229
+ }
230
+ export {};