diff --git a/docs/kubebox.js b/docs/kubebox.js index 3502f81..2fe4788 100644 --- a/docs/kubebox.js +++ b/docs/kubebox.js @@ -247,8 +247,6 @@ const crypto = require('crypto'), GoogleCloudPlatform = require('./auth/gcp'), URI = require('urijs'); -const { error } = require('./error'); - class ChainRequest { constructor(...requests) { @@ -449,12 +447,6 @@ class Client { oauth_authorize({ username, password }) { return new ChainRequest( () => this.oauth_server_metadata(), - { - onRejected: err => { - return Promise.reject(err.response && [401, 403, 404].includes(err.response.statusCode) - ? error(`Authentication failed for ${this.url}, OAuth method unavailable!`) - : err) - }}, response => { const metadata = JSON.parse(response.body.toString('utf8')); const { protocol, hostname, port, path } = URI.parse(metadata.authorization_endpoint); @@ -479,12 +471,6 @@ class Client { oauth_authorize_web({ username, password }) { return new ChainRequest( () => this.oauth_server_metadata(), - { - onRejected: err => { - return Promise.reject(err.response && [401, 403, 404].includes(err.response.statusCode) - ? error(`Authentication failed for ${this.url}, OAuth method unavailable!`) - : err) - }}, response => { const metadata = JSON.parse(response.body.toString('utf8')); const { protocol, hostname, port, path } = URI.parse(metadata.authorization_endpoint); @@ -581,7 +567,7 @@ function mergeSingle(target, source) { module.exports = Client; -},{"./auth/exec":1,"./auth/gcp":2,"./auth/oidc":3,"./error":10,"./http-then":"http-then","crypto":162,"urijs":"urijs"}],5:[function(require,module,exports){ +},{"./auth/exec":1,"./auth/gcp":2,"./auth/oidc":3,"./http-then":"http-then","crypto":162,"urijs":"urijs"}],5:[function(require,module,exports){ 'use strict'; const URI = require('urijs'); @@ -77587,7 +77573,7 @@ class Kubebox extends EventEmitter { .fail(s => status.setContent(`${s} Authenticating to {bold}${client.url}{/bold}`)) .then(user => log(`{green-fg}Authenticated as {bold}${user.metadata.name}{/bold}{/green-fg}`) .then(() => connect(null, Object.assign({}, options, { user: user })))) - .catch(error => error.response && error.response.statusCode === 401 + .catch(error => error.response && [401, 403, 404].includes(error.response.statusCode) ? log(`{red-fg}Authentication failed for ${client.url}{/red-fg}`) // throttle reauthentication .then(wait(100)) diff --git a/lib/client.js b/lib/client.js index 50abca6..906865e 100644 --- a/lib/client.js +++ b/lib/client.js @@ -7,8 +7,6 @@ const crypto = require('crypto'), GoogleCloudPlatform = require('./auth/gcp'), URI = require('urijs'); -const { error } = require('./error'); - class ChainRequest { constructor(...requests) { @@ -209,12 +207,6 @@ class Client { oauth_authorize({ username, password }) { return new ChainRequest( () => this.oauth_server_metadata(), - { - onRejected: err => { - return Promise.reject(err.response && [401, 403, 404].includes(err.response.statusCode) - ? error(`Authentication failed for ${this.url}, OAuth method unavailable!`) - : err) - }}, response => { const metadata = JSON.parse(response.body.toString('utf8')); const { protocol, hostname, port, path } = URI.parse(metadata.authorization_endpoint); @@ -239,12 +231,6 @@ class Client { oauth_authorize_web({ username, password }) { return new ChainRequest( () => this.oauth_server_metadata(), - { - onRejected: err => { - return Promise.reject(err.response && [401, 403, 404].includes(err.response.statusCode) - ? error(`Authentication failed for ${this.url}, OAuth method unavailable!`) - : err) - }}, response => { const metadata = JSON.parse(response.body.toString('utf8')); const { protocol, hostname, port, path } = URI.parse(metadata.authorization_endpoint); diff --git a/lib/kubebox.js b/lib/kubebox.js index 86232a9..6bdb28e 100644 --- a/lib/kubebox.js +++ b/lib/kubebox.js @@ -152,7 +152,7 @@ class Kubebox extends EventEmitter { .fail(s => status.setContent(`${s} Authenticating to {bold}${client.url}{/bold}`)) .then(user => log(`{green-fg}Authenticated as {bold}${user.metadata.name}{/bold}{/green-fg}`) .then(() => connect(null, Object.assign({}, options, { user: user })))) - .catch(error => error.response && error.response.statusCode === 401 + .catch(error => error.response && [401, 403, 404].includes(error.response.statusCode) ? log(`{red-fg}Authentication failed for ${client.url}{/red-fg}`) // throttle reauthentication .then(wait(100))