Skip to content

Commit 108c9f0

Browse files
committedApr 8, 2018
feat(token): accept opts.token for opts._authToken
1 parent 89789b0 commit 108c9f0

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed
 

‎README.md

+19-18
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,6 @@ Fetch options are optional, and can be passed in as either a Map-like object
8888
(one with a `.get()` method), a plain javascript object, or a
8989
[`figgy-pudding`](https://npm.im/figgy-pudding) instance.
9090

91-
##### <a name="opts-auth-token"></a> `opts._authToken`
92-
93-
* Type: String
94-
* Default: null
95-
96-
Authentication token string.
97-
98-
Can be scoped to a registry by using a "nerf dart" for that registry. That is:
99-
100-
```
101-
{
102-
'//registry.npmjs.org/:_authToken': 't0k3nH34r'
103-
}
104-
```
105-
10691
##### <a name="opts-agent"></a> `opts.agent`
10792

10893
* Type: http.Agent
@@ -362,7 +347,7 @@ account.
362347
* Default: null
363348

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

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

514499
Time before a hanging request times out.
515500

501+
##### <a name="opts-token"></a> `opts.token`
502+
503+
* Alias: `opts._authToken`
504+
* Type: String
505+
* Default: null
506+
507+
Authentication token string.
508+
509+
Can be scoped to a registry by using a "nerf dart" for that registry. That is:
510+
511+
```
512+
{
513+
'//registry.npmjs.org/:token': 't0k3nH34r'
514+
}
515+
```
516+
516517
##### <a name="opts-user-agent"></a> `opts.user-agent`
517518

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

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

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

547548
** DEPRECATED ** This is a legacy authentication token supported only for
548-
*compatibility. Please us [`opts._authToken`](#opts-auth-token) instead.
549+
*compatibility. Please use [`opts.token`](#opts-token) instead.

‎auth.js

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function getAuth (registry, opts) {
1010
let AUTH = {}
1111
const regKey = registry && registryKey(registry)
1212
const doKey = (key, alias) => addKey(opts, AUTH, regKey, key, alias)
13+
doKey('token')
1314
doKey('_authToken', 'token')
1415
doKey('username')
1516
doKey('password')

‎config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const pkg = require('./package.json')
44
const pudding = require('figgy-pudding')
55
const silentLog = require('./silentlog.js')
66

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

0 commit comments

Comments
 (0)
Please sign in to comment.