@zimic/interceptor 1.2.5 → 1.2.6-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-7GKHYQ2U.mjs → chunk-6GEP6R3L.mjs} +29 -25
- package/dist/chunk-6GEP6R3L.mjs.map +1 -0
- package/dist/{chunk-ZZGHTY2X.js → chunk-PB4TJVK3.js} +29 -25
- package/dist/chunk-PB4TJVK3.js.map +1 -0
- package/dist/cli.js +17 -17
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/http.js +10 -8
- package/dist/http.js.map +1 -1
- package/dist/http.mjs +10 -8
- package/dist/http.mjs.map +1 -1
- package/dist/server.js +6 -6
- package/dist/server.mjs +1 -1
- package/package.json +1 -1
- package/src/server/InterceptorServer.ts +1 -1
- package/src/server/constants.ts +1 -1
- package/src/utils/http.ts +0 -92
- package/src/webSocket/WebSocketHandler.ts +10 -10
- package/dist/chunk-7GKHYQ2U.mjs.map +0 -1
- package/dist/chunk-ZZGHTY2X.js.map +0 -1
package/dist/http.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/http/interceptor/errors/RunningHttpInterceptorError.ts","../src/http/interceptor/errors/NotRunningHttpInterceptorError.ts","../src/http/interceptor/errors/UnknownHttpInterceptorPlatformError.ts","../src/http/interceptor/errors/UnknownHttpInterceptorTypeError.ts","../src/http/interceptor/errors/RequestSavingSafeLimitExceededError.ts","../src/cli/browser/shared/constants.ts","../src/http/interceptorWorker/errors/UnregisteredBrowserServiceWorkerError.ts","../src/http/requestHandler/errors/DisabledRequestSavingError.ts","../../zimic-utils/src/data/isDefined.ts","../../zimic-utils/src/data/isNonEmpty.ts","../../zimic-utils/src/import/createCachedDynamicImport.ts","../../zimic-utils/src/logging/Logger.ts","../src/utils/environment.ts","../src/utils/files.ts","../src/utils/logging.ts","../src/http/requestHandler/errors/TimesCheckError.ts","../../zimic-utils/src/data/blobEquals.ts","../../zimic-utils/src/data/isPrimitiveJSONValue.ts","../../zimic-utils/src/data/jsonContains.ts","../../zimic-utils/src/data/jsonEquals.ts","../../zimic-utils/src/time/waitForDelay.ts","../src/utils/data.ts","../src/utils/numbers.ts","../src/http/requestHandler/errors/NoResponseDefinitionError.ts","../src/http/requestHandler/errors/TimesDeclarationPointer.ts","../src/http/requestHandler/HttpRequestHandlerClient.ts","../src/http/requestHandler/LocalHttpRequestHandler.ts","../../zimic-utils/src/url/createRegexFromPath.ts","../../zimic-utils/src/url/excludeNonPathParams.ts","../../zimic-utils/src/url/validateURLProtocol.ts","../src/utils/arrays.ts","../src/utils/http.ts","../src/http/requestHandler/types/requests.ts","../src/http/interceptorWorker/constants.ts","../src/http/interceptorWorker/HttpInterceptorWorker.ts","../src/http/requestHandler/RemoteHttpRequestHandler.ts","../src/http/interceptor/HttpInterceptorClient.ts","../../zimic-utils/src/url/validatePathParams.ts","../src/http/interceptorWorker/LocalHttpInterceptorWorker.ts","../src/utils/crypto.ts","../src/utils/fetch.ts","../src/webSocket/errors/UnauthorizedWebSocketConnectionError.ts","../src/utils/webSocket.ts","../src/webSocket/constants.ts","../src/webSocket/errors/InvalidWebSocketMessageError.ts","../src/webSocket/errors/NotRunningWebSocketHandlerError.ts","../src/webSocket/WebSocketHandler.ts","../src/webSocket/WebSocketClient.ts","../src/http/interceptorWorker/RemoteHttpInterceptorWorker.ts","../src/http/interceptorWorker/factory.ts","../src/http/interceptor/HttpInterceptorStore.ts","../src/http/interceptor/LocalHttpInterceptor.ts","../src/http/interceptor/RemoteHttpInterceptor.ts","../src/http/interceptor/factory.ts","../src/http/index.ts"],"names":["color","value","HttpHeaders","HttpSearchParams","matchesRestriction","HttpFormData","protocol","interceptor","HttpInvalidFormDataError","HttpInvalidJSONError"],"mappings":";;;;;;;;;;AAOA,IAAM,2BAAA,GAAN,cAA0C,KAAA,CAAM;AAAA,EAC9C,YAAY,iBAAA,EAA2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;AAAA,MACd;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AAAA,EAEA,MAAM,KAAA,GAAQ;AACZ,IAAA,MAAM,IAAA,CAAK,OAAO,KAAA,EAAM;AAAA,EAC1B;AACF,CAAA;AAKA,IAAO,6BAAA,GAAQ,qBAAA;;;AC3Jf,SAAS,8BAA8B,OAAA,EAAyE;AAC9G,EAAA,OAAO,OAAA,CAAQ,IAAA,KAAS,MAAA,IAAa,OAAA,CAAQ,IAAA,KAAS,OAAA;AACxD;AAEA,SAAS,+BAA+B,OAAA,EAA0E;AAChH,EAAA,OAAO,QAAQ,IAAA,KAAS,QAAA;AAC1B;AAYO,SAAS,sBACd,OAAA,EAC0E;AAC1E,EAAA,MAAM,OAAO,OAAA,CAAQ,IAAA;AAErB,EAAA,IAAI,6BAAA,CAA8B,OAAO,CAAA,EAAG;AAC1C,IAAA,OAAO,IAAI,6BAA6B,OAAO,CAAA;AAAA,EACjD,CAAA,MAAA,IAAW,8BAAA,CAA+B,OAAO,CAAA,EAAG;AAClD,IAAA,OAAO,IAAI,8BAA8B,OAAO,CAAA;AAAA,EAClD;AAEA,EAAA,MAAM,IAAI,wCAAgC,IAAI,CAAA;AAChD;;;AC6BO,IAAM,oBAAA,GAAN,cAAmCQ,sBAAA,CAAyB;AAAC;AAc7D,IAAM,gBAAA,GAAN,cAA+BC,kBAAA,CAAqB;AAAC","file":"http.mjs","sourcesContent":["/**\n * An error thrown when the interceptor is running and some operation requires it to be stopped first.\n *\n * @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorstart `interceptor.start()` API reference}\n * @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorstop `interceptor.stop()` API reference}\n * @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorisrunning `interceptor.isRunning` API reference}\n */\nclass RunningHttpInterceptorError extends Error {\n constructor(additionalMessage: string) {\n super(`The interceptor is running. ${additionalMessage}`);\n this.name = 'RunningHttpInterceptorError';\n }\n}\n\nexport default RunningHttpInterceptorError;\n","/**\n * An error thrown when the interceptor is not running and it's not possible to use the mocking utilities.\n *\n * @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorstart `interceptor.start()` API reference}\n * @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorstop `interceptor.stop()` API reference}\n * @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorisrunning `interceptor.isRunning` API reference}\n */\nclass NotRunningHttpInterceptorError extends Error {\n constructor() {\n super('Interceptor is not running. Did you forget to call `await interceptor.start()`?');\n this.name = 'NotRunningHttpInterceptorError';\n }\n}\n\nexport default NotRunningHttpInterceptorError;\n","/**\n * An error thrown when an unknown interceptor platform is detected. Currently, the platforms `node` and `browser` are\n * supported.\n *\n * @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorplatform `interceptor.platform` API reference}\n */\nclass UnknownHttpInterceptorPlatformError extends Error {\n /* istanbul ignore next -- @preserve\n * Ignoring because checking unknown platforms is currently not possible in our Vitest setup. */\n constructor() {\n super('Unknown interceptor platform.');\n this.name = 'UnknownHttpInterceptorPlatformError';\n }\n}\n\nexport default UnknownHttpInterceptorPlatformError;\n","import { HttpInterceptorType } from '../types/options';\n\nclass UnknownHttpInterceptorTypeError extends TypeError {\n constructor(unknownType: unknown) {\n super(\n `Unknown HTTP interceptor type: ${unknownType}. The available options are ` +\n `'${'local' satisfies HttpInterceptorType}' and ` +\n `'${'remote' satisfies HttpInterceptorType}'.`,\n );\n this.name = 'UnknownHttpInterceptorTypeError';\n }\n}\n\nexport default UnknownHttpInterceptorTypeError;\n","/**\n * Error thrown when the safe limit of saved intercepted requests is exceeded.\n *\n * @see {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `createHttpInterceptor` API reference}\n */\nclass RequestSavingSafeLimitExceededError extends TypeError {\n constructor(numberOfSavedRequests: number, safeLimit: number) {\n super(\n `The number of intercepted requests saved in memory (${numberOfSavedRequests}) exceeded the safe limit of ` +\n `${safeLimit}. Did you forget to call \\`interceptor.clear()\\`?\\n\\n` +\n 'If you need to save requests, make sure to regularly call `interceptor.clear()`. Alternatively, you can ' +\n 'hide this warning by increasing `requestSaving.safeLimit` in your interceptor. Note that saving too many ' +\n 'requests in memory can lead to performance issues.\\n\\n' +\n 'If you do not need to save requests, consider setting `requestSaving.enabled: false` in your ' +\n 'interceptor.\\n\\n' +\n 'Learn more: https://zimic.dev/docs/interceptor/api/create-http-interceptor',\n );\n this.name = 'RequestSavingSafeLimitExceededError';\n }\n}\n\nexport default RequestSavingSafeLimitExceededError;\n","export const SERVICE_WORKER_FILE_NAME = 'mockServiceWorker.js';\n","import { SERVICE_WORKER_FILE_NAME } from '@/cli/browser/shared/constants';\n\n/**\n * An error thrown when the browser mock service worker is not found.\n *\n * @see {@link https://zimic.dev/docs/interceptor/cli/browser#zimic-interceptor-browser-init `zimic-interceptor browser init` API reference}\n */\nclass UnregisteredBrowserServiceWorkerError extends Error {\n constructor() {\n super(\n 'Failed to register the browser service worker: ' +\n `script '${window.location.origin}/${SERVICE_WORKER_FILE_NAME}' not found.\\n\\n` +\n 'Did you forget to run `zimic-interceptor browser init <publicDirectory>`?\\n\\n' +\n 'Learn more: https://zimic.dev/docs/interceptor/cli/browser#zimic-interceptor-browser-init',\n );\n this.name = 'UnregisteredBrowserServiceWorkerError';\n }\n\n static matchesRawError(error: unknown) {\n return (\n error instanceof Error &&\n error.message.toLowerCase().includes('service worker script does not exist at the given path')\n );\n }\n}\n\nexport default UnregisteredBrowserServiceWorkerError;\n","/**\n * Error thrown when trying to access requests when the interceptor is not configured to do so.\n *\n * @see {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `createHttpInterceptor` API reference}\n */\nclass DisabledRequestSavingError extends TypeError {\n constructor() {\n super(\n 'Intercepted requests are not being saved. ' +\n 'Did you forget to use `requestSaving.enabled: true` in your interceptor?\\n\\n' +\n 'Learn more: https://zimic.dev/docs/interceptor/api/create-http-interceptor',\n );\n this.name = 'DisabledRequestSavingError';\n }\n}\n\nexport default DisabledRequestSavingError;\n","function isDefined<Value>(value: Value): value is NonNullable<Value> {\n return value !== undefined && value !== null;\n}\n\nexport default isDefined;\n","import isDefined from './isDefined';\n\nfunction isNonEmpty<Value>(value: Value): value is Exclude<NonNullable<Value>, ''> {\n return isDefined(value) && value !== '';\n}\n\nexport default isNonEmpty;\n","function createCachedDynamicImport<ImportType>(\n importModuleDynamically: () => Promise<ImportType>,\n): () => Promise<ImportType> {\n let cachedImportResult: ImportType | undefined;\n\n return async function importModuleDynamicallyWithCache() {\n cachedImportResult ??= await importModuleDynamically();\n return cachedImportResult;\n };\n}\n\nexport default createCachedDynamicImport;\n","export type TableLogRow = Record<string, string>;\n\nexport interface TableLogHeader<Row extends TableLogRow> {\n title: string;\n property: keyof Row;\n}\n\nexport interface LoggerOptions {\n prefix?: string;\n}\n\nclass Logger {\n prefix?: string;\n\n raw: Logger;\n\n constructor(options: LoggerOptions = {}) {\n const { prefix } = options;\n\n this.prefix = prefix;\n\n this.raw = prefix ? new Logger({ ...options, prefix: undefined }) : this;\n }\n\n private logWithLevel(level: 'log' | 'warn' | 'error', ...messages: unknown[]) {\n if (this.prefix) {\n console[level](this.prefix, ...messages);\n } else {\n console[level](...messages);\n }\n }\n\n info(...messages: unknown[]) {\n this.logWithLevel('log', ...messages);\n }\n\n warn(...messages: unknown[]) {\n this.logWithLevel('warn', ...messages);\n }\n\n error(...messages: unknown[]) {\n this.logWithLevel('error', ...messages);\n }\n\n table<Row extends TableLogRow>(headers: TableLogHeader<Row>[], rows: Row[]) {\n const columnLengths = headers.map((header) => {\n let maxValueLength = header.title.length;\n\n for (const row of rows) {\n const value = row[header.property];\n\n if (value.length > maxValueLength) {\n maxValueLength = value.length;\n }\n }\n\n return maxValueLength;\n });\n\n const formattedRows: string[][] = [];\n\n const horizontalLine = columnLengths.map((length) => '─'.repeat(length));\n formattedRows.push(horizontalLine, []);\n\n for (let headerIndex = 0; headerIndex < headers.length; headerIndex++) {\n const header = headers[headerIndex];\n const columnLength = columnLengths[headerIndex];\n\n const value = header.title;\n formattedRows.at(-1)?.push(value.padEnd(columnLength, ' '));\n }\n\n formattedRows.push(horizontalLine);\n\n for (const row of rows) {\n formattedRows.push([]);\n\n for (let headerIndex = 0; headerIndex < headers.length; headerIndex++) {\n const header = headers[headerIndex];\n const columnLength = columnLengths[headerIndex];\n\n const value = row[header.property];\n formattedRows.at(-1)?.push(value.padEnd(columnLength, ' '));\n }\n }\n\n formattedRows.push(horizontalLine);\n\n const formattedTable = formattedRows\n .map((row, index) => {\n const isFirstLine = index === 0;\n if (isFirstLine) {\n return `┌─${row.join('─┬─')}─┐`;\n }\n\n const isLineAfterHeaders = index === 2;\n if (isLineAfterHeaders) {\n return `├─${row.join('─┼─')}─┤`;\n }\n\n const isLastLine = index === formattedRows.length - 1;\n if (isLastLine) {\n return `└─${row.join('─┴─')}─┘`;\n }\n\n return `│ ${row.join(' │ ')} │`;\n })\n .join('\\n');\n\n this.logWithLevel('log', formattedTable);\n }\n}\n\nexport default Logger;\n","export function isServerSide() {\n return typeof process !== 'undefined' && typeof process.versions !== 'undefined';\n}\n\nexport function isClientSide() {\n return typeof window !== 'undefined' && typeof document !== 'undefined';\n}\n","import createCachedDynamicImport from '@zimic/utils/import/createCachedDynamicImport';\nimport type fs from 'fs';\n\nexport const importFile = createCachedDynamicImport(\n /* istanbul ignore next -- @preserve\n * Ignoring as Node.js >=20 provides a global File and the import fallback won't run. */\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n async () => globalThis.File ?? (await import('buffer')).File,\n);\n\nexport function isGlobalFileAvailable() {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n return globalThis.File !== undefined;\n}\n\nexport const importFilesystem = createCachedDynamicImport<typeof fs>(() => import('fs'));\n\nexport async function pathExists(path: string) {\n const fs = await importFilesystem();\n\n try {\n await fs.promises.access(path);\n return true;\n } catch {\n return false;\n }\n}\n","import { HttpFormData, HttpHeaders, HttpSearchParams } from '@zimic/http';\nimport createCachedDynamicImport from '@zimic/utils/import/createCachedDynamicImport';\nimport Logger from '@zimic/utils/logging/Logger';\nimport color from 'picocolors';\n\nimport { isClientSide } from './environment';\nimport { isGlobalFileAvailable } from './files';\n\nexport const logger = new Logger({\n prefix: color.cyan('[@zimic/interceptor]'),\n});\n\nfunction stringifyJSONToLog(value: unknown): string {\n return JSON.stringify(\n value,\n (_key, value) => {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return stringifyValueToLog(value, {\n fallback: (value) => value as string,\n });\n },\n 2,\n )\n .replace(/\\n\\s*/g, ' ')\n .replace(/\"(File { name: '.*?', type: '.*?', size: \\d*? })\"/g, '$1')\n .replace(/\"(Blob { type: '.*?', size: \\d*? })\"/g, '$1');\n}\n\nexport function stringifyValueToLog(\n value: unknown,\n options: {\n fallback?: (value: unknown) => string;\n includeClassName?: { searchParams?: boolean };\n } = {},\n): string {\n const { fallback = stringifyJSONToLog, includeClassName } = options;\n\n if (value === null || value === undefined || typeof value !== 'object') {\n return String(value);\n }\n\n if (value instanceof HttpHeaders) {\n return stringifyValueToLog(value.toObject());\n }\n\n if (value instanceof HttpHeaders || value instanceof HttpSearchParams) {\n const prefix = (includeClassName?.searchParams ?? false) ? 'URLSearchParams ' : '';\n return `${prefix}${stringifyValueToLog(value.toObject())}`;\n }\n\n if (value instanceof HttpFormData) {\n return `FormData ${stringifyValueToLog(value.toObject())}`;\n }\n\n if (isGlobalFileAvailable() && value instanceof File) {\n return `File { name: '${value.name}', type: '${value.type}', size: ${value.size} }`;\n }\n\n if (value instanceof Blob) {\n return `Blob { type: '${value.type}', size: ${value.size} }`;\n }\n\n return fallback(value);\n}\n\nconst importUtil = createCachedDynamicImport(() => import('util'));\n\nexport async function formatValueToLog(value: unknown, options: { colors?: boolean } = {}) {\n if (isClientSide()) {\n return value;\n }\n\n const { colors = true } = options;\n\n const util = await importUtil();\n\n return util.inspect(value, {\n colors,\n compact: true,\n depth: Infinity,\n maxArrayLength: Infinity,\n maxStringLength: Infinity,\n breakLength: Infinity,\n sorted: true,\n });\n}\n","import isNonEmpty from '@zimic/utils/data/isNonEmpty';\nimport { Range } from '@zimic/utils/types';\nimport color from 'picocolors';\n\nimport { HttpInterceptorRequestSaving } from '@/http/interceptor/types/public';\nimport { stringifyValueToLog } from '@/utils/logging';\n\nimport { UnmatchedHttpInterceptorRequestGroup } from '../types/restrictions';\nimport TimesDeclarationPointer from './TimesDeclarationPointer';\n\ninterface TimesCheckErrorOptions {\n requestLimits: Range<number>;\n numberOfMatchedRequests: number;\n declarationPointer: TimesDeclarationPointer | undefined;\n unmatchedRequestGroups: UnmatchedHttpInterceptorRequestGroup[];\n hasRestrictions: boolean;\n requestSaving: HttpInterceptorRequestSaving;\n}\n\nfunction createMessageHeader({\n requestLimits,\n hasRestrictions,\n numberOfMatchedRequests,\n unmatchedRequestGroups,\n}: TimesCheckErrorOptions) {\n const requestPrefix = hasRestrictions ? 'matching ' : '';\n\n return [\n 'Expected ',\n\n requestLimits.min === requestLimits.max ? 'exactly ' : 'at least ',\n requestLimits.min,\n\n requestLimits.min === requestLimits.max &&\n (requestLimits.min === 1 ? ` ${requestPrefix}request` : ` ${requestPrefix}requests`),\n\n requestLimits.min !== requestLimits.max &&\n Number.isFinite(requestLimits.max) &&\n ` and at most ${requestLimits.max}`,\n\n requestLimits.min !== requestLimits.max &&\n (requestLimits.max === 1 ? ` ${requestPrefix}request` : ` ${requestPrefix}requests`),\n\n ', but got ',\n numberOfMatchedRequests,\n '.',\n\n unmatchedRequestGroups.length > 0 &&\n `\\n\\nRequests evaluated by this handler:\\n\\n ${color.green('- Expected')}\\n ${color.red('+ Received')}`,\n ]\n .filter((part) => part !== false)\n .join('');\n}\n\nfunction createMessageDiffs({ requestSaving, unmatchedRequestGroups }: TimesCheckErrorOptions) {\n if (!requestSaving.enabled) {\n return 'Tip: use `requestSaving.enabled: true` in your interceptor for more details about the unmatched requests.';\n }\n\n return unmatchedRequestGroups\n .map(({ request, diff }, index) => {\n const requestNumber = index + 1;\n\n const messageParts = [`${requestNumber}: ${request.method} ${request.url}`];\n\n if (diff.computed) {\n messageParts.push('Computed restriction:');\n\n const stringifiedExpected = stringifyValueToLog(diff.computed.expected);\n const stringifiedReceived = stringifyValueToLog(diff.computed.received);\n\n messageParts.push(` ${color.green(`- return ${stringifiedExpected}`)}`);\n messageParts.push(` ${color.red(`+ return ${stringifiedReceived}`)}`);\n }\n\n if (diff.headers) {\n messageParts.push('Headers:');\n\n const stringifiedExpected = stringifyValueToLog(diff.headers.expected);\n const stringifiedReceived = stringifyValueToLog(diff.headers.received);\n\n messageParts.push(` ${color.green(`- ${stringifiedExpected}`)}`);\n messageParts.push(` ${color.red(`+ ${stringifiedReceived}`)}`);\n }\n\n if (diff.searchParams) {\n messageParts.push('Search params:');\n\n const stringifiedExpected = stringifyValueToLog(diff.searchParams.expected);\n const stringifiedReceived = stringifyValueToLog(diff.searchParams.received);\n\n messageParts.push(` ${color.green(`- ${stringifiedExpected}`)}`);\n messageParts.push(` ${color.red(`+ ${stringifiedReceived}`)}`);\n }\n\n if (diff.body) {\n messageParts.push('Body:');\n\n const stringifiedExpected = stringifyValueToLog(diff.body.expected, {\n includeClassName: { searchParams: true },\n });\n const stringifiedReceived = stringifyValueToLog(diff.body.received, {\n includeClassName: { searchParams: true },\n });\n\n messageParts.push(` ${color.green(`- ${stringifiedExpected}`)}`);\n messageParts.push(` ${color.red(`+ ${stringifiedReceived}`)}`);\n }\n\n return messageParts.join('\\n ');\n })\n .join('\\n\\n');\n}\n\nfunction createMessageFooter() {\n return 'Learn more: https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes';\n}\n\nfunction createMessage(options: TimesCheckErrorOptions) {\n const messageHeader = createMessageHeader(options);\n const messageDiffs = createMessageDiffs(options);\n const messageFooter = createMessageFooter();\n\n return [messageHeader, messageDiffs, messageFooter].filter(isNonEmpty).join('\\n\\n');\n}\n\nclass TimesCheckError extends TypeError {\n constructor(options: TimesCheckErrorOptions) {\n const message = createMessage(options);\n super(message);\n\n this.name = 'TimesCheckError';\n this.cause = options.declarationPointer;\n }\n}\n\nexport default TimesCheckError;\n","async function blobEquals(blob: Blob, otherBlob: Blob) {\n if (blob.type !== otherBlob.type || blob.size !== otherBlob.size) {\n return false;\n }\n\n const reader = blob.stream().getReader();\n const otherReader = otherBlob.stream().getReader();\n\n let buffer: Uint8Array = new Uint8Array(0);\n let otherBuffer: Uint8Array = new Uint8Array(0);\n\n try {\n while (true) {\n const bufferReadPromises: Promise<void>[] = [];\n\n if (buffer.length === 0) {\n bufferReadPromises.push(\n reader.read().then((result) => {\n if (!result.done) {\n buffer = result.value;\n }\n }),\n );\n }\n\n if (otherBuffer.length === 0) {\n bufferReadPromises.push(\n otherReader.read().then((result) => {\n if (!result.done) {\n otherBuffer = result.value;\n }\n }),\n );\n }\n\n await Promise.all(bufferReadPromises);\n\n const haveStreamsEndedTogether = buffer.length === 0 && otherBuffer.length === 0;\n\n if (haveStreamsEndedTogether) {\n return true;\n }\n\n const hasOneStreamEndedBeforeTheOther =\n (buffer.length === 0 && otherBuffer.length > 0) || (buffer.length > 0 && otherBuffer.length === 0);\n\n if (hasOneStreamEndedBeforeTheOther) {\n return false;\n }\n\n const minimumByteLength = Math.min(buffer.length, otherBuffer.length);\n\n for (let byteIndex = 0; byteIndex < minimumByteLength; byteIndex++) {\n if (buffer[byteIndex] !== otherBuffer[byteIndex]) {\n return false;\n }\n }\n\n buffer = buffer.slice(minimumByteLength);\n otherBuffer = otherBuffer.slice(minimumByteLength);\n }\n } finally {\n reader.releaseLock();\n otherReader.releaseLock();\n }\n}\n\nexport default blobEquals;\n","import { JSONValue } from '@/types/json';\n\nexport function isPrimitiveJSONValue<Value extends JSONValue>(value: Value): value is Exclude<Value, object> {\n return typeof value !== 'object' || value === null;\n}\n","import { JSONValue } from '@/types/json';\n\nimport { isPrimitiveJSONValue } from './isPrimitiveJSONValue';\n\nfunction jsonContains(value: JSONValue, otherValue: JSONValue): boolean {\n if (isPrimitiveJSONValue(value)) {\n return value === otherValue;\n }\n if (isPrimitiveJSONValue(otherValue)) {\n return false;\n }\n\n if (Array.isArray<JSONValue>(value)) {\n if (!Array.isArray<JSONValue>(otherValue)) {\n return false;\n }\n if (value.length < otherValue.length) {\n return false;\n }\n\n let lastMatchedIndex = -1;\n return otherValue.every((otherItem) => {\n for (let index = lastMatchedIndex + 1; index < value.length; index++) {\n if (jsonContains(value[index], otherItem)) {\n lastMatchedIndex = index;\n return true;\n }\n }\n return false;\n });\n }\n\n if (Array.isArray<JSONValue>(otherValue)) {\n return false;\n }\n\n const valueKeys = Object.keys(value);\n const otherValueKeys = Object.keys(otherValue);\n\n if (valueKeys.length < otherValueKeys.length) {\n return false;\n }\n\n return otherValueKeys.every((key) => {\n const subValue = value[key];\n const subOtherValue = otherValue[key];\n return jsonContains(subValue, subOtherValue);\n });\n}\n\nexport default jsonContains;\n","import { JSONValue } from '@/types/json';\n\nimport { isPrimitiveJSONValue } from './isPrimitiveJSONValue';\n\nfunction jsonEquals(value: JSONValue, otherValue: JSONValue): boolean {\n if (isPrimitiveJSONValue(value)) {\n return value === otherValue;\n }\n if (isPrimitiveJSONValue(otherValue)) {\n return false;\n }\n\n if (Array.isArray<JSONValue>(value)) {\n if (!Array.isArray<JSONValue>(otherValue)) {\n return false;\n }\n if (value.length !== otherValue.length) {\n return false;\n }\n return value.every((item, index) => jsonEquals(item, otherValue[index]));\n }\n\n if (Array.isArray<JSONValue>(otherValue)) {\n return false;\n }\n\n const valueKeys = Object.keys(value);\n const otherValueKeys = Object.keys(otherValue);\n\n if (valueKeys.length !== otherValueKeys.length) {\n return false;\n }\n\n return valueKeys.every((key) => {\n const subValue = value[key];\n const subOtherValue = otherValue[key];\n return jsonEquals(subValue, subOtherValue);\n });\n}\n\nexport default jsonEquals;\n","function waitForDelay(milliseconds: number) {\n return new Promise<void>((resolve) => {\n setTimeout(resolve, milliseconds);\n });\n}\n\nexport default waitForDelay;\n","import { isClientSide } from './environment';\n\nexport async function convertReadableStreamToBlob(\n stream: ReadableStream<Uint8Array<ArrayBuffer>>,\n options?: BlobPropertyBag,\n): Promise<Blob> {\n const chunks: Uint8Array<ArrayBuffer>[] = [];\n const reader = stream.getReader();\n\n while (true) {\n const result = await reader.read();\n\n if (result.value) {\n chunks.push(result.value);\n }\n\n if (result.done) {\n break;\n }\n }\n\n return new Blob(chunks, options);\n}\n\nexport function convertArrayBufferToBlob(buffer: ArrayBuffer, options?: BlobPropertyBag): Blob {\n return new Blob([buffer], options);\n}\n\nexport function convertArrayBufferToBase64(buffer: ArrayBuffer) {\n if (isClientSide()) {\n const bufferBytes = new Uint8Array(buffer);\n\n const bufferAsStringArray = [];\n for (const byte of bufferBytes) {\n const byteCode = String.fromCharCode(byte);\n bufferAsStringArray.push(byteCode);\n }\n const bufferAsString = bufferAsStringArray.join('');\n\n return btoa(bufferAsString);\n } else {\n return Buffer.from(buffer).toString('base64');\n }\n}\n\nexport function convertBase64ToArrayBuffer(base64Value: string) {\n if (isClientSide()) {\n const bufferAsString = atob(base64Value);\n const array = Uint8Array.from(bufferAsString, (character) => character.charCodeAt(0));\n return array.buffer;\n } else {\n return Buffer.from(base64Value, 'base64');\n }\n}\n\nexport const HEX_REGEX = /^[a-z0-9]+$/;\n\nexport function convertHexLengthToByteLength(hexLength: number) {\n return Math.ceil(hexLength / 2); // 1 byte = 2 hex characters\n}\n\nexport const BASE64URL_REGEX = /^[a-zA-Z0-9-_]+$/;\n\nexport function convertHexLengthToBase64urlLength(hexLength: number) {\n const byteLength = convertHexLengthToByteLength(hexLength);\n return Math.ceil((byteLength * 4) / 3); // 1 byte = 4/3 base64url characters\n}\n","export function random(lowerLimit: number, upperLimit: number): number {\n const range = Math.max(upperLimit - lowerLimit, 0);\n\n if (range === 0) {\n return lowerLimit;\n }\n\n return Math.random() * range + lowerLimit;\n}\n\nexport function randomInt(lowerLimit: number, upperLimit: number): number {\n return Math.floor(random(lowerLimit, upperLimit));\n}\n","class NoResponseDefinitionError extends TypeError {\n constructor() {\n super('Cannot generate a response without a definition. Use .respond() to set a response.');\n this.name = 'NoResponseDefinitionError';\n }\n}\n\nexport default NoResponseDefinitionError;\n","class TimesDeclarationPointer extends Error {\n constructor(minNumberOfRequests: number, maxNumberOfRequests?: number) {\n super('declared at:');\n this.name = `handler.times(${minNumberOfRequests}${\n maxNumberOfRequests === undefined ? '' : `, ${maxNumberOfRequests}`\n })`;\n }\n}\n\nexport default TimesDeclarationPointer;\n","import {\n HttpSchemaMethod,\n HttpSchemaPath,\n HttpStatusCode,\n HttpFormData,\n HttpHeaders,\n HttpSearchParams,\n HttpSchema,\n HttpRequestSearchParamsSchema,\n HttpRequestHeadersSchema,\n} from '@zimic/http';\nimport blobEquals from '@zimic/utils/data/blobEquals';\nimport jsonContains from '@zimic/utils/data/jsonContains';\nimport jsonEquals from '@zimic/utils/data/jsonEquals';\nimport waitForDelay from '@zimic/utils/time/waitForDelay';\nimport { Default, Range } from '@zimic/utils/types';\n\nimport { convertArrayBufferToBlob, convertReadableStreamToBlob } from '@/utils/data';\nimport { random } from '@/utils/numbers';\n\nimport HttpInterceptorClient from '../interceptor/HttpInterceptorClient';\nimport DisabledRequestSavingError from './errors/DisabledRequestSavingError';\nimport NoResponseDefinitionError from './errors/NoResponseDefinitionError';\nimport TimesCheckError from './errors/TimesCheckError';\nimport TimesDeclarationPointer from './errors/TimesDeclarationPointer';\nimport { InternalHttpRequestHandler } from './types/public';\nimport {\n HttpInterceptorRequest,\n HttpInterceptorResponse,\n HttpRequestHandlerResponseDeclaration,\n HttpRequestHandlerResponseDeclarationFactory,\n HttpRequestHandlerResponseDelayFactory,\n InterceptedHttpInterceptorRequest,\n} from './types/requests';\nimport {\n HttpRequestHandlerRestriction,\n RestrictionDiff,\n RestrictionDiffs,\n RestrictionMatchResult,\n HttpRequestHandlerStaticRestriction,\n UnmatchedHttpInterceptorRequestGroup,\n} from './types/restrictions';\n\nconst DEFAULT_NUMBER_OF_REQUEST_LIMITS: Range<number> = Object.freeze({\n min: 0,\n max: Infinity,\n});\n\nexport type HttpRequestHandlerRequestMatch =\n | { success: true }\n | { success: false; cause: 'missingResponseDeclaration' | 'exceededNumberOfRequests' }\n | { success: false; cause: 'unmatchedRestrictions'; diff: RestrictionDiffs };\n\nclass HttpRequestHandlerClient<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath<Schema, Method>,\n StatusCode extends HttpStatusCode = never,\n> {\n private restrictions: HttpRequestHandlerRestriction<Schema, Method, Path>[] = [];\n\n private limits = {\n numberOfRequests: DEFAULT_NUMBER_OF_REQUEST_LIMITS,\n };\n\n private timesPointer?: TimesDeclarationPointer;\n\n private numberOfMatchedRequests = 0;\n private unmatchedRequestGroups: UnmatchedHttpInterceptorRequestGroup[] = [];\n private _requests: InterceptedHttpInterceptorRequest<Path, Default<Schema[Path][Method]>, StatusCode>[] = [];\n\n private createResponseDeclaration?: HttpRequestHandlerResponseDeclarationFactory<\n Path,\n Default<Schema[Path][Method]>,\n StatusCode\n >;\n\n private createResponseDelay?: HttpRequestHandlerResponseDelayFactory<Path, Default<Schema[Path][Method]>>;\n\n constructor(\n private interceptor: HttpInterceptorClient<Schema>,\n public method: Method,\n public path: Path,\n private handler: InternalHttpRequestHandler<Schema, Method, Path, StatusCode>,\n ) {}\n\n with(restriction: HttpRequestHandlerRestriction<Schema, Method, Path>): this {\n this.restrictions.push(restriction);\n return this;\n }\n\n delay(\n minMilliseconds: number | HttpRequestHandlerResponseDelayFactory<Path, Default<Schema[Path][Method]>>,\n maxMilliseconds?: number,\n ): this {\n if (minMilliseconds === maxMilliseconds) {\n return this.delay(minMilliseconds);\n }\n\n if (typeof minMilliseconds === 'number' && typeof maxMilliseconds === 'number') {\n this.createResponseDelay = () => random(minMilliseconds, maxMilliseconds);\n return this;\n }\n\n if (typeof minMilliseconds === 'number') {\n this.createResponseDelay = () => minMilliseconds;\n return this;\n }\n\n this.createResponseDelay = minMilliseconds;\n return this;\n }\n\n respond<NewStatusCode extends HttpStatusCode>(\n declaration:\n | HttpRequestHandlerResponseDeclaration<Default<Schema[Path][Method]>, NewStatusCode>\n | HttpRequestHandlerResponseDeclarationFactory<Path, Default<Schema[Path][Method]>, NewStatusCode>,\n ): HttpRequestHandlerClient<Schema, Method, Path, NewStatusCode> {\n const newThis = this as unknown as HttpRequestHandlerClient<Schema, Method, Path, NewStatusCode>;\n\n newThis.createResponseDeclaration = this.isResponseDeclarationFactory(declaration)\n ? declaration\n : () => declaration;\n\n newThis.numberOfMatchedRequests = 0;\n newThis.unmatchedRequestGroups.length = 0;\n\n newThis.clearInterceptedRequests();\n\n this.interceptor.registerRequestHandler(this.handler);\n\n return newThis;\n }\n\n private isResponseDeclarationFactory(\n declaration:\n | HttpRequestHandlerResponseDeclaration<Default<Schema[Path][Method]>>\n | HttpRequestHandlerResponseDeclarationFactory<Path, Default<Schema[Path][Method]>>,\n ) {\n return typeof declaration === 'function';\n }\n\n times(\n minNumberOfRequests: number,\n maxNumberOfRequests?: number,\n ): HttpRequestHandlerClient<Schema, Method, Path, StatusCode> {\n this.limits.numberOfRequests = {\n min: minNumberOfRequests,\n max: maxNumberOfRequests ?? minNumberOfRequests,\n };\n\n this.timesPointer = new TimesDeclarationPointer(minNumberOfRequests, maxNumberOfRequests);\n\n return this;\n }\n\n checkTimes() {\n const isWithinLimits =\n this.numberOfMatchedRequests >= this.limits.numberOfRequests.min &&\n this.numberOfMatchedRequests <= this.limits.numberOfRequests.max;\n\n if (!isWithinLimits) {\n throw new TimesCheckError({\n requestLimits: this.limits.numberOfRequests,\n numberOfMatchedRequests: this.numberOfMatchedRequests,\n declarationPointer: this.timesPointer,\n unmatchedRequestGroups: this.unmatchedRequestGroups,\n hasRestrictions: this.restrictions.length > 0,\n requestSaving: this.interceptor.requestSaving,\n });\n }\n }\n\n clear(): this {\n this.restrictions.length = 0;\n\n this.limits = {\n numberOfRequests: DEFAULT_NUMBER_OF_REQUEST_LIMITS,\n };\n\n this.timesPointer = undefined;\n\n this.numberOfMatchedRequests = 0;\n this.unmatchedRequestGroups.length = 0;\n\n this.clearInterceptedRequests();\n\n this.createResponseDeclaration = undefined;\n this.createResponseDelay = undefined;\n\n return this;\n }\n\n async matchesRequest(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n ): Promise<HttpRequestHandlerRequestMatch> {\n const restrictionsMatch = await this.matchesRestrictions(request);\n\n if (!restrictionsMatch.success) {\n return { success: false, cause: 'unmatchedRestrictions', diff: restrictionsMatch.diff };\n }\n\n const hasResponseDeclaration = this.createResponseDeclaration !== undefined;\n\n if (!hasResponseDeclaration) {\n return { success: false, cause: 'missingResponseDeclaration' };\n }\n\n const canAcceptMoreRequests = this.numberOfMatchedRequests < this.limits.numberOfRequests.max;\n\n if (!canAcceptMoreRequests) {\n return { success: false, cause: 'exceededNumberOfRequests' };\n }\n\n return { success: true };\n }\n\n markRequestAsMatched(_request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>) {\n this.numberOfMatchedRequests++;\n }\n\n markRequestAsUnmatched(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n options: { diff: RestrictionDiffs },\n ) {\n const shouldSaveUnmatchedRequests =\n this.interceptor.requestSaving.enabled && this.restrictions.length > 0 && this.timesPointer !== undefined;\n\n if (shouldSaveUnmatchedRequests) {\n this.unmatchedRequestGroups.push({ request, diff: options.diff });\n }\n }\n\n async matchesRestrictions(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n ): Promise<RestrictionMatchResult<RestrictionDiffs>> {\n for (const restriction of this.restrictions) {\n if (this.isComputedRequestRestriction(restriction)) {\n const matchesComputedRestriction = await restriction(request);\n\n if (!matchesComputedRestriction) {\n return {\n success: false,\n diff: { computed: { expected: true, received: false } },\n };\n }\n\n continue;\n }\n\n const matchesHeadersRestrictions = this.matchesRequestHeadersRestrictions(request, restriction);\n const matchesSearchParamsRestrictions = this.matchesRequestSearchParamsRestrictions(request, restriction);\n const matchesBodyRestrictions = await this.matchesRequestBodyRestrictions(request, restriction);\n\n const matchesRestriction =\n matchesHeadersRestrictions.success &&\n matchesSearchParamsRestrictions.success &&\n matchesBodyRestrictions.success;\n\n if (!matchesRestriction) {\n return {\n success: false,\n diff: {\n headers: matchesHeadersRestrictions.diff,\n searchParams: matchesSearchParamsRestrictions.diff,\n body: matchesBodyRestrictions.diff,\n },\n };\n }\n }\n\n return { success: true };\n }\n\n private matchesRequestHeadersRestrictions(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n restriction: HttpRequestHandlerStaticRestriction<Schema, Method, Path>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): RestrictionMatchResult<RestrictionDiff<HttpHeaders<any>>> {\n if (restriction.headers === undefined) {\n return { success: true };\n }\n\n const restrictedHeaders = new HttpHeaders(\n restriction.headers as Default<HttpRequestHeadersSchema<Default<Schema[Path][Method]>>>,\n );\n\n const matchesRestriction = restriction.exact\n ? request.headers.equals(restrictedHeaders)\n : request.headers.contains(restrictedHeaders);\n\n return matchesRestriction\n ? { success: true }\n : {\n success: false,\n diff: { expected: restrictedHeaders, received: request.headers },\n };\n }\n\n private matchesRequestSearchParamsRestrictions(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n restriction: HttpRequestHandlerStaticRestriction<Schema, Method, Path>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): RestrictionMatchResult<RestrictionDiff<HttpSearchParams<any>>> {\n if (restriction.searchParams === undefined) {\n return { success: true };\n }\n\n const restrictedSearchParams = new HttpSearchParams(\n restriction.searchParams as Default<HttpRequestSearchParamsSchema<Default<Schema[Path][Method]>>>,\n );\n\n const matchesRestriction = restriction.exact\n ? request.searchParams.equals(restrictedSearchParams)\n : request.searchParams.contains(restrictedSearchParams);\n\n return matchesRestriction\n ? { success: true }\n : {\n success: false,\n diff: { expected: restrictedSearchParams, received: request.searchParams },\n };\n }\n\n private async matchesRequestBodyRestrictions(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n restriction: HttpRequestHandlerStaticRestriction<Schema, Method, Path>,\n ): Promise<RestrictionMatchResult<RestrictionDiff<unknown>>> {\n if (restriction.body === undefined) {\n return { success: true };\n }\n\n const body = request.body as unknown;\n const restrictionBody = restriction.body as unknown;\n\n if (typeof body === 'string' && typeof restrictionBody === 'string') {\n const matchesRestriction = restriction.exact ? body === restrictionBody : body.includes(restrictionBody);\n\n return matchesRestriction\n ? { success: true }\n : {\n success: false,\n diff: { expected: restrictionBody, received: body },\n };\n }\n\n if (restrictionBody instanceof HttpFormData) {\n if (!(body instanceof HttpFormData)) {\n return {\n success: false,\n diff: { expected: restrictionBody, received: body },\n };\n }\n\n const matchesRestriction = restriction.exact\n ? await body.equals(restrictionBody)\n : await body.contains(restrictionBody);\n\n return matchesRestriction\n ? { success: true }\n : {\n success: false,\n diff: { expected: restrictionBody, received: body },\n };\n }\n\n if (restrictionBody instanceof HttpSearchParams) {\n if (!(body instanceof HttpSearchParams)) {\n return {\n success: false,\n diff: { expected: restrictionBody, received: body },\n };\n }\n\n const matchesRestriction = restriction.exact ? body.equals(restrictionBody) : body.contains(restrictionBody);\n\n return matchesRestriction\n ? { success: true }\n : {\n success: false,\n diff: { expected: restrictionBody, received: body },\n };\n }\n\n if (\n restrictionBody instanceof Blob ||\n restrictionBody instanceof ArrayBuffer ||\n restrictionBody instanceof ReadableStream\n ) {\n if (!(body instanceof Blob)) {\n return {\n success: false,\n diff: { expected: restrictionBody, received: body },\n };\n }\n\n let restrictionBodyAsBlob: Blob;\n\n if (restrictionBody instanceof ArrayBuffer) {\n restrictionBodyAsBlob = convertArrayBufferToBlob(restrictionBody, { type: body.type });\n } else if (restrictionBody instanceof ReadableStream) {\n restrictionBodyAsBlob = await convertReadableStreamToBlob(\n restrictionBody as ReadableStream<Uint8Array<ArrayBuffer>>,\n { type: body.type },\n );\n } else {\n restrictionBodyAsBlob = restrictionBody;\n }\n\n const matchesRestriction = await blobEquals(body, restrictionBodyAsBlob);\n\n return matchesRestriction\n ? { success: true }\n : {\n success: false,\n diff: { expected: restrictionBody, received: body },\n };\n }\n\n const matchesRestriction = restriction.exact\n ? jsonEquals(request.body, restriction.body)\n : jsonContains(request.body, restriction.body);\n\n return matchesRestriction\n ? { success: true }\n : {\n success: false,\n diff: { expected: restrictionBody, received: body },\n };\n }\n\n private isComputedRequestRestriction(restriction: HttpRequestHandlerRestriction<Schema, Method, Path>) {\n return typeof restriction === 'function';\n }\n\n async applyResponseDeclaration(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n ): Promise<HttpRequestHandlerResponseDeclaration<Default<Schema[Path][Method]>, StatusCode>> {\n if (!this.createResponseDeclaration) {\n throw new NoResponseDefinitionError();\n }\n\n if (this.createResponseDelay) {\n const delay = await this.createResponseDelay(request);\n\n if (delay > 0) {\n await waitForDelay(delay);\n }\n }\n\n const appliedDeclaration = await this.createResponseDeclaration(request);\n return appliedDeclaration;\n }\n\n saveInterceptedRequest(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n response: HttpInterceptorResponse<Default<Schema[Path][Method]>, StatusCode>,\n ) {\n const interceptedRequest = this.createInterceptedRequest(request, response);\n this._requests.push(interceptedRequest);\n this.interceptor.incrementNumberOfSavedRequests(1);\n }\n\n private clearInterceptedRequests() {\n this.interceptor.incrementNumberOfSavedRequests(-this._requests.length);\n this._requests.length = 0;\n }\n\n private createInterceptedRequest(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n response: HttpInterceptorResponse<Default<Schema[Path][Method]>, StatusCode>,\n ) {\n const interceptedRequest = request as InterceptedHttpInterceptorRequest<\n Path,\n Default<Schema[Path][Method]>,\n StatusCode\n >;\n\n Object.defineProperty(interceptedRequest, 'response', {\n value: response,\n enumerable: true,\n configurable: false,\n writable: false,\n });\n\n return interceptedRequest;\n }\n\n get requests(): readonly InterceptedHttpInterceptorRequest<Path, Default<Schema[Path][Method]>, StatusCode>[] {\n if (!this.interceptor.requestSaving.enabled) {\n throw new DisabledRequestSavingError();\n }\n\n return this._requests;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyHttpRequestHandlerClient = HttpRequestHandlerClient<any, any, any, any>;\n\nexport default HttpRequestHandlerClient;\n","import { HttpSchema, HttpSchemaMethod, HttpSchemaPath, HttpStatusCode } from '@zimic/http';\nimport { Default } from '@zimic/utils/types';\n\nimport HttpInterceptorClient from '../interceptor/HttpInterceptorClient';\nimport HttpRequestHandlerClient from './HttpRequestHandlerClient';\nimport { InternalHttpRequestHandler } from './types/public';\nimport {\n HttpInterceptorRequest,\n HttpInterceptorResponse,\n HttpRequestHandlerResponseDeclaration,\n HttpRequestHandlerResponseDeclarationFactory,\n HttpRequestHandlerResponseDelayFactory,\n InterceptedHttpInterceptorRequest,\n} from './types/requests';\nimport { HttpRequestHandlerRestriction } from './types/restrictions';\n\nclass LocalHttpRequestHandler<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath<Schema, Method>,\n StatusCode extends HttpStatusCode = never,\n> implements InternalHttpRequestHandler<Schema, Method, Path, StatusCode> {\n readonly type = 'local';\n\n client: HttpRequestHandlerClient<Schema, Method, Path, StatusCode>;\n\n constructor(interceptor: HttpInterceptorClient<Schema>, method: Method, path: Path) {\n this.client = new HttpRequestHandlerClient(interceptor, method, path, this);\n }\n\n get method() {\n return this.client.method;\n }\n\n get path() {\n return this.client.path;\n }\n\n with(restriction: HttpRequestHandlerRestriction<Schema, Method, Path>): this {\n this.client.with(restriction);\n return this;\n }\n\n delay(\n minMilliseconds: number | HttpRequestHandlerResponseDelayFactory<Path, Default<Schema[Path][Method]>>,\n maxMilliseconds?: number,\n ): this {\n this.client.delay(minMilliseconds, maxMilliseconds);\n return this;\n }\n\n respond<NewStatusCode extends HttpStatusCode>(\n declaration:\n | HttpRequestHandlerResponseDeclaration<Default<Schema[Path][Method]>, NewStatusCode>\n | HttpRequestHandlerResponseDeclarationFactory<Path, Default<Schema[Path][Method]>, NewStatusCode>,\n ): LocalHttpRequestHandler<Schema, Method, Path, NewStatusCode> {\n this.client.respond(declaration);\n\n const newThis = this as unknown as LocalHttpRequestHandler<Schema, Method, Path, NewStatusCode>;\n return newThis;\n }\n\n times(minNumberOfRequests: number, maxNumberOfRequests?: number): this {\n this.client.times(minNumberOfRequests, maxNumberOfRequests);\n return this;\n }\n\n checkTimes() {\n this.client.checkTimes();\n }\n\n clear(): this {\n this.client.clear();\n return this;\n }\n\n get requests(): readonly InterceptedHttpInterceptorRequest<Path, Default<Schema[Path][Method]>, StatusCode>[] {\n return this.client.requests;\n }\n\n async matchesRequest(request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>) {\n const requestMatch = await this.client.matchesRequest(request);\n\n if (requestMatch.success) {\n this.client.markRequestAsMatched(request);\n } else if (requestMatch.cause === 'unmatchedRestrictions') {\n this.client.markRequestAsUnmatched(request, { diff: requestMatch.diff });\n } else {\n this.client.markRequestAsMatched(request);\n }\n\n return requestMatch;\n }\n\n async applyResponseDeclaration(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n ): Promise<HttpRequestHandlerResponseDeclaration<Default<Schema[Path][Method]>, StatusCode>> {\n return this.client.applyResponseDeclaration(request);\n }\n\n saveInterceptedRequest(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n response: HttpInterceptorResponse<Default<Schema[Path][Method]>, StatusCode>,\n ) {\n this.client.saveInterceptedRequest(request, response);\n }\n}\n\nexport type AnyLocalHttpRequestHandler =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | LocalHttpRequestHandler<any, any, any>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | LocalHttpRequestHandler<any, any, any, any>;\n\nexport default LocalHttpRequestHandler;\n","export function createPathCharactersToEscapeRegex() {\n return /([.(){}+$])/g;\n}\n\nexport function preparePathForRegex(path: string) {\n // We encode the path using the URL API because, differently from encodeURI and encodeURIComponent, URL does not\n // re-encode already encoded characters. Since URL requires a full URL, we use a data scheme and strip it later.\n const pathURLPrefix = `data:${path.startsWith('/') ? '' : '/'}`;\n const pathAsURL = new URL(`${pathURLPrefix}${path}`);\n const encodedPath = pathAsURL.href.replace(pathURLPrefix, '');\n\n return encodedPath.replace(/^\\/+/g, '').replace(/\\/+$/g, '').replace(createPathCharactersToEscapeRegex(), '\\\\$1');\n}\n\n// Path params names must match the JavaScript identifier pattern.\n// See // https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#identifiers.\nexport function createPathParamRegex() {\n return /(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)(?!\\\\[*+?])/gu;\n}\n\nexport function createRepeatingPathParamRegex() {\n return /(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)\\\\\\+/gu;\n}\n\nexport function createOptionalPathParamRegex() {\n return /(?<leadingSlash>\\/)?(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)\\?(?<trailingSlash>\\/)?/gu;\n}\n\nexport function createOptionalRepeatingPathParamRegex() {\n return /(?<leadingSlash>\\/)?(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)\\*(?<trailingSlash>\\/)?/gu;\n}\n\nfunction createRegexFromPath(path: string) {\n const pathRegexContent = preparePathForRegex(path)\n .replace(\n createOptionalRepeatingPathParamRegex(),\n (\n _match,\n leadingSlash: string | undefined,\n escape: string | undefined,\n identifier: string,\n trailingSlash: string | undefined,\n ) => {\n if (escape) {\n return `${leadingSlash ?? ''}:${identifier}\\\\*${trailingSlash ?? ''}`;\n }\n\n const hasSegmentBeforePrefix = leadingSlash === '/';\n const prefixExpression = hasSegmentBeforePrefix ? '/?' : leadingSlash;\n\n const hasSegmentAfterSuffix = trailingSlash === '/';\n const suffixExpression = hasSegmentAfterSuffix ? '/?' : trailingSlash;\n\n if (prefixExpression && suffixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>.+?)?${suffixExpression})?`;\n } else if (prefixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>.+?))?`;\n } else if (suffixExpression) {\n return `(?:(?<${identifier}>.+?)${suffixExpression})?`;\n } else {\n return `(?<${identifier}>.+?)?`;\n }\n },\n )\n .replace(createRepeatingPathParamRegex(), (_match, escape: string | undefined, identifier: string) => {\n return escape ? `:${identifier}\\\\+` : `(?<${identifier}>.+)`;\n })\n .replace(\n createOptionalPathParamRegex(),\n (\n _match,\n leadingSlash: string | undefined,\n escape: string | undefined,\n identifier: string,\n trailingSlash: string | undefined,\n ) => {\n if (escape) {\n return `${leadingSlash ?? ''}:${identifier}\\\\?${trailingSlash ?? ''}`;\n }\n\n const hasSegmentBeforePrefix = leadingSlash === '/';\n const prefixExpression = hasSegmentBeforePrefix ? '/?' : leadingSlash;\n\n const hasSegmentAfterSuffix = trailingSlash === '/';\n const suffixExpression = hasSegmentAfterSuffix ? '/?' : trailingSlash;\n\n if (prefixExpression && suffixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>[^\\\\/]+?)?${suffixExpression})`;\n } else if (prefixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>[^\\\\/]+?))?`;\n } else if (suffixExpression) {\n return `(?:(?<${identifier}>[^\\\\/]+?)${suffixExpression})?`;\n } else {\n return `(?<${identifier}>[^\\\\/]+?)?`;\n }\n },\n )\n .replace(createPathParamRegex(), (_match, escape: string | undefined, identifier: string) => {\n return escape ? `:${identifier}` : `(?<${identifier}>[^\\\\/]+?)`;\n });\n\n return new RegExp(`^/?${pathRegexContent}/?$`);\n}\n\nexport default createRegexFromPath;\n","function excludeNonPathParams(url: URL) {\n url.hash = '';\n url.search = '';\n url.username = '';\n url.password = '';\n return url;\n}\n\nexport default excludeNonPathParams;\n","export class UnsupportedURLProtocolError extends TypeError {\n constructor(protocol: string, availableProtocols: string[] | readonly string[]) {\n super(\n `Unsupported URL protocol: '${protocol}'. ` +\n `The available options are ${availableProtocols.map((protocol) => `'${protocol}'`).join(', ')}`,\n );\n this.name = 'UnsupportedURLProtocolError';\n }\n}\n\nfunction validateURLProtocol(url: URL, protocols: string[] | readonly string[]) {\n const protocol = url.protocol.replace(/:$/, '');\n\n if (!protocols.includes(protocol)) {\n throw new UnsupportedURLProtocolError(protocol, protocols);\n }\n}\n\nexport default validateURLProtocol;\n","export function removeArrayIndex<Item>(array: Item[], index: number) {\n if (index >= 0 && index < array.length) {\n array.splice(index, 1);\n }\n return array;\n}\n\nexport function removeArrayElement<Item>(array: Item[], element: Item) {\n const index = array.indexOf(element);\n return removeArrayIndex(array, index);\n}\n","import { HttpMethod } from '@zimic/http';\nimport { Server as HttpServer } from 'http';\n\nclass HttpServerTimeoutError extends Error {}\n\nexport class HttpServerStartTimeoutError extends HttpServerTimeoutError {\n constructor(reachedTimeout: number) {\n super(`HTTP server start timed out after ${reachedTimeout}ms.`);\n this.name = 'HttpServerStartTimeoutError';\n }\n}\n\nexport class HttpServerStopTimeoutError extends HttpServerTimeoutError {\n constructor(reachedTimeout: number) {\n super(`HTTP server stop timed out after ${reachedTimeout}ms.`);\n this.name = 'HttpServerStopTimeoutError';\n }\n}\n\nexport const DEFAULT_HTTP_SERVER_LIFECYCLE_TIMEOUT = 60 * 1000;\n\nexport async function startHttpServer(\n server: HttpServer,\n options: {\n hostname?: string;\n port?: number;\n timeout?: number;\n } = {},\n) {\n const { hostname, port, timeout: timeoutDuration = DEFAULT_HTTP_SERVER_LIFECYCLE_TIMEOUT } = options;\n\n await new Promise<void>((resolve, reject) => {\n function handleStartError(error: unknown) {\n server.off('listening', handleStartSuccess); // eslint-disable-line @typescript-eslint/no-use-before-define\n reject(error);\n }\n\n const startTimeout = setTimeout(() => {\n const timeoutError = new HttpServerStartTimeoutError(timeoutDuration);\n handleStartError(timeoutError);\n }, timeoutDuration);\n\n function handleStartSuccess() {\n server.off('error', handleStartError);\n clearTimeout(startTimeout);\n resolve();\n }\n\n server.once('error', handleStartError);\n server.listen(port, hostname, handleStartSuccess);\n });\n}\n\nexport async function stopHttpServer(server: HttpServer, options: { timeout?: number } = {}) {\n const { timeout: timeoutDuration = DEFAULT_HTTP_SERVER_LIFECYCLE_TIMEOUT } = options;\n\n if (!server.listening) {\n return;\n }\n\n await new Promise<void>((resolve, reject) => {\n const stopTimeout = setTimeout(() => {\n const timeoutError = new HttpServerStopTimeoutError(timeoutDuration);\n reject(timeoutError);\n }, timeoutDuration);\n\n server.close((error) => {\n clearTimeout(stopTimeout);\n\n /* istanbul ignore if -- @preserve\n * This is expected not to happen since the servers are not stopped unless they are running. */\n if (error) {\n reject(error);\n } else {\n resolve();\n }\n });\n\n server.closeAllConnections();\n });\n}\n\nexport function getHttpServerPort(server: HttpServer) {\n const address = server.address();\n\n /* istanbul ignore if -- @preserve\n * The address is expected to be an object because the server does not listen on a pipe or Unix domain socket. */\n if (typeof address === 'string') {\n return undefined;\n } else {\n return address?.port;\n }\n}\n\nexport const HTTP_METHODS_WITH_REQUEST_BODY = new Set<HttpMethod>(['POST', 'PUT', 'PATCH', 'DELETE']);\n\nexport const HTTP_METHODS_WITH_RESPONSE_BODY = new Set<HttpMethod>([\n 'GET',\n 'POST',\n 'PUT',\n 'PATCH',\n 'DELETE',\n 'OPTIONS',\n]);\n\nexport function methodCanHaveResponseBody(method: HttpMethod) {\n return HTTP_METHODS_WITH_RESPONSE_BODY.has(method);\n}\n","import {\n HttpHeaders,\n HttpHeadersInit,\n HttpMethodSchema,\n HttpRequest,\n HttpRequestBodySchema,\n HttpRequestHeadersSchema,\n HttpRequestSearchParamsSchema,\n HttpResponse,\n HttpResponseBodySchema,\n HttpResponseHeadersSchema,\n HttpResponseSchema,\n HttpSearchParams,\n HttpStatusCode,\n InferPathParams,\n} from '@zimic/http';\nimport { Default, PartialByKey, PossiblePromise, Replace } from '@zimic/utils/types';\n\ntype HttpRequestHandlerResponseBody<\n ResponseSchema extends HttpResponseSchema,\n StatusCode extends HttpStatusCode,\n> = HttpResponseBodySchema<{ response: { [Code in StatusCode]: ResponseSchema } }, StatusCode>;\n\nexport type HttpRequestHandlerResponseWithBody<\n ResponseSchema extends HttpResponseSchema,\n StatusCode extends HttpStatusCode,\n> = unknown extends ResponseSchema['body']\n ? { body?: null }\n : undefined extends ResponseSchema['body']\n ? { body?: HttpRequestHandlerResponseBody<ResponseSchema, StatusCode> }\n : { body: HttpRequestHandlerResponseBody<ResponseSchema, StatusCode> };\n\ntype HttpRequestHandlerResponseDeclarationHeaders<ResponseSchema extends HttpResponseSchema> = HttpHeadersInit<\n PartialByKey<Default<ResponseSchema['headers']>, 'content-type'>\n>;\n\nexport type HttpRequestHandlerResponseDeclarationWithHeaders<ResponseSchema extends HttpResponseSchema> =\n undefined extends ResponseSchema['headers']\n ? { headers?: HttpRequestHandlerResponseDeclarationHeaders<ResponseSchema> }\n : Exclude<keyof ResponseSchema['headers'], symbol> extends 'content-type'\n ? { headers?: HttpRequestHandlerResponseDeclarationHeaders<ResponseSchema> }\n : { headers: HttpRequestHandlerResponseDeclarationHeaders<ResponseSchema> };\n\n/** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrespond `handler.respond()` API reference} */\nexport type HttpRequestHandlerResponseDeclaration<\n MethodSchema extends HttpMethodSchema = HttpMethodSchema,\n StatusCode extends HttpStatusCode = HttpStatusCode,\n> = StatusCode extends StatusCode\n ? { status: StatusCode } & HttpRequestHandlerResponseWithBody<\n Default<Default<MethodSchema['response']>[StatusCode]>,\n StatusCode\n > &\n HttpRequestHandlerResponseDeclarationWithHeaders<Default<Default<MethodSchema['response']>[StatusCode]>>\n : never;\n\n/** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrespond `handler.respond()` API reference} */\nexport type HttpRequestHandlerResponseDeclarationFactory<\n Path extends string,\n MethodSchema extends HttpMethodSchema,\n StatusCode extends HttpStatusCode = HttpStatusCode,\n> = (\n request: Omit<HttpInterceptorRequest<Path, MethodSchema>, 'response'>,\n) => PossiblePromise<HttpRequestHandlerResponseDeclaration<MethodSchema, StatusCode>>;\n\n/** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerdelay `handler.delay()` API reference} */\nexport type HttpRequestHandlerResponseDelayFactory<Path extends string, MethodSchema extends HttpMethodSchema> = (\n request: Omit<HttpInterceptorRequest<Path, MethodSchema>, 'response'>,\n) => PossiblePromise<number>;\n\n/** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrequests `handler.requests` API reference} */\nexport interface HttpInterceptorRequest<Path extends string, MethodSchema extends HttpMethodSchema> extends Omit<\n HttpRequest,\n keyof Body | 'headers' | 'clone'\n> {\n /**\n * The headers of the request.\n *\n * @see {@link https://zimic.dev/docs/interceptor/guides/http/headers#using-request-headers Using request headers}\n */\n headers: HttpHeaders<Default<HttpRequestHeadersSchema<MethodSchema>>>;\n\n /**\n * The path parameters of the request. They are parsed from the path string when using dynamic paths.\n *\n * @see {@link https://zimic.dev/docs/interceptor/guides/http/path-params#using-request-path-params Using request path parameters}\n */\n pathParams: InferPathParams<Path>;\n\n /**\n * The search parameters of the request.\n *\n * @see {@link https://zimic.dev/docs/interceptor/guides/http/search-params#using-request-search-params Using request search parameters}\n */\n searchParams: HttpSearchParams<Default<HttpRequestSearchParamsSchema<MethodSchema>>>;\n\n /**\n * The body of the request. It is already parsed by default as detailed in\n * {@link https://zimic.dev/docs/interceptor/guides/http/bodies#default-body-parsing Default body parsing}.\n *\n * @see {@link https://zimic.dev/docs/interceptor/guides/http/bodies#using-request-bodies Using request bodies}\n */\n body: Replace<HttpRequestBodySchema<MethodSchema>, ArrayBuffer | ReadableStream, Blob>;\n\n /** The raw request object. */\n raw: HttpRequest<HttpRequestBodySchema<MethodSchema>, Default<HttpRequestHeadersSchema<MethodSchema>>>;\n}\n\n/** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrequests `handler.requests` API reference} */\nexport interface HttpInterceptorResponse<\n MethodSchema extends HttpMethodSchema,\n StatusCode extends HttpStatusCode,\n> extends Omit<HttpResponse, keyof Body | 'headers' | 'clone'> {\n /**\n * The headers of the response.\n *\n * @see {@link https://zimic.dev/docs/interceptor/guides/http/headers#using-response-headers Using response headers}\n */\n headers: HttpHeaders<Default<HttpResponseHeadersSchema<MethodSchema, StatusCode>>>;\n\n /** The status code of the response. */\n status: StatusCode;\n\n /**\n * The body of the response. It is already parsed by default as detailed in\n * {@link https://zimic.dev/docs/interceptor/guides/http/bodies#default-body-parsing Default body parsing}.\n *\n * @see {@link https://zimic.dev/docs/interceptor/guides/http/bodies#using-response-bodies Using response bodies}\n */\n body: Replace<HttpResponseBodySchema<MethodSchema, StatusCode>, ArrayBuffer | ReadableStream, Blob>;\n\n /** The raw response object. */\n raw: HttpResponse<\n HttpResponseBodySchema<MethodSchema, StatusCode>,\n Default<HttpResponseHeadersSchema<MethodSchema, StatusCode>>,\n StatusCode\n >;\n}\n\nexport const HTTP_INTERCEPTOR_REQUEST_HIDDEN_PROPERTIES = Object.freeze(\n new Set<Exclude<keyof HttpRequest, keyof HttpInterceptorRequest<string, never>>>([\n 'bodyUsed',\n 'arrayBuffer',\n 'blob',\n 'formData',\n 'json',\n 'text',\n 'clone',\n ]),\n);\n\nexport const HTTP_INTERCEPTOR_RESPONSE_HIDDEN_PROPERTIES = Object.freeze(\n new Set<Exclude<keyof HttpResponse, keyof HttpInterceptorResponse<never, never>>>(\n HTTP_INTERCEPTOR_REQUEST_HIDDEN_PROPERTIES,\n ),\n);\n\n/** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrequests `handler.requests` API reference} */\nexport interface InterceptedHttpInterceptorRequest<\n Path extends string,\n MethodSchema extends HttpMethodSchema,\n StatusCode extends HttpStatusCode = never,\n> extends HttpInterceptorRequest<Path, MethodSchema> {\n /** The response that was returned for the intercepted request. */\n response: StatusCode extends [never] ? never : HttpInterceptorResponse<MethodSchema, StatusCode>;\n}\n","import { HttpInterceptorType, UnhandledRequestStrategy } from '../interceptor/types/options';\n\nexport const DEFAULT_UNHANDLED_REQUEST_STRATEGY = Object.freeze({\n local: Object.freeze<UnhandledRequestStrategy.LocalDeclaration>({\n action: 'reject',\n log: true,\n }),\n remote: Object.freeze<UnhandledRequestStrategy.RemoteDeclaration>({\n action: 'reject',\n log: true,\n }),\n} satisfies Record<HttpInterceptorType, Readonly<UnhandledRequestStrategy.Declaration>>);\n","import {\n HttpHeadersInit,\n HttpHeaders,\n HttpBody,\n HttpResponse,\n HttpMethod,\n HttpMethodSchema,\n HttpSchema,\n HttpStatusCode,\n InferPathParams,\n parseHttpBody,\n HttpSearchParams,\n} from '@zimic/http';\nimport isDefined from '@zimic/utils/data/isDefined';\nimport { Default, PossiblePromise } from '@zimic/utils/types';\nimport color from 'picocolors';\n\nimport { removeArrayElement } from '@/utils/arrays';\nimport { isClientSide } from '@/utils/environment';\nimport { methodCanHaveResponseBody } from '@/utils/http';\nimport { formatValueToLog, logger } from '@/utils/logging';\n\nimport HttpInterceptorClient, { AnyHttpInterceptorClient } from '../interceptor/HttpInterceptorClient';\nimport { HttpInterceptorPlatform, HttpInterceptorType, UnhandledRequestStrategy } from '../interceptor/types/options';\nimport {\n UnhandledHttpInterceptorRequestPath,\n UnhandledHttpInterceptorRequestMethodSchema,\n} from '../interceptor/types/requests';\nimport {\n HTTP_INTERCEPTOR_REQUEST_HIDDEN_PROPERTIES,\n HTTP_INTERCEPTOR_RESPONSE_HIDDEN_PROPERTIES,\n HttpInterceptorRequest,\n HttpInterceptorResponse,\n} from '../requestHandler/types/requests';\nimport { DEFAULT_UNHANDLED_REQUEST_STRATEGY } from './constants';\nimport { MSWHttpResponseFactory } from './types/msw';\nimport { HttpInterceptorWorkerType } from './types/options';\n\nabstract class HttpInterceptorWorker {\n abstract get type(): HttpInterceptorWorkerType;\n\n platform: HttpInterceptorPlatform | null = null;\n isRunning = false;\n\n private startingPromise?: Promise<void>;\n private stoppingPromise?: Promise<void>;\n\n private runningInterceptors: AnyHttpInterceptorClient[] = [];\n\n abstract start(): Promise<void>;\n\n protected async sharedStart(internalStart: () => Promise<void>) {\n if (this.isRunning) {\n return;\n }\n\n if (this.startingPromise) {\n return this.startingPromise;\n }\n\n try {\n this.startingPromise = internalStart();\n await this.startingPromise;\n\n this.startingPromise = undefined;\n } catch (error) {\n // In server side (e.g. Node.js), we need to manually log the error because this will be treated as an unhandled\n // promise rejection. If we don't log it, the output won't contain details about the error. In the browser,\n // uncaught promise rejections are automatically logged.\n if (!isClientSide()) {\n console.error(error);\n }\n\n await this.stop();\n throw error;\n }\n }\n\n abstract stop(): Promise<void>;\n\n protected async sharedStop(internalStop: () => PossiblePromise<void>) {\n if (!this.isRunning) {\n return;\n }\n if (this.stoppingPromise) {\n return this.stoppingPromise;\n }\n\n const stoppingResult = internalStop();\n\n if (stoppingResult instanceof Promise) {\n this.stoppingPromise = stoppingResult;\n await this.stoppingPromise;\n }\n\n this.stoppingPromise = undefined;\n }\n\n abstract use<Schema extends HttpSchema>(\n interceptor: HttpInterceptorClient<Schema>,\n method: HttpMethod,\n path: string,\n createResponse: MSWHttpResponseFactory,\n ): PossiblePromise<void>;\n\n protected async logUnhandledRequestIfNecessary(\n request: Request,\n strategy: UnhandledRequestStrategy.Declaration | null,\n ) {\n if (strategy?.log) {\n await HttpInterceptorWorker.logUnhandledRequestWarning(request, strategy.action);\n return { wasLogged: true };\n }\n return { wasLogged: false };\n }\n\n protected async getUnhandledRequestStrategy(request: Request, interceptorType: HttpInterceptorType) {\n const candidates = await this.getUnhandledRequestStrategyCandidates(request, interceptorType);\n const strategy = this.reduceUnhandledRequestStrategyCandidates(candidates);\n return strategy;\n }\n\n private reduceUnhandledRequestStrategyCandidates(candidateStrategies: UnhandledRequestStrategy.Declaration[]) {\n if (candidateStrategies.length === 0) {\n return null;\n }\n\n // Prefer strategies from first to last, overriding undefined values with the next candidate.\n return candidateStrategies.reduce(\n (accumulatedStrategy, candidateStrategy): UnhandledRequestStrategy.Declaration => ({\n action: accumulatedStrategy.action,\n log: accumulatedStrategy.log ?? candidateStrategy.log,\n }),\n );\n }\n\n private async getUnhandledRequestStrategyCandidates(\n request: Request,\n interceptorType: HttpInterceptorType,\n ): Promise<UnhandledRequestStrategy.Declaration[]> {\n const globalDefaultStrategy = DEFAULT_UNHANDLED_REQUEST_STRATEGY[interceptorType];\n\n try {\n const interceptor = this.findInterceptorByRequestBaseURL(request);\n\n if (!interceptor) {\n return [];\n }\n\n const requestClone = request.clone();\n const interceptorStrategy = await this.getInterceptorUnhandledRequestStrategy(requestClone, interceptor);\n\n return [interceptorStrategy, globalDefaultStrategy].filter(isDefined);\n } catch (error) {\n console.error(error);\n\n return [globalDefaultStrategy];\n }\n }\n\n registerRunningInterceptor(interceptor: AnyHttpInterceptorClient) {\n this.runningInterceptors.push(interceptor);\n }\n\n unregisterRunningInterceptor(interceptor: AnyHttpInterceptorClient) {\n removeArrayElement(this.runningInterceptors, interceptor);\n }\n\n private findInterceptorByRequestBaseURL(request: Request) {\n const interceptor = this.runningInterceptors.findLast((interceptor) => {\n return request.url.startsWith(interceptor.baseURLAsString);\n });\n\n return interceptor;\n }\n\n private async getInterceptorUnhandledRequestStrategy(request: Request, interceptor: AnyHttpInterceptorClient) {\n if (typeof interceptor.onUnhandledRequest === 'function') {\n const parsedRequest = await HttpInterceptorWorker.parseRawUnhandledRequest(request);\n return interceptor.onUnhandledRequest(parsedRequest);\n }\n\n return interceptor.onUnhandledRequest;\n }\n\n abstract clearHandlers<Schema extends HttpSchema>(options?: {\n interceptor?: HttpInterceptorClient<Schema>;\n }): PossiblePromise<void>;\n\n abstract get interceptorsWithHandlers(): AnyHttpInterceptorClient[];\n\n static createResponseFromDeclaration(\n request: Request,\n declaration: { status: number; headers?: HttpHeadersInit; body?: HttpBody },\n ): HttpResponse {\n const headers = new HttpHeaders(declaration.headers);\n const status = declaration.status;\n\n const canHaveBody = methodCanHaveResponseBody(request.method as HttpMethod) && status !== 204;\n\n if (!canHaveBody) {\n return new Response(null, { headers, status }) as HttpResponse;\n }\n\n if (\n typeof declaration.body === 'string' ||\n declaration.body === null ||\n declaration.body === undefined ||\n declaration.body instanceof FormData ||\n declaration.body instanceof URLSearchParams ||\n declaration.body instanceof Blob ||\n declaration.body instanceof ArrayBuffer ||\n declaration.body instanceof ReadableStream\n ) {\n return new Response(declaration.body ?? null, { headers, status }) as HttpResponse;\n }\n\n return Response.json(declaration.body, { headers, status }) as HttpResponse;\n }\n\n static async parseRawUnhandledRequest(request: Request) {\n return this.parseRawRequest<UnhandledHttpInterceptorRequestPath, UnhandledHttpInterceptorRequestMethodSchema>(\n request,\n );\n }\n\n static async parseRawRequest<Path extends string, MethodSchema extends HttpMethodSchema>(\n originalRawRequest: Request,\n options?: { baseURL: string; pathRegex: RegExp },\n ): Promise<HttpInterceptorRequest<Path, MethodSchema>> {\n const rawRequest = originalRawRequest.clone();\n const rawRequestClone = rawRequest.clone();\n\n type BodySchema = Default<Default<MethodSchema['request']>['body']>;\n\n const parsedBody = await parseHttpBody<BodySchema>(rawRequest).catch((error: unknown) => {\n logger.error('Failed to parse request body:', error);\n return null;\n });\n\n type HeadersSchema = Default<Default<MethodSchema['request']>['headers']>;\n const headers = new HttpHeaders<HeadersSchema>(rawRequest.headers);\n\n const pathParams = this.parseRawPathParams<Path>(rawRequest, options);\n\n const parsedURL = new URL(rawRequest.url);\n type SearchParamsSchema = Default<Default<MethodSchema['request']>['searchParams']>;\n const searchParams = new HttpSearchParams<SearchParamsSchema>(parsedURL.searchParams);\n\n const parsedRequest = new Proxy(rawRequest as unknown as HttpInterceptorRequest<Path, MethodSchema>, {\n has(target, property: keyof HttpInterceptorRequest<Path, MethodSchema>) {\n if (HttpInterceptorWorker.isHiddenRequestProperty(property)) {\n return false;\n }\n return Reflect.has(target, property);\n },\n\n get(target, property: keyof HttpInterceptorRequest<Path, MethodSchema>) {\n if (HttpInterceptorWorker.isHiddenRequestProperty(property)) {\n return undefined;\n }\n return Reflect.get(target, property, target) as unknown;\n },\n });\n\n Object.defineProperty(parsedRequest, 'body', {\n value: parsedBody,\n enumerable: true,\n configurable: false,\n writable: false,\n });\n\n Object.defineProperty(parsedRequest, 'headers', {\n value: headers,\n enumerable: true,\n configurable: false,\n writable: false,\n });\n\n Object.defineProperty(parsedRequest, 'pathParams', {\n value: pathParams,\n enumerable: true,\n configurable: false,\n writable: false,\n });\n\n Object.defineProperty(parsedRequest, 'searchParams', {\n value: searchParams,\n enumerable: true,\n configurable: false,\n writable: false,\n });\n\n Object.defineProperty(parsedRequest, 'raw', {\n value: rawRequestClone,\n enumerable: true,\n configurable: false,\n writable: false,\n });\n\n return parsedRequest;\n }\n\n private static isHiddenRequestProperty(property: string) {\n return HTTP_INTERCEPTOR_REQUEST_HIDDEN_PROPERTIES.has(property as never);\n }\n\n static async parseRawResponse<MethodSchema extends HttpMethodSchema, StatusCode extends HttpStatusCode>(\n originalRawResponse: Response,\n ): Promise<HttpInterceptorResponse<MethodSchema, StatusCode>> {\n const rawResponse = originalRawResponse.clone();\n const rawResponseClone = rawResponse.clone();\n\n type BodySchema = Default<Default<Default<MethodSchema['response']>[StatusCode]>['body']>;\n const parsedBody = await parseHttpBody<BodySchema>(rawResponse).catch((error: unknown) => {\n logger.error('Failed to parse response body:', error);\n return null;\n });\n\n type HeadersSchema = Default<Default<Default<MethodSchema['response']>[StatusCode]>['headers']>;\n const headers = new HttpHeaders<HeadersSchema>(rawResponse.headers);\n\n const parsedRequest = new Proxy(rawResponse as unknown as HttpInterceptorResponse<MethodSchema, StatusCode>, {\n has(target, property: keyof HttpInterceptorResponse<MethodSchema, StatusCode>) {\n if (HttpInterceptorWorker.isHiddenResponseProperty(property)) {\n return false;\n }\n return Reflect.has(target, property);\n },\n\n get(target, property: keyof HttpInterceptorResponse<MethodSchema, StatusCode>) {\n if (HttpInterceptorWorker.isHiddenResponseProperty(property)) {\n return undefined;\n }\n return Reflect.get(target, property, target) as unknown;\n },\n });\n\n Object.defineProperty(parsedRequest, 'body', {\n value: parsedBody,\n enumerable: true,\n configurable: false,\n writable: false,\n });\n\n Object.defineProperty(parsedRequest, 'headers', {\n value: headers,\n enumerable: true,\n configurable: false,\n writable: false,\n });\n\n Object.defineProperty(parsedRequest, 'raw', {\n value: rawResponseClone,\n enumerable: true,\n configurable: false,\n writable: false,\n });\n\n return parsedRequest;\n }\n\n private static isHiddenResponseProperty(property: string) {\n return HTTP_INTERCEPTOR_RESPONSE_HIDDEN_PROPERTIES.has(property as never);\n }\n\n static parseRawPathParams<Path extends string>(\n request: Request,\n options?: { baseURL: string; pathRegex: RegExp },\n ): InferPathParams<Path> {\n const requestPath = request.url.replace(options?.baseURL ?? '', '');\n const paramsMatch = options?.pathRegex.exec(requestPath);\n\n const params: Record<string, string | undefined> = {};\n\n for (const [paramName, paramValue] of Object.entries(paramsMatch?.groups ?? {})) {\n params[paramName] = typeof paramValue === 'string' ? decodeURIComponent(paramValue) : undefined;\n }\n\n return params as InferPathParams<Path>;\n }\n\n static async logUnhandledRequestWarning(rawRequest: Request, action: UnhandledRequestStrategy.Action) {\n const request = await this.parseRawRequest(rawRequest);\n\n const [formattedHeaders, formattedSearchParams, formattedBody] = await Promise.all([\n formatValueToLog(request.headers.toObject()),\n formatValueToLog(request.searchParams.toObject()),\n formatValueToLog(request.body),\n ]);\n\n logger[action === 'bypass' ? 'warn' : 'error'](\n `${action === 'bypass' ? 'Warning:' : 'Error:'} Request was not handled and was ` +\n `${action === 'bypass' ? color.yellow('bypassed') : color.red('rejected')}.\\n\\n `,\n `${request.method} ${request.url}`,\n '\\n Headers:',\n formattedHeaders,\n '\\n Search params:',\n formattedSearchParams,\n '\\n Body:',\n formattedBody,\n '\\n\\nLearn more: https://zimic.dev/docs/interceptor/guides/http/unhandled-requests',\n );\n }\n}\n\nexport default HttpInterceptorWorker;\n","import { HttpSchema, HttpSchemaMethod, HttpSchemaPath, HttpStatusCode } from '@zimic/http';\nimport { Default, PossiblePromise } from '@zimic/utils/types';\n\nimport HttpInterceptorClient from '../interceptor/HttpInterceptorClient';\nimport HttpRequestHandlerClient from './HttpRequestHandlerClient';\nimport {\n InternalHttpRequestHandler,\n SyncedRemoteHttpRequestHandler as PublicSyncedRemoteHttpRequestHandler,\n} from './types/public';\nimport {\n HttpInterceptorRequest,\n HttpInterceptorResponse,\n HttpRequestHandlerResponseDeclaration,\n HttpRequestHandlerResponseDeclarationFactory,\n HttpRequestHandlerResponseDelayFactory,\n InterceptedHttpInterceptorRequest,\n} from './types/requests';\nimport { HttpRequestHandlerRestriction } from './types/restrictions';\n\nconst PENDING_PROPERTIES = new Set<string | symbol>(['then'] satisfies (keyof Promise<unknown>)[]);\n\nclass RemoteHttpRequestHandler<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath<Schema, Method>,\n StatusCode extends HttpStatusCode = never,\n> implements InternalHttpRequestHandler<Schema, Method, Path, StatusCode> {\n readonly type = 'remote';\n\n client: HttpRequestHandlerClient<Schema, Method, Path, StatusCode>;\n\n private syncPromises: Promise<unknown>[] = [];\n\n private unsynced: this;\n private synced: this;\n\n constructor(interceptor: HttpInterceptorClient<Schema, typeof RemoteHttpRequestHandler>, method: Method, path: Path) {\n this.client = new HttpRequestHandlerClient(interceptor, method, path, this);\n this.unsynced = this;\n this.synced = this.createSyncedProxy();\n }\n\n private createSyncedProxy() {\n return new Proxy(this, {\n has: (target, property) => {\n if (this.isHiddenPropertyWhenSynced(property)) {\n return false;\n }\n return Reflect.has(target, property);\n },\n\n get: (target, property) => {\n if (this.isHiddenPropertyWhenSynced(property)) {\n return undefined;\n }\n return Reflect.get(target, property);\n },\n });\n }\n\n private isHiddenPropertyWhenSynced(property: string | symbol) {\n return PENDING_PROPERTIES.has(property);\n }\n\n get method() {\n return this.client.method;\n }\n\n get path() {\n return this.client.path;\n }\n\n with(restriction: HttpRequestHandlerRestriction<Schema, Method, Path>): this {\n this.client.with(restriction);\n return this.unsynced;\n }\n\n delay(\n minMilliseconds: number | HttpRequestHandlerResponseDelayFactory<Path, Default<Schema[Path][Method]>>,\n maxMilliseconds?: number,\n ): this {\n this.client.delay(minMilliseconds, maxMilliseconds);\n return this.unsynced;\n }\n\n respond<NewStatusCode extends HttpStatusCode>(\n declaration:\n | HttpRequestHandlerResponseDeclaration<Default<Schema[Path][Method]>, NewStatusCode>\n | HttpRequestHandlerResponseDeclarationFactory<Path, Default<Schema[Path][Method]>, NewStatusCode>,\n ): RemoteHttpRequestHandler<Schema, Method, Path, NewStatusCode> {\n const newUnsyncedThis = this.unsynced as unknown as RemoteHttpRequestHandler<Schema, Method, Path, NewStatusCode>;\n newUnsyncedThis.client.respond(declaration);\n return newUnsyncedThis;\n }\n\n times(minNumberOfRequests: number, maxNumberOfRequests?: number): this {\n this.client.times(minNumberOfRequests, maxNumberOfRequests);\n return this;\n }\n\n async checkTimes() {\n return new Promise<void>((resolve, reject) => {\n try {\n this.client.checkTimes();\n resolve();\n } catch (error) {\n reject(error);\n }\n });\n }\n\n clear(): this {\n this.client.clear();\n return this.unsynced;\n }\n\n get requests(): readonly InterceptedHttpInterceptorRequest<Path, Default<Schema[Path][Method]>, StatusCode>[] {\n return this.client.requests;\n }\n\n async matchesRequest(request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>) {\n const requestMatch = await this.client.matchesRequest(request);\n\n if (requestMatch.success) {\n this.client.markRequestAsMatched(request);\n } else if (requestMatch.cause === 'unmatchedRestrictions') {\n this.client.markRequestAsUnmatched(request, { diff: requestMatch.diff });\n } else {\n this.client.markRequestAsMatched(request);\n }\n\n return requestMatch;\n }\n\n async applyResponseDeclaration(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n ): Promise<HttpRequestHandlerResponseDeclaration<Default<Schema[Path][Method]>, StatusCode>> {\n return this.client.applyResponseDeclaration(request);\n }\n\n saveInterceptedRequest(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n response: HttpInterceptorResponse<Default<Schema[Path][Method]>, StatusCode>,\n ) {\n this.client.saveInterceptedRequest(request, response);\n }\n\n registerSyncPromise(promise: Promise<unknown>) {\n this.syncPromises.push(promise);\n }\n\n get isSynced() {\n return this.syncPromises.length === 0;\n }\n\n then<\n FulfilledResult = PublicSyncedRemoteHttpRequestHandler<Schema, Method, Path, StatusCode>,\n RejectedResult = never,\n >(\n onFulfilled?:\n | ((\n handler: PublicSyncedRemoteHttpRequestHandler<Schema, Method, Path, StatusCode>,\n ) => PossiblePromise<FulfilledResult>)\n | null,\n onRejected?: ((reason: unknown) => PossiblePromise<RejectedResult>) | null,\n ): Promise<FulfilledResult | RejectedResult> {\n const promisesToWait = new Set(this.syncPromises);\n\n return Promise.all(promisesToWait)\n .then(() => {\n this.syncPromises = this.syncPromises.filter((promise) => !promisesToWait.has(promise));\n\n return this.isSynced ? this.synced : this.unsynced;\n })\n .then(onFulfilled, onRejected);\n }\n\n catch<RejectedResult = never>(\n onRejected?: ((reason: unknown) => PossiblePromise<RejectedResult>) | null,\n ): Promise<PublicSyncedRemoteHttpRequestHandler<Schema, Method, Path, StatusCode> | RejectedResult> {\n return this.then().catch(onRejected);\n }\n\n finally(\n onFinally?: (() => void) | null,\n ): Promise<PublicSyncedRemoteHttpRequestHandler<Schema, Method, Path, StatusCode>> {\n return this.then().finally(onFinally);\n }\n}\n\nexport type AnyRemoteHttpRequestHandler =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | RemoteHttpRequestHandler<any, any, any>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | RemoteHttpRequestHandler<any, any, any, any>;\n\nexport default RemoteHttpRequestHandler;\n","import {\n HttpResponse,\n HTTP_METHODS,\n HttpMethod,\n HttpSchemaMethod,\n HttpSchemaPath,\n HttpStatusCode,\n HttpSchema,\n} from '@zimic/http';\nimport { Default, PossiblePromise } from '@zimic/utils/types';\nimport createRegexFromPath from '@zimic/utils/url/createRegexFromPath';\nimport excludeNonPathParams from '@zimic/utils/url/excludeNonPathParams';\nimport validateURLProtocol from '@zimic/utils/url/validateURLProtocol';\n\nimport { isServerSide } from '@/utils/environment';\n\nimport HttpInterceptorWorker from '../interceptorWorker/HttpInterceptorWorker';\nimport HttpRequestHandlerClient, {\n AnyHttpRequestHandlerClient,\n HttpRequestHandlerRequestMatch,\n} from '../requestHandler/HttpRequestHandlerClient';\nimport LocalHttpRequestHandler from '../requestHandler/LocalHttpRequestHandler';\nimport RemoteHttpRequestHandler from '../requestHandler/RemoteHttpRequestHandler';\nimport { HttpRequestHandler, InternalHttpRequestHandler } from '../requestHandler/types/public';\nimport { HttpInterceptorRequest } from '../requestHandler/types/requests';\nimport NotRunningHttpInterceptorError from './errors/NotRunningHttpInterceptorError';\nimport RequestSavingSafeLimitExceededError from './errors/RequestSavingSafeLimitExceededError';\nimport RunningHttpInterceptorError from './errors/RunningHttpInterceptorError';\nimport HttpInterceptorStore from './HttpInterceptorStore';\nimport { UnhandledRequestStrategy } from './types/options';\nimport { HttpInterceptorRequestSaving } from './types/public';\nimport { HttpInterceptorRequestContext } from './types/requests';\n\nexport const SUPPORTED_BASE_URL_PROTOCOLS = Object.freeze(['http', 'https']);\n\nexport const DEFAULT_REQUEST_SAVING_SAFE_LIMIT = 1000;\n\nclass HttpInterceptorClient<\n Schema extends HttpSchema,\n HandlerConstructor extends HttpRequestHandlerConstructor = HttpRequestHandlerConstructor,\n> {\n private store: HttpInterceptorStore;\n private _baseURL!: URL;\n\n private createWorker: () => HttpInterceptorWorker;\n private deleteWorker: () => void;\n private worker?: HttpInterceptorWorker;\n\n requestSaving: HttpInterceptorRequestSaving;\n private numberOfSavedRequests = 0;\n\n onUnhandledRequest?: HandlerConstructor extends typeof LocalHttpRequestHandler\n ? UnhandledRequestStrategy.Local\n : UnhandledRequestStrategy.Remote;\n\n isRunning = false;\n\n private Handler: HandlerConstructor;\n\n private handlers: {\n [Method in HttpMethod]: Map<string, AnyHttpRequestHandlerClient[]>;\n } = {\n GET: new Map(),\n POST: new Map(),\n PATCH: new Map(),\n PUT: new Map(),\n DELETE: new Map(),\n HEAD: new Map(),\n OPTIONS: new Map(),\n };\n\n constructor(options: {\n store: HttpInterceptorStore;\n baseURL: URL;\n createWorker: () => HttpInterceptorWorker;\n deleteWorker: () => void;\n requestSaving?: Partial<HttpInterceptorRequestSaving>;\n onUnhandledRequest?: UnhandledRequestStrategy;\n Handler: HandlerConstructor;\n }) {\n this.store = options.store;\n this.baseURL = options.baseURL;\n\n this.createWorker = options.createWorker;\n this.deleteWorker = options.deleteWorker;\n\n this.requestSaving = {\n enabled: options.requestSaving?.enabled ?? this.getDefaultRequestSavingEnabled(),\n safeLimit: options.requestSaving?.safeLimit ?? DEFAULT_REQUEST_SAVING_SAFE_LIMIT,\n };\n\n this.onUnhandledRequest = options.onUnhandledRequest satisfies\n | UnhandledRequestStrategy\n | undefined as this['onUnhandledRequest'];\n\n this.Handler = options.Handler;\n }\n\n private getDefaultRequestSavingEnabled(): boolean {\n return isServerSide() ? process.env.NODE_ENV === 'test' : false;\n }\n\n get baseURL() {\n return this._baseURL;\n }\n\n set baseURL(newBaseURL: URL) {\n if (this.isRunning) {\n throw new RunningHttpInterceptorError(\n 'Did you forget to call `await interceptor.stop()` before changing the base URL?',\n );\n }\n\n validateURLProtocol(newBaseURL, SUPPORTED_BASE_URL_PROTOCOLS);\n excludeNonPathParams(newBaseURL);\n\n this._baseURL = newBaseURL;\n }\n\n get baseURLAsString() {\n if (this.baseURL.href === `${this.baseURL.origin}/`) {\n return this.baseURL.origin;\n }\n return this.baseURL.href;\n }\n\n private get workerOrThrow() {\n if (!this.worker) {\n throw new NotRunningHttpInterceptorError();\n }\n return this.worker;\n }\n\n get platform() {\n return this.worker?.platform ?? null;\n }\n\n async start() {\n try {\n this.worker = this.createWorker();\n\n await this.worker.start();\n this.worker.registerRunningInterceptor(this);\n\n this.markAsRunning(true);\n } catch (error) {\n await this.stop();\n throw error;\n }\n }\n\n async stop() {\n this.worker?.unregisterRunningInterceptor(this);\n\n // The number of interceptors will be 0 if the first client could not start due to an error.\n const isLastRunningInterceptor = this.numberOfRunningInterceptors === 0 || this.numberOfRunningInterceptors === 1;\n\n if (isLastRunningInterceptor) {\n await this.worker?.stop();\n this.deleteWorker();\n }\n\n this.markAsRunning(false);\n this.worker = undefined;\n }\n\n private markAsRunning(isRunning: boolean) {\n if (this.workerOrThrow.type === 'local') {\n this.store.markLocalInterceptorAsRunning(this, isRunning);\n } else {\n this.store.markRemoteInterceptorAsRunning(this, isRunning, this.baseURL);\n }\n this.isRunning = isRunning;\n }\n\n get numberOfRunningInterceptors() {\n if (!this.isRunning) {\n return 0;\n }\n\n if (this.workerOrThrow.type === 'local') {\n return this.store.numberOfRunningLocalInterceptors;\n } else {\n return this.store.numberOfRunningRemoteInterceptors(this.baseURL);\n }\n }\n\n get(path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) {\n return this.createHttpRequestHandler('GET' as HttpSchemaMethod<Schema>, path);\n }\n\n post(path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) {\n return this.createHttpRequestHandler('POST' as HttpSchemaMethod<Schema>, path);\n }\n\n patch(path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) {\n return this.createHttpRequestHandler('PATCH' as HttpSchemaMethod<Schema>, path);\n }\n\n put(path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) {\n return this.createHttpRequestHandler('PUT' as HttpSchemaMethod<Schema>, path);\n }\n\n delete(path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) {\n return this.createHttpRequestHandler('DELETE' as HttpSchemaMethod<Schema>, path);\n }\n\n head(path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) {\n return this.createHttpRequestHandler('HEAD' as HttpSchemaMethod<Schema>, path);\n }\n\n options(path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) {\n return this.createHttpRequestHandler('OPTIONS' as HttpSchemaMethod<Schema>, path);\n }\n\n private createHttpRequestHandler<\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath<Schema, Method>,\n >(method: Method, path: Path): HttpRequestHandler<Schema, Method, Path> {\n if (!this.isRunning) {\n throw new NotRunningHttpInterceptorError();\n }\n\n const handler = new this.Handler<Schema, Method, Path>(this as SharedHttpInterceptorClient<Schema>, method, path);\n this.registerRequestHandler(handler);\n\n return handler;\n }\n\n registerRequestHandler<\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath<Schema, Method>,\n StatusCode extends HttpStatusCode = never,\n >(handler: InternalHttpRequestHandler<Schema, Method, Path, StatusCode>) {\n const pathHandlers = this.handlers[handler.method].get(handler.path) ?? [];\n\n const isAlreadyRegistered = pathHandlers.includes(handler.client);\n\n if (isAlreadyRegistered) {\n return;\n }\n\n pathHandlers.push(handler.client);\n\n const isFirstHandlerForMethodPath = pathHandlers.length === 1;\n\n if (!isFirstHandlerForMethodPath) {\n return;\n }\n\n this.handlers[handler.method].set(handler.path, pathHandlers);\n\n const pathRegex = createRegexFromPath(handler.path);\n\n const registrationResult = this.workerOrThrow.use(this, handler.method, handler.path, async (context) => {\n const response = await this.handleInterceptedRequest(\n handler.method,\n handler.path,\n pathRegex,\n context as HttpInterceptorRequestContext<Schema, Method, Path>,\n );\n return response;\n });\n\n if (handler instanceof RemoteHttpRequestHandler && registrationResult instanceof Promise) {\n handler.registerSyncPromise(registrationResult);\n }\n }\n\n private async handleInterceptedRequest<\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath<Schema, Method>,\n Context extends HttpInterceptorRequestContext<Schema, Method, Path>,\n >(method: Method, path: Path, pathRegex: RegExp, { request }: Context): Promise<HttpResponse | null> {\n const parsedRequest = await HttpInterceptorWorker.parseRawRequest<Path, Default<Schema[Path][Method]>>(request, {\n baseURL: this.baseURLAsString,\n pathRegex,\n });\n\n const matchedHandler = await this.findMatchedHandler(method, path, parsedRequest);\n\n if (!matchedHandler) {\n return null;\n }\n\n const responseDeclaration = await matchedHandler.applyResponseDeclaration(parsedRequest);\n const response = HttpInterceptorWorker.createResponseFromDeclaration(request, responseDeclaration);\n\n if (this.requestSaving.enabled) {\n const responseClone = response.clone();\n\n const parsedResponse = await HttpInterceptorWorker.parseRawResponse<\n Default<Schema[Path][Method]>,\n typeof responseDeclaration.status\n >(responseClone);\n\n matchedHandler.saveInterceptedRequest(parsedRequest, parsedResponse);\n }\n\n return response;\n }\n\n incrementNumberOfSavedRequests(increment: number) {\n this.numberOfSavedRequests = Math.max(this.numberOfSavedRequests + increment, 0);\n\n const exceedsSafeLimit = this.numberOfSavedRequests > this.requestSaving.safeLimit;\n\n if (increment > 0 && exceedsSafeLimit) {\n const error = new RequestSavingSafeLimitExceededError(this.numberOfSavedRequests, this.requestSaving.safeLimit);\n console.warn(error);\n }\n }\n\n private async findMatchedHandler<\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath<Schema, Method>,\n >(\n method: Method,\n path: Path,\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Promise<HttpRequestHandlerClient<Schema, Method, Path, any> | undefined> {\n /* istanbul ignore next -- @preserve\n * Ignoring because there will always be a handler for the given method and path at this point. */\n const pathHandlers = this.handlers[method].get(path) ?? [];\n\n const failedRequestMatches = new Map<\n AnyHttpRequestHandlerClient,\n Extract<HttpRequestHandlerRequestMatch, { success: false }>\n >();\n\n // If we find a matching handler that can accept more requests, we return it immediately.\n for (let handlerIndex = pathHandlers.length - 1; handlerIndex >= 0; handlerIndex--) {\n const handler = pathHandlers[handlerIndex];\n const requestMatch = await handler.matchesRequest(request);\n\n if (requestMatch.success) {\n handler.markRequestAsMatched(request);\n return handler;\n }\n\n failedRequestMatches.set(handler, requestMatch);\n }\n\n // If no handler matched or could accept more requests, we iterate again over the handlers to check which ones\n // could have matched considering only restrictions.\n for (let handlerIndex = pathHandlers.length - 1; handlerIndex >= 0; handlerIndex--) {\n const handler = pathHandlers[handlerIndex];\n const requestMatch = failedRequestMatches.get(handler);\n\n // Handlers that did not match due to anything other than restrictions are still marked as matched to trigger a\n // times check error.\n if (requestMatch?.cause === 'unmatchedRestrictions') {\n handler.markRequestAsUnmatched(request, { diff: requestMatch.diff });\n } else {\n handler.markRequestAsMatched(request);\n break;\n }\n }\n\n return undefined;\n }\n\n checkTimes() {\n for (const method of HTTP_METHODS) {\n const pathHandlers = this.handlers[method];\n\n for (const handlers of pathHandlers.values()) {\n for (let handlerIndex = handlers.length - 1; handlerIndex >= 0; handlerIndex--) {\n const handler = handlers[handlerIndex];\n handler.checkTimes();\n }\n }\n }\n }\n\n clear() {\n const clearPromises: Promise<AnyHttpRequestHandlerClient | void>[] = [\n Promise.resolve(this.workerOrThrow.clearHandlers({ interceptor: this })),\n ];\n\n for (const method of HTTP_METHODS) {\n for (const result of this.clearMethodHandlers(method)) {\n clearPromises.push(Promise.resolve(result));\n }\n\n const pathHandlers = this.handlers[method];\n pathHandlers.clear();\n }\n\n return Promise.all(clearPromises);\n }\n\n private clearMethodHandlers(method: HttpMethod) {\n const pathHandlers = this.handlers[method];\n const clearResults: PossiblePromise<AnyHttpRequestHandlerClient>[] = [];\n\n for (const handlers of pathHandlers.values()) {\n for (const handler of handlers) {\n clearResults.push(handler.clear());\n }\n }\n\n return clearResults;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyHttpInterceptorClient = HttpInterceptorClient<any>;\n\nexport type HttpRequestHandlerConstructor = typeof LocalHttpRequestHandler | typeof RemoteHttpRequestHandler;\n\nexport type SharedHttpInterceptorClient<Schema extends HttpSchema> = HttpInterceptorClient<\n Schema,\n typeof LocalHttpRequestHandler\n> &\n HttpInterceptorClient<Schema, typeof RemoteHttpRequestHandler>;\n\nexport default HttpInterceptorClient;\n","import { createPathParamRegex } from './createRegexFromPath';\n\nexport class DuplicatedPathParamError extends Error {\n constructor(path: string, paramName: string) {\n super(\n `The path parameter '${paramName}' appears more than once in '${path}'. This is not supported. ` +\n 'Please make sure that each parameter is unique.',\n );\n this.name = 'DuplicatedPathParamError';\n }\n}\n\nfunction validatePathParams(path: string) {\n const pathParamMatches = path.toString().matchAll(createPathParamRegex());\n\n const uniqueParamNames = new Set<string>();\n\n for (const paramMatch of pathParamMatches) {\n const paramName = paramMatch.groups?.identifier;\n\n if (!paramName) {\n continue;\n }\n\n if (uniqueParamNames.has(paramName)) {\n throw new DuplicatedPathParamError(path, paramName);\n }\n\n uniqueParamNames.add(paramName);\n }\n}\n\nexport default validatePathParams;\n","import { HttpRequest, HttpResponse, HttpMethod, HttpSchema } from '@zimic/http';\nimport createRegexFromPath from '@zimic/utils/url/createRegexFromPath';\nimport excludeNonPathParams from '@zimic/utils/url/excludeNonPathParams';\nimport validatePathParams from '@zimic/utils/url/validatePathParams';\nimport { SharedOptions as MSWWorkerSharedOptions, http, passthrough } from 'msw';\nimport * as mswBrowser from 'msw/browser';\nimport * as mswNode from 'msw/node';\n\nimport { removeArrayIndex } from '@/utils/arrays';\nimport { isClientSide, isServerSide } from '@/utils/environment';\n\nimport NotRunningHttpInterceptorError from '../interceptor/errors/NotRunningHttpInterceptorError';\nimport UnknownHttpInterceptorPlatformError from '../interceptor/errors/UnknownHttpInterceptorPlatformError';\nimport HttpInterceptorClient, { AnyHttpInterceptorClient } from '../interceptor/HttpInterceptorClient';\nimport UnregisteredBrowserServiceWorkerError from './errors/UnregisteredBrowserServiceWorkerError';\nimport HttpInterceptorWorker from './HttpInterceptorWorker';\nimport { HttpResponseFactoryContext } from './types/http';\nimport { BrowserMSWWorker, MSWHttpResponseFactory, MSWWorker, NodeMSWWorker } from './types/msw';\nimport { LocalHttpInterceptorWorkerOptions } from './types/options';\n\ninterface HttpHandler {\n baseURL: string;\n method: HttpMethod;\n pathRegex: RegExp;\n interceptor: AnyHttpInterceptorClient;\n createResponse: (context: HttpResponseFactoryContext) => Promise<Response>;\n}\n\nclass LocalHttpInterceptorWorker extends HttpInterceptorWorker {\n private internalWorker?: MSWWorker;\n\n private httpHandlersByMethod: {\n [Method in HttpMethod]: HttpHandler[];\n } = {\n GET: [],\n POST: [],\n PATCH: [],\n PUT: [],\n DELETE: [],\n HEAD: [],\n OPTIONS: [],\n };\n\n constructor(_options: LocalHttpInterceptorWorkerOptions) {\n super();\n }\n\n get type() {\n return 'local' as const;\n }\n\n get internalWorkerOrThrow() {\n /* istanbul ignore if -- @preserve\n * Trying to access the internal worker when it does not exist should not happen. */\n if (!this.internalWorker) {\n throw new NotRunningHttpInterceptorError();\n }\n return this.internalWorker;\n }\n\n get internalWorkerOrCreate() {\n this.internalWorker ??= this.createInternalWorker();\n return this.internalWorker;\n }\n\n private createInternalWorker() {\n const mswHttpHandler = http.all('*', async (context) => {\n const request = context.request satisfies Request as HttpRequest;\n const response = await this.createResponseForRequest(request);\n return response;\n });\n\n if (isServerSide() && 'setupServer' in mswNode) {\n return mswNode.setupServer(mswHttpHandler);\n }\n\n /* istanbul ignore else -- @preserve */\n if (isClientSide() && 'setupWorker' in mswBrowser) {\n return mswBrowser.setupWorker(mswHttpHandler);\n }\n\n /* istanbul ignore next -- @preserve\n * Ignoring because checking unknown platforms is not configured in our test setup. */\n throw new UnknownHttpInterceptorPlatformError();\n }\n\n async start() {\n await super.sharedStart(async () => {\n const internalWorker = this.internalWorkerOrCreate;\n\n const sharedOptions: MSWWorkerSharedOptions = {\n onUnhandledRequest: 'bypass',\n };\n\n if (this.isInternalBrowserWorker(internalWorker)) {\n this.platform = 'browser';\n await this.startInBrowser(internalWorker, sharedOptions);\n } else {\n this.platform = 'node';\n this.startInNode(internalWorker, sharedOptions);\n }\n\n this.isRunning = true;\n });\n }\n\n private async startInBrowser(internalWorker: BrowserMSWWorker, sharedOptions: MSWWorkerSharedOptions) {\n try {\n await internalWorker.start({ ...sharedOptions, quiet: true });\n } catch (error) {\n this.handleBrowserWorkerStartError(error);\n }\n }\n\n private handleBrowserWorkerStartError(error: unknown) {\n if (UnregisteredBrowserServiceWorkerError.matchesRawError(error)) {\n throw new UnregisteredBrowserServiceWorkerError();\n }\n throw error;\n }\n\n private startInNode(internalWorker: NodeMSWWorker, sharedOptions: MSWWorkerSharedOptions) {\n internalWorker.listen(sharedOptions);\n }\n\n async stop() {\n await super.sharedStop(() => {\n const internalWorker = this.internalWorkerOrCreate;\n\n if (this.isInternalBrowserWorker(internalWorker)) {\n this.stopInBrowser(internalWorker);\n } else {\n this.stopInNode(internalWorker);\n }\n this.clearHandlers();\n\n this.internalWorker = undefined;\n this.isRunning = false;\n });\n }\n\n private stopInBrowser(internalWorker: BrowserMSWWorker) {\n internalWorker.stop();\n }\n\n private stopInNode(internalWorker: NodeMSWWorker) {\n internalWorker.close();\n }\n\n private isInternalBrowserWorker(worker: MSWWorker) {\n return 'start' in worker && 'stop' in worker;\n }\n\n hasInternalBrowserWorker() {\n return this.isInternalBrowserWorker(this.internalWorkerOrThrow);\n }\n\n hasInternalNodeWorker() {\n return !this.hasInternalBrowserWorker();\n }\n\n use<Schema extends HttpSchema>(\n interceptor: HttpInterceptorClient<Schema>,\n method: HttpMethod,\n path: string,\n createResponse: MSWHttpResponseFactory,\n ) {\n if (!this.isRunning) {\n throw new NotRunningHttpInterceptorError();\n }\n\n validatePathParams(path);\n\n const methodHandlers = this.httpHandlersByMethod[method];\n\n const handler: HttpHandler = {\n baseURL: interceptor.baseURLAsString,\n method,\n pathRegex: createRegexFromPath(path),\n interceptor,\n createResponse: async (context) => {\n const request = context.request as HttpRequest;\n const requestClone = request.clone();\n\n let response: HttpResponse | null = null;\n\n try {\n response = await createResponse({ ...context, request });\n } catch (error) {\n console.error(error);\n }\n\n if (!response) {\n return this.bypassOrRejectUnhandledRequest(requestClone);\n }\n\n if (context.request.method === 'HEAD') {\n return new Response(null, {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n }\n\n return response;\n },\n };\n\n methodHandlers.push(handler);\n }\n\n private async createResponseForRequest(request: HttpRequest) {\n const methodHandlers = this.httpHandlersByMethod[request.method as HttpMethod];\n\n const requestURL = excludeNonPathParams(new URL(request.url));\n const requestURLAsString = requestURL.href === `${requestURL.origin}/` ? requestURL.origin : requestURL.href;\n\n for (let handlerIndex = methodHandlers.length - 1; handlerIndex >= 0; handlerIndex--) {\n const handler = methodHandlers[handlerIndex];\n const matchesBaseURL = requestURLAsString.startsWith(handler.baseURL);\n\n if (!matchesBaseURL) {\n continue;\n }\n\n const requestPath = requestURLAsString.replace(handler.baseURL, '');\n const matchesPath = handler.pathRegex.test(requestPath);\n\n if (!matchesPath) {\n continue;\n }\n\n const response = await handler.createResponse({ request });\n return response;\n }\n\n return this.bypassOrRejectUnhandledRequest(request);\n }\n\n private async bypassOrRejectUnhandledRequest(request: HttpRequest) {\n const requestClone = request.clone();\n\n const strategy = await super.getUnhandledRequestStrategy(request, 'local');\n await super.logUnhandledRequestIfNecessary(requestClone, strategy);\n\n if (strategy?.action === 'reject') {\n return Response.error();\n } else {\n return passthrough();\n }\n }\n\n clearHandlers<Schema extends HttpSchema>(\n options: {\n interceptor?: HttpInterceptorClient<Schema>;\n } = {},\n ) {\n if (!this.isRunning) {\n throw new NotRunningHttpInterceptorError();\n }\n\n if (options.interceptor === undefined) {\n for (const handlers of Object.values(this.httpHandlersByMethod)) {\n handlers.length = 0;\n }\n } else {\n for (const methodHandlers of Object.values(this.httpHandlersByMethod)) {\n const groupToRemoveIndex = methodHandlers.findIndex((group) => group.interceptor === options.interceptor);\n removeArrayIndex(methodHandlers, groupToRemoveIndex);\n }\n }\n }\n\n get interceptorsWithHandlers() {\n const interceptors = new Set<AnyHttpInterceptorClient>();\n\n for (const handlers of Object.values(this.httpHandlersByMethod)) {\n for (const handler of handlers) {\n interceptors.add(handler.interceptor);\n }\n }\n\n return Array.from(interceptors);\n }\n}\n\nexport default LocalHttpInterceptorWorker;\n","import createCachedDynamicImport from '@zimic/utils/import/createCachedDynamicImport';\n\nexport type IsomorphicCrypto = Crypto | typeof import('crypto');\n\nexport const importCrypto = createCachedDynamicImport<IsomorphicCrypto>(async () => {\n const globalCrypto = globalThis.crypto as typeof globalThis.crypto | undefined;\n /* istanbul ignore next -- @preserve\n * Ignoring as Node.js >=20 provides a global crypto and the import fallback won't run. */\n return globalCrypto ?? (await import('crypto'));\n});\n","import { JSONValue } from '@zimic/http';\n\nimport { convertArrayBufferToBase64, convertBase64ToArrayBuffer } from './data';\n\nexport type SerializedHttpRequest = JSONValue<{\n url: string;\n method: string;\n mode: RequestMode;\n headers: Record<string, string>;\n cache: RequestCache;\n credentials: RequestCredentials;\n integrity: string;\n keepalive: boolean;\n redirect: RequestRedirect;\n referrer: string;\n referrerPolicy: ReferrerPolicy;\n body: string | null;\n}>;\n\nexport async function serializeRequest(request: Request): Promise<SerializedHttpRequest> {\n const requestClone = request.clone();\n const serializedBody = requestClone.body ? convertArrayBufferToBase64(await requestClone.arrayBuffer()) : null;\n\n return {\n url: request.url,\n method: request.method,\n mode: request.mode,\n headers: Object.fromEntries(request.headers),\n cache: request.cache,\n credentials: request.credentials,\n integrity: request.integrity,\n keepalive: request.keepalive,\n redirect: request.redirect,\n referrer: request.referrer,\n referrerPolicy: request.referrerPolicy,\n body: serializedBody,\n };\n}\n\nexport function deserializeRequest(serializedRequest: SerializedHttpRequest): Request {\n const deserializedBody = serializedRequest.body ? convertBase64ToArrayBuffer(serializedRequest.body) : null;\n\n return new Request(serializedRequest.url, {\n method: serializedRequest.method,\n mode: serializedRequest.mode,\n headers: new Headers(serializedRequest.headers),\n cache: serializedRequest.cache,\n credentials: serializedRequest.credentials,\n integrity: serializedRequest.integrity,\n keepalive: serializedRequest.keepalive,\n redirect: serializedRequest.redirect,\n referrer: serializedRequest.referrer,\n referrerPolicy: serializedRequest.referrerPolicy,\n body: deserializedBody,\n });\n}\n\nexport type SerializedResponse = JSONValue<{\n status: number;\n statusText: string;\n headers: Record<string, string>;\n body: string | null;\n}>;\n\nexport async function serializeResponse(response: Response): Promise<SerializedResponse> {\n const responseClone = response.clone();\n const serializedBody = responseClone.body ? convertArrayBufferToBase64(await responseClone.arrayBuffer()) : null;\n\n return {\n status: response.status,\n statusText: response.statusText,\n headers: Object.fromEntries(response.headers),\n body: serializedBody,\n };\n}\n\nexport function deserializeResponse(serializedResponse: SerializedResponse): Response {\n const deserializedBody = serializedResponse.body ? convertBase64ToArrayBuffer(serializedResponse.body) : null;\n\n return new Response(deserializedBody, {\n status: serializedResponse.status,\n statusText: serializedResponse.statusText,\n headers: new Headers(serializedResponse.headers),\n });\n}\n","import { CloseEvent } from 'isomorphic-ws';\n\n/** Error thrown when the connection to the interceptor web socket server is unauthorized. */\nclass UnauthorizedWebSocketConnectionError extends Error {\n constructor(readonly event: CloseEvent) {\n super(`${event.reason} (code ${event.code})`);\n this.name = 'UnauthorizedWebSocketConnectionError';\n }\n}\n\nexport default UnauthorizedWebSocketConnectionError;\n","import ClientSocket, { type WebSocketServer as ServerSocket } from 'isomorphic-ws';\n\nimport { WebSocketControlMessage } from '@/webSocket/constants';\nimport UnauthorizedWebSocketConnectionError from '@/webSocket/errors/UnauthorizedWebSocketConnectionError';\n\nclass WebSocketTimeoutError extends Error {}\n\nexport class WebSocketOpenTimeoutError extends WebSocketTimeoutError {\n constructor(reachedTimeout: number) {\n super(`Web socket open timed out after ${reachedTimeout}ms.`);\n this.name = 'WebSocketOpenTimeoutError';\n }\n}\n\nexport class WebSocketMessageTimeoutError extends WebSocketTimeoutError {\n constructor(reachedTimeout: number) {\n super(`Web socket message timed out after ${reachedTimeout}ms.`);\n this.name = 'WebSocketMessageTimeoutError';\n }\n}\n\nexport class WebSocketMessageAbortError extends WebSocketTimeoutError {\n constructor() {\n super('Web socket message was aborted.');\n this.name = 'WebSocketMessageAbortError';\n }\n}\n\nexport class WebSocketCloseTimeoutError extends WebSocketTimeoutError {\n constructor(reachedTimeout: number) {\n super(`Web socket close timed out after ${reachedTimeout}ms.`);\n this.name = 'WebSocketCloseTimeoutError';\n }\n}\n\nexport const DEFAULT_WEB_SOCKET_LIFECYCLE_TIMEOUT = 60 * 1000;\nexport const DEFAULT_WEB_SOCKET_MESSAGE_TIMEOUT = 3 * 60 * 1000;\n\nexport async function waitForOpenClientSocket(\n socket: ClientSocket,\n options: {\n timeout?: number;\n waitForAuthentication?: boolean;\n } = {},\n) {\n const { timeout: timeoutDuration = DEFAULT_WEB_SOCKET_LIFECYCLE_TIMEOUT, waitForAuthentication = false } = options;\n\n const isAlreadyOpen = socket.readyState === socket.OPEN;\n\n if (isAlreadyOpen) {\n return;\n }\n\n await new Promise<void>((resolve, reject) => {\n function removeAllSocketListeners() {\n socket.removeEventListener('message', handleSocketMessage); // eslint-disable-line @typescript-eslint/no-use-before-define\n socket.removeEventListener('open', handleOpenSuccess); // eslint-disable-line @typescript-eslint/no-use-before-define\n socket.removeEventListener('error', handleOpenError); // eslint-disable-line @typescript-eslint/no-use-before-define\n socket.removeEventListener('close', handleClose); // eslint-disable-line @typescript-eslint/no-use-before-define\n }\n\n function handleOpenError(error: unknown) {\n removeAllSocketListeners();\n reject(error);\n }\n\n function handleClose(event: ClientSocket.CloseEvent) {\n const isUnauthorized = event.code === 1008;\n\n /* istanbul ignore else -- @preserve\n * An unauthorized close event is the only one we expect to happen here. */\n if (isUnauthorized) {\n const unauthorizedError = new UnauthorizedWebSocketConnectionError(event);\n handleOpenError(unauthorizedError);\n } else {\n handleOpenError(event);\n }\n }\n\n const openTimeout = setTimeout(() => {\n const timeoutError = new WebSocketOpenTimeoutError(timeoutDuration);\n handleOpenError(timeoutError);\n }, timeoutDuration);\n\n function handleOpenSuccess() {\n removeAllSocketListeners();\n clearTimeout(openTimeout);\n resolve();\n }\n\n function handleSocketMessage(message: ClientSocket.MessageEvent) {\n const hasValidAuth = message.data === ('socket:auth:valid' satisfies WebSocketControlMessage);\n\n /* istanbul ignore else -- @preserve\n * We currently only support the 'socket:auth:valid' message and it is the only possible control message here. */\n if (hasValidAuth) {\n handleOpenSuccess();\n }\n }\n\n if (waitForAuthentication) {\n socket.addEventListener('message', handleSocketMessage);\n } else {\n socket.addEventListener('open', handleOpenSuccess);\n }\n\n socket.addEventListener('error', handleOpenError);\n socket.addEventListener('close', handleClose);\n });\n}\n\nexport async function closeClientSocket(socket: ClientSocket, options: { timeout?: number } = {}) {\n const { timeout: timeoutDuration = DEFAULT_WEB_SOCKET_LIFECYCLE_TIMEOUT } = options;\n\n const isAlreadyClosed = socket.readyState === socket.CLOSED;\n if (isAlreadyClosed) {\n return;\n }\n\n await new Promise<void>((resolve, reject) => {\n function removeAllSocketListeners() {\n socket.removeEventListener('error', handleError); // eslint-disable-line @typescript-eslint/no-use-before-define\n socket.removeEventListener('close', handleClose); // eslint-disable-line @typescript-eslint/no-use-before-define\n }\n\n function handleError(error: unknown) {\n removeAllSocketListeners();\n reject(error);\n }\n\n const closeTimeout = setTimeout(() => {\n const timeoutError = new WebSocketCloseTimeoutError(timeoutDuration);\n handleError(timeoutError);\n }, timeoutDuration);\n\n function handleClose() {\n removeAllSocketListeners();\n clearTimeout(closeTimeout);\n resolve();\n }\n\n socket.addEventListener('error', handleError);\n socket.addEventListener('close', handleClose);\n\n socket.close();\n });\n}\n\nexport async function closeServerSocket(socket: InstanceType<typeof ServerSocket>, options: { timeout?: number } = {}) {\n const { timeout: timeoutDuration = DEFAULT_WEB_SOCKET_LIFECYCLE_TIMEOUT } = options;\n\n await new Promise<void>((resolve, reject) => {\n const closeTimeout = setTimeout(() => {\n const timeoutError = new WebSocketCloseTimeoutError(timeoutDuration);\n reject(timeoutError);\n }, timeoutDuration);\n\n for (const client of socket.clients) {\n client.terminate();\n }\n\n socket.close((error) => {\n clearTimeout(closeTimeout);\n\n /* istanbul ignore if -- @preserve\n * This is not expected since the server is not stopped unless it is running. */\n if (error) {\n reject(error);\n } else {\n resolve();\n }\n });\n });\n}\n","export const WEB_SOCKET_CONTROL_MESSAGES = Object.freeze(['socket:auth:valid'] as const);\nexport type WebSocketControlMessage = (typeof WEB_SOCKET_CONTROL_MESSAGES)[number];\n","class InvalidWebSocketMessageError extends Error {\n constructor(message: unknown) {\n super(`Web socket message is invalid and could not be parsed: ${message}`);\n this.name = 'InvalidWebSocketMessageError';\n }\n}\n\nexport default InvalidWebSocketMessageError;\n","class NotRunningWebSocketHandlerError extends Error {\n constructor() {\n super('Web socket handler is not running.');\n this.name = 'NotRunningWebSocketHandlerError';\n }\n}\n\nexport default NotRunningWebSocketHandlerError;\n","import { Collection } from '@zimic/utils/types';\nimport ClientSocket from 'isomorphic-ws';\n\nimport { importCrypto } from '@/utils/crypto';\nimport {\n DEFAULT_WEB_SOCKET_LIFECYCLE_TIMEOUT,\n DEFAULT_WEB_SOCKET_MESSAGE_TIMEOUT,\n WebSocketMessageAbortError,\n WebSocketMessageTimeoutError,\n closeClientSocket,\n waitForOpenClientSocket,\n} from '@/utils/webSocket';\n\nimport { WEB_SOCKET_CONTROL_MESSAGES, WebSocketControlMessage } from './constants';\nimport InvalidWebSocketMessageError from './errors/InvalidWebSocketMessageError';\nimport NotRunningWebSocketHandlerError from './errors/NotRunningWebSocketHandlerError';\nimport {\n WebSocketEventMessageListener,\n WebSocketReplyMessageListener,\n WebSocketReplyMessage,\n WebSocketEventMessage,\n WebSocketSchema,\n WebSocketChannel,\n WebSocketChannelWithReply,\n WebSocketChannelWithNoReply,\n WebSocketMessage,\n} from './types';\n\ninterface WebSocketRequestAbortOptions<Schema extends WebSocketSchema> {\n shouldAbortRequest?: (request: WebSocketEventMessage<Schema>) => boolean;\n}\n\nabstract class WebSocketHandler<Schema extends WebSocketSchema> {\n private sockets = new Set<ClientSocket>();\n\n socketTimeout: number;\n messageTimeout: number;\n\n private channelListeners: {\n [Channel in WebSocketChannel<Schema>]?: {\n event: Set<WebSocketEventMessageListener<Schema, Channel>>;\n reply: Set<WebSocketReplyMessageListener<Schema, Channel>>;\n };\n } = {};\n\n private socketListeners = {\n abortRequests: new Map<ClientSocket, Set<(options: WebSocketRequestAbortOptions<Schema>) => void>>(),\n };\n\n protected constructor(options: { socketTimeout?: number; messageTimeout?: number }) {\n this.socketTimeout = options.socketTimeout ?? DEFAULT_WEB_SOCKET_LIFECYCLE_TIMEOUT;\n this.messageTimeout = options.messageTimeout ?? DEFAULT_WEB_SOCKET_MESSAGE_TIMEOUT;\n }\n\n abstract isRunning: boolean;\n\n protected async registerSocket(socket: ClientSocket, options: { waitForAuthentication?: boolean } = {}) {\n const openPromise = waitForOpenClientSocket(socket, {\n timeout: this.socketTimeout,\n waitForAuthentication: options.waitForAuthentication,\n });\n\n const handleSocketMessage = async (rawMessage: ClientSocket.MessageEvent) => {\n await this.handleSocketMessage(socket, rawMessage);\n };\n socket.addEventListener('message', handleSocketMessage);\n\n await openPromise;\n\n /* istanbul ignore next -- @preserve\n * It is difficult to reliably simulate socket errors in tests. */\n function handleSocketError(error: ClientSocket.ErrorEvent) {\n console.error(error);\n }\n socket.addEventListener('error', handleSocketError);\n\n const handleSocketClose = () => {\n this.sockets.delete(socket);\n\n this.emitSocket('abortRequests', socket);\n this.socketListeners.abortRequests.delete(socket);\n\n socket.removeEventListener('message', handleSocketMessage);\n socket.removeEventListener('close', handleSocketClose);\n socket.removeEventListener('error', handleSocketError);\n };\n\n socket.addEventListener('close', handleSocketClose);\n\n this.sockets.add(socket);\n }\n\n private handleSocketMessage = async (socket: ClientSocket, rawMessage: ClientSocket.MessageEvent) => {\n try {\n if (this.isControlMessageData(rawMessage.data)) {\n return;\n }\n\n const stringifiedMessageData = this.readRawMessageData(rawMessage.data);\n const parsedMessageData = this.parseMessage(stringifiedMessageData);\n await this.notifyListeners(parsedMessageData, socket);\n } catch (error) {\n console.error(error);\n }\n };\n\n private isControlMessageData(messageData: ClientSocket.Data): messageData is WebSocketControlMessage {\n return (\n typeof messageData === 'string' && WEB_SOCKET_CONTROL_MESSAGES.includes(messageData as WebSocketControlMessage)\n );\n }\n\n private readRawMessageData(data: ClientSocket.Data) {\n /* istanbul ignore else -- @preserve\n * All supported websocket messages should be encoded as strings. */\n if (typeof data === 'string') {\n return data;\n } else {\n throw new InvalidWebSocketMessageError(data);\n }\n }\n\n private parseMessage(stringifiedMessage: string): WebSocketMessage<Schema> {\n let parsedMessage: unknown;\n\n try {\n parsedMessage = JSON.parse(stringifiedMessage) as unknown;\n } catch {\n throw new InvalidWebSocketMessageError(stringifiedMessage);\n }\n\n if (!this.isMessage(parsedMessage)) {\n throw new InvalidWebSocketMessageError(stringifiedMessage);\n }\n\n if (this.isReplyMessage(parsedMessage)) {\n return {\n id: parsedMessage.id,\n channel: parsedMessage.channel,\n requestId: parsedMessage.requestId,\n data: parsedMessage.data,\n };\n }\n\n return {\n id: parsedMessage.id,\n channel: parsedMessage.channel,\n data: parsedMessage.data,\n };\n }\n\n private isMessage(message: unknown): message is WebSocketMessage<Schema> {\n return (\n typeof message === 'object' &&\n message !== null &&\n 'id' in message &&\n typeof message.id === 'string' &&\n 'channel' in message &&\n typeof message.channel === 'string' &&\n (!('requestId' in message) || typeof message.requestId === 'string')\n );\n }\n\n isChannelEvent<Channel extends WebSocketChannel<Schema>>(\n event: WebSocketEventMessage<Schema>,\n channel: Channel,\n ): event is WebSocketEventMessage<Schema, Channel> {\n return event.channel === channel;\n }\n\n private async notifyListeners(message: WebSocketMessage<Schema>, socket: ClientSocket) {\n if (this.isReplyMessage(message)) {\n await this.notifyReplyListeners(message, socket);\n } else {\n await this.notifyEventListeners(message, socket);\n }\n }\n\n private async notifyReplyListeners(message: WebSocketReplyMessage<Schema>, socket: ClientSocket) {\n /* istanbul ignore next -- @preserve\n * Reply listeners are always present when notified in normal conditions. If they were not present, the request\n * would reach a timeout and not be responded. The empty set serves as a fallback. */\n const listeners = this.channelListeners[message.channel]?.reply ?? new Set();\n\n const listenerPromises = Array.from(listeners, async (listener) => {\n await listener(message, socket);\n });\n\n await Promise.all(listenerPromises);\n }\n\n private async notifyEventListeners(message: WebSocketEventMessage<Schema>, socket: ClientSocket) {\n const listeners = this.channelListeners[message.channel]?.event ?? new Set();\n\n const listenerPromises = Array.from(listeners, async (listener) => {\n const replyData = await listener(message, socket);\n await this.reply(message, replyData, { sockets: [socket] });\n });\n\n await Promise.all(listenerPromises);\n }\n\n protected async closeClientSockets(sockets: Collection<ClientSocket> = this.sockets) {\n const closingPromises = Array.from(sockets, async (socket) => {\n await closeClientSocket(socket, { timeout: this.socketTimeout });\n });\n await Promise.all(closingPromises);\n }\n\n private async createEventMessage<Channel extends WebSocketChannel<Schema>>(\n channel: Channel,\n eventData: WebSocketEventMessage<Schema, Channel>['data'],\n ) {\n const crypto = await importCrypto();\n\n const eventMessage: WebSocketEventMessage<Schema, Channel> = {\n id: crypto.randomUUID(),\n channel,\n data: eventData,\n };\n return eventMessage;\n }\n\n async send<Channel extends WebSocketChannelWithNoReply<Schema>>(\n channel: Channel,\n eventData: WebSocketEventMessage<Schema, Channel>['data'],\n options: {\n sockets?: Collection<ClientSocket>;\n } = {},\n ) {\n const event = await this.createEventMessage(channel, eventData);\n this.sendMessage(event, options.sockets);\n }\n\n async request<Channel extends WebSocketChannelWithReply<Schema>>(\n channel: Channel,\n requestData: WebSocketEventMessage<Schema, Channel>['data'],\n options: {\n sockets?: Collection<ClientSocket>;\n } = {},\n ) {\n const request = await this.createEventMessage(channel, requestData);\n this.sendMessage(request, options.sockets);\n\n const response = await this.waitForReply(channel, request, options.sockets);\n return response.data;\n }\n\n async waitForReply<Channel extends WebSocketChannelWithReply<Schema>>(\n channel: Channel,\n request: WebSocketEventMessage<Schema, Channel>,\n sockets: Collection<ClientSocket> = this.sockets,\n ) {\n return new Promise<WebSocketReplyMessage<Schema, Channel>>((resolve, reject) => {\n const replyTimeout = setTimeout(() => {\n this.offChannel('reply', channel, replyListener); // eslint-disable-line @typescript-eslint/no-use-before-define\n\n for (const socket of sockets) {\n this.offSocket('abortRequests', socket, abortRequestsHandler); // eslint-disable-line @typescript-eslint/no-use-before-define\n }\n\n const timeoutError = new WebSocketMessageTimeoutError(this.messageTimeout);\n reject(timeoutError);\n }, this.messageTimeout);\n\n const replyListener = this.onChannel('reply', channel, (message) => {\n if (message.requestId !== request.id) {\n return;\n }\n\n clearTimeout(replyTimeout);\n\n this.offChannel('reply', channel, replyListener);\n\n for (const socket of sockets) {\n this.offSocket('abortRequests', socket, abortRequestsHandler); // eslint-disable-line @typescript-eslint/no-use-before-define\n }\n\n resolve(message);\n });\n\n const abortRequestsHandler = (options: WebSocketRequestAbortOptions<Schema>) => {\n const shouldAbortRequest = options.shouldAbortRequest === undefined || options.shouldAbortRequest(request);\n\n /* istanbul ignore if -- @preserve\n * Aborting requests is highly non-deterministic because it depends on specific timing of socket events. */\n if (!shouldAbortRequest) {\n return;\n }\n\n clearTimeout(replyTimeout);\n\n this.offChannel('reply', channel, replyListener);\n\n for (const socket of sockets) {\n this.offSocket('abortRequests', socket, abortRequestsHandler);\n }\n\n const abortError = new WebSocketMessageAbortError();\n reject(abortError);\n };\n\n for (const socket of sockets) {\n this.onSocket('abortRequests', socket, abortRequestsHandler);\n }\n });\n }\n\n private isReplyMessage<Channel extends WebSocketChannel<Schema>>(message: WebSocketMessage<Schema, Channel>) {\n return 'requestId' in message;\n }\n\n async reply<Channel extends WebSocketChannel<Schema>>(\n request: WebSocketEventMessage<Schema, Channel>,\n replyData: WebSocketReplyMessage<Schema, Channel>['data'],\n options: {\n sockets: Collection<ClientSocket>;\n },\n ) {\n const reply = await this.createReplyMessage(request, replyData);\n\n // If this handler received a request and was stopped before responding, discard any pending replies.\n if (this.isRunning) {\n this.sendMessage(reply, options.sockets);\n }\n }\n\n private async createReplyMessage<Channel extends WebSocketChannel<Schema>>(\n request: WebSocketEventMessage<Schema, Channel>,\n replyData: WebSocketReplyMessage<Schema, Channel>['data'],\n ) {\n const crypto = await importCrypto();\n\n const replyMessage: WebSocketReplyMessage<Schema, Channel> = {\n id: crypto.randomUUID(),\n channel: request.channel,\n requestId: request.id,\n data: replyData,\n };\n return replyMessage;\n }\n\n private sendMessage<Channel extends WebSocketChannel<Schema>>(\n message: WebSocketMessage<Schema, Channel>,\n sockets: Collection<ClientSocket> = this.sockets,\n ) {\n if (!this.isRunning) {\n throw new NotRunningWebSocketHandlerError();\n }\n\n const stringifiedMessage = JSON.stringify(message);\n\n for (const socket of sockets) {\n socket.send(stringifiedMessage);\n }\n }\n\n onChannel<Channel extends WebSocketChannel<Schema>, Listener extends WebSocketEventMessageListener<Schema, Channel>>(\n type: 'event',\n channel: Channel,\n eventListener: Listener,\n ): Listener;\n onChannel<Channel extends WebSocketChannel<Schema>, Listener extends WebSocketReplyMessageListener<Schema, Channel>>(\n type: 'reply',\n channel: Channel,\n replyListener: Listener,\n ): Listener;\n onChannel<\n Channel extends WebSocketChannel<Schema>,\n Listener extends WebSocketEventMessageListener<Schema, Channel> & WebSocketReplyMessageListener<Schema, Channel>,\n >(type: 'event' | 'reply', channel: Channel, listener: Listener): Listener {\n const listeners = this.getOrCreateChannelListeners<Channel>(channel);\n listeners[type].add(listener);\n return listener;\n }\n\n private getOrCreateChannelListeners<Channel extends WebSocketChannel<Schema>>(channel: Channel) {\n const listeners = this.channelListeners[channel] ?? {\n event: new Set(),\n reply: new Set(),\n };\n\n if (!this.channelListeners[channel]) {\n this.channelListeners[channel] = listeners;\n }\n\n return listeners;\n }\n\n offChannel<Channel extends WebSocketChannel<Schema>>(\n type: 'event',\n channel: Channel,\n eventListener: WebSocketEventMessageListener<Schema, Channel>,\n ): void;\n offChannel<Channel extends WebSocketChannel<Schema>>(\n type: 'reply',\n channel: Channel,\n replyListener: WebSocketReplyMessageListener<Schema, Channel>,\n ): void;\n offChannel<Channel extends WebSocketChannel<Schema>>(\n type: 'event' | 'reply',\n channel: Channel,\n listener: WebSocketEventMessageListener<Schema, Channel> & WebSocketReplyMessageListener<Schema, Channel>,\n ) {\n const listeners = this.channelListeners[channel];\n listeners?.[type].delete(listener);\n }\n\n onSocket<Listener extends (options: WebSocketRequestAbortOptions<Schema>) => void>(\n type: 'abortRequests',\n socket: ClientSocket,\n listener: Listener,\n ): Listener {\n const listeners = this.getOrCreateSocketListeners(type, socket);\n listeners.add(listener);\n return listener;\n }\n\n private getOrCreateSocketListeners(type: 'abortRequests', socket: ClientSocket) {\n const listeners = this.socketListeners[type].get(socket) ?? new Set();\n\n if (!this.socketListeners[type].has(socket)) {\n this.socketListeners[type].set(socket, listeners);\n }\n\n return listeners;\n }\n\n offSocket<Listener extends (options: WebSocketRequestAbortOptions<Schema>) => void>(\n type: 'abortRequests',\n socket: ClientSocket,\n listener: Listener,\n ) {\n const listeners = this.socketListeners[type].get(socket);\n listeners?.delete(listener);\n }\n\n emitSocket(type: 'abortRequests', socket: ClientSocket, options: WebSocketRequestAbortOptions<Schema> = {}) {\n for (const listener of this.socketListeners[type].get(socket) ?? []) {\n listener(options);\n }\n }\n\n offAny() {\n this.channelListeners = {};\n\n for (const listenersBySocket of Object.values(this.socketListeners)) {\n for (const listeners of listenersBySocket.values()) {\n listeners.clear();\n }\n }\n }\n}\n\nexport default WebSocketHandler;\n","import validateURLProtocol from '@zimic/utils/url/validateURLProtocol';\nimport ClientSocket from 'isomorphic-ws';\n\nimport { WebSocketSchema } from './types';\nimport WebSocketHandler from './WebSocketHandler';\n\nconst SUPPORTED_WEB_SOCKET_PROTOCOLS = ['ws', 'wss'];\n\ninterface WebSocketClientOptions {\n url: string;\n socketTimeout?: number;\n messageTimeout?: number;\n}\n\nclass WebSocketClient<Schema extends WebSocketSchema> extends WebSocketHandler<Schema> {\n private url: URL;\n\n private socket?: ClientSocket;\n\n constructor(options: WebSocketClientOptions) {\n super({\n socketTimeout: options.socketTimeout,\n messageTimeout: options.messageTimeout,\n });\n\n this.url = new URL(options.url);\n validateURLProtocol(this.url, SUPPORTED_WEB_SOCKET_PROTOCOLS);\n }\n\n get isRunning() {\n return this.socket !== undefined && this.socket.readyState === this.socket.OPEN;\n }\n\n async start(options: { parameters?: Record<string, string>; waitForAuthentication?: boolean } = {}) {\n const parametersAsString = options.parameters\n ? Object.entries(options.parameters)\n .map(([key, value]) => `${key}=${value}`)\n .map(encodeURIComponent)\n : [];\n\n this.socket = new ClientSocket(this.url, parametersAsString);\n\n try {\n await super.registerSocket(this.socket, options);\n } catch (error) {\n await this.stop();\n throw error;\n }\n }\n\n async stop() {\n super.offAny();\n\n if (this.socket) {\n await super.closeClientSockets([this.socket]);\n }\n\n this.socket = undefined;\n }\n}\n\nexport default WebSocketClient;\n","import { HttpMethod, HttpSchema } from '@zimic/http';\nimport validatePathParams from '@zimic/utils/url/validatePathParams';\n\nimport { HttpHandlerCommit, InterceptorServerWebSocketSchema } from '@/server/types/schema';\nimport { importCrypto } from '@/utils/crypto';\nimport { isClientSide, isServerSide } from '@/utils/environment';\nimport { deserializeRequest, serializeResponse } from '@/utils/fetch';\nimport { WebSocketMessageAbortError } from '@/utils/webSocket';\nimport { WebSocketEventMessage } from '@/webSocket/types';\nimport WebSocketClient from '@/webSocket/WebSocketClient';\n\nimport NotRunningHttpInterceptorError from '../interceptor/errors/NotRunningHttpInterceptorError';\nimport UnknownHttpInterceptorPlatformError from '../interceptor/errors/UnknownHttpInterceptorPlatformError';\nimport HttpInterceptorClient, { AnyHttpInterceptorClient } from '../interceptor/HttpInterceptorClient';\nimport { HttpInterceptorPlatform } from '../interceptor/types/options';\nimport HttpInterceptorWorker from './HttpInterceptorWorker';\nimport { HttpResponseFactoryContext } from './types/http';\nimport { MSWHttpResponseFactory } from './types/msw';\nimport { RemoteHttpInterceptorWorkerOptions } from './types/options';\n\ninterface HttpHandler {\n id: string;\n baseURL: string;\n method: HttpMethod;\n path: string;\n interceptor: AnyHttpInterceptorClient;\n createResponse: (context: HttpResponseFactoryContext) => Promise<Response | null>;\n}\n\nclass RemoteHttpInterceptorWorker extends HttpInterceptorWorker {\n private httpHandlers = new Map<HttpHandler['id'], HttpHandler>();\n\n webSocketClient: WebSocketClient<InterceptorServerWebSocketSchema>;\n private auth?: RemoteHttpInterceptorWorkerOptions['auth'];\n\n constructor(options: RemoteHttpInterceptorWorkerOptions) {\n super();\n\n this.webSocketClient = new WebSocketClient({\n url: this.getWebSocketServerURL(options.serverURL).toString(),\n });\n\n this.auth = options.auth;\n }\n\n get type() {\n return 'remote' as const;\n }\n\n private getWebSocketServerURL(serverURL: URL) {\n const webSocketServerURL = new URL(serverURL);\n webSocketServerURL.protocol = serverURL.protocol.replace(/^http(s)?:$/, 'ws$1:');\n return webSocketServerURL;\n }\n\n async start() {\n await super.sharedStart(async () => {\n this.webSocketClient.onChannel('event', 'interceptors/responses/create', this.createResponse);\n this.webSocketClient.onChannel('event', 'interceptors/responses/unhandled', this.handleUnhandledServerRequest);\n\n await this.webSocketClient.start({\n parameters: this.auth ? { token: this.auth.token } : undefined,\n waitForAuthentication: true,\n });\n\n this.platform = this.readPlatform();\n this.isRunning = true;\n });\n }\n\n private createResponse = async (\n message: WebSocketEventMessage<InterceptorServerWebSocketSchema, 'interceptors/responses/create'>,\n ) => {\n const { handlerId, request: serializedRequest } = message.data;\n\n const handler = this.httpHandlers.get(handlerId);\n const request = deserializeRequest(serializedRequest);\n\n try {\n const rawResponse = (await handler?.createResponse({ request })) ?? null;\n const response = rawResponse && request.method === 'HEAD' ? new Response(null, rawResponse) : rawResponse;\n\n if (response) {\n return { response: await serializeResponse(response) };\n }\n } catch (error) {\n console.error(error);\n }\n\n const strategy = await super.getUnhandledRequestStrategy(request, 'remote');\n await super.logUnhandledRequestIfNecessary(request, strategy);\n\n return { response: null };\n };\n\n private handleUnhandledServerRequest = async (\n message: WebSocketEventMessage<InterceptorServerWebSocketSchema, 'interceptors/responses/unhandled'>,\n ) => {\n const { request: serializedRequest } = message.data;\n const request = deserializeRequest(serializedRequest);\n\n const strategy = await super.getUnhandledRequestStrategy(request, 'remote');\n const { wasLogged } = await super.logUnhandledRequestIfNecessary(request, strategy);\n\n return { wasLogged };\n };\n\n private readPlatform(): HttpInterceptorPlatform {\n if (isServerSide()) {\n return 'node';\n }\n /* istanbul ignore else -- @preserve */\n if (isClientSide()) {\n return 'browser';\n }\n /* istanbul ignore next -- @preserve\n * Ignoring because checking unknown platforms is not configured in our test setup. */\n throw new UnknownHttpInterceptorPlatformError();\n }\n\n async stop() {\n await super.sharedStop(async () => {\n this.webSocketClient.offChannel('event', 'interceptors/responses/create', this.createResponse);\n this.webSocketClient.offChannel('event', 'interceptors/responses/unhandled', this.handleUnhandledServerRequest);\n\n await this.clearHandlers();\n\n await this.webSocketClient.stop();\n\n this.isRunning = false;\n });\n }\n\n async use<Schema extends HttpSchema>(\n interceptor: HttpInterceptorClient<Schema>,\n method: HttpMethod,\n path: string,\n createResponse: MSWHttpResponseFactory,\n ) {\n if (!this.isRunning) {\n throw new NotRunningHttpInterceptorError();\n }\n\n validatePathParams(path);\n\n const crypto = await importCrypto();\n\n const handler: HttpHandler = {\n id: crypto.randomUUID(),\n baseURL: interceptor.baseURLAsString,\n method,\n path,\n interceptor,\n async createResponse(context) {\n const response = await createResponse(context);\n return response;\n },\n };\n\n this.httpHandlers.set(handler.id, handler);\n\n await this.webSocketClient.request('interceptors/workers/commit', {\n id: handler.id,\n baseURL: handler.baseURL,\n method: handler.method,\n path: handler.path,\n });\n }\n\n async clearHandlers<Schema extends HttpSchema>(\n options: {\n interceptor?: HttpInterceptorClient<Schema>;\n } = {},\n ) {\n if (!this.isRunning) {\n throw new NotRunningHttpInterceptorError();\n }\n\n if (options.interceptor === undefined) {\n this.httpHandlers.clear();\n } else {\n for (const handler of this.httpHandlers.values()) {\n if (handler.interceptor === options.interceptor) {\n this.httpHandlers.delete(handler.id);\n }\n }\n }\n\n if (!this.webSocketClient.isRunning) {\n return;\n }\n\n const handlersToRecommit = Array.from<HttpHandler, HttpHandlerCommit>(this.httpHandlers.values(), (handler) => ({\n id: handler.id,\n baseURL: handler.baseURL,\n method: handler.method,\n path: handler.path,\n }));\n\n try {\n await this.webSocketClient.request('interceptors/workers/reset', handlersToRecommit);\n } catch (error) {\n /* istanbul ignore next -- @preserve\n *\n * If the socket is closed before receiving a response, the message is aborted with an error. This can happen if\n * we send a request message and the interceptor server closes the socket before sending a response. In this case,\n * we can safely ignore the error because we know that the server is shutting down and resetting is no longer\n * necessary.\n *\n * Due to the rare nature of this edge case, we can't reliably reproduce it in tests. */\n const isMessageAbortError = error instanceof WebSocketMessageAbortError;\n\n /* istanbul ignore next -- @preserve */\n if (!isMessageAbortError) {\n throw error;\n }\n }\n }\n\n get interceptorsWithHandlers() {\n const interceptors = Array.from(this.httpHandlers.values(), (handler) => handler.interceptor);\n return interceptors;\n }\n}\n\nexport default RemoteHttpInterceptorWorker;\n","import LocalHttpInterceptorWorker from './LocalHttpInterceptorWorker';\nimport RemoteHttpInterceptorWorker from './RemoteHttpInterceptorWorker';\nimport {\n HttpInterceptorWorkerOptions,\n LocalHttpInterceptorWorkerOptions,\n RemoteHttpInterceptorWorkerOptions,\n} from './types/options';\n\nexport function createHttpInterceptorWorker(options: LocalHttpInterceptorWorkerOptions): LocalHttpInterceptorWorker;\nexport function createHttpInterceptorWorker(options: RemoteHttpInterceptorWorkerOptions): RemoteHttpInterceptorWorker;\nexport function createHttpInterceptorWorker(\n options: HttpInterceptorWorkerOptions,\n): LocalHttpInterceptorWorker | RemoteHttpInterceptorWorker;\nexport function createHttpInterceptorWorker(\n options: HttpInterceptorWorkerOptions,\n): LocalHttpInterceptorWorker | RemoteHttpInterceptorWorker {\n if (options.type === 'local') {\n return new LocalHttpInterceptorWorker(options);\n } else {\n return new RemoteHttpInterceptorWorker(options);\n }\n}\n","import { createHttpInterceptorWorker } from '../interceptorWorker/factory';\nimport LocalHttpInterceptorWorker from '../interceptorWorker/LocalHttpInterceptorWorker';\nimport RemoteHttpInterceptorWorker from '../interceptorWorker/RemoteHttpInterceptorWorker';\nimport {\n LocalHttpInterceptorWorkerOptions,\n RemoteHttpInterceptorWorkerOptions,\n} from '../interceptorWorker/types/options';\nimport { AnyHttpInterceptorClient } from './HttpInterceptorClient';\n\ninterface RemoteWorkerKeyOptions {\n auth: RemoteHttpInterceptorWorkerOptions['auth'];\n}\n\nclass HttpInterceptorStore {\n private static _localWorker?: LocalHttpInterceptorWorker;\n private static runningLocalInterceptors = new Set<AnyHttpInterceptorClient>();\n\n private static remoteWorkers = new Map<string, RemoteHttpInterceptorWorker>();\n private static runningRemoteInterceptors = new Map<string, Set<AnyHttpInterceptorClient>>();\n\n private class = HttpInterceptorStore;\n\n get localWorker() {\n return this.class._localWorker;\n }\n\n private getRemoteWorkerKey(baseURL: URL, options: RemoteWorkerKeyOptions) {\n const key = [`${baseURL.origin}${baseURL.pathname}`];\n\n if (options.auth) {\n key.push(options.auth.token);\n }\n\n return key.join(':');\n }\n\n remoteWorker(baseURL: URL, options: RemoteWorkerKeyOptions) {\n const remoteWorkerKey = this.getRemoteWorkerKey(baseURL, options);\n return this.class.remoteWorkers.get(remoteWorkerKey);\n }\n\n get numberOfRunningLocalInterceptors() {\n return this.class.runningLocalInterceptors.size;\n }\n\n numberOfRunningRemoteInterceptors(baseURL: URL) {\n const runningInterceptors = this.class.runningRemoteInterceptors.get(baseURL.origin);\n return runningInterceptors?.size ?? 0;\n }\n\n markLocalInterceptorAsRunning(interceptor: AnyHttpInterceptorClient, isRunning: boolean) {\n if (isRunning) {\n this.class.runningLocalInterceptors.add(interceptor);\n } else {\n this.class.runningLocalInterceptors.delete(interceptor);\n }\n }\n\n markRemoteInterceptorAsRunning(interceptor: AnyHttpInterceptorClient, isRunning: boolean, baseURL: URL) {\n const runningInterceptors =\n this.class.runningRemoteInterceptors.get(baseURL.origin) ?? this.createRunningInterceptorsSet(baseURL);\n\n if (isRunning) {\n runningInterceptors.add(interceptor);\n } else {\n runningInterceptors.delete(interceptor);\n }\n }\n\n private createRunningInterceptorsSet(baseURL: URL) {\n const runningInterceptors = new Set<AnyHttpInterceptorClient>();\n this.class.runningRemoteInterceptors.set(baseURL.origin, runningInterceptors);\n return runningInterceptors;\n }\n\n getOrCreateLocalWorker(workerOptions: Omit<LocalHttpInterceptorWorkerOptions, 'type'>) {\n const existingWorker = this.class._localWorker;\n if (existingWorker) {\n return existingWorker;\n }\n\n const createdWorker = createHttpInterceptorWorker({ ...workerOptions, type: 'local' });\n this.class._localWorker = createdWorker;\n\n return createdWorker;\n }\n\n deleteLocalWorker() {\n this.class._localWorker = undefined;\n }\n\n getOrCreateRemoteWorker(workerOptions: Omit<RemoteHttpInterceptorWorkerOptions, 'type'>) {\n const remoteWorkerKey = this.getRemoteWorkerKey(workerOptions.serverURL, { auth: workerOptions.auth });\n const existingWorker = this.class.remoteWorkers.get(remoteWorkerKey);\n\n if (existingWorker) {\n return existingWorker;\n }\n\n const createdWorker = createHttpInterceptorWorker({ ...workerOptions, type: 'remote' });\n this.class.remoteWorkers.set(remoteWorkerKey, createdWorker);\n\n return createdWorker;\n }\n\n deleteRemoteWorker(baseURL: URL, options: RemoteWorkerKeyOptions) {\n const remoteWorkerKey = this.getRemoteWorkerKey(baseURL, options);\n this.class.remoteWorkers.delete(remoteWorkerKey);\n }\n}\n\nexport default HttpInterceptorStore;\n","import { HttpSchema, HttpSchemaMethod, HttpSchemaPath } from '@zimic/http';\n\nimport LocalHttpRequestHandler from '../requestHandler/LocalHttpRequestHandler';\nimport HttpInterceptorClient from './HttpInterceptorClient';\nimport HttpInterceptorStore from './HttpInterceptorStore';\nimport { SyncHttpInterceptorMethodHandler } from './types/handlers';\nimport { LocalHttpInterceptorOptions, UnhandledRequestStrategy } from './types/options';\nimport { HttpInterceptorRequestSaving, LocalHttpInterceptor as PublicLocalHttpInterceptor } from './types/public';\n\nclass LocalHttpInterceptor<Schema extends HttpSchema> implements PublicLocalHttpInterceptor<Schema> {\n private store = new HttpInterceptorStore();\n\n client: HttpInterceptorClient<Schema, typeof LocalHttpRequestHandler>;\n\n constructor(options: LocalHttpInterceptorOptions) {\n const baseURL = new URL(options.baseURL);\n\n this.client = new HttpInterceptorClient<Schema, typeof LocalHttpRequestHandler>({\n store: this.store,\n baseURL,\n createWorker: () => {\n return this.store.getOrCreateLocalWorker({});\n },\n deleteWorker: () => {\n this.store.deleteLocalWorker();\n },\n Handler: LocalHttpRequestHandler,\n onUnhandledRequest: options.onUnhandledRequest,\n requestSaving: options.requestSaving,\n });\n }\n\n get type() {\n return 'local' as const;\n }\n\n get baseURL() {\n return this.client.baseURLAsString;\n }\n\n set baseURL(baseURL: LocalHttpInterceptorOptions['baseURL']) {\n this.client.baseURL = new URL(baseURL);\n }\n\n get requestSaving() {\n return this.client.requestSaving;\n }\n\n set requestSaving(requestSaving: HttpInterceptorRequestSaving) {\n this.client.requestSaving = requestSaving;\n }\n\n get onUnhandledRequest() {\n return this.client.onUnhandledRequest;\n }\n\n set onUnhandledRequest(onUnhandledRequest: UnhandledRequestStrategy.Local | undefined) {\n this.client.onUnhandledRequest = onUnhandledRequest;\n }\n\n get platform() {\n return this.client.platform;\n }\n\n get isRunning() {\n return this.client.isRunning;\n }\n\n async start() {\n if (this.isRunning) {\n return;\n }\n\n await this.client.start();\n }\n\n async stop() {\n if (!this.isRunning) {\n return;\n }\n\n this.clear();\n await this.client.stop();\n }\n\n get = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.get(path);\n }) as unknown as SyncHttpInterceptorMethodHandler<Schema, 'GET'>;\n\n post = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.post(path);\n }) as unknown as SyncHttpInterceptorMethodHandler<Schema, 'POST'>;\n\n patch = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.patch(path);\n }) as unknown as SyncHttpInterceptorMethodHandler<Schema, 'PATCH'>;\n\n put = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.put(path);\n }) as unknown as SyncHttpInterceptorMethodHandler<Schema, 'PUT'>;\n\n delete = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.delete(path);\n }) as unknown as SyncHttpInterceptorMethodHandler<Schema, 'DELETE'>;\n\n head = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.head(path);\n }) as unknown as SyncHttpInterceptorMethodHandler<Schema, 'HEAD'>;\n\n options = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.options(path);\n }) as unknown as SyncHttpInterceptorMethodHandler<Schema, 'OPTIONS'>;\n\n checkTimes() {\n this.client.checkTimes();\n }\n\n clear() {\n void this.client.clear();\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyLocalHttpInterceptor = LocalHttpInterceptor<any>;\n\nexport default LocalHttpInterceptor;\n","import { HttpSchema, HttpSchemaMethod, HttpSchemaPath } from '@zimic/http';\n\nimport RemoteHttpRequestHandler from '../requestHandler/RemoteHttpRequestHandler';\nimport RunningHttpInterceptorError from './errors/RunningHttpInterceptorError';\nimport HttpInterceptorClient from './HttpInterceptorClient';\nimport HttpInterceptorStore from './HttpInterceptorStore';\nimport { AsyncHttpInterceptorMethodHandler } from './types/handlers';\nimport { RemoteHttpInterceptorOptions, UnhandledRequestStrategy } from './types/options';\nimport { HttpInterceptorRequestSaving, RemoteHttpInterceptor as PublicRemoteHttpInterceptor } from './types/public';\n\nclass RemoteHttpInterceptor<Schema extends HttpSchema> implements PublicRemoteHttpInterceptor<Schema> {\n private store = new HttpInterceptorStore();\n client: HttpInterceptorClient<Schema, typeof RemoteHttpRequestHandler>;\n\n private _auth?: RemoteHttpInterceptorOptions['auth'];\n\n constructor(options: RemoteHttpInterceptorOptions) {\n this._auth = options.auth;\n\n const baseURL = new URL(options.baseURL);\n\n this.client = new HttpInterceptorClient<Schema, typeof RemoteHttpRequestHandler>({\n store: this.store,\n baseURL,\n createWorker: () => {\n return this.store.getOrCreateRemoteWorker({\n serverURL: baseURL,\n auth: this._auth,\n });\n },\n deleteWorker: () => {\n this.store.deleteRemoteWorker(baseURL, { auth: options.auth });\n },\n Handler: RemoteHttpRequestHandler,\n onUnhandledRequest: options.onUnhandledRequest,\n requestSaving: options.requestSaving,\n });\n }\n\n get type() {\n return 'remote' as const;\n }\n\n get baseURL() {\n return this.client.baseURLAsString;\n }\n\n set baseURL(baseURL: string) {\n this.client.baseURL = new URL(baseURL);\n }\n\n get requestSaving() {\n return this.client.requestSaving;\n }\n\n set requestSaving(requestSaving: HttpInterceptorRequestSaving) {\n this.client.requestSaving = requestSaving;\n }\n\n get auth() {\n return this._auth;\n }\n\n set auth(auth: RemoteHttpInterceptorOptions['auth'] | undefined) {\n const cannotChangeAuthWhileRunningMessage =\n 'Did you forget to call `await interceptor.stop()` before changing the authentication parameters?';\n\n if (this.isRunning) {\n throw new RunningHttpInterceptorError(cannotChangeAuthWhileRunningMessage);\n }\n\n if (!auth) {\n this._auth = undefined;\n return;\n }\n\n this._auth = new Proxy(auth, {\n set: (target, property, value) => {\n if (this.isRunning) {\n throw new RunningHttpInterceptorError(cannotChangeAuthWhileRunningMessage);\n }\n return Reflect.set(target, property, value);\n },\n });\n }\n\n get onUnhandledRequest() {\n return this.client.onUnhandledRequest;\n }\n\n set onUnhandledRequest(onUnhandledRequest: UnhandledRequestStrategy.Remote | undefined) {\n this.client.onUnhandledRequest = onUnhandledRequest;\n }\n\n get platform() {\n return this.client.platform;\n }\n\n get isRunning() {\n return this.client.isRunning;\n }\n\n async start() {\n if (this.isRunning) {\n return;\n }\n\n await this.client.start();\n }\n\n async stop() {\n if (!this.isRunning) {\n return;\n }\n\n await this.clear();\n await this.client.stop();\n }\n\n get = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.get(path);\n }) as unknown as AsyncHttpInterceptorMethodHandler<Schema, 'GET'>;\n\n post = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.post(path);\n }) as unknown as AsyncHttpInterceptorMethodHandler<Schema, 'POST'>;\n\n patch = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.patch(path);\n }) as unknown as AsyncHttpInterceptorMethodHandler<Schema, 'PATCH'>;\n\n put = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.put(path);\n }) as unknown as AsyncHttpInterceptorMethodHandler<Schema, 'PUT'>;\n\n delete = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.delete(path);\n }) as unknown as AsyncHttpInterceptorMethodHandler<Schema, 'DELETE'>;\n\n head = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.head(path);\n }) as unknown as AsyncHttpInterceptorMethodHandler<Schema, 'HEAD'>;\n\n options = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.options(path);\n }) as unknown as AsyncHttpInterceptorMethodHandler<Schema, 'OPTIONS'>;\n\n checkTimes() {\n return new Promise<void>((resolve, reject) => {\n try {\n this.client.checkTimes();\n resolve();\n } catch (error) {\n reject(error);\n }\n });\n }\n\n async clear() {\n await this.client.clear();\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyRemoteHttpInterceptor = RemoteHttpInterceptor<any>;\n\nexport default RemoteHttpInterceptor;\n","import { HttpSchema } from '@zimic/http';\n\nimport UnknownHttpInterceptorTypeError from './errors/UnknownHttpInterceptorTypeError';\nimport LocalHttpInterceptor from './LocalHttpInterceptor';\nimport RemoteHttpInterceptor from './RemoteHttpInterceptor';\nimport { HttpInterceptorOptions, LocalHttpInterceptorOptions, RemoteHttpInterceptorOptions } from './types/options';\nimport {\n LocalHttpInterceptor as PublicLocalHttpInterceptor,\n RemoteHttpInterceptor as PublicRemoteHttpInterceptor,\n} from './types/public';\n\nfunction isLocalHttpInterceptorOptions(options: HttpInterceptorOptions): options is LocalHttpInterceptorOptions {\n return options.type === undefined || options.type === 'local';\n}\n\nfunction isRemoteHttpInterceptorOptions(options: HttpInterceptorOptions): options is RemoteHttpInterceptorOptions {\n return options.type === 'remote';\n}\n\n/** @see {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `createHttpInterceptor()` API reference} */\nexport function createHttpInterceptor<Schema extends HttpSchema>(\n options: LocalHttpInterceptorOptions,\n): PublicLocalHttpInterceptor<Schema>;\nexport function createHttpInterceptor<Schema extends HttpSchema>(\n options: RemoteHttpInterceptorOptions,\n): PublicRemoteHttpInterceptor<Schema>;\nexport function createHttpInterceptor<Schema extends HttpSchema>(\n options: HttpInterceptorOptions,\n): PublicLocalHttpInterceptor<Schema> | PublicRemoteHttpInterceptor<Schema>;\nexport function createHttpInterceptor<Schema extends HttpSchema>(\n options: HttpInterceptorOptions,\n): PublicLocalHttpInterceptor<Schema> | PublicRemoteHttpInterceptor<Schema> {\n const type = options.type;\n\n if (isLocalHttpInterceptorOptions(options)) {\n return new LocalHttpInterceptor<Schema>(options);\n } else if (isRemoteHttpInterceptorOptions(options)) {\n return new RemoteHttpInterceptor<Schema>(options);\n }\n\n throw new UnknownHttpInterceptorTypeError(type);\n}\n","import {\n InvalidFormDataError as HttpInvalidFormDataError,\n InvalidJSONError as HttpInvalidJSONError,\n} from '@zimic/http';\n\nexport { default as RunningHttpInterceptorError } from './interceptor/errors/RunningHttpInterceptorError';\nexport { default as NotRunningHttpInterceptorError } from './interceptor/errors/NotRunningHttpInterceptorError';\nexport { default as UnknownHttpInterceptorPlatformError } from './interceptor/errors/UnknownHttpInterceptorPlatformError';\nexport { default as UnknownHttpInterceptorTypeError } from './interceptor/errors/UnknownHttpInterceptorTypeError';\nexport { default as RequestSavingSafeLimitExceededError } from './interceptor/errors/RequestSavingSafeLimitExceededError';\n\nexport { default as UnregisteredBrowserServiceWorkerError } from './interceptorWorker/errors/UnregisteredBrowserServiceWorkerError';\n\nexport { default as DisabledRequestSavingError } from './requestHandler/errors/DisabledRequestSavingError';\nexport { default as TimesCheckError } from './requestHandler/errors/TimesCheckError';\n\nexport type {\n HttpRequestHandlerResponseDeclaration,\n HttpRequestHandlerResponseDeclarationFactory,\n HttpRequestHandlerResponseDelayFactory,\n HttpInterceptorRequest,\n HttpInterceptorResponse,\n InterceptedHttpInterceptorRequest,\n} from './requestHandler/types/requests';\n\nexport type {\n LocalHttpRequestHandler,\n RemoteHttpRequestHandler,\n SyncedRemoteHttpRequestHandler,\n PendingRemoteHttpRequestHandler,\n HttpRequestHandler,\n} from './requestHandler/types/public';\nexport type {\n HttpRequestHandlerRestriction,\n HttpRequestHandlerStaticRestriction,\n HttpRequestHandlerComputedRestriction,\n HttpRequestHandlerHeadersStaticRestriction,\n HttpRequestHandlerSearchParamsStaticRestriction,\n HttpRequestHandlerBodyStaticRestriction,\n} from './requestHandler/types/restrictions';\n\nexport type {\n HttpInterceptorType,\n HttpInterceptorPlatform,\n LocalHttpInterceptorOptions,\n RemoteHttpInterceptorOptions,\n HttpInterceptorOptions,\n UnhandledRequestStrategy,\n} from './interceptor/types/options';\n\nexport type { UnhandledHttpInterceptorRequest } from './interceptor/types/requests';\n\nexport type { InferHttpInterceptorSchema } from './interceptor/types/schema';\n\nexport type { LocalHttpInterceptor, RemoteHttpInterceptor, HttpInterceptor } from './interceptor/types/public';\n\nexport { createHttpInterceptor } from './interceptor/factory';\n\n/**\n * Error thrown when a value is not valid {@link https://developer.mozilla.org/docs/Web/API/FormData FormData}. HTTP\n * interceptors might throw this error when trying to parse the body of a request or response with the header\n * `'content-type': 'multipart/form-data'`, if the content cannot be parsed to form data.\n *\n * @deprecated This type has been moved to {@link https://zimic.dev/docs/http `@zimic/http`}. Please import\n * `InvalidFormDataError` from `@zimic/http` instead.\n *\n * ```ts\n * import { InvalidFormDataError } from '@zimic/http';\n * ```\n */\nexport class InvalidFormDataError extends HttpInvalidFormDataError {}\n\n/**\n * Error thrown when a value is not valid JSON. HTTP interceptors might throw this error when trying to parse the body\n * of a request or response with the header `'content-type': 'application/json'`, if the content cannot be parsed to\n * JSON.\n *\n * @deprecated This type has been moved to {@link https://zimic.dev/docs/http `@zimic/http`}. Please import\n * `InvalidJSONError` from `@zimic/http` instead.\n *\n * ```ts\n * import { InvalidJSONError } from '@zimic/http';\n * ```\n */\nexport class InvalidJSONError extends HttpInvalidJSONError {}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/http/interceptor/errors/RunningHttpInterceptorError.ts","../src/http/interceptor/errors/NotRunningHttpInterceptorError.ts","../src/http/interceptor/errors/UnknownHttpInterceptorPlatformError.ts","../src/http/interceptor/errors/UnknownHttpInterceptorTypeError.ts","../src/http/interceptor/errors/RequestSavingSafeLimitExceededError.ts","../src/cli/browser/shared/constants.ts","../src/http/interceptorWorker/errors/UnregisteredBrowserServiceWorkerError.ts","../src/http/requestHandler/errors/DisabledRequestSavingError.ts","../../zimic-utils/src/data/isDefined.ts","../../zimic-utils/src/data/isNonEmpty.ts","../../zimic-utils/src/import/createCachedDynamicImport.ts","../../zimic-utils/src/logging/Logger.ts","../src/utils/environment.ts","../src/utils/files.ts","../src/utils/logging.ts","../src/http/requestHandler/errors/TimesCheckError.ts","../../zimic-utils/src/data/blobEquals.ts","../../zimic-utils/src/data/isPrimitiveJSONValue.ts","../../zimic-utils/src/data/jsonContains.ts","../../zimic-utils/src/data/jsonEquals.ts","../../zimic-utils/src/time/waitForDelay.ts","../src/utils/data.ts","../src/utils/numbers.ts","../src/http/requestHandler/errors/NoResponseDefinitionError.ts","../src/http/requestHandler/errors/TimesDeclarationPointer.ts","../src/http/requestHandler/HttpRequestHandlerClient.ts","../src/http/requestHandler/LocalHttpRequestHandler.ts","../../zimic-utils/src/url/createRegexFromPath.ts","../../zimic-utils/src/url/excludeNonPathParams.ts","../../zimic-utils/src/url/validateURLProtocol.ts","../src/utils/arrays.ts","../src/utils/http.ts","../src/http/requestHandler/types/requests.ts","../src/http/interceptorWorker/constants.ts","../src/http/interceptorWorker/HttpInterceptorWorker.ts","../src/http/requestHandler/RemoteHttpRequestHandler.ts","../src/http/interceptor/HttpInterceptorClient.ts","../../zimic-utils/src/url/validatePathParams.ts","../src/http/interceptorWorker/LocalHttpInterceptorWorker.ts","../src/utils/crypto.ts","../src/utils/fetch.ts","../src/webSocket/errors/UnauthorizedWebSocketConnectionError.ts","../src/utils/webSocket.ts","../src/webSocket/constants.ts","../src/webSocket/errors/InvalidWebSocketMessageError.ts","../src/webSocket/errors/NotRunningWebSocketHandlerError.ts","../src/webSocket/WebSocketHandler.ts","../src/webSocket/WebSocketClient.ts","../src/http/interceptorWorker/RemoteHttpInterceptorWorker.ts","../src/http/interceptorWorker/factory.ts","../src/http/interceptor/HttpInterceptorStore.ts","../src/http/interceptor/LocalHttpInterceptor.ts","../src/http/interceptor/RemoteHttpInterceptor.ts","../src/http/interceptor/factory.ts","../src/http/index.ts"],"names":["color","value","HttpHeaders","HttpSearchParams","matchesRestriction","HttpFormData","protocol","interceptor","HttpInvalidFormDataError","HttpInvalidJSONError"],"mappings":";;;;;;;;;;AAOA,IAAM,2BAAA,GAAN,cAA0C,KAAA,CAAM;AAAA,EAC9C,YAAY,iBAAA,EAA2B;AACrC,IAAA,KAAA,CAAM,CAAA,4BAAA,EAA+B,iBAAiB,CAAA,CAAE,CAAA;AACxD,IAAA,IAAA,CAAK,IAAA,GAAO,6BAAA;AAAA,EACd;AACF,CAAA;AAEA,IAAO,mCAAA,GAAQ;;;ACPf,IAAM,8BAAA,GAAN,cAA6C,KAAA,CAAM;AAAA,EACjD,WAAA,GAAc;AACZ,IAAA,KAAA,CAAM,iFAAiF,CAAA;AACvF,IAAA,IAAA,CAAK,IAAA,GAAO,gCAAA;AAAA,EACd;AACF,CAAA;AAEA,IAAO,sCAAA,GAAQ;;;ACRf,IAAM,mCAAA,GAAN,cAAkD,KAAA,CAAM;AAAA;AAAA;AAAA,EAGtD,WAAA,GAAc;AACZ,IAAA,KAAA,CAAM,+BAA+B,CAAA;AACrC,IAAA,IAAA,CAAK,IAAA,GAAO,qCAAA;AAAA,EACd;AACF,CAAA;AAEA,IAAO,2CAAA,GAAQ;;;ACbf,IAAM,+BAAA,GAAN,cAA8C,SAAA,CAAU;AAAA,EACtD,YAAY,WAAA,EAAsB;AAChC,IAAA,KAAA;AAAA,MACE,CAAA,+BAAA,EAAkC,WAAW,CAAA,6BAAA,EACvC,OAAqC,UACrC,QAAsC,CAAA,EAAA;AAAA,KAC9C;AACA,IAAA,IAAA,CAAK,IAAA,GAAO,iCAAA;AAAA,EACd;AACF,CAAA;AAEA,IAAO,uCAAA,GAAQ;;;ACRf,IAAM,mCAAA,GAAN,cAAkD,SAAA,CAAU;AAAA,EAC1D,WAAA,CAAY,uBAA+B,SAAA,EAAmB;AAC5D,IAAA,KAAA;AAAA,MACE,CAAA,oDAAA,EAAuD,qBAAqB,CA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,IAAA,OAAO,IAAI,OAAA,CAAc,CAAC,OAAA,EAAS,MAAA,KAAW;AAC5C,MAAA,IAAI;AACF,QAAA,IAAA,CAAK,OAAO,UAAA,EAAW;AACvB,QAAA,OAAA,EAAQ;AAAA,MACV,SAAS,KAAA,EAAO;AACd,QAAA,MAAA,CAAO,KAAK,CAAA;AAAA,MACd;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AAAA,EAEA,MAAM,KAAA,GAAQ;AACZ,IAAA,MAAM,IAAA,CAAK,OAAO,KAAA,EAAM;AAAA,EAC1B;AACF,CAAA;AAKA,IAAO,6BAAA,GAAQ,qBAAA;;;AC3Jf,SAAS,8BAA8B,OAAA,EAAyE;AAC9G,EAAA,OAAO,OAAA,CAAQ,IAAA,KAAS,MAAA,IAAa,OAAA,CAAQ,IAAA,KAAS,OAAA;AACxD;AAEA,SAAS,+BAA+B,OAAA,EAA0E;AAChH,EAAA,OAAO,QAAQ,IAAA,KAAS,QAAA;AAC1B;AAYO,SAAS,sBACd,OAAA,EAC0E;AAC1E,EAAA,MAAM,OAAO,OAAA,CAAQ,IAAA;AAErB,EAAA,IAAI,6BAAA,CAA8B,OAAO,CAAA,EAAG;AAC1C,IAAA,OAAO,IAAI,6BAA6B,OAAO,CAAA;AAAA,EACjD,CAAA,MAAA,IAAW,8BAAA,CAA+B,OAAO,CAAA,EAAG;AAClD,IAAA,OAAO,IAAI,8BAA8B,OAAO,CAAA;AAAA,EAClD;AAEA,EAAA,MAAM,IAAI,wCAAgC,IAAI,CAAA;AAChD;;;AC6BO,IAAM,oBAAA,GAAN,cAAmCQ,sBAAA,CAAyB;AAAC;AAc7D,IAAM,gBAAA,GAAN,cAA+BC,kBAAA,CAAqB;AAAC","file":"http.mjs","sourcesContent":["/**\n * An error thrown when the interceptor is running and some operation requires it to be stopped first.\n *\n * @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorstart `interceptor.start()` API reference}\n * @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorstop `interceptor.stop()` API reference}\n * @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorisrunning `interceptor.isRunning` API reference}\n */\nclass RunningHttpInterceptorError extends Error {\n constructor(additionalMessage: string) {\n super(`The interceptor is running. ${additionalMessage}`);\n this.name = 'RunningHttpInterceptorError';\n }\n}\n\nexport default RunningHttpInterceptorError;\n","/**\n * An error thrown when the interceptor is not running and it's not possible to use the mocking utilities.\n *\n * @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorstart `interceptor.start()` API reference}\n * @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorstop `interceptor.stop()` API reference}\n * @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorisrunning `interceptor.isRunning` API reference}\n */\nclass NotRunningHttpInterceptorError extends Error {\n constructor() {\n super('Interceptor is not running. Did you forget to call `await interceptor.start()`?');\n this.name = 'NotRunningHttpInterceptorError';\n }\n}\n\nexport default NotRunningHttpInterceptorError;\n","/**\n * An error thrown when an unknown interceptor platform is detected. Currently, the platforms `node` and `browser` are\n * supported.\n *\n * @see {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorplatform `interceptor.platform` API reference}\n */\nclass UnknownHttpInterceptorPlatformError extends Error {\n /* istanbul ignore next -- @preserve\n * Ignoring because checking unknown platforms is currently not possible in our Vitest setup. */\n constructor() {\n super('Unknown interceptor platform.');\n this.name = 'UnknownHttpInterceptorPlatformError';\n }\n}\n\nexport default UnknownHttpInterceptorPlatformError;\n","import { HttpInterceptorType } from '../types/options';\n\nclass UnknownHttpInterceptorTypeError extends TypeError {\n constructor(unknownType: unknown) {\n super(\n `Unknown HTTP interceptor type: ${unknownType}. The available options are ` +\n `'${'local' satisfies HttpInterceptorType}' and ` +\n `'${'remote' satisfies HttpInterceptorType}'.`,\n );\n this.name = 'UnknownHttpInterceptorTypeError';\n }\n}\n\nexport default UnknownHttpInterceptorTypeError;\n","/**\n * Error thrown when the safe limit of saved intercepted requests is exceeded.\n *\n * @see {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `createHttpInterceptor` API reference}\n */\nclass RequestSavingSafeLimitExceededError extends TypeError {\n constructor(numberOfSavedRequests: number, safeLimit: number) {\n super(\n `The number of intercepted requests saved in memory (${numberOfSavedRequests}) exceeded the safe limit of ` +\n `${safeLimit}. Did you forget to call \\`interceptor.clear()\\`?\\n\\n` +\n 'If you need to save requests, make sure to regularly call `interceptor.clear()`. Alternatively, you can ' +\n 'hide this warning by increasing `requestSaving.safeLimit` in your interceptor. Note that saving too many ' +\n 'requests in memory can lead to performance issues.\\n\\n' +\n 'If you do not need to save requests, consider setting `requestSaving.enabled: false` in your ' +\n 'interceptor.\\n\\n' +\n 'Learn more: https://zimic.dev/docs/interceptor/api/create-http-interceptor',\n );\n this.name = 'RequestSavingSafeLimitExceededError';\n }\n}\n\nexport default RequestSavingSafeLimitExceededError;\n","export const SERVICE_WORKER_FILE_NAME = 'mockServiceWorker.js';\n","import { SERVICE_WORKER_FILE_NAME } from '@/cli/browser/shared/constants';\n\n/**\n * An error thrown when the browser mock service worker is not found.\n *\n * @see {@link https://zimic.dev/docs/interceptor/cli/browser#zimic-interceptor-browser-init `zimic-interceptor browser init` API reference}\n */\nclass UnregisteredBrowserServiceWorkerError extends Error {\n constructor() {\n super(\n 'Failed to register the browser service worker: ' +\n `script '${window.location.origin}/${SERVICE_WORKER_FILE_NAME}' not found.\\n\\n` +\n 'Did you forget to run `zimic-interceptor browser init <publicDirectory>`?\\n\\n' +\n 'Learn more: https://zimic.dev/docs/interceptor/cli/browser#zimic-interceptor-browser-init',\n );\n this.name = 'UnregisteredBrowserServiceWorkerError';\n }\n\n static matchesRawError(error: unknown) {\n return (\n error instanceof Error &&\n error.message.toLowerCase().includes('service worker script does not exist at the given path')\n );\n }\n}\n\nexport default UnregisteredBrowserServiceWorkerError;\n","/**\n * Error thrown when trying to access requests when the interceptor is not configured to do so.\n *\n * @see {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `createHttpInterceptor` API reference}\n */\nclass DisabledRequestSavingError extends TypeError {\n constructor() {\n super(\n 'Intercepted requests are not being saved. ' +\n 'Did you forget to use `requestSaving.enabled: true` in your interceptor?\\n\\n' +\n 'Learn more: https://zimic.dev/docs/interceptor/api/create-http-interceptor',\n );\n this.name = 'DisabledRequestSavingError';\n }\n}\n\nexport default DisabledRequestSavingError;\n","function isDefined<Value>(value: Value): value is NonNullable<Value> {\n return value !== undefined && value !== null;\n}\n\nexport default isDefined;\n","import isDefined from './isDefined';\n\nfunction isNonEmpty<Value>(value: Value): value is Exclude<NonNullable<Value>, ''> {\n return isDefined(value) && value !== '';\n}\n\nexport default isNonEmpty;\n","function createCachedDynamicImport<ImportType>(\n importModuleDynamically: () => Promise<ImportType>,\n): () => Promise<ImportType> {\n let cachedImportResult: ImportType | undefined;\n\n return async function importModuleDynamicallyWithCache() {\n cachedImportResult ??= await importModuleDynamically();\n return cachedImportResult;\n };\n}\n\nexport default createCachedDynamicImport;\n","export type TableLogRow = Record<string, string>;\n\nexport interface TableLogHeader<Row extends TableLogRow> {\n title: string;\n property: keyof Row;\n}\n\nexport interface LoggerOptions {\n prefix?: string;\n}\n\nclass Logger {\n prefix?: string;\n\n raw: Logger;\n\n constructor(options: LoggerOptions = {}) {\n const { prefix } = options;\n\n this.prefix = prefix;\n\n this.raw = prefix ? new Logger({ ...options, prefix: undefined }) : this;\n }\n\n private logWithLevel(level: 'log' | 'warn' | 'error', ...messages: unknown[]) {\n if (this.prefix) {\n console[level](this.prefix, ...messages);\n } else {\n console[level](...messages);\n }\n }\n\n info(...messages: unknown[]) {\n this.logWithLevel('log', ...messages);\n }\n\n warn(...messages: unknown[]) {\n this.logWithLevel('warn', ...messages);\n }\n\n error(...messages: unknown[]) {\n this.logWithLevel('error', ...messages);\n }\n\n table<Row extends TableLogRow>(headers: TableLogHeader<Row>[], rows: Row[]) {\n const columnLengths = headers.map((header) => {\n let maxValueLength = header.title.length;\n\n for (const row of rows) {\n const value = row[header.property];\n\n if (value.length > maxValueLength) {\n maxValueLength = value.length;\n }\n }\n\n return maxValueLength;\n });\n\n const formattedRows: string[][] = [];\n\n const horizontalLine = columnLengths.map((length) => '─'.repeat(length));\n formattedRows.push(horizontalLine, []);\n\n for (let headerIndex = 0; headerIndex < headers.length; headerIndex++) {\n const header = headers[headerIndex];\n const columnLength = columnLengths[headerIndex];\n\n const value = header.title;\n formattedRows.at(-1)?.push(value.padEnd(columnLength, ' '));\n }\n\n formattedRows.push(horizontalLine);\n\n for (const row of rows) {\n formattedRows.push([]);\n\n for (let headerIndex = 0; headerIndex < headers.length; headerIndex++) {\n const header = headers[headerIndex];\n const columnLength = columnLengths[headerIndex];\n\n const value = row[header.property];\n formattedRows.at(-1)?.push(value.padEnd(columnLength, ' '));\n }\n }\n\n formattedRows.push(horizontalLine);\n\n const formattedTable = formattedRows\n .map((row, index) => {\n const isFirstLine = index === 0;\n if (isFirstLine) {\n return `┌─${row.join('─┬─')}─┐`;\n }\n\n const isLineAfterHeaders = index === 2;\n if (isLineAfterHeaders) {\n return `├─${row.join('─┼─')}─┤`;\n }\n\n const isLastLine = index === formattedRows.length - 1;\n if (isLastLine) {\n return `└─${row.join('─┴─')}─┘`;\n }\n\n return `│ ${row.join(' │ ')} │`;\n })\n .join('\\n');\n\n this.logWithLevel('log', formattedTable);\n }\n}\n\nexport default Logger;\n","export function isServerSide() {\n return typeof process !== 'undefined' && typeof process.versions !== 'undefined';\n}\n\nexport function isClientSide() {\n return typeof window !== 'undefined' && typeof document !== 'undefined';\n}\n","import createCachedDynamicImport from '@zimic/utils/import/createCachedDynamicImport';\nimport type fs from 'fs';\n\nexport const importFile = createCachedDynamicImport(\n /* istanbul ignore next -- @preserve\n * Ignoring as Node.js >=20 provides a global File and the import fallback won't run. */\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n async () => globalThis.File ?? (await import('buffer')).File,\n);\n\nexport function isGlobalFileAvailable() {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n return globalThis.File !== undefined;\n}\n\nexport const importFilesystem = createCachedDynamicImport<typeof fs>(() => import('fs'));\n\nexport async function pathExists(path: string) {\n const fs = await importFilesystem();\n\n try {\n await fs.promises.access(path);\n return true;\n } catch {\n return false;\n }\n}\n","import { HttpFormData, HttpHeaders, HttpSearchParams } from '@zimic/http';\nimport createCachedDynamicImport from '@zimic/utils/import/createCachedDynamicImport';\nimport Logger from '@zimic/utils/logging/Logger';\nimport color from 'picocolors';\n\nimport { isClientSide } from './environment';\nimport { isGlobalFileAvailable } from './files';\n\nexport const logger = new Logger({\n prefix: color.cyan('[@zimic/interceptor]'),\n});\n\nfunction stringifyJSONToLog(value: unknown): string {\n return JSON.stringify(\n value,\n (_key, value) => {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return stringifyValueToLog(value, {\n fallback: (value) => value as string,\n });\n },\n 2,\n )\n .replace(/\\n\\s*/g, ' ')\n .replace(/\"(File { name: '.*?', type: '.*?', size: \\d*? })\"/g, '$1')\n .replace(/\"(Blob { type: '.*?', size: \\d*? })\"/g, '$1');\n}\n\nexport function stringifyValueToLog(\n value: unknown,\n options: {\n fallback?: (value: unknown) => string;\n includeClassName?: { searchParams?: boolean };\n } = {},\n): string {\n const { fallback = stringifyJSONToLog, includeClassName } = options;\n\n if (value === null || value === undefined || typeof value !== 'object') {\n return String(value);\n }\n\n if (value instanceof HttpHeaders) {\n return stringifyValueToLog(value.toObject());\n }\n\n if (value instanceof HttpHeaders || value instanceof HttpSearchParams) {\n const prefix = (includeClassName?.searchParams ?? false) ? 'URLSearchParams ' : '';\n return `${prefix}${stringifyValueToLog(value.toObject())}`;\n }\n\n if (value instanceof HttpFormData) {\n return `FormData ${stringifyValueToLog(value.toObject())}`;\n }\n\n if (isGlobalFileAvailable() && value instanceof File) {\n return `File { name: '${value.name}', type: '${value.type}', size: ${value.size} }`;\n }\n\n if (value instanceof Blob) {\n return `Blob { type: '${value.type}', size: ${value.size} }`;\n }\n\n return fallback(value);\n}\n\nconst importUtil = createCachedDynamicImport(() => import('util'));\n\nexport async function formatValueToLog(value: unknown, options: { colors?: boolean } = {}) {\n if (isClientSide()) {\n return value;\n }\n\n const { colors = true } = options;\n\n const util = await importUtil();\n\n return util.inspect(value, {\n colors,\n compact: true,\n depth: Infinity,\n maxArrayLength: Infinity,\n maxStringLength: Infinity,\n breakLength: Infinity,\n sorted: true,\n });\n}\n","import isNonEmpty from '@zimic/utils/data/isNonEmpty';\nimport { Range } from '@zimic/utils/types';\nimport color from 'picocolors';\n\nimport { HttpInterceptorRequestSaving } from '@/http/interceptor/types/public';\nimport { stringifyValueToLog } from '@/utils/logging';\n\nimport { UnmatchedHttpInterceptorRequestGroup } from '../types/restrictions';\nimport TimesDeclarationPointer from './TimesDeclarationPointer';\n\ninterface TimesCheckErrorOptions {\n requestLimits: Range<number>;\n numberOfMatchedRequests: number;\n declarationPointer: TimesDeclarationPointer | undefined;\n unmatchedRequestGroups: UnmatchedHttpInterceptorRequestGroup[];\n hasRestrictions: boolean;\n requestSaving: HttpInterceptorRequestSaving;\n}\n\nfunction createMessageHeader({\n requestLimits,\n hasRestrictions,\n numberOfMatchedRequests,\n unmatchedRequestGroups,\n}: TimesCheckErrorOptions) {\n const requestPrefix = hasRestrictions ? 'matching ' : '';\n\n return [\n 'Expected ',\n\n requestLimits.min === requestLimits.max ? 'exactly ' : 'at least ',\n requestLimits.min,\n\n requestLimits.min === requestLimits.max &&\n (requestLimits.min === 1 ? ` ${requestPrefix}request` : ` ${requestPrefix}requests`),\n\n requestLimits.min !== requestLimits.max &&\n Number.isFinite(requestLimits.max) &&\n ` and at most ${requestLimits.max}`,\n\n requestLimits.min !== requestLimits.max &&\n (requestLimits.max === 1 ? ` ${requestPrefix}request` : ` ${requestPrefix}requests`),\n\n ', but got ',\n numberOfMatchedRequests,\n '.',\n\n unmatchedRequestGroups.length > 0 &&\n `\\n\\nRequests evaluated by this handler:\\n\\n ${color.green('- Expected')}\\n ${color.red('+ Received')}`,\n ]\n .filter((part) => part !== false)\n .join('');\n}\n\nfunction createMessageDiffs({ requestSaving, unmatchedRequestGroups }: TimesCheckErrorOptions) {\n if (!requestSaving.enabled) {\n return 'Tip: use `requestSaving.enabled: true` in your interceptor for more details about the unmatched requests.';\n }\n\n return unmatchedRequestGroups\n .map(({ request, diff }, index) => {\n const requestNumber = index + 1;\n\n const messageParts = [`${requestNumber}: ${request.method} ${request.url}`];\n\n if (diff.computed) {\n messageParts.push('Computed restriction:');\n\n const stringifiedExpected = stringifyValueToLog(diff.computed.expected);\n const stringifiedReceived = stringifyValueToLog(diff.computed.received);\n\n messageParts.push(` ${color.green(`- return ${stringifiedExpected}`)}`);\n messageParts.push(` ${color.red(`+ return ${stringifiedReceived}`)}`);\n }\n\n if (diff.headers) {\n messageParts.push('Headers:');\n\n const stringifiedExpected = stringifyValueToLog(diff.headers.expected);\n const stringifiedReceived = stringifyValueToLog(diff.headers.received);\n\n messageParts.push(` ${color.green(`- ${stringifiedExpected}`)}`);\n messageParts.push(` ${color.red(`+ ${stringifiedReceived}`)}`);\n }\n\n if (diff.searchParams) {\n messageParts.push('Search params:');\n\n const stringifiedExpected = stringifyValueToLog(diff.searchParams.expected);\n const stringifiedReceived = stringifyValueToLog(diff.searchParams.received);\n\n messageParts.push(` ${color.green(`- ${stringifiedExpected}`)}`);\n messageParts.push(` ${color.red(`+ ${stringifiedReceived}`)}`);\n }\n\n if (diff.body) {\n messageParts.push('Body:');\n\n const stringifiedExpected = stringifyValueToLog(diff.body.expected, {\n includeClassName: { searchParams: true },\n });\n const stringifiedReceived = stringifyValueToLog(diff.body.received, {\n includeClassName: { searchParams: true },\n });\n\n messageParts.push(` ${color.green(`- ${stringifiedExpected}`)}`);\n messageParts.push(` ${color.red(`+ ${stringifiedReceived}`)}`);\n }\n\n return messageParts.join('\\n ');\n })\n .join('\\n\\n');\n}\n\nfunction createMessageFooter() {\n return 'Learn more: https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes';\n}\n\nfunction createMessage(options: TimesCheckErrorOptions) {\n const messageHeader = createMessageHeader(options);\n const messageDiffs = createMessageDiffs(options);\n const messageFooter = createMessageFooter();\n\n return [messageHeader, messageDiffs, messageFooter].filter(isNonEmpty).join('\\n\\n');\n}\n\nclass TimesCheckError extends TypeError {\n constructor(options: TimesCheckErrorOptions) {\n const message = createMessage(options);\n super(message);\n\n this.name = 'TimesCheckError';\n this.cause = options.declarationPointer;\n }\n}\n\nexport default TimesCheckError;\n","async function blobEquals(blob: Blob, otherBlob: Blob) {\n if (blob.type !== otherBlob.type || blob.size !== otherBlob.size) {\n return false;\n }\n\n const reader = blob.stream().getReader();\n const otherReader = otherBlob.stream().getReader();\n\n let buffer: Uint8Array = new Uint8Array(0);\n let otherBuffer: Uint8Array = new Uint8Array(0);\n\n try {\n while (true) {\n const bufferReadPromises: Promise<void>[] = [];\n\n if (buffer.length === 0) {\n bufferReadPromises.push(\n reader.read().then((result) => {\n if (!result.done) {\n buffer = result.value;\n }\n }),\n );\n }\n\n if (otherBuffer.length === 0) {\n bufferReadPromises.push(\n otherReader.read().then((result) => {\n if (!result.done) {\n otherBuffer = result.value;\n }\n }),\n );\n }\n\n await Promise.all(bufferReadPromises);\n\n const haveStreamsEndedTogether = buffer.length === 0 && otherBuffer.length === 0;\n\n if (haveStreamsEndedTogether) {\n return true;\n }\n\n const hasOneStreamEndedBeforeTheOther =\n (buffer.length === 0 && otherBuffer.length > 0) || (buffer.length > 0 && otherBuffer.length === 0);\n\n if (hasOneStreamEndedBeforeTheOther) {\n return false;\n }\n\n const minimumByteLength = Math.min(buffer.length, otherBuffer.length);\n\n for (let byteIndex = 0; byteIndex < minimumByteLength; byteIndex++) {\n if (buffer[byteIndex] !== otherBuffer[byteIndex]) {\n return false;\n }\n }\n\n buffer = buffer.slice(minimumByteLength);\n otherBuffer = otherBuffer.slice(minimumByteLength);\n }\n } finally {\n reader.releaseLock();\n otherReader.releaseLock();\n }\n}\n\nexport default blobEquals;\n","import { JSONValue } from '@/types/json';\n\nexport function isPrimitiveJSONValue<Value extends JSONValue>(value: Value): value is Exclude<Value, object> {\n return typeof value !== 'object' || value === null;\n}\n","import { JSONValue } from '@/types/json';\n\nimport { isPrimitiveJSONValue } from './isPrimitiveJSONValue';\n\nfunction jsonContains(value: JSONValue, otherValue: JSONValue): boolean {\n if (isPrimitiveJSONValue(value)) {\n return value === otherValue;\n }\n if (isPrimitiveJSONValue(otherValue)) {\n return false;\n }\n\n if (Array.isArray<JSONValue>(value)) {\n if (!Array.isArray<JSONValue>(otherValue)) {\n return false;\n }\n if (value.length < otherValue.length) {\n return false;\n }\n\n let lastMatchedIndex = -1;\n return otherValue.every((otherItem) => {\n for (let index = lastMatchedIndex + 1; index < value.length; index++) {\n if (jsonContains(value[index], otherItem)) {\n lastMatchedIndex = index;\n return true;\n }\n }\n return false;\n });\n }\n\n if (Array.isArray<JSONValue>(otherValue)) {\n return false;\n }\n\n const valueKeys = Object.keys(value);\n const otherValueKeys = Object.keys(otherValue);\n\n if (valueKeys.length < otherValueKeys.length) {\n return false;\n }\n\n return otherValueKeys.every((key) => {\n const subValue = value[key];\n const subOtherValue = otherValue[key];\n return jsonContains(subValue, subOtherValue);\n });\n}\n\nexport default jsonContains;\n","import { JSONValue } from '@/types/json';\n\nimport { isPrimitiveJSONValue } from './isPrimitiveJSONValue';\n\nfunction jsonEquals(value: JSONValue, otherValue: JSONValue): boolean {\n if (isPrimitiveJSONValue(value)) {\n return value === otherValue;\n }\n if (isPrimitiveJSONValue(otherValue)) {\n return false;\n }\n\n if (Array.isArray<JSONValue>(value)) {\n if (!Array.isArray<JSONValue>(otherValue)) {\n return false;\n }\n if (value.length !== otherValue.length) {\n return false;\n }\n return value.every((item, index) => jsonEquals(item, otherValue[index]));\n }\n\n if (Array.isArray<JSONValue>(otherValue)) {\n return false;\n }\n\n const valueKeys = Object.keys(value);\n const otherValueKeys = Object.keys(otherValue);\n\n if (valueKeys.length !== otherValueKeys.length) {\n return false;\n }\n\n return valueKeys.every((key) => {\n const subValue = value[key];\n const subOtherValue = otherValue[key];\n return jsonEquals(subValue, subOtherValue);\n });\n}\n\nexport default jsonEquals;\n","function waitForDelay(milliseconds: number) {\n return new Promise<void>((resolve) => {\n setTimeout(resolve, milliseconds);\n });\n}\n\nexport default waitForDelay;\n","import { isClientSide } from './environment';\n\nexport async function convertReadableStreamToBlob(\n stream: ReadableStream<Uint8Array<ArrayBuffer>>,\n options?: BlobPropertyBag,\n): Promise<Blob> {\n const chunks: Uint8Array<ArrayBuffer>[] = [];\n const reader = stream.getReader();\n\n while (true) {\n const result = await reader.read();\n\n if (result.value) {\n chunks.push(result.value);\n }\n\n if (result.done) {\n break;\n }\n }\n\n return new Blob(chunks, options);\n}\n\nexport function convertArrayBufferToBlob(buffer: ArrayBuffer, options?: BlobPropertyBag): Blob {\n return new Blob([buffer], options);\n}\n\nexport function convertArrayBufferToBase64(buffer: ArrayBuffer) {\n if (isClientSide()) {\n const bufferBytes = new Uint8Array(buffer);\n\n const bufferAsStringArray = [];\n for (const byte of bufferBytes) {\n const byteCode = String.fromCharCode(byte);\n bufferAsStringArray.push(byteCode);\n }\n const bufferAsString = bufferAsStringArray.join('');\n\n return btoa(bufferAsString);\n } else {\n return Buffer.from(buffer).toString('base64');\n }\n}\n\nexport function convertBase64ToArrayBuffer(base64Value: string) {\n if (isClientSide()) {\n const bufferAsString = atob(base64Value);\n const array = Uint8Array.from(bufferAsString, (character) => character.charCodeAt(0));\n return array.buffer;\n } else {\n return Buffer.from(base64Value, 'base64');\n }\n}\n\nexport const HEX_REGEX = /^[a-z0-9]+$/;\n\nexport function convertHexLengthToByteLength(hexLength: number) {\n return Math.ceil(hexLength / 2); // 1 byte = 2 hex characters\n}\n\nexport const BASE64URL_REGEX = /^[a-zA-Z0-9-_]+$/;\n\nexport function convertHexLengthToBase64urlLength(hexLength: number) {\n const byteLength = convertHexLengthToByteLength(hexLength);\n return Math.ceil((byteLength * 4) / 3); // 1 byte = 4/3 base64url characters\n}\n","export function random(lowerLimit: number, upperLimit: number): number {\n const range = Math.max(upperLimit - lowerLimit, 0);\n\n if (range === 0) {\n return lowerLimit;\n }\n\n return Math.random() * range + lowerLimit;\n}\n\nexport function randomInt(lowerLimit: number, upperLimit: number): number {\n return Math.floor(random(lowerLimit, upperLimit));\n}\n","class NoResponseDefinitionError extends TypeError {\n constructor() {\n super('Cannot generate a response without a definition. Use .respond() to set a response.');\n this.name = 'NoResponseDefinitionError';\n }\n}\n\nexport default NoResponseDefinitionError;\n","class TimesDeclarationPointer extends Error {\n constructor(minNumberOfRequests: number, maxNumberOfRequests?: number) {\n super('declared at:');\n this.name = `handler.times(${minNumberOfRequests}${\n maxNumberOfRequests === undefined ? '' : `, ${maxNumberOfRequests}`\n })`;\n }\n}\n\nexport default TimesDeclarationPointer;\n","import {\n HttpSchemaMethod,\n HttpSchemaPath,\n HttpStatusCode,\n HttpFormData,\n HttpHeaders,\n HttpSearchParams,\n HttpSchema,\n HttpRequestSearchParamsSchema,\n HttpRequestHeadersSchema,\n} from '@zimic/http';\nimport blobEquals from '@zimic/utils/data/blobEquals';\nimport jsonContains from '@zimic/utils/data/jsonContains';\nimport jsonEquals from '@zimic/utils/data/jsonEquals';\nimport waitForDelay from '@zimic/utils/time/waitForDelay';\nimport { Default, Range } from '@zimic/utils/types';\n\nimport { convertArrayBufferToBlob, convertReadableStreamToBlob } from '@/utils/data';\nimport { random } from '@/utils/numbers';\n\nimport HttpInterceptorClient from '../interceptor/HttpInterceptorClient';\nimport DisabledRequestSavingError from './errors/DisabledRequestSavingError';\nimport NoResponseDefinitionError from './errors/NoResponseDefinitionError';\nimport TimesCheckError from './errors/TimesCheckError';\nimport TimesDeclarationPointer from './errors/TimesDeclarationPointer';\nimport { InternalHttpRequestHandler } from './types/public';\nimport {\n HttpInterceptorRequest,\n HttpInterceptorResponse,\n HttpRequestHandlerResponseDeclaration,\n HttpRequestHandlerResponseDeclarationFactory,\n HttpRequestHandlerResponseDelayFactory,\n InterceptedHttpInterceptorRequest,\n} from './types/requests';\nimport {\n HttpRequestHandlerRestriction,\n RestrictionDiff,\n RestrictionDiffs,\n RestrictionMatchResult,\n HttpRequestHandlerStaticRestriction,\n UnmatchedHttpInterceptorRequestGroup,\n} from './types/restrictions';\n\nconst DEFAULT_NUMBER_OF_REQUEST_LIMITS: Range<number> = Object.freeze({\n min: 0,\n max: Infinity,\n});\n\nexport type HttpRequestHandlerRequestMatch =\n | { success: true }\n | { success: false; cause: 'missingResponseDeclaration' | 'exceededNumberOfRequests' }\n | { success: false; cause: 'unmatchedRestrictions'; diff: RestrictionDiffs };\n\nclass HttpRequestHandlerClient<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath<Schema, Method>,\n StatusCode extends HttpStatusCode = never,\n> {\n private restrictions: HttpRequestHandlerRestriction<Schema, Method, Path>[] = [];\n\n private limits = {\n numberOfRequests: DEFAULT_NUMBER_OF_REQUEST_LIMITS,\n };\n\n private timesPointer?: TimesDeclarationPointer;\n\n private numberOfMatchedRequests = 0;\n private unmatchedRequestGroups: UnmatchedHttpInterceptorRequestGroup[] = [];\n private _requests: InterceptedHttpInterceptorRequest<Path, Default<Schema[Path][Method]>, StatusCode>[] = [];\n\n private createResponseDeclaration?: HttpRequestHandlerResponseDeclarationFactory<\n Path,\n Default<Schema[Path][Method]>,\n StatusCode\n >;\n\n private createResponseDelay?: HttpRequestHandlerResponseDelayFactory<Path, Default<Schema[Path][Method]>>;\n\n constructor(\n private interceptor: HttpInterceptorClient<Schema>,\n public method: Method,\n public path: Path,\n private handler: InternalHttpRequestHandler<Schema, Method, Path, StatusCode>,\n ) {}\n\n with(restriction: HttpRequestHandlerRestriction<Schema, Method, Path>): this {\n this.restrictions.push(restriction);\n return this;\n }\n\n delay(\n minMilliseconds: number | HttpRequestHandlerResponseDelayFactory<Path, Default<Schema[Path][Method]>>,\n maxMilliseconds?: number,\n ): this {\n if (minMilliseconds === maxMilliseconds) {\n return this.delay(minMilliseconds);\n }\n\n if (typeof minMilliseconds === 'number' && typeof maxMilliseconds === 'number') {\n this.createResponseDelay = () => random(minMilliseconds, maxMilliseconds);\n return this;\n }\n\n if (typeof minMilliseconds === 'number') {\n this.createResponseDelay = () => minMilliseconds;\n return this;\n }\n\n this.createResponseDelay = minMilliseconds;\n return this;\n }\n\n respond<NewStatusCode extends HttpStatusCode>(\n declaration:\n | HttpRequestHandlerResponseDeclaration<Default<Schema[Path][Method]>, NewStatusCode>\n | HttpRequestHandlerResponseDeclarationFactory<Path, Default<Schema[Path][Method]>, NewStatusCode>,\n ): HttpRequestHandlerClient<Schema, Method, Path, NewStatusCode> {\n const newThis = this as unknown as HttpRequestHandlerClient<Schema, Method, Path, NewStatusCode>;\n\n newThis.createResponseDeclaration = this.isResponseDeclarationFactory(declaration)\n ? declaration\n : () => declaration;\n\n newThis.numberOfMatchedRequests = 0;\n newThis.unmatchedRequestGroups.length = 0;\n\n newThis.clearInterceptedRequests();\n\n this.interceptor.registerRequestHandler(this.handler);\n\n return newThis;\n }\n\n private isResponseDeclarationFactory(\n declaration:\n | HttpRequestHandlerResponseDeclaration<Default<Schema[Path][Method]>>\n | HttpRequestHandlerResponseDeclarationFactory<Path, Default<Schema[Path][Method]>>,\n ) {\n return typeof declaration === 'function';\n }\n\n times(\n minNumberOfRequests: number,\n maxNumberOfRequests?: number,\n ): HttpRequestHandlerClient<Schema, Method, Path, StatusCode> {\n this.limits.numberOfRequests = {\n min: minNumberOfRequests,\n max: maxNumberOfRequests ?? minNumberOfRequests,\n };\n\n this.timesPointer = new TimesDeclarationPointer(minNumberOfRequests, maxNumberOfRequests);\n\n return this;\n }\n\n checkTimes() {\n const isWithinLimits =\n this.numberOfMatchedRequests >= this.limits.numberOfRequests.min &&\n this.numberOfMatchedRequests <= this.limits.numberOfRequests.max;\n\n if (!isWithinLimits) {\n throw new TimesCheckError({\n requestLimits: this.limits.numberOfRequests,\n numberOfMatchedRequests: this.numberOfMatchedRequests,\n declarationPointer: this.timesPointer,\n unmatchedRequestGroups: this.unmatchedRequestGroups,\n hasRestrictions: this.restrictions.length > 0,\n requestSaving: this.interceptor.requestSaving,\n });\n }\n }\n\n clear(): this {\n this.restrictions.length = 0;\n\n this.limits = {\n numberOfRequests: DEFAULT_NUMBER_OF_REQUEST_LIMITS,\n };\n\n this.timesPointer = undefined;\n\n this.numberOfMatchedRequests = 0;\n this.unmatchedRequestGroups.length = 0;\n\n this.clearInterceptedRequests();\n\n this.createResponseDeclaration = undefined;\n this.createResponseDelay = undefined;\n\n return this;\n }\n\n async matchesRequest(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n ): Promise<HttpRequestHandlerRequestMatch> {\n const restrictionsMatch = await this.matchesRestrictions(request);\n\n if (!restrictionsMatch.success) {\n return { success: false, cause: 'unmatchedRestrictions', diff: restrictionsMatch.diff };\n }\n\n const hasResponseDeclaration = this.createResponseDeclaration !== undefined;\n\n if (!hasResponseDeclaration) {\n return { success: false, cause: 'missingResponseDeclaration' };\n }\n\n const canAcceptMoreRequests = this.numberOfMatchedRequests < this.limits.numberOfRequests.max;\n\n if (!canAcceptMoreRequests) {\n return { success: false, cause: 'exceededNumberOfRequests' };\n }\n\n return { success: true };\n }\n\n markRequestAsMatched(_request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>) {\n this.numberOfMatchedRequests++;\n }\n\n markRequestAsUnmatched(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n options: { diff: RestrictionDiffs },\n ) {\n const shouldSaveUnmatchedRequests =\n this.interceptor.requestSaving.enabled && this.restrictions.length > 0 && this.timesPointer !== undefined;\n\n if (shouldSaveUnmatchedRequests) {\n this.unmatchedRequestGroups.push({ request, diff: options.diff });\n }\n }\n\n async matchesRestrictions(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n ): Promise<RestrictionMatchResult<RestrictionDiffs>> {\n for (const restriction of this.restrictions) {\n if (this.isComputedRequestRestriction(restriction)) {\n const matchesComputedRestriction = await restriction(request);\n\n if (!matchesComputedRestriction) {\n return {\n success: false,\n diff: { computed: { expected: true, received: false } },\n };\n }\n\n continue;\n }\n\n const matchesHeadersRestrictions = this.matchesRequestHeadersRestrictions(request, restriction);\n const matchesSearchParamsRestrictions = this.matchesRequestSearchParamsRestrictions(request, restriction);\n const matchesBodyRestrictions = await this.matchesRequestBodyRestrictions(request, restriction);\n\n const matchesRestriction =\n matchesHeadersRestrictions.success &&\n matchesSearchParamsRestrictions.success &&\n matchesBodyRestrictions.success;\n\n if (!matchesRestriction) {\n return {\n success: false,\n diff: {\n headers: matchesHeadersRestrictions.diff,\n searchParams: matchesSearchParamsRestrictions.diff,\n body: matchesBodyRestrictions.diff,\n },\n };\n }\n }\n\n return { success: true };\n }\n\n private matchesRequestHeadersRestrictions(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n restriction: HttpRequestHandlerStaticRestriction<Schema, Method, Path>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): RestrictionMatchResult<RestrictionDiff<HttpHeaders<any>>> {\n if (restriction.headers === undefined) {\n return { success: true };\n }\n\n const restrictedHeaders = new HttpHeaders(\n restriction.headers as Default<HttpRequestHeadersSchema<Default<Schema[Path][Method]>>>,\n );\n\n const matchesRestriction = restriction.exact\n ? request.headers.equals(restrictedHeaders)\n : request.headers.contains(restrictedHeaders);\n\n return matchesRestriction\n ? { success: true }\n : {\n success: false,\n diff: { expected: restrictedHeaders, received: request.headers },\n };\n }\n\n private matchesRequestSearchParamsRestrictions(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n restriction: HttpRequestHandlerStaticRestriction<Schema, Method, Path>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): RestrictionMatchResult<RestrictionDiff<HttpSearchParams<any>>> {\n if (restriction.searchParams === undefined) {\n return { success: true };\n }\n\n const restrictedSearchParams = new HttpSearchParams(\n restriction.searchParams as Default<HttpRequestSearchParamsSchema<Default<Schema[Path][Method]>>>,\n );\n\n const matchesRestriction = restriction.exact\n ? request.searchParams.equals(restrictedSearchParams)\n : request.searchParams.contains(restrictedSearchParams);\n\n return matchesRestriction\n ? { success: true }\n : {\n success: false,\n diff: { expected: restrictedSearchParams, received: request.searchParams },\n };\n }\n\n private async matchesRequestBodyRestrictions(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n restriction: HttpRequestHandlerStaticRestriction<Schema, Method, Path>,\n ): Promise<RestrictionMatchResult<RestrictionDiff<unknown>>> {\n if (restriction.body === undefined) {\n return { success: true };\n }\n\n const body = request.body as unknown;\n const restrictionBody = restriction.body as unknown;\n\n if (typeof body === 'string' && typeof restrictionBody === 'string') {\n const matchesRestriction = restriction.exact ? body === restrictionBody : body.includes(restrictionBody);\n\n return matchesRestriction\n ? { success: true }\n : {\n success: false,\n diff: { expected: restrictionBody, received: body },\n };\n }\n\n if (restrictionBody instanceof HttpFormData) {\n if (!(body instanceof HttpFormData)) {\n return {\n success: false,\n diff: { expected: restrictionBody, received: body },\n };\n }\n\n const matchesRestriction = restriction.exact\n ? await body.equals(restrictionBody)\n : await body.contains(restrictionBody);\n\n return matchesRestriction\n ? { success: true }\n : {\n success: false,\n diff: { expected: restrictionBody, received: body },\n };\n }\n\n if (restrictionBody instanceof HttpSearchParams) {\n if (!(body instanceof HttpSearchParams)) {\n return {\n success: false,\n diff: { expected: restrictionBody, received: body },\n };\n }\n\n const matchesRestriction = restriction.exact ? body.equals(restrictionBody) : body.contains(restrictionBody);\n\n return matchesRestriction\n ? { success: true }\n : {\n success: false,\n diff: { expected: restrictionBody, received: body },\n };\n }\n\n if (\n restrictionBody instanceof Blob ||\n restrictionBody instanceof ArrayBuffer ||\n restrictionBody instanceof ReadableStream\n ) {\n if (!(body instanceof Blob)) {\n return {\n success: false,\n diff: { expected: restrictionBody, received: body },\n };\n }\n\n let restrictionBodyAsBlob: Blob;\n\n if (restrictionBody instanceof ArrayBuffer) {\n restrictionBodyAsBlob = convertArrayBufferToBlob(restrictionBody, { type: body.type });\n } else if (restrictionBody instanceof ReadableStream) {\n restrictionBodyAsBlob = await convertReadableStreamToBlob(\n restrictionBody as ReadableStream<Uint8Array<ArrayBuffer>>,\n { type: body.type },\n );\n } else {\n restrictionBodyAsBlob = restrictionBody;\n }\n\n const matchesRestriction = await blobEquals(body, restrictionBodyAsBlob);\n\n return matchesRestriction\n ? { success: true }\n : {\n success: false,\n diff: { expected: restrictionBody, received: body },\n };\n }\n\n const matchesRestriction = restriction.exact\n ? jsonEquals(request.body, restriction.body)\n : jsonContains(request.body, restriction.body);\n\n return matchesRestriction\n ? { success: true }\n : {\n success: false,\n diff: { expected: restrictionBody, received: body },\n };\n }\n\n private isComputedRequestRestriction(restriction: HttpRequestHandlerRestriction<Schema, Method, Path>) {\n return typeof restriction === 'function';\n }\n\n async applyResponseDeclaration(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n ): Promise<HttpRequestHandlerResponseDeclaration<Default<Schema[Path][Method]>, StatusCode>> {\n if (!this.createResponseDeclaration) {\n throw new NoResponseDefinitionError();\n }\n\n if (this.createResponseDelay) {\n const delay = await this.createResponseDelay(request);\n\n if (delay > 0) {\n await waitForDelay(delay);\n }\n }\n\n const appliedDeclaration = await this.createResponseDeclaration(request);\n return appliedDeclaration;\n }\n\n saveInterceptedRequest(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n response: HttpInterceptorResponse<Default<Schema[Path][Method]>, StatusCode>,\n ) {\n const interceptedRequest = this.createInterceptedRequest(request, response);\n this._requests.push(interceptedRequest);\n this.interceptor.incrementNumberOfSavedRequests(1);\n }\n\n private clearInterceptedRequests() {\n this.interceptor.incrementNumberOfSavedRequests(-this._requests.length);\n this._requests.length = 0;\n }\n\n private createInterceptedRequest(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n response: HttpInterceptorResponse<Default<Schema[Path][Method]>, StatusCode>,\n ) {\n const interceptedRequest = request as InterceptedHttpInterceptorRequest<\n Path,\n Default<Schema[Path][Method]>,\n StatusCode\n >;\n\n Object.defineProperty(interceptedRequest, 'response', {\n value: response,\n enumerable: true,\n configurable: false,\n writable: false,\n });\n\n return interceptedRequest;\n }\n\n get requests(): readonly InterceptedHttpInterceptorRequest<Path, Default<Schema[Path][Method]>, StatusCode>[] {\n if (!this.interceptor.requestSaving.enabled) {\n throw new DisabledRequestSavingError();\n }\n\n return this._requests;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyHttpRequestHandlerClient = HttpRequestHandlerClient<any, any, any, any>;\n\nexport default HttpRequestHandlerClient;\n","import { HttpSchema, HttpSchemaMethod, HttpSchemaPath, HttpStatusCode } from '@zimic/http';\nimport { Default } from '@zimic/utils/types';\n\nimport HttpInterceptorClient from '../interceptor/HttpInterceptorClient';\nimport HttpRequestHandlerClient from './HttpRequestHandlerClient';\nimport { InternalHttpRequestHandler } from './types/public';\nimport {\n HttpInterceptorRequest,\n HttpInterceptorResponse,\n HttpRequestHandlerResponseDeclaration,\n HttpRequestHandlerResponseDeclarationFactory,\n HttpRequestHandlerResponseDelayFactory,\n InterceptedHttpInterceptorRequest,\n} from './types/requests';\nimport { HttpRequestHandlerRestriction } from './types/restrictions';\n\nclass LocalHttpRequestHandler<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath<Schema, Method>,\n StatusCode extends HttpStatusCode = never,\n> implements InternalHttpRequestHandler<Schema, Method, Path, StatusCode> {\n readonly type = 'local';\n\n client: HttpRequestHandlerClient<Schema, Method, Path, StatusCode>;\n\n constructor(interceptor: HttpInterceptorClient<Schema>, method: Method, path: Path) {\n this.client = new HttpRequestHandlerClient(interceptor, method, path, this);\n }\n\n get method() {\n return this.client.method;\n }\n\n get path() {\n return this.client.path;\n }\n\n with(restriction: HttpRequestHandlerRestriction<Schema, Method, Path>): this {\n this.client.with(restriction);\n return this;\n }\n\n delay(\n minMilliseconds: number | HttpRequestHandlerResponseDelayFactory<Path, Default<Schema[Path][Method]>>,\n maxMilliseconds?: number,\n ): this {\n this.client.delay(minMilliseconds, maxMilliseconds);\n return this;\n }\n\n respond<NewStatusCode extends HttpStatusCode>(\n declaration:\n | HttpRequestHandlerResponseDeclaration<Default<Schema[Path][Method]>, NewStatusCode>\n | HttpRequestHandlerResponseDeclarationFactory<Path, Default<Schema[Path][Method]>, NewStatusCode>,\n ): LocalHttpRequestHandler<Schema, Method, Path, NewStatusCode> {\n this.client.respond(declaration);\n\n const newThis = this as unknown as LocalHttpRequestHandler<Schema, Method, Path, NewStatusCode>;\n return newThis;\n }\n\n times(minNumberOfRequests: number, maxNumberOfRequests?: number): this {\n this.client.times(minNumberOfRequests, maxNumberOfRequests);\n return this;\n }\n\n checkTimes() {\n this.client.checkTimes();\n }\n\n clear(): this {\n this.client.clear();\n return this;\n }\n\n get requests(): readonly InterceptedHttpInterceptorRequest<Path, Default<Schema[Path][Method]>, StatusCode>[] {\n return this.client.requests;\n }\n\n async matchesRequest(request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>) {\n const requestMatch = await this.client.matchesRequest(request);\n\n if (requestMatch.success) {\n this.client.markRequestAsMatched(request);\n } else if (requestMatch.cause === 'unmatchedRestrictions') {\n this.client.markRequestAsUnmatched(request, { diff: requestMatch.diff });\n } else {\n this.client.markRequestAsMatched(request);\n }\n\n return requestMatch;\n }\n\n async applyResponseDeclaration(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n ): Promise<HttpRequestHandlerResponseDeclaration<Default<Schema[Path][Method]>, StatusCode>> {\n return this.client.applyResponseDeclaration(request);\n }\n\n saveInterceptedRequest(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n response: HttpInterceptorResponse<Default<Schema[Path][Method]>, StatusCode>,\n ) {\n this.client.saveInterceptedRequest(request, response);\n }\n}\n\nexport type AnyLocalHttpRequestHandler =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | LocalHttpRequestHandler<any, any, any>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | LocalHttpRequestHandler<any, any, any, any>;\n\nexport default LocalHttpRequestHandler;\n","export function createPathCharactersToEscapeRegex() {\n return /([.(){}+$])/g;\n}\n\nexport function preparePathForRegex(path: string) {\n // We encode the path using the URL API because, differently from encodeURI and encodeURIComponent, URL does not\n // re-encode already encoded characters. Since URL requires a full URL, we use a data scheme and strip it later.\n const pathURLPrefix = `data:${path.startsWith('/') ? '' : '/'}`;\n const pathAsURL = new URL(`${pathURLPrefix}${path}`);\n const encodedPath = pathAsURL.href.replace(pathURLPrefix, '');\n\n return encodedPath.replace(/^\\/+/g, '').replace(/\\/+$/g, '').replace(createPathCharactersToEscapeRegex(), '\\\\$1');\n}\n\n// Path params names must match the JavaScript identifier pattern.\n// See // https://developer.mozilla.org/docs/Web/JavaScript/Reference/Lexical_grammar#identifiers.\nexport function createPathParamRegex() {\n return /(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)(?!\\\\[*+?])/gu;\n}\n\nexport function createRepeatingPathParamRegex() {\n return /(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)\\\\\\+/gu;\n}\n\nexport function createOptionalPathParamRegex() {\n return /(?<leadingSlash>\\/)?(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)\\?(?<trailingSlash>\\/)?/gu;\n}\n\nexport function createOptionalRepeatingPathParamRegex() {\n return /(?<leadingSlash>\\/)?(?<escape>\\\\)?:(?<identifier>[$_\\p{ID_Start}][$\\p{ID_Continue}]+)\\*(?<trailingSlash>\\/)?/gu;\n}\n\nfunction createRegexFromPath(path: string) {\n const pathRegexContent = preparePathForRegex(path)\n .replace(\n createOptionalRepeatingPathParamRegex(),\n (\n _match,\n leadingSlash: string | undefined,\n escape: string | undefined,\n identifier: string,\n trailingSlash: string | undefined,\n ) => {\n if (escape) {\n return `${leadingSlash ?? ''}:${identifier}\\\\*${trailingSlash ?? ''}`;\n }\n\n const hasSegmentBeforePrefix = leadingSlash === '/';\n const prefixExpression = hasSegmentBeforePrefix ? '/?' : leadingSlash;\n\n const hasSegmentAfterSuffix = trailingSlash === '/';\n const suffixExpression = hasSegmentAfterSuffix ? '/?' : trailingSlash;\n\n if (prefixExpression && suffixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>.+?)?${suffixExpression})?`;\n } else if (prefixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>.+?))?`;\n } else if (suffixExpression) {\n return `(?:(?<${identifier}>.+?)${suffixExpression})?`;\n } else {\n return `(?<${identifier}>.+?)?`;\n }\n },\n )\n .replace(createRepeatingPathParamRegex(), (_match, escape: string | undefined, identifier: string) => {\n return escape ? `:${identifier}\\\\+` : `(?<${identifier}>.+)`;\n })\n .replace(\n createOptionalPathParamRegex(),\n (\n _match,\n leadingSlash: string | undefined,\n escape: string | undefined,\n identifier: string,\n trailingSlash: string | undefined,\n ) => {\n if (escape) {\n return `${leadingSlash ?? ''}:${identifier}\\\\?${trailingSlash ?? ''}`;\n }\n\n const hasSegmentBeforePrefix = leadingSlash === '/';\n const prefixExpression = hasSegmentBeforePrefix ? '/?' : leadingSlash;\n\n const hasSegmentAfterSuffix = trailingSlash === '/';\n const suffixExpression = hasSegmentAfterSuffix ? '/?' : trailingSlash;\n\n if (prefixExpression && suffixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>[^\\\\/]+?)?${suffixExpression})`;\n } else if (prefixExpression) {\n return `(?:${prefixExpression}(?<${identifier}>[^\\\\/]+?))?`;\n } else if (suffixExpression) {\n return `(?:(?<${identifier}>[^\\\\/]+?)${suffixExpression})?`;\n } else {\n return `(?<${identifier}>[^\\\\/]+?)?`;\n }\n },\n )\n .replace(createPathParamRegex(), (_match, escape: string | undefined, identifier: string) => {\n return escape ? `:${identifier}` : `(?<${identifier}>[^\\\\/]+?)`;\n });\n\n return new RegExp(`^/?${pathRegexContent}/?$`);\n}\n\nexport default createRegexFromPath;\n","function excludeNonPathParams(url: URL) {\n url.hash = '';\n url.search = '';\n url.username = '';\n url.password = '';\n return url;\n}\n\nexport default excludeNonPathParams;\n","export class UnsupportedURLProtocolError extends TypeError {\n constructor(protocol: string, availableProtocols: string[] | readonly string[]) {\n super(\n `Unsupported URL protocol: '${protocol}'. ` +\n `The available options are ${availableProtocols.map((protocol) => `'${protocol}'`).join(', ')}`,\n );\n this.name = 'UnsupportedURLProtocolError';\n }\n}\n\nfunction validateURLProtocol(url: URL, protocols: string[] | readonly string[]) {\n const protocol = url.protocol.replace(/:$/, '');\n\n if (!protocols.includes(protocol)) {\n throw new UnsupportedURLProtocolError(protocol, protocols);\n }\n}\n\nexport default validateURLProtocol;\n","export function removeArrayIndex<Item>(array: Item[], index: number) {\n if (index >= 0 && index < array.length) {\n array.splice(index, 1);\n }\n return array;\n}\n\nexport function removeArrayElement<Item>(array: Item[], element: Item) {\n const index = array.indexOf(element);\n return removeArrayIndex(array, index);\n}\n","import { HttpMethod } from '@zimic/http';\n\nexport const HTTP_METHODS_WITH_REQUEST_BODY = new Set<HttpMethod>(['POST', 'PUT', 'PATCH', 'DELETE']);\n\nexport const HTTP_METHODS_WITH_RESPONSE_BODY = new Set<HttpMethod>([\n 'GET',\n 'POST',\n 'PUT',\n 'PATCH',\n 'DELETE',\n 'OPTIONS',\n]);\n\nexport function methodCanHaveResponseBody(method: HttpMethod) {\n return HTTP_METHODS_WITH_RESPONSE_BODY.has(method);\n}\n","import {\n HttpHeaders,\n HttpHeadersInit,\n HttpMethodSchema,\n HttpRequest,\n HttpRequestBodySchema,\n HttpRequestHeadersSchema,\n HttpRequestSearchParamsSchema,\n HttpResponse,\n HttpResponseBodySchema,\n HttpResponseHeadersSchema,\n HttpResponseSchema,\n HttpSearchParams,\n HttpStatusCode,\n InferPathParams,\n} from '@zimic/http';\nimport { Default, PartialByKey, PossiblePromise, Replace } from '@zimic/utils/types';\n\ntype HttpRequestHandlerResponseBody<\n ResponseSchema extends HttpResponseSchema,\n StatusCode extends HttpStatusCode,\n> = HttpResponseBodySchema<{ response: { [Code in StatusCode]: ResponseSchema } }, StatusCode>;\n\nexport type HttpRequestHandlerResponseWithBody<\n ResponseSchema extends HttpResponseSchema,\n StatusCode extends HttpStatusCode,\n> = unknown extends ResponseSchema['body']\n ? { body?: null }\n : undefined extends ResponseSchema['body']\n ? { body?: HttpRequestHandlerResponseBody<ResponseSchema, StatusCode> }\n : { body: HttpRequestHandlerResponseBody<ResponseSchema, StatusCode> };\n\ntype HttpRequestHandlerResponseDeclarationHeaders<ResponseSchema extends HttpResponseSchema> = HttpHeadersInit<\n PartialByKey<Default<ResponseSchema['headers']>, 'content-type'>\n>;\n\nexport type HttpRequestHandlerResponseDeclarationWithHeaders<ResponseSchema extends HttpResponseSchema> =\n undefined extends ResponseSchema['headers']\n ? { headers?: HttpRequestHandlerResponseDeclarationHeaders<ResponseSchema> }\n : Exclude<keyof ResponseSchema['headers'], symbol> extends 'content-type'\n ? { headers?: HttpRequestHandlerResponseDeclarationHeaders<ResponseSchema> }\n : { headers: HttpRequestHandlerResponseDeclarationHeaders<ResponseSchema> };\n\n/** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrespond `handler.respond()` API reference} */\nexport type HttpRequestHandlerResponseDeclaration<\n MethodSchema extends HttpMethodSchema = HttpMethodSchema,\n StatusCode extends HttpStatusCode = HttpStatusCode,\n> = StatusCode extends StatusCode\n ? { status: StatusCode } & HttpRequestHandlerResponseWithBody<\n Default<Default<MethodSchema['response']>[StatusCode]>,\n StatusCode\n > &\n HttpRequestHandlerResponseDeclarationWithHeaders<Default<Default<MethodSchema['response']>[StatusCode]>>\n : never;\n\n/** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrespond `handler.respond()` API reference} */\nexport type HttpRequestHandlerResponseDeclarationFactory<\n Path extends string,\n MethodSchema extends HttpMethodSchema,\n StatusCode extends HttpStatusCode = HttpStatusCode,\n> = (\n request: Omit<HttpInterceptorRequest<Path, MethodSchema>, 'response'>,\n) => PossiblePromise<HttpRequestHandlerResponseDeclaration<MethodSchema, StatusCode>>;\n\n/** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerdelay `handler.delay()` API reference} */\nexport type HttpRequestHandlerResponseDelayFactory<Path extends string, MethodSchema extends HttpMethodSchema> = (\n request: Omit<HttpInterceptorRequest<Path, MethodSchema>, 'response'>,\n) => PossiblePromise<number>;\n\n/** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrequests `handler.requests` API reference} */\nexport interface HttpInterceptorRequest<Path extends string, MethodSchema extends HttpMethodSchema> extends Omit<\n HttpRequest,\n keyof Body | 'headers' | 'clone'\n> {\n /**\n * The headers of the request.\n *\n * @see {@link https://zimic.dev/docs/interceptor/guides/http/headers#using-request-headers Using request headers}\n */\n headers: HttpHeaders<Default<HttpRequestHeadersSchema<MethodSchema>>>;\n\n /**\n * The path parameters of the request. They are parsed from the path string when using dynamic paths.\n *\n * @see {@link https://zimic.dev/docs/interceptor/guides/http/path-params#using-request-path-params Using request path parameters}\n */\n pathParams: InferPathParams<Path>;\n\n /**\n * The search parameters of the request.\n *\n * @see {@link https://zimic.dev/docs/interceptor/guides/http/search-params#using-request-search-params Using request search parameters}\n */\n searchParams: HttpSearchParams<Default<HttpRequestSearchParamsSchema<MethodSchema>>>;\n\n /**\n * The body of the request. It is already parsed by default as detailed in\n * {@link https://zimic.dev/docs/interceptor/guides/http/bodies#default-body-parsing Default body parsing}.\n *\n * @see {@link https://zimic.dev/docs/interceptor/guides/http/bodies#using-request-bodies Using request bodies}\n */\n body: Replace<HttpRequestBodySchema<MethodSchema>, ArrayBuffer | ReadableStream, Blob>;\n\n /** The raw request object. */\n raw: HttpRequest<HttpRequestBodySchema<MethodSchema>, Default<HttpRequestHeadersSchema<MethodSchema>>>;\n}\n\n/** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrequests `handler.requests` API reference} */\nexport interface HttpInterceptorResponse<\n MethodSchema extends HttpMethodSchema,\n StatusCode extends HttpStatusCode,\n> extends Omit<HttpResponse, keyof Body | 'headers' | 'clone'> {\n /**\n * The headers of the response.\n *\n * @see {@link https://zimic.dev/docs/interceptor/guides/http/headers#using-response-headers Using response headers}\n */\n headers: HttpHeaders<Default<HttpResponseHeadersSchema<MethodSchema, StatusCode>>>;\n\n /** The status code of the response. */\n status: StatusCode;\n\n /**\n * The body of the response. It is already parsed by default as detailed in\n * {@link https://zimic.dev/docs/interceptor/guides/http/bodies#default-body-parsing Default body parsing}.\n *\n * @see {@link https://zimic.dev/docs/interceptor/guides/http/bodies#using-response-bodies Using response bodies}\n */\n body: Replace<HttpResponseBodySchema<MethodSchema, StatusCode>, ArrayBuffer | ReadableStream, Blob>;\n\n /** The raw response object. */\n raw: HttpResponse<\n HttpResponseBodySchema<MethodSchema, StatusCode>,\n Default<HttpResponseHeadersSchema<MethodSchema, StatusCode>>,\n StatusCode\n >;\n}\n\nexport const HTTP_INTERCEPTOR_REQUEST_HIDDEN_PROPERTIES = Object.freeze(\n new Set<Exclude<keyof HttpRequest, keyof HttpInterceptorRequest<string, never>>>([\n 'bodyUsed',\n 'arrayBuffer',\n 'blob',\n 'formData',\n 'json',\n 'text',\n 'clone',\n ]),\n);\n\nexport const HTTP_INTERCEPTOR_RESPONSE_HIDDEN_PROPERTIES = Object.freeze(\n new Set<Exclude<keyof HttpResponse, keyof HttpInterceptorResponse<never, never>>>(\n HTTP_INTERCEPTOR_REQUEST_HIDDEN_PROPERTIES,\n ),\n);\n\n/** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrequests `handler.requests` API reference} */\nexport interface InterceptedHttpInterceptorRequest<\n Path extends string,\n MethodSchema extends HttpMethodSchema,\n StatusCode extends HttpStatusCode = never,\n> extends HttpInterceptorRequest<Path, MethodSchema> {\n /** The response that was returned for the intercepted request. */\n response: StatusCode extends [never] ? never : HttpInterceptorResponse<MethodSchema, StatusCode>;\n}\n","import { HttpInterceptorType, UnhandledRequestStrategy } from '../interceptor/types/options';\n\nexport const DEFAULT_UNHANDLED_REQUEST_STRATEGY = Object.freeze({\n local: Object.freeze<UnhandledRequestStrategy.LocalDeclaration>({\n action: 'reject',\n log: true,\n }),\n remote: Object.freeze<UnhandledRequestStrategy.RemoteDeclaration>({\n action: 'reject',\n log: true,\n }),\n} satisfies Record<HttpInterceptorType, Readonly<UnhandledRequestStrategy.Declaration>>);\n","import {\n HttpHeadersInit,\n HttpHeaders,\n HttpBody,\n HttpResponse,\n HttpMethod,\n HttpMethodSchema,\n HttpSchema,\n HttpStatusCode,\n InferPathParams,\n parseHttpBody,\n HttpSearchParams,\n} from '@zimic/http';\nimport isDefined from '@zimic/utils/data/isDefined';\nimport { Default, PossiblePromise } from '@zimic/utils/types';\nimport color from 'picocolors';\n\nimport { removeArrayElement } from '@/utils/arrays';\nimport { isClientSide } from '@/utils/environment';\nimport { methodCanHaveResponseBody } from '@/utils/http';\nimport { formatValueToLog, logger } from '@/utils/logging';\n\nimport HttpInterceptorClient, { AnyHttpInterceptorClient } from '../interceptor/HttpInterceptorClient';\nimport { HttpInterceptorPlatform, HttpInterceptorType, UnhandledRequestStrategy } from '../interceptor/types/options';\nimport {\n UnhandledHttpInterceptorRequestPath,\n UnhandledHttpInterceptorRequestMethodSchema,\n} from '../interceptor/types/requests';\nimport {\n HTTP_INTERCEPTOR_REQUEST_HIDDEN_PROPERTIES,\n HTTP_INTERCEPTOR_RESPONSE_HIDDEN_PROPERTIES,\n HttpInterceptorRequest,\n HttpInterceptorResponse,\n} from '../requestHandler/types/requests';\nimport { DEFAULT_UNHANDLED_REQUEST_STRATEGY } from './constants';\nimport { MSWHttpResponseFactory } from './types/msw';\nimport { HttpInterceptorWorkerType } from './types/options';\n\nabstract class HttpInterceptorWorker {\n abstract get type(): HttpInterceptorWorkerType;\n\n platform: HttpInterceptorPlatform | null = null;\n isRunning = false;\n\n private startingPromise?: Promise<void>;\n private stoppingPromise?: Promise<void>;\n\n private runningInterceptors: AnyHttpInterceptorClient[] = [];\n\n abstract start(): Promise<void>;\n\n protected async sharedStart(internalStart: () => Promise<void>) {\n if (this.isRunning) {\n return;\n }\n\n if (this.startingPromise) {\n return this.startingPromise;\n }\n\n try {\n this.startingPromise = internalStart();\n await this.startingPromise;\n\n this.startingPromise = undefined;\n } catch (error) {\n // In server side (e.g. Node.js), we need to manually log the error because this will be treated as an unhandled\n // promise rejection. If we don't log it, the output won't contain details about the error. In the browser,\n // uncaught promise rejections are automatically logged.\n if (!isClientSide()) {\n console.error(error);\n }\n\n await this.stop();\n throw error;\n }\n }\n\n abstract stop(): Promise<void>;\n\n protected async sharedStop(internalStop: () => PossiblePromise<void>) {\n if (!this.isRunning) {\n return;\n }\n if (this.stoppingPromise) {\n return this.stoppingPromise;\n }\n\n const stoppingResult = internalStop();\n\n if (stoppingResult instanceof Promise) {\n this.stoppingPromise = stoppingResult;\n await this.stoppingPromise;\n }\n\n this.stoppingPromise = undefined;\n }\n\n abstract use<Schema extends HttpSchema>(\n interceptor: HttpInterceptorClient<Schema>,\n method: HttpMethod,\n path: string,\n createResponse: MSWHttpResponseFactory,\n ): PossiblePromise<void>;\n\n protected async logUnhandledRequestIfNecessary(\n request: Request,\n strategy: UnhandledRequestStrategy.Declaration | null,\n ) {\n if (strategy?.log) {\n await HttpInterceptorWorker.logUnhandledRequestWarning(request, strategy.action);\n return { wasLogged: true };\n }\n return { wasLogged: false };\n }\n\n protected async getUnhandledRequestStrategy(request: Request, interceptorType: HttpInterceptorType) {\n const candidates = await this.getUnhandledRequestStrategyCandidates(request, interceptorType);\n const strategy = this.reduceUnhandledRequestStrategyCandidates(candidates);\n return strategy;\n }\n\n private reduceUnhandledRequestStrategyCandidates(candidateStrategies: UnhandledRequestStrategy.Declaration[]) {\n if (candidateStrategies.length === 0) {\n return null;\n }\n\n // Prefer strategies from first to last, overriding undefined values with the next candidate.\n return candidateStrategies.reduce(\n (accumulatedStrategy, candidateStrategy): UnhandledRequestStrategy.Declaration => ({\n action: accumulatedStrategy.action,\n log: accumulatedStrategy.log ?? candidateStrategy.log,\n }),\n );\n }\n\n private async getUnhandledRequestStrategyCandidates(\n request: Request,\n interceptorType: HttpInterceptorType,\n ): Promise<UnhandledRequestStrategy.Declaration[]> {\n const globalDefaultStrategy = DEFAULT_UNHANDLED_REQUEST_STRATEGY[interceptorType];\n\n try {\n const interceptor = this.findInterceptorByRequestBaseURL(request);\n\n if (!interceptor) {\n return [];\n }\n\n const requestClone = request.clone();\n const interceptorStrategy = await this.getInterceptorUnhandledRequestStrategy(requestClone, interceptor);\n\n return [interceptorStrategy, globalDefaultStrategy].filter(isDefined);\n } catch (error) {\n console.error(error);\n\n return [globalDefaultStrategy];\n }\n }\n\n registerRunningInterceptor(interceptor: AnyHttpInterceptorClient) {\n this.runningInterceptors.push(interceptor);\n }\n\n unregisterRunningInterceptor(interceptor: AnyHttpInterceptorClient) {\n removeArrayElement(this.runningInterceptors, interceptor);\n }\n\n private findInterceptorByRequestBaseURL(request: Request) {\n const interceptor = this.runningInterceptors.findLast((interceptor) => {\n return request.url.startsWith(interceptor.baseURLAsString);\n });\n\n return interceptor;\n }\n\n private async getInterceptorUnhandledRequestStrategy(request: Request, interceptor: AnyHttpInterceptorClient) {\n if (typeof interceptor.onUnhandledRequest === 'function') {\n const parsedRequest = await HttpInterceptorWorker.parseRawUnhandledRequest(request);\n return interceptor.onUnhandledRequest(parsedRequest);\n }\n\n return interceptor.onUnhandledRequest;\n }\n\n abstract clearHandlers<Schema extends HttpSchema>(options?: {\n interceptor?: HttpInterceptorClient<Schema>;\n }): PossiblePromise<void>;\n\n abstract get interceptorsWithHandlers(): AnyHttpInterceptorClient[];\n\n static createResponseFromDeclaration(\n request: Request,\n declaration: { status: number; headers?: HttpHeadersInit; body?: HttpBody },\n ): HttpResponse {\n const headers = new HttpHeaders(declaration.headers);\n const status = declaration.status;\n\n const canHaveBody = methodCanHaveResponseBody(request.method as HttpMethod) && status !== 204;\n\n if (!canHaveBody) {\n return new Response(null, { headers, status }) as HttpResponse;\n }\n\n if (\n typeof declaration.body === 'string' ||\n declaration.body === null ||\n declaration.body === undefined ||\n declaration.body instanceof FormData ||\n declaration.body instanceof URLSearchParams ||\n declaration.body instanceof Blob ||\n declaration.body instanceof ArrayBuffer ||\n declaration.body instanceof ReadableStream\n ) {\n return new Response(declaration.body ?? null, { headers, status }) as HttpResponse;\n }\n\n return Response.json(declaration.body, { headers, status }) as HttpResponse;\n }\n\n static async parseRawUnhandledRequest(request: Request) {\n return this.parseRawRequest<UnhandledHttpInterceptorRequestPath, UnhandledHttpInterceptorRequestMethodSchema>(\n request,\n );\n }\n\n static async parseRawRequest<Path extends string, MethodSchema extends HttpMethodSchema>(\n originalRawRequest: Request,\n options?: { baseURL: string; pathRegex: RegExp },\n ): Promise<HttpInterceptorRequest<Path, MethodSchema>> {\n const rawRequest = originalRawRequest.clone();\n const rawRequestClone = rawRequest.clone();\n\n type BodySchema = Default<Default<MethodSchema['request']>['body']>;\n\n const parsedBody = await parseHttpBody<BodySchema>(rawRequest).catch((error: unknown) => {\n logger.error('Failed to parse request body:', error);\n return null;\n });\n\n type HeadersSchema = Default<Default<MethodSchema['request']>['headers']>;\n const headers = new HttpHeaders<HeadersSchema>(rawRequest.headers);\n\n const pathParams = this.parseRawPathParams<Path>(rawRequest, options);\n\n const parsedURL = new URL(rawRequest.url);\n type SearchParamsSchema = Default<Default<MethodSchema['request']>['searchParams']>;\n const searchParams = new HttpSearchParams<SearchParamsSchema>(parsedURL.searchParams);\n\n const parsedRequest = new Proxy(rawRequest as unknown as HttpInterceptorRequest<Path, MethodSchema>, {\n has(target, property: keyof HttpInterceptorRequest<Path, MethodSchema>) {\n if (HttpInterceptorWorker.isHiddenRequestProperty(property)) {\n return false;\n }\n return Reflect.has(target, property);\n },\n\n get(target, property: keyof HttpInterceptorRequest<Path, MethodSchema>) {\n if (HttpInterceptorWorker.isHiddenRequestProperty(property)) {\n return undefined;\n }\n return Reflect.get(target, property, target) as unknown;\n },\n });\n\n Object.defineProperty(parsedRequest, 'body', {\n value: parsedBody,\n enumerable: true,\n configurable: false,\n writable: false,\n });\n\n Object.defineProperty(parsedRequest, 'headers', {\n value: headers,\n enumerable: true,\n configurable: false,\n writable: false,\n });\n\n Object.defineProperty(parsedRequest, 'pathParams', {\n value: pathParams,\n enumerable: true,\n configurable: false,\n writable: false,\n });\n\n Object.defineProperty(parsedRequest, 'searchParams', {\n value: searchParams,\n enumerable: true,\n configurable: false,\n writable: false,\n });\n\n Object.defineProperty(parsedRequest, 'raw', {\n value: rawRequestClone,\n enumerable: true,\n configurable: false,\n writable: false,\n });\n\n return parsedRequest;\n }\n\n private static isHiddenRequestProperty(property: string) {\n return HTTP_INTERCEPTOR_REQUEST_HIDDEN_PROPERTIES.has(property as never);\n }\n\n static async parseRawResponse<MethodSchema extends HttpMethodSchema, StatusCode extends HttpStatusCode>(\n originalRawResponse: Response,\n ): Promise<HttpInterceptorResponse<MethodSchema, StatusCode>> {\n const rawResponse = originalRawResponse.clone();\n const rawResponseClone = rawResponse.clone();\n\n type BodySchema = Default<Default<Default<MethodSchema['response']>[StatusCode]>['body']>;\n const parsedBody = await parseHttpBody<BodySchema>(rawResponse).catch((error: unknown) => {\n logger.error('Failed to parse response body:', error);\n return null;\n });\n\n type HeadersSchema = Default<Default<Default<MethodSchema['response']>[StatusCode]>['headers']>;\n const headers = new HttpHeaders<HeadersSchema>(rawResponse.headers);\n\n const parsedRequest = new Proxy(rawResponse as unknown as HttpInterceptorResponse<MethodSchema, StatusCode>, {\n has(target, property: keyof HttpInterceptorResponse<MethodSchema, StatusCode>) {\n if (HttpInterceptorWorker.isHiddenResponseProperty(property)) {\n return false;\n }\n return Reflect.has(target, property);\n },\n\n get(target, property: keyof HttpInterceptorResponse<MethodSchema, StatusCode>) {\n if (HttpInterceptorWorker.isHiddenResponseProperty(property)) {\n return undefined;\n }\n return Reflect.get(target, property, target) as unknown;\n },\n });\n\n Object.defineProperty(parsedRequest, 'body', {\n value: parsedBody,\n enumerable: true,\n configurable: false,\n writable: false,\n });\n\n Object.defineProperty(parsedRequest, 'headers', {\n value: headers,\n enumerable: true,\n configurable: false,\n writable: false,\n });\n\n Object.defineProperty(parsedRequest, 'raw', {\n value: rawResponseClone,\n enumerable: true,\n configurable: false,\n writable: false,\n });\n\n return parsedRequest;\n }\n\n private static isHiddenResponseProperty(property: string) {\n return HTTP_INTERCEPTOR_RESPONSE_HIDDEN_PROPERTIES.has(property as never);\n }\n\n static parseRawPathParams<Path extends string>(\n request: Request,\n options?: { baseURL: string; pathRegex: RegExp },\n ): InferPathParams<Path> {\n const requestPath = request.url.replace(options?.baseURL ?? '', '');\n const paramsMatch = options?.pathRegex.exec(requestPath);\n\n const params: Record<string, string | undefined> = {};\n\n for (const [paramName, paramValue] of Object.entries(paramsMatch?.groups ?? {})) {\n params[paramName] = typeof paramValue === 'string' ? decodeURIComponent(paramValue) : undefined;\n }\n\n return params as InferPathParams<Path>;\n }\n\n static async logUnhandledRequestWarning(rawRequest: Request, action: UnhandledRequestStrategy.Action) {\n const request = await this.parseRawRequest(rawRequest);\n\n const [formattedHeaders, formattedSearchParams, formattedBody] = await Promise.all([\n formatValueToLog(request.headers.toObject()),\n formatValueToLog(request.searchParams.toObject()),\n formatValueToLog(request.body),\n ]);\n\n logger[action === 'bypass' ? 'warn' : 'error'](\n `${action === 'bypass' ? 'Warning:' : 'Error:'} Request was not handled and was ` +\n `${action === 'bypass' ? color.yellow('bypassed') : color.red('rejected')}.\\n\\n `,\n `${request.method} ${request.url}`,\n '\\n Headers:',\n formattedHeaders,\n '\\n Search params:',\n formattedSearchParams,\n '\\n Body:',\n formattedBody,\n '\\n\\nLearn more: https://zimic.dev/docs/interceptor/guides/http/unhandled-requests',\n );\n }\n}\n\nexport default HttpInterceptorWorker;\n","import { HttpSchema, HttpSchemaMethod, HttpSchemaPath, HttpStatusCode } from '@zimic/http';\nimport { Default, PossiblePromise } from '@zimic/utils/types';\n\nimport HttpInterceptorClient from '../interceptor/HttpInterceptorClient';\nimport HttpRequestHandlerClient from './HttpRequestHandlerClient';\nimport {\n InternalHttpRequestHandler,\n SyncedRemoteHttpRequestHandler as PublicSyncedRemoteHttpRequestHandler,\n} from './types/public';\nimport {\n HttpInterceptorRequest,\n HttpInterceptorResponse,\n HttpRequestHandlerResponseDeclaration,\n HttpRequestHandlerResponseDeclarationFactory,\n HttpRequestHandlerResponseDelayFactory,\n InterceptedHttpInterceptorRequest,\n} from './types/requests';\nimport { HttpRequestHandlerRestriction } from './types/restrictions';\n\nconst PENDING_PROPERTIES = new Set<string | symbol>(['then'] satisfies (keyof Promise<unknown>)[]);\n\nclass RemoteHttpRequestHandler<\n Schema extends HttpSchema,\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath<Schema, Method>,\n StatusCode extends HttpStatusCode = never,\n> implements InternalHttpRequestHandler<Schema, Method, Path, StatusCode> {\n readonly type = 'remote';\n\n client: HttpRequestHandlerClient<Schema, Method, Path, StatusCode>;\n\n private syncPromises: Promise<unknown>[] = [];\n\n private unsynced: this;\n private synced: this;\n\n constructor(interceptor: HttpInterceptorClient<Schema, typeof RemoteHttpRequestHandler>, method: Method, path: Path) {\n this.client = new HttpRequestHandlerClient(interceptor, method, path, this);\n this.unsynced = this;\n this.synced = this.createSyncedProxy();\n }\n\n private createSyncedProxy() {\n return new Proxy(this, {\n has: (target, property) => {\n if (this.isHiddenPropertyWhenSynced(property)) {\n return false;\n }\n return Reflect.has(target, property);\n },\n\n get: (target, property) => {\n if (this.isHiddenPropertyWhenSynced(property)) {\n return undefined;\n }\n return Reflect.get(target, property);\n },\n });\n }\n\n private isHiddenPropertyWhenSynced(property: string | symbol) {\n return PENDING_PROPERTIES.has(property);\n }\n\n get method() {\n return this.client.method;\n }\n\n get path() {\n return this.client.path;\n }\n\n with(restriction: HttpRequestHandlerRestriction<Schema, Method, Path>): this {\n this.client.with(restriction);\n return this.unsynced;\n }\n\n delay(\n minMilliseconds: number | HttpRequestHandlerResponseDelayFactory<Path, Default<Schema[Path][Method]>>,\n maxMilliseconds?: number,\n ): this {\n this.client.delay(minMilliseconds, maxMilliseconds);\n return this.unsynced;\n }\n\n respond<NewStatusCode extends HttpStatusCode>(\n declaration:\n | HttpRequestHandlerResponseDeclaration<Default<Schema[Path][Method]>, NewStatusCode>\n | HttpRequestHandlerResponseDeclarationFactory<Path, Default<Schema[Path][Method]>, NewStatusCode>,\n ): RemoteHttpRequestHandler<Schema, Method, Path, NewStatusCode> {\n const newUnsyncedThis = this.unsynced as unknown as RemoteHttpRequestHandler<Schema, Method, Path, NewStatusCode>;\n newUnsyncedThis.client.respond(declaration);\n return newUnsyncedThis;\n }\n\n times(minNumberOfRequests: number, maxNumberOfRequests?: number): this {\n this.client.times(minNumberOfRequests, maxNumberOfRequests);\n return this;\n }\n\n async checkTimes() {\n return new Promise<void>((resolve, reject) => {\n try {\n this.client.checkTimes();\n resolve();\n } catch (error) {\n reject(error);\n }\n });\n }\n\n clear(): this {\n this.client.clear();\n return this.unsynced;\n }\n\n get requests(): readonly InterceptedHttpInterceptorRequest<Path, Default<Schema[Path][Method]>, StatusCode>[] {\n return this.client.requests;\n }\n\n async matchesRequest(request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>) {\n const requestMatch = await this.client.matchesRequest(request);\n\n if (requestMatch.success) {\n this.client.markRequestAsMatched(request);\n } else if (requestMatch.cause === 'unmatchedRestrictions') {\n this.client.markRequestAsUnmatched(request, { diff: requestMatch.diff });\n } else {\n this.client.markRequestAsMatched(request);\n }\n\n return requestMatch;\n }\n\n async applyResponseDeclaration(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n ): Promise<HttpRequestHandlerResponseDeclaration<Default<Schema[Path][Method]>, StatusCode>> {\n return this.client.applyResponseDeclaration(request);\n }\n\n saveInterceptedRequest(\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n response: HttpInterceptorResponse<Default<Schema[Path][Method]>, StatusCode>,\n ) {\n this.client.saveInterceptedRequest(request, response);\n }\n\n registerSyncPromise(promise: Promise<unknown>) {\n this.syncPromises.push(promise);\n }\n\n get isSynced() {\n return this.syncPromises.length === 0;\n }\n\n then<\n FulfilledResult = PublicSyncedRemoteHttpRequestHandler<Schema, Method, Path, StatusCode>,\n RejectedResult = never,\n >(\n onFulfilled?:\n | ((\n handler: PublicSyncedRemoteHttpRequestHandler<Schema, Method, Path, StatusCode>,\n ) => PossiblePromise<FulfilledResult>)\n | null,\n onRejected?: ((reason: unknown) => PossiblePromise<RejectedResult>) | null,\n ): Promise<FulfilledResult | RejectedResult> {\n const promisesToWait = new Set(this.syncPromises);\n\n return Promise.all(promisesToWait)\n .then(() => {\n this.syncPromises = this.syncPromises.filter((promise) => !promisesToWait.has(promise));\n\n return this.isSynced ? this.synced : this.unsynced;\n })\n .then(onFulfilled, onRejected);\n }\n\n catch<RejectedResult = never>(\n onRejected?: ((reason: unknown) => PossiblePromise<RejectedResult>) | null,\n ): Promise<PublicSyncedRemoteHttpRequestHandler<Schema, Method, Path, StatusCode> | RejectedResult> {\n return this.then().catch(onRejected);\n }\n\n finally(\n onFinally?: (() => void) | null,\n ): Promise<PublicSyncedRemoteHttpRequestHandler<Schema, Method, Path, StatusCode>> {\n return this.then().finally(onFinally);\n }\n}\n\nexport type AnyRemoteHttpRequestHandler =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | RemoteHttpRequestHandler<any, any, any>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | RemoteHttpRequestHandler<any, any, any, any>;\n\nexport default RemoteHttpRequestHandler;\n","import {\n HttpResponse,\n HTTP_METHODS,\n HttpMethod,\n HttpSchemaMethod,\n HttpSchemaPath,\n HttpStatusCode,\n HttpSchema,\n} from '@zimic/http';\nimport { Default, PossiblePromise } from '@zimic/utils/types';\nimport createRegexFromPath from '@zimic/utils/url/createRegexFromPath';\nimport excludeNonPathParams from '@zimic/utils/url/excludeNonPathParams';\nimport validateURLProtocol from '@zimic/utils/url/validateURLProtocol';\n\nimport { isServerSide } from '@/utils/environment';\n\nimport HttpInterceptorWorker from '../interceptorWorker/HttpInterceptorWorker';\nimport HttpRequestHandlerClient, {\n AnyHttpRequestHandlerClient,\n HttpRequestHandlerRequestMatch,\n} from '../requestHandler/HttpRequestHandlerClient';\nimport LocalHttpRequestHandler from '../requestHandler/LocalHttpRequestHandler';\nimport RemoteHttpRequestHandler from '../requestHandler/RemoteHttpRequestHandler';\nimport { HttpRequestHandler, InternalHttpRequestHandler } from '../requestHandler/types/public';\nimport { HttpInterceptorRequest } from '../requestHandler/types/requests';\nimport NotRunningHttpInterceptorError from './errors/NotRunningHttpInterceptorError';\nimport RequestSavingSafeLimitExceededError from './errors/RequestSavingSafeLimitExceededError';\nimport RunningHttpInterceptorError from './errors/RunningHttpInterceptorError';\nimport HttpInterceptorStore from './HttpInterceptorStore';\nimport { UnhandledRequestStrategy } from './types/options';\nimport { HttpInterceptorRequestSaving } from './types/public';\nimport { HttpInterceptorRequestContext } from './types/requests';\n\nexport const SUPPORTED_BASE_URL_PROTOCOLS = Object.freeze(['http', 'https']);\n\nexport const DEFAULT_REQUEST_SAVING_SAFE_LIMIT = 1000;\n\nclass HttpInterceptorClient<\n Schema extends HttpSchema,\n HandlerConstructor extends HttpRequestHandlerConstructor = HttpRequestHandlerConstructor,\n> {\n private store: HttpInterceptorStore;\n private _baseURL!: URL;\n\n private createWorker: () => HttpInterceptorWorker;\n private deleteWorker: () => void;\n private worker?: HttpInterceptorWorker;\n\n requestSaving: HttpInterceptorRequestSaving;\n private numberOfSavedRequests = 0;\n\n onUnhandledRequest?: HandlerConstructor extends typeof LocalHttpRequestHandler\n ? UnhandledRequestStrategy.Local\n : UnhandledRequestStrategy.Remote;\n\n isRunning = false;\n\n private Handler: HandlerConstructor;\n\n private handlers: {\n [Method in HttpMethod]: Map<string, AnyHttpRequestHandlerClient[]>;\n } = {\n GET: new Map(),\n POST: new Map(),\n PATCH: new Map(),\n PUT: new Map(),\n DELETE: new Map(),\n HEAD: new Map(),\n OPTIONS: new Map(),\n };\n\n constructor(options: {\n store: HttpInterceptorStore;\n baseURL: URL;\n createWorker: () => HttpInterceptorWorker;\n deleteWorker: () => void;\n requestSaving?: Partial<HttpInterceptorRequestSaving>;\n onUnhandledRequest?: UnhandledRequestStrategy;\n Handler: HandlerConstructor;\n }) {\n this.store = options.store;\n this.baseURL = options.baseURL;\n\n this.createWorker = options.createWorker;\n this.deleteWorker = options.deleteWorker;\n\n this.requestSaving = {\n enabled: options.requestSaving?.enabled ?? this.getDefaultRequestSavingEnabled(),\n safeLimit: options.requestSaving?.safeLimit ?? DEFAULT_REQUEST_SAVING_SAFE_LIMIT,\n };\n\n this.onUnhandledRequest = options.onUnhandledRequest satisfies\n | UnhandledRequestStrategy\n | undefined as this['onUnhandledRequest'];\n\n this.Handler = options.Handler;\n }\n\n private getDefaultRequestSavingEnabled(): boolean {\n return isServerSide() ? process.env.NODE_ENV === 'test' : false;\n }\n\n get baseURL() {\n return this._baseURL;\n }\n\n set baseURL(newBaseURL: URL) {\n if (this.isRunning) {\n throw new RunningHttpInterceptorError(\n 'Did you forget to call `await interceptor.stop()` before changing the base URL?',\n );\n }\n\n validateURLProtocol(newBaseURL, SUPPORTED_BASE_URL_PROTOCOLS);\n excludeNonPathParams(newBaseURL);\n\n this._baseURL = newBaseURL;\n }\n\n get baseURLAsString() {\n if (this.baseURL.href === `${this.baseURL.origin}/`) {\n return this.baseURL.origin;\n }\n return this.baseURL.href;\n }\n\n private get workerOrThrow() {\n if (!this.worker) {\n throw new NotRunningHttpInterceptorError();\n }\n return this.worker;\n }\n\n get platform() {\n return this.worker?.platform ?? null;\n }\n\n async start() {\n try {\n this.worker = this.createWorker();\n\n await this.worker.start();\n this.worker.registerRunningInterceptor(this);\n\n this.markAsRunning(true);\n } catch (error) {\n await this.stop();\n throw error;\n }\n }\n\n async stop() {\n this.worker?.unregisterRunningInterceptor(this);\n\n // The number of interceptors will be 0 if the first client could not start due to an error.\n const isLastRunningInterceptor = this.numberOfRunningInterceptors === 0 || this.numberOfRunningInterceptors === 1;\n\n if (isLastRunningInterceptor) {\n await this.worker?.stop();\n this.deleteWorker();\n }\n\n this.markAsRunning(false);\n this.worker = undefined;\n }\n\n private markAsRunning(isRunning: boolean) {\n if (this.workerOrThrow.type === 'local') {\n this.store.markLocalInterceptorAsRunning(this, isRunning);\n } else {\n this.store.markRemoteInterceptorAsRunning(this, isRunning, this.baseURL);\n }\n this.isRunning = isRunning;\n }\n\n get numberOfRunningInterceptors() {\n if (!this.isRunning) {\n return 0;\n }\n\n if (this.workerOrThrow.type === 'local') {\n return this.store.numberOfRunningLocalInterceptors;\n } else {\n return this.store.numberOfRunningRemoteInterceptors(this.baseURL);\n }\n }\n\n get(path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) {\n return this.createHttpRequestHandler('GET' as HttpSchemaMethod<Schema>, path);\n }\n\n post(path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) {\n return this.createHttpRequestHandler('POST' as HttpSchemaMethod<Schema>, path);\n }\n\n patch(path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) {\n return this.createHttpRequestHandler('PATCH' as HttpSchemaMethod<Schema>, path);\n }\n\n put(path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) {\n return this.createHttpRequestHandler('PUT' as HttpSchemaMethod<Schema>, path);\n }\n\n delete(path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) {\n return this.createHttpRequestHandler('DELETE' as HttpSchemaMethod<Schema>, path);\n }\n\n head(path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) {\n return this.createHttpRequestHandler('HEAD' as HttpSchemaMethod<Schema>, path);\n }\n\n options(path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) {\n return this.createHttpRequestHandler('OPTIONS' as HttpSchemaMethod<Schema>, path);\n }\n\n private createHttpRequestHandler<\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath<Schema, Method>,\n >(method: Method, path: Path): HttpRequestHandler<Schema, Method, Path> {\n if (!this.isRunning) {\n throw new NotRunningHttpInterceptorError();\n }\n\n const handler = new this.Handler<Schema, Method, Path>(this as SharedHttpInterceptorClient<Schema>, method, path);\n this.registerRequestHandler(handler);\n\n return handler;\n }\n\n registerRequestHandler<\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath<Schema, Method>,\n StatusCode extends HttpStatusCode = never,\n >(handler: InternalHttpRequestHandler<Schema, Method, Path, StatusCode>) {\n const pathHandlers = this.handlers[handler.method].get(handler.path) ?? [];\n\n const isAlreadyRegistered = pathHandlers.includes(handler.client);\n\n if (isAlreadyRegistered) {\n return;\n }\n\n pathHandlers.push(handler.client);\n\n const isFirstHandlerForMethodPath = pathHandlers.length === 1;\n\n if (!isFirstHandlerForMethodPath) {\n return;\n }\n\n this.handlers[handler.method].set(handler.path, pathHandlers);\n\n const pathRegex = createRegexFromPath(handler.path);\n\n const registrationResult = this.workerOrThrow.use(this, handler.method, handler.path, async (context) => {\n const response = await this.handleInterceptedRequest(\n handler.method,\n handler.path,\n pathRegex,\n context as HttpInterceptorRequestContext<Schema, Method, Path>,\n );\n return response;\n });\n\n if (handler instanceof RemoteHttpRequestHandler && registrationResult instanceof Promise) {\n handler.registerSyncPromise(registrationResult);\n }\n }\n\n private async handleInterceptedRequest<\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath<Schema, Method>,\n Context extends HttpInterceptorRequestContext<Schema, Method, Path>,\n >(method: Method, path: Path, pathRegex: RegExp, { request }: Context): Promise<HttpResponse | null> {\n const parsedRequest = await HttpInterceptorWorker.parseRawRequest<Path, Default<Schema[Path][Method]>>(request, {\n baseURL: this.baseURLAsString,\n pathRegex,\n });\n\n const matchedHandler = await this.findMatchedHandler(method, path, parsedRequest);\n\n if (!matchedHandler) {\n return null;\n }\n\n const responseDeclaration = await matchedHandler.applyResponseDeclaration(parsedRequest);\n const response = HttpInterceptorWorker.createResponseFromDeclaration(request, responseDeclaration);\n\n if (this.requestSaving.enabled) {\n const responseClone = response.clone();\n\n const parsedResponse = await HttpInterceptorWorker.parseRawResponse<\n Default<Schema[Path][Method]>,\n typeof responseDeclaration.status\n >(responseClone);\n\n matchedHandler.saveInterceptedRequest(parsedRequest, parsedResponse);\n }\n\n return response;\n }\n\n incrementNumberOfSavedRequests(increment: number) {\n this.numberOfSavedRequests = Math.max(this.numberOfSavedRequests + increment, 0);\n\n const exceedsSafeLimit = this.numberOfSavedRequests > this.requestSaving.safeLimit;\n\n if (increment > 0 && exceedsSafeLimit) {\n const error = new RequestSavingSafeLimitExceededError(this.numberOfSavedRequests, this.requestSaving.safeLimit);\n console.warn(error);\n }\n }\n\n private async findMatchedHandler<\n Method extends HttpSchemaMethod<Schema>,\n Path extends HttpSchemaPath<Schema, Method>,\n >(\n method: Method,\n path: Path,\n request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Promise<HttpRequestHandlerClient<Schema, Method, Path, any> | undefined> {\n /* istanbul ignore next -- @preserve\n * Ignoring because there will always be a handler for the given method and path at this point. */\n const pathHandlers = this.handlers[method].get(path) ?? [];\n\n const failedRequestMatches = new Map<\n AnyHttpRequestHandlerClient,\n Extract<HttpRequestHandlerRequestMatch, { success: false }>\n >();\n\n // If we find a matching handler that can accept more requests, we return it immediately.\n for (let handlerIndex = pathHandlers.length - 1; handlerIndex >= 0; handlerIndex--) {\n const handler = pathHandlers[handlerIndex];\n const requestMatch = await handler.matchesRequest(request);\n\n if (requestMatch.success) {\n handler.markRequestAsMatched(request);\n return handler;\n }\n\n failedRequestMatches.set(handler, requestMatch);\n }\n\n // If no handler matched or could accept more requests, we iterate again over the handlers to check which ones\n // could have matched considering only restrictions.\n for (let handlerIndex = pathHandlers.length - 1; handlerIndex >= 0; handlerIndex--) {\n const handler = pathHandlers[handlerIndex];\n const requestMatch = failedRequestMatches.get(handler);\n\n // Handlers that did not match due to anything other than restrictions are still marked as matched to trigger a\n // times check error.\n if (requestMatch?.cause === 'unmatchedRestrictions') {\n handler.markRequestAsUnmatched(request, { diff: requestMatch.diff });\n } else {\n handler.markRequestAsMatched(request);\n break;\n }\n }\n\n return undefined;\n }\n\n checkTimes() {\n for (const method of HTTP_METHODS) {\n const pathHandlers = this.handlers[method];\n\n for (const handlers of pathHandlers.values()) {\n for (let handlerIndex = handlers.length - 1; handlerIndex >= 0; handlerIndex--) {\n const handler = handlers[handlerIndex];\n handler.checkTimes();\n }\n }\n }\n }\n\n clear() {\n const clearPromises: Promise<AnyHttpRequestHandlerClient | void>[] = [\n Promise.resolve(this.workerOrThrow.clearHandlers({ interceptor: this })),\n ];\n\n for (const method of HTTP_METHODS) {\n for (const result of this.clearMethodHandlers(method)) {\n clearPromises.push(Promise.resolve(result));\n }\n\n const pathHandlers = this.handlers[method];\n pathHandlers.clear();\n }\n\n return Promise.all(clearPromises);\n }\n\n private clearMethodHandlers(method: HttpMethod) {\n const pathHandlers = this.handlers[method];\n const clearResults: PossiblePromise<AnyHttpRequestHandlerClient>[] = [];\n\n for (const handlers of pathHandlers.values()) {\n for (const handler of handlers) {\n clearResults.push(handler.clear());\n }\n }\n\n return clearResults;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyHttpInterceptorClient = HttpInterceptorClient<any>;\n\nexport type HttpRequestHandlerConstructor = typeof LocalHttpRequestHandler | typeof RemoteHttpRequestHandler;\n\nexport type SharedHttpInterceptorClient<Schema extends HttpSchema> = HttpInterceptorClient<\n Schema,\n typeof LocalHttpRequestHandler\n> &\n HttpInterceptorClient<Schema, typeof RemoteHttpRequestHandler>;\n\nexport default HttpInterceptorClient;\n","import { createPathParamRegex } from './createRegexFromPath';\n\nexport class DuplicatedPathParamError extends Error {\n constructor(path: string, paramName: string) {\n super(\n `The path parameter '${paramName}' appears more than once in '${path}'. This is not supported. ` +\n 'Please make sure that each parameter is unique.',\n );\n this.name = 'DuplicatedPathParamError';\n }\n}\n\nfunction validatePathParams(path: string) {\n const pathParamMatches = path.toString().matchAll(createPathParamRegex());\n\n const uniqueParamNames = new Set<string>();\n\n for (const paramMatch of pathParamMatches) {\n const paramName = paramMatch.groups?.identifier;\n\n if (!paramName) {\n continue;\n }\n\n if (uniqueParamNames.has(paramName)) {\n throw new DuplicatedPathParamError(path, paramName);\n }\n\n uniqueParamNames.add(paramName);\n }\n}\n\nexport default validatePathParams;\n","import { HttpRequest, HttpResponse, HttpMethod, HttpSchema } from '@zimic/http';\nimport createRegexFromPath from '@zimic/utils/url/createRegexFromPath';\nimport excludeNonPathParams from '@zimic/utils/url/excludeNonPathParams';\nimport validatePathParams from '@zimic/utils/url/validatePathParams';\nimport { SharedOptions as MSWWorkerSharedOptions, http, passthrough } from 'msw';\nimport * as mswBrowser from 'msw/browser';\nimport * as mswNode from 'msw/node';\n\nimport { removeArrayIndex } from '@/utils/arrays';\nimport { isClientSide, isServerSide } from '@/utils/environment';\n\nimport NotRunningHttpInterceptorError from '../interceptor/errors/NotRunningHttpInterceptorError';\nimport UnknownHttpInterceptorPlatformError from '../interceptor/errors/UnknownHttpInterceptorPlatformError';\nimport HttpInterceptorClient, { AnyHttpInterceptorClient } from '../interceptor/HttpInterceptorClient';\nimport UnregisteredBrowserServiceWorkerError from './errors/UnregisteredBrowserServiceWorkerError';\nimport HttpInterceptorWorker from './HttpInterceptorWorker';\nimport { HttpResponseFactoryContext } from './types/http';\nimport { BrowserMSWWorker, MSWHttpResponseFactory, MSWWorker, NodeMSWWorker } from './types/msw';\nimport { LocalHttpInterceptorWorkerOptions } from './types/options';\n\ninterface HttpHandler {\n baseURL: string;\n method: HttpMethod;\n pathRegex: RegExp;\n interceptor: AnyHttpInterceptorClient;\n createResponse: (context: HttpResponseFactoryContext) => Promise<Response>;\n}\n\nclass LocalHttpInterceptorWorker extends HttpInterceptorWorker {\n private internalWorker?: MSWWorker;\n\n private httpHandlersByMethod: {\n [Method in HttpMethod]: HttpHandler[];\n } = {\n GET: [],\n POST: [],\n PATCH: [],\n PUT: [],\n DELETE: [],\n HEAD: [],\n OPTIONS: [],\n };\n\n constructor(_options: LocalHttpInterceptorWorkerOptions) {\n super();\n }\n\n get type() {\n return 'local' as const;\n }\n\n get internalWorkerOrThrow() {\n /* istanbul ignore if -- @preserve\n * Trying to access the internal worker when it does not exist should not happen. */\n if (!this.internalWorker) {\n throw new NotRunningHttpInterceptorError();\n }\n return this.internalWorker;\n }\n\n get internalWorkerOrCreate() {\n this.internalWorker ??= this.createInternalWorker();\n return this.internalWorker;\n }\n\n private createInternalWorker() {\n const mswHttpHandler = http.all('*', async (context) => {\n const request = context.request satisfies Request as HttpRequest;\n const response = await this.createResponseForRequest(request);\n return response;\n });\n\n if (isServerSide() && 'setupServer' in mswNode) {\n return mswNode.setupServer(mswHttpHandler);\n }\n\n /* istanbul ignore else -- @preserve */\n if (isClientSide() && 'setupWorker' in mswBrowser) {\n return mswBrowser.setupWorker(mswHttpHandler);\n }\n\n /* istanbul ignore next -- @preserve\n * Ignoring because checking unknown platforms is not configured in our test setup. */\n throw new UnknownHttpInterceptorPlatformError();\n }\n\n async start() {\n await super.sharedStart(async () => {\n const internalWorker = this.internalWorkerOrCreate;\n\n const sharedOptions: MSWWorkerSharedOptions = {\n onUnhandledRequest: 'bypass',\n };\n\n if (this.isInternalBrowserWorker(internalWorker)) {\n this.platform = 'browser';\n await this.startInBrowser(internalWorker, sharedOptions);\n } else {\n this.platform = 'node';\n this.startInNode(internalWorker, sharedOptions);\n }\n\n this.isRunning = true;\n });\n }\n\n private async startInBrowser(internalWorker: BrowserMSWWorker, sharedOptions: MSWWorkerSharedOptions) {\n try {\n await internalWorker.start({ ...sharedOptions, quiet: true });\n } catch (error) {\n this.handleBrowserWorkerStartError(error);\n }\n }\n\n private handleBrowserWorkerStartError(error: unknown) {\n if (UnregisteredBrowserServiceWorkerError.matchesRawError(error)) {\n throw new UnregisteredBrowserServiceWorkerError();\n }\n throw error;\n }\n\n private startInNode(internalWorker: NodeMSWWorker, sharedOptions: MSWWorkerSharedOptions) {\n internalWorker.listen(sharedOptions);\n }\n\n async stop() {\n await super.sharedStop(() => {\n const internalWorker = this.internalWorkerOrCreate;\n\n if (this.isInternalBrowserWorker(internalWorker)) {\n this.stopInBrowser(internalWorker);\n } else {\n this.stopInNode(internalWorker);\n }\n this.clearHandlers();\n\n this.internalWorker = undefined;\n this.isRunning = false;\n });\n }\n\n private stopInBrowser(internalWorker: BrowserMSWWorker) {\n internalWorker.stop();\n }\n\n private stopInNode(internalWorker: NodeMSWWorker) {\n internalWorker.close();\n }\n\n private isInternalBrowserWorker(worker: MSWWorker) {\n return 'start' in worker && 'stop' in worker;\n }\n\n hasInternalBrowserWorker() {\n return this.isInternalBrowserWorker(this.internalWorkerOrThrow);\n }\n\n hasInternalNodeWorker() {\n return !this.hasInternalBrowserWorker();\n }\n\n use<Schema extends HttpSchema>(\n interceptor: HttpInterceptorClient<Schema>,\n method: HttpMethod,\n path: string,\n createResponse: MSWHttpResponseFactory,\n ) {\n if (!this.isRunning) {\n throw new NotRunningHttpInterceptorError();\n }\n\n validatePathParams(path);\n\n const methodHandlers = this.httpHandlersByMethod[method];\n\n const handler: HttpHandler = {\n baseURL: interceptor.baseURLAsString,\n method,\n pathRegex: createRegexFromPath(path),\n interceptor,\n createResponse: async (context) => {\n const request = context.request as HttpRequest;\n const requestClone = request.clone();\n\n let response: HttpResponse | null = null;\n\n try {\n response = await createResponse({ ...context, request });\n } catch (error) {\n console.error(error);\n }\n\n if (!response) {\n return this.bypassOrRejectUnhandledRequest(requestClone);\n }\n\n if (context.request.method === 'HEAD') {\n return new Response(null, {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n });\n }\n\n return response;\n },\n };\n\n methodHandlers.push(handler);\n }\n\n private async createResponseForRequest(request: HttpRequest) {\n const methodHandlers = this.httpHandlersByMethod[request.method as HttpMethod];\n\n const requestURL = excludeNonPathParams(new URL(request.url));\n const requestURLAsString = requestURL.href === `${requestURL.origin}/` ? requestURL.origin : requestURL.href;\n\n for (let handlerIndex = methodHandlers.length - 1; handlerIndex >= 0; handlerIndex--) {\n const handler = methodHandlers[handlerIndex];\n const matchesBaseURL = requestURLAsString.startsWith(handler.baseURL);\n\n if (!matchesBaseURL) {\n continue;\n }\n\n const requestPath = requestURLAsString.replace(handler.baseURL, '');\n const matchesPath = handler.pathRegex.test(requestPath);\n\n if (!matchesPath) {\n continue;\n }\n\n const response = await handler.createResponse({ request });\n return response;\n }\n\n return this.bypassOrRejectUnhandledRequest(request);\n }\n\n private async bypassOrRejectUnhandledRequest(request: HttpRequest) {\n const requestClone = request.clone();\n\n const strategy = await super.getUnhandledRequestStrategy(request, 'local');\n await super.logUnhandledRequestIfNecessary(requestClone, strategy);\n\n if (strategy?.action === 'reject') {\n return Response.error();\n } else {\n return passthrough();\n }\n }\n\n clearHandlers<Schema extends HttpSchema>(\n options: {\n interceptor?: HttpInterceptorClient<Schema>;\n } = {},\n ) {\n if (!this.isRunning) {\n throw new NotRunningHttpInterceptorError();\n }\n\n if (options.interceptor === undefined) {\n for (const handlers of Object.values(this.httpHandlersByMethod)) {\n handlers.length = 0;\n }\n } else {\n for (const methodHandlers of Object.values(this.httpHandlersByMethod)) {\n const groupToRemoveIndex = methodHandlers.findIndex((group) => group.interceptor === options.interceptor);\n removeArrayIndex(methodHandlers, groupToRemoveIndex);\n }\n }\n }\n\n get interceptorsWithHandlers() {\n const interceptors = new Set<AnyHttpInterceptorClient>();\n\n for (const handlers of Object.values(this.httpHandlersByMethod)) {\n for (const handler of handlers) {\n interceptors.add(handler.interceptor);\n }\n }\n\n return Array.from(interceptors);\n }\n}\n\nexport default LocalHttpInterceptorWorker;\n","import createCachedDynamicImport from '@zimic/utils/import/createCachedDynamicImport';\n\nexport type IsomorphicCrypto = Crypto | typeof import('crypto');\n\nexport const importCrypto = createCachedDynamicImport<IsomorphicCrypto>(async () => {\n const globalCrypto = globalThis.crypto as typeof globalThis.crypto | undefined;\n /* istanbul ignore next -- @preserve\n * Ignoring as Node.js >=20 provides a global crypto and the import fallback won't run. */\n return globalCrypto ?? (await import('crypto'));\n});\n","import { JSONValue } from '@zimic/http';\n\nimport { convertArrayBufferToBase64, convertBase64ToArrayBuffer } from './data';\n\nexport type SerializedHttpRequest = JSONValue<{\n url: string;\n method: string;\n mode: RequestMode;\n headers: Record<string, string>;\n cache: RequestCache;\n credentials: RequestCredentials;\n integrity: string;\n keepalive: boolean;\n redirect: RequestRedirect;\n referrer: string;\n referrerPolicy: ReferrerPolicy;\n body: string | null;\n}>;\n\nexport async function serializeRequest(request: Request): Promise<SerializedHttpRequest> {\n const requestClone = request.clone();\n const serializedBody = requestClone.body ? convertArrayBufferToBase64(await requestClone.arrayBuffer()) : null;\n\n return {\n url: request.url,\n method: request.method,\n mode: request.mode,\n headers: Object.fromEntries(request.headers),\n cache: request.cache,\n credentials: request.credentials,\n integrity: request.integrity,\n keepalive: request.keepalive,\n redirect: request.redirect,\n referrer: request.referrer,\n referrerPolicy: request.referrerPolicy,\n body: serializedBody,\n };\n}\n\nexport function deserializeRequest(serializedRequest: SerializedHttpRequest): Request {\n const deserializedBody = serializedRequest.body ? convertBase64ToArrayBuffer(serializedRequest.body) : null;\n\n return new Request(serializedRequest.url, {\n method: serializedRequest.method,\n mode: serializedRequest.mode,\n headers: new Headers(serializedRequest.headers),\n cache: serializedRequest.cache,\n credentials: serializedRequest.credentials,\n integrity: serializedRequest.integrity,\n keepalive: serializedRequest.keepalive,\n redirect: serializedRequest.redirect,\n referrer: serializedRequest.referrer,\n referrerPolicy: serializedRequest.referrerPolicy,\n body: deserializedBody,\n });\n}\n\nexport type SerializedResponse = JSONValue<{\n status: number;\n statusText: string;\n headers: Record<string, string>;\n body: string | null;\n}>;\n\nexport async function serializeResponse(response: Response): Promise<SerializedResponse> {\n const responseClone = response.clone();\n const serializedBody = responseClone.body ? convertArrayBufferToBase64(await responseClone.arrayBuffer()) : null;\n\n return {\n status: response.status,\n statusText: response.statusText,\n headers: Object.fromEntries(response.headers),\n body: serializedBody,\n };\n}\n\nexport function deserializeResponse(serializedResponse: SerializedResponse): Response {\n const deserializedBody = serializedResponse.body ? convertBase64ToArrayBuffer(serializedResponse.body) : null;\n\n return new Response(deserializedBody, {\n status: serializedResponse.status,\n statusText: serializedResponse.statusText,\n headers: new Headers(serializedResponse.headers),\n });\n}\n","import { CloseEvent } from 'isomorphic-ws';\n\n/** Error thrown when the connection to the interceptor web socket server is unauthorized. */\nclass UnauthorizedWebSocketConnectionError extends Error {\n constructor(readonly event: CloseEvent) {\n super(`${event.reason} (code ${event.code})`);\n this.name = 'UnauthorizedWebSocketConnectionError';\n }\n}\n\nexport default UnauthorizedWebSocketConnectionError;\n","import ClientSocket, { type WebSocketServer as ServerSocket } from 'isomorphic-ws';\n\nimport { WebSocketControlMessage } from '@/webSocket/constants';\nimport UnauthorizedWebSocketConnectionError from '@/webSocket/errors/UnauthorizedWebSocketConnectionError';\n\nclass WebSocketTimeoutError extends Error {}\n\nexport class WebSocketOpenTimeoutError extends WebSocketTimeoutError {\n constructor(reachedTimeout: number) {\n super(`Web socket open timed out after ${reachedTimeout}ms.`);\n this.name = 'WebSocketOpenTimeoutError';\n }\n}\n\nexport class WebSocketMessageTimeoutError extends WebSocketTimeoutError {\n constructor(reachedTimeout: number) {\n super(`Web socket message timed out after ${reachedTimeout}ms.`);\n this.name = 'WebSocketMessageTimeoutError';\n }\n}\n\nexport class WebSocketMessageAbortError extends WebSocketTimeoutError {\n constructor() {\n super('Web socket message was aborted.');\n this.name = 'WebSocketMessageAbortError';\n }\n}\n\nexport class WebSocketCloseTimeoutError extends WebSocketTimeoutError {\n constructor(reachedTimeout: number) {\n super(`Web socket close timed out after ${reachedTimeout}ms.`);\n this.name = 'WebSocketCloseTimeoutError';\n }\n}\n\nexport const DEFAULT_WEB_SOCKET_LIFECYCLE_TIMEOUT = 60 * 1000;\nexport const DEFAULT_WEB_SOCKET_MESSAGE_TIMEOUT = 3 * 60 * 1000;\n\nexport async function waitForOpenClientSocket(\n socket: ClientSocket,\n options: {\n timeout?: number;\n waitForAuthentication?: boolean;\n } = {},\n) {\n const { timeout: timeoutDuration = DEFAULT_WEB_SOCKET_LIFECYCLE_TIMEOUT, waitForAuthentication = false } = options;\n\n const isAlreadyOpen = socket.readyState === socket.OPEN;\n\n if (isAlreadyOpen) {\n return;\n }\n\n await new Promise<void>((resolve, reject) => {\n function removeAllSocketListeners() {\n socket.removeEventListener('message', handleSocketMessage); // eslint-disable-line @typescript-eslint/no-use-before-define\n socket.removeEventListener('open', handleOpenSuccess); // eslint-disable-line @typescript-eslint/no-use-before-define\n socket.removeEventListener('error', handleOpenError); // eslint-disable-line @typescript-eslint/no-use-before-define\n socket.removeEventListener('close', handleClose); // eslint-disable-line @typescript-eslint/no-use-before-define\n }\n\n function handleOpenError(error: unknown) {\n removeAllSocketListeners();\n reject(error);\n }\n\n function handleClose(event: ClientSocket.CloseEvent) {\n const isUnauthorized = event.code === 1008;\n\n /* istanbul ignore else -- @preserve\n * An unauthorized close event is the only one we expect to happen here. */\n if (isUnauthorized) {\n const unauthorizedError = new UnauthorizedWebSocketConnectionError(event);\n handleOpenError(unauthorizedError);\n } else {\n handleOpenError(event);\n }\n }\n\n const openTimeout = setTimeout(() => {\n const timeoutError = new WebSocketOpenTimeoutError(timeoutDuration);\n handleOpenError(timeoutError);\n }, timeoutDuration);\n\n function handleOpenSuccess() {\n removeAllSocketListeners();\n clearTimeout(openTimeout);\n resolve();\n }\n\n function handleSocketMessage(message: ClientSocket.MessageEvent) {\n const hasValidAuth = message.data === ('socket:auth:valid' satisfies WebSocketControlMessage);\n\n /* istanbul ignore else -- @preserve\n * We currently only support the 'socket:auth:valid' message and it is the only possible control message here. */\n if (hasValidAuth) {\n handleOpenSuccess();\n }\n }\n\n if (waitForAuthentication) {\n socket.addEventListener('message', handleSocketMessage);\n } else {\n socket.addEventListener('open', handleOpenSuccess);\n }\n\n socket.addEventListener('error', handleOpenError);\n socket.addEventListener('close', handleClose);\n });\n}\n\nexport async function closeClientSocket(socket: ClientSocket, options: { timeout?: number } = {}) {\n const { timeout: timeoutDuration = DEFAULT_WEB_SOCKET_LIFECYCLE_TIMEOUT } = options;\n\n const isAlreadyClosed = socket.readyState === socket.CLOSED;\n if (isAlreadyClosed) {\n return;\n }\n\n await new Promise<void>((resolve, reject) => {\n function removeAllSocketListeners() {\n socket.removeEventListener('error', handleError); // eslint-disable-line @typescript-eslint/no-use-before-define\n socket.removeEventListener('close', handleClose); // eslint-disable-line @typescript-eslint/no-use-before-define\n }\n\n function handleError(error: unknown) {\n removeAllSocketListeners();\n reject(error);\n }\n\n const closeTimeout = setTimeout(() => {\n const timeoutError = new WebSocketCloseTimeoutError(timeoutDuration);\n handleError(timeoutError);\n }, timeoutDuration);\n\n function handleClose() {\n removeAllSocketListeners();\n clearTimeout(closeTimeout);\n resolve();\n }\n\n socket.addEventListener('error', handleError);\n socket.addEventListener('close', handleClose);\n\n socket.close();\n });\n}\n\nexport async function closeServerSocket(socket: InstanceType<typeof ServerSocket>, options: { timeout?: number } = {}) {\n const { timeout: timeoutDuration = DEFAULT_WEB_SOCKET_LIFECYCLE_TIMEOUT } = options;\n\n await new Promise<void>((resolve, reject) => {\n const closeTimeout = setTimeout(() => {\n const timeoutError = new WebSocketCloseTimeoutError(timeoutDuration);\n reject(timeoutError);\n }, timeoutDuration);\n\n for (const client of socket.clients) {\n client.terminate();\n }\n\n socket.close((error) => {\n clearTimeout(closeTimeout);\n\n /* istanbul ignore if -- @preserve\n * This is not expected since the server is not stopped unless it is running. */\n if (error) {\n reject(error);\n } else {\n resolve();\n }\n });\n });\n}\n","export const WEB_SOCKET_CONTROL_MESSAGES = Object.freeze(['socket:auth:valid'] as const);\nexport type WebSocketControlMessage = (typeof WEB_SOCKET_CONTROL_MESSAGES)[number];\n","class InvalidWebSocketMessageError extends Error {\n constructor(message: unknown) {\n super(`Web socket message is invalid and could not be parsed: ${message}`);\n this.name = 'InvalidWebSocketMessageError';\n }\n}\n\nexport default InvalidWebSocketMessageError;\n","class NotRunningWebSocketHandlerError extends Error {\n constructor() {\n super('Web socket handler is not running.');\n this.name = 'NotRunningWebSocketHandlerError';\n }\n}\n\nexport default NotRunningWebSocketHandlerError;\n","import { Collection } from '@zimic/utils/types';\nimport ClientSocket from 'isomorphic-ws';\n\nimport { importCrypto } from '@/utils/crypto';\nimport {\n DEFAULT_WEB_SOCKET_LIFECYCLE_TIMEOUT,\n DEFAULT_WEB_SOCKET_MESSAGE_TIMEOUT,\n WebSocketMessageAbortError,\n WebSocketMessageTimeoutError,\n closeClientSocket,\n waitForOpenClientSocket,\n} from '@/utils/webSocket';\n\nimport { WEB_SOCKET_CONTROL_MESSAGES, WebSocketControlMessage } from './constants';\nimport InvalidWebSocketMessageError from './errors/InvalidWebSocketMessageError';\nimport NotRunningWebSocketHandlerError from './errors/NotRunningWebSocketHandlerError';\nimport {\n WebSocketEventMessageListener,\n WebSocketReplyMessageListener,\n WebSocketReplyMessage,\n WebSocketEventMessage,\n WebSocketSchema,\n WebSocketChannel,\n WebSocketChannelWithReply,\n WebSocketChannelWithNoReply,\n WebSocketMessage,\n} from './types';\n\ninterface WebSocketRequestAbortOptions<Schema extends WebSocketSchema> {\n shouldAbortRequest?: (request: WebSocketEventMessage<Schema>) => boolean;\n}\n\nabstract class WebSocketHandler<Schema extends WebSocketSchema> {\n private sockets = new Set<ClientSocket>();\n\n socketTimeout: number;\n messageTimeout: number;\n\n private channelListeners: {\n [Channel in WebSocketChannel<Schema>]?: {\n event: Set<WebSocketEventMessageListener<Schema, Channel>>;\n reply: Set<WebSocketReplyMessageListener<Schema, Channel>>;\n };\n } = {};\n\n private socketListeners = {\n abortRequests: new Map<ClientSocket, Set<(options: WebSocketRequestAbortOptions<Schema>) => void>>(),\n };\n\n protected constructor(options: { socketTimeout?: number; messageTimeout?: number }) {\n this.socketTimeout = options.socketTimeout ?? DEFAULT_WEB_SOCKET_LIFECYCLE_TIMEOUT;\n this.messageTimeout = options.messageTimeout ?? DEFAULT_WEB_SOCKET_MESSAGE_TIMEOUT;\n }\n\n abstract isRunning: boolean;\n\n protected async registerSocket(socket: ClientSocket, options: { waitForAuthentication?: boolean } = {}) {\n const openPromise = waitForOpenClientSocket(socket, {\n timeout: this.socketTimeout,\n waitForAuthentication: options.waitForAuthentication,\n });\n\n const handleSocketMessage = async (rawMessage: ClientSocket.MessageEvent) => {\n await this.handleSocketMessage(socket, rawMessage);\n };\n socket.addEventListener('message', handleSocketMessage);\n\n await openPromise;\n\n /* istanbul ignore next -- @preserve\n * It is difficult to reliably simulate socket errors in tests. */\n function handleSocketError(error: ClientSocket.ErrorEvent) {\n console.error(error);\n }\n socket.addEventListener('error', handleSocketError);\n\n const handleSocketClose = () => {\n this.sockets.delete(socket);\n\n this.emitSocket('abortRequests', socket);\n this.socketListeners.abortRequests.delete(socket);\n\n socket.removeEventListener('message', handleSocketMessage);\n socket.removeEventListener('close', handleSocketClose);\n socket.removeEventListener('error', handleSocketError);\n };\n\n socket.addEventListener('close', handleSocketClose);\n\n this.sockets.add(socket);\n }\n\n private handleSocketMessage = async (socket: ClientSocket, rawMessage: ClientSocket.MessageEvent) => {\n try {\n if (this.isControlMessageData(rawMessage.data)) {\n return;\n }\n\n const stringifiedMessageData = this.readRawMessageData(rawMessage.data);\n const parsedMessageData = this.parseMessage(stringifiedMessageData);\n await this.notifyListeners(parsedMessageData, socket);\n } catch (error) {\n console.error(error);\n }\n };\n\n private isControlMessageData(messageData: ClientSocket.Data): messageData is WebSocketControlMessage {\n return (\n typeof messageData === 'string' && WEB_SOCKET_CONTROL_MESSAGES.includes(messageData as WebSocketControlMessage)\n );\n }\n\n private readRawMessageData(data: ClientSocket.Data) {\n /* istanbul ignore else -- @preserve\n * All supported websocket messages should be encoded as strings. */\n if (typeof data === 'string') {\n return data;\n } else {\n throw new InvalidWebSocketMessageError(data);\n }\n }\n\n private parseMessage(stringifiedMessage: string): WebSocketMessage<Schema> {\n let parsedMessage: unknown;\n\n try {\n parsedMessage = JSON.parse(stringifiedMessage) as unknown;\n } catch {\n throw new InvalidWebSocketMessageError(stringifiedMessage);\n }\n\n if (!this.isMessage(parsedMessage)) {\n throw new InvalidWebSocketMessageError(stringifiedMessage);\n }\n\n if (this.isReplyMessage(parsedMessage)) {\n return {\n id: parsedMessage.id,\n channel: parsedMessage.channel,\n requestId: parsedMessage.requestId,\n data: parsedMessage.data,\n };\n }\n\n return {\n id: parsedMessage.id,\n channel: parsedMessage.channel,\n data: parsedMessage.data,\n };\n }\n\n private isMessage(message: unknown): message is WebSocketMessage<Schema> {\n return (\n typeof message === 'object' &&\n message !== null &&\n 'id' in message &&\n typeof message.id === 'string' &&\n 'channel' in message &&\n typeof message.channel === 'string' &&\n (!('requestId' in message) || typeof message.requestId === 'string')\n );\n }\n\n isChannelEvent<Channel extends WebSocketChannel<Schema>>(\n event: WebSocketEventMessage<Schema>,\n channel: Channel,\n ): event is WebSocketEventMessage<Schema, Channel> {\n return event.channel === channel;\n }\n\n private async notifyListeners(message: WebSocketMessage<Schema>, socket: ClientSocket) {\n if (this.isReplyMessage(message)) {\n await this.notifyReplyListeners(message, socket);\n } else {\n await this.notifyEventListeners(message, socket);\n }\n }\n\n private async notifyReplyListeners(message: WebSocketReplyMessage<Schema>, socket: ClientSocket) {\n /* istanbul ignore next -- @preserve\n * Reply listeners are always present when notified in normal conditions. If they were not present, the request\n * would reach a timeout and not be responded. The empty set serves as a fallback. */\n const listeners = this.channelListeners[message.channel]?.reply ?? new Set();\n\n const listenerPromises = Array.from(listeners, async (listener) => {\n await listener(message, socket);\n });\n\n await Promise.all(listenerPromises);\n }\n\n private async notifyEventListeners(message: WebSocketEventMessage<Schema>, socket: ClientSocket) {\n const listeners = this.channelListeners[message.channel]?.event ?? new Set();\n\n const listenerPromises = Array.from(listeners, async (listener) => {\n const replyData = await listener(message, socket);\n await this.reply(message, replyData, { sockets: [socket] });\n });\n\n await Promise.all(listenerPromises);\n }\n\n protected async closeClientSockets(sockets: Collection<ClientSocket> = this.sockets) {\n const closingPromises = Array.from(sockets, async (socket) => {\n await closeClientSocket(socket, { timeout: this.socketTimeout });\n });\n await Promise.all(closingPromises);\n }\n\n private async createEventMessage<Channel extends WebSocketChannel<Schema>>(\n channel: Channel,\n eventData: WebSocketEventMessage<Schema, Channel>['data'],\n ) {\n const crypto = await importCrypto();\n\n const eventMessage: WebSocketEventMessage<Schema, Channel> = {\n id: crypto.randomUUID(),\n channel,\n data: eventData,\n };\n return eventMessage;\n }\n\n async send<Channel extends WebSocketChannelWithNoReply<Schema>>(\n channel: Channel,\n eventData: WebSocketEventMessage<Schema, Channel>['data'],\n options: {\n sockets?: Collection<ClientSocket>;\n } = {},\n ) {\n const event = await this.createEventMessage(channel, eventData);\n this.sendMessage(event, options.sockets);\n }\n\n async request<Channel extends WebSocketChannelWithReply<Schema>>(\n channel: Channel,\n requestData: WebSocketEventMessage<Schema, Channel>['data'],\n options: {\n sockets?: Collection<ClientSocket>;\n } = {},\n ) {\n const request = await this.createEventMessage(channel, requestData);\n this.sendMessage(request, options.sockets);\n\n const response = await this.waitForReply(channel, request, options.sockets);\n return response.data;\n }\n\n async waitForReply<Channel extends WebSocketChannelWithReply<Schema>>(\n channel: Channel,\n request: WebSocketEventMessage<Schema, Channel>,\n sockets: Collection<ClientSocket> = this.sockets,\n ) {\n return new Promise<WebSocketReplyMessage<Schema, Channel>>((resolve, reject) => {\n const replyTimeout = setTimeout(() => {\n this.offChannel('reply', channel, replyListener); // eslint-disable-line @typescript-eslint/no-use-before-define\n\n for (const socket of sockets) {\n this.offSocket('abortRequests', socket, abortRequestsHandler); // eslint-disable-line @typescript-eslint/no-use-before-define\n }\n\n const timeoutError = new WebSocketMessageTimeoutError(this.messageTimeout);\n reject(timeoutError);\n }, this.messageTimeout);\n\n const replyListener = this.onChannel('reply', channel, (message) => {\n if (message.requestId !== request.id) {\n return;\n }\n\n clearTimeout(replyTimeout);\n\n this.offChannel('reply', channel, replyListener);\n\n for (const socket of sockets) {\n this.offSocket('abortRequests', socket, abortRequestsHandler); // eslint-disable-line @typescript-eslint/no-use-before-define\n }\n\n resolve(message);\n });\n\n const abortRequestsHandler = (options: WebSocketRequestAbortOptions<Schema>) => {\n const shouldAbortRequest = options.shouldAbortRequest === undefined || options.shouldAbortRequest(request);\n\n /* istanbul ignore if -- @preserve\n * Aborting requests is highly non-deterministic because it depends on specific timing of socket events. */\n if (!shouldAbortRequest) {\n return;\n }\n\n clearTimeout(replyTimeout);\n\n this.offChannel('reply', channel, replyListener);\n\n for (const socket of sockets) {\n this.offSocket('abortRequests', socket, abortRequestsHandler);\n }\n\n const abortError = new WebSocketMessageAbortError();\n reject(abortError);\n };\n\n for (const socket of sockets) {\n this.onSocket('abortRequests', socket, abortRequestsHandler);\n }\n });\n }\n\n private isReplyMessage<Channel extends WebSocketChannel<Schema>>(message: WebSocketMessage<Schema, Channel>) {\n return 'requestId' in message;\n }\n\n async reply<Channel extends WebSocketChannel<Schema>>(\n request: WebSocketEventMessage<Schema, Channel>,\n replyData: WebSocketReplyMessage<Schema, Channel>['data'],\n options: {\n sockets: Collection<ClientSocket>;\n },\n ) {\n const reply = await this.createReplyMessage(request, replyData);\n\n // If this handler received a request and was stopped before responding, discard any pending replies.\n if (this.isRunning) {\n this.sendMessage(reply, options.sockets);\n }\n }\n\n private async createReplyMessage<Channel extends WebSocketChannel<Schema>>(\n request: WebSocketEventMessage<Schema, Channel>,\n replyData: WebSocketReplyMessage<Schema, Channel>['data'],\n ) {\n const crypto = await importCrypto();\n\n const replyMessage: WebSocketReplyMessage<Schema, Channel> = {\n id: crypto.randomUUID(),\n channel: request.channel,\n requestId: request.id,\n data: replyData,\n };\n return replyMessage;\n }\n\n private sendMessage<Channel extends WebSocketChannel<Schema>>(\n message: WebSocketMessage<Schema, Channel>,\n sockets: Collection<ClientSocket> = this.sockets,\n ) {\n if (!this.isRunning) {\n throw new NotRunningWebSocketHandlerError();\n }\n\n const stringifiedMessage = JSON.stringify(message);\n\n for (const socket of sockets) {\n socket.send(stringifiedMessage);\n }\n }\n\n onChannel<Channel extends WebSocketChannel<Schema>, Listener extends WebSocketEventMessageListener<Schema, Channel>>(\n type: 'event',\n channel: Channel,\n eventListener: Listener,\n ): Listener;\n onChannel<Channel extends WebSocketChannel<Schema>, Listener extends WebSocketReplyMessageListener<Schema, Channel>>(\n type: 'reply',\n channel: Channel,\n replyListener: Listener,\n ): Listener;\n onChannel<\n Channel extends WebSocketChannel<Schema>,\n Listener extends WebSocketEventMessageListener<Schema, Channel> & WebSocketReplyMessageListener<Schema, Channel>,\n >(type: 'event' | 'reply', channel: Channel, listener: Listener): Listener {\n const listeners = this.getOrCreateChannelListeners<Channel>(channel);\n listeners[type].add(listener);\n return listener;\n }\n\n offAny() {\n this.channelListeners = {};\n\n for (const listenersBySocket of Object.values(this.socketListeners)) {\n for (const listeners of listenersBySocket.values()) {\n listeners.clear();\n }\n }\n }\n\n private getOrCreateChannelListeners<Channel extends WebSocketChannel<Schema>>(channel: Channel) {\n const listeners = this.channelListeners[channel] ?? {\n event: new Set(),\n reply: new Set(),\n };\n\n if (!this.channelListeners[channel]) {\n this.channelListeners[channel] = listeners;\n }\n\n return listeners;\n }\n\n offChannel<Channel extends WebSocketChannel<Schema>>(\n type: 'event',\n channel: Channel,\n eventListener: WebSocketEventMessageListener<Schema, Channel>,\n ): void;\n offChannel<Channel extends WebSocketChannel<Schema>>(\n type: 'reply',\n channel: Channel,\n replyListener: WebSocketReplyMessageListener<Schema, Channel>,\n ): void;\n offChannel<Channel extends WebSocketChannel<Schema>>(\n type: 'event' | 'reply',\n channel: Channel,\n listener: WebSocketEventMessageListener<Schema, Channel> & WebSocketReplyMessageListener<Schema, Channel>,\n ) {\n const listeners = this.channelListeners[channel];\n listeners?.[type].delete(listener);\n }\n\n onSocket<Listener extends (options: WebSocketRequestAbortOptions<Schema>) => void>(\n type: 'abortRequests',\n socket: ClientSocket,\n listener: Listener,\n ): Listener {\n const listeners = this.getOrCreateSocketListeners(type, socket);\n listeners.add(listener);\n return listener;\n }\n\n private getOrCreateSocketListeners(type: 'abortRequests', socket: ClientSocket) {\n const listeners = this.socketListeners[type].get(socket) ?? new Set();\n\n if (!this.socketListeners[type].has(socket)) {\n this.socketListeners[type].set(socket, listeners);\n }\n\n return listeners;\n }\n\n offSocket<Listener extends (options: WebSocketRequestAbortOptions<Schema>) => void>(\n type: 'abortRequests',\n socket: ClientSocket,\n listener: Listener,\n ) {\n const listeners = this.socketListeners[type].get(socket);\n listeners?.delete(listener);\n }\n\n emitSocket(type: 'abortRequests', socket: ClientSocket, options: WebSocketRequestAbortOptions<Schema> = {}) {\n for (const listener of this.socketListeners[type].get(socket) ?? []) {\n listener(options);\n }\n }\n}\n\nexport default WebSocketHandler;\n","import validateURLProtocol from '@zimic/utils/url/validateURLProtocol';\nimport ClientSocket from 'isomorphic-ws';\n\nimport { WebSocketSchema } from './types';\nimport WebSocketHandler from './WebSocketHandler';\n\nconst SUPPORTED_WEB_SOCKET_PROTOCOLS = ['ws', 'wss'];\n\ninterface WebSocketClientOptions {\n url: string;\n socketTimeout?: number;\n messageTimeout?: number;\n}\n\nclass WebSocketClient<Schema extends WebSocketSchema> extends WebSocketHandler<Schema> {\n private url: URL;\n\n private socket?: ClientSocket;\n\n constructor(options: WebSocketClientOptions) {\n super({\n socketTimeout: options.socketTimeout,\n messageTimeout: options.messageTimeout,\n });\n\n this.url = new URL(options.url);\n validateURLProtocol(this.url, SUPPORTED_WEB_SOCKET_PROTOCOLS);\n }\n\n get isRunning() {\n return this.socket !== undefined && this.socket.readyState === this.socket.OPEN;\n }\n\n async start(options: { parameters?: Record<string, string>; waitForAuthentication?: boolean } = {}) {\n const parametersAsString = options.parameters\n ? Object.entries(options.parameters)\n .map(([key, value]) => `${key}=${value}`)\n .map(encodeURIComponent)\n : [];\n\n this.socket = new ClientSocket(this.url, parametersAsString);\n\n try {\n await super.registerSocket(this.socket, options);\n } catch (error) {\n await this.stop();\n throw error;\n }\n }\n\n async stop() {\n super.offAny();\n\n if (this.socket) {\n await super.closeClientSockets([this.socket]);\n }\n\n this.socket = undefined;\n }\n}\n\nexport default WebSocketClient;\n","import { HttpMethod, HttpSchema } from '@zimic/http';\nimport validatePathParams from '@zimic/utils/url/validatePathParams';\n\nimport { HttpHandlerCommit, InterceptorServerWebSocketSchema } from '@/server/types/schema';\nimport { importCrypto } from '@/utils/crypto';\nimport { isClientSide, isServerSide } from '@/utils/environment';\nimport { deserializeRequest, serializeResponse } from '@/utils/fetch';\nimport { WebSocketMessageAbortError } from '@/utils/webSocket';\nimport { WebSocketEventMessage } from '@/webSocket/types';\nimport WebSocketClient from '@/webSocket/WebSocketClient';\n\nimport NotRunningHttpInterceptorError from '../interceptor/errors/NotRunningHttpInterceptorError';\nimport UnknownHttpInterceptorPlatformError from '../interceptor/errors/UnknownHttpInterceptorPlatformError';\nimport HttpInterceptorClient, { AnyHttpInterceptorClient } from '../interceptor/HttpInterceptorClient';\nimport { HttpInterceptorPlatform } from '../interceptor/types/options';\nimport HttpInterceptorWorker from './HttpInterceptorWorker';\nimport { HttpResponseFactoryContext } from './types/http';\nimport { MSWHttpResponseFactory } from './types/msw';\nimport { RemoteHttpInterceptorWorkerOptions } from './types/options';\n\ninterface HttpHandler {\n id: string;\n baseURL: string;\n method: HttpMethod;\n path: string;\n interceptor: AnyHttpInterceptorClient;\n createResponse: (context: HttpResponseFactoryContext) => Promise<Response | null>;\n}\n\nclass RemoteHttpInterceptorWorker extends HttpInterceptorWorker {\n private httpHandlers = new Map<HttpHandler['id'], HttpHandler>();\n\n webSocketClient: WebSocketClient<InterceptorServerWebSocketSchema>;\n private auth?: RemoteHttpInterceptorWorkerOptions['auth'];\n\n constructor(options: RemoteHttpInterceptorWorkerOptions) {\n super();\n\n this.webSocketClient = new WebSocketClient({\n url: this.getWebSocketServerURL(options.serverURL).toString(),\n });\n\n this.auth = options.auth;\n }\n\n get type() {\n return 'remote' as const;\n }\n\n private getWebSocketServerURL(serverURL: URL) {\n const webSocketServerURL = new URL(serverURL);\n webSocketServerURL.protocol = serverURL.protocol.replace(/^http(s)?:$/, 'ws$1:');\n return webSocketServerURL;\n }\n\n async start() {\n await super.sharedStart(async () => {\n this.webSocketClient.onChannel('event', 'interceptors/responses/create', this.createResponse);\n this.webSocketClient.onChannel('event', 'interceptors/responses/unhandled', this.handleUnhandledServerRequest);\n\n await this.webSocketClient.start({\n parameters: this.auth ? { token: this.auth.token } : undefined,\n waitForAuthentication: true,\n });\n\n this.platform = this.readPlatform();\n this.isRunning = true;\n });\n }\n\n private createResponse = async (\n message: WebSocketEventMessage<InterceptorServerWebSocketSchema, 'interceptors/responses/create'>,\n ) => {\n const { handlerId, request: serializedRequest } = message.data;\n\n const handler = this.httpHandlers.get(handlerId);\n const request = deserializeRequest(serializedRequest);\n\n try {\n const rawResponse = (await handler?.createResponse({ request })) ?? null;\n const response = rawResponse && request.method === 'HEAD' ? new Response(null, rawResponse) : rawResponse;\n\n if (response) {\n return { response: await serializeResponse(response) };\n }\n } catch (error) {\n console.error(error);\n }\n\n const strategy = await super.getUnhandledRequestStrategy(request, 'remote');\n await super.logUnhandledRequestIfNecessary(request, strategy);\n\n return { response: null };\n };\n\n private handleUnhandledServerRequest = async (\n message: WebSocketEventMessage<InterceptorServerWebSocketSchema, 'interceptors/responses/unhandled'>,\n ) => {\n const { request: serializedRequest } = message.data;\n const request = deserializeRequest(serializedRequest);\n\n const strategy = await super.getUnhandledRequestStrategy(request, 'remote');\n const { wasLogged } = await super.logUnhandledRequestIfNecessary(request, strategy);\n\n return { wasLogged };\n };\n\n private readPlatform(): HttpInterceptorPlatform {\n if (isServerSide()) {\n return 'node';\n }\n /* istanbul ignore else -- @preserve */\n if (isClientSide()) {\n return 'browser';\n }\n /* istanbul ignore next -- @preserve\n * Ignoring because checking unknown platforms is not configured in our test setup. */\n throw new UnknownHttpInterceptorPlatformError();\n }\n\n async stop() {\n await super.sharedStop(async () => {\n this.webSocketClient.offChannel('event', 'interceptors/responses/create', this.createResponse);\n this.webSocketClient.offChannel('event', 'interceptors/responses/unhandled', this.handleUnhandledServerRequest);\n\n await this.clearHandlers();\n\n await this.webSocketClient.stop();\n\n this.isRunning = false;\n });\n }\n\n async use<Schema extends HttpSchema>(\n interceptor: HttpInterceptorClient<Schema>,\n method: HttpMethod,\n path: string,\n createResponse: MSWHttpResponseFactory,\n ) {\n if (!this.isRunning) {\n throw new NotRunningHttpInterceptorError();\n }\n\n validatePathParams(path);\n\n const crypto = await importCrypto();\n\n const handler: HttpHandler = {\n id: crypto.randomUUID(),\n baseURL: interceptor.baseURLAsString,\n method,\n path,\n interceptor,\n async createResponse(context) {\n const response = await createResponse(context);\n return response;\n },\n };\n\n this.httpHandlers.set(handler.id, handler);\n\n await this.webSocketClient.request('interceptors/workers/commit', {\n id: handler.id,\n baseURL: handler.baseURL,\n method: handler.method,\n path: handler.path,\n });\n }\n\n async clearHandlers<Schema extends HttpSchema>(\n options: {\n interceptor?: HttpInterceptorClient<Schema>;\n } = {},\n ) {\n if (!this.isRunning) {\n throw new NotRunningHttpInterceptorError();\n }\n\n if (options.interceptor === undefined) {\n this.httpHandlers.clear();\n } else {\n for (const handler of this.httpHandlers.values()) {\n if (handler.interceptor === options.interceptor) {\n this.httpHandlers.delete(handler.id);\n }\n }\n }\n\n if (!this.webSocketClient.isRunning) {\n return;\n }\n\n const handlersToRecommit = Array.from<HttpHandler, HttpHandlerCommit>(this.httpHandlers.values(), (handler) => ({\n id: handler.id,\n baseURL: handler.baseURL,\n method: handler.method,\n path: handler.path,\n }));\n\n try {\n await this.webSocketClient.request('interceptors/workers/reset', handlersToRecommit);\n } catch (error) {\n /* istanbul ignore next -- @preserve\n *\n * If the socket is closed before receiving a response, the message is aborted with an error. This can happen if\n * we send a request message and the interceptor server closes the socket before sending a response. In this case,\n * we can safely ignore the error because we know that the server is shutting down and resetting is no longer\n * necessary.\n *\n * Due to the rare nature of this edge case, we can't reliably reproduce it in tests. */\n const isMessageAbortError = error instanceof WebSocketMessageAbortError;\n\n /* istanbul ignore next -- @preserve */\n if (!isMessageAbortError) {\n throw error;\n }\n }\n }\n\n get interceptorsWithHandlers() {\n const interceptors = Array.from(this.httpHandlers.values(), (handler) => handler.interceptor);\n return interceptors;\n }\n}\n\nexport default RemoteHttpInterceptorWorker;\n","import LocalHttpInterceptorWorker from './LocalHttpInterceptorWorker';\nimport RemoteHttpInterceptorWorker from './RemoteHttpInterceptorWorker';\nimport {\n HttpInterceptorWorkerOptions,\n LocalHttpInterceptorWorkerOptions,\n RemoteHttpInterceptorWorkerOptions,\n} from './types/options';\n\nexport function createHttpInterceptorWorker(options: LocalHttpInterceptorWorkerOptions): LocalHttpInterceptorWorker;\nexport function createHttpInterceptorWorker(options: RemoteHttpInterceptorWorkerOptions): RemoteHttpInterceptorWorker;\nexport function createHttpInterceptorWorker(\n options: HttpInterceptorWorkerOptions,\n): LocalHttpInterceptorWorker | RemoteHttpInterceptorWorker;\nexport function createHttpInterceptorWorker(\n options: HttpInterceptorWorkerOptions,\n): LocalHttpInterceptorWorker | RemoteHttpInterceptorWorker {\n if (options.type === 'local') {\n return new LocalHttpInterceptorWorker(options);\n } else {\n return new RemoteHttpInterceptorWorker(options);\n }\n}\n","import { createHttpInterceptorWorker } from '../interceptorWorker/factory';\nimport LocalHttpInterceptorWorker from '../interceptorWorker/LocalHttpInterceptorWorker';\nimport RemoteHttpInterceptorWorker from '../interceptorWorker/RemoteHttpInterceptorWorker';\nimport {\n LocalHttpInterceptorWorkerOptions,\n RemoteHttpInterceptorWorkerOptions,\n} from '../interceptorWorker/types/options';\nimport { AnyHttpInterceptorClient } from './HttpInterceptorClient';\n\ninterface RemoteWorkerKeyOptions {\n auth: RemoteHttpInterceptorWorkerOptions['auth'];\n}\n\nclass HttpInterceptorStore {\n private static _localWorker?: LocalHttpInterceptorWorker;\n private static runningLocalInterceptors = new Set<AnyHttpInterceptorClient>();\n\n private static remoteWorkers = new Map<string, RemoteHttpInterceptorWorker>();\n private static runningRemoteInterceptors = new Map<string, Set<AnyHttpInterceptorClient>>();\n\n private class = HttpInterceptorStore;\n\n get localWorker() {\n return this.class._localWorker;\n }\n\n private getRemoteWorkerKey(baseURL: URL, options: RemoteWorkerKeyOptions) {\n const key = [`${baseURL.origin}${baseURL.pathname}`];\n\n if (options.auth) {\n key.push(options.auth.token);\n }\n\n return key.join(':');\n }\n\n remoteWorker(baseURL: URL, options: RemoteWorkerKeyOptions) {\n const remoteWorkerKey = this.getRemoteWorkerKey(baseURL, options);\n return this.class.remoteWorkers.get(remoteWorkerKey);\n }\n\n get numberOfRunningLocalInterceptors() {\n return this.class.runningLocalInterceptors.size;\n }\n\n numberOfRunningRemoteInterceptors(baseURL: URL) {\n const runningInterceptors = this.class.runningRemoteInterceptors.get(baseURL.origin);\n return runningInterceptors?.size ?? 0;\n }\n\n markLocalInterceptorAsRunning(interceptor: AnyHttpInterceptorClient, isRunning: boolean) {\n if (isRunning) {\n this.class.runningLocalInterceptors.add(interceptor);\n } else {\n this.class.runningLocalInterceptors.delete(interceptor);\n }\n }\n\n markRemoteInterceptorAsRunning(interceptor: AnyHttpInterceptorClient, isRunning: boolean, baseURL: URL) {\n const runningInterceptors =\n this.class.runningRemoteInterceptors.get(baseURL.origin) ?? this.createRunningInterceptorsSet(baseURL);\n\n if (isRunning) {\n runningInterceptors.add(interceptor);\n } else {\n runningInterceptors.delete(interceptor);\n }\n }\n\n private createRunningInterceptorsSet(baseURL: URL) {\n const runningInterceptors = new Set<AnyHttpInterceptorClient>();\n this.class.runningRemoteInterceptors.set(baseURL.origin, runningInterceptors);\n return runningInterceptors;\n }\n\n getOrCreateLocalWorker(workerOptions: Omit<LocalHttpInterceptorWorkerOptions, 'type'>) {\n const existingWorker = this.class._localWorker;\n if (existingWorker) {\n return existingWorker;\n }\n\n const createdWorker = createHttpInterceptorWorker({ ...workerOptions, type: 'local' });\n this.class._localWorker = createdWorker;\n\n return createdWorker;\n }\n\n deleteLocalWorker() {\n this.class._localWorker = undefined;\n }\n\n getOrCreateRemoteWorker(workerOptions: Omit<RemoteHttpInterceptorWorkerOptions, 'type'>) {\n const remoteWorkerKey = this.getRemoteWorkerKey(workerOptions.serverURL, { auth: workerOptions.auth });\n const existingWorker = this.class.remoteWorkers.get(remoteWorkerKey);\n\n if (existingWorker) {\n return existingWorker;\n }\n\n const createdWorker = createHttpInterceptorWorker({ ...workerOptions, type: 'remote' });\n this.class.remoteWorkers.set(remoteWorkerKey, createdWorker);\n\n return createdWorker;\n }\n\n deleteRemoteWorker(baseURL: URL, options: RemoteWorkerKeyOptions) {\n const remoteWorkerKey = this.getRemoteWorkerKey(baseURL, options);\n this.class.remoteWorkers.delete(remoteWorkerKey);\n }\n}\n\nexport default HttpInterceptorStore;\n","import { HttpSchema, HttpSchemaMethod, HttpSchemaPath } from '@zimic/http';\n\nimport LocalHttpRequestHandler from '../requestHandler/LocalHttpRequestHandler';\nimport HttpInterceptorClient from './HttpInterceptorClient';\nimport HttpInterceptorStore from './HttpInterceptorStore';\nimport { SyncHttpInterceptorMethodHandler } from './types/handlers';\nimport { LocalHttpInterceptorOptions, UnhandledRequestStrategy } from './types/options';\nimport { HttpInterceptorRequestSaving, LocalHttpInterceptor as PublicLocalHttpInterceptor } from './types/public';\n\nclass LocalHttpInterceptor<Schema extends HttpSchema> implements PublicLocalHttpInterceptor<Schema> {\n private store = new HttpInterceptorStore();\n\n client: HttpInterceptorClient<Schema, typeof LocalHttpRequestHandler>;\n\n constructor(options: LocalHttpInterceptorOptions) {\n const baseURL = new URL(options.baseURL);\n\n this.client = new HttpInterceptorClient<Schema, typeof LocalHttpRequestHandler>({\n store: this.store,\n baseURL,\n createWorker: () => {\n return this.store.getOrCreateLocalWorker({});\n },\n deleteWorker: () => {\n this.store.deleteLocalWorker();\n },\n Handler: LocalHttpRequestHandler,\n onUnhandledRequest: options.onUnhandledRequest,\n requestSaving: options.requestSaving,\n });\n }\n\n get type() {\n return 'local' as const;\n }\n\n get baseURL() {\n return this.client.baseURLAsString;\n }\n\n set baseURL(baseURL: LocalHttpInterceptorOptions['baseURL']) {\n this.client.baseURL = new URL(baseURL);\n }\n\n get requestSaving() {\n return this.client.requestSaving;\n }\n\n set requestSaving(requestSaving: HttpInterceptorRequestSaving) {\n this.client.requestSaving = requestSaving;\n }\n\n get onUnhandledRequest() {\n return this.client.onUnhandledRequest;\n }\n\n set onUnhandledRequest(onUnhandledRequest: UnhandledRequestStrategy.Local | undefined) {\n this.client.onUnhandledRequest = onUnhandledRequest;\n }\n\n get platform() {\n return this.client.platform;\n }\n\n get isRunning() {\n return this.client.isRunning;\n }\n\n async start() {\n if (this.isRunning) {\n return;\n }\n\n await this.client.start();\n }\n\n async stop() {\n if (!this.isRunning) {\n return;\n }\n\n this.clear();\n await this.client.stop();\n }\n\n get = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.get(path);\n }) as unknown as SyncHttpInterceptorMethodHandler<Schema, 'GET'>;\n\n post = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.post(path);\n }) as unknown as SyncHttpInterceptorMethodHandler<Schema, 'POST'>;\n\n patch = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.patch(path);\n }) as unknown as SyncHttpInterceptorMethodHandler<Schema, 'PATCH'>;\n\n put = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.put(path);\n }) as unknown as SyncHttpInterceptorMethodHandler<Schema, 'PUT'>;\n\n delete = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.delete(path);\n }) as unknown as SyncHttpInterceptorMethodHandler<Schema, 'DELETE'>;\n\n head = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.head(path);\n }) as unknown as SyncHttpInterceptorMethodHandler<Schema, 'HEAD'>;\n\n options = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.options(path);\n }) as unknown as SyncHttpInterceptorMethodHandler<Schema, 'OPTIONS'>;\n\n checkTimes() {\n this.client.checkTimes();\n }\n\n clear() {\n void this.client.clear();\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyLocalHttpInterceptor = LocalHttpInterceptor<any>;\n\nexport default LocalHttpInterceptor;\n","import { HttpSchema, HttpSchemaMethod, HttpSchemaPath } from '@zimic/http';\n\nimport RemoteHttpRequestHandler from '../requestHandler/RemoteHttpRequestHandler';\nimport RunningHttpInterceptorError from './errors/RunningHttpInterceptorError';\nimport HttpInterceptorClient from './HttpInterceptorClient';\nimport HttpInterceptorStore from './HttpInterceptorStore';\nimport { AsyncHttpInterceptorMethodHandler } from './types/handlers';\nimport { RemoteHttpInterceptorOptions, UnhandledRequestStrategy } from './types/options';\nimport { HttpInterceptorRequestSaving, RemoteHttpInterceptor as PublicRemoteHttpInterceptor } from './types/public';\n\nclass RemoteHttpInterceptor<Schema extends HttpSchema> implements PublicRemoteHttpInterceptor<Schema> {\n private store = new HttpInterceptorStore();\n client: HttpInterceptorClient<Schema, typeof RemoteHttpRequestHandler>;\n\n private _auth?: RemoteHttpInterceptorOptions['auth'];\n\n constructor(options: RemoteHttpInterceptorOptions) {\n this._auth = options.auth;\n\n const baseURL = new URL(options.baseURL);\n\n this.client = new HttpInterceptorClient<Schema, typeof RemoteHttpRequestHandler>({\n store: this.store,\n baseURL,\n createWorker: () => {\n return this.store.getOrCreateRemoteWorker({\n serverURL: baseURL,\n auth: this._auth,\n });\n },\n deleteWorker: () => {\n this.store.deleteRemoteWorker(baseURL, { auth: options.auth });\n },\n Handler: RemoteHttpRequestHandler,\n onUnhandledRequest: options.onUnhandledRequest,\n requestSaving: options.requestSaving,\n });\n }\n\n get type() {\n return 'remote' as const;\n }\n\n get baseURL() {\n return this.client.baseURLAsString;\n }\n\n set baseURL(baseURL: string) {\n this.client.baseURL = new URL(baseURL);\n }\n\n get requestSaving() {\n return this.client.requestSaving;\n }\n\n set requestSaving(requestSaving: HttpInterceptorRequestSaving) {\n this.client.requestSaving = requestSaving;\n }\n\n get auth() {\n return this._auth;\n }\n\n set auth(auth: RemoteHttpInterceptorOptions['auth'] | undefined) {\n const cannotChangeAuthWhileRunningMessage =\n 'Did you forget to call `await interceptor.stop()` before changing the authentication parameters?';\n\n if (this.isRunning) {\n throw new RunningHttpInterceptorError(cannotChangeAuthWhileRunningMessage);\n }\n\n if (!auth) {\n this._auth = undefined;\n return;\n }\n\n this._auth = new Proxy(auth, {\n set: (target, property, value) => {\n if (this.isRunning) {\n throw new RunningHttpInterceptorError(cannotChangeAuthWhileRunningMessage);\n }\n return Reflect.set(target, property, value);\n },\n });\n }\n\n get onUnhandledRequest() {\n return this.client.onUnhandledRequest;\n }\n\n set onUnhandledRequest(onUnhandledRequest: UnhandledRequestStrategy.Remote | undefined) {\n this.client.onUnhandledRequest = onUnhandledRequest;\n }\n\n get platform() {\n return this.client.platform;\n }\n\n get isRunning() {\n return this.client.isRunning;\n }\n\n async start() {\n if (this.isRunning) {\n return;\n }\n\n await this.client.start();\n }\n\n async stop() {\n if (!this.isRunning) {\n return;\n }\n\n await this.clear();\n await this.client.stop();\n }\n\n get = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.get(path);\n }) as unknown as AsyncHttpInterceptorMethodHandler<Schema, 'GET'>;\n\n post = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.post(path);\n }) as unknown as AsyncHttpInterceptorMethodHandler<Schema, 'POST'>;\n\n patch = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.patch(path);\n }) as unknown as AsyncHttpInterceptorMethodHandler<Schema, 'PATCH'>;\n\n put = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.put(path);\n }) as unknown as AsyncHttpInterceptorMethodHandler<Schema, 'PUT'>;\n\n delete = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.delete(path);\n }) as unknown as AsyncHttpInterceptorMethodHandler<Schema, 'DELETE'>;\n\n head = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.head(path);\n }) as unknown as AsyncHttpInterceptorMethodHandler<Schema, 'HEAD'>;\n\n options = ((path: HttpSchemaPath<Schema, HttpSchemaMethod<Schema>>) => {\n return this.client.options(path);\n }) as unknown as AsyncHttpInterceptorMethodHandler<Schema, 'OPTIONS'>;\n\n checkTimes() {\n return new Promise<void>((resolve, reject) => {\n try {\n this.client.checkTimes();\n resolve();\n } catch (error) {\n reject(error);\n }\n });\n }\n\n async clear() {\n await this.client.clear();\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyRemoteHttpInterceptor = RemoteHttpInterceptor<any>;\n\nexport default RemoteHttpInterceptor;\n","import { HttpSchema } from '@zimic/http';\n\nimport UnknownHttpInterceptorTypeError from './errors/UnknownHttpInterceptorTypeError';\nimport LocalHttpInterceptor from './LocalHttpInterceptor';\nimport RemoteHttpInterceptor from './RemoteHttpInterceptor';\nimport { HttpInterceptorOptions, LocalHttpInterceptorOptions, RemoteHttpInterceptorOptions } from './types/options';\nimport {\n LocalHttpInterceptor as PublicLocalHttpInterceptor,\n RemoteHttpInterceptor as PublicRemoteHttpInterceptor,\n} from './types/public';\n\nfunction isLocalHttpInterceptorOptions(options: HttpInterceptorOptions): options is LocalHttpInterceptorOptions {\n return options.type === undefined || options.type === 'local';\n}\n\nfunction isRemoteHttpInterceptorOptions(options: HttpInterceptorOptions): options is RemoteHttpInterceptorOptions {\n return options.type === 'remote';\n}\n\n/** @see {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `createHttpInterceptor()` API reference} */\nexport function createHttpInterceptor<Schema extends HttpSchema>(\n options: LocalHttpInterceptorOptions,\n): PublicLocalHttpInterceptor<Schema>;\nexport function createHttpInterceptor<Schema extends HttpSchema>(\n options: RemoteHttpInterceptorOptions,\n): PublicRemoteHttpInterceptor<Schema>;\nexport function createHttpInterceptor<Schema extends HttpSchema>(\n options: HttpInterceptorOptions,\n): PublicLocalHttpInterceptor<Schema> | PublicRemoteHttpInterceptor<Schema>;\nexport function createHttpInterceptor<Schema extends HttpSchema>(\n options: HttpInterceptorOptions,\n): PublicLocalHttpInterceptor<Schema> | PublicRemoteHttpInterceptor<Schema> {\n const type = options.type;\n\n if (isLocalHttpInterceptorOptions(options)) {\n return new LocalHttpInterceptor<Schema>(options);\n } else if (isRemoteHttpInterceptorOptions(options)) {\n return new RemoteHttpInterceptor<Schema>(options);\n }\n\n throw new UnknownHttpInterceptorTypeError(type);\n}\n","import {\n InvalidFormDataError as HttpInvalidFormDataError,\n InvalidJSONError as HttpInvalidJSONError,\n} from '@zimic/http';\n\nexport { default as RunningHttpInterceptorError } from './interceptor/errors/RunningHttpInterceptorError';\nexport { default as NotRunningHttpInterceptorError } from './interceptor/errors/NotRunningHttpInterceptorError';\nexport { default as UnknownHttpInterceptorPlatformError } from './interceptor/errors/UnknownHttpInterceptorPlatformError';\nexport { default as UnknownHttpInterceptorTypeError } from './interceptor/errors/UnknownHttpInterceptorTypeError';\nexport { default as RequestSavingSafeLimitExceededError } from './interceptor/errors/RequestSavingSafeLimitExceededError';\n\nexport { default as UnregisteredBrowserServiceWorkerError } from './interceptorWorker/errors/UnregisteredBrowserServiceWorkerError';\n\nexport { default as DisabledRequestSavingError } from './requestHandler/errors/DisabledRequestSavingError';\nexport { default as TimesCheckError } from './requestHandler/errors/TimesCheckError';\n\nexport type {\n HttpRequestHandlerResponseDeclaration,\n HttpRequestHandlerResponseDeclarationFactory,\n HttpRequestHandlerResponseDelayFactory,\n HttpInterceptorRequest,\n HttpInterceptorResponse,\n InterceptedHttpInterceptorRequest,\n} from './requestHandler/types/requests';\n\nexport type {\n LocalHttpRequestHandler,\n RemoteHttpRequestHandler,\n SyncedRemoteHttpRequestHandler,\n PendingRemoteHttpRequestHandler,\n HttpRequestHandler,\n} from './requestHandler/types/public';\nexport type {\n HttpRequestHandlerRestriction,\n HttpRequestHandlerStaticRestriction,\n HttpRequestHandlerComputedRestriction,\n HttpRequestHandlerHeadersStaticRestriction,\n HttpRequestHandlerSearchParamsStaticRestriction,\n HttpRequestHandlerBodyStaticRestriction,\n} from './requestHandler/types/restrictions';\n\nexport type {\n HttpInterceptorType,\n HttpInterceptorPlatform,\n LocalHttpInterceptorOptions,\n RemoteHttpInterceptorOptions,\n HttpInterceptorOptions,\n UnhandledRequestStrategy,\n} from './interceptor/types/options';\n\nexport type { UnhandledHttpInterceptorRequest } from './interceptor/types/requests';\n\nexport type { InferHttpInterceptorSchema } from './interceptor/types/schema';\n\nexport type { LocalHttpInterceptor, RemoteHttpInterceptor, HttpInterceptor } from './interceptor/types/public';\n\nexport { createHttpInterceptor } from './interceptor/factory';\n\n/**\n * Error thrown when a value is not valid {@link https://developer.mozilla.org/docs/Web/API/FormData FormData}. HTTP\n * interceptors might throw this error when trying to parse the body of a request or response with the header\n * `'content-type': 'multipart/form-data'`, if the content cannot be parsed to form data.\n *\n * @deprecated This type has been moved to {@link https://zimic.dev/docs/http `@zimic/http`}. Please import\n * `InvalidFormDataError` from `@zimic/http` instead.\n *\n * ```ts\n * import { InvalidFormDataError } from '@zimic/http';\n * ```\n */\nexport class InvalidFormDataError extends HttpInvalidFormDataError {}\n\n/**\n * Error thrown when a value is not valid JSON. HTTP interceptors might throw this error when trying to parse the body\n * of a request or response with the header `'content-type': 'application/json'`, if the content cannot be parsed to\n * JSON.\n *\n * @deprecated This type has been moved to {@link https://zimic.dev/docs/http `@zimic/http`}. Please import\n * `InvalidJSONError` from `@zimic/http` instead.\n *\n * ```ts\n * import { InvalidJSONError } from '@zimic/http';\n * ```\n */\nexport class InvalidJSONError extends HttpInvalidJSONError {}\n"]}
|