npm-token

管理你的身份验证令牌

选择命令行版本:

概要

🌐 Synopsis

npm token list
npm token revoke <id|token>
npm token create [--read-only] [--cidr=list]

注意:此命令不支持工作区。

🌐 Note: This command is unaware of workspaces.

描述

🌐 Description

这使你可以列出、创建和撤销身份验证令牌。

🌐 This lets you list, create and revoke authentication tokens.

  • npm token list:显示所有活跃的认证令牌的表格。你可以用 --json 请求 JSON 格式,或用 --parseable 请求制表符分隔的值。
+--------+---------+------------+----------+----------------+
| id | token | created | read-only | CIDR whitelist |
+--------+---------+------------+----------+----------------+
| 7f3134 | 1fa9ba… | 2017-10-02 | yes | |
+--------+---------+------------+----------+----------------+
| c03241 | af7aef… | 2017-10-02 | no | 192.168.0.1/24 |
+--------+---------+------------+----------+----------------+
| e0cf92 | 3a436a… | 2017-10-02 | no | |
+--------+---------+------------+----------+----------------+
| 63eb9d | 74ef35… | 2017-09-28 | no | |
+--------+---------+------------+----------+----------------+
| 2daaa8 | cbad5f… | 2017-09-26 | no | |
+--------+---------+------------+----------+----------------+
| 68c2fe | 127e51… | 2017-09-23 | no | |
+--------+---------+------------+----------+----------------+
| 6334e1 | 1dadd1… | 2017-09-23 | no | |
+--------+---------+------------+----------+----------------+
  • npm token create [--read-only] [--cidr=<cidr-ranges>]:创建一个新的身份验证令牌。它可以是 --read-only,或者接受一个 CIDR 范围的列表,用于限制该令牌的使用。这将提示你输入密码,如果你启用了双因素认证,还会要求输入一次性密码(OTP)。

    目前,CLI 无法生成自动化令牌。有关生成自动化令牌的更多信息,请参阅文档网站

+----------------+--------------------------------------+
| token | a73c9572-f1b9-8983-983d-ba3ac3cc913d |
+----------------+--------------------------------------+
| cidr_whitelist | |
+----------------+--------------------------------------+
| readonly | false |
+----------------+--------------------------------------+
| created | 2017-10-02T07:52:24.838Z |
+----------------+--------------------------------------+
  • npm token revoke <token|id>:立即从注册表中移除身份验证令牌。你将无法再使用它。此功能可以接受完整的令牌(例如你从 npm token create 获取的令牌以及在 .npmrc 中找到的令牌),也可以接受在 npm token list 的可解析输出或 JSON 输出中看到的 ID。它不接受在常规 npm token list 输出中显示的截断令牌。

配置

🌐 Configuration

read-only

  • 默认:否
  • 类型:布尔

这用于在使用 npm token create 命令配置有限访问令牌时,将令牌标记为无法发布。

🌐 This is used to mark a token as unable to publish when configuring limited access tokens with the npm token create command.

cidr

  • 默认值:空
  • 类型:null 或字符串(可以多次设置)

这是一个 CIDR 地址列表,用于在使用 npm token create 命令配置有限访问令牌时使用。

🌐 This is a list of CIDR address to be used when configuring limited access tokens with the npm token create command.

registry

  • 默认: "https://registry.npmjs.org/"
  • 类型:网址

npm 注册表的基本 URL。

🌐 The base URL of the npm registry.

otp

  • 默认值:空
  • 类型:空或字符串

这是来自双因素认证器的一次性密码。在使用 npm access 发布或更改软件包权限时需要此密码。

🌐 This is a one-time password from a two-factor authenticator. It's needed when publishing or changing package permissions with npm access.

如果未设置,并且注册表响应失败并询问一次性密码,npm 将在命令行上提示输入一次密码。

🌐 If not set, and a registry response fails with a challenge for a one-time password, npm will prompt on the command line for one.

也可以看看

🌐 See Also