@exchanges/binance
Version:
Exchange provider for Binance API
47 lines • 2.51 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.apiSecretCall = void 0;
const utils_1 = require("../utils");
const apiKeyCall_1 = require("./apiKeyCall");
function apiSecretCall(options) {
return __awaiter(this, void 0, void 0, function* () {
if (!options)
throw new TypeError('apiSecretCall options is empty');
if (typeof options !== 'object')
throw new TypeError('apiSecretCall options is not object');
if (!options.host)
throw new TypeError('apiSecretCall options.host is empty');
if (!options.path)
throw new TypeError('apiSecretCall options.path is empty');
if (!options.method)
throw new TypeError('apiSecretCall options.method is empty');
if (!options.apiKey)
throw new Error('apiSecretCall options.apiKey is empty');
if (!options.apiSecret)
throw new Error('apiSecretCall options.apiSecret is empty');
if (!options.getTime)
throw new Error('apiSecretCall options.getTime is empty');
const sendData = Object.assign({}, options.data);
if (!options.noTimestamp) {
const timestamp = yield options.getTime();
Object.assign(sendData, { timestamp }, options.recvWindow ? { recvWindow: options.recvWindow } : undefined);
}
if (!options.noSignature) {
const queryData = (0, utils_1.makeQueryString)(sendData);
const signature = (0, utils_1.createSignature)(options.apiSecret, queryData);
Object.assign(sendData, { signature });
}
return (0, apiKeyCall_1.apiKeyCall)(Object.assign(Object.assign({}, options), { data: sendData }));
});
}
exports.apiSecretCall = apiSecretCall;
//# sourceMappingURL=apiSecretCall.js.map