New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@binance/connector

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@binance/connector - npm Package Compare versions

Comparing version 2.0.0-rc.3 to 2.0.0-rc.4

2

package.json
{
"name": "@binance/connector",
"version": "2.0.0-rc.3",
"version": "2.0.0-rc.4",
"description": "This is a lightweight library that works as a connector to the Binance public API.",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -52,3 +52,2 @@ # Binance connector in Nodejs

.catch(error => client.logger.error(error))
```

@@ -58,5 +57,26 @@

## RSA Key based Authentication
```javascript
const { Spot } = require('@binance/connector')
const apiKey = ''
const apiSecret = '' // has no effect when RSA private key is provided
// load private key
const privateKey = fs.readFileSync('/Users/john/ssl/private_key_encrypted.pem')
const privateKeyPassphrase = 'password'
const client = new Spot(apiKey, apiSecret, {
privateKey,
privateKeyPassphrase // only used for encrypted key
})
// Get account information
client.account().then(response => client.logger.log(response.data))
```
### Testnet
While `/sapi/*` endpoints don't have testnet environment yet, `/api/*` endpoints can be tested in
While `/sapi/*` endpoints don't have testnet environment yet, `/api/*` endpoints can be tested in
[Spot Testnet](https://testnet.binance.vision/). You can use it by changing the base URL:

@@ -96,3 +116,3 @@

It's easy to set timeout in milliseconds in request. If the request take longer than timeout, the request will be aborted. If it's not set, there will be no timeout.
It's easy to set timeout in milliseconds in request. If the request take longer than timeout, the request will be aborted. If it's not set, there will be no timeout.

@@ -120,4 +140,4 @@ ```javascript

const apiSecret = ''
const client = new Spot(apiKey, apiSecret,
{
const client = new Spot(apiKey, apiSecret,
{
proxy: {

@@ -206,3 +226,3 @@ protocol: 'https',

- Request config - Configuration send to the server, which can include URL, request method and headers.
```

@@ -216,7 +236,7 @@ // client initialization is skipped

client.logger.error(err.response.data) // includes both error code and message
client.logger.error(err.response.config) // includes request's config
client.logger.error(err.response.config) // includes request's config
})
```
- `Server error`

@@ -223,0 +243,0 @@ - This is thrown when server returns `5XX`, it's an issue from server side.

@@ -8,3 +8,3 @@ 'use strict'

constructor (options) {
const { apiKey, apiSecret, baseURL, logger, timeout, proxy, httpsAgent } = options
const { apiKey, apiSecret, baseURL, logger, timeout, proxy, httpsAgent, privateKey, privateKeyPassphrase } = options

@@ -19,2 +19,4 @@ this.apiKey = apiKey

this.logger = logger || defaultLogger
this.privateKey = privateKey || ''
this.privateKeyPassphrase = privateKeyPassphrase || ''
}

@@ -43,7 +45,20 @@

const queryString = buildQueryString({ ...params, timestamp })
const signature = crypto
.createHmac('sha256', this.apiSecret)
.update(queryString)
.digest('hex')
let signature
if (!this.privateKey) {
signature = crypto
.createHmac('sha256', this.apiSecret)
.update(queryString)
.digest('hex')
} else {
signature = crypto
.createSign('RSA-SHA256')
.update(queryString)
.sign({
key: this.privateKey,
passphrase: this.privateKeyPassphrase
}, 'base64')
signature = encodeURIComponent(signature)
}
return createRequest({

@@ -50,0 +65,0 @@ method,

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