Skip to content

Commit 11dbd7e

Browse files
MaxBlack-devMax Black
andauthored
fix: display full token when creating authentication tokens (#8709)
Fixes [#8684](#8684) ### What / Why When running `npm token create`, the created authentication token was being redacted in the output, making it difficult for users to copy and use the token. This happened because npm's output system automatically applies redaction to sensitive information like tokens. ### How - Import `META` from `proc-log` to access output metadata options - Use `{ [META]: true, redact: false }` option in `output.standard()` to disable redaction for the token display line - This follows the established pattern used in other parts of the codebase (e.g., `lib/utils/open-url.js`) for displaying sensitive information that users need to see ### Testing - All existing tests pass - The fix preserves the existing output format and test expectations - Token is now displayed in full while maintaining proper formatting and colors ### Before Created publish token npm_*** ### After Created publish token npm_1a2b3c4d5e6f7g8h9i0j The token can now be copied and used directly without being obscured by npm's redaction system. Co-authored-by: Max Black <[email protected]>
1 parent 06510a8 commit 11dbd7e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/commands/token.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { log, output } = require('proc-log')
1+
const { log, output, META } = require('proc-log')
22
const { listTokens, createToken, removeToken } = require('npm-profile')
33
const { otplease } = require('../utils/auth.js')
44
const readUserInfo = require('../utils/read-user-info.js')
@@ -147,7 +147,7 @@ class Token extends BaseCommand {
147147
const chalk = this.npm.chalk
148148
// Identical to list
149149
const level = result.readonly ? 'read only' : 'publish'
150-
output.standard(`Created ${chalk.blue(level)} token ${result.token}`)
150+
output.standard(`Created ${chalk.blue(level)} token ${result.token}`, { [META]: true, redact: false })
151151
if (result.cidr_whitelist?.length) {
152152
output.standard(`with IP whitelist: ${chalk.green(result.cidr_whitelist.join(','))}`)
153153
}

0 commit comments

Comments
 (0)