UNPKG

bitmart-api

Version:

Complete & robust Node.js SDK for BitMart's REST APIs and WebSockets, with TypeScript declarations.

65 lines 2.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WS_ERROR_ENUM = exports.WS_BASE_URL_MAP = exports.WS_KEY_MAP = void 0; exports.neverGuard = neverGuard; exports.safeTerminateWs = safeTerminateWs; /** Should be one WS key per unique URL */ exports.WS_KEY_MAP = { spotPublicV1: 'spotPublicV1', spotPrivateV1: 'spotPrivateV1', futuresPublicV1: 'futuresPublicV1', futuresPrivateV1: 'futuresPrivateV1', futuresPublicV2: 'futuresPublicV2', futuresPrivateV2: 'futuresPrivateV2', }; exports.WS_BASE_URL_MAP = { spotPublicV1: { livenet: 'wss://ws-manager-compress.bitmart.com/api?protocol=1.1', demo: undefined, }, spotPrivateV1: { livenet: 'wss://ws-manager-compress.bitmart.com/user?protocol=1.1', demo: undefined, }, futuresPublicV1: { livenet: 'wss://openapi-ws.bitmart.com/api?protocol=1.1', demo: undefined, }, futuresPrivateV1: { livenet: 'wss://openapi-ws.bitmart.com/user?protocol=1.1', demo: undefined, }, futuresPublicV2: { livenet: 'wss://openapi-ws-v2.bitmart.com/api?protocol=1.1', demo: 'wss://openapi-wsdemo-v2.bitmart.com/api?protocol=1.1', }, futuresPrivateV2: { livenet: 'wss://openapi-ws-v2.bitmart.com/user?protocol=1.1', demo: 'wss://openapi-wsdemo-v2.bitmart.com/user?protocol=1.1', }, }; exports.WS_ERROR_ENUM = { INVALID_ACCESS_KEY: 'todo:', }; function neverGuard(x, msg) { return new Error(`Unhandled value exception "${x}", ${msg}`); } /** * ws.terminate() is undefined in browsers. * This only works in node.js, not in browsers. * Does nothing if `ws` is undefined. Does nothing in browsers. */ function safeTerminateWs(ws, fallbackToClose) { if (!ws) { return false; } if (typeof ws['terminate'] === 'function') { ws.terminate(); return true; } else if (fallbackToClose) { ws.close(); } return false; } //# sourceMappingURL=websocket-util.js.map