Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const code = request.query.code;
const token = await this.fetchToken(code);
resolve(token.access_token);
return 'Thank you. You can close this tab.';
} catch (err) {
reject(err);
} finally {
this.server.stop();
}
},
});
const codeChallenge = this.base64url(createHash('sha256').update(this.codeVerifier).digest('base64'));
const authorizeUrl = this.buildAuthorizeUrl(codeChallenge);
cli.log(chalk.green('*') + ' ' + chalk.white('...if your browser does not open, open this:')
+ ' ' + chalk.underline(chalk.blue(authorizeUrl)));
open(authorizeUrl);
this.server.start();
} catch (e) {
// tslint:disable-next-line:no-console
console.log('Error inside of the execute:', e);
}
});
}
saveEndpointOrError(newEndpoint, alias, secret).then(function (_) {
const msg = `Endpoint '${alias}' saved.`
cli.log(msg)
res.end(msg)
server.close(err => process.exit())
})
.catch(function (err) {
display(buildpacks: BuildpackResponse[], indent: string) {
if (buildpacks.length === 1) {
cli.log(this.registryUrlToName(buildpacks[0].buildpack.url, true))
} else {
buildpacks.forEach((b, i) => {
cli.log(`${indent}${i + 1}. ${this.registryUrlToName(b.buildpack.url, true)}`)
})
}
}
async run() {
const {args, flags} = this.parse(ClientsRotate)
cli.action.start(`Updating ${color.cyan(args.id)}`)
const {body: client} = await this.heroku.post(
`/oauth/clients/${encodeURIComponent(args.id)}/actions/rotate-credentials`,
)
cli.action.stop()
if (flags.json) {
cli.styledJSON(client)
} else if (flags.shell) {
cli.log(`HEROKU_OAUTH_ID=${client.id}`)
cli.log(`HEROKU_OAUTH_SECRET=${client.secret}`)
} else {
cli.styledHeader(`${client.name}`)
cli.styledObject(client)
}
}
}
private async diffPrompt(original: Config, newConfig: Config): Promise {
if (_.isEqual(original, newConfig)) {
this.warn('no changes to config')
return false
}
cli.log()
cli.log('Config Diff:')
showDiff(original, newConfig)
cli.log()
return cli.confirm(`Update config on ${color.app(this.app)} with these values?`)
}
const {redirect_uri, name} = args
validateURL(redirect_uri)
cli.action.start(`Creating ${args.name}`)
const {body: client} = await this.heroku.post('/oauth/clients', {
body: {name, redirect_uri},
})
cli.action.stop()
if (flags.json) {
cli.styledJSON(client)
} else {
cli.log(`HEROKU_OAUTH_ID=${client.id}`)
cli.log(`HEROKU_OAUTH_SECRET=${client.secret}`)
}
}
}
async run() {
const {flags} = this.parse(AuthorizationsIndex)
let {body: authorizations} = await this.heroku.get>('/oauth/authorizations')
authorizations = sortBy(authorizations, 'description')
if (flags.json) {
cli.styledJSON(authorizations)
} else if (authorizations.length === 0) {
cli.log('No OAuth authorizations.')
} else {
cli.table(authorizations, {
description: {get: (v: any) => color.green(v.description)},
id: {},
scope: {get: (v: any) => v.scope.join(',')},
}, {'no-header': true, printLine: this.log})
}
}
}
if ((!flags.app) && (!flags.all)) {
cli.error('You need to specify the scope via --app or --all')
}
if (flags.app) {
url = `/apps/${flags.app}/addons`
} else {
url = '/addons'
}
const headers = {'Accept-Expansion': 'addon_service, plan'}
const {body: addons} = await this.heroku.get(url, {headers})
if (addons.length === 0) {
if (flags.app) {
cli.log(`No add-ons for app ${flags.app}`)
} else {
cli.log('No add-ons on your apps')
}
return
}
if (flags.json) {
ux.styledJSON(addons)
} else {
ux.table(addons, {
name: {
get: getAddonName
},
plan: {
get: row => {
if (row.plan && row.plan.name) {
columns: [
{key: 'buildpack', label: 'Buildpack'},
{key: 'category', label: 'Category'},
{key: 'description', label: 'Description', format: trunc}
]
})
}
if (buildpacks.length === 0) {
cli.log('No buildpacks found')
} else if (buildpacks.length === 1) {
displayTable(buildpacks)
cli.log('\n1 buildpack found')
} else {
displayTable(buildpacks)
cli.log(`\n${buildpacks.length} buildpacks found`)
}
}
}
description: buildpack.description
}
})
const trunc = (value: string, _: string) => truncate(value, {length: 35, omission: '…'})
let displayTable = (buildpacks: TableRow[]) => {
cli.table(buildpacks, {
columns: [
{key: 'buildpack', label: 'Buildpack'},
{key: 'category', label: 'Category'},
{key: 'description', label: 'Description', format: trunc}
]
})
}
if (buildpacks.length === 0) {
cli.log('No buildpacks found')
} else if (buildpacks.length === 1) {
displayTable(buildpacks)
cli.log('\n1 buildpack found')
} else {
displayTable(buildpacks)
cli.log(`\n${buildpacks.length} buildpacks found`)
}
}
}