diff --git a/README.md b/README.md index 8eacd52..741bb5c 100644 --- a/README.md +++ b/README.md @@ -377,3 +377,5 @@ fortniteAPI.login() ```js true ``` + +- killSession() : `Promise` with no Return | Kill Session diff --git a/index.js b/index.js index 48f9f0a..d336f4d 100644 --- a/index.js +++ b/index.js @@ -37,7 +37,7 @@ class FortniteApi { let expireDate = new Date( new Date(this.expires_at).getTime() - 15 * 60000 ); - if (this.expires_at && expireDate < actualDate) { + if (this.access_token && this.expires_at && expireDate < actualDate) { this.expires_at = undefined; //Refresh Token request({ @@ -460,6 +460,26 @@ class FortniteApi { }); }); } + + killSession() { + return new Promise((resolve, reject) => { + request({ + url: EndPoint.killSession(this.access_token), + headers: { + Authorization: "bearer " + this.access_token + }, + method: "DELETE", + json: true, + body: {} + }) + .then(() => { + resolve(); + }) + .catch(() => { + reject(); + }); + }); + } } module.exports = FortniteApi; diff --git a/package.json b/package.json index ee9d1b1..c626add 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fortnite-api", - "version": "2.7.2", + "version": "2.8.0", "description": "Fortnite API", "main": "index.js", "scripts": { diff --git a/tools/endpoint.js b/tools/endpoint.js index b482989..2edd467 100644 --- a/tools/endpoint.js +++ b/tools/endpoint.js @@ -32,5 +32,8 @@ module.exports = { accountId + "/public/QueryProfile?profileId=profile0&rvn=-1" ); + }, + killSession: token => { + return "https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/sessions/kill/" + token; } };