Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

The great tfa → 2fa rename #18845

Merged
merged 1 commit into from Oct 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/cli/npm-token.md
Expand Up @@ -5,11 +5,11 @@ npm-token(1) -- Manage your authentication tokens

npm token list [--json|--parseable]
npm token create [--read-only] [--cidr=1.1.1.1/24,2.2.2.2/16]
npm token delete <id|token>
npm token revoke <id|token>

## DESCRIPTION

This list you list, create and delete authentication tokens.
This list you list, create and revoke authentication tokens.

* `npm token list`:
Shows a table of all active authentication tokens. You can request this as
Expand Down Expand Up @@ -52,7 +52,7 @@ This list you list, create and delete authentication tokens.
+----------------+--------------------------------------+
```

* `npm token delete <token|id>`:
* `npm token revoke <token|id>`:
This removes an authentication token, making it immediately unusable. This can accept
both complete tokens (as you get back from `npm token create` and will
find in your `.npmrc`) and ids as seen in the `npm token list` output.
Expand Down
12 changes: 6 additions & 6 deletions lib/profile.js
Expand Up @@ -87,11 +87,11 @@ function config () {
}

const knownProfileKeys = qw`
name email ${'two factor auth'} fullname homepage
name email ${'two-factor auth'} fullname homepage
freenode twitter github created updated`

function get (args) {
const tfa = 'two factor auth'
const tfa = 'two-factor auth'
const conf = config()
return pulseTillDone.withPromise(profile.get(conf)).then((info) => {
if (!info.cidr_whitelist) delete info.cidr_whitelist
Expand Down Expand Up @@ -202,7 +202,7 @@ function enable2fa (args) {
}
const mode = args[0] || 'auth-and-writes'
if (mode !== 'auth-only' && mode !== 'auth-and-writes') {
return Promise.reject(new Error(`Invalid two factor authentication mode "${mode}".\n` +
return Promise.reject(new Error(`Invalid two-factor authentication mode "${mode}".\n` +
'Valid modes are:\n' +
' auth-only - Require two-factor authentication only when logging in\n' +
' auth-and-writes - Require two-factor authentication when logging in AND when publishing'))
Expand Down Expand Up @@ -235,7 +235,7 @@ function enable2fa (args) {
}
})
}).then(() => {
log.info('profile', 'Setting two factor authentication to ' + mode)
log.info('profile', 'Setting two-factor authentication to ' + mode)
return pulseTillDone.withPromise(profile.set(info, conf))
}).then((challenge) => {
if (challenge.tfa === null) {
Expand All @@ -252,10 +252,10 @@ function enable2fa (args) {
}).then((code) => {
return readUserInfo.otp('And an OTP code from your authenticator: ')
}).then((otp1) => {
log.info('profile', 'Finalizing two factor authentication')
log.info('profile', 'Finalizing two-factor authentication')
return profile.set({tfa: [otp1]}, conf)
}).then((result) => {
output('TFA successfully enabled. Below are your recovery codes, please print these out.')
output('2FA successfully enabled. Below are your recovery codes, please print these out.')
output('You will need these to recover access to your account if you lose your authentication device.')
result.tfa.forEach((c) => output('\t' + c))
})
Expand Down
10 changes: 5 additions & 5 deletions lib/token.js
Expand Up @@ -15,17 +15,17 @@ module.exports = token

token.usage =
'npm token list\n' +
'npm token delete <tokenKey>\n' +
'npm token revoke <tokenKey>\n' +
'npm token create [--read-only] [--cidr=list]\n'

token.subcommands = ['list', 'delete', 'create']
token.subcommands = ['list', 'revoke', 'create']

token.completion = function (opts, cb) {
var argv = opts.conf.argv.remain

switch (argv[2]) {
case 'list':
case 'delete':
case 'revoke':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should accept both here. This would be a breaking change otherwise, and I think it's fine to have delete as an alias.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh oops, I didn't mean to ditch it entirely!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, this is tab completion. I'm ok with not tab completing delete.

case 'create':
return cb(null, [])
default:
Expand All @@ -46,7 +46,7 @@ function token (args, cb) {
withCb(list(), cb)
break
case 'delete':
case 'rel':
case 'revoke':
case 'remove':
case 'rm':
withCb(rm(args.slice(1)), cb)
Expand Down Expand Up @@ -127,7 +127,7 @@ function list (args) {

function rm (args) {
if (args.length === 0) {
throw new Error('npm token delete <tokenKey>')
throw new Error('npm token revoke <tokenKey>')
}
const conf = config()
const toRemove = []
Expand Down