@heroku-cli/command
Advanced tools
Comparing version 8.1.2 to 8.1.3
@@ -0,1 +1,10 @@ | ||
<a name="8.1.3"></a> | ||
## [8.1.3](https://github.com/heroku/heroku-cli-command/compare/v8.1.2...v8.1.3) (2018-05-07) | ||
### Bug Fixes | ||
* use jwt auth on browser login ([3ba6ac7](https://github.com/heroku/heroku-cli-command/commit/3ba6ac7)) | ||
* web -> browser ([2a78cc0](https://github.com/heroku/heroku-cli-command/commit/2a78cc0)) | ||
<a name="8.1.2"></a> | ||
@@ -2,0 +11,0 @@ ## [8.1.2](https://github.com/heroku/heroku-cli-command/compare/v8.1.1...v8.1.2) (2018-05-06) |
@@ -6,3 +6,3 @@ import * as Config from '@oclif/config'; | ||
expiresIn?: number; | ||
method?: 'interactive' | 'sso' | 'web'; | ||
method?: 'interactive' | 'sso' | 'browser'; | ||
browser?: string; | ||
@@ -18,3 +18,3 @@ } | ||
logout(token?: string | undefined): Promise<any>; | ||
private web(); | ||
private browser(); | ||
private interactive(login?, expiresIn?); | ||
@@ -24,4 +24,4 @@ private createOAuthToken(username, password, opts?); | ||
private defaultToken(); | ||
private enableWebLogin(); | ||
private enableBrowserLogin(); | ||
private sso(org?); | ||
} |
@@ -25,7 +25,7 @@ "use strict"; | ||
if (opts.expiresIn) { | ||
// can't use web with --expires-in | ||
// can't use browser with --expires-in | ||
input = 'interactive'; | ||
} | ||
else if (this.enableWebLogin()) { | ||
input = await cli_ux_1.default.prompt(`heroku: Login with [${color_1.default.green('w')}]eb, [${color_1.default.green('i')}]nteractive, or [${color_1.default.green('s')}]so`, { default: defaultMethod }); | ||
else if (this.enableBrowserLogin()) { | ||
input = await cli_ux_1.default.prompt(`heroku: Login with [${color_1.default.green('b')}]rowser, [${color_1.default.green('i')}]nteractive, or [${color_1.default.green('s')}]so (enterprise-only)`, { default: defaultMethod }); | ||
} | ||
@@ -38,5 +38,5 @@ else { | ||
switch (input) { | ||
case 'w': | ||
case 'web': | ||
auth = await this.web(); | ||
case 'b': | ||
case 'browser': | ||
auth = await this.browser(); | ||
break; | ||
@@ -98,3 +98,3 @@ case 'i': | ||
} | ||
async web() { | ||
async browser() { | ||
const { body: urls } = await this.heroku.post(`${this.loginHost}/auth`); | ||
@@ -104,3 +104,7 @@ // TODO: handle browser | ||
cli_ux_1.default.action.start('heroku: Waiting for login'); | ||
const { body: auth } = await this.heroku.get(`${this.loginHost}${urls.cli_url}`); | ||
const { body: auth } = await this.heroku.get(`${this.loginHost}${urls.cli_url}`, { | ||
headers: { | ||
authorization: `Bearer ${urls.token}`, | ||
} | ||
}); | ||
if (auth.error) | ||
@@ -116,3 +120,3 @@ cli_ux_1.default.error(auth.error); | ||
refresh: auth.refresh_token, | ||
method: 'web', | ||
method: 'browser', | ||
}; | ||
@@ -194,3 +198,3 @@ } | ||
} | ||
enableWebLogin() { | ||
enableBrowserLogin() { | ||
if (!process.env.HEROKU_LOGIN_HOST) | ||
@@ -197,0 +201,0 @@ return false; |
{ | ||
"name": "@heroku-cli/command", | ||
"description": "base class for Heroku CLI commands", | ||
"version": "8.1.2", | ||
"version": "8.1.3", | ||
"author": "Jeff Dickey @jdxcode", | ||
@@ -37,3 +37,3 @@ "bugs": "https://github.com/heroku/heroku-cli-command/issues", | ||
"proxyquire": "^2.0.1", | ||
"sinon": "^5.0.4", | ||
"sinon": "^5.0.7", | ||
"testdouble": "^3.8.1", | ||
@@ -40,0 +40,0 @@ "ts-node": "^6.0.3", |
46446
1123