@upbit-official/upbit-sdk 1.0.0 → 1.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.
Files changed (190) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +21 -0
  3. package/client.d.mts +10 -4
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +10 -4
  6. package/client.d.ts.map +1 -1
  7. package/client.js +23 -5
  8. package/client.js.map +1 -1
  9. package/client.mjs +23 -5
  10. package/client.mjs.map +1 -1
  11. package/index.d.mts +3 -1
  12. package/index.d.mts.map +1 -1
  13. package/index.d.ts +3 -1
  14. package/index.d.ts.map +1 -1
  15. package/index.js +2 -1
  16. package/index.js.map +1 -1
  17. package/index.mjs +1 -1
  18. package/index.mjs.map +1 -1
  19. package/internal/ws-parser.d.mts +40 -0
  20. package/internal/ws-parser.d.mts.map +1 -0
  21. package/internal/ws-parser.d.ts +40 -0
  22. package/internal/ws-parser.d.ts.map +1 -0
  23. package/internal/ws-parser.js +125 -0
  24. package/internal/ws-parser.js.map +1 -0
  25. package/internal/ws-parser.mjs +118 -0
  26. package/internal/ws-parser.mjs.map +1 -0
  27. package/internal/ws-simple-types.d.mts +8 -0
  28. package/internal/ws-simple-types.d.mts.map +1 -0
  29. package/internal/ws-simple-types.d.ts +8 -0
  30. package/internal/ws-simple-types.d.ts.map +1 -0
  31. package/internal/ws-simple-types.js +3 -0
  32. package/internal/ws-simple-types.js.map +1 -0
  33. package/internal/ws-simple-types.mjs +2 -0
  34. package/internal/ws-simple-types.mjs.map +1 -0
  35. package/internal/ws.d.mts +1 -0
  36. package/internal/ws.d.mts.map +1 -1
  37. package/internal/ws.d.ts +1 -0
  38. package/internal/ws.d.ts.map +1 -1
  39. package/internal/ws.js.map +1 -1
  40. package/internal/ws.mjs.map +1 -1
  41. package/lib/index.d.mts +4 -2
  42. package/lib/index.d.mts.map +1 -1
  43. package/lib/index.d.ts +4 -2
  44. package/lib/index.d.ts.map +1 -1
  45. package/lib/index.js +2 -1
  46. package/lib/index.js.map +1 -1
  47. package/lib/index.mjs +1 -1
  48. package/lib/index.mjs.map +1 -1
  49. package/lib/jsonParseFloat.d.mts +5 -5
  50. package/lib/jsonParseFloat.d.mts.map +1 -1
  51. package/lib/jsonParseFloat.d.ts +5 -5
  52. package/lib/jsonParseFloat.d.ts.map +1 -1
  53. package/lib/jsonParseFloat.js +30 -12
  54. package/lib/jsonParseFloat.js.map +1 -1
  55. package/lib/jsonParseFloat.mjs +30 -12
  56. package/lib/jsonParseFloat.mjs.map +1 -1
  57. package/lib/ws.d.mts +102 -15
  58. package/lib/ws.d.mts.map +1 -1
  59. package/lib/ws.d.ts +102 -15
  60. package/lib/ws.d.ts.map +1 -1
  61. package/lib/ws.js +208 -34
  62. package/lib/ws.js.map +1 -1
  63. package/lib/ws.mjs +204 -33
  64. package/lib/ws.mjs.map +1 -1
  65. package/package.json +1 -1
  66. package/resources/index.d.mts +3 -2
  67. package/resources/index.d.mts.map +1 -1
  68. package/resources/index.d.ts +3 -2
  69. package/resources/index.d.ts.map +1 -1
  70. package/resources/index.js +3 -1
  71. package/resources/index.js.map +1 -1
  72. package/resources/index.mjs +3 -2
  73. package/resources/index.mjs.map +1 -1
  74. package/resources/ws-info/index.d.mts +6 -0
  75. package/resources/ws-info/index.d.mts.map +1 -0
  76. package/resources/ws-info/index.d.ts +6 -0
  77. package/resources/ws-info/index.d.ts.map +1 -0
  78. package/resources/ws-info/index.js +6 -0
  79. package/resources/ws-info/index.js.map +1 -0
  80. package/resources/ws-info/index.mjs +2 -0
  81. package/resources/ws-info/index.mjs.map +1 -0
  82. package/resources/ws-info/internal-base.d.mts +63 -0
  83. package/resources/ws-info/internal-base.d.mts.map +1 -0
  84. package/resources/ws-info/internal-base.d.ts +63 -0
  85. package/resources/ws-info/internal-base.d.ts.map +1 -0
  86. package/resources/ws-info/internal-base.js +47 -0
  87. package/resources/ws-info/internal-base.js.map +1 -0
  88. package/resources/ws-info/internal-base.mjs +41 -0
  89. package/resources/ws-info/internal-base.mjs.map +1 -0
  90. package/resources/ws-info/ws-info.d.mts +1180 -0
  91. package/resources/ws-info/ws-info.d.mts.map +1 -0
  92. package/resources/ws-info/ws-info.d.ts +1180 -0
  93. package/resources/ws-info/ws-info.d.ts.map +1 -0
  94. package/resources/ws-info/ws-info.js +8 -0
  95. package/resources/ws-info/ws-info.js.map +1 -0
  96. package/resources/ws-info/ws-info.mjs +4 -0
  97. package/resources/ws-info/ws-info.mjs.map +1 -0
  98. package/resources/ws-info/ws.d.mts +91 -0
  99. package/resources/ws-info/ws.d.mts.map +1 -0
  100. package/resources/ws-info/ws.d.ts +91 -0
  101. package/resources/ws-info/ws.d.ts.map +1 -0
  102. package/resources/ws-info/ws.js +463 -0
  103. package/resources/ws-info/ws.js.map +1 -0
  104. package/resources/ws-info/ws.mjs +458 -0
  105. package/resources/ws-info/ws.mjs.map +1 -0
  106. package/resources/ws-info.d.mts +2 -0
  107. package/resources/ws-info.d.mts.map +1 -0
  108. package/resources/ws-info.d.ts +2 -0
  109. package/resources/ws-info.d.ts.map +1 -0
  110. package/resources/ws-info.js +5 -0
  111. package/resources/ws-info.js.map +1 -0
  112. package/resources/ws-info.mjs +2 -0
  113. package/resources/ws-info.mjs.map +1 -0
  114. package/resources/ws-private/index.d.mts +3 -1
  115. package/resources/ws-private/index.d.mts.map +1 -1
  116. package/resources/ws-private/index.d.ts +3 -1
  117. package/resources/ws-private/index.d.ts.map +1 -1
  118. package/resources/ws-private/index.js.map +1 -1
  119. package/resources/ws-private/index.mjs +1 -1
  120. package/resources/ws-private/index.mjs.map +1 -1
  121. package/resources/ws-private/internal-base.d.mts.map +1 -1
  122. package/resources/ws-private/internal-base.d.ts.map +1 -1
  123. package/resources/ws-private/internal-base.js.map +1 -1
  124. package/resources/ws-private/internal-base.mjs.map +1 -1
  125. package/resources/ws-private/ws-private.d.mts +301 -9
  126. package/resources/ws-private/ws-private.d.mts.map +1 -1
  127. package/resources/ws-private/ws-private.d.ts +301 -9
  128. package/resources/ws-private/ws-private.d.ts.map +1 -1
  129. package/resources/ws-private/ws-private.js.map +1 -1
  130. package/resources/ws-private/ws-private.mjs.map +1 -1
  131. package/resources/ws-private/ws.d.mts +2 -2
  132. package/resources/ws-private/ws.d.mts.map +1 -1
  133. package/resources/ws-private/ws.d.ts +2 -2
  134. package/resources/ws-private/ws.d.ts.map +1 -1
  135. package/resources/ws-private/ws.js +15 -20
  136. package/resources/ws-private/ws.js.map +1 -1
  137. package/resources/ws-private/ws.mjs +15 -20
  138. package/resources/ws-private/ws.mjs.map +1 -1
  139. package/resources/ws-public/index.d.mts +3 -1
  140. package/resources/ws-public/index.d.mts.map +1 -1
  141. package/resources/ws-public/index.d.ts +3 -1
  142. package/resources/ws-public/index.d.ts.map +1 -1
  143. package/resources/ws-public/index.js.map +1 -1
  144. package/resources/ws-public/index.mjs +1 -1
  145. package/resources/ws-public/index.mjs.map +1 -1
  146. package/resources/ws-public/internal-base.d.mts.map +1 -1
  147. package/resources/ws-public/internal-base.d.ts.map +1 -1
  148. package/resources/ws-public/internal-base.js.map +1 -1
  149. package/resources/ws-public/internal-base.mjs.map +1 -1
  150. package/resources/ws-public/ws-public.d.mts +355 -5
  151. package/resources/ws-public/ws-public.d.mts.map +1 -1
  152. package/resources/ws-public/ws-public.d.ts +355 -5
  153. package/resources/ws-public/ws-public.d.ts.map +1 -1
  154. package/resources/ws-public/ws.d.mts +2 -2
  155. package/resources/ws-public/ws.d.mts.map +1 -1
  156. package/resources/ws-public/ws.d.ts +2 -2
  157. package/resources/ws-public/ws.d.ts.map +1 -1
  158. package/resources/ws-public/ws.js +15 -20
  159. package/resources/ws-public/ws.js.map +1 -1
  160. package/resources/ws-public/ws.mjs +15 -20
  161. package/resources/ws-public/ws.mjs.map +1 -1
  162. package/src/client.ts +92 -5
  163. package/src/index.ts +24 -1
  164. package/src/internal/ws-parser.ts +164 -0
  165. package/src/internal/ws-simple-types.ts +34 -0
  166. package/src/internal/ws.ts +1 -0
  167. package/src/lib/index.ts +17 -2
  168. package/src/lib/jsonParseFloat.ts +37 -12
  169. package/src/lib/ws.ts +367 -55
  170. package/src/resources/index.ts +42 -2
  171. package/src/resources/ws-info/index.ts +44 -0
  172. package/src/resources/ws-info/internal-base.ts +96 -0
  173. package/src/resources/ws-info/ws-info.ts +1855 -0
  174. package/src/resources/ws-info/ws.ts +574 -0
  175. package/src/resources/ws-info.ts +1 -0
  176. package/src/resources/ws-private/index.ts +12 -1
  177. package/src/resources/ws-private/internal-base.ts +0 -1
  178. package/src/resources/ws-private/ws-private.ts +420 -18
  179. package/src/resources/ws-private/ws.ts +16 -23
  180. package/src/resources/ws-public/index.ts +16 -1
  181. package/src/resources/ws-public/internal-base.ts +0 -1
  182. package/src/resources/ws-public/ws-public.ts +459 -4
  183. package/src/resources/ws-public/ws.ts +16 -23
  184. package/src/version.ts +1 -1
  185. package/version.d.mts +1 -1
  186. package/version.d.ts +1 -1
  187. package/version.js +1 -1
  188. package/version.js.map +1 -1
  189. package/version.mjs +1 -1
  190. package/version.mjs.map +1 -1
@@ -3,8 +3,458 @@ import { APIResource } from '../../core/resource';
3
3
  export class WsPublic extends APIResource {}
4
4
 
5
5
  /**
6
- * WebSocket public client event — subscription request sent to server
6
+ * Subscription query response in DEFAULT or JSON_LIST format.
7
7
  */
8
+ export interface ListSubscriptionsResponse {
9
+ method: 'LIST_SUBSCRIPTIONS';
10
+
11
+ /** Current subscriptions. Additional fields depend on the subscription type. */
12
+ result: Array<ListSubscriptionsResponse.Result>;
13
+
14
+ /** Ticket returned by the server. */
15
+ ticket: string;
16
+ }
17
+
18
+ export namespace ListSubscriptionsResponse {
19
+ export interface Result {
20
+ /** Subscribed stream type. */
21
+ type: string;
22
+
23
+ [key: string]: unknown;
24
+ }
25
+ }
26
+
27
+ /**
28
+ * Subscription query response in the requested WebSocket format.
29
+ */
30
+ export type ListSubscriptionsServerResponse = ListSubscriptionsResponse | SimpleListSubscriptionsResponse;
31
+
32
+ export interface SimpleCandle {
33
+ /**
34
+ * Data type (candle.{interval}). Examples: candle.1s, candle.1m, candle.240m
35
+ */
36
+ ty:
37
+ | 'candle.1s'
38
+ | 'candle.1m'
39
+ | 'candle.3m'
40
+ | 'candle.5m'
41
+ | 'candle.10m'
42
+ | 'candle.15m'
43
+ | 'candle.30m'
44
+ | 'candle.60m'
45
+ | 'candle.240m';
46
+
47
+ /**
48
+ * Accumulated trade value
49
+ */
50
+ catp?: string;
51
+
52
+ /**
53
+ * Accumulated trade volume
54
+ */
55
+ catv?: string;
56
+
57
+ /**
58
+ * Market code
59
+ */
60
+ cd?: string;
61
+
62
+ /**
63
+ * Candle base time (KST, yyyy-MM-dd'T'HH:mm:ss)
64
+ */
65
+ cdttmk?: string;
66
+
67
+ /**
68
+ * Candle base time (UTC, yyyy-MM-dd'T'HH:mm:ss)
69
+ */
70
+ cdttmu?: string;
71
+
72
+ /**
73
+ * High price
74
+ */
75
+ hp?: string;
76
+
77
+ /**
78
+ * Low price
79
+ */
80
+ lp?: string;
81
+
82
+ /**
83
+ * Opening price
84
+ */
85
+ op?: string;
86
+
87
+ /**
88
+ * Stream type (snapshot or realtime)
89
+ */
90
+ st?: 'SNAPSHOT' | 'REALTIME';
91
+
92
+ /**
93
+ * Timestamp (ms)
94
+ */
95
+ tms?: number;
96
+
97
+ /**
98
+ * Closing price (current price)
99
+ */
100
+ tp?: string;
101
+ }
102
+
103
+ /**
104
+ * Subscription query response in SIMPLE or SIMPLE_LIST format.
105
+ */
106
+ export interface SimpleListSubscriptionsResponse {
107
+ mthd: 'LIST_SUBSCRIPTIONS';
108
+
109
+ /** Current subscriptions with abbreviated keys. */
110
+ rslt: Array<SimpleListSubscriptionsResponse.Result>;
111
+
112
+ /** Ticket returned by the server. */
113
+ tckt: string;
114
+ }
115
+
116
+ export namespace SimpleListSubscriptionsResponse {
117
+ export interface Result {
118
+ /** Subscribed stream type. */
119
+ ty: string;
120
+
121
+ [key: string]: unknown;
122
+ }
123
+ }
124
+
125
+ export interface SimpleOrderbook {
126
+ /**
127
+ * Data type
128
+ */
129
+ ty: 'orderbook';
130
+
131
+ /**
132
+ * Market code
133
+ */
134
+ cd?: string;
135
+
136
+ /**
137
+ * Orderbook grouping unit. 0 means default unit. KRW markets only.
138
+ */
139
+ lv?: string;
140
+
141
+ /**
142
+ * List of orderbook units (default 30; adjustable via .count in codes)
143
+ */
144
+ obu?: Array<SimpleOrderbook.Obu>;
145
+
146
+ /**
147
+ * Stream type (snapshot or realtime)
148
+ */
149
+ st?: 'SNAPSHOT' | 'REALTIME';
150
+
151
+ /**
152
+ * Total ask quantity in orderbook
153
+ */
154
+ tas?: string;
155
+
156
+ /**
157
+ * Total bid quantity in orderbook
158
+ */
159
+ tbs?: string;
160
+
161
+ /**
162
+ * Timestamp (ms)
163
+ */
164
+ tms?: number;
165
+ }
166
+
167
+ export namespace SimpleOrderbook {
168
+ /**
169
+ * Orderbook unit entry
170
+ */
171
+ export interface Obu {
172
+ /**
173
+ * Ask price
174
+ */
175
+ ap?: string;
176
+
177
+ /**
178
+ * Ask quantity
179
+ */
180
+ as?: string;
181
+
182
+ /**
183
+ * Bid price
184
+ */
185
+ bp?: string;
186
+
187
+ /**
188
+ * Bid quantity
189
+ */
190
+ bs?: string;
191
+ }
192
+ }
193
+
194
+ export type SimplePublicServerEvent = SimpleTicker | SimpleTrade | SimpleOrderbook | SimpleCandle;
195
+
196
+ export interface SimpleTicker {
197
+ /**
198
+ * Data type
199
+ */
200
+ ty: 'ticker';
201
+
202
+ /**
203
+ * Accumulated ask volume
204
+ */
205
+ aav?: string;
206
+
207
+ /**
208
+ * Ask/bid side
209
+ */
210
+ ab?: 'ASK' | 'BID';
211
+
212
+ /**
213
+ * Accumulated bid volume
214
+ */
215
+ abv?: string;
216
+
217
+ /**
218
+ * Accumulated trade value (since UTC 00:00)
219
+ */
220
+ atp?: string;
221
+
222
+ /**
223
+ * 24-hour accumulated trade value
224
+ */
225
+ atp24h?: string;
226
+
227
+ /**
228
+ * Accumulated trade volume (since UTC 00:00)
229
+ */
230
+ atv?: string;
231
+
232
+ /**
233
+ * 24-hour accumulated trade volume
234
+ */
235
+ atv24h?: string;
236
+
237
+ /**
238
+ * Price change direction relative to previous close
239
+ */
240
+ c?: 'RISE' | 'EVEN' | 'FALL';
241
+
242
+ /**
243
+ * Market code
244
+ */
245
+ cd?: string;
246
+
247
+ /**
248
+ * Absolute price change from previous close
249
+ */
250
+ cp?: string;
251
+
252
+ /**
253
+ * Absolute change rate from previous close
254
+ */
255
+ cr?: string;
256
+
257
+ /**
258
+ * Delisting date (only present when delisting is scheduled)
259
+ */
260
+ dd?: SimpleTicker.Dd | null;
261
+
262
+ /**
263
+ * Date of 52-week high (yyyy-MM-dd)
264
+ */
265
+ h52wdt?: string;
266
+
267
+ /**
268
+ * 52-week high price
269
+ */
270
+ h52wp?: string;
271
+
272
+ /**
273
+ * High price
274
+ */
275
+ hp?: string;
276
+
277
+ /**
278
+ * Date of 52-week low (yyyy-MM-dd)
279
+ */
280
+ l52wdt?: string;
281
+
282
+ /**
283
+ * 52-week low price
284
+ */
285
+ l52wp?: string;
286
+
287
+ /**
288
+ * Low price
289
+ */
290
+ lp?: string;
291
+
292
+ /**
293
+ * Market trading status
294
+ */
295
+ ms?: 'PREVIEW' | 'ACTIVE' | 'DELISTED';
296
+
297
+ /**
298
+ * Opening price
299
+ */
300
+ op?: string;
301
+
302
+ /**
303
+ * Previous day closing price
304
+ */
305
+ pcp?: string;
306
+
307
+ /**
308
+ * Signed price change from previous close
309
+ */
310
+ scp?: string;
311
+
312
+ /**
313
+ * Signed change rate from previous close
314
+ */
315
+ scr?: string;
316
+
317
+ /**
318
+ * Stream type (snapshot or realtime)
319
+ */
320
+ st?: 'SNAPSHOT' | 'REALTIME';
321
+
322
+ /**
323
+ * Most recent trade date (UTC, yyyyMMdd)
324
+ */
325
+ tdt?: string;
326
+
327
+ /**
328
+ * Timestamp (ms)
329
+ */
330
+ tms?: number;
331
+
332
+ /**
333
+ * Current price (closing price)
334
+ */
335
+ tp?: string;
336
+
337
+ /**
338
+ * Most recent trade time (UTC, HHmmss)
339
+ */
340
+ ttm?: string;
341
+
342
+ /**
343
+ * Trade timestamp (ms)
344
+ */
345
+ ttms?: number;
346
+
347
+ /**
348
+ * Most recent trade volume
349
+ */
350
+ tv?: string;
351
+ }
352
+
353
+ export namespace SimpleTicker {
354
+ /**
355
+ * Delisting date (only present when delisting is scheduled)
356
+ */
357
+ export interface Dd {
358
+ day?: number;
359
+
360
+ month?: number;
361
+
362
+ year?: number;
363
+ }
364
+ }
365
+
366
+ export interface SimpleTrade {
367
+ /**
368
+ * Data type
369
+ */
370
+ ty: 'trade';
371
+
372
+ /**
373
+ * Ask/bid side
374
+ */
375
+ ab?: 'ASK' | 'BID';
376
+
377
+ /**
378
+ * Best ask price
379
+ */
380
+ bap?: string;
381
+
382
+ /**
383
+ * Best ask quantity
384
+ */
385
+ bas?: string;
386
+
387
+ /**
388
+ * Best bid price
389
+ */
390
+ bbp?: string;
391
+
392
+ /**
393
+ * Best bid quantity
394
+ */
395
+ bbs?: string;
396
+
397
+ /**
398
+ * Price change direction relative to previous close
399
+ */
400
+ c?: 'RISE' | 'EVEN' | 'FALL';
401
+
402
+ /**
403
+ * Market code
404
+ */
405
+ cd?: string;
406
+
407
+ /**
408
+ * Absolute price change from previous close
409
+ */
410
+ cp?: string;
411
+
412
+ /**
413
+ * Previous day closing price
414
+ */
415
+ pcp?: string;
416
+
417
+ /**
418
+ * Unique trade ID. Used to determine trade uniqueness; order is not guaranteed.
419
+ */
420
+ sid?: number;
421
+
422
+ /**
423
+ * Stream type (snapshot or realtime)
424
+ */
425
+ st?: 'SNAPSHOT' | 'REALTIME';
426
+
427
+ /**
428
+ * Trade date (UTC, yyyy-MM-dd)
429
+ */
430
+ td?: string;
431
+
432
+ /**
433
+ * Timestamp (ms)
434
+ */
435
+ tms?: number;
436
+
437
+ /**
438
+ * Trade price
439
+ */
440
+ tp?: string;
441
+
442
+ /**
443
+ * Trade time (UTC, HH:mm:ss)
444
+ */
445
+ ttm?: string;
446
+
447
+ /**
448
+ * Trade timestamp (ms)
449
+ */
450
+ ttms?: number;
451
+
452
+ /**
453
+ * Trade volume
454
+ */
455
+ tv?: string;
456
+ }
457
+
8
458
  export type ConnectPublicClientEvent =
9
459
  | Array<
10
460
  | ConnectPublicClientEvent.WsTicketField
@@ -127,9 +577,6 @@ export namespace ConnectPublicClientEvent {
127
577
  }
128
578
  }
129
579
 
130
- /**
131
- * WebSocket public server event — stream message received from server
132
- */
133
580
  export type ConnectPublicServerEvent =
134
581
  | ConnectPublicServerEvent.Ticker
135
582
  | ConnectPublicServerEvent.Trade
@@ -554,6 +1001,14 @@ export namespace ConnectPublicServerEvent {
554
1001
 
555
1002
  export declare namespace WsPublic {
556
1003
  export {
1004
+ type ListSubscriptionsResponse as ListSubscriptionsResponse,
1005
+ type ListSubscriptionsServerResponse as ListSubscriptionsServerResponse,
1006
+ type SimpleListSubscriptionsResponse as SimpleListSubscriptionsResponse,
1007
+ type SimpleCandle as SimpleCandle,
1008
+ type SimpleOrderbook as SimpleOrderbook,
1009
+ type SimplePublicServerEvent as SimplePublicServerEvent,
1010
+ type SimpleTicker as SimpleTicker,
1011
+ type SimpleTrade as SimpleTrade,
557
1012
  type ConnectPublicClientEvent as ConnectPublicClientEvent,
558
1013
  type ConnectPublicServerEvent as ConnectPublicServerEvent,
559
1014
  };
@@ -3,9 +3,9 @@ import { WsPublicEmitter, WsPublicStreamMessage, WebSocketError, buildURL } from
3
3
  import { InternalEventEmitter } from '../../core/EventEmitter';
4
4
  import { sleep } from '../../internal/utils/sleep';
5
5
  import { isRecoverableClose, type ReconnectingEvent, type ReconnectingOverrides } from '../../internal/ws';
6
- import * as WsPublicAPI from './ws-public';
7
- import { Upbit } from '../../client';
8
- import { jsonParseFloat } from '../../lib/jsonParseFloat';
6
+ import type * as WsPublicAPI from './ws-public';
7
+ import type { Upbit } from '../../client';
8
+ import { isRecord, parseWebSocketValue } from '../../internal/ws-parser';
9
9
 
10
10
  export interface WsPublicWSReconnectOptions {
11
11
  /**
@@ -68,7 +68,7 @@ export class WsPublicWS extends WsPublicEmitter {
68
68
  ) {
69
69
  super();
70
70
  this._client = client;
71
- this._parameters = undefined;
71
+ this._parameters = parameters;
72
72
  const { reconnect, ...wsOptions } = options ?? {};
73
73
  this._wsOptions = wsOptions;
74
74
  this._reconnectOptions = reconnect ?? null;
@@ -146,7 +146,7 @@ export class WsPublicWS extends WsPublicEmitter {
146
146
  push({ type: 'message', message: event });
147
147
  };
148
148
 
149
- // All errors (API + socket) funnel through _onError → 'error' event
149
+ // Connection and transport errors funnel through _onError → 'error' event
150
150
  const onEmitterError = (err: WebSocketError) => {
151
151
  push({ type: 'error', error: err });
152
152
  };
@@ -271,27 +271,20 @@ export class WsPublicWS extends WsPublicEmitter {
271
271
 
272
272
  const socket = new WS.WebSocket(this.url, {
273
273
  ...this._wsOptions,
274
- headers: {
275
- ...this._authHeaders(),
276
- ...this._wsOptions?.headers,
277
- },
274
+ headers: this._client._buildWebSocketHandshakeHeaders(this._authHeaders(), this._wsOptions?.headers),
278
275
  });
279
276
 
280
277
  socket.on('message', (wsEvent) => {
281
- const event = (() => {
282
- try {
283
- return jsonParseFloat(wsEvent.toString()) as WsPublicAPI.ConnectPublicServerEvent;
284
- } catch (err) {
285
- this._onError(null, 'could not parse websocket event', err);
286
- return null;
287
- }
288
- })();
289
-
290
- if (event) {
291
- this._emit('event', event);
292
-
293
- // @ts-ignore TS isn't smart enough to get the relationship right here
294
- this._emit(event.type, event);
278
+ let event: unknown;
279
+ try {
280
+ event = parseWebSocketValue(wsEvent.toString());
281
+ } catch (error) {
282
+ this._onError(null, 'could not parse WebSocket message', new SyntaxError('Invalid WebSocket JSON'));
283
+ return;
284
+ }
285
+ this._emit('event', event as WsPublicAPI.ConnectPublicServerEvent);
286
+ if (isRecord(event) && typeof event['type'] === 'string') {
287
+ this._emit(event['type'] as any, event as any);
295
288
  }
296
289
  });
297
290
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.0.0';
1
+ export const VERSION = '1.1.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.0.0";
1
+ export declare const VERSION = "1.1.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.0.0";
1
+ export declare const VERSION = "1.1.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '1.0.0';
4
+ exports.VERSION = '1.1.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,OAAO,CAAC"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,OAAO,CAAC,CAAC,2BAA2B"}
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '1.0.0';
1
+ export const VERSION = '1.1.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map
package/version.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"version.mjs","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
1
+ {"version":3,"file":"version.mjs","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,2BAA2B"}