Merge pull request #8 from AAVikings/develop

KeyVault Module Integration
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2018-10-04 22:16:07 +02:00
commit bd2e7816a8
9 files changed
+334 -135

No files matched your search

+24 -6
View File
@@ -28,9 +28,12 @@
function getTicker(pMarket, callBackFunction) {
let authToken = window.localStorage.getItem('auth0Token');
let path = "ExchangeAPI" + "/"
+ CURRENT_BOT_CODE_NAME + "/"
+ "getTicker" + "/"
+ window.SESSION_TOKEN
+ authToken
;
callServer(undefined, path + "/NO-LOG", onServerResponse);
@@ -46,9 +49,12 @@
function getOpenPositions(pMarket, callBackFunction) {
let authToken = window.localStorage.getItem('auth0Token');
let path = "ExchangeAPI" + "/"
+ CURRENT_BOT_CODE_NAME + "/"
+ "getOpenPositions" + "/"
+ window.SESSION_TOKEN
+ authToken
;
callServer(undefined, path + "/NO-LOG", onServerResponse);
@@ -64,9 +70,12 @@
function getExecutedTrades(pPositionId, callBackFunction) {
let authToken = window.localStorage.getItem('auth0Token');
let path = "ExchangeAPI" + "/"
+ CURRENT_BOT_CODE_NAME + "/"
+ "getExecutedTrades" + "/"
+ window.SESSION_TOKEN + "/"
+ authToken + "/"
+ pPositionId
;
@@ -83,9 +92,12 @@
function putPosition(pMarket, pType, pRate, pAmountA, pAmountB, callBackFunction) {
let authToken = window.localStorage.getItem('auth0Token');
let path = "ExchangeAPI" + "/"
+ CURRENT_BOT_CODE_NAME + "/"
+ "putPosition" + "/"
+ window.SESSION_TOKEN + "/"
+ authToken + "/"
+ pType + "/"
+ pRate + "/"
+ pAmountA + "/"
@@ -105,9 +117,12 @@
function movePosition(pPositionId, pNewRate, pPositionAmountB, callBackFunction) {
let authToken = window.localStorage.getItem('auth0Token');
let path = "ExchangeAPI" + "/"
+ CURRENT_BOT_CODE_NAME + "/"
+ "movePosition" + "/"
+ window.SESSION_TOKEN + "/"
+ authToken + "/"
+ pPositionId + "/"
+ pNewRate + "/"
+ pPositionAmountB
@@ -126,9 +141,12 @@
function getPublicTradeHistory(pMarket, startTime, endTime, callBackFunction) {
let authToken = window.localStorage.getItem('auth0Token');
let path = "ExchangeAPI" + "/"
+ CURRENT_BOT_CODE_NAME + "/"
+ "getPublicTradeHistory" + "/"
+ window.SESSION_TOKEN + "/"
+ authToken + "/"
+ startTime + "/"
+ endTime
;
+1
View File
@@ -4,6 +4,7 @@
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<Name>Project</Name>
<RootNamespace>browser</RootNamespace>
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
+60 -4
View File
@@ -1,4 +1,4 @@
exports.newExchangeAPI = function newExchangeAPI() {
exports.newExchangeAPI = function newExchangeAPI(botDisplayName, authToken) {
/*
@@ -7,6 +7,7 @@
*/
const _ = require('lodash');
const isValidOrder = require('./exchangeUtils').isValidOrder;
const graphqlClient = require('graphql-client')
let MODULE_NAME = "Exchange API";
@@ -31,18 +32,73 @@
if (CONSOLE_LOG === true) { console.log("[INFO] ExchangeAPI -> initialize -> Entering function."); }
let exchange = global.EXCHANGE_NAME.toLowerCase() + 'Client.js';
//TODO From financial beings we get the exchange the bot is trading
let botExchange = 'Poloniex';
let exchange = botExchange.toLowerCase() + 'Client.js';
let api = require('./Wrappers/' + exchange);
apiClient = api.newAPIClient(global.EXCHANGE_KEYS[global.EXCHANGE_NAME].Key, global.EXCHANGE_KEYS[global.EXCHANGE_NAME].Secret);
callBackFunction(global.DEFAULT_OK_RESPONSE);
if (!authToken) {
console.log("[ERROR] Exchange API -> initialize -> User Not Logged In.");
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
} else {
let keyVaultAPI = createKeyVaultAPIClient(authToken)
apiClient = api.newAPIClient(keyVaultAPI);
callBackFunction(global.DEFAULT_OK_RESPONSE);
}
} catch (err) {
console.log("[ERROR] ExchangeAPI -> initialize -> err = " + err.message);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
function createKeyVaultAPIClient(authToken) {
if (CONSOLE_LOG === true) { console.log("[INFO] createKeyVaultAPIClient -> Entering function."); }
const keyVaultAPI = graphqlClient({
url: 'https://keyvault-api.advancedalgos.net/graphql',
headers: {
Authorization: 'Bearer ' + authToken
}
});
keyVaultAPI.signTransaction = function (transaction, next) {
let variables = {
botId: botDisplayName,
transaction: transaction
}
keyVaultAPI.query(`
mutation($botId: String, $transaction: String!){
signTransaction(botId: $botId, transaction: $transaction){
key,
signature,
date
}
}`, variables, function (req, res) {
if (res.status === 401) {
next(undefined, 'Error from graphql: Not authorized');
}
}).then(res => {
if (res.errors) {
next(undefined, 'Error from graphql: ' + res.errors);
} else {
let signature = {
Key: res.data.signTransaction.key,
Sign: res.data.signTransaction.signature
}
next(signature)
}
}).catch(error => {
next(undefined, 'Error signing the message on the key vault: ' + error.message);
});
}
if (CONSOLE_LOG === true) { console.log("[INFO] createKeyVaultAPIClient -> Returning graphql client."); }
return keyVaultAPI;
}
/*
* Position Object = {
* id, String
+19 -18
View File
@@ -5,8 +5,7 @@ module.exports = (function () {
'use strict';
// Module dependencies
var crypto = require('crypto'),
request = require('request'),
var request = require('request'),
nonce = require('nonce')();
// Constants
@@ -27,27 +26,18 @@ module.exports = (function () {
}
// Constructor
function Poloniex(key, secret) {
function Poloniex(keyVaultAPI) {
// Generate headers signed by this user's key and secret.
// The secret is encapsulated and never exposed
this._getPrivateHeaders = function (parameters) {
this._getPrivateHeaders = function (parameters, next) {
var paramString, signature;
if (!key || !secret) {
throw 'Poloniex: Error. API key and secret required';
}
// Convert to `arg1=foo&arg2=bar`
paramString = Object.keys(parameters).map(function (param) {
return encodeURIComponent(param) + '=' + encodeURIComponent(parameters[param]);
}).join('&');
signature = crypto.createHmac('sha512', secret).update(paramString).digest('hex');
return {
Key: key,
Sign: signature
};
keyVaultAPI.signTransaction(paramString, next);
};
}
@@ -123,11 +113,22 @@ module.exports = (function () {
options = {
method: 'POST',
url: PRIVATE_API_URL,
form: parameters,
headers: this._getPrivateHeaders(parameters)
form: parameters
};
return this._request(options, callback);
let headers = this._getPrivateHeaders(parameters, next)
let thisObject = this
function next(pHeaders, error) {
if (!error) {
options.headers = pHeaders;
return thisObject._request(options, callback);
} else {
callback(error);
}
}
},
/////
@@ -436,4 +437,4 @@ module.exports = (function () {
Poloniex.prototype.myTradeHistory = Poloniex.prototype.returnTradeHistory;
return Poloniex;
})();
})();
+2 -2
View File
@@ -1,4 +1,4 @@
exports.newAPIClient = function newAPIClient(pKey, pSecret) {
exports.newAPIClient = function newAPIClient(keyVaultAPI) {
/*
/* ATENTION: This Library is used both a the cloud (AACloud) and also at the AAWeb on the server side without any modifications.
@@ -44,7 +44,7 @@
'ETIMEDOUT'
];
let API = new Poloniex(pKey, pSecret);
let API = new Poloniex(keyVaultAPI);
let thisObject = {
getTicker: getTicker,
+7 -22
View File
@@ -21,20 +21,6 @@ function newLogin() {
container.isDraggeable = false;
container.isClickeable = true;
const AUTH0_CLIENT_ID = 'WQTnXt20a0t2WGl64mEcOyP4Ippo37nB';
const AUTH0_DOMAIN = 'advancedalgos.eu.auth0.com';
const LOGIN_URL = "https://" + AUTH0_DOMAIN + "/authorize" +
"?state=" +
"&client_id=" + AUTH0_CLIENT_ID +
"&response_type=id_token" +
"&redirect_uri=" + location.href + "index.html" +
"&scope=openid" +
"&nonce=CALCULATESOMENONCE";
const LOGOUT_URL = "/";
let currentURL;
let currentLabel;
let Auth0;
@@ -46,14 +32,15 @@ function newLogin() {
let parameters = {
domain: 'advancedalgos.eu.auth0.com',
clientID: 'WQTnXt20a0t2WGl64mEcOyP4Ippo37nB',
redirectUri: window.location.href,
clientID: 'WQTnXt20a0t2WGl64mEcOyP4Ippo37nB'
audience: 'https://auth-dev.advancedalgos.net',
};
Auth0 = new auth0.WebAuth(parameters);
userAuthorization = window.location.hash.substr(1); // What comes after the # on the URL.
let sessionToken = window.localStorage.getItem('sessionToken');
if (sessionToken !== null && sessionToken !== "") {
@@ -76,16 +63,11 @@ function newLogin() {
} else {
console.log(userAuthorization);
Auth0.parseHash({ hash: window.location.hash }, function (err, authResult) {
if (err) {
return console.log("Parse Hash Error", err);
}
console.log("Auth0 Error", err);
console.log("Auth0 Result", authResult);
// The contents of authResult depend on which authentication parameters were used.
// It can include the following:
// authResult.accessToken - access token for the API specified by `audience`
@@ -96,6 +78,9 @@ function newLogin() {
let authId = authResult.idTokenPayload.sub;
// We store the token so we can identify the user
window.localStorage.setItem('auth0Token', authResult.accessToken);
/* Now we connect to the users module to get the users alias, first, middle and last names. */
const apolloClient = new Apollo.lib.ApolloClient({
@@ -174,7 +159,7 @@ function newLogin() {
Auth0.authorize({
scope: 'openid profile',
responseType: 'id_token'
responseType: 'token id_token'
});
} else {
+205 -56
View File
@@ -29,9 +29,12 @@
}
},
"asn1": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz",
"integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y="
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz",
"integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==",
"requires": {
"safer-buffer": "2.1.2"
}
},
"assert-plus": {
"version": "1.0.0",
@@ -54,9 +57,9 @@
"integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg="
},
"aws4": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.7.0.tgz",
"integrity": "sha512-32NDda82rhwD9/JBCCkB+MRYDp0oSvlo2IL6rQWA10PQi7tDUM3eqMSltXmY+Oyl/7N3P3qNtAlv7X0d9bI28w=="
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz",
"integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ=="
},
"azure-storage": {
"version": "2.8.2",
@@ -74,12 +77,72 @@
"validator": "9.4.1",
"xml2js": "0.2.8",
"xmlbuilder": "0.4.3"
},
"dependencies": {
"har-validator": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz",
"integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=",
"requires": {
"ajv": "5.5.2",
"har-schema": "2.0.0"
}
},
"oauth-sign": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz",
"integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM="
},
"request": {
"version": "2.83.0",
"resolved": "https://registry.npmjs.org/request/-/request-2.83.0.tgz",
"integrity": "sha512-lR3gD69osqm6EYLk9wB/G1W/laGWjzH90t1vEa2xuxHD5KUrSzp9pUSfTm+YC5Nxt2T8nMPEvKlhbQayU7bgFw==",
"requires": {
"aws-sign2": "0.7.0",
"aws4": "1.8.0",
"caseless": "0.12.0",
"combined-stream": "1.0.7",
"extend": "3.0.2",
"forever-agent": "0.6.1",
"form-data": "2.3.2",
"har-validator": "5.0.3",
"hawk": "6.0.2",
"http-signature": "1.2.0",
"is-typedarray": "1.0.0",
"isstream": "0.1.2",
"json-stringify-safe": "5.0.1",
"mime-types": "2.1.20",
"oauth-sign": "0.8.2",
"performance-now": "2.1.0",
"qs": "6.5.2",
"safe-buffer": "5.1.2",
"stringstream": "0.0.6",
"tough-cookie": "2.3.4",
"tunnel-agent": "0.6.0",
"uuid": "3.2.1"
},
"dependencies": {
"extend": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
"integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g=="
}
}
},
"tough-cookie": {
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz",
"integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==",
"requires": {
"punycode": "1.4.1"
}
}
}
},
"bcrypt-pbkdf": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz",
"integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
"integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=",
"optional": true,
"requires": {
"tweetnacl": "0.14.5"
@@ -114,9 +177,9 @@
"integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ="
},
"combined-stream": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
"integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=",
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz",
"integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==",
"requires": {
"delayed-stream": "1.0.0"
}
@@ -166,12 +229,21 @@
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
},
"ecc-jsbn": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz",
"integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=",
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
"integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=",
"optional": true,
"requires": {
"jsbn": "0.1.1"
"jsbn": "0.1.1",
"safer-buffer": "2.1.2"
}
},
"encoding": {
"version": "0.1.12",
"resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz",
"integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=",
"requires": {
"iconv-lite": "0.4.24"
}
},
"extend": {
@@ -206,7 +278,17 @@
"requires": {
"asynckit": "0.4.0",
"combined-stream": "1.0.6",
"mime-types": "2.1.18"
"mime-types": "2.1.20"
},
"dependencies": {
"combined-stream": {
"version": "1.0.6",
"resolved": "http://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
"integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=",
"requires": {
"delayed-stream": "1.0.0"
}
}
}
},
"getpass": {
@@ -217,15 +299,31 @@
"assert-plus": "1.0.0"
}
},
"graphql": {
"version": "14.0.2",
"resolved": "https://registry.npmjs.org/graphql/-/graphql-14.0.2.tgz",
"integrity": "sha512-gUC4YYsaiSJT1h40krG3J+USGlwhzNTXSb4IOZljn9ag5Tj+RkoXrWp+Kh7WyE3t1NCfab5kzCuxBIvOMERMXw==",
"requires": {
"iterall": "1.2.2"
}
},
"graphql-client": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/graphql-client/-/graphql-client-2.0.1.tgz",
"integrity": "sha512-XXdjUD3mwsBDcUB7g+iXQeRt+3gmIbvA/Yx1nE5aq2RQmaJwiH4hEoYw27AW8cDR90pCrPlHJAb1jJq3zUMbZA==",
"requires": {
"isomorphic-fetch": "2.2.1"
}
},
"har-schema": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz",
"integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI="
},
"har-validator": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz",
"integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=",
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.0.tgz",
"integrity": "sha512-+qnmNjI4OfH2ipQ9VQOw23bBd/ibtfbVdK2fYbY4acTDqKTW/YDp9McimZdDbG8iV9fZizUqQMD5xvriB146TA==",
"requires": {
"ajv": "5.5.2",
"har-schema": "2.0.0"
@@ -263,7 +361,15 @@
"requires": {
"assert-plus": "1.0.0",
"jsprim": "1.4.1",
"sshpk": "1.14.1"
"sshpk": "1.14.2"
}
},
"iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"requires": {
"safer-buffer": "2.1.2"
}
},
"inherits": {
@@ -291,11 +397,25 @@
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
},
"isomorphic-fetch": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz",
"integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=",
"requires": {
"node-fetch": "1.7.3",
"whatwg-fetch": "3.0.0"
}
},
"isstream": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo="
},
"iterall": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/iterall/-/iterall-1.2.2.tgz",
"integrity": "sha512-yynBb1g+RFUPY64fTrFv7nsjRrENBQJaX2UL+2Szc9REFrSNm1rpSXHGzhmAy7a9uv3vlvgBlXnf9RqmPH1/DA=="
},
"jsbn": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
@@ -356,16 +476,16 @@
}
},
"mime-db": {
"version": "1.33.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz",
"integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ=="
"version": "1.36.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.36.0.tgz",
"integrity": "sha512-L+xvyD9MkoYMXb1jAmzI/lWYAxAMCPvIBSWur0PZ5nOf5euahRLVqH//FKW9mWp2lkqUgYiXPgkzfMUFi4zVDw=="
},
"mime-types": {
"version": "2.1.18",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz",
"integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==",
"version": "2.1.20",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.20.tgz",
"integrity": "sha512-HrkrPaP9vGuWbLK1B1FfgAkbqNjIuy4eHlIYnFi7kamZyLLrGlo2mpcx0bBmNpKqBtYtAfGbodDddIgddSJC2A==",
"requires": {
"mime-db": "1.33.0"
"mime-db": "1.36.0"
}
},
"ms": {
@@ -373,15 +493,24 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"node-fetch": {
"version": "1.7.3",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz",
"integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==",
"requires": {
"encoding": "0.1.12",
"is-stream": "1.1.0"
}
},
"nonce": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/nonce/-/nonce-1.0.4.tgz",
"integrity": "sha1-7nMCrejBvvR28wG4yR9cxRpIdhI="
},
"oauth-sign": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz",
"integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM="
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",
"integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ=="
},
"performance-now": {
"version": "2.1.0",
@@ -393,6 +522,11 @@
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz",
"integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M="
},
"psl": {
"version": "1.1.29",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.1.29.tgz",
"integrity": "sha512-AeUmQ0oLN02flVHXWh9sSJF7mcdFq0ppid/JkErufc3hGIV/AMa8Fo9VgDo/cT2jFdOWoFvHp90qqBH54W+gjQ=="
},
"punycode": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
@@ -417,38 +551,41 @@
}
},
"request": {
"version": "2.83.0",
"resolved": "https://registry.npmjs.org/request/-/request-2.83.0.tgz",
"integrity": "sha512-lR3gD69osqm6EYLk9wB/G1W/laGWjzH90t1vEa2xuxHD5KUrSzp9pUSfTm+YC5Nxt2T8nMPEvKlhbQayU7bgFw==",
"version": "2.88.0",
"resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz",
"integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==",
"requires": {
"aws-sign2": "0.7.0",
"aws4": "1.7.0",
"aws4": "1.8.0",
"caseless": "0.12.0",
"combined-stream": "1.0.6",
"extend": "3.0.1",
"combined-stream": "1.0.7",
"extend": "3.0.2",
"forever-agent": "0.6.1",
"form-data": "2.3.2",
"har-validator": "5.0.3",
"hawk": "6.0.2",
"har-validator": "5.1.0",
"http-signature": "1.2.0",
"is-typedarray": "1.0.0",
"isstream": "0.1.2",
"json-stringify-safe": "5.0.1",
"mime-types": "2.1.18",
"oauth-sign": "0.8.2",
"mime-types": "2.1.20",
"oauth-sign": "0.9.0",
"performance-now": "2.1.0",
"qs": "6.5.2",
"safe-buffer": "5.1.2",
"stringstream": "0.0.6",
"tough-cookie": "2.3.4",
"tough-cookie": "2.4.3",
"tunnel-agent": "0.6.0",
"uuid": "3.2.1"
"uuid": "3.3.2"
},
"dependencies": {
"extend": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz",
"integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ="
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
"integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g=="
},
"uuid": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz",
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
}
}
},
@@ -462,6 +599,11 @@
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"sax": {
"version": "0.5.8",
"resolved": "https://registry.npmjs.org/sax/-/sax-0.5.8.tgz",
@@ -476,17 +618,18 @@
}
},
"sshpk": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.1.tgz",
"integrity": "sha1-Ew9Zde3a2WPx1W+SuaxsUfqfg+s=",
"version": "1.14.2",
"resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.2.tgz",
"integrity": "sha1-xvxhZIo9nE52T9P8306hBeSSupg=",
"requires": {
"asn1": "0.2.3",
"asn1": "0.2.4",
"assert-plus": "1.0.0",
"bcrypt-pbkdf": "1.0.1",
"bcrypt-pbkdf": "1.0.2",
"dashdash": "1.14.1",
"ecc-jsbn": "0.1.1",
"ecc-jsbn": "0.1.2",
"getpass": "0.1.7",
"jsbn": "0.1.1",
"safer-buffer": "2.1.2",
"tweetnacl": "0.14.5"
}
},
@@ -501,10 +644,11 @@
"integrity": "sha512-87GEBAkegbBcweToUrdzf3eLhWNg06FJTebl4BVJz/JgWy8CvEr9dRtX5qWphiynMSQlxxi+QqN0z5T32SLlhA=="
},
"tough-cookie": {
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz",
"integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==",
"version": "2.4.3",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz",
"integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==",
"requires": {
"psl": "1.1.29",
"punycode": "1.4.1"
}
},
@@ -557,6 +701,11 @@
"extsprintf": "1.3.0"
}
},
"whatwg-fetch": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz",
"integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q=="
},
"xml2js": {
"version": "0.2.8",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.2.8.tgz",
+3
View File
@@ -10,8 +10,11 @@
"@octokit/rest": "^14.0.9",
"atob": "^2.1.1",
"azure-storage": "^2.8.2",
"graphql": "^14.0.2",
"graphql-client": "^2.0.1",
"lodash": "^4.17.11",
"nonce": "^1.0.4",
"request": "^2.88.0",
"retry": "^0.12.0"
}
}
+13 -27
View File
@@ -728,31 +728,17 @@ function onBrowserRequest(request, response) {
/* We are going to let access the exchange only to authenticated users, that measn that we need the a valid session token. */
let sessionToken = requestParameters[3];
let session = sessionManager.getSession(sessionToken);
if (session !== undefined) {
let exchangeKey = session.exchangeKeys[0].key; // 0 because we only deal with one exchange for now.
let exchangeSecret = session.exchangeKeys[0].secret;
global.EXCHANGE_NAME = "Poloniex";
let botDisplayName = requestParameters[2];
let authToken = requestParameters[4];
if (authToken !== undefined) {
global.MARKET = {
assetA: "USDT",
assetB: "BTC"
};
global.EXCHANGE_KEYS = {
"Poloniex": {
"Key": exchangeKey,
"Secret": exchangeSecret
}
}
const EXCHANGE_API = require('./Server/Exchange/' + 'ExchangeAPI');
let exchangeAPI = EXCHANGE_API.newExchangeAPI();
const EXCHANGE_API = require('./Server/Exchange/ExchangeAPI');
let exchangeAPI = EXCHANGE_API.newExchangeAPI(botDisplayName, authToken);
exchangeAPI.initialize(onInizialized);
@@ -779,7 +765,7 @@ function onBrowserRequest(request, response) {
}
function callExchangeAPIMethod() {
switch (requestParameters[2]) {
switch (requestParameters[3]) {
case "getTicker": {
exchangeAPI.getTicker(global.MARKET, onExchangeResponse);
@@ -792,22 +778,22 @@ function onBrowserRequest(request, response) {
}
case "getExecutedTrades": {
exchangeAPI.getExecutedTrades(requestParameters[4], onExchangeResponse);
exchangeAPI.getExecutedTrades(requestParameters[5], onExchangeResponse);
break;
}
case "putPosition": {
exchangeAPI.putPosition(global.MARKET, requestParameters[4], requestParameters[5], requestParameters[6], requestParameters[7], onExchangeResponse);
exchangeAPI.putPosition(global.MARKET, requestParameters[5], requestParameters[6], requestParameters[7], requestParameters[8], onExchangeResponse);
break;
}
case "movePosition": {
exchangeAPI.moveOrder(requestParameters[4], requestParameters[5], requestParameters[6], onExchangeResponse);
exchangeAPI.moveOrder(requestParameters[5], requestParameters[6], requestParameters[7], onExchangeResponse);
break;
}
case "getPublicTradeHistory": {
exchangeAPI.getPublicTradeHistory(global.MARKET, requestParameters[4], requestParameters[5], requestParameters[6], onExchangeResponse);
exchangeAPI.getPublicTradeHistory(global.MARKET, requestParameters[5], requestParameters[6], requestParameters[7], onExchangeResponse);
break;
}
@@ -823,7 +809,7 @@ function onBrowserRequest(request, response) {
/* Delete these secrets before they get logged. */
requestParameters[3] = "";
requestParameters[4] = "";
if (err.result === global.DEFAULT_OK_RESPONSE.result)
respondWithContent(JSON.stringify(exchangeResponse), response);
else
@@ -837,7 +823,7 @@ function onBrowserRequest(request, response) {
let customResponse = {
result: global.CUSTOM_FAIL_RESPONSE.result,
message: "Your session has expired. Please login again."
message: "You are not logged in."
};
respondWithContent(JSON.stringify(customResponse), response);