双重身份认证( two-factor authentication ,2FA)通过以下的方式来确认你的身份,防止未经授权就访问你的账号。

  • 用户名或者是密码
  • 手机号或者平板电脑

当你开启了 2FA,那么当你使用账户或者具有写访问权限的包去执行某些操作的时候(取决于你的 2FA设置 ),我们会提示你输入一个一次性的密码。

Note:双重认证为你的账号提供了最好的安全的方式来抵御攻击。我们强烈的建议你在注册完成之后尽快的开启2FA。

双重身份认证模式

双重身份认证,有两种模式。一种仅授权,一种是授权和写入。

Two-factor authentication on npm can be enabled for authorization only, or authorization and writes.

仅授权

如果开启了 2FA的仅授权,我们将会对于某些授权操作(authorized actions)要求输入一次性密码。 | Action | CLI command | | —- | —- | | 登录 npm | npm login | | 修改配置信息设置(包括你的密码) | npm profile set | | 更改账户的 2FA 模式 | npm profile enable-2fa auth-only | | 关闭账户的 2FA 模式 | npm profile disable-2fa |

授权和写入

如果你开启了 2FA 的授权和写入模式,我们将会对一些授权和写入操作要求输入一次性密码。 | Action | CLI command | | —- | —- | | 登录 npmLog in to npm | npm login | | 修改配置信息设置(包括你的密码) | npm profile set | | 更改账户的 2FA 模式 | npm profile enable-2fa auth-and-writes | | 关闭账户的 2FA 模式 | npm profile disable-2fa | | 创建 tokens | npm token create | | 取消(revoke) tokens | npm token revoke | | 上传包 | npm publish | | Unpublish packages | npm unpublish | | Deprecate packages | npm deprecate | | Change package visibility | npm access public/restricted | | Change user and team package access | npm access grant/revoke | | Change package 2FA requirements | N/A |