@jsnw/kalshi-client 0.0.1

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/dist/index.cjs ADDED
@@ -0,0 +1,672 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let node_crypto = require("node:crypto");
3
+ let zod = require("zod");
4
+ let uuid = require("uuid");
5
+ let ws = require("ws");
6
+ let node_timers_promises = require("node:timers/promises");
7
+ //#region src/request-signer.ts
8
+ var RequestSigner = class {
9
+ privkey;
10
+ /**
11
+ * @param {RequestSignerOptions} options
12
+ */
13
+ constructor(options) {
14
+ this.privkey = options.privateKey;
15
+ }
16
+ /**
17
+ * @param {SignatureParameters} params
18
+ * @return {string}
19
+ */
20
+ getSignature({ timestamp, httpMethod, path }) {
21
+ const text = `${(timestamp instanceof Date ? timestamp.getTime() : timestamp).toString()}${httpMethod.toUpperCase()}${path.split("?")[0].replace(/\/+$/, "")}`;
22
+ const sign = (0, node_crypto.createSign)("RSA-SHA256");
23
+ sign.update(text);
24
+ sign.end();
25
+ return sign.sign({
26
+ key: this.privkey,
27
+ padding: node_crypto.constants.RSA_PKCS1_PSS_PADDING,
28
+ saltLength: node_crypto.constants.RSA_PSS_SALTLEN_DIGEST
29
+ }).toString("base64");
30
+ }
31
+ };
32
+ //#endregion
33
+ //#region src/credentials-provider.ts
34
+ var InMemoryCredentialsProvider = class {
35
+ accessKey;
36
+ privateKey;
37
+ signer;
38
+ /**
39
+ * @param {InMemoryCredentialsProviderOptions} options
40
+ */
41
+ constructor(options) {
42
+ this.accessKey = options.accessKey;
43
+ this.privateKey = options.privateKey;
44
+ this.signer = new RequestSigner({ privateKey: this.privateKey });
45
+ }
46
+ /**
47
+ * @param {string} accessKey
48
+ */
49
+ setAccessKey(accessKey) {
50
+ if (this.accessKey === accessKey) return;
51
+ this.accessKey = accessKey;
52
+ }
53
+ /**
54
+ * @param {string} privateKey
55
+ */
56
+ setPrivateKey(privateKey) {
57
+ if (this.privateKey === privateKey) return;
58
+ this.privateKey = privateKey;
59
+ this.signer = new RequestSigner({ privateKey });
60
+ }
61
+ /**
62
+ * @return {string}
63
+ */
64
+ getAccessKey() {
65
+ return this.accessKey;
66
+ }
67
+ /**
68
+ * @param {SignatureParameters} options
69
+ * @return {string}
70
+ */
71
+ getSignature(options) {
72
+ return this.signer.getSignature(options);
73
+ }
74
+ };
75
+ //#endregion
76
+ //#region src/schemas/primitives.ts
77
+ const primitives$fixedPointSchema = zod.z.string().regex(/^\d{1,14}\.\d{2,8}$/);
78
+ const primitives$orderSideSchema = zod.z.enum(["yes", "no"]);
79
+ const primitives$bookSideSchema = zod.z.enum(["bid", "ask"]);
80
+ const primitives$orderActionSchema = zod.z.enum(["buy", "sell"]);
81
+ //#endregion
82
+ //#region src/schemas/orders.ts
83
+ const orders$orderStatusSchema = zod.z.enum([
84
+ "resting",
85
+ "canceled",
86
+ "executed"
87
+ ]);
88
+ const orders$orderTypeSchema = zod.z.enum(["limit", "market"]);
89
+ const orders$selfTradePreventionTypeSchema = zod.z.enum(["taker_at_cross", "maker"]);
90
+ const orders$orderDetailedSchema = zod.z.object({
91
+ order_id: zod.z.uuid(),
92
+ user_id: zod.z.uuid(),
93
+ subaccount_number: zod.z.number().min(0).max(32).default(0),
94
+ order_group_id: zod.z.uuid().nullable().optional(),
95
+ exchange_index: zod.z.number().min(0).default(0),
96
+ client_order_id: zod.z.string(),
97
+ ticker: zod.z.string(),
98
+ outcome_side: primitives$orderSideSchema,
99
+ book_side: primitives$bookSideSchema,
100
+ type: orders$orderTypeSchema,
101
+ status: orders$orderStatusSchema,
102
+ yes_price_dollars: primitives$fixedPointSchema,
103
+ no_price_dollars: primitives$fixedPointSchema,
104
+ fill_count_fp: primitives$fixedPointSchema,
105
+ remaining_count_fp: primitives$fixedPointSchema,
106
+ initial_count_fp: primitives$fixedPointSchema,
107
+ taker_fill_cost_dollars: primitives$fixedPointSchema,
108
+ maker_fill_cost_dollars: primitives$fixedPointSchema,
109
+ taker_fees_dollars: primitives$fixedPointSchema,
110
+ maker_fees_dollars: primitives$fixedPointSchema,
111
+ self_trade_prevention_type: orders$selfTradePreventionTypeSchema.nullable().optional(),
112
+ cancel_order_on_pause: zod.z.boolean(),
113
+ created_time: zod.z.iso.datetime(),
114
+ expiration_time: zod.z.iso.datetime().nullable().optional(),
115
+ last_update_time: zod.z.iso.datetime().nullable().optional()
116
+ });
117
+ const orders$orderWsSchema = orders$orderDetailedSchema.omit({
118
+ exchange_index: true,
119
+ type: true,
120
+ no_price_dollars: true,
121
+ cancel_order_on_pause: true
122
+ }).extend({
123
+ side: primitives$orderSideSchema,
124
+ created_ts_ms: zod.z.number().positive(),
125
+ last_updated_ts_ms: zod.z.number().positive().optional(),
126
+ expiration_ts_ms: zod.z.number().positive().optional()
127
+ });
128
+ //#endregion
129
+ //#region src/consts.ts
130
+ const KALSHI_WS_URL = {
131
+ "development": "wss://external-api-ws.demo.kalshi.co",
132
+ "production": "wss://external-api-ws.kalshi.com"
133
+ };
134
+ //#endregion
135
+ //#region src/typed-emitter.ts
136
+ var TypedEmitter = class {
137
+ listeners = /* @__PURE__ */ new Map();
138
+ wrappers = /* @__PURE__ */ new WeakMap();
139
+ on(event, listener) {
140
+ if (!this.listeners.has(event)) this.listeners.set(event, /* @__PURE__ */ new Set());
141
+ this.listeners.get(event).add(listener);
142
+ }
143
+ once(event, listener) {
144
+ const wrapper = (...args) => {
145
+ listener(...args);
146
+ this.off(event, listener);
147
+ };
148
+ this.wrappers.set(listener, wrapper);
149
+ this.on(event, wrapper);
150
+ }
151
+ off(event, listener) {
152
+ const originalFn = this.wrappers.get(listener) || listener;
153
+ this.listeners.get(event)?.delete(originalFn);
154
+ this.wrappers.delete(listener);
155
+ }
156
+ emit(event, ...args) {
157
+ this.listeners.get(event)?.forEach((fn) => fn(...args));
158
+ }
159
+ removeListeners(event) {
160
+ this.listeners.delete(event);
161
+ }
162
+ removeAllListeners() {
163
+ this.listeners.clear();
164
+ }
165
+ listenersCount(event) {
166
+ if (event !== void 0) return this.listeners.get(event)?.size || 0;
167
+ let acc = 0;
168
+ for (const set of this.listeners.values()) acc += set.size;
169
+ return acc;
170
+ }
171
+ };
172
+ //#endregion
173
+ //#region src/defer.ts
174
+ /**
175
+ * @template T
176
+ * @return {DeferredPromise<T>}
177
+ */
178
+ function defer() {
179
+ let resolve, reject;
180
+ return {
181
+ promise: new Promise((res, rej) => {
182
+ resolve = res;
183
+ reject = rej;
184
+ }),
185
+ resolve,
186
+ reject
187
+ };
188
+ }
189
+ //#endregion
190
+ //#region src/ws-wrapper/errors.ts
191
+ var WsWrapperError = class extends Error {};
192
+ var NotConnectedError = class extends WsWrapperError {};
193
+ var InvalidStateError = class extends WsWrapperError {};
194
+ //#endregion
195
+ //#region src/random-int.ts
196
+ /**
197
+ * Generates a random integer between min (inclusive) and max (inclusive)
198
+ * @param {number} min - The minimum value (inclusive)
199
+ * @param {number} max - The maximum value (inclusive)
200
+ * @returns {number} A random integer between min and max
201
+ */
202
+ function randomInt(min, max) {
203
+ return Math.floor(Math.random() * (max - min + 1)) + min;
204
+ }
205
+ //#endregion
206
+ //#region src/ws-wrapper/ws-wrapper.ts
207
+ var WsWrapper = class extends TypedEmitter {
208
+ wsAddress;
209
+ agent;
210
+ connectHeaders;
211
+ reconnectStrategy;
212
+ state = "idle";
213
+ openDefer = null;
214
+ closeDefer = null;
215
+ reconnectAbort = null;
216
+ ws = null;
217
+ closeRequested = false;
218
+ reconnectAttempt = 0;
219
+ lastError = null;
220
+ /**
221
+ * @param {WsWrapperOptions} options
222
+ */
223
+ constructor(options) {
224
+ super();
225
+ this.wsAddress = options.address;
226
+ this.agent = options.agent;
227
+ this.connectHeaders = options.headers;
228
+ this.reconnectStrategy = options.reconnect;
229
+ }
230
+ /**
231
+ * @return {Promise<void>}
232
+ */
233
+ open() {
234
+ switch (this.state) {
235
+ case "idle":
236
+ this.state = "connecting";
237
+ this.openDefer = defer();
238
+ this.createWs();
239
+ return this.openDefer.promise;
240
+ case "connecting":
241
+ case "reconnecting": return this.openDefer.promise;
242
+ case "connected": return Promise.resolve();
243
+ case "closing": return Promise.reject(/* @__PURE__ */ new Error("Cannot reopen WS connection while it's still closing"));
244
+ default:
245
+ const _exhaustive = this.state;
246
+ throw new Error(`Unreachable: ${_exhaustive}`);
247
+ }
248
+ }
249
+ /**
250
+ * @param {BufferLike} data
251
+ * @return {Promise<void>}
252
+ */
253
+ send(data) {
254
+ return new Promise((resolve, reject) => {
255
+ if (this.state !== "connected") return reject(new NotConnectedError());
256
+ if (!this.ws) return reject(new InvalidStateError());
257
+ this.ws.send(data, (err) => {
258
+ if (err) return reject(err);
259
+ return resolve();
260
+ });
261
+ });
262
+ }
263
+ /**
264
+ * @return {Promise<void>}
265
+ */
266
+ close() {
267
+ switch (this.state) {
268
+ case "idle": return Promise.resolve();
269
+ case "connected":
270
+ case "connecting":
271
+ case "reconnecting":
272
+ this.state = "closing";
273
+ this.closeRequested = true;
274
+ this.closeDefer = defer();
275
+ this.ws?.close();
276
+ this.reconnectAbort?.abort();
277
+ return this.closeDefer.promise;
278
+ case "closing": return this.closeDefer.promise;
279
+ default:
280
+ const _exhaustive = this.state;
281
+ throw new Error(`Unreachable: ${_exhaustive}`);
282
+ }
283
+ }
284
+ createWs() {
285
+ this.ws = new ws.WebSocket(this.wsAddress, {
286
+ autoPong: true,
287
+ headers: this.getConnectHeaders(),
288
+ agent: this.agent
289
+ });
290
+ this.ws.on("open", this.handleOpen);
291
+ this.ws.on("message", this.handleMessage);
292
+ this.ws.on("error", this.handleError);
293
+ this.ws.on("close", this.handleClose);
294
+ }
295
+ /**
296
+ * @return {Record<string, string>}
297
+ * @private
298
+ */
299
+ getConnectHeaders() {
300
+ if (!this.connectHeaders) return {};
301
+ if (typeof this.connectHeaders === "function") return this.connectHeaders();
302
+ return this.connectHeaders;
303
+ }
304
+ /**
305
+ * @return {number | false}
306
+ * @private
307
+ */
308
+ getReconnectDelay() {
309
+ const attempt = this.reconnectAttempt;
310
+ if (this.closeRequested || !this.reconnectStrategy) return false;
311
+ if (typeof this.reconnectStrategy === "function") return this.reconnectStrategy(attempt);
312
+ if (typeof this.reconnectStrategy === "object") {
313
+ if (attempt > this.reconnectStrategy.maxAttempts) return false;
314
+ if (typeof this.reconnectStrategy.interval === "function") return this.reconnectStrategy.interval(attempt);
315
+ if (typeof this.reconnectStrategy.interval === "number") return this.reconnectStrategy.interval;
316
+ if (typeof this.reconnectStrategy.interval === "object" && !Array.isArray(this.reconnectStrategy.interval)) return randomInt(this.reconnectStrategy.interval.min, this.reconnectStrategy.interval.max);
317
+ if (Array.isArray(this.reconnectStrategy.interval)) {
318
+ if (this.reconnectStrategy.interval.length === 0) return 0;
319
+ else if (this.reconnectStrategy.interval.length === 1) return this.reconnectStrategy.interval[0];
320
+ else if (this.reconnectStrategy.interval.length > 1) return this.reconnectStrategy.interval[(attempt - 1) % this.reconnectStrategy.interval.length];
321
+ }
322
+ }
323
+ return false;
324
+ }
325
+ /**
326
+ * @private
327
+ */
328
+ reset() {
329
+ this.state = "idle";
330
+ this.ws?.removeAllListeners();
331
+ this.openDefer?.reject(this.lastError ?? /* @__PURE__ */ new Error("WS connection closed"));
332
+ this.closeDefer?.resolve();
333
+ this.closeRequested = false;
334
+ this.openDefer = null;
335
+ this.closeDefer = null;
336
+ this.ws = null;
337
+ this.lastError = null;
338
+ this.reconnectAttempt = 0;
339
+ }
340
+ /**
341
+ */
342
+ handleOpen = () => {
343
+ this.state = "connected";
344
+ this.openDefer?.resolve();
345
+ this.openDefer = null;
346
+ const attempt = this.reconnectAttempt;
347
+ this.reconnectAttempt = 0;
348
+ this.emit("ready", attempt > 0);
349
+ };
350
+ /**
351
+ * @param {WebSocket.RawData} data
352
+ * @param {boolean} isBinary
353
+ */
354
+ handleMessage = (data, isBinary) => {
355
+ this.emit("message", data, isBinary);
356
+ };
357
+ /**
358
+ * @param {Error} err
359
+ */
360
+ handleError = (err) => {
361
+ this.lastError = err;
362
+ this.emit("error", err);
363
+ };
364
+ /**
365
+ * @param {number} code
366
+ * @param {Buffer} reason
367
+ */
368
+ handleClose = async (code, reason) => {
369
+ this.reconnectAttempt += 1;
370
+ const reconnectDelay = this.getReconnectDelay();
371
+ if (reconnectDelay !== false) {
372
+ this.state = "reconnecting";
373
+ this.reconnectAbort = new AbortController();
374
+ try {
375
+ await (0, node_timers_promises.setTimeout)(Math.max(1, reconnectDelay), void 0, { signal: this.reconnectAbort.signal });
376
+ } catch (e) {
377
+ this.reset();
378
+ this.emit("close");
379
+ return;
380
+ }
381
+ if (this.state !== "reconnecting") return;
382
+ this.ws?.removeAllListeners();
383
+ this.ws = null;
384
+ this.emit("reconnecting", this.reconnectAttempt);
385
+ this.createWs();
386
+ } else {
387
+ this.reset();
388
+ this.emit("close");
389
+ }
390
+ };
391
+ };
392
+ //#endregion
393
+ //#region src/wait-registry/errors.ts
394
+ var TimeoutError = class extends Error {
395
+ constructor(key) {
396
+ super(`Timed out waiting for key: ${key.toString()}`);
397
+ this.name = "TimeoutError";
398
+ }
399
+ };
400
+ var RegistryClearedError = class extends Error {
401
+ constructor() {
402
+ super("Registry cleared");
403
+ this.name = "RegistryClearedError";
404
+ }
405
+ };
406
+ //#endregion
407
+ //#region src/wait-registry/wait-registry.ts
408
+ var WaitRegistry = class {
409
+ storage = /* @__PURE__ */ new Map();
410
+ add(key, expiresInMs) {
411
+ if (this.storage.has(key)) throw new TypeError(`Key already exists: ${key.toString()}`);
412
+ const deferred = defer();
413
+ const timer = setTimeout(this.rejectOnTimeout.bind(this, key), expiresInMs);
414
+ timer.unref();
415
+ this.storage.set(key, {
416
+ deferred,
417
+ _timer: timer
418
+ });
419
+ return deferred.promise;
420
+ }
421
+ resolve(key, value) {
422
+ const awaiter = this.storage.get(key);
423
+ if (!awaiter) return;
424
+ clearTimeout(awaiter._timer);
425
+ this.storage.delete(key);
426
+ awaiter.deferred.resolve(value);
427
+ }
428
+ reject(key, error) {
429
+ const awaiter = this.storage.get(key);
430
+ if (!awaiter) return;
431
+ clearTimeout(awaiter._timer);
432
+ this.storage.delete(key);
433
+ awaiter.deferred.reject(error);
434
+ }
435
+ clear(passError) {
436
+ const error = passError ?? new RegistryClearedError();
437
+ for (const awaiter of this.storage.values()) {
438
+ clearTimeout(awaiter._timer);
439
+ awaiter.deferred.reject(error);
440
+ }
441
+ this.storage.clear();
442
+ }
443
+ rejectOnTimeout(key) {
444
+ const awaiter = this.storage.get(key);
445
+ if (!awaiter) return;
446
+ this.storage.delete(key);
447
+ clearTimeout(awaiter._timer);
448
+ awaiter.deferred.reject(new TimeoutError(key));
449
+ }
450
+ };
451
+ //#endregion
452
+ //#region src/logging.ts
453
+ const noopLogger = (level, message, context) => {};
454
+ //#endregion
455
+ //#region src/ws/messages.ts
456
+ const wsOkMessageSchema = zod.z.object({
457
+ id: zod.z.number(),
458
+ sid: zod.z.number(),
459
+ type: zod.z.literal("ok"),
460
+ msg: zod.z.any().optional()
461
+ });
462
+ const wsErrorMessageSchema = zod.z.object({
463
+ id: zod.z.number(),
464
+ type: zod.z.literal("error"),
465
+ msg: zod.z.object({
466
+ code: zod.z.number(),
467
+ msg: zod.z.string()
468
+ })
469
+ });
470
+ const wsSubscribedMessageSchema = zod.z.object({
471
+ id: zod.z.number(),
472
+ type: zod.z.literal("subscribed"),
473
+ msg: zod.z.object({
474
+ channel: zod.z.string(),
475
+ sid: zod.z.number()
476
+ })
477
+ });
478
+ const wsUserOrderMessageSchema = zod.z.object({
479
+ sid: zod.z.number().positive(),
480
+ type: zod.z.literal("user_order"),
481
+ msg: orders$orderWsSchema
482
+ });
483
+ const wsAnyMessageSchema = zod.z.discriminatedUnion("type", [
484
+ wsOkMessageSchema,
485
+ wsErrorMessageSchema,
486
+ wsSubscribedMessageSchema,
487
+ wsUserOrderMessageSchema
488
+ ]);
489
+ //#endregion
490
+ //#region src/ws/errors.ts
491
+ var WsKalshiError = class extends Error {
492
+ id;
493
+ code;
494
+ /**
495
+ * @param {number} id
496
+ * @param {number} code
497
+ * @param {string} message
498
+ */
499
+ constructor(id, code, message) {
500
+ super(message);
501
+ this.id = id;
502
+ this.code = code;
503
+ }
504
+ };
505
+ //#endregion
506
+ //#region src/ws/ws-client.ts
507
+ var WsClient = class extends TypedEmitter {
508
+ id;
509
+ baseURL;
510
+ credentialsProvider;
511
+ log;
512
+ ws;
513
+ lastMessageId = 0;
514
+ subscribeAwaiters = new WaitRegistry();
515
+ /**
516
+ * @param {WsClientOptions} options
517
+ */
518
+ constructor(options) {
519
+ super();
520
+ this.id = options.id ?? (0, uuid.v4)();
521
+ this.baseURL = KALSHI_WS_URL[options.environment ?? "development"];
522
+ this.credentialsProvider = options.credentialsProvider;
523
+ this.log = options.log ?? noopLogger;
524
+ const path = "/trade-api/ws/v2", address = `${this.baseURL}${path}`;
525
+ this.ws = new WsWrapper({
526
+ ...options.wsOptions,
527
+ address,
528
+ headers: () => {
529
+ const timestamp = Date.now();
530
+ const signature = this.credentialsProvider.getSignature({
531
+ timestamp,
532
+ httpMethod: "GET",
533
+ path
534
+ });
535
+ return {
536
+ "Content-Type": "application/json",
537
+ "KALSHI-ACCESS-KEY": this.credentialsProvider.getAccessKey(),
538
+ "KALSHI-ACCESS-SIGNATURE": signature,
539
+ "KALSHI-ACCESS-TIMESTAMP": timestamp.toString()
540
+ };
541
+ }
542
+ });
543
+ this.ws.on("ready", this.onReady);
544
+ this.ws.on("message", this.onMessage);
545
+ this.ws.on("error", this.onError);
546
+ this.ws.on("reconnecting", this.onReconnecting);
547
+ this.ws.on("close", this.onClose);
548
+ }
549
+ onReady = async (afterReconnect) => {
550
+ this.log("debug", "WebSocket connection ready", { afterReconnect });
551
+ this.emit("ready");
552
+ };
553
+ /**
554
+ * @param {WebSocket.RawData} data
555
+ * @param {boolean} isBinary
556
+ * @return {Promise<void>}
557
+ */
558
+ onMessage = async (data, isBinary) => {
559
+ if (isBinary) {
560
+ this.log("warn", "invalid incoming message format (=binary)");
561
+ return;
562
+ }
563
+ let jsonData = null;
564
+ try {
565
+ jsonData = JSON.parse(data.toString());
566
+ } catch (e) {
567
+ this.log("warn", "failed to decode incoming message as JSON string");
568
+ return;
569
+ }
570
+ this.log("debug", "incoming message", { message: jsonData });
571
+ const { data: msg, error } = wsAnyMessageSchema.safeParse(jsonData);
572
+ if (error) {
573
+ this.log("warn", "failed to validate message", {
574
+ message: jsonData,
575
+ error
576
+ });
577
+ return;
578
+ }
579
+ this.processMessage(msg);
580
+ };
581
+ /**
582
+ * @param {number} attempt
583
+ */
584
+ onReconnecting = (attempt) => {
585
+ this.log("debug", "reconnecting", { attempt });
586
+ this.emit("reconnect", attempt);
587
+ };
588
+ /**
589
+ * @param {Error} err
590
+ */
591
+ onError = (err) => {
592
+ this.log("error", "WebSocket error", { err });
593
+ };
594
+ /**
595
+ */
596
+ onClose = () => {
597
+ this.log("debug", "WebSocket connection closed");
598
+ this.emit("close");
599
+ this.subscribeAwaiters.clear();
600
+ };
601
+ /**
602
+ * @param {WsAnyMessage} msg
603
+ * @private
604
+ */
605
+ processMessage(msg) {
606
+ switch (msg.type) {
607
+ case "ok":
608
+ this.subscribeAwaiters.resolve(msg.id, true);
609
+ break;
610
+ case "error":
611
+ this.subscribeAwaiters.reject(msg.id, new WsKalshiError(msg.id, msg.msg.code, msg.msg.msg));
612
+ break;
613
+ case "subscribed":
614
+ this.subscribeAwaiters.resolve(msg.id, true);
615
+ break;
616
+ }
617
+ this.emit("message", msg);
618
+ }
619
+ };
620
+ //#endregion
621
+ //#region src/ws/common.ts
622
+ const WS_KALSHI_ERRORS = {
623
+ UNABLE_TO_PROCESS: 1,
624
+ PARAMS_REQUIRED: 2,
625
+ CHANNELS_REQUIRED: 3,
626
+ SUBSCRIPTION_IDS_REQUIRED: 4,
627
+ UNKNOWN_COMMAND: 5,
628
+ ALREADY_SUBSCRIBED: 6,
629
+ UNKNOWN_SUBSCRIPTION_ID: 7,
630
+ UNKNOWN_CHANNEL_NAME: 8,
631
+ AUTHENTICATION_REQUIRED: 9,
632
+ CHANNEL_ERROR: 10,
633
+ INVALID_PARAMETER: 11,
634
+ EXACTLY_ONE_SUBSCRIPTION_ID_IS_REQUIRED: 12,
635
+ UNSUPPORTED_ACTION: 13,
636
+ MARKET_TICKER_REQUIRED: 14,
637
+ ACTION_REQUIRED: 15,
638
+ MARKET_NOT_FOUND: 16,
639
+ INTERNAL_ERROR: 17,
640
+ COMMAND_TIMEOUT: 18,
641
+ SHARD_FACTOR_MUST_BE_GT0: 19,
642
+ SHARD_FACTOR_IS_REQUIRED: 20,
643
+ INVALID_SHARD_KEY: 21,
644
+ SHARD_FACTOR_MUST_BE_LT100: 22,
645
+ SUBSCRIPTION_BUFFER_OVERFLOW: 25
646
+ };
647
+ const WS_KALSHI_SERVER_ERRORS = [
648
+ WS_KALSHI_ERRORS.CHANNEL_ERROR,
649
+ WS_KALSHI_ERRORS.INTERNAL_ERROR,
650
+ WS_KALSHI_ERRORS.COMMAND_TIMEOUT
651
+ ];
652
+ //#endregion
653
+ exports.InMemoryCredentialsProvider = InMemoryCredentialsProvider;
654
+ exports.RequestSigner = RequestSigner;
655
+ exports.WS_KALSHI_ERRORS = WS_KALSHI_ERRORS;
656
+ exports.WS_KALSHI_SERVER_ERRORS = WS_KALSHI_SERVER_ERRORS;
657
+ exports.WsClient = WsClient;
658
+ exports.WsKalshiError = WsKalshiError;
659
+ exports.orders$orderDetailedSchema = orders$orderDetailedSchema;
660
+ exports.orders$orderStatusSchema = orders$orderStatusSchema;
661
+ exports.orders$orderTypeSchema = orders$orderTypeSchema;
662
+ exports.orders$orderWsSchema = orders$orderWsSchema;
663
+ exports.orders$selfTradePreventionTypeSchema = orders$selfTradePreventionTypeSchema;
664
+ exports.primitives$bookSideSchema = primitives$bookSideSchema;
665
+ exports.primitives$fixedPointSchema = primitives$fixedPointSchema;
666
+ exports.primitives$orderActionSchema = primitives$orderActionSchema;
667
+ exports.primitives$orderSideSchema = primitives$orderSideSchema;
668
+ exports.wsAnyMessageSchema = wsAnyMessageSchema;
669
+ exports.wsErrorMessageSchema = wsErrorMessageSchema;
670
+ exports.wsOkMessageSchema = wsOkMessageSchema;
671
+ exports.wsSubscribedMessageSchema = wsSubscribedMessageSchema;
672
+ exports.wsUserOrderMessageSchema = wsUserOrderMessageSchema;