1 | # npm-registry-fetch [![npm version](https://img.shields.io/npm/v/npm-registry-fetch.svg)](https://npm.im/npm-registry-fetch) [![license](https://img.shields.io/npm/l/npm-registry-fetch.svg)](https://npm.im/npm-registry-fetch) [![Travis](https://img.shields.io/travis/npm/npm-registry-fetch/latest.svg)](https://travis-ci.org/npm/npm-registry-fetch) [![AppVeyor](https://img.shields.io/appveyor/ci/zkat/npm-registry-fetch/latest.svg)](https://ci.appveyor.com/project/npm/npm-registry-fetch) [![Coverage Status](https://coveralls.io/repos/github/npm/npm-registry-fetch/badge.svg?branch=latest)](https://coveralls.io/github/npm/npm-registry-fetch?branch=latest)
|
2 |
|
3 | [`npm-registry-fetch`](https://github.com/npm/npm-registry-fetch) is a Node.js
|
4 | library that implements a `fetch`-like API for accessing npm registry APIs
|
5 | consistently. It's able to consume npm-style configuration values and has all
|
6 | the necessary logic for picking registries, handling scopes, and dealing with
|
7 | authentication details built-in.
|
8 |
|
9 | This package is meant to replace the older
|
10 | [`npm-registry-client`](https://npm.im/npm-registry-client).
|
11 |
|
12 | ## Example
|
13 |
|
14 | ```javascript
|
15 | const npmFetch = require('npm-registry-fetch')
|
16 |
|
17 | console.log(
|
18 | await npmFetch.json('/-/ping')
|
19 | )
|
20 | ```
|
21 |
|
22 | ## Table of Contents
|
23 |
|
24 | * [Installing](#install)
|
25 | * [Example](#example)
|
26 | * [Contributing](#contributing)
|
27 | * [API](#api)
|
28 | * [`fetch`](#fetch)
|
29 | * [`fetch.json`](#fetch-json)
|
30 | * [`fetch` options](#fetch-opts)
|
31 |
|
32 | ### Install
|
33 |
|
34 | `$ npm install npm-registry-fetch`
|
35 |
|
36 | ### Contributing
|
37 |
|
38 | The npm team enthusiastically welcomes contributions and project participation!
|
39 | There's a bunch of things you can do if you want to contribute! The [Contributor
|
40 | Guide](CONTRIBUTING.md) has all the information you need for everything from
|
41 | reporting bugs to contributing entire new features. Please don't hesitate to
|
42 | jump in if you'd like to, or even ask us questions if something isn't clear.
|
43 |
|
44 | All participants and maintainers in this project are expected to follow [Code of
|
45 | Conduct](CODE_OF_CONDUCT.md), and just generally be excellent to each other.
|
46 |
|
47 | Please refer to the [Changelog](CHANGELOG.md) for project history details, too.
|
48 |
|
49 | Happy hacking!
|
50 |
|
51 | ### API
|
52 |
|
53 | #### Caching and `write=true` query strings
|
54 |
|
55 | Before performing any PUT or DELETE operation, npm clients first make a
|
56 | GET request to the registry resource being updated, which includes
|
57 | the query string `?write=true`.
|
58 |
|
59 | The semantics of this are, effectively, "I intend to write to this thing,
|
60 | and need to know the latest current value, so that my write can land
|
61 | cleanly".
|
62 |
|
63 | The public npm registry handles these `?write=true` requests by ensuring
|
64 | that the cache is re-validated before sending a response. In order to
|
65 | maintain the same behavior on the client, and not get tripped up by an
|
66 | overeager local cache when we intend to write data to the registry, any
|
67 | request that comes through `npm-registry-fetch` that contains `write=true`
|
68 | in the query string will forcibly set the `prefer-online` option to `true`,
|
69 | and set both `prefer-offline` and `offline` to false, so that any local
|
70 | cached value will be revalidated.
|
71 |
|
72 | #### <a name="fetch"></a> `> fetch(url, [opts]) -> Promise<Response>`
|
73 |
|
74 | Performs a request to a given URL.
|
75 |
|
76 | The URL can be either a full URL, or a path to one. The appropriate registry
|
77 | will be automatically picked if only a URL path is given.
|
78 |
|
79 | For available options, please see the section on [`fetch` options](#fetch-opts).
|
80 |
|
81 | ##### Example
|
82 |
|
83 | ```javascript
|
84 | const res = await fetch('/-/ping')
|
85 | console.log(res.headers)
|
86 | res.on('data', d => console.log(d.toString('utf8')))
|
87 | ```
|
88 |
|
89 | #### <a name="fetch-json"></a> `> fetch.json(url, [opts]) -> Promise<ResponseJSON>`
|
90 |
|
91 | Performs a request to a given registry URL, parses the body of the response as
|
92 | JSON, and returns it as its final value. This is a utility shorthand for
|
93 | `fetch(url).then(res => res.json())`.
|
94 |
|
95 | For available options, please see the section on [`fetch` options](#fetch-opts).
|
96 |
|
97 | ##### Example
|
98 |
|
99 | ```javascript
|
100 | const res = await fetch.json('/-/ping')
|
101 | console.log(res) // Body parsed as JSON
|
102 | ```
|
103 |
|
104 | #### <a name="fetch-json-stream"></a> `> fetch.json.stream(url, jsonPath, [opts]) -> Stream`
|
105 |
|
106 | Performs a request to a given registry URL and parses the body of the response
|
107 | as JSON, with each entry being emitted through the stream.
|
108 |
|
109 | The `jsonPath` argument is a [`JSONStream.parse()`
|
110 | path](https://github.com/dominictarr/JSONStream#jsonstreamparsepath), and the
|
111 | returned stream (unlike default `JSONStream`s), has a valid
|
112 | `Symbol.asyncIterator` implementation.
|
113 |
|
114 | For available options, please see the section on [`fetch` options](#fetch-opts).
|
115 |
|
116 | ##### Example
|
117 |
|
118 | ```javascript
|
119 | console.log('https://npm.im/~zkat has access to the following packages:')
|
120 | for await (let {key, value} of fetch.json.stream('/-/user/zkat/package', '$*')) {
|
121 | console.log(`https://npm.im/${key} (perms: ${value})`)
|
122 | }
|
123 | ```
|
124 |
|
125 | #### <a name="fetch-opts"></a> `fetch` Options
|
126 |
|
127 | Fetch options are optional, and can be passed in as either a Map-like object
|
128 | (one with a `.get()` method), a plain javascript object, or a
|
129 | [`figgy-pudding`](https://npm.im/figgy-pudding) instance.
|
130 |
|
131 | ##### <a name="opts-agent"></a> `opts.agent`
|
132 |
|
133 | * Type: http.Agent
|
134 | * Default: an appropriate agent based on URL protocol and proxy settings
|
135 |
|
136 | An [`Agent`](https://nodejs.org/api/http.html#http_class_http_agent) instance to
|
137 | be shared across requests. This allows multiple concurrent `fetch` requests to
|
138 | happen on the same socket.
|
139 |
|
140 | You do _not_ need to provide this option unless you want something particularly
|
141 | specialized, since proxy configurations and http/https agents are already
|
142 | automatically managed internally when this option is not passed through.
|
143 |
|
144 | ##### <a name="opts-body"></a> `opts.body`
|
145 |
|
146 | * Type: Buffer | Stream | Object
|
147 | * Default: null
|
148 |
|
149 | Request body to send through the outgoing request. Buffers and Streams will be
|
150 | passed through as-is, with a default `content-type` of
|
151 | `application/octet-stream`. Plain JavaScript objects will be `JSON.stringify`ed
|
152 | and the `content-type` will default to `application/json`.
|
153 |
|
154 | Use [`opts.headers`](#opts-headers) to set the content-type to something else.
|
155 |
|
156 | ##### <a name="opts-ca"></a> `opts.ca`
|
157 |
|
158 | * Type: String, Array, or null
|
159 | * Default: null
|
160 |
|
161 | The Certificate Authority signing certificate that is trusted for SSL
|
162 | connections to the registry. Values should be in PEM format (Windows calls it
|
163 | "Base-64 encoded X.509 (.CER)") with newlines replaced by the string `'\n'`. For
|
164 | example:
|
165 |
|
166 | ```
|
167 | {
|
168 | ca: '-----BEGIN CERTIFICATE-----\nXXXX\nXXXX\n-----END CERTIFICATE-----'
|
169 | }
|
170 | ```
|
171 |
|
172 | Set to `null` to only allow "known" registrars, or to a specific CA cert
|
173 | to trust only that specific signing authority.
|
174 |
|
175 | Multiple CAs can be trusted by specifying an array of certificates instead of a
|
176 | single string.
|
177 |
|
178 | See also [`opts.strict-ssl`](#opts-strict-ssl), [`opts.ca`](#opts-ca) and
|
179 | [`opts.key`](#opts-key)
|
180 |
|
181 | ##### <a name="opts-cache"></a> `opts.cache`
|
182 |
|
183 | * Type: path
|
184 | * Default: null
|
185 |
|
186 | The location of the http cache directory. If provided, certain cachable requests
|
187 | will be cached according to [IETF RFC 7234](https://tools.ietf.org/html/rfc7234)
|
188 | rules. This will speed up future requests, as well as make the cached data
|
189 | available offline if necessary/requested.
|
190 |
|
191 | See also [`offline`](#opts-offline), [`prefer-offline`](#opts-prefer-offline),
|
192 | and [`prefer-online`](#opts-prefer-online).
|
193 |
|
194 | ##### <a name="opts-cert"></a> `opts.cert`
|
195 |
|
196 | * Type: String
|
197 | * Default: null
|
198 |
|
199 | A client certificate to pass when accessing the registry. Values should be in
|
200 | PEM format (Windows calls it "Base-64 encoded X.509 (.CER)") with newlines
|
201 | replaced by the string `'\n'`. For example:
|
202 |
|
203 | ```
|
204 | {
|
205 | cert: '-----BEGIN CERTIFICATE-----\nXXXX\nXXXX\n-----END CERTIFICATE-----'
|
206 | }
|
207 | ```
|
208 |
|
209 | It is _not_ the path to a certificate file (and there is no "certfile" option).
|
210 |
|
211 | See also: [`opts.ca`](#opts-ca) and [`opts.key`](#opts-key)
|
212 |
|
213 | ##### <a name="opts-fetch-retries"></a> `opts.fetch-retries`
|
214 |
|
215 | * Type: Number
|
216 | * Default: 2
|
217 |
|
218 | The "retries" config for [`retry`](https://npm.im/retry) to use when fetching
|
219 | packages from the registry.
|
220 |
|
221 | See also [`opts.retry`](#opts-retry) to provide all retry options as a single
|
222 | object.
|
223 |
|
224 | ##### <a name="opts-fetch-retry-factor"></a> `opts.fetch-retry-factor`
|
225 |
|
226 | * Type: Number
|
227 | * Default: 10
|
228 |
|
229 | The "factor" config for [`retry`](https://npm.im/retry) to use when fetching
|
230 | packages.
|
231 |
|
232 | See also [`opts.retry`](#opts-retry) to provide all retry options as a single
|
233 | object.
|
234 |
|
235 | ##### <a name="opts-fetch-retry-mintimeout"></a> `opts.fetch-retry-mintimeout`
|
236 |
|
237 | * Type: Number
|
238 | * Default: 10000 (10 seconds)
|
239 |
|
240 | The "minTimeout" config for [`retry`](https://npm.im/retry) to use when fetching
|
241 | packages.
|
242 |
|
243 | See also [`opts.retry`](#opts-retry) to provide all retry options as a single
|
244 | object.
|
245 |
|
246 | ##### <a name="opts-fetch-retry-maxtimeout"></a> `opts.fetch-retry-maxtimeout`
|
247 |
|
248 | * Type: Number
|
249 | * Default: 60000 (1 minute)
|
250 |
|
251 | The "maxTimeout" config for [`retry`](https://npm.im/retry) to use when fetching
|
252 | packages.
|
253 |
|
254 | See also [`opts.retry`](#opts-retry) to provide all retry options as a single
|
255 | object.
|
256 |
|
257 | ##### <a name="opts-force-auth"></a> `opts.force-auth`
|
258 |
|
259 | * Alias: `opts.forceAuth`
|
260 | * Type: Object
|
261 | * Default: null
|
262 |
|
263 | If present, other auth-related values in `opts` will be completely ignored,
|
264 | including `alwaysAuth`, `email`, and `otp`, when calculating auth for a request,
|
265 | and the auth details in `opts.forceAuth` will be used instead.
|
266 |
|
267 | ##### <a name="opts-gzip"></a> `opts.gzip`
|
268 |
|
269 | * Type: Boolean
|
270 | * Default: false
|
271 |
|
272 | If true, `npm-registry-fetch` will set the `Content-Encoding` header to `gzip`
|
273 | and use `zlib.gzip()` or `zlib.createGzip()` to gzip-encode
|
274 | [`opts.body`](#opts-body).
|
275 |
|
276 | ##### <a name="opts-headers"></a> `opts.headers`
|
277 |
|
278 | * Type: Object
|
279 | * Default: null
|
280 |
|
281 | Additional headers for the outgoing request. This option can also be used to
|
282 | override headers automatically generated by `npm-registry-fetch`, such as
|
283 | `Content-Type`.
|
284 |
|
285 | ##### <a name="opts-ignore-body"></a> `opts.ignore-body`
|
286 |
|
287 | * Alias: `opts.ignoreBody`
|
288 | * Type: Boolean
|
289 | * Default: false
|
290 |
|
291 | If true, the **response body** will be thrown away and `res.body` set to `null`.
|
292 | This will prevent dangling response sockets for requests where you don't usually
|
293 | care what the response body is.
|
294 |
|
295 | ##### <a name="opts-integrity"></a> `opts.integrity`
|
296 |
|
297 | * Type: String | [SRI object](https://npm.im/ssri)
|
298 | * Default: null
|
299 |
|
300 | If provided, the response body's will be verified against this integrity string,
|
301 | using [`ssri`](https://npm.im/ssri). If verification succeeds, the response will
|
302 | complete as normal. If verification fails, the response body will error with an
|
303 | `EINTEGRITY` error.
|
304 |
|
305 | Body integrity is only verified if the body is actually consumed to completion --
|
306 | that is, if you use `res.json()`/`res.buffer()`, or if you consume the default
|
307 | `res` stream data to its end.
|
308 |
|
309 | Cached data will have its integrity automatically verified using the
|
310 | previously-generated integrity hash for the saved request information, so
|
311 | `EINTEGRITY` errors can happen if [`opts.cache`](#opts-cache) is used, even if
|
312 | `opts.integrity` is not passed in.
|
313 |
|
314 | ##### <a name='opts-is-from-ci'></a> `opts.is-from-ci`
|
315 |
|
316 | * Alias: `opts.isFromCI`
|
317 | * Type: Boolean
|
318 | * Default: Based on environment variables
|
319 |
|
320 | This is used to populate the `npm-in-ci` request header sent to the registry.
|
321 |
|
322 | ##### <a name="opts-key"></a> `opts.key`
|
323 |
|
324 | * Type: String
|
325 | * Default: null
|
326 |
|
327 | A client key to pass when accessing the registry. Values should be in PEM
|
328 | format with newlines replaced by the string `'\n'`. For example:
|
329 |
|
330 | ```
|
331 | {
|
332 | key: '-----BEGIN PRIVATE KEY-----\nXXXX\nXXXX\n-----END PRIVATE KEY-----'
|
333 | }
|
334 | ```
|
335 |
|
336 | It is _not_ the path to a key file (and there is no "keyfile" option).
|
337 |
|
338 | See also: [`opts.ca`](#opts-ca) and [`opts.cert`](#opts-cert)
|
339 |
|
340 | ##### <a name="opts-local-address"></a> `opts.local-address`
|
341 |
|
342 | * Type: IP Address String
|
343 | * Default: null
|
344 |
|
345 | The IP address of the local interface to use when making connections
|
346 | to the registry.
|
347 |
|
348 | See also [`opts.proxy`](#opts-proxy)
|
349 |
|
350 | ##### <a name="opts-log"></a> `opts.log`
|
351 |
|
352 | * Type: [`npmlog`](https://npm.im/npmlog)-like
|
353 | * Default: null
|
354 |
|
355 | Logger object to use for logging operation details. Must have the same methods
|
356 | as `npmlog`.
|
357 |
|
358 | ##### <a name="opts-map-json"></a> `opts.map-json`
|
359 |
|
360 | * Alias: `mapJson`, `mapJSON`
|
361 | * Type: Function
|
362 | * Default: undefined
|
363 |
|
364 | When using `fetch.json.stream()` (NOT `fetch.json()`), this will be passed down
|
365 | to [`JSONStream`](https://npm.im/JSONStream) as the second argument to
|
366 | `JSONStream.parse`, and can be used to transform stream data before output.
|
367 |
|
368 | ##### <a name="opts-maxsockets"></a> `opts.maxsockets`
|
369 |
|
370 | * Alias: `opts.max-sockets`
|
371 | * Type: Integer
|
372 | * Default: 12
|
373 |
|
374 | Maximum number of sockets to keep open during requests. Has no effect if
|
375 | [`opts.agent`](#opts-agent) is used.
|
376 |
|
377 | ##### <a name="opts-method"></a> `opts.method`
|
378 |
|
379 | * Type: String
|
380 | * Default: 'GET'
|
381 |
|
382 | HTTP method to use for the outgoing request. Case-insensitive.
|
383 |
|
384 | ##### <a name="opts-noproxy"></a> `opts.noproxy`
|
385 |
|
386 | * Type: Boolean
|
387 | * Default: process.env.NOPROXY
|
388 |
|
389 | If true, proxying will be disabled even if [`opts.proxy`](#opts-proxy) is used.
|
390 |
|
391 | ##### <a name="opts-npm-session"></a> `opts.npm-session`
|
392 |
|
393 | * Alias: `opts.npmSession`
|
394 | * Type: String
|
395 | * Default: null
|
396 |
|
397 | If provided, will be sent in the `npm-session` header. This header is used by
|
398 | the npm registry to identify individual user sessions (usually individual
|
399 | invocations of the CLI).
|
400 |
|
401 | ##### <a name="opts-offline"></a> `opts.offline`
|
402 |
|
403 | * Type: Boolean
|
404 | * Default: false
|
405 |
|
406 | Force offline mode: no network requests will be done during install. To allow
|
407 | `npm-registry-fetch` to fill in missing cache data, see
|
408 | [`opts.prefer-offline`](#opts-prefer-offline).
|
409 |
|
410 | This option is only really useful if you're also using
|
411 | [`opts.cache`](#opts-cache).
|
412 |
|
413 | This option is set to `true` when the request includes `write=true` in the
|
414 | query string.
|
415 |
|
416 | ##### <a name="opts-otp"></a> `opts.otp`
|
417 |
|
418 | * Type: Number | String
|
419 | * Default: null
|
420 |
|
421 | This is a one-time password from a two-factor authenticator. It is required for
|
422 | certain registry interactions when two-factor auth is enabled for a user
|
423 | account.
|
424 |
|
425 | ##### <a name="opts-password"></a> `opts.password`
|
426 |
|
427 | * Alias: `_password`
|
428 | * Type: String
|
429 | * Default: null
|
430 |
|
431 | Password used for basic authentication. For the more modern authentication
|
432 | method, please use the (more secure) [`opts.token`](#opts-token)
|
433 |
|
434 | Can optionally be scoped to a registry by using a "nerf dart" for that registry.
|
435 | That is:
|
436 |
|
437 | ```
|
438 | {
|
439 | '//registry.npmjs.org/:password': 't0k3nH34r'
|
440 | }
|
441 | ```
|
442 |
|
443 | See also [`opts.username`](#opts-username)
|
444 |
|
445 | ##### <a name="opts-prefer-offline"></a> `opts.prefer-offline`
|
446 |
|
447 | * Type: Boolean
|
448 | * Default: false
|
449 |
|
450 | If true, staleness checks for cached data will be bypassed, but missing data
|
451 | will be requested from the server. To force full offline mode, use
|
452 | [`opts.offline`](#opts-offline).
|
453 |
|
454 | This option is generally only useful if you're also using
|
455 | [`opts.cache`](#opts-cache).
|
456 |
|
457 | This option is set to `false` when the request includes `write=true` in the
|
458 | query string.
|
459 |
|
460 | ##### <a name="opts-prefer-online"></a> `opts.prefer-online`
|
461 |
|
462 | * Type: Boolean
|
463 | * Default: false
|
464 |
|
465 | If true, staleness checks for cached data will be forced, making the CLI look
|
466 | for updates immediately even for fresh package data.
|
467 |
|
468 | This option is generally only useful if you're also using
|
469 | [`opts.cache`](#opts-cache).
|
470 |
|
471 | This option is set to `true` when the request includes `write=true` in the
|
472 | query string.
|
473 |
|
474 | ##### <a name="opts-project-scope"></a> `opts.project-scope`
|
475 |
|
476 | * Alias: `opts.projectScope`
|
477 | * Type: String
|
478 | * Default: null
|
479 |
|
480 | If provided, will be sent in the `npm-scope` header. This header is used by the
|
481 | npm registry to identify the toplevel package scope that a particular project
|
482 | installation is using.
|
483 |
|
484 | ##### <a name="opts-proxy"></a> `opts.proxy`
|
485 |
|
486 | * Type: url
|
487 | * Default: null
|
488 |
|
489 | A proxy to use for outgoing http requests. If not passed in, the `HTTP(S)_PROXY`
|
490 | environment variable will be used.
|
491 |
|
492 | ##### <a name="opts-query"></a> `opts.query`
|
493 |
|
494 | * Type: String | Object
|
495 | * Default: null
|
496 |
|
497 | If provided, the request URI will have a query string appended to it using this
|
498 | query. If `opts.query` is an object, it will be converted to a query string
|
499 | using
|
500 | [`querystring.stringify()`](https://nodejs.org/api/querystring.html#querystring_querystring_stringify_obj_sep_eq_options).
|
501 |
|
502 | If the request URI already has a query string, it will be merged with
|
503 | `opts.query`, preferring `opts.query` values.
|
504 |
|
505 | ##### <a name="opts-refer"></a> `opts.refer`
|
506 |
|
507 | * Alias: `opts.referer`
|
508 | * Type: String
|
509 | * Default: null
|
510 |
|
511 | Value to use for the `Referer` header. The npm CLI itself uses this to serialize
|
512 | the npm command line using the given request.
|
513 |
|
514 | ##### <a name="opts-registry"></a> `opts.registry`
|
515 |
|
516 | * Type: URL
|
517 | * Default: `'https://registry.npmjs.org'`
|
518 |
|
519 | Registry configuration for a request. If a request URL only includes the URL
|
520 | path, this registry setting will be prepended. This configuration is also used
|
521 | to determine authentication details, so even if the request URL references a
|
522 | completely different host, `opts.registry` will be used to find the auth details
|
523 | for that request.
|
524 |
|
525 | See also [`opts.scope`](#opts-scope), [`opts.spec`](#opts-spec), and
|
526 | [`opts.<scope>:registry`](#opts-scope-registry) which can all affect the actual
|
527 | registry URL used by the outgoing request.
|
528 |
|
529 | ##### <a name="opts-retry"></a> `opts.retry`
|
530 |
|
531 | * Type: Object
|
532 | * Default: null
|
533 |
|
534 | Single-object configuration for request retry settings. If passed in, will
|
535 | override individually-passed `fetch-retry-*` settings.
|
536 |
|
537 | ##### <a name="opts-scope"></a> `opts.scope`
|
538 |
|
539 | * Type: String
|
540 | * Default: null
|
541 |
|
542 | Associate an operation with a scope for a scoped registry. This option can force
|
543 | lookup of scope-specific registries and authentication.
|
544 |
|
545 | See also [`opts.<scope>:registry`](#opts-scope-registry) and
|
546 | [`opts.spec`](#opts-spec) for interactions with this option.
|
547 |
|
548 | ##### <a name="opts-scope-registry"></a> `opts.<scope>:registry`
|
549 |
|
550 | * Type: String
|
551 | * Default: null
|
552 |
|
553 | This option type can be used to configure the registry used for requests
|
554 | involving a particular scope. For example, `opts['@myscope:registry'] =
|
555 | 'https://scope-specific.registry/'` will make it so requests go out to this
|
556 | registry instead of [`opts.registry`](#opts-registry) when
|
557 | [`opts.scope`](#opts-scope) is used, or when [`opts.spec`](#opts-spec) is a
|
558 | scoped package spec.
|
559 |
|
560 | The `@` before the scope name is optional, but recommended.
|
561 |
|
562 | ##### <a name="opts-spec"></a> `opts.spec`
|
563 |
|
564 | * Type: String | [`npm-registry-arg`](https://npm.im/npm-registry-arg) object.
|
565 | * Default: null
|
566 |
|
567 | If provided, can be used to automatically configure [`opts.scope`](#opts-scope)
|
568 | based on a specific package name. Non-registry package specs will throw an
|
569 | error.
|
570 |
|
571 | ##### <a name="opts-strict-ssl"></a> `opts.strict-ssl`
|
572 |
|
573 | * Type: Boolean
|
574 | * Default: true
|
575 |
|
576 | Whether or not to do SSL key validation when making requests to the
|
577 | registry via https.
|
578 |
|
579 | See also [`opts.ca`](#opts-ca).
|
580 |
|
581 | ##### <a name="opts-timeout"></a> `opts.timeout`
|
582 |
|
583 | * Type: Milliseconds
|
584 | * Default: 0 (no timeout)
|
585 |
|
586 | Time before a hanging request times out.
|
587 |
|
588 | ##### <a name="opts-token"></a> `opts.token`
|
589 |
|
590 | * Alias: `opts._authToken`
|
591 | * Type: String
|
592 | * Default: null
|
593 |
|
594 | Authentication token string.
|
595 |
|
596 | Can be scoped to a registry by using a "nerf dart" for that registry. That is:
|
597 |
|
598 | ```
|
599 | {
|
600 | '//registry.npmjs.org/:token': 't0k3nH34r'
|
601 | }
|
602 | ```
|
603 |
|
604 | ##### <a name="opts-user-agent"></a> `opts.user-agent`
|
605 |
|
606 | * Type: String
|
607 | * Default: `'npm-registry-fetch@<version>/node@<node-version>+<arch> (<platform>)'`
|
608 |
|
609 | User agent string to send in the `User-Agent` header.
|
610 |
|
611 | ##### <a name="opts-username"></a> `opts.username`
|
612 |
|
613 | * Type: String
|
614 | * Default: null
|
615 |
|
616 | Username used for basic authentication. For the more modern authentication
|
617 | method, please use the (more secure) [`opts.token`](#opts-token)
|
618 |
|
619 | Can optionally be scoped to a registry by using a "nerf dart" for that registry.
|
620 | That is:
|
621 |
|
622 | ```
|
623 | {
|
624 | '//registry.npmjs.org/:username': 't0k3nH34r'
|
625 | }
|
626 | ```
|
627 |
|
628 | See also [`opts.password`](#opts-password)
|
629 |
|
630 | ##### <a name="opts-auth"></a> `opts._auth`
|
631 |
|
632 | * Type: String
|
633 | * Default: null
|
634 |
|
635 | ** DEPRECATED ** This is a legacy authentication token supported only for
|
636 | compatibility. Please use [`opts.token`](#opts-token) instead.
|