Skip to content

Commit

Permalink
feat(token): accept opts.token for opts._authToken
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Apr 8, 2018
1 parent 89789b0 commit 108c9f0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
37 changes: 19 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,6 @@ Fetch options are optional, and can be passed in as either a Map-like object
(one with a `.get()` method), a plain javascript object, or a
[`figgy-pudding`](https://npm.im/figgy-pudding) instance.

##### <a name="opts-auth-token"></a> `opts._authToken`

* Type: String
* Default: null

Authentication token string.

Can be scoped to a registry by using a "nerf dart" for that registry. That is:

```
{
'//registry.npmjs.org/:_authToken': 't0k3nH34r'
}
```

##### <a name="opts-agent"></a> `opts.agent`

* Type: http.Agent
Expand Down Expand Up @@ -362,7 +347,7 @@ account.
* Default: null

Password used for basic authentication. For the more modern authentication
method, please use the (more secure) [`opts._authToken`](#opts-auth-token)
method, please use the (more secure) [`opts.token`](#opts-token)

Can optionally be scoped to a registry by using a "nerf dart" for that registry.
That is:
Expand Down Expand Up @@ -513,6 +498,22 @@ See also [`opts.ca`](#opts-ca).

Time before a hanging request times out.

##### <a name="opts-token"></a> `opts.token`

* Alias: `opts._authToken`
* Type: String
* Default: null

Authentication token string.

Can be scoped to a registry by using a "nerf dart" for that registry. That is:

```
{
'//registry.npmjs.org/:token': 't0k3nH34r'
}
```

##### <a name="opts-user-agent"></a> `opts.user-agent`

* Type: String
Expand All @@ -526,7 +527,7 @@ User agent string to send in the `User-Agent` header.
* Default: null

Username used for basic authentication. For the more modern authentication
method, please use the (more secure) [`opts._authToken`](#opts-auth-token)
method, please use the (more secure) [`opts.token`](#opts-token)

Can optionally be scoped to a registry by using a "nerf dart" for that registry.
That is:
Expand All @@ -545,4 +546,4 @@ See also [`opts.password`](#opts-password)
* Default: null

** DEPRECATED ** This is a legacy authentication token supported only for
*compatibility. Please us [`opts._authToken`](#opts-auth-token) instead.
*compatibility. Please use [`opts.token`](#opts-token) instead.
1 change: 1 addition & 0 deletions auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function getAuth (registry, opts) {
let AUTH = {}
const regKey = registry && registryKey(registry)
const doKey = (key, alias) => addKey(opts, AUTH, regKey, key, alias)
doKey('token')
doKey('_authToken', 'token')
doKey('username')
doKey('password')
Expand Down
2 changes: 1 addition & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const pkg = require('./package.json')
const pudding = require('figgy-pudding')
const silentLog = require('./silentlog.js')

const AUTH_REGEX = /^(?:.*:)?(_authToken|username|_password|password|email|always-auth|_auth|otp)$/
const AUTH_REGEX = /^(?:.*:)?(token|_authToken|username|_password|password|email|always-auth|_auth|otp)$/
const SCOPE_REGISTRY_REGEX = /@.*:registry$/gi
const RegFetchConfig = pudding({
'agent': {},
Expand Down

0 comments on commit 108c9f0

Please sign in to comment.