degiro-api
Advanced tools
Comparing version 0.6.5 to 1.0.0
@@ -17,2 +17,3 @@ "use strict"; | ||
username: params.username.toLowerCase().trim(), | ||
oneTimePassword: params.oneTimePassword, | ||
queryParams: { | ||
@@ -35,2 +36,8 @@ reason: 'session_expired', | ||
fetch(BASE_API_URL + LOGIN_URL_PATH, requestOptions) | ||
.then(function (res) { | ||
if (!payload.oneTimePassword) | ||
return res; | ||
utils_1.debug('Sending OTP'); | ||
return fetch(BASE_API_URL + LOGIN_URL_PATH + "/totp", requestOptions); | ||
}) | ||
.then(function (res) { return res.json(); }) | ||
@@ -37,0 +44,0 @@ .then(function (res) { |
@@ -10,2 +10,3 @@ import { DeGiroClassInterface } from './interfaces'; | ||
private readonly pwd; | ||
private readonly oneTimePassword; | ||
private jsessionId; | ||
@@ -12,0 +13,0 @@ private accountConfig; |
@@ -38,5 +38,6 @@ "use strict"; | ||
this.getJSESSIONID = function () { return _this.hasSessionId() ? _this.accountConfig.data.sessionId : undefined; }; | ||
var username = params.username, pwd = params.pwd, jsessionId = params.jsessionId; | ||
var username = params.username, pwd = params.pwd, oneTimePassword = params.oneTimePassword, jsessionId = params.jsessionId; | ||
username = username || process.env['DEGIRO_USER']; | ||
pwd = pwd || process.env['DEGIRO_PWD']; | ||
oneTimePassword = oneTimePassword || process.env['DEGIRO_OTP']; | ||
jsessionId = jsessionId || process.env['DEGIRO_JSESSIONID']; | ||
@@ -49,2 +50,3 @@ if (!username) | ||
this.pwd = pwd; | ||
this.oneTimePassword = oneTimePassword; | ||
this.jsessionId = jsessionId; | ||
@@ -61,3 +63,7 @@ } | ||
return new Promise(function (resolve, reject) { | ||
api_1.loginRequest({ username: _this.username, pwd: _this.pwd }) | ||
api_1.loginRequest({ | ||
username: _this.username, | ||
pwd: _this.pwd, | ||
oneTimePassword: _this.oneTimePassword | ||
}) | ||
.then(function (loginResponse) { | ||
@@ -64,0 +70,0 @@ if (!loginResponse.sessionId) |
export declare type DeGiroSettupType = { | ||
username?: string; | ||
pwd?: string; | ||
oneTimePassword?: string; | ||
jsessionId?: string; | ||
}; | ||
//# sourceMappingURL=DeGiroSettupType.d.ts.map |
@@ -6,2 +6,3 @@ export declare type LoginRequestBodyType = { | ||
username: string; | ||
oneTimePassword: string | undefined; | ||
queryParams: { | ||
@@ -8,0 +9,0 @@ reason: string; |
export declare type LoginRequestParamsType = { | ||
username: string; | ||
pwd: string; | ||
oneTimePassword: string | undefined; | ||
}; | ||
//# sourceMappingURL=LoginRequestParamsType.d.ts.map |
{ | ||
"name": "degiro-api", | ||
"version": "0.6.5", | ||
"version": "1.0.0", | ||
"public": true, | ||
@@ -5,0 +5,0 @@ "description": "Unofficial DeGiro API for Javascript. Buy and sell in the stock market. See your portfolio and much more", |
# DeGiro Trading Broker API | ||
This is an unofficial TypeScript API client (Backend & Frontend) for DeGiro's trading platform. Using this module you can easily automate your orders (buy and sell) and get information about orders, funds or products. | ||
This is an unofficial TypeScript API client (Backend & Frontend) for DeGiro's trading platform. Using this module you can easily automate your orders (buy and sell) and get information about orders, funds or products. From now on we have one time password (OTP) support. | ||
@@ -168,5 +168,6 @@ All responses and objects are typed to develop faster and secure. | ||
const degiro = new DeGiro({ | ||
username: '<your_username_here>', | ||
pwd: '*******', | ||
jsessionId: previousJSESSIONID | ||
username: '<your_username_here>', // process.env['DEGIRO_USER] | ||
pwd: '<your_password_here>', // process.env['DEGIRO_PWD] | ||
oneTimePassword: '<your_one_time_password_here>', // process.env['DEGIRO_OTP] | ||
jsessionId: '<your_jsessionId_here>', // process.env['DEGIRO_JSESSIONID] | ||
}) | ||
@@ -173,0 +174,0 @@ |
@@ -20,2 +20,3 @@ // Import types | ||
username: params.username.toLowerCase().trim(), | ||
oneTimePassword: params.oneTimePassword, | ||
queryParams: { | ||
@@ -48,2 +49,7 @@ reason: 'session_expired', | ||
fetch(BASE_API_URL + LOGIN_URL_PATH, requestOptions) | ||
.then((res) => { | ||
if (!payload.oneTimePassword) return res | ||
debug('Sending OTP') | ||
return fetch(BASE_API_URL + LOGIN_URL_PATH + "/totp", requestOptions); | ||
}) | ||
.then(res => res.json()) | ||
@@ -55,4 +61,4 @@ .then((res) => { | ||
}) | ||
.catch(reject) | ||
.catch(reject); | ||
}) | ||
} | ||
} |
@@ -73,2 +73,3 @@ // Import modules | ||
private readonly pwd: string | ||
private readonly oneTimePassword: string | undefined | ||
private jsessionId: string | undefined | ||
@@ -81,6 +82,7 @@ private accountConfig: AccountConfigType | undefined | ||
constructor(params: DeGiroSettupType = {}) { | ||
let { username, pwd, jsessionId } = params | ||
let { username, pwd, oneTimePassword, jsessionId } = params | ||
username = username || process.env['DEGIRO_USER'] | ||
pwd = pwd || process.env['DEGIRO_PWD'] | ||
oneTimePassword = oneTimePassword || process.env['DEGIRO_OTP'] | ||
jsessionId = jsessionId || process.env['DEGIRO_JSESSIONID'] | ||
@@ -93,2 +95,3 @@ | ||
this.pwd = pwd | ||
this.oneTimePassword = oneTimePassword | ||
@@ -107,3 +110,7 @@ this.jsessionId = jsessionId | ||
return new Promise((resolve, reject) => { | ||
loginRequest({ username: this.username, pwd: this.pwd }) | ||
loginRequest({ | ||
username: this.username, | ||
pwd: this.pwd, | ||
oneTimePassword: this.oneTimePassword | ||
}) | ||
.then((loginResponse: LoginResponseType) => { | ||
@@ -256,3 +263,3 @@ if (!loginResponse.sessionId) reject('Login response have not a sessionId field') | ||
if (error) return reject(error) | ||
resolve(portfolio) | ||
resolve(<any[]>portfolio) | ||
}) | ||
@@ -357,2 +364,2 @@ }) | ||
} | ||
} |
export type DeGiroSettupType = { | ||
username?: string, | ||
pwd?: string, | ||
oneTimePassword?: string, | ||
jsessionId?: string, | ||
} |
@@ -6,5 +6,6 @@ export type LoginRequestBodyType = { | ||
username: string, | ||
oneTimePassword: string | undefined, | ||
queryParams: { | ||
reason: string, | ||
}, | ||
} | ||
} |
export type LoginRequestParamsType = { | ||
username: string, | ||
pwd: string, | ||
} | ||
oneTimePassword: string | undefined | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1601770
7578
1
744
4
24