Comparing version 9.0.3 to 9.0.4
@@ -213,3 +213,3 @@ const EventEmitter = require('events').EventEmitter | ||
// don't immediately retry on error - exponential back-off | ||
delay = delay ? Math.max(60000, delay * 2) : 5000 | ||
delay = delay ? Math.min(60000, delay * 2) : 5000 // up to and no more than one minute | ||
} | ||
@@ -216,0 +216,0 @@ |
@@ -104,2 +104,18 @@ // Licensed under the Apache License, Version 2.0 (the 'License'); you may not | ||
} | ||
function scrubRequest (req, cloned) { | ||
// scrub credentials | ||
req.url = scrubURL(req.url) | ||
if (req.headers.cookie) { | ||
req.headers.cookie = 'XXXXXXX' | ||
} | ||
if (req.auth) { | ||
if (!cloned) { | ||
req.auth = JSON.parse(JSON.stringify(req.auth)) // clone just auth if not already cloned | ||
} | ||
req.auth.username = SCRUBBED_STR | ||
req.auth.password = SCRUBBED_STR | ||
} | ||
} | ||
const responseHandler = function (response, req, opts, resolve, reject, callback) { | ||
@@ -115,3 +131,3 @@ const statusCode = response.status || (response.response && response.response.status) || 500 | ||
const responseHeaders = Object.assign({ | ||
uri: req.url, | ||
uri: scrubURL(req.url), | ||
statusCode: statusCode | ||
@@ -168,7 +184,3 @@ }, response.headers) | ||
// scrub credentials | ||
req.url = scrubURL(req.url) | ||
responseHeaders.uri = scrubURL(responseHeaders.uri) | ||
if (req.headers.cookie) { | ||
req.headers.cookie = 'XXXXXXX' | ||
} | ||
scrubRequest(req) | ||
@@ -207,2 +219,4 @@ log({ err: 'couch', body: body, headers: responseHeaders }) | ||
scrubRequest(req) | ||
const responseHeaders = Object.assign({ | ||
@@ -256,3 +270,6 @@ uri: req.url, | ||
uri: cfg.url | ||
}, cfg.requestDefaults) | ||
}, { | ||
...cfg.requestDefaults, | ||
headers: Object.assign(headers, cfg.requestDefaults && cfg.requestDefaults.headers ? cfg.requestDefaults.headers : {}) | ||
}) | ||
@@ -375,8 +392,8 @@ // https://github.com/mikeal/request#requestjar | ||
// scrub and log | ||
const scrubbedReq = JSON.parse(JSON.stringify(req)) | ||
scrubbedReq.url = scrubURL(scrubbedReq.url) | ||
if (scrubbedReq.auth) { | ||
scrubbedReq.auth.username = SCRUBBED_STR | ||
scrubbedReq.auth.password = SCRUBBED_STR | ||
const scrubbedReq = { | ||
method: req.method, | ||
headers: JSON.parse(JSON.stringify(req.headers)), | ||
url: req.url | ||
} | ||
scrubRequest(scrubbedReq, true) | ||
log(scrubbedReq) | ||
@@ -383,0 +400,0 @@ |
@@ -7,3 +7,3 @@ { | ||
"repository": "http://github.com/apache/couchdb-nano", | ||
"version": "9.0.3", | ||
"version": "9.0.4", | ||
"author": "Apache CouchDB <dev@couchdb.apache.org> (http://couchdb.apache.org)", | ||
@@ -10,0 +10,0 @@ "keywords": [ |
@@ -216,3 +216,11 @@ [![Build Status](https://travis-ci.org/apache/couchdb-nano.svg?branch=main)](https://travis-ci.org/apache/couchdb-nano)![Coverage](https://img.shields.io/badge/coverage-100%-ff69b4.svg)[![dependencies Status](https://david-dm.org/apache/couchdb-nano/status.svg)](https://david-dm.org/apache/couchdb-nano)[![NPM](http://img.shields.io/npm/v/nano.svg?style=flat-square)](https://www.npmjs.com/package/nano) | ||
url: 'http://localhost:5984/foo', | ||
requestDefaults: { proxy: { 'protocol': 'http', 'host': 'myproxy.net' } } | ||
requestDefaults: { | ||
proxy: { | ||
protocol: 'http', | ||
host: 'myproxy.net' | ||
}, | ||
headers: { | ||
customheader: 'MyCustomHeader' | ||
} | ||
} | ||
}; | ||
@@ -222,2 +230,19 @@ const db = require('nano')(opts); | ||
Nano works perfectly well over HTTPS as long as the SSL cert is signed by a certification authority known by your client operating system. If you have a custom or self-signed certificate, you may need to create your own HTTPS agent and pass it to Nano e.g. | ||
```js | ||
const httpsAgent = new https.Agent({ | ||
ca: '/path/to/cert', | ||
rejectUnauthorized: true, | ||
keepAlive: true, | ||
maxSockets: 6 | ||
}) | ||
const nano = Nano({ | ||
url: process.env.COUCH_URL, | ||
requestDefaults: { | ||
agent: httpsAgent, | ||
} | ||
}) | ||
``` | ||
Please check [axios] for more information on the defaults. They support features like proxies, timeout etc. | ||
@@ -301,8 +326,8 @@ | ||
### nano.db.create(name, [callback]) | ||
### nano.db.create(name, [opts], [callback]) | ||
Creates a CouchDB database with the given `name`: | ||
Creates a CouchDB database with the given `name`, with options `opts`. | ||
```js | ||
await nano.db.create('alice') | ||
await nano.db.create('alice', { n: 3 }) | ||
``` | ||
@@ -309,0 +334,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
174645
2908
1364