@pm2/js-api
Advanced tools
Comparing version 0.5.60 to 0.5.63
{ | ||
"name": "@pm2/js-api", | ||
"version": "0.5.60", | ||
"version": "0.5.63", | ||
"description": "PM2.io API Client for Javascript", | ||
@@ -12,6 +12,7 @@ "main": "index.js", | ||
"test": "mocha test/*", | ||
"build": "browserify -s Keymetrics -r ./ > ./dist/keymetrics.es5.js", | ||
"dist": "browserify -s Keymetrics -r ./ | uglifyjs -c warnings=false -m > ./dist/keymetrics.es5.min.js", | ||
"build": "mkdir -p dist; browserify -s Keymetrics -r ./ > ./dist/keymetrics.es5.js", | ||
"dist": "mkdir -p dist; browserify -s Keymetrics -r ./ | uglifyjs -c warnings=false -m > ./dist/keymetrics.es5.min.js", | ||
"doc": "jsdoc -r ./src --readme ./README.md -d doc -t ./node_modules/minami", | ||
"clean": "rm dist/*" | ||
"clean": "rm dist/*", | ||
"prepublish": "npm run build && npm run dist" | ||
}, | ||
@@ -30,3 +31,3 @@ "repository": { | ||
"author": "Keymetrics Team", | ||
"license": "Apache 2.0", | ||
"license": "Apache-2", | ||
"bugs": { | ||
@@ -37,3 +38,3 @@ "url": "https://github.com/keymetrics/km.js/issues" | ||
"dependencies": { | ||
"async": "^2.4.1", | ||
"async": "^2.6.3", | ||
"axios": "^0.19.0", | ||
@@ -45,6 +46,6 @@ "debug": "^2.6.8", | ||
"devDependencies": { | ||
"babel-core": "^6.26.0", | ||
"babel-core": "6.26.0", | ||
"babel-preset-es2015": "*", | ||
"babel-preset-stage-2": "*", | ||
"babelify": "*", | ||
"babel-preset-stage-2": "6.24.1", | ||
"babelify": "8.0.0", | ||
"browserify": "^13.1.0", | ||
@@ -54,6 +55,6 @@ "jsdoc": "^3.4.2", | ||
"mocha": "^3.0.2", | ||
"pm2": "latest", | ||
"pm2": "^4.1.2", | ||
"should": "*", | ||
"standard": "^10.0.2", | ||
"uglify-js": "*" | ||
"uglify-js": "~3.3.7" | ||
}, | ||
@@ -60,0 +61,0 @@ "browserify": { |
@@ -194,19 +194,27 @@ | ||
loggerHttp(`Asking to the oauth flow to retrieve new tokens`) | ||
this.oauth_flow.retrieveTokens(this.km, (err, data) => { | ||
// if it fail, we fail the whole request | ||
if (err) { | ||
loggerHttp(`Failed to retrieve new tokens : ${err.message || err}`) | ||
return next(response) | ||
} | ||
// if its good, we try to update the tokens | ||
loggerHttp(`Succesfully retrieved new tokens`) | ||
this._updateTokens(null, data, (err, authenticated) => { | ||
var q = () => { | ||
this.oauth_flow.retrieveTokens(this.km, (err, data) => { | ||
// if it fail, we fail the whole request | ||
if (err) return next(response) | ||
// then we can rebuffer the request | ||
loggerHttp(`Re-buffering call to ${httpOpts.url} since authenticated now`) | ||
httpOpts.headers.Authorization = `Bearer ${this.tokens.access_token}` | ||
return this._axios.request(httpOpts).then(successNext).catch(next) | ||
if (err) { | ||
loggerHttp(`Failed to retrieve new tokens : ${err.message || err}`) | ||
return next(response) | ||
} | ||
// if its good, we try to update the tokens | ||
loggerHttp(`Succesfully retrieved new tokens`) | ||
this._updateTokens(null, data, (err, authenticated) => { | ||
// if it fail, we fail the whole request | ||
if (err) return next(response) | ||
// then we can rebuffer the request | ||
loggerHttp(`Re-buffering call to ${httpOpts.url} since authenticated now`) | ||
httpOpts.headers.Authorization = `Bearer ${this.tokens.access_token}` | ||
return this._axios.request(httpOpts).then(successNext).catch(next) | ||
}) | ||
}) | ||
}) | ||
} | ||
if (httpOpts.url == this.opts.services.OAUTH + '/api/oauth/token') { | ||
// Avoid infinite recursive loop to retrieveToken | ||
return setTimeout(q.bind(this), 500) | ||
} | ||
q() | ||
}) | ||
@@ -213,0 +221,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
895334
19
11795
Updatedasync@^2.6.3