From 1de4002095446719657a1409f46b5e43c1938f80 Mon Sep 17 00:00:00 2001 From: sunkaflek <> Date: Mon, 30 Mar 2020 23:58:45 +0200 Subject: [PATCH 1/5] fix login issues --- src/index.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/index.js b/src/index.js index 93e53ff..f69e47d 100644 --- a/src/index.js +++ b/src/index.js @@ -37,8 +37,8 @@ const create = ({ }; const checkSuccess = res => { - if (res.status !== 0) { - throw Error(res.message); + if (res.errors !== undefined && res.errors !== null) { + throw Error(res.errors[0].text); } return res; }; @@ -268,12 +268,12 @@ const create = ({ }) .then(res => res.json()) .then(res => { - urls.paUrl = res.paUrl; - urls.productSearchUrl = res.productSearchUrl; - urls.productTypesUrl = res.productTypesUrl; - urls.reportingUrl = res.reportingUrl; - urls.tradingUrl = res.tradingUrl; - urls.vwdQuotecastServiceUrl = res.vwdQuotecastServiceUrl; + urls.paUrl = res.data.paUrl; + urls.productSearchUrl = res.data.productSearchUrl; + urls.productTypesUrl = res.data.productTypesUrl; + urls.reportingUrl = res.data.reportingUrl; + urls.tradingUrl = res.data.tradingUrl; + urls.vwdQuotecastServiceUrl = res.data.vwdQuotecastServiceUrl; }); /** @@ -287,8 +287,8 @@ const create = ({ let loginParams = { username, password, + isPassCodeReset: false, isRedirectToMobile: false, - loginButtonUniversal: '', queryParams: {reason: 'session_expired'}, }; @@ -419,7 +419,7 @@ const create = ({ ) .then(res => res.json()) .then(checkSuccess) - .then(json => ({order, confirmationId: json.confirmationId})); + .then(json => ({order, confirmationId: json.data.confirmationId})); }; /** @@ -443,7 +443,7 @@ const create = ({ ) .then(res => res.json()) .then(checkSuccess) - .then(json => ({orderId: json.orderId})); + .then(json => ({orderId: json.data.orderId})); }; /** From 472c229032024ea87408fd9100b99a698477d754 Mon Sep 17 00:00:00 2001 From: sunkaflek <> Date: Tue, 31 Mar 2020 23:52:07 +0200 Subject: [PATCH 2/5] add more data to getAskBidPrice --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index f69e47d..414abd3 100644 --- a/src/index.js +++ b/src/index.js @@ -153,7 +153,7 @@ const create = ({ method: 'POST', headers: {Origin: 'https://trader.degiro.nl'}, body: JSON.stringify({ - controlData: `req(${issueId}.BidPrice);req(${issueId}.AskPrice);req(${issueId}.LastPrice);req(${issueId}.LastTime);`, + controlData: `req(${issueId}.BidPrice);req(${issueId}.AskPrice);req(${issueId}.LastPrice);req(${issueId}.LastTime);req(${issueId}.OpenPrice);req(${issueId}.RelativeDifference);`, }), }) .then(() => fetch(`https://degiro.quotecast.vwdservices.com/CORS/${vwdSession.sessionId}`)) From 731d1b8a00e40847a66f0730028c2a6e10a3002b Mon Sep 17 00:00:00 2001 From: sunkaflek <> Date: Wed, 1 Apr 2020 00:11:51 +0200 Subject: [PATCH 3/5] fake ordinary user-agent, to prevent Degiro spotting automated trading --- src/fetch.js | 9 +++++++++ src/index.js | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 src/fetch.js diff --git a/src/fetch.js b/src/fetch.js new file mode 100644 index 0000000..5a24c7d --- /dev/null +++ b/src/fetch.js @@ -0,0 +1,9 @@ +// fetch.js +//via https://github.com/node-fetch/node-fetch/issues/591#issuecomment-474457866 +const fetch = require('node-fetch') + +module.exports = (url, args = {}) => { + args.headers = args.headers || {} + args.headers['user-agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:74.0) Gecko/20100101 Firefox/74.0' + return fetch(url, args) +} \ No newline at end of file diff --git a/src/index.js b/src/index.js index 414abd3..6059fbf 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,4 @@ -const fetch = require('node-fetch'); +const fetch = require('./fetch.js'); const querystring = require('querystring'); const parseCookies = require('cookie').parse; const {Actions, OrderTypes, TimeTypes, ProductTypes, Sort} = require('./constants'); @@ -153,7 +153,7 @@ const create = ({ method: 'POST', headers: {Origin: 'https://trader.degiro.nl'}, body: JSON.stringify({ - controlData: `req(${issueId}.BidPrice);req(${issueId}.AskPrice);req(${issueId}.LastPrice);req(${issueId}.LastTime);req(${issueId}.OpenPrice);req(${issueId}.RelativeDifference);`, + controlData: `req(${issueId}.BidPrice);req(${issueId}.AskPrice);req(${issueId}.LastPrice);req(${issueId}.LastTime);req(${issueId}.OpenPrice);req(${issueId}.RelativeDifference);req(${issueId}.AbsoluteDifference);`, }), }) .then(() => fetch(`https://degiro.quotecast.vwdservices.com/CORS/${vwdSession.sessionId}`)) From b30d4c919a42d9506918738c0bae2e94f12b34ac Mon Sep 17 00:00:00 2001 From: sunkaflek <> Date: Thu, 9 Apr 2020 15:59:31 +0200 Subject: [PATCH 4/5] add High and Low prices to getAskBid data --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 6059fbf..03e73cb 100644 --- a/src/index.js +++ b/src/index.js @@ -153,7 +153,7 @@ const create = ({ method: 'POST', headers: {Origin: 'https://trader.degiro.nl'}, body: JSON.stringify({ - controlData: `req(${issueId}.BidPrice);req(${issueId}.AskPrice);req(${issueId}.LastPrice);req(${issueId}.LastTime);req(${issueId}.OpenPrice);req(${issueId}.RelativeDifference);req(${issueId}.AbsoluteDifference);`, + controlData: `req(${issueId}.BidPrice);req(${issueId}.AskPrice);req(${issueId}.LastPrice);req(${issueId}.LastTime);req(${issueId}.OpenPrice);req(${issueId}.HighPrice);req(${issueId}.LowPrice);req(${issueId}.RelativeDifference);req(${issueId}.AbsoluteDifference);`, }), }) .then(() => fetch(`https://degiro.quotecast.vwdservices.com/CORS/${vwdSession.sessionId}`)) From f4c2316c901c9fce2f03ee261780da0ca88daffe Mon Sep 17 00:00:00 2001 From: sunkaflek <> Date: Sat, 25 Apr 2020 18:35:23 +0200 Subject: [PATCH 5/5] update user agent --- src/fetch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fetch.js b/src/fetch.js index 5a24c7d..4d9d019 100644 --- a/src/fetch.js +++ b/src/fetch.js @@ -4,6 +4,6 @@ const fetch = require('node-fetch') module.exports = (url, args = {}) => { args.headers = args.headers || {} - args.headers['user-agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:74.0) Gecko/20100101 Firefox/74.0' + args.headers['user-agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:75.0) Gecko/20100101 Firefox/75.0' return fetch(url, args) } \ No newline at end of file