@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
@@ -1,22 +1,372 @@
1
+ import type { WebSocketMessage } from '../../internal/ws-parser';
2
+
3
+ import type { WsListSubscriptionsResponse } from '../../lib/ws';
4
+
1
5
  import { APIResource } from '../../core/resource';
2
6
 
7
+ import * as WsPrivateAPI from './ws-private';
8
+
3
9
  export class WsPrivate extends APIResource {}
4
10
 
11
+ export interface Announcement {
12
+ /**
13
+ * Data type
14
+ */
15
+ type: 'announcement';
16
+
17
+ /**
18
+ * Announcement body in Markdown. Included only when include_body is true and may
19
+ * be null for large bodies.
20
+ */
21
+ body?: string | null;
22
+
23
+ /**
24
+ * Announcement category
25
+ */
26
+ category?: AnnouncementCategory;
27
+
28
+ /**
29
+ * Announcement event type
30
+ */
31
+ event_type?: AnnouncementEventType;
32
+
33
+ /**
34
+ * First publication time (KST, ISO 8601)
35
+ */
36
+ first_listed_at?: string;
37
+
38
+ /**
39
+ * Latest publication time (KST, ISO 8601)
40
+ */
41
+ listed_at?: string;
42
+
43
+ /**
44
+ * Stream type (announcement supports realtime only)
45
+ */
46
+ stream_type?: 'REALTIME';
47
+
48
+ /**
49
+ * Timestamp (ms)
50
+ */
51
+ timestamp?: number;
52
+
53
+ /**
54
+ * Announcement title
55
+ */
56
+ title?: string;
57
+
58
+ /**
59
+ * Announcement detail page URL
60
+ */
61
+ url?: string;
62
+
63
+ /**
64
+ * Announcement unique ID
65
+ */
66
+ uuid?: string;
67
+ }
68
+
5
69
  /**
6
- * WebSocket private client event — subscription request sent to server (JWT
7
- * required)
70
+ * Announcement category
8
71
  */
9
- export type ConnectPrivateClientEvent =
10
- | Array<
11
- | ConnectPrivateClientEvent.WsTicketField
12
- | ConnectPrivateClientEvent.WsMyOrderTypeField
13
- | ConnectPrivateClientEvent.WsFormatField
14
- >
15
- | Array<
16
- | ConnectPrivateClientEvent.WsTicketField
17
- | ConnectPrivateClientEvent.WsMyAssetTypeField
18
- | ConnectPrivateClientEvent.WsFormatField
19
- >;
72
+ export type AnnouncementCategory =
73
+ | 'notice'
74
+ | 'trade'
75
+ | 'wallet'
76
+ | 'maintenance'
77
+ | 'digital_asset'
78
+ | 'nft'
79
+ | 'service'
80
+ | 'event'
81
+ | 'note'
82
+ | 'trading'
83
+ | 'airdrop'
84
+ | 'feature'
85
+ | 'disclosure';
86
+
87
+ export type AnnouncementEventType = 'CREATED' | 'UPDATED';
88
+
89
+ export interface SimpleAnnouncement {
90
+ /**
91
+ * Data type
92
+ */
93
+ ty: 'announcement';
94
+
95
+ /**
96
+ * Announcement body in Markdown. Included only when include_body is true and may
97
+ * be null for large bodies.
98
+ */
99
+ bd?: string | null;
100
+
101
+ /**
102
+ * Announcement category
103
+ */
104
+ cat?:
105
+ | 'notice'
106
+ | 'trade'
107
+ | 'wallet'
108
+ | 'maintenance'
109
+ | 'digital_asset'
110
+ | 'nft'
111
+ | 'service'
112
+ | 'event'
113
+ | 'note'
114
+ | 'trading'
115
+ | 'airdrop'
116
+ | 'feature'
117
+ | 'disclosure';
118
+
119
+ /**
120
+ * Announcement event type
121
+ */
122
+ et?: 'CREATED' | 'UPDATED';
123
+
124
+ /**
125
+ * First publication time (KST, ISO 8601)
126
+ */
127
+ flat?: string;
128
+
129
+ /**
130
+ * Latest publication time (KST, ISO 8601)
131
+ */
132
+ lat?: string;
133
+
134
+ /**
135
+ * Stream type (announcement supports realtime only)
136
+ */
137
+ st?: 'REALTIME';
138
+
139
+ /**
140
+ * Timestamp (ms)
141
+ */
142
+ tms?: number;
143
+
144
+ /**
145
+ * Announcement title
146
+ */
147
+ tt?: string;
148
+
149
+ /**
150
+ * Announcement unique ID
151
+ */
152
+ uid?: string;
153
+
154
+ /**
155
+ * Announcement detail page URL
156
+ */
157
+ url?: string;
158
+ }
159
+
160
+ export interface SimpleMyAsset {
161
+ /**
162
+ * Data type
163
+ */
164
+ ty: 'myAsset';
165
+
166
+ /**
167
+ * List of asset entries
168
+ */
169
+ ast?: Array<SimpleMyAsset.Ast>;
170
+
171
+ /**
172
+ * Asset timestamp (ms)
173
+ */
174
+ asttms?: number;
175
+
176
+ /**
177
+ * Asset unique ID
178
+ */
179
+ astuid?: string;
180
+
181
+ /**
182
+ * Stream type (snapshot or realtime)
183
+ */
184
+ st?: 'SNAPSHOT' | 'REALTIME';
185
+
186
+ /**
187
+ * Timestamp (ms)
188
+ */
189
+ tms?: number;
190
+ }
191
+
192
+ export namespace SimpleMyAsset {
193
+ /**
194
+ * Asset entry
195
+ */
196
+ export interface Ast {
197
+ /**
198
+ * Available balance
199
+ */
200
+ b?: string;
201
+
202
+ /**
203
+ * Currency code (uppercase)
204
+ */
205
+ cu?: string;
206
+
207
+ /**
208
+ * Balance locked in open orders
209
+ */
210
+ l?: string;
211
+ }
212
+ }
213
+
214
+ export interface SimpleMyOrder {
215
+ /**
216
+ * Data type
217
+ */
218
+ ty: 'myOrder';
219
+
220
+ /**
221
+ * User-defined lookup value. Only provided for orders created after 2024-10-18.
222
+ */
223
+ id?: string | null;
224
+
225
+ /**
226
+ * Ask/bid side
227
+ */
228
+ ab?: 'ASK' | 'BID';
229
+
230
+ /**
231
+ * Average execution price
232
+ */
233
+ ap?: string;
234
+
235
+ /**
236
+ * Market code
237
+ */
238
+ cd?: string;
239
+
240
+ /**
241
+ * Executed trade value
242
+ */
243
+ ef?: string;
244
+
245
+ /**
246
+ * Executed quantity
247
+ */
248
+ ev?: string;
249
+
250
+ /**
251
+ * Whether the executed order is a maker order. Null when state is not trade.
252
+ */
253
+ im?: boolean | null;
254
+
255
+ /**
256
+ * Amount locked for this trade
257
+ */
258
+ l?: string;
259
+
260
+ /**
261
+ * Order type
262
+ */
263
+ ot?: 'limit' | 'price' | 'market' | 'best';
264
+
265
+ /**
266
+ * Order timestamp (ms)
267
+ */
268
+ otms?: number;
269
+
270
+ /**
271
+ * Order price. When state=trade, this is the execution price.
272
+ */
273
+ p?: string;
274
+
275
+ /**
276
+ * Fee already paid
277
+ */
278
+ pf?: string;
279
+
280
+ /**
281
+ * Amount (buy) or quantity (sell) cancelled by self-match prevention
282
+ */
283
+ pl?: string | null;
284
+
285
+ /**
286
+ * Order quantity cancelled by self-match prevention
287
+ */
288
+ pv?: string | null;
289
+
290
+ /**
291
+ * Remaining fee
292
+ */
293
+ rmf?: string;
294
+
295
+ /**
296
+ * Fee reserved for this order
297
+ */
298
+ rsf?: string;
299
+
300
+ /**
301
+ * Remaining order quantity after execution
302
+ */
303
+ rv?: string;
304
+
305
+ /**
306
+ * Order status
307
+ */
308
+ s?: 'wait' | 'watch' | 'trade' | 'done' | 'cancel' | 'prevented';
309
+
310
+ /**
311
+ * Self-match prevention type
312
+ */
313
+ smpt?: 'reduce' | 'cancel_maker' | 'cancel_taker' | null;
314
+
315
+ /**
316
+ * Stream type (snapshot or realtime)
317
+ */
318
+ st?: 'SNAPSHOT' | 'REALTIME';
319
+
320
+ /**
321
+ * Number of executions for this order
322
+ */
323
+ tc?: number;
324
+
325
+ /**
326
+ * Fee incurred on execution. Null when state is not trade.
327
+ */
328
+ tf?: string | null;
329
+
330
+ /**
331
+ * IOC/FOK/POST ONLY order condition
332
+ */
333
+ tif?: 'ioc' | 'fok' | 'post_only' | null;
334
+
335
+ /**
336
+ * Timestamp (ms)
337
+ */
338
+ tms?: number;
339
+
340
+ /**
341
+ * Trade timestamp (ms)
342
+ */
343
+ ttms?: number | null;
344
+
345
+ /**
346
+ * Trade unique ID
347
+ */
348
+ tuid?: string | null;
349
+
350
+ /**
351
+ * Order unique ID
352
+ */
353
+ uid?: string;
354
+
355
+ /**
356
+ * Order quantity. When state=trade, this is the executed quantity.
357
+ */
358
+ v?: string;
359
+ }
360
+
361
+ export type SimplePrivateServerEvent = SimpleAnnouncement | SimpleMyOrder | SimpleMyAsset;
362
+
363
+ export type ConnectPrivateClientEvent = Array<
364
+ | ConnectPrivateClientEvent.WsTicketField
365
+ | ConnectPrivateClientEvent.WsAnnouncementTypeField
366
+ | ConnectPrivateClientEvent.WsMyOrderTypeField
367
+ | ConnectPrivateClientEvent.WsMyAssetTypeField
368
+ | ConnectPrivateClientEvent.WsFormatField
369
+ >;
20
370
 
21
371
  export namespace ConnectPrivateClientEvent {
22
372
  /**
@@ -29,6 +379,44 @@ export namespace ConnectPrivateClientEvent {
29
379
  ticket: string;
30
380
  }
31
381
 
382
+ /**
383
+ * Announcement subscription type field
384
+ */
385
+ export interface WsAnnouncementTypeField {
386
+ type: 'announcement';
387
+
388
+ /**
389
+ * Announcement categories to receive. Omit this field to receive announcements
390
+ * from all categories.
391
+ */
392
+ categories?: Array<WsPrivateAPI.AnnouncementCategory>;
393
+
394
+ /**
395
+ * Whether to include the announcement body in stream messages
396
+ */
397
+ include_body?: boolean;
398
+ }
399
+
400
+ /**
401
+ * Response format specifier field
402
+ */
403
+ export interface WsFormatField {
404
+ /**
405
+ * Response format selector
406
+ */
407
+ format?: 'DEFAULT' | 'SIMPLE' | 'JSON_LIST' | 'SIMPLE_LIST';
408
+ }
409
+
410
+ /**
411
+ * Ticket field that identifies the requester
412
+ */
413
+ export interface WsTicketField {
414
+ /**
415
+ * A value that uniquely identifies the requester (UUID recommended)
416
+ */
417
+ ticket: string;
418
+ }
419
+
32
420
  /**
33
421
  * MyOrder subscription type field
34
422
  */
@@ -59,11 +447,10 @@ export namespace ConnectPrivateClientEvent {
59
447
  }
60
448
  }
61
449
 
62
- /**
63
- * WebSocket private server event — stream message received from server (JWT
64
- * required)
65
- */
66
- export type ConnectPrivateServerEvent = ConnectPrivateServerEvent.MyOrder | ConnectPrivateServerEvent.MyAsset;
450
+ export type ConnectPrivateServerEvent =
451
+ | Announcement
452
+ | ConnectPrivateServerEvent.MyOrder
453
+ | ConnectPrivateServerEvent.MyAsset;
67
454
 
68
455
  export namespace ConnectPrivateServerEvent {
69
456
  /**
@@ -276,7 +663,22 @@ export namespace ConnectPrivateServerEvent {
276
663
 
277
664
  export declare namespace WsPrivate {
278
665
  export {
666
+ type Announcement as Announcement,
667
+ type AnnouncementCategory as AnnouncementCategory,
668
+ type AnnouncementEventType as AnnouncementEventType,
669
+ type SimpleAnnouncement as SimpleAnnouncement,
670
+ type SimpleMyAsset as SimpleMyAsset,
671
+ type SimpleMyOrder as SimpleMyOrder,
672
+ type SimplePrivateServerEvent as SimplePrivateServerEvent,
279
673
  type ConnectPrivateClientEvent as ConnectPrivateClientEvent,
674
+ type ConnectPrivateServerMessage as ConnectPrivateServerMessage,
280
675
  type ConnectPrivateServerEvent as ConnectPrivateServerEvent,
281
676
  };
282
677
  }
678
+
679
+ export type ConnectPrivateServerMessage =
680
+ | WebSocketMessage<ConnectPrivateServerEvent | SimplePrivateServerEvent>
681
+ | WsListSubscriptionsResponse
682
+ | Array<
683
+ WebSocketMessage<ConnectPrivateServerEvent | SimplePrivateServerEvent> | WsListSubscriptionsResponse
684
+ >;
@@ -3,10 +3,10 @@ import { WsPrivateEmitter, WsPrivateStreamMessage, WebSocketError, buildURL } fr
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 WsPrivateAPI from './ws-private';
7
- import { Upbit } from '../../client';
8
- import { jsonParseFloat } from '../../lib/jsonParseFloat';
6
+ import type * as WsPrivateAPI from './ws-private';
7
+ import type { Upbit } from '../../client';
9
8
  import { createJwtToken } from '../../lib/jwtAuth';
9
+ import { isRecord, parseWebSocketValue } from '../../internal/ws-parser';
10
10
 
11
11
  export interface WsPrivateWSReconnectOptions {
12
12
  /**
@@ -69,7 +69,7 @@ export class WsPrivateWS extends WsPrivateEmitter {
69
69
  ) {
70
70
  super();
71
71
  this._client = client;
72
- this._parameters = undefined;
72
+ this._parameters = parameters;
73
73
  const { reconnect, ...wsOptions } = options ?? {};
74
74
  this._wsOptions = wsOptions;
75
75
  this._reconnectOptions = reconnect ?? null;
@@ -147,7 +147,7 @@ export class WsPrivateWS extends WsPrivateEmitter {
147
147
  push({ type: 'message', message: event });
148
148
  };
149
149
 
150
- // All errors (API + socket) funnel through _onError → 'error' event
150
+ // Connection and transport errors funnel through _onError → 'error' event
151
151
  const onEmitterError = (err: WebSocketError) => {
152
152
  push({ type: 'error', error: err });
153
153
  };
@@ -272,27 +272,20 @@ export class WsPrivateWS extends WsPrivateEmitter {
272
272
 
273
273
  const socket = new WS.WebSocket(this.url, {
274
274
  ...this._wsOptions,
275
- headers: {
276
- ...this._authHeaders(),
277
- ...this._wsOptions?.headers,
278
- },
275
+ headers: this._client._buildWebSocketHandshakeHeaders(this._authHeaders(), this._wsOptions?.headers),
279
276
  });
280
277
 
281
278
  socket.on('message', (wsEvent) => {
282
- const event = (() => {
283
- try {
284
- return jsonParseFloat(wsEvent.toString()) as WsPrivateAPI.ConnectPrivateServerEvent;
285
- } catch (err) {
286
- this._onError(null, 'could not parse websocket event', err);
287
- return null;
288
- }
289
- })();
290
-
291
- if (event) {
292
- this._emit('event', event);
293
-
294
- // @ts-ignore TS isn't smart enough to get the relationship right here
295
- this._emit(event.type, event);
279
+ let event: unknown;
280
+ try {
281
+ event = parseWebSocketValue(wsEvent.toString());
282
+ } catch (error) {
283
+ this._onError(null, 'could not parse WebSocket message', new SyntaxError('Invalid WebSocket JSON'));
284
+ return;
285
+ }
286
+ this._emit('event', event as WsPrivateAPI.ConnectPrivateServerEvent);
287
+ if (isRecord(event) && typeof event['type'] === 'string') {
288
+ this._emit(event['type'] as any, event as any);
296
289
  }
297
290
  });
298
291
 
@@ -1,2 +1,17 @@
1
- export { WsPublic, type ConnectPublicClientEvent, type ConnectPublicServerEvent } from './ws-public';
1
+ export {
2
+ WsPublic,
3
+ type ConnectPublicClientEvent,
4
+ type ConnectPublicServerEvent,
5
+ type ListSubscriptionsResponse,
6
+ type ListSubscriptionsServerResponse,
7
+ type SimpleListSubscriptionsResponse,
8
+ } from './ws-public';
2
9
  export { type WsPublicWSClientOptions, type WsPublicWSReconnectOptions } from './ws';
10
+
11
+ export type { SimplePublicServerEvent } from '../../internal/ws-simple-types';
12
+ export type {
13
+ SimpleTicker,
14
+ SimpleTrade,
15
+ SimpleOrderbook,
16
+ SimpleCandle,
17
+ } from '../../internal/ws-simple-types';
@@ -5,7 +5,6 @@ import { UpbitError } from '../../core/error';
5
5
  import { stringifyQuery } from '../../internal/utils';
6
6
 
7
7
  import type { ReconnectingEvent } from '../../internal/ws';
8
-
9
8
  export type WsPublicStreamMessage =
10
9
  | { type: 'connecting' | 'open' | 'closing' | 'close' }
11
10
  | { type: 'reconnecting'; reconnect: ReconnectingEvent }