Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

binance

Package Overview
Dependencies
Maintainers
1
Versions
171
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

binance - npm Package Compare versions

Comparing version 2.0.12 to 2.0.13

4

CHANGELOG.md
# Binance API
## 2.0.13
- Expose time sync offset getter/setter in base client. `getTimeOffset()/setTimeOffest(value)`.
- Add handler to signMessage method, falling back to browser equivalent if method is not a function (react/preact/#141).
## 2.0.12

@@ -4,0 +8,0 @@ - Increase default timeout for websocket pong heartbeats to 7500ms.

@@ -30,2 +30,7 @@ import { AxiosError, AxiosRequestConfig, Method } from 'axios';

};
/**
* Return time sync offset, automatically set if time sync is enabled. A higher offset means system clock is behind server time.
*/
getTimeOffset(): number;
setTimeOffset(value: number): void;
get(endpoint: string, params?: any): GenericAPIResponse;

@@ -32,0 +37,0 @@ getForBaseUrl(endpoint: string, baseUrlKey: BinanceBaseUrlKey, params?: any): GenericAPIResponse<any>;

20

lib/util/BaseRestClient.js

@@ -22,2 +22,3 @@ "use strict";

constructor(baseUrlKey, options = {}, requestOptions = {}) {
this.timeOffset = 0;
this.options = Object.assign({ recvWindow: 5000,

@@ -50,3 +51,2 @@ // how often to sync time drift with binance servers

}
this.timeOffset = null;
this.syncTimePromise = null;

@@ -69,2 +69,11 @@ this.apiLimitTrackers = {

}
/**
* Return time sync offset, automatically set if time sync is enabled. A higher offset means system clock is behind server time.
*/
getTimeOffset() {
return this.timeOffset;
}
setTimeOffset(value) {
this.timeOffset = value;
}
get(endpoint, params) {

@@ -135,5 +144,2 @@ return this._call('GET', endpoint, params);

}
if (this.timeOffset === null) {
yield this.syncTime();
}
params = yield this.signRequest(params);

@@ -218,5 +224,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
const params = Object.assign(Object.assign({}, data), {
// api_key: this.key,
timestamp: Date.now() + (this.timeOffset || 0) });
const params = Object.assign(Object.assign({}, data), { timestamp: Date.now() + (this.timeOffset || 0) });
// Optional, set to 5000 by default. Increase if timestamp/recvWindow errors are seen.

@@ -238,3 +242,3 @@ if (this.options.recvWindow && !params.recvWindow) {

if (this.options.disableTimeSync === true) {
return Promise.resolve(false);
return Promise.resolve();
}

@@ -241,0 +245,0 @@ if (this.syncTimePromise !== null) {

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -14,7 +33,11 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

const crypto_1 = require("crypto");
const browserMethods = __importStar(require("./browser-support"));
function signMessage(message, secret) {
return __awaiter(this, void 0, void 0, function* () {
return crypto_1.createHmac('sha256', secret)
.update(message)
.digest('hex');
if (typeof crypto_1.createHmac === 'function') {
return crypto_1.createHmac('sha256', secret)
.update(message)
.digest('hex');
}
return browserMethods.signMessage(message, secret);
});

@@ -21,0 +44,0 @@ }

{
"name": "binance",
"version": "2.0.12",
"version": "2.0.13",
"description": "Node.js connector for Binance's REST APIs and WebSockets, with TypeScript & integration tests.",

@@ -19,3 +19,3 @@ "main": "lib/index.js",

"pack": "webpack --config webpack/webpack.config.js",
"prepublish": "npm run build:clean",
"prepublishOnly": "npm run build:clean",
"betapublish": "npm publish --tag beta"

@@ -22,0 +22,0 @@ },

@@ -71,3 +71,3 @@ # binance

const API_KEY = 'xxx';
const PRIVATE_KEY = 'yyy';
const API_SECRET = 'yyy';

@@ -96,3 +96,3 @@ const client = new MainClient({

See [spot-client.ts](./src/spot-client.ts) for further information.
See [spot-client.ts](./src/main-client.ts) for further information.

@@ -106,3 +106,3 @@ ### REST USD-M Futures

const API_KEY = 'xxx';
const PRIVATE_KEY = 'yyy';
const API_SECRET = 'yyy';

@@ -140,3 +140,3 @@ const client = new USDMClient({

const API_KEY = 'xxx';
const PRIVATE_KEY = 'yyy';
const API_SECRET = 'yyy';

@@ -143,0 +143,0 @@ // optionally override the logger

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc