You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/integrations/integrating-npm-with-external-services/about-access-tokens.mdx
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,10 +55,13 @@ Granular access tokens allow you to restrict access provided to the token based
55
55
- Set a token expiration date
56
56
- Limit token access based on IP address ranges
57
57
- Select between **read-only** or **read and write** access
58
+
- Configure a token to **Bypass 2FA** requirements
58
59
59
60
You can create up to 1000 granular access tokens on your npm account. You can set how long your token is valid for, at least one day in the future. Each token can access up to 50 organizations, and up to either 50 packages, 50 scopes, or a combination of 50 packages and scopes. Access tokens are tied to users’ permission; hence it cannot have more permission than the user at any point in time. If a user has their access revoked from a package or an org., their granular access token also will have its access revoked from those packages or org.
60
61
61
62
When you give a token access to an organization, the token can only be used for managing organization settings and teams or users associated with the organization. It does not give the token the right to publish packages managed by the organization.
62
63
64
+
The Bypass 2FA capability applies to tokens with write access and is set to false by default at token creation. When the Bypass 2FA option is set to true, this setting takes precedence over account-level and package-level 2FA settings. This means that even if account-level 2FA is enabled and/or package-level 2FA is required, 2FA will still be bypassed when using the token.
Copy file name to clipboardExpand all lines: content/integrations/integrating-npm-with-external-services/creating-and-viewing-access-tokens.mdx
+10-6Lines changed: 10 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,33 +22,37 @@ You can [create](#creating-access-tokens) and [view](#viewing-access-tokens) acc
22
22
23
23
4. (Optional) In the **Description** field, enter a description for your token.
24
24
25
-
5. In the **Expiration** field, enter a token expiration period. The date must be at least 1 day in the future.
25
+
5. (Optional) Check the **Bypass two-factor authentication** checkbox if you want this token to bypass 2FA requirements for write actions.
26
+
- This setting is unchecked (false) by default
27
+
- By checking this box, the token will bypass 2FA for write actions even if 2FA is enabled at the account or package level
26
28
27
-
6. (Optional) In the **Allowed IP Ranges** field, enter IP address ranges to restrict your access token to. You must use [CIDR][cidr-wiki] notation to enter IP address ranges. To add more than one allowed IP range, click **Add IP Range** and enter an IP range in the new text field.
29
+
6. In the **Expiration** field, enter a token expiration period. The date must be at least 1 day in the future.
30
+
31
+
7. (Optional) In the **Allowed IP Ranges** field, enter IP address ranges to restrict your access token to. You must use [CIDR][cidr-wiki] notation to enter IP address ranges. To add more than one allowed IP range, click **Add IP Range** and enter an IP range in the new text field.
28
32
29
33
<Screenshotsrc="/integrations/integrating-npm-with-external-services/granular-access-token-ip-range.png"alt="Screenshot of the allowed IP ranges section" />
30
34
31
-
7. (Optional) In the **Packages and scopes** section, configure your token's access to packages and scopes.
35
+
8. (Optional) In the **Packages and scopes** section, configure your token's access to packages and scopes.
32
36
- In the **Permissions** dropdown menu, select **No access**, **Read-only**, or **Read and write**.
33
37
- Under **Select Packages**, select either:
34
38
-**All Packages** to grant the token access to all packages the user account has access to.
35
39
-**Only select packages and scopes** to choose up to 50 specific packages or scopes to give the token access to. Then select specific packages or scopes from the dropdown menu.
36
40
37
41
<Screenshotsrc="/integrations/integrating-npm-with-external-services/granular-access-token-packages-scopes.png"alt="Screenshot of the packages and scopes section" />
38
42
39
-
8. (Optional) In the **Organizations** section, configure your token's access to organizations.
43
+
9. (Optional) In the **Organizations** section, configure your token's access to organizations.
40
44
- In the **Permissions** dropdown menu, select **No access**, **Read-only**, or **Read and write**.
41
45
- Under **Select organizations**, select the organizations you want to grant your token access to.
42
46
43
47
<Screenshotsrc="/integrations/integrating-npm-with-external-services/granular-access-token-organizations.png"alt="Screenshot of the organizations section" />
44
48
45
49
_**Note**: When you give a token access to an organization, the token can only be used for managing organization settings and teams or users associated with the organization. It does not give the token the right to publish packages managed by the organization._
46
50
47
-
9. Review the token summary, then click **Generate Token**.
51
+
10. Review the token summary, then click **Generate Token**.
48
52
49
53
<Screenshotsrc="/integrations/integrating-npm-with-external-services/granular-access-token-summary.png"alt="Screenshot of the granular access token summary and the generate token button" />
Copy file name to clipboardExpand all lines: content/integrations/integrating-npm-with-external-services/revoking-access-tokens.mdx
+13-1Lines changed: 13 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,19 @@ redirect_from:
4
4
- /revoking-authentication-tokens
5
5
---
6
6
7
-
To keep your account and packages secure, we strongly recommend revoking (deleting) tokens you no longer need or that have been compromised. You can revoke any token you have created.
7
+
To keep your account and packages secure, we strongly recommend revoking (deleting) tokens you no longer need or that have been compromised. You can revoke any token you have created, including granular access tokens.
8
+
9
+
## Revoking tokens on the website
10
+
11
+
1. In the upper right corner of the page, click your profile picture, then click **Access Tokens**.
12
+
13
+
2. Find the token you want to delete in the token list.
14
+
15
+
3. Click the **×** button next to the token, or select multiple tokens and click **Delete Selected Tokens**.
16
+
17
+
4. Confirm the deletion when prompted.
18
+
19
+
## Revoking tokens using the CLI
8
20
9
21
1. To see a list of your tokens, on the command line, run:
Copy file name to clipboardExpand all lines: content/integrations/integrating-npm-with-external-services/using-private-packages-in-a-ci-cd-workflow.mdx
+21-23Lines changed: 21 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,50 +25,48 @@ Create a new access token that will be used only to access npm packages from a C
25
25
26
26
When generating an access token for use in a continuous integration environment, we recommend using a granular access token with limited access to provide greater security.
27
27
28
-
If you use a legacy token instead, by default, `npm token create` will generate a token with both read and write permissions. We recommend creating a read-only token:
28
+
For most CI workflows that only install dependencies and run tests, a **read-only** granular access token is sufficient and most secure.
29
+
30
+
<Note>
31
+
32
+
**Note:** If your CI workflow requires write operations (such as publishing test packages), you may need a granular access token with read and write permissions and bypass 2FA enabled to prevent automated workflows from being blocked by 2FA prompts. However, we strongly recommend using read-only tokens whenever possible and reserving bypass 2FA for deployment workflows only.
33
+
34
+
</Note>
29
35
30
36
<Notevariant="danger">
31
37
32
38
**Warning:** Legacy access tokens are removed as of November 2025.
33
39
34
40
</Note>
35
41
36
-
```
37
-
npm token create --read-only
38
-
```
39
-
40
-
For more information on creating access tokens, including CIDR-whitelisted tokens, see "[Creating an access token][create-token]".
42
+
For more information on creating granular access tokens, including CIDR-whitelisted tokens, see "[Creating and viewing access tokens][create-token]".
41
43
42
44
### Continuous deployment
43
45
44
46
For publishing packages in continuous deployment environments, we strongly recommend using [trusted publishing](/trusted-publishers) when available, as it provides enhanced security without requiring token management.
45
47
46
-
If trusted publishing is not available for your CI/CD provider, you may create an [automation token][create-token] on the website. This will allow you to publish even if you have two-factor authentication enabled on your account.
48
+
If trusted publishing is not available for your CI/CD provider, you can create a [granular access token with bypass 2FA enabled][create-token] on the website. This will allow you to publish even if you have two-factor authentication enabled on your account.
47
49
48
-
### Interactive workflows
50
+
<Note>
49
51
50
-
If your workflow produces a package, but you publish it manually after validation, then you will want to create a token with read and write permissions, which are granted with the standard token creation command:
52
+
**Security considerations for bypass 2FA:**
51
53
52
-
```
53
-
npm token create
54
-
```
54
+
- Only enable bypass 2FA when necessary for automated publishing workflows
55
+
- Use restrictive permissions and short expiration dates
56
+
- Consider IP address restrictions and regular token rotation
57
+
- Use trusted publishing instead of bypass 2FA tokens whenever possible
55
58
56
-
### CIDR whitelists
59
+
</Note>
57
60
58
-
For increased security, you may use a CIDR-whitelisted token that can only be used from a certain IP address range. You can use a CIDR whitelist with a read and publish token or a read-only token:
61
+
### Interactive workflows
59
62
60
-
```
61
-
npm token create --cidr=[list]
62
-
npm token create --read-only --cidr=[list]
63
-
```
63
+
If your workflow produces a package, but you publish it manually after validation, then you will want to create a granular access token with read and write permissions. See "[Creating and viewing access tokens][create-token]" for instructions.
64
64
65
-
Example:
65
+
### CIDR whitelists
66
66
67
-
```
68
-
npm token create --cidr=192.0.2.0/24
69
-
```
67
+
For increased security, you may use a CIDR-whitelisted granular access token that can only be used from a certain IP address range. You can configure IP address restrictions when creating your granular access token on the website.
70
68
71
-
For more information, see "[Creating and viewing authentication tokens][create-token]".
69
+
For more information, see "[Creating and viewing access tokens][create-token]".
72
70
73
71
## Set the token as an environment variable on the CI/CD server
Copy file name to clipboardExpand all lines: content/packages-and-modules/securing-your-code/requiring-2fa-for-package-publishing-and-settings-modification.mdx
+15-5Lines changed: 15 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,10 +6,21 @@ import shared from '~/shared.js'
6
6
7
7
To protect your packages, as a package publisher, you can require everyone who has write access to a package to have two-factor authentication (2FA) enabled. This will require that users provide 2FA credentials in addition to their login token when they publish the package. For more information, see "[Configuring two-factor authentication][config-2fa]".
8
8
9
-
You may also choose to allow publishing with either two-factor authentication _or_ with [automation tokens][creating-automation-token]. This lets you configure automation tokens in a CI/CD workflow, but requires two-factor authentication from interactive publishes.
9
+
You may also choose to allow publishing with either two-factor authentication _or_ with [granular access tokens with bypass 2FA enabled][creating-granular-access-token]. This lets you configure tokens in a CI/CD workflow, but requires two-factor authentication from interactive publishes.
10
10
11
11
For CI/CD workflows, consider using [trusted publishing](/trusted-publishers), which provides secure, token-free publishing that automatically enforces strong authentication without requiring manual token management.
12
12
13
+
<Note>
14
+
15
+
**Important notes about granular access tokens:**
16
+
17
+
- Bypass 2FA configuration is set at token creation
18
+
- When **bypass 2FA is disabled**: The system will check account-level and package-level settings to determine if 2FA is required
19
+
- When **bypass 2FA is enabled**: The token will bypass all 2FA requirements at all times, regardless of account-level or package-level 2FA settings
20
+
- When **Require two-factor authentication and disallow tokens** is selected at the package level, granular access tokens cannot be used regardless of their bypass 2FA setting
21
+
22
+
</Note>
23
+
13
24
## Configuring two-factor authentication
14
25
15
26
1. <>{shared['user-login'].text}</>
@@ -26,16 +37,15 @@ For CI/CD workflows, consider using [trusted publishing](/trusted-publishers), w
26
37
1.**Dont require two-factor authentication**
27
38
With this option, a maintainer can publish a package or change the package settings whether they have two-factor authentication enabled or not. This is the least secure setting.
28
39
29
-
2.**Require two-factor authentication or automation tokens or granular access token**
30
-
With this option, maintainers must have two-factor authentication enabled for their account. If they publish a package interactively, using the `npm publish` command, they will be required to enter 2FA credentials when they perform the publish. However, maintainers may also create an [automation token][creating-automation-token] or a [granular access token][creating-granular-access-token] and use that to publish. A second factor is _not_ required when using a token, making it useful for continuous integration and continuous deployment workflows.
40
+
2.**Require two-factor authentication or granular access tokens**
41
+
With this option, maintainers must have two-factor authentication enabled for their account. If they publish a package interactively, using the `npm publish` command, they will be required to enter 2FA credentials when they perform the publish. However, maintainers may also create a [granular access token with bypass 2FA enabled][creating-granular-access-token] and use that to publish. A second factor is _not_ required when using these specific token types, making them useful for continuous integration and continuous deployment workflows.
31
42
32
43
3.**Require two-factor authentication and disallow tokens**
33
-
With this option, a maintainer must have two-factor authentication enabled for their account, and they must publish interactively. Maintainers will be required to enter 2FA credentials when they perform the publish. Automation tokens and granular access tokens cannot be used to publish packages.
44
+
With this option, a maintainer must have two-factor authentication enabled for their account, and they must publish interactively. Maintainers will be required to enter 2FA credentials when they perform the publish. Granular access tokens cannot be used to publish packages, regardless of their bypass 2FA setting.
34
45
35
46
<Screenshotsrc="/packages-and-modules/securing-your-code/2fa-package-setting.png"alt="Screenshot showing the require two-factor option for a package" />
0 commit comments