Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2023-07-13 09:09:17 +00:00
parent 4fad06f438
commit 40a500c743
4168 changed files with 298222 additions and 374905 deletions

6
node_modules/nock/CHANGELOG.md generated vendored
View file

@ -1,6 +0,0 @@
# Changelog
Nocks changelog can be found directly in the [GitHub release notes](https://github.com/nock/nock/releases).
These are automatically created by [semantic-release](https://github.com/semantic-release/semantic-release) based on their [commit message conventions](https://semantic-release.gitbook.io/semantic-release#commit-message-format).
Migration guides are available for major versions in the [migration guides directory](https://github.com/nock/nock/tree/main/migration_guides).

89
node_modules/nock/README.md generated vendored
View file

@ -159,7 +159,7 @@ If you dont want interceptors to be removed as they are used, you can use the
### Specifying hostname
The request hostname can be a string or a RegExp.
The request hostname can be a string, URL, or a RegExp.
```js
const scope = nock('http://www.example.com')
@ -167,6 +167,12 @@ const scope = nock('http://www.example.com')
.reply(200, 'domain matched')
```
```js
const scope = nock(new URL('http://www.example.com'))
.get('/resource')
.reply(200, 'domain matched')
```
```js
const scope = nock(/example\.com/)
.get('/resource')
@ -846,11 +852,24 @@ If you need to match requests only if certain request headers match, you can.
```js
const scope = nock('http://api.myservice.com')
// Interceptors created after here will only match when the header `accept` equals `application/json`.
.matchHeader('accept', 'application/json')
.get('/')
.reply(200, {
data: 'hello world',
})
.get('/')
// Only this interceptor will match the header value `x-my-action` with `MyFirstAction`
.matchHeader('x-my-action', 'MyFirstAction')
.reply(200, {
data: 'FirstActionResponse',
})
.get('/')
// Only this interceptor will match the header value `x-my-action` with `MySecondAction`
.matchHeader('x-my-action', 'MySecondAction')
.reply(200, {
data: 'SecondActionResponse',
})
```
You can also use a regexp for the header body.
@ -1323,6 +1342,18 @@ const interceptor = nock('http://example.org').get('somePath')
nock.removeInterceptor(interceptor)
```
**Note** `.reply(...)` method returns Scope, not Interceptor, and so it is not a valid argument for `nock.removeInterceptor`. So if your method chain ends with `.reply` to be used with `nock.removeInterceptor` the chain need to be break in between:
```js
// this will NOT work
const interceptor = nock('http://example.org').get('somePath').reply(200, 'OK')
nock.removeInterceptor(interceptor)
// this is how it should be
const interceptor = nock('http://example.org').get('somePath')
interceptor.reply(200, 'OK')
nock.removeInterceptor(interceptor)
```
## Events
A scope emits the following events:
@ -1402,6 +1433,14 @@ return nockBack('promisedFixture.json').then(({ nockDone, context }) => {
})
```
Or, with async/await:
```js
const { nockDone, context } = await nockBack('promisedFixture.json')
// your test code
nockDone()
```
#### Options
As an optional second parameter you can pass the following options
@ -1451,6 +1490,8 @@ To set the mode call `nockBack.setMode(mode)` or run the tests with the `NOCK_BA
- record: use recorded nocks, record new nocks
- update: remove recorded nocks, record nocks
- lockdown: use recorded nocks, disables all http calls even when not nocked, doesn't record
## Common issues
@ -1498,9 +1539,9 @@ import test from 'ava' // You can use any test framework.
// can't be intercepted by nock. So, configure axios to use the node adapter.
//
// References:
// https://github.com/nock/nock/issues/699#issuecomment-272708264
// https://github.com/axios/axios/issues/305
axios.defaults.adapter = require('axios/lib/adapters/http')
// https://github.com/axios/axios/pull/5277
axios.defaults.adapter = 'http'
test('can fetch test response', async t => {
// Set up the mock request.
@ -1518,6 +1559,18 @@ test('can fetch test response', async t => {
})
```
For Nock + Axios + Jest to work, you'll have to also adapt your jest.config.js, like so:
```js
const config = {
moduleNameMapper: {
// Force CommonJS build for http adapter to be available.
// via https://github.com/axios/axios/issues/5101#issuecomment-1276572468
'^axios$': require.resolve('axios'),
},
}
```
[axios]: https://github.com/axios/axios
### Memory issues with Jest
@ -1565,10 +1618,30 @@ By participating in this project you agree to abide by its terms.
Thanks goes to these wonderful people ([emoji key](https://github.com/all-contributors/all-contributors#emoji-key)):
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore -->
| [<img src="https://avatars1.githubusercontent.com/u/47910?v=4" width="100px;" alt="Pedro Teixeira"/><br /><sub><b>Pedro Teixeira</b></sub>](http://pgte.me)<br />[💻](https://github.com/nock/nock/commits?author=pgte "Code") [🚧](#maintenance-pgte "Maintenance") | [<img src="https://avatars3.githubusercontent.com/u/10771967?v=4" width="100px;" alt="n30n0v"/><br /><sub><b>n30n0v</b></sub>](https://github.com/n30n0v)<br />[💻](https://github.com/nock/nock/commits?author=n30n0v "Code") | [<img src="https://avatars3.githubusercontent.com/u/910753?v=4" width="100px;" alt="Richard Littauer"/><br /><sub><b>Richard Littauer</b></sub>](https://burntfen.com)<br />[🚧](#maintenance-RichardLitt "Maintenance") [💻](https://github.com/nock/nock/commits?author=RichardLitt "Code") [📝](#blog-RichardLitt "Blogposts") | [<img src="https://avatars1.githubusercontent.com/u/3731165?v=4" width="100px;" alt="Ian Walker-Sperber"/><br /><sub><b>Ian Walker-Sperber</b></sub>](http://ianwsperber.com)<br />[💻](https://github.com/nock/nock/commits?author=ianwsperber "Code") | [<img src="https://avatars2.githubusercontent.com/u/1505203?v=4" width="100px;" alt="Ivan Erceg"/><br /><sub><b>Ivan Erceg</b></sub>](http://ilovacha.com)<br />[💻](https://github.com/nock/nock/commits?author=ierceg "Code") [🚧](#maintenance-ierceg "Maintenance") | [<img src="https://avatars2.githubusercontent.com/u/1487036?v=4" width="100px;" alt="Paul Melnikow"/><br /><sub><b>Paul Melnikow</b></sub>](https://twitter.com/paulmelnikow)<br />[💻](https://github.com/nock/nock/commits?author=paulmelnikow "Code") [🚧](#maintenance-paulmelnikow "Maintenance") | [<img src="https://avatars3.githubusercontent.com/u/39992?v=4" width="100px;" alt="Gregor Martynus"/><br /><sub><b>Gregor Martynus</b></sub>](https://twitter.com/gr2m)<br />[💻](https://github.com/nock/nock/commits?author=gr2m "Code") [🚧](#maintenance-gr2m "Maintenance") [💼](#business-gr2m "Business development") [💵](#financial-gr2m "Financial") [📝](#blog-gr2m "Blogposts") |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| [<img src="https://avatars1.githubusercontent.com/u/6701030?v=4" width="100px;" alt="Hutson Betts"/><br /><sub><b>Hutson Betts</b></sub>](https://gitlab.com/hutson)<br />[💵](#financial-hutson "Financial") | [<img src="https://avatars2.githubusercontent.com/u/6105119?v=4" width="100px;" alt="Jonas Lilja"/><br /><sub><b>Jonas Lilja</b></sub>](http://lilja.io)<br />[💵](#financial-jlilja "Financial") [💻](https://github.com/nock/nock/commits?author=jlilja "Code") | [<img src="https://avatars0.githubusercontent.com/u/4446950?v=4" width="100px;" alt="Benjamin Ki"/><br /><sub><b>Benjamin Ki</b></sub>](https://github.com/benrki)<br />[💵](#financial-benrki "Financial") | [<img src="https://avatars2.githubusercontent.com/u/3250463?v=4" width="100px;" alt="Chad Fawcett"/><br /><sub><b>Chad Fawcett</b></sub>](http://chadf.ca)<br />[💵](#financial-chadfawcett "Financial") |
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="http://pgte.me"><img src="https://avatars1.githubusercontent.com/u/47910?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Pedro Teixeira</b></sub></a><br /><a href="https://github.com/nock/nock/commits?author=pgte" title="Code">💻</a> <a href="#maintenance-pgte" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://github.com/n30n0v"><img src="https://avatars3.githubusercontent.com/u/10771967?v=4?s=100" width="100px;" alt=""/><br /><sub><b>n30n0v</b></sub></a><br /><a href="https://github.com/nock/nock/commits?author=n30n0v" title="Code">💻</a></td>
<td align="center"><a href="https://burntfen.com"><img src="https://avatars3.githubusercontent.com/u/910753?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Richard Littauer</b></sub></a><br /><a href="#maintenance-RichardLitt" title="Maintenance">🚧</a> <a href="https://github.com/nock/nock/commits?author=RichardLitt" title="Code">💻</a> <a href="#blog-RichardLitt" title="Blogposts">📝</a></td>
<td align="center"><a href="http://ianwsperber.com"><img src="https://avatars1.githubusercontent.com/u/3731165?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ian Walker-Sperber</b></sub></a><br /><a href="https://github.com/nock/nock/commits?author=ianwsperber" title="Code">💻</a></td>
<td align="center"><a href="http://ilovacha.com"><img src="https://avatars2.githubusercontent.com/u/1505203?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ivan Erceg</b></sub></a><br /><a href="https://github.com/nock/nock/commits?author=ierceg" title="Code">💻</a> <a href="#maintenance-ierceg" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://twitter.com/paulmelnikow"><img src="https://avatars2.githubusercontent.com/u/1487036?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Paul Melnikow</b></sub></a><br /><a href="https://github.com/nock/nock/commits?author=paulmelnikow" title="Code">💻</a> <a href="#maintenance-paulmelnikow" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://twitter.com/gr2m"><img src="https://avatars3.githubusercontent.com/u/39992?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Gregor Martynus</b></sub></a><br /><a href="https://github.com/nock/nock/commits?author=gr2m" title="Code">💻</a> <a href="#maintenance-gr2m" title="Maintenance">🚧</a> <a href="#business-gr2m" title="Business development">💼</a> <a href="#financial-gr2m" title="Financial">💵</a> <a href="#blog-gr2m" title="Blogposts">📝</a></td>
</tr>
<tr>
<td align="center"><a href="https://gitlab.com/hutson"><img src="https://avatars1.githubusercontent.com/u/6701030?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Hutson Betts</b></sub></a><br /><a href="#financial-hutson" title="Financial">💵</a></td>
<td align="center"><a href="http://lilja.io"><img src="https://avatars2.githubusercontent.com/u/6105119?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jonas Lilja</b></sub></a><br /><a href="#financial-jlilja" title="Financial">💵</a> <a href="https://github.com/nock/nock/commits?author=jlilja" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/benrki"><img src="https://avatars0.githubusercontent.com/u/4446950?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Benjamin Ki</b></sub></a><br /><a href="#financial-benrki" title="Financial">💵</a></td>
<td align="center"><a href="http://chadf.ca"><img src="https://avatars2.githubusercontent.com/u/3250463?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Chad Fawcett</b></sub></a><br /><a href="#financial-chadfawcett" title="Financial">💵</a></td>
<td align="center"><a href="http://www.laurencemyers.com.au"><img src="https://avatars.githubusercontent.com/u/6336048?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Laurence Dougal Myers</b></sub></a><br /><a href="https://github.com/nock/nock/commits?author=laurence-myers" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Beretta1979"><img src="https://avatars.githubusercontent.com/u/10073962?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sébastien Van Bruaene</b></sub></a><br /><a href="https://github.com/nock/nock/commits?author=Beretta1979" title="Code">💻</a> <a href="https://github.com/nock/nock/commits?author=Beretta1979" title="Tests">⚠️</a></td>
</tr>
</table>
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->

57
node_modules/nock/lib/back.js generated vendored
View file

@ -175,6 +175,47 @@ const record = {
},
}
const update = {
setup: function () {
recorder.restore()
recorder.clear()
cleanAll()
activate()
disableNetConnect()
},
start: function (fixture, options) {
if (!fs) {
throw new Error('no fs')
}
const context = removeFixture(fixture)
recorder.record({
dont_print: true,
output_objects: true,
...options.recorder,
})
context.isRecording = true
return context
},
finish: function (fixture, options, context) {
let outputs = recorder.outputs()
if (typeof options.afterRecord === 'function') {
outputs = options.afterRecord(outputs)
}
outputs =
typeof outputs === 'string' ? outputs : JSON.stringify(outputs, null, 4)
debug('recorder outputs:', outputs)
fs.mkdirSync(path.dirname(fixture), { recursive: true })
fs.writeFileSync(fixture, outputs)
},
}
const lockdown = {
setup: function () {
recorder.restore()
@ -215,6 +256,20 @@ function load(fixture, options) {
return context
}
function removeFixture(fixture, options) {
const context = {
scopes: [],
assertScopesFinished: function () {},
}
if (fixture && fixtureExists(fixture)) {
/* istanbul ignore next - fs.unlinkSync is for node 10 support */
fs.rmSync ? fs.rmSync(fixture) : fs.unlinkSync(fixture)
}
context.isLoaded = false
return context
}
function applyHook(scopes, fn) {
if (!fn) {
return
@ -258,6 +313,8 @@ const Modes = {
record, // use recorded nocks, record new nocks
update, // allow http calls, record all nocks, don't use recorded nocks
lockdown, // use recorded nocks, disables all http calls even when not nocked, doesnt record
}

77
node_modules/nock/lib/common.js generated vendored
View file

@ -1,7 +1,8 @@
'use strict'
const debug = require('debug')('nock.common')
const set = require('lodash.set')
const isPlainObject = require('lodash/isPlainObject')
const set = require('lodash/set')
const timers = require('timers')
const url = require('url')
const util = require('util')
@ -194,7 +195,7 @@ function isJSONContent(headers) {
*
* Duplicates throw an error.
*/
function headersFieldNamesToLowerCase(headers) {
function headersFieldNamesToLowerCase(headers, throwOnDuplicate) {
if (!isPlainObject(headers)) {
throw Error('Headers must be provided as an object')
}
@ -203,9 +204,15 @@ function headersFieldNamesToLowerCase(headers) {
Object.entries(headers).forEach(([fieldName, fieldValue]) => {
const key = fieldName.toLowerCase()
if (lowerCaseHeaders[key] !== undefined) {
throw Error(
`Failed to convert header keys to lower case due to field name conflict: ${key}`
)
if (throwOnDuplicate) {
throw Error(
`Failed to convert header keys to lower case due to field name conflict: ${key}`
)
} else {
debug(
`Duplicate header provided in request: ${key}. Only the last value can be matched.`
)
}
}
lowerCaseHeaders[key] = fieldValue
})
@ -547,7 +554,7 @@ function urlToOptions(url) {
* Used for comparing decoded search parameters, request body JSON objects,
* and URL decoded request form bodies.
*
* Performs a general recursive strict comparision with two caveats:
* Performs a general recursive strict comparison with two caveats:
* - The expected data can use regexp to compare values
* - JSON path notation and nested objects are considered equal
*/
@ -602,60 +609,17 @@ function deepEqual(expected, actual) {
return expected === actual
}
/**
* Checks if `value` is a plain object, that is, an object created by the
* `Object` constructor or one with a `[[Prototype]]` of `null`.
* https://github.com/lodash/lodash/blob/588bf3e20db0ae039a822a14a8fa238c5b298e65/isPlainObject.js
*
* @param {*} value The value to check.
* @return {boolean}
*/
function isPlainObject(value) {
const isObjectLike = typeof value === 'object' && value !== null
const tag = Object.prototype.toString.call(value)
if (!isObjectLike || tag !== '[object Object]') {
return false
}
if (Object.getPrototypeOf(value) === null) {
return true
}
let proto = value
while (Object.getPrototypeOf(proto) !== null) {
proto = Object.getPrototypeOf(proto)
}
return Object.getPrototypeOf(value) === proto
}
/**
* Creates an object with the same keys as `object` and values generated
* by running each own enumerable string keyed property of `object` thru
* `iteratee`. (iteration order is not guaranteed)
* The iteratee is invoked with three arguments: (value, key, object).
* https://github.com/lodash/lodash/blob/588bf3e20db0ae039a822a14a8fa238c5b298e65/mapValue.js
*
* @param {Object} object The object to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Object} Returns the new mapped object.
*/
function mapValue(object, iteratee) {
object = Object(object)
const result = {}
Object.keys(object).forEach(key => {
result[key] = iteratee(object[key], key, object)
})
return result
}
const timeouts = []
const intervals = []
const immediates = []
const wrapTimer = (timer, ids) => (...args) => {
const id = timer(...args)
ids.push(id)
return id
}
const wrapTimer =
(timer, ids) =>
(...args) => {
const id = timer(...args)
ids.push(id)
return id
}
const setTimeout = wrapTimer(timers.setTimeout, timeouts)
const setInterval = wrapTimer(timers.setInterval, intervals)
@ -717,7 +681,6 @@ module.exports = {
isRequestDestroyed,
isStream,
isUtf8Representable,
mapValue,
matchStringOrRegexp,
normalizeClientRequestArgs,
normalizeOrigin,

View file

@ -40,7 +40,10 @@ class InterceptedRequestRouter {
// affecting the user so we use a clone of the object.
...options,
// We use lower-case header field names throughout Nock.
headers: common.headersFieldNamesToLowerCase(options.headers || {}),
headers: common.headersFieldNamesToLowerCase(
options.headers || {},
false
),
}
this.interceptors = interceptors
@ -48,8 +51,14 @@ class InterceptedRequestRouter {
// support setting `timeout` using request `options`
// https://nodejs.org/docs/latest-v12.x/api/http.html#http_http_request_url_options_callback
if (options.timeout) {
this.socket.setTimeout(options.timeout)
// any timeout in the request options override any timeout in the agent options.
// per https://github.com/nodejs/node/pull/21204
const timeout =
options.timeout ||
(options.agent && options.agent.options && options.agent.options.timeout)
if (timeout) {
this.socket.setTimeout(timeout)
}
this.response = new IncomingMessage(this.socket)
@ -134,8 +143,11 @@ class InterceptedRequestRouter {
// from docs: When write function is called with empty string or buffer, it does nothing and waits for more input.
// However, actually implementation checks the state of finished and aborted before checking if the first arg is empty.
handleWrite(buffer, encoding, callback) {
handleWrite(...args) {
debug('request write')
let [buffer, encoding] = args
const { req } = this
if (req.finished) {
@ -153,7 +165,7 @@ class InterceptedRequestRouter {
return false
}
if (!buffer || buffer.length === 0) {
if (!buffer) {
return true
}
@ -162,6 +174,9 @@ class InterceptedRequestRouter {
}
this.requestBodyBuffers.push(buffer)
// writable.write encoding param is optional
// so if callback is present it's the last argument
const callback = args.length > 1 ? args[args.length - 1] : undefined
// can't use instanceof Function because some test runners
// run tests in vm.runInNewContext where Function is not same
// as that in the current context
@ -279,9 +294,8 @@ class InterceptedRequestRouter {
const requestBodyBuffer = Buffer.concat(this.requestBodyBuffers)
// When request body is a binary buffer we internally use in its hexadecimal
// representation.
const requestBodyIsUtf8Representable = common.isUtf8Representable(
requestBodyBuffer
)
const requestBodyIsUtf8Representable =
common.isUtf8Representable(requestBodyBuffer)
const requestBodyString = requestBodyBuffer.toString(
requestBodyIsUtf8Representable ? 'utf8' : 'hex'
)

29
node_modules/nock/lib/interceptor.js generated vendored
View file

@ -66,7 +66,8 @@ module.exports = class Interceptor {
// We use lower-case header field names throughout Nock.
this.reqheaders = common.headersFieldNamesToLowerCase(
scope.scopeOptions.reqheaders || {}
scope.scopeOptions.reqheaders || {},
true
)
this.badheaders = common.headersFieldsArrayToLowerCase(
scope.scopeOptions.badheaders || []
@ -155,7 +156,7 @@ module.exports = class Interceptor {
)
// If the content is not encoded we may need to transform the response body.
// Otherwise we leave it as it is.
// Otherwise, we leave it as it is.
if (
body &&
typeof body !== 'string' &&
@ -173,10 +174,14 @@ module.exports = class Interceptor {
// https://tools.ietf.org/html/rfc7231#section-3.1.1.5
this.rawHeaders.push('Content-Type', 'application/json')
}
}
if (this.scope.contentLen) {
// https://tools.ietf.org/html/rfc7230#section-3.3.2
if (this.scope.contentLen) {
// https://tools.ietf.org/html/rfc7230#section-3.3.2
if (typeof body === 'string') {
this.rawHeaders.push('Content-Length', body.length)
} else if (Buffer.isBuffer(body)) {
this.rawHeaders.push('Content-Length', body.byteLength)
}
}
@ -412,6 +417,12 @@ module.exports = class Interceptor {
}
matchHostName(options) {
const { basePath } = this.scope
if (basePath instanceof RegExp) {
return basePath.test(options.hostname)
}
return options.hostname === this.scope.urlParts.hostname
}
@ -442,13 +453,17 @@ module.exports = class Interceptor {
markConsumed() {
this.interceptionCounter++
remove(this)
if ((this.scope.shouldPersist() || this.counter > 0) && this.filePath) {
if (
(this.scope.shouldPersist() || this.counter > 0) &&
this.interceptionCounter > 1 &&
this.filePath
) {
this.body = fs.createReadStream(this.filePath)
this.body.pause()
}
remove(this)
if (!this.scope.shouldPersist() && this.counter < 1) {
this.scope.remove(this._key, this)
}

View file

@ -1,5 +1,6 @@
'use strict'
const mapValues = require('lodash/mapValues')
const querystring = require('querystring')
const common = require('./common')
@ -43,7 +44,7 @@ module.exports = function matchBody(options, spec, body) {
}
// strip line endings from both so that we get a match no matter what OS we are running on
// if Content-Type does not contains 'multipart'
// if Content-Type does not contain 'multipart'
if (!isMultipart && typeof body === 'string') {
body = body.replace(/\r?\n|\r/g, '')
}
@ -52,8 +53,8 @@ module.exports = function matchBody(options, spec, body) {
spec = spec.replace(/\r?\n|\r/g, '')
}
// Because the nature of URL encoding, all the values in the body have been cast to strings.
// dataEqual does strict checking so we we have to cast the non-regexp values in the spec too.
// Because the nature of URL encoding, all the values in the body must be cast to strings.
// dataEqual does strict checking, so we have to cast the non-regexp values in the spec too.
if (isUrlencoded) {
spec = mapValuesDeep(spec, val => (val instanceof RegExp ? val : `${val}`))
}
@ -70,7 +71,7 @@ function mapValuesDeep(obj, cb) {
return obj.map(v => mapValuesDeep(v, cb))
}
if (common.isPlainObject(obj)) {
return common.mapValue(obj, v => mapValuesDeep(v, cb))
return mapValues(obj, v => mapValuesDeep(v, cb))
}
return cb(obj)
}

View file

@ -79,7 +79,7 @@ class ReadableBuffers extends stream.Readable {
this.buffers = buffers
}
_read(size) {
_read(_size) {
while (this.buffers.length) {
if (!this.push(this.buffers.shift())) {
return
@ -315,7 +315,7 @@ function playbackInterceptor({
// Calling `start` immediately could take the request all the way to the connection delay
// during a single microtask execution. This setImmediate stalls the playback to ensure the
// correct events are emitted first ('socket', 'finish') and any aborts in the in the queue or
// correct events are emitted first ('socket', 'finish') and any aborts in the queue or
// called during a 'finish' listener can be called.
common.setImmediate(() => {
if (!common.isRequestDestroyed(req)) {

2
node_modules/nock/lib/recorder.js generated vendored
View file

@ -168,7 +168,7 @@ let currentRecordingId = 0
const defaultRecordOptions = {
dont_print: false,
enable_reqheaders_recording: false,
logging: console.log,
logging: console.log, // eslint-disable-line no-console
output_objects: false,
use_separator: true,
}

47
node_modules/nock/lib/scope.js generated vendored
View file

@ -11,6 +11,7 @@ const debug = require('debug')('nock.scope')
const { EventEmitter } = require('events')
const Interceptor = require('./interceptor')
const { URL, Url: LegacyUrl } = url
let fs
try {
@ -20,7 +21,46 @@ try {
}
/**
* @param {string|RegExp|url.url} basePath
* Normalizes the passed url for consistent internal processing
* @param {string|LegacyUrl|URL} u
*/
function normalizeUrl(u) {
if (!(u instanceof URL)) {
if (u instanceof LegacyUrl) {
return normalizeUrl(new URL(url.format(u)))
}
// If the url is invalid, let the URL library report it
return normalizeUrl(new URL(u))
}
if (!/https?:/.test(u.protocol)) {
throw new TypeError(
`Protocol '${u.protocol}' not recognized. This commonly occurs when a hostname and port are included without a protocol, producing a URL that is valid but confusing, and probably not what you want.`
)
}
return {
href: u.href,
origin: u.origin,
protocol: u.protocol,
username: u.username,
password: u.password,
host: u.host,
hostname:
// strip brackets from IPv6
typeof u.hostname === 'string' && u.hostname.startsWith('[')
? u.hostname.slice(1, -1)
: u.hostname,
port: u.port || (u.protocol === 'http:' ? 80 : 443),
pathname: u.pathname,
search: u.search,
searchParams: u.searchParams,
hash: u.hash,
}
}
/**
* @param {string|RegExp|LegacyUrl|URL} basePath
* @param {Object} options
* @param {boolean} options.allowUnmocked
* @param {string[]} options.badheaders
@ -52,9 +92,8 @@ class Scope extends EventEmitter {
let logNamespace = String(basePath)
if (!(basePath instanceof RegExp)) {
this.urlParts = url.parse(basePath)
this.port =
this.urlParts.port || (this.urlParts.protocol === 'http:' ? 80 : 443)
this.urlParts = normalizeUrl(basePath)
this.port = this.urlParts.port
this.basePathname = this.urlParts.pathname.replace(/\/$/, '')
this.basePath = `${this.urlParts.protocol}//${this.urlParts.hostname}:${this.port}`
logNamespace = this.urlParts.host

1
node_modules/nock/lib/socket.js generated vendored
View file

@ -40,6 +40,7 @@ module.exports = class Socket extends EventEmitter {
resume() {}
ref() {}
unref() {}
write() {}
address() {
return {

33
node_modules/nock/package.json generated vendored
View file

@ -7,14 +7,14 @@
"testing",
"isolation"
],
"version": "13.1.1",
"version": "13.3.1",
"author": "Pedro Teixeira <pedro.teixeira@gmail.com>",
"repository": {
"type": "git",
"url": "https://github.com/nock/nock.git"
},
"bugs": {
"url": "http://github.com/nock/nock/issues"
"url": "https://github.com/nock/nock/issues"
},
"engines": {
"node": ">= 10.13"
@ -24,34 +24,33 @@
"dependencies": {
"debug": "^4.1.0",
"json-stringify-safe": "^5.0.1",
"lodash.set": "^4.3.2",
"lodash": "^4.17.21",
"propagate": "^2.0.0"
},
"devDependencies": {
"@sinonjs/fake-timers": "^7.0.2",
"@definitelytyped/dtslint": "^0.0.159",
"@sinonjs/fake-timers": "^10.0.0",
"assert-rejects": "^1.0.0",
"chai": "^4.1.2",
"dirty-chai": "^2.0.1",
"dtslint": "^4.0.4",
"eslint": "^7.3.1",
"eslint": "^8.8.0",
"eslint-config-prettier": "^8.1.0",
"eslint-config-standard": "^16.0.2",
"eslint-config-standard": "^17.0.0-0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-mocha": "^8.0.0",
"eslint-plugin-mocha": "^10.0.3",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-standard": "^5.0.0",
"eslint-plugin-promise": "^6.0.0",
"form-data": "^4.0.0",
"got": "^11.3.0",
"mocha": "^8.0.1",
"mocha": "^9.1.3",
"npm-run-all": "^4.1.5",
"nyc": "^15.0.0",
"prettier": "2.2.1",
"prettier": "2.7.1",
"proxyquire": "^2.1.0",
"rimraf": "^3.0.0",
"semantic-release": "^17.0.2",
"sinon": "^10.0.0",
"sinon-chai": "^3.3.0",
"semantic-release": "^19.0.2",
"sinon": "^15.0.1",
"sinon-chai": "^3.7.0",
"typescript": "^4.2.2"
},
"scripts": {
@ -60,8 +59,8 @@
"lint": "run-p lint:js lint:ts",
"lint:js": "eslint --cache --cache-location './.cache/eslint' '**/*.js'",
"lint:js:fix": "eslint --cache --cache-location './.cache/eslint' --fix '**/*.js'",
"lint:ts": "dtslint types",
"test": "nyc mocha tests",
"lint:ts": "dtslint --expectOnly types",
"test": "nyc --reporter=lcov --reporter=text mocha tests",
"test:coverage": "open coverage/lcov-report/index.html"
},
"license": "MIT",

8
node_modules/nock/types/index.d.ts generated vendored
View file

@ -198,7 +198,7 @@ declare namespace nock {
once(): this
twice(): this
thrice(): this
optionally(): this
optionally(flag?: boolean): this
delay(opts: number | { head?: number; body?: number }): this
delayBody(timeMs: number): this
@ -228,8 +228,8 @@ declare namespace nock {
}
interface Definition {
scope: string
path: string
scope: string | RegExp
path: string | RegExp
port?: number | string
method?: string
status?: number
@ -240,7 +240,7 @@ declare namespace nock {
options?: Options
}
type BackMode = 'wild' | 'dryrun' | 'record' | 'lockdown'
type BackMode = 'wild' | 'dryrun' | 'record' | 'update' | 'lockdown'
interface Back {
currentMode: BackMode