配置双重身份验证

您可以在您的 npm 用户账户上启用双重身份验证 (2FA),以防止未经授权访问您的账户和包,方法是使用移动应用程序中的 安全密钥基于时间的一次性密码 (TOTP)

注意:使用 WebAuthn 的安全密钥流程目前处于测试阶段。

先决条件

在您的 npm 用户账户上启用 2FA 之前,您必须:

有关支持的 2FA 方法的更多信息,请参阅 "关于双重身份验证"。

1CEKr65jmpyKVy/buHaD04b1WSfyG13EhOUH5wQnGZNY69HbVqT5GxsMkYxnc2jNO358Ux6bCXk/KyuZP4tleKCp4ZaJYvwF5Lqb74wp7SZoXn3Rq7yLE8U5xsDQtms0

从网站配置 2FA

启用 2FA

  1. tOSdQq4mThnp75IdOT/ECzX0pw46acznW6YZbaZRgnZObt/owG71HYwqbaEk+y2/uvF7Kh9y86WsdfXsA2xMmocJEO+sEzX23pzFlF/sp/3578K/U+18MZFwIvq44frF

  2. acwVa0cwidMtilYLDQIo7yL334CQ4JLLA4iXAAQoxZf8TVH2jR2aiHtaTtO6IE5D1tzC+13Og4OUJRH0SH2p/pfl237poieVDs7jVYbAkds=

  3. yolePStAbZXB8UAxlUxAOC9q8OW3hLT1pfaSmi7yFJaVgoPJSS5CG8MGHfBp4ypogejPZfvLSX+SIqfJBo4JquyIDDvZqfcmNeufLTXRpwI=

  4. 1Jr85VkRUxdiTOrxGZUzEXXQYX6Cdzti9BizSLs8xBwX5E1K4NvIaFAViuDI+fAlxsB4q8zjKMLc+uMbPt1yyzL2QDFEQyfGECioVCeJIjcIet9TgQ51T1NindnxHSCM

  5. wHIpywUlS3Wet0Tci0IrxnxxnfDsvjgbWkGrD2yWB3YmsXKGnaJlYPyTJpov/51nb6odhYkvzpEXFuImOfRT3ldf8E5Q6DJ7YeFMjaiY4lR1fY2tEXQ9o9VNHMiKtCFrkq8ciyWqPtQ8HtMOjYy8e7u3OOes7seQKSZR9BFM+N2L8Pdb4pIdr/u9EisPbv3edGDsfLR1V1bFi4jpz/gUCru2xLOfYDW9dPlxcl/rrXGgkm3ur4r4PX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DWEdD/yv+kx9WsWLoyuuD923fk=

  5. 0jmkN8AKjiiYnOgJuALixew+ahGQnCb3I92CWZSAQAGBPDDUsbyvrAFgK93syzfUzYngywH20/vlii9JJDPylJal/YhRPVWLXroRXZN8iQaSnw0pjafhwdkpM9sScGHgFYVHLu9wodrfeAhO98m2XQ==

禁用 2FA

x2RkGQo+FLBRpzosXAGg3+QOBjUO490v/ZVLyRHdt9Qep2/vos01wMYCXpDT2JGTDnlptf/cMj36nwS0r3kOLtRFowj1+61tkdXAWC7ylgM=

1CEKr65jmpyKVy/buHaD0+dPkat2YGs1Ooh8IwTypEgC96MEsiaCDNz/AJBa+Hb8MiWXpwOYSobapghY3J1RL0+ojpzpfhd0/fE2uEQ170M2AeZm3ytCjnro2/OCePLtgyK23c0TM4oYcM5FaEf+Z15/zdzfiIxys6qsw01BdUrUhQZgiM+3tcKi7hZp2x//AXyr4G7Y8w1ouwENftyRDOLRQ69+ZcutVD2mq6qcLCHzTZc2+i5oIcG1xnJHXdm7

  1. tOSdQq4mThnp75IdOT/ECzX0pw46acznW6YZbaZRgnZObt/owG71HYwqbaEk+y2/uvF7Kh9y86WsdfXsA2xMmocJEO+sEzX23pzFlF/sp/3578K/U+18MZFwIvq44frF

  2. acwVa0cwidMtilYLDQIo7yL334CQ4JLLA4iXAAQoxZf8TVH2jR2aiHtaTtO6IE5D1tzC+13Og4OUJRH0SH2p/pfl237poieVDs7jVYbAkds=

  3. yolePStAbZXB8UAxlUxAOC9q8OW3hLT1pfaSmi7yFJaVgoPJSS5CG8MGHfBp4ypogejPZfvLSX+SIqfJBo4JqmCJWPPPj72pmunzAWf2PX0=

  4. 3vj4nZxqKc7Tvi9wuiIRR6Z9vMN1JnrtdWVC0JpzwX5dZwvDUi+c4Umc+1DDFwdSGaFX3ZAYmyPH28gkOD/RzqcVmMtkYG9IorWq+2Hq85QpVjN2y6FeNWXq84n9sQKR

  5. 1rpV5WU2s6pPqwp/3xvgPstUdW+nNK40grIL+vpfE6o=

从命令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TZ980uLTdnerRkMVdcrgaoIlHUSrD3VNVnvIhWP5g0w7tC5Ut9ikuHm0+BwX4XzIc+vBnHBkut8oT2T+TAajS48Z1EDrejKYWFFmnMICw==
  3. xUUKjIJFnHsoGdRKl/VyD26wsqs/qGL9VMdHNhno8XbgUEUhCdh5V4osyMWscpbHJHcqAOxcSAnF0ktqcNKdWFDvDN+G7hRAjEIhi4hBp3n5praxdDDV2pwDHJcQtaA1v/dguv8LnaDviU0MdHQw7g==

      zhUf4aJnnpT5f3eF9kZdO9asEPTPjcqgW26TaPTlamjRE1mlFj00+h6R6njp0Ob8hcxH8rLVitj6yytGRQz3ZnDwsrCfW6twb4L3HNhXw+eAxfvAB3mal3FBRJ9H/PpojNsxC8Gcjz3dKnuXoZeaNQ==
  4. szkEUrdAL3qkzon17UmGl2+Rp5eu9MYDG+WIx2Bfuw4jWc9gB6eTZRFGhMbAfMmPnr9eZovQXQzmOnTckzc00mxMC5Q+sTrdByl8aBi5f2kASVIKJuDuk4/L/LB6LpAEAB2ZLFqidYhd5hbAjRb9uwFy6gsTNmsjCO8jvyq17ek=

从命令行发送一次性密码

WQUxnstoagagsWop/IQwkq9KF5CPIxsCZmGUs8VZxOxBueWqteX5+4rMpTnv/69d6zP+q72e2IFKsQU1Ll4TDhXYZFrp4z0zW0Ufv/ieIRkLUqg7Fmz2aUP1X21NWUp42MOxGvcbg8HwCBU8TT4jLsZYecwnTZnrmzw0Tdgs69apL04Tm/HflRuUfszP2ba190ht6nUyODXFwaNNi6Z+vU6jhFdGGKfmd7AVpd0wAq6fgln8FGaV/elddfxPBfb8c/3rUyu0ORdmuI7rXsGwZrRWEDEICXcSNxLc7ldZTKvHDPv1tBHgu2MpSRdlO819AqHGqkrfHZzj3ziOFRlnjg==

npm publish [<tarball>|<folder>][--tag <tag>] --otp=123456
npm owner add <user > --otp=123456
npm owner rm <user> --otp=123456
npm dist-tags add <pkg>@<version> [<tag>] --otp=123456
npm access edit [<package>) --otp=123456
npm unpublish [<@scope>/]<pkg>[@<version>] --otp=123456

从命令行删除 2FA

  1. YMeamfXeKPwC7vG8tfSvM9T82Is/Z8zI1z0USba7wclRQQAe5jv2SN0nTYBrooBGJ3+qs/uZivL2gcyH7FjLXeYjJR7lzPIvv7ZZpemOae3+QJc6aCb+ttdQRmuOpqn0

  2. 1AouBj3YZ+02REXInC1aiBPAMySCWiEn2nFXR18rYSE+k5A6Y6P1ZT08D60ICLCv

    npm profile disable-2fa
    
  3. B0S9Lj4RMUt85le6azf/iJ92MsTC9mhod29FloTNbgvYSVhsXwLub9PAvVVEgIS5

    LzCn+tuWS3ZD7/SeJpP9sA==

  4. szkEUrdAL3qkzon17UmGlzNQWD+dEIz8iEDSqM0GlarSsn/pVsXcsO+Oxz7jXrQH7kzAQ1Kug7mDxgFbpAbm1OamxedG8u8Z3ixKYEP/SpdB9//TIWKVq+YhkmWiAPi+VwRzh0Q4rOGy3t3awZczsg==

    BJBziuUWomhJ7j+mjNbBV4EIvB36fQMhfdTSuIp2wPEnnH7w+BORCA2it2sWc7OieXvDdt6ymPyZAIyHSX2gxw==

解决 TOTP 错误

EQkhne/Ac/7jbu5fMK8Tm4sC3IXqfpvNqjkI27EqBVNFRhTjTCcfl9WcxY6TDn+8A6H/+SBItk5mP4tMuFJzt9+lwK+UoaXmXk4+4tBalMgyMmEMiA2+pRFCYY5mRIf5OLCrr0JxiAIdzfefK+7H2j1doqlzU4TM1tulkSOyEwiRJU4GJUz5NnLhOzWRxyjdCe8gqsYoKoz/iI3MkRYSk/GoG1aEJ5pwYgudYPgCkUYUY8ikho2CA5TKzCrJchgRwIzX18+cbYxhtGqIMDyLBoUN/bmDYHQubjzNSCxLHvs+YyFh72vloQn3ADa3cVtWn8x0pOuQ/1wOI/Tcf46jxzDKoONorn6xKSpDhUZFM0s=

/2k5PBmCtI1ULMtDxceUqQkSZR2gv4oT7F/LVx/1L7JF93hzmzP1snQG+n5ujI1G75FGXuQteoy/mbM+b79nwsxTkzYkIwR8oeWe47AYZ4l3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