bfx-api-node-rest
Advanced tools
Comparing version 1.1.4 to 2.0.0
236
lib/rest2.js
@@ -8,3 +8,3 @@ 'use strict' | ||
const { URLSearchParams } = require('url') | ||
const { genAuthSig, nonce, isClass } = require('bfx-api-node-util') | ||
const { genAuthSig, nonce, isClass, takeResNotifyInfo } = require('bfx-api-node-util') | ||
const { | ||
@@ -33,3 +33,4 @@ FundingCredit, | ||
Currency, | ||
StatusMessagesDeriv | ||
StatusMessagesDeriv, | ||
Notification | ||
} = require('bfx-api-node-models') | ||
@@ -234,6 +235,6 @@ | ||
if (Array.isArray(data[0])) { | ||
return data.map(row => new ModelClass(row)) | ||
return data.map(row => new ModelClass(row, this)) | ||
} | ||
return new ModelClass(data) | ||
return new ModelClass(data, this) | ||
} | ||
@@ -1003,70 +1004,2 @@ | ||
/** | ||
* Request a deposit address | ||
* | ||
* @param {Object} params | ||
* @param {string} params.request | ||
* @param {string} params.nonce | ||
* @param {string} params.method - name of currency | ||
* @param {string} params.wallet_name - 'trading', 'exchange' or 'deposit' | ||
* @param {number} params.renew - 1 or 0 | ||
* @param {Method} cb | ||
* @return {Promise} p | ||
* @deprecated | ||
* @see https://docs.bitfinex.com/v1/reference#rest-auth-deposit | ||
*/ | ||
deposit (params, cb) { | ||
return this._makeAuthLegacyRequest('deposit/new', params, cb) | ||
} | ||
/** | ||
* Requests a withdrawl from a wallet | ||
* | ||
* @param {Object} params | ||
* @param {string} params.withdraw_type - name of currency | ||
* @param {string} params.walletselected - 'trading', 'exchange, or 'deposit' | ||
* @param {string} params.amount | ||
* @param {string} params.address | ||
* @param {string} params.payment_id - optional, for monero | ||
* @param {string} params.account_name | ||
* @param {string} params.account_number | ||
* @param {string} params.swift | ||
* @param {string} params.bank_name | ||
* @param {string} params.bank_address | ||
* @param {string} params.bank_city | ||
* @param {string} params.bank_country | ||
* @param {string} params.detail_payment - message to beneficiary | ||
* @param {number} params.expressWire - 1 or 0 | ||
* @param {string} params.intermediary_bank_name | ||
* @param {string} params.intermediary_bank_address | ||
* @param {string} params.intermediary_bank_city | ||
* @param {string} params.intermediary_bank_country | ||
* @param {string} params.intermediary_bank_account | ||
* @param {string} params.intermediary_bank_swift | ||
* @param {Method} cb | ||
* @return {Promise} p | ||
* @deprecated | ||
* @see https://docs.bitfinex.com/v1/reference#rest-auth-withdrawal | ||
*/ | ||
withdraw (params, cb) { | ||
return this._makeAuthLegacyRequest('withdraw', params, cb) | ||
} | ||
/** | ||
* Execute a balance transfer between wallets | ||
* | ||
* @param {Object} params | ||
* @param {number} params.amount - amount to transfer | ||
* @param {string} params.currency - currency of funds to transfer | ||
* @param {string} params.walletFrom - wallet to transfer from | ||
* @param {string} params.walletTo - wallet to transfer to | ||
* @param {Method} cb | ||
* @return {Promise} p | ||
* @deprecated | ||
* @see https://docs.bitfinex.com/v1/reference#rest-auth-transfer-between-wallets | ||
*/ | ||
transfer (params, cb) { | ||
return this.make_request('transfer', params, cb) | ||
} | ||
/** | ||
* Fetch the permissions of the key being used to generate this request | ||
@@ -1098,18 +1031,5 @@ * | ||
* @param {number} params.position_id | ||
* @param {number} params.amount | ||
* @param {Method} cb | ||
* @return {Promise} p | ||
* @deprecated | ||
* @see https://docs.bitfinex.com/v1/reference#rest-auth-claim-position | ||
*/ | ||
claimPosition (params, cb) { | ||
return this._makeAuthLegacyRequest('positions/claim', params, cb) | ||
} | ||
/** | ||
* @param {Object} params | ||
* @param {number} params.position_id | ||
* @param {Method} cb | ||
* @return {Promise} p | ||
* @deprecated | ||
* @see https://docs.bitfinex.com/v1/reference#rest-auth-close-position | ||
@@ -1175,4 +1095,150 @@ */ | ||
} | ||
/** | ||
* Submit new order | ||
* | ||
* @param {Order} order - models.Order | ||
* @param {Method} cb | ||
*/ | ||
submitOrder (order, cb) { | ||
return this._makeAuthRequest('/auth/w/order/submit', order.toNewOrderPacket(), cb) | ||
.then((res) => { | ||
// 2 orders can be returned if OCO was used. But due to the interface | ||
// we can only return one. User should use getOrders instead | ||
return takeResNotifyInfo(res)[0] || [] | ||
}) | ||
} | ||
/** | ||
* Update existing order | ||
* | ||
* @param {Objet} order - updates to order | ||
* @param {Method} cb | ||
*/ | ||
updateOrder (changes, cb) { | ||
return this._makeAuthRequest('/auth/w/order/update', changes, cb) | ||
.then(takeResNotifyInfo) | ||
} | ||
/** | ||
* Cancel existing order | ||
* | ||
* @param {int} id - order id | ||
* @param {Method} cb | ||
*/ | ||
cancelOrder (id, cb) { | ||
return this._makeAuthRequest('/auth/w/order/cancel', { id }, cb) | ||
.then(takeResNotifyInfo) | ||
} | ||
submitOrderMulti () { | ||
return Promise.reject(new Error('Not implemented - requires work on WS as well')) | ||
} | ||
/** | ||
* Claim existing open position | ||
* | ||
* @param {int} id - position id | ||
* @param {Method} cb | ||
*/ | ||
claimPosition (id, cb) { | ||
return this._makeAuthRequest('/auth/w/position/claim', { id }, cb) | ||
.then(takeResNotifyInfo) | ||
} | ||
/** | ||
* Submit new funding offer | ||
* | ||
* @param {Object} offer - models.Offer | ||
* @param {Method} cb | ||
*/ | ||
submitFundingOffer (offer, cb) { | ||
return this._makeAuthRequest('/auth/w/funding/offer/submit', offer.toNewOfferPacket(), cb) | ||
.then(takeResNotifyInfo) | ||
} | ||
/** | ||
* Cancel existing funding offer | ||
* | ||
* @param {int} id - offer id | ||
* @param {Method} cb | ||
*/ | ||
cancelFundingOffer (id, cb) { | ||
return this._makeAuthRequest('/auth/w/funding/offer/cancel', { id }, cb) | ||
.then(takeResNotifyInfo) | ||
} | ||
/** | ||
* Close funding | ||
* | ||
* @param {Object} params | ||
* @param {int} param.id - funding id | ||
* @param {string} param.type - funding type LIMIT | FRRDELTAVAR | ||
* @param {*} cb | ||
*/ | ||
closeFunding (params, cb) { | ||
return this._makeAuthRequest('/auth/w/funding/close', params, cb) | ||
.then(takeResNotifyInfo) | ||
} | ||
/** | ||
* Submit automatic funding | ||
* | ||
* @param {Object} params | ||
* @param {int} params.status | ||
* @param {string} params.currency - currency i.e fUSD | ||
* @param {number} params.amount - amount to borrow/lend | ||
* @param {number} params.rate - if == 0 then FRR is used | ||
* @param {int} params.period - time the offer remains locked in for | ||
* @param {*} cb | ||
*/ | ||
submitAutoFunding (params, cb) { | ||
return this._makeAuthRequest('/auth/w/funding/auto', params, cb) | ||
.then(takeResNotifyInfo) | ||
} | ||
/** | ||
* Execute a balance transfer between wallets | ||
* | ||
* @param {number} params.amount - amount to transfer | ||
* @param {string} params.from - wallet from | ||
* @param {string} params.to - wallet to | ||
* @param {string} params.currency - currency from | ||
* @param {string} params.currencyTo - currency to | ||
* @param {Method} cb | ||
* @return {Promise} p | ||
*/ | ||
transfer (params, cb) { | ||
params.currency_to = params.currencyTo | ||
return this._makeAuthRequest('/auth/w/funding/auto', params, cb) | ||
.then(takeResNotifyInfo) | ||
} | ||
/** | ||
* @param {Object} params | ||
* @param {string} wallet - wallet i.e exchange, margin | ||
* @param {string} method - protocol method i.e bitcoin, tetherus | ||
* @param {int} opRenew - if 1 then generates a new address | ||
* @param {*} cb | ||
*/ | ||
getDepositAddress (params, cb) { | ||
params.op_renew = params.opRenew | ||
return this._makeAuthRequest('/auth/w/deposit/address', params, cb) | ||
.then(takeResNotifyInfo) | ||
} | ||
/** | ||
* @param {object} params | ||
* @param {string} wallet - wallet i.e exchange, margin | ||
* @param {string} method - protocol method i.e bitcoin, tetherus | ||
* @param {number} amount - amount to withdraw | ||
* @param {string} address - destination address | ||
* @param {*} cb | ||
*/ | ||
withdraw (params, cb) { | ||
return this._makeAuthRequest('/v2/auth/w/withdraw', params, cb) | ||
.then(takeResNotifyInfo) | ||
} | ||
} | ||
module.exports = RESTv2 |
{ | ||
"name": "bfx-api-node-rest", | ||
"version": "1.1.4", | ||
"version": "2.0.0", | ||
"description": "Official Bitfinex REST v1 & v2 API interfaces", | ||
@@ -54,4 +54,4 @@ "engines": { | ||
"dependencies": { | ||
"bfx-api-node-models": "git+http://github.com/bitfinexcom/bfx-api-node-models.git#semver:^1.0.12", | ||
"bfx-api-node-util": "git+http://github.com/bitfinexcom/bfx-api-node-util.git#semver:^1.0.2", | ||
"bfx-api-node-models": "git+http://github.com/bitfinexcom/bfx-api-node-models.git#semver:^1.1.0", | ||
"bfx-api-node-util": "git+http://github.com/bitfinexcom/bfx-api-node-util.git#semver:^1.0.4", | ||
"bluebird": "^3.5.5", | ||
@@ -58,0 +58,0 @@ "copy": "^0.3.2", |
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 2 instances in 1 package
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 2 instances in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
123008
2240
4