diff --git a/.gitignore b/.gitignore index eb913c1..5934960 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ node_modules .esm-cache .vs-code dump.rdb +.vscode diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index a8d6186..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "vsicons.presets.angular": false -} \ No newline at end of file diff --git a/YahooFantasy.mjs b/YahooFantasy.mjs index 636728e..18b38c6 100644 --- a/YahooFantasy.mjs +++ b/YahooFantasy.mjs @@ -31,7 +31,7 @@ class YahooFantasy { this.CONSUMER_SECRET = consumerSecret; this.REDIRECT_URI = redirectUri; - this.refreshTokenCallback = () => {}; + this.refreshTokenCallback = () => { }; if (tokenCallbackFn) { this.refreshTokenCallback = tokenCallbackFn; @@ -65,7 +65,7 @@ class YahooFantasy { } // oauth2 authenticatiocn function -- follow redirect to yahoo login - auth(res, state = null) { + auth(res, state = null, scope = null) { const authData = { client_id: this.CONSUMER_KEY, redirect_uri: this.REDIRECT_URI, @@ -76,6 +76,10 @@ class YahooFantasy { authData.state = state; } + if (scope) { + authData.scope = scope + } + const options = { hostname: "api.login.yahoo.com", port: 443, @@ -140,9 +144,10 @@ class YahooFantasy { }); tokenReponse.on("end", async () => { - const { access_token, refresh_token } = JSON.parse( + const data = JSON.parse( Buffer.concat(chunks) ); + const { access_token, refresh_token } = data; this.yahooUserToken = access_token; this.yahooRefreshToken = refresh_token; @@ -155,7 +160,7 @@ class YahooFantasy { }); } - cb(null, { access_token, refresh_token, state }); + cb(null, { ...data, state }); }); }); diff --git a/index.js b/index.js index f4726b2..e2e903c 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ /* global module, require */ require = require("esm")(module, true); module.exports = require("./YahooFantasy.mjs").default; - +module.exports.teamHelper = require('./helpers/teamHelper.mjs'); // TODO: league settings sample data // TODO: transactions sample data diff --git a/package-lock.json b/package-lock.json index cf1857c..3f76c3a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "yahoo-fantasy", - "version": "5.2.2", + "version": "5.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "yahoo-fantasy", - "version": "5.2.2", + "version": "5.3.0", "license": "MIT", "dependencies": { "esm": "^3.2.25",