Update checked-in dependencies
This commit is contained in:
parent
4b72bef651
commit
dbb232a3d8
1389 changed files with 209949 additions and 542 deletions
4
node_modules/@mswjs/interceptors/src/RemoteHttpInterceptor.ts
generated
vendored
4
node_modules/@mswjs/interceptors/src/RemoteHttpInterceptor.ts
generated
vendored
|
|
@ -4,6 +4,7 @@ import { Interceptor } from './Interceptor'
|
|||
import { BatchInterceptor } from './BatchInterceptor'
|
||||
import { ClientRequestInterceptor } from './interceptors/ClientRequest'
|
||||
import { XMLHttpRequestInterceptor } from './interceptors/XMLHttpRequest'
|
||||
import { FetchInterceptor } from './interceptors/fetch'
|
||||
import { handleRequest } from './utils/handleRequest'
|
||||
import { RequestController } from './RequestController'
|
||||
import { FetchResponse } from './utils/fetchUtils'
|
||||
|
|
@ -30,7 +31,7 @@ export interface SerializedResponse {
|
|||
}
|
||||
|
||||
export class RemoteHttpInterceptor extends BatchInterceptor<
|
||||
[ClientRequestInterceptor, XMLHttpRequestInterceptor]
|
||||
[ClientRequestInterceptor, XMLHttpRequestInterceptor, FetchInterceptor]
|
||||
> {
|
||||
constructor() {
|
||||
super({
|
||||
|
|
@ -38,6 +39,7 @@ export class RemoteHttpInterceptor extends BatchInterceptor<
|
|||
interceptors: [
|
||||
new ClientRequestInterceptor(),
|
||||
new XMLHttpRequestInterceptor(),
|
||||
new FetchInterceptor(),
|
||||
],
|
||||
})
|
||||
}
|
||||
|
|
|
|||
33
node_modules/@mswjs/interceptors/src/interceptors/ClientRequest/agents.ts
generated
vendored
33
node_modules/@mswjs/interceptors/src/interceptors/ClientRequest/agents.ts
generated
vendored
|
|
@ -9,6 +9,7 @@ import {
|
|||
|
||||
declare module 'node:http' {
|
||||
interface Agent {
|
||||
options?: http.AgentOptions
|
||||
createConnection(options: any, callback: any): net.Socket
|
||||
}
|
||||
}
|
||||
|
|
@ -33,15 +34,23 @@ export class MockAgent extends http.Agent {
|
|||
|
||||
public createConnection(options: any, callback: any): net.Socket {
|
||||
const createConnection =
|
||||
(this.customAgent instanceof http.Agent &&
|
||||
this.customAgent.createConnection) ||
|
||||
super.createConnection
|
||||
this.customAgent instanceof http.Agent
|
||||
? this.customAgent.createConnection
|
||||
: super.createConnection
|
||||
|
||||
const createConnectionOptions =
|
||||
this.customAgent instanceof http.Agent
|
||||
? {
|
||||
...options,
|
||||
...this.customAgent.options,
|
||||
}
|
||||
: options
|
||||
|
||||
const socket = new MockHttpSocket({
|
||||
connectionOptions: options,
|
||||
createConnection: createConnection.bind(
|
||||
this.customAgent || this,
|
||||
options,
|
||||
createConnectionOptions,
|
||||
callback
|
||||
),
|
||||
onRequest: this.onRequest.bind(this),
|
||||
|
|
@ -66,15 +75,23 @@ export class MockHttpsAgent extends https.Agent {
|
|||
|
||||
public createConnection(options: any, callback: any): net.Socket {
|
||||
const createConnection =
|
||||
(this.customAgent instanceof https.Agent &&
|
||||
this.customAgent.createConnection) ||
|
||||
super.createConnection
|
||||
this.customAgent instanceof https.Agent
|
||||
? this.customAgent.createConnection
|
||||
: super.createConnection
|
||||
|
||||
const createConnectionOptions =
|
||||
this.customAgent instanceof https.Agent
|
||||
? {
|
||||
...options,
|
||||
...this.customAgent.options,
|
||||
}
|
||||
: options
|
||||
|
||||
const socket = new MockHttpSocket({
|
||||
connectionOptions: options,
|
||||
createConnection: createConnection.bind(
|
||||
this.customAgent || this,
|
||||
options,
|
||||
createConnectionOptions,
|
||||
callback
|
||||
),
|
||||
onRequest: this.onRequest.bind(this),
|
||||
|
|
|
|||
|
|
@ -341,6 +341,50 @@ it('sets fallback Agent based on the URL protocol', () => {
|
|||
expect(agent).toHaveProperty('protocol', url.protocol)
|
||||
})
|
||||
|
||||
it('preserves `requestUnauthorized` option set to undefined', () => {
|
||||
const [, options] = normalizeClientRequestArgs('https:', [
|
||||
'https://github.com',
|
||||
{ rejectUnauthorized: undefined },
|
||||
])
|
||||
|
||||
expect(options.rejectUnauthorized).toBe(undefined)
|
||||
expect((options.agent as HttpsAgent).options.rejectUnauthorized).toBe(
|
||||
undefined
|
||||
)
|
||||
})
|
||||
|
||||
it('preserves `requestUnauthorized` option set to true', () => {
|
||||
const [, options] = normalizeClientRequestArgs('https:', [
|
||||
'https://github.com',
|
||||
{ rejectUnauthorized: true },
|
||||
])
|
||||
|
||||
expect(options.rejectUnauthorized).toBe(true)
|
||||
expect((options.agent as HttpsAgent).options.rejectUnauthorized).toBe(true)
|
||||
})
|
||||
|
||||
it('preserves `requestUnauthorized` option set to false', () => {
|
||||
const [, options] = normalizeClientRequestArgs('https:', [
|
||||
'https://github.com',
|
||||
{ rejectUnauthorized: false },
|
||||
])
|
||||
|
||||
expect(options.rejectUnauthorized).toBe(false)
|
||||
expect((options.agent as HttpsAgent).options.rejectUnauthorized).toBe(false)
|
||||
})
|
||||
|
||||
it('does not add `rejectUnauthorized` value if not set', () => {
|
||||
const agent = new HttpsAgent()
|
||||
const [, options] = normalizeClientRequestArgs('https:', [
|
||||
'https://github.com',
|
||||
])
|
||||
|
||||
expect(options).not.toHaveProperty('rejectUnauthorized')
|
||||
expect((options.agent as HttpsAgent).options).not.toHaveProperty(
|
||||
'rejectUnauthorized'
|
||||
)
|
||||
})
|
||||
|
||||
it('does not set any fallback Agent given "agent: false" option', () => {
|
||||
const [, options] = normalizeClientRequestArgs('https:', [
|
||||
'https://github.com',
|
||||
|
|
|
|||
|
|
@ -243,7 +243,10 @@ export function normalizeClientRequestArgs(
|
|||
const agent =
|
||||
options.protocol === 'https:'
|
||||
? new HttpsAgent({
|
||||
rejectUnauthorized: options.rejectUnauthorized,
|
||||
// Any other value other than false is considered as true, so we don't add this property if undefined.
|
||||
...('rejectUnauthorized' in options && {
|
||||
rejectUnauthorized: options.rejectUnauthorized,
|
||||
}),
|
||||
})
|
||||
: new HttpAgent()
|
||||
|
||||
|
|
|
|||
10
node_modules/@mswjs/interceptors/src/interceptors/fetch/index.ts
generated
vendored
10
node_modules/@mswjs/interceptors/src/interceptors/fetch/index.ts
generated
vendored
|
|
@ -144,6 +144,14 @@ export class FetchInterceptor extends Interceptor<HttpRequestEventMap> {
|
|||
'no mocked response received, performing request as-is...'
|
||||
)
|
||||
|
||||
/**
|
||||
* @note Clone the request instance right before performing it.
|
||||
* This preserves any modifications made to the intercepted request
|
||||
* in the "request" listener. This also allows the user to read the
|
||||
* request body in the "response" listener (otherwise "unusable").
|
||||
*/
|
||||
const requestCloneForResponseEvent = request.clone()
|
||||
|
||||
return pureFetch(request).then(async (response) => {
|
||||
this.logger.info('original fetch performed', response)
|
||||
|
||||
|
|
@ -155,7 +163,7 @@ export class FetchInterceptor extends Interceptor<HttpRequestEventMap> {
|
|||
await emitAsync(this.emitter, 'response', {
|
||||
response: responseClone,
|
||||
isMockedResponse: false,
|
||||
request,
|
||||
request: requestCloneForResponseEvent,
|
||||
requestId,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
6
node_modules/@mswjs/interceptors/src/utils/createProxy.test.ts
generated
vendored
6
node_modules/@mswjs/interceptors/src/utils/createProxy.test.ts
generated
vendored
|
|
@ -90,8 +90,10 @@ it('spies on the constructor', () => {
|
|||
}
|
||||
|
||||
const constructorCall = vi.fn<
|
||||
[ConstructorParameters<typeof OriginalClass>, Function],
|
||||
typeof OriginalClass
|
||||
(
|
||||
args: ConstructorParameters<typeof OriginalClass>,
|
||||
next: () => typeof OriginalClass
|
||||
) => typeof OriginalClass
|
||||
>((args, next) => next())
|
||||
|
||||
const ProxyClass = createProxy(OriginalClass, {
|
||||
|
|
|
|||
2
node_modules/@mswjs/interceptors/src/utils/hasConfigurableGlobal.test.ts
generated
vendored
2
node_modules/@mswjs/interceptors/src/utils/hasConfigurableGlobal.test.ts
generated
vendored
|
|
@ -6,7 +6,7 @@ beforeAll(() => {
|
|||
})
|
||||
|
||||
afterEach(() => {
|
||||
vi.resetAllMocks()
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
afterAll(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue