Skip to content

Commit aaa2087

Browse files
committed
feat: separate login/adduser, remove auth types
BREAKING CHANGE: This removes all `auth-type` configs except `web` and `legacy`. BREAKING CHANGE: Finally, `login` and `adduser` are now separate commands that send different data to the registry. BREAKING CHANGE `auth-type` config values `web` and `legacy` only try their respective methods, npm no longer tries them all and waits to see which one doesn't fail. The difference between `adduser` and `login` depends on the `auth-type`. - `web`: the POST to `/-/v1/login` contains a `{ create: true }` value in its payload for `adduser` - `legacy` the `PUT` request to `/-/user/org.couchdb.user:${username}` contains an `email` value in its payload for `adduser`.
1 parent dcc3765 commit aaa2087

29 files changed

+645
-1329
lines changed

docs/content/commands/npm-adduser.md

+7-20
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ description: Add a registry user account
1313
```bash
1414
npm adduser
1515

16-
aliases: login, add-user
16+
alias: add-user
1717
```
1818

1919
<!-- automatically generated, do not edit manually -->
@@ -25,22 +25,12 @@ Note: This command is unaware of workspaces.
2525

2626
### Description
2727

28-
Create or verify a user named `<username>` in the specified registry, and
29-
save the credentials to the `.npmrc` file. If no registry is specified,
30-
the default registry will be used (see [`config`](/using-npm/config)).
28+
Create a new user in the specified registry, and save the credentials to
29+
the `.npmrc` file. If no registry is specified, the default registry
30+
will be used (see [`config`](/using-npm/config)).
3131

32-
The username, password, and email are read in from prompts.
33-
34-
To reset your password, go to <https://www.npmjs.com/forgot>
35-
36-
To change your email address, go to <https://www.npmjs.com/email-edit>
37-
38-
You may use this command multiple times with the same user account to
39-
authorize on a new machine. When authenticating on a new machine,
40-
the username, password and email address must all match with
41-
your existing record.
42-
43-
`npm login` is an alias to `adduser` and behaves exactly the same way.
32+
When using `legacy` for your `auth-type`, the username, password, and
33+
email are read in from prompts.
4434

4535
### Configuration
4636

@@ -93,10 +83,7 @@ npm init --scope=@foo --yes
9383
#### `auth-type`
9484

9585
* Default: "legacy"
96-
* Type: "legacy", "web", "sso", "saml", "oauth", or "webauthn"
97-
98-
NOTE: auth-type values "sso", "saml", "oauth", and "webauthn" will be
99-
removed in a future version.
86+
* Type: "legacy" or "web"
10087

10188
What authentication strategy to use with `login`.
10289

docs/content/commands/npm-login.md

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
---
2+
title: npm-login
3+
section: 1
4+
description: Login to a registry user account
5+
---
6+
7+
### Synopsis
8+
9+
<!-- AUTOGENERATED USAGE DESCRIPTIONS START -->
10+
<!-- automatically generated, do not edit manually -->
11+
<!-- see lib/commands/login.js -->
12+
13+
```bash
14+
npm login
15+
```
16+
17+
<!-- automatically generated, do not edit manually -->
18+
<!-- see lib/commands/login.js -->
19+
20+
<!-- AUTOGENERATED USAGE DESCRIPTIONS END -->
21+
22+
Note: This command is unaware of workspaces.
23+
24+
### Description
25+
26+
Verify a user in the specified registry, and save the credentials to the
27+
`.npmrc` file. If no registry is specified, the default registry will be
28+
used (see [`config`](/using-npm/config)).
29+
30+
When using `legacy` for your `auth-type`, the username and password, are
31+
read in from prompts.
32+
33+
To reset your password, go to <https://www.npmjs.com/forgot>
34+
35+
To change your email address, go to <https://www.npmjs.com/email-edit>
36+
37+
You may use this command multiple times with the same user account to
38+
authorize on a new machine. When authenticating on a new machine,
39+
the username, password and email address must all match with
40+
your existing record.
41+
42+
### Configuration
43+
44+
<!-- AUTOGENERATED CONFIG DESCRIPTIONS START -->
45+
<!-- automatically generated, do not edit manually -->
46+
<!-- see lib/utils/config/definitions.js -->
47+
#### `registry`
48+
49+
* Default: "https://registry.npmjs.org/"
50+
* Type: URL
51+
52+
The base URL of the npm registry.
53+
54+
<!-- automatically generated, do not edit manually -->
55+
<!-- see lib/utils/config/definitions.js -->
56+
57+
#### `scope`
58+
59+
* Default: the scope of the current project, if any, or ""
60+
* Type: String
61+
62+
Associate an operation with a scope for a scoped registry.
63+
64+
Useful when logging in to or out of a private registry:
65+
66+
```
67+
# log in, linking the scope to the custom registry
68+
npm login --scope=@mycorp --registry=https://registry.mycorp.com
69+
70+
# log out, removing the link and the auth token
71+
npm logout --scope=@mycorp
72+
```
73+
74+
This will cause `@mycorp` to be mapped to the registry for future
75+
installation of packages specified according to the pattern
76+
`@mycorp/package`.
77+
78+
This will also cause `npm init` to create a scoped package.
79+
80+
```
81+
# accept all defaults, and create a package named "@foo/whatever",
82+
# instead of just named "whatever"
83+
npm init --scope=@foo --yes
84+
```
85+
86+
87+
<!-- automatically generated, do not edit manually -->
88+
<!-- see lib/utils/config/definitions.js -->
89+
90+
#### `auth-type`
91+
92+
* Default: "legacy"
93+
* Type: "legacy" or "web"
94+
95+
What authentication strategy to use with `login`.
96+
97+
<!-- automatically generated, do not edit manually -->
98+
<!-- see lib/utils/config/definitions.js -->
99+
100+
<!-- AUTOGENERATED CONFIG DESCRIPTIONS END -->
101+
102+
### See Also
103+
104+
* [npm registry](/using-npm/registry)
105+
* [npm config](/commands/npm-config)
106+
* [npmrc](/configuring-npm/npmrc)
107+
* [npm owner](/commands/npm-owner)
108+
* [npm whoami](/commands/npm-whoami)
109+
* [npm token](/commands/npm-token)
110+
* [npm profile](/commands/npm-profile)

docs/content/using-npm/config.md

+1-29
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,7 @@ exit code.
218218
#### `auth-type`
219219

220220
* Default: "legacy"
221-
* Type: "legacy", "web", "sso", "saml", "oauth", or "webauthn"
222-
223-
NOTE: auth-type values "sso", "saml", "oauth", and "webauthn" will be
224-
removed in a future version.
221+
* Type: "legacy" or "web"
225222

226223
What authentication strategy to use with `login`.
227224

@@ -2084,31 +2081,6 @@ Alias for --package-lock
20842081
<!-- automatically generated, do not edit manually -->
20852082
<!-- see lib/utils/config/definitions.js -->
20862083

2087-
#### `sso-poll-frequency`
2088-
2089-
* Default: 500
2090-
* Type: Number
2091-
* DEPRECATED: The --auth-type method of SSO/SAML/OAuth will be removed in a
2092-
future version of npm in favor of web-based login.
2093-
2094-
When used with SSO-enabled `auth-type`s, configures how regularly the
2095-
registry should be polled while the user is completing authentication.
2096-
2097-
<!-- automatically generated, do not edit manually -->
2098-
<!-- see lib/utils/config/definitions.js -->
2099-
2100-
#### `sso-type`
2101-
2102-
* Default: "oauth"
2103-
* Type: null, "oauth", or "saml"
2104-
* DEPRECATED: The --auth-type method of SSO/SAML/OAuth will be removed in a
2105-
future version of npm in favor of web-based login.
2106-
2107-
If `--auth-type=sso`, the type of SSO type to use.
2108-
2109-
<!-- automatically generated, do not edit manually -->
2110-
<!-- see lib/utils/config/definitions.js -->
2111-
21122084
#### `tmp`
21132085

21142086
* Default: The value returned by the Node.js `os.tmpdir()` method

docs/nav.yml

+3
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@
9696
- title: npm link
9797
url: /commands/npm-link
9898
description: Symlink a package folder
99+
- title: npm login
100+
url: /commands/npm-login
101+
description: Login to a registry user account
99102
- title: npm logout
100103
url: /commands/npm-logout
101104
description: Log out of the registry

lib/auth/legacy.js

-100
This file was deleted.

lib/auth/oauth.js

-8
This file was deleted.

lib/auth/saml.js

-8
This file was deleted.

0 commit comments

Comments
 (0)