@zimic/interceptor 1.1.2-canary.2 → 1.1.2-canary.4

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/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../package.json","../src/cli/browser/shared/constants.ts","../src/cli/browser/init.ts","../src/utils/processes.ts","../src/cli/server/start.ts","../src/cli/server/token/create.ts","../src/cli/server/token/list.ts","../src/cli/server/token/remove.ts","../src/cli/cli.ts","../src/cli/index.ts"],"names":["path","__require","fs","logger","color","createCachedDynamicImport_default","createInterceptorServer","exitEvent","createInterceptorToken","listInterceptorTokens","readInterceptorTokenFromFile","removeInterceptorToken","yargs","hideBin","DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBE,IAAA,OAAA,GAAW,gBAAA;;;AChBN,IAAM,wBAAA,GAA2B,sBAAA;;;ACQxC,IAAM,aAAA,GAAgBA,sBAAK,IAAA,CAAKC,0BAAA,CAAQ,QAAQ,KAAK,CAAA,EAAG,IAAA,EAAM,IAAA,EAAM,IAAI,CAAA;AACjE,IAAM,wBAAA,GAA2BD,qBAAA,CAAK,IAAA,CAAK,aAAA,EAAe,OAAO,wBAAwB,CAAA;AAMhG,eAAe,8BAAA,CAA+B,EAAE,eAAA,EAAgB,EAAoC;AAClG,EAAA,MAAME,oBAAG,QAAA,CAAS,KAAA,CAAM,iBAAiB,EAAE,SAAA,EAAW,MAAM,CAAA;AAE5D,EAAA,MAAM,eAAA,GAAkBF,qBAAA,CAAK,IAAA,CAAK,eAAA,EAAiB,wBAAwB,CAAA;AAC3E,EAAA,MAAME,mBAAA,CAAG,QAAA,CAAS,QAAA,CAAS,wBAAA,EAA0B,eAAe,CAAA;AAEpE,EAAAC,uBAAA,CAAO,KAAK,CAAA,+BAAA,EAAkCC,uBAAA,CAAM,OAAA,CAAQ,eAAe,CAAC,CAAA,CAAA,CAAG,CAAA;AACj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A;AAAA;AACH,OACF,CAEC,OAAA;AAAA,QACC,CAAC,MAAM,MAAM,CAAA;AAAA,QACb,yCAAA;AAAA,QACA,CAACF,MAAAA,KACCA,MAAAA,CAAM,MAAA,CAAO,YAAA,EAAc;AAAA,UACzB,IAAA,EAAM,QAAA;AAAA,UACN,WAAA,EAAa,uDAAA;AAAA,UACb,KAAA,EAAO,GAAA;AAAA,UACP,OAAA,EAASE;AAAA,SACV,CAAA;AAAA,QACH,OAAO,YAAA,KAAiB;AACtB,UAAA,MAAM,2BAAA,CAA4B;AAAA,YAChC,iBAAiB,YAAA,CAAa;AAAA,WAC/B,CAAA;AAAA;AACH,OACF,CAEC,OAAA;AAAA,QACC,CAAC,gBAAgB,kBAAkB,CAAA;AAAA,QACnC,8JAAA;AAAA,QAEA,CAACF,MAAAA,KACCA,MAAAA,CACG,UAAA,CAAW,SAAA,EAAW;AAAA,UACrB,IAAA,EAAM,QAAA;AAAA,UACN,WAAA,EAAa,wCAAA;AAAA,UACb,YAAA,EAAc;AAAA,SACf,CAAA,CACA,MAAA,CAAO,YAAA,EAAc;AAAA,UACpB,IAAA,EAAM,QAAA;AAAA,UACN,WAAA,EAAa,uDAAA;AAAA,UACb,KAAA,EAAO,GAAA;AAAA,UACP,OAAA,EAASE;AAAA,SACV,CAAA;AAAA,QACL,OAAO,YAAA,KAAiB;AACtB,UAAA,MAAM,4BAAA,CAA6B;AAAA,YACjC,SAAS,YAAA,CAAa,OAAA;AAAA,YACtB,iBAAiB,YAAA,CAAa;AAAA,WAC/B,CAAA;AAAA;AACH;AACF;AACJ,IAGH,KAAA,EAAM;AACX;AAEA,IAAO,WAAA,GAAQ,MAAA;;;ACjLf,KAAK,WAAA,EAAO","file":"cli.js","sourcesContent":["{\n \"name\": \"@zimic/interceptor\",\n \"description\": \"Next-gen TypeScript-first HTTP intercepting and mocking\",\n \"keywords\": [\n \"zimic\",\n \"typescript\",\n \"types\",\n \"typegen\",\n \"validation\",\n \"inference\",\n \"http\",\n \"interceptor\",\n \"mock\",\n \"api\",\n \"static\"\n ],\n \"version\": \"1.1.2-canary.2\",\n \"homepage\": \"https://zimic.dev/docs/interceptor\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/zimicjs/zimic.git\",\n \"directory\": \"packages/zimic-interceptor\"\n },\n \"author\": {\n \"name\": \"Diego Aquino\",\n \"url\": \"https://github.com/diego-aquino\"\n },\n \"funding\": {\n \"type\": \"github\",\n \"url\": \"https://github.com/sponsors/zimicjs\"\n },\n \"private\": false,\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n },\n \"engines\": {\n \"node\": \">=20.0.0\"\n },\n \"license\": \"MIT\",\n \"files\": [\n \"package.json\",\n \"README.md\",\n \"LICENSE.md\",\n \"src\",\n \"!src/**/tests\",\n \"!src/**/__tests__\",\n \"!src/**/*.test.ts\",\n \"dist\",\n \"index.d.ts\",\n \"http.d.ts\",\n \"server.d.ts\"\n ],\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"index.d.ts\",\n \"bin\": {\n \"zimic-interceptor\": \"./dist/cli.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"default\": \"./dist/index.js\"\n },\n \"./http\": {\n \"types\": \"./http.d.ts\",\n \"import\": \"./dist/http.mjs\",\n \"require\": \"./dist/http.js\",\n \"default\": \"./dist/http.js\"\n },\n \"./server\": {\n \"types\": \"./server.d.ts\",\n \"import\": \"./dist/server.mjs\",\n \"require\": \"./dist/server.js\",\n \"default\": \"./dist/server.js\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"scripts\": {\n \"dev\": \"tsup --watch\",\n \"cli\": \"node --enable-source-maps ./dist/cli.js\",\n \"build\": \"tsup\",\n \"lint\": \"eslint --cache --no-error-on-unmatched-pattern --no-warn-ignored --fix\",\n \"lint:turbo\": \"pnpm lint . --max-warnings 0\",\n \"style\": \"prettier --log-level warn --ignore-unknown --no-error-on-unmatched-pattern --cache\",\n \"style:check\": \"pnpm style --check\",\n \"style:format\": \"pnpm style --write\",\n \"test\": \"dotenv -v NODE_ENV=test -v FORCE_COLOR=1 -- vitest\",\n \"test:turbo\": \"dotenv -v CI=true -- pnpm run test run --coverage\",\n \"types:check\": \"tsc --noEmit\",\n \"deps:install-playwright\": \"playwright install chromium\",\n \"deps:init-msw\": \"msw init ./public --no-save\",\n \"deps:prepare\": \"pnpm deps:install-playwright && pnpm deps:init-msw\",\n \"postinstall\": \"node --enable-source-maps -e \\\"try{require('./dist/scripts/postinstall')}catch(error){console.error(error)}\\\"\"\n },\n \"dependencies\": {\n \"@whatwg-node/server\": \"0.10.12\",\n \"execa\": \"9.6.0\",\n \"isomorphic-ws\": \"5.0.0\",\n \"msw\": \"2.11.1\",\n \"picocolors\": \"^1.1.1\",\n \"ws\": \"8.18.3\",\n \"yargs\": \"18.0.0\",\n \"zod\": \"^4.1.11\"\n },\n \"optionalDependencies\": {\n \"bufferutil\": \"4.0.9\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^24.5.2\",\n \"@types/ws\": \"^8.18.1\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.2.4\",\n \"@vitest/coverage-istanbul\": \"^3.2.4\",\n \"@zimic/eslint-config-node\": \"workspace:*\",\n \"@zimic/lint-staged-config\": \"workspace:*\",\n \"@zimic/tsconfig\": \"workspace:*\",\n \"@zimic/utils\": \"workspace:*\",\n \"dotenv-cli\": \"^10.0.0\",\n \"eslint\": \"^9.36.0\",\n \"playwright\": \"^1.55.0\",\n \"tsup\": \"^8.4.0\",\n \"typescript\": \"^5.9.2\",\n \"vitest\": \"^3.2.4\"\n },\n \"peerDependencies\": {\n \"@zimic/http\": \"^1.1.0 || workspace:*\",\n \"typescript\": \">=5.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"typescript\": {\n \"optional\": true\n }\n }\n}\n","export const SERVICE_WORKER_FILE_NAME = 'mockServiceWorker.js';\n","import fs from 'fs';\nimport path from 'path';\nimport color from 'picocolors';\n\nimport { logger } from '@/utils/logging';\n\nimport { SERVICE_WORKER_FILE_NAME } from './shared/constants';\n\nconst MSW_ROOT_PATH = path.join(require.resolve('msw'), '..', '..', '..');\nexport const MOCK_SERVICE_WORKER_PATH = path.join(MSW_ROOT_PATH, 'lib', SERVICE_WORKER_FILE_NAME);\n\ninterface BrowserServiceWorkerInitOptions {\n publicDirectory: string;\n}\n\nasync function initializeBrowserServiceWorker({ publicDirectory }: BrowserServiceWorkerInitOptions) {\n await fs.promises.mkdir(publicDirectory, { recursive: true });\n\n const destinationPath = path.join(publicDirectory, SERVICE_WORKER_FILE_NAME);\n await fs.promises.copyFile(MOCK_SERVICE_WORKER_PATH, destinationPath);\n\n logger.info(`Service worker script saved to ${color.magenta(destinationPath)}.`);\n}\n\nexport default initializeBrowserServiceWorker;\n","import createCachedDynamicImport from '@zimic/utils/import/createCachedDynamicImport';\n\nexport const PROCESS_EXIT_EVENTS = Object.freeze([\n 'beforeExit',\n 'uncaughtExceptionMonitor',\n 'SIGINT',\n 'SIGTERM',\n 'SIGHUP',\n 'SIGBREAK',\n] as const);\n\nexport type ProcessExitEvent = (typeof PROCESS_EXIT_EVENTS)[number];\n\n// Having an undefined exit code means that the process will already exit with the default exit code.\nexport const PROCESS_EXIT_CODE_BY_EXIT_EVENT: Record<string, number | undefined> = {\n beforeExit: undefined,\n uncaughtExceptionMonitor: undefined,\n SIGINT: 130,\n SIGTERM: 143,\n SIGHUP: 129,\n SIGBREAK: 131,\n} satisfies Record<ProcessExitEvent, number | undefined>;\n\nexport const importExeca = createCachedDynamicImport(() => import('execa'));\n\ninterface CommandErrorOptions {\n command?: string[];\n exitCode?: number;\n signal?: NodeJS.Signals;\n originalMessage?: string;\n}\n\nexport class CommandError extends Error {\n static readonly DEFAULT_EXIT_CODE = 1;\n\n readonly command: string[];\n readonly exitCode: number;\n readonly signal?: NodeJS.Signals;\n\n constructor(executable: string, options: CommandErrorOptions) {\n const message = CommandError.createMessage(executable, options);\n super(message);\n\n this.name = 'CommandError';\n this.command = options.command ?? [executable];\n this.exitCode = this.getExitCode(options);\n this.signal = options.signal;\n }\n\n private getExitCode(options: CommandErrorOptions): number {\n const existingExitCode = options.exitCode;\n const exitCodeInferredFromSignal =\n options.signal === undefined ? undefined : PROCESS_EXIT_CODE_BY_EXIT_EVENT[options.signal];\n\n return existingExitCode ?? exitCodeInferredFromSignal ?? CommandError.DEFAULT_EXIT_CODE;\n }\n\n private static createMessage(command: string, options: CommandErrorOptions) {\n const suffix = options.originalMessage ? `: ${options.originalMessage}` : '';\n\n if (options.exitCode === undefined && options.signal === undefined) {\n return `Command '${command}' failed${suffix}`;\n }\n\n const prefix = `Command '${command}' exited `;\n const infix = options.exitCode === undefined ? `after signal ${options.signal}` : `with code ${options.exitCode}`;\n\n return `${prefix}${infix}${suffix}`;\n }\n}\n\nexport async function runCommand(commandEntry: string, commandArguments: string[]) {\n const { execa: $, ExecaError } = await importExeca();\n\n try {\n await $(commandEntry, commandArguments, { stdio: 'inherit' });\n } catch (error) {\n /* istanbul ignore if -- @preserve\n * This is a safeguard if the error is not an ExecaError. It is not expected to run. */\n if (!(error instanceof ExecaError)) {\n throw error;\n }\n\n const commandError = new CommandError(commandEntry, {\n command: [commandEntry, ...commandArguments],\n exitCode: error.exitCode,\n signal: error.signal,\n originalMessage: error.originalMessage,\n });\n\n throw commandError;\n }\n}\n","import color from 'picocolors';\n\nimport { InterceptorServer, createInterceptorServer } from '@/server';\nimport { InterceptorServerOptions } from '@/server/types/options';\nimport { logger } from '@/utils/logging';\nimport {\n CommandError,\n PROCESS_EXIT_CODE_BY_EXIT_EVENT,\n PROCESS_EXIT_EVENTS,\n ProcessExitEvent,\n runCommand,\n} from '@/utils/processes';\n\ninterface InterceptorServerStartOptions extends InterceptorServerOptions {\n ephemeral: boolean;\n onReady?: { command: string; arguments: string[] };\n}\n\nexport let serverSingleton: InterceptorServer | undefined;\n\nasync function startInterceptorServer({\n hostname,\n port,\n logUnhandledRequests,\n tokensDirectory,\n ephemeral,\n onReady,\n}: InterceptorServerStartOptions) {\n const server = createInterceptorServer({\n hostname,\n port,\n logUnhandledRequests,\n tokensDirectory,\n });\n\n async function handleExitEvent(exitEvent: ProcessExitEvent | undefined) {\n await server.stop();\n\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n for (const { exitEvent, exitHandler } of exitHandlerGroups) {\n process.off(exitEvent, exitHandler);\n }\n\n const exitCode = exitEvent ? PROCESS_EXIT_CODE_BY_EXIT_EVENT[exitEvent] : undefined;\n if (exitCode !== undefined) {\n process.exit(exitCode);\n }\n }\n\n const exitHandlerGroups = PROCESS_EXIT_EVENTS.map((exitEvent) => ({\n exitEvent,\n exitHandler: handleExitEvent.bind(null, exitEvent),\n }));\n\n for (const { exitEvent, exitHandler } of exitHandlerGroups) {\n process.on(exitEvent, exitHandler);\n }\n\n serverSingleton = server;\n\n await server.start();\n\n logger.info(\n `${ephemeral ? 'Ephemeral s' : 'S'}erver is running on ${color.yellow(`${server.hostname}:${server.port}`)}`,\n );\n\n const isDangerouslyUnprotected = !tokensDirectory && process.env.NODE_ENV === 'production';\n\n if (isDangerouslyUnprotected) {\n logger.warn(\n [\n `Attention: this interceptor server is ${color.bold(color.red('unprotected'))}. Do not expose it publicly without authentication.`,\n '',\n 'Learn more: https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#interceptor-server-authentication',\n ].join('\\n'),\n );\n }\n\n if (onReady) {\n try {\n await runCommand(onReady.command, onReady.arguments);\n } catch (error) {\n console.error(error);\n\n /* istanbul ignore if -- @preserve\n * A CommandError is always expected here. */\n if (!(error instanceof CommandError)) {\n throw error;\n }\n\n process.exit(error.exitCode);\n }\n }\n\n if (ephemeral) {\n await handleExitEvent(undefined);\n process.exit(0);\n }\n}\n\nexport default startInterceptorServer;\n","import color from 'picocolors';\n\nimport { createInterceptorToken } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerCreateTokenOptions {\n tokenName?: string;\n tokensDirectory: string;\n}\n\nexport async function createInterceptorServerToken({\n tokenName,\n tokensDirectory,\n}: InterceptorServerCreateTokenOptions) {\n const token = await createInterceptorToken({ name: tokenName, tokensDirectory });\n\n logger.info(\n [\n `${color.green(color.bold('✔'))} Token${tokenName ? ` ${color.green(tokenName)}` : ''} created:`,\n '',\n color.yellow(token.value),\n '',\n 'Store this token securely. It cannot be retrieved later.',\n '',\n `To enable authentication in your interceptor server, use the ${color.cyan('--tokens-dir')} option. Only ` +\n 'remote interceptors bearing a valid token will be allowed to connect.',\n '',\n `${color.dim('$')} zimic-interceptor server start ${color.cyan('--tokens-dir')} ${color.magenta(tokensDirectory)}`,\n '',\n 'Learn more: https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#interceptor-server-authentication',\n ].join('\\n'),\n );\n}\n","import { listInterceptorTokens } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerListTokensOptions {\n tokensDirectory: string;\n}\n\nexport async function listInterceptorServerTokens({ tokensDirectory }: InterceptorServerListTokensOptions) {\n const tokens = await listInterceptorTokens({ tokensDirectory });\n\n logger.raw.table(\n [\n { title: 'ID', property: 'id' },\n { title: 'NAME', property: 'name' },\n { title: 'CREATED AT', property: 'createdAt' },\n ],\n tokens.map((token) => ({\n id: token.id,\n name: token.name ?? '',\n createdAt: token.createdAt.toISOString(),\n })),\n );\n}\n","import color from 'picocolors';\n\nimport { readInterceptorTokenFromFile, removeInterceptorToken } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerCreateTokenOptions {\n tokenId: string;\n tokensDirectory: string;\n}\n\nexport async function removeInterceptorServerToken({ tokenId, tokensDirectory }: InterceptorServerCreateTokenOptions) {\n const token = await readInterceptorTokenFromFile(tokenId, { tokensDirectory });\n\n if (!token) {\n logger.error(`${color.red(color.bold('✘'))} Token ${color.red(tokenId)} not found.`);\n process.exit(1);\n }\n\n await removeInterceptorToken(token.id, { tokensDirectory });\n\n logger.info(`${color.green(color.bold('✔'))} Token ${color.green(token.name ?? token.id)} removed.`);\n}\n","import yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport { version } from '@@/package.json';\n\nimport { DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY } from '../server/utils/auth';\nimport initializeBrowserServiceWorker from './browser/init';\nimport startInterceptorServer from './server/start';\nimport { createInterceptorServerToken } from './server/token/create';\nimport { listInterceptorServerTokens } from './server/token/list';\nimport { removeInterceptorServerToken } from './server/token/remove';\n\nasync function runCLI() {\n await yargs(hideBin(process.argv))\n .scriptName('zimic-interceptor')\n .version(version)\n .showHelpOnFail(false)\n .strict()\n\n .command('browser', 'Manage your browser mock configuration.', (yargs) =>\n yargs.demandCommand().command(\n 'init <publicDirectory>',\n 'Initialize the browser service worker configuration.',\n (yargs) =>\n yargs.positional('publicDirectory', {\n type: 'string',\n description: 'The path to the public directory of your application.',\n demandOption: true,\n }),\n async (cliArguments) => {\n await initializeBrowserServiceWorker({\n publicDirectory: cliArguments.publicDirectory,\n });\n },\n ),\n )\n\n .command('server', 'Manage interceptor servers.', (yargs) =>\n yargs\n .demandCommand()\n .command(\n 'start [-- onReady]',\n 'Start an interceptor server.',\n (yargs) =>\n yargs\n .positional('onReady', {\n description: 'A command to run when the server is ready to accept connections.',\n type: 'string',\n })\n .option('hostname', {\n type: 'string',\n description: 'The hostname to start the server on.',\n alias: 'h',\n default: 'localhost',\n })\n .option('port', {\n type: 'number',\n description: 'The port to start the server on.',\n alias: 'p',\n })\n .option('ephemeral', {\n type: 'boolean',\n description:\n 'Whether the server should stop automatically after the on-ready command finishes. ' +\n 'If no on-ready command is provided and ephemeral is true, the server will stop immediately after ' +\n 'starting.',\n alias: 'e',\n default: false,\n })\n .option('log-unhandled-requests', {\n type: 'boolean',\n description:\n 'Whether to log a warning when no interceptors were found for the base URL of a request. ' +\n 'If an interceptor was matched, the logging behavior for that base URL is configured in the ' +\n 'interceptor itself.',\n alias: 'l',\n })\n .option('tokens-dir', {\n type: 'string',\n description:\n 'The directory where the authorized interceptor authentication tokens are saved. If provided, only ' +\n 'remote interceptors bearing a valid token will be accepted. This option is essential if you are ' +\n 'exposing your interceptor server publicly. For local development and testing, though, ' +\n '`--tokens-dir` is optional.',\n alias: 't',\n }),\n async (cliArguments) => {\n const onReadyCommand = cliArguments._.at(2)?.toString();\n const onReadyCommandArguments = cliArguments._.slice(3).map((argument) => argument.toString());\n\n await startInterceptorServer({\n hostname: cliArguments.hostname,\n port: cliArguments.port,\n ephemeral: cliArguments.ephemeral,\n logUnhandledRequests: cliArguments.logUnhandledRequests,\n tokensDirectory: cliArguments.tokensDir,\n onReady: onReadyCommand\n ? {\n command: onReadyCommand.toString(),\n arguments: onReadyCommandArguments,\n }\n : undefined,\n });\n },\n )\n\n .command('token', 'Manage remote interceptor authentication tokens.', (yargs) =>\n yargs\n .demandCommand()\n .command(\n 'create',\n 'Create an interceptor token.',\n (yargs) =>\n yargs\n .option('name', {\n type: 'string',\n description: 'The name of the token to create.',\n alias: 'n',\n })\n .option('tokens-dir', {\n type: 'string',\n description: 'The directory where the created interceptor token will be saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await createInterceptorServerToken({\n tokenName: cliArguments.name,\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n )\n\n .command(\n ['ls', 'list'],\n 'List the authorized interceptor tokens.',\n (yargs) =>\n yargs.option('tokens-dir', {\n type: 'string',\n description: 'The directory where the interceptor tokens are saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await listInterceptorServerTokens({\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n )\n\n .command(\n ['rm <tokenId>', 'remove <tokenId>'],\n 'Remove (invalidate) an interceptor token. Existing connections will not be affected, so restarting the ' +\n 'server is recommended to disconnect all interceptors.',\n (yargs) =>\n yargs\n .positional('tokenId', {\n type: 'string',\n description: 'The identifier of the token to remove.',\n demandOption: true,\n })\n .option('tokens-dir', {\n type: 'string',\n description: 'The directory where the interceptor tokens are saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await removeInterceptorServerToken({\n tokenId: cliArguments.tokenId,\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n ),\n ),\n )\n\n .parse();\n}\n\nexport default runCLI;\n","#!/usr/bin/env node\nimport runCLI from './cli';\n\nvoid runCLI();\n"]}
1
+ {"version":3,"sources":["../package.json","../src/cli/browser/shared/constants.ts","../src/cli/browser/init.ts","../src/utils/processes.ts","../src/cli/server/start.ts","../src/cli/server/token/create.ts","../src/cli/server/token/list.ts","../src/cli/server/token/remove.ts","../src/cli/cli.ts","../src/cli/index.ts"],"names":["path","__require","fs","logger","color","createCachedDynamicImport_default","createInterceptorServer","exitEvent","createInterceptorToken","listInterceptorTokens","readInterceptorTokenFromFile","removeInterceptorToken","yargs","hideBin","DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBE,IAAA,OAAA,GAAW,gBAAA;;;AChBN,IAAM,wBAAA,GAA2B,sBAAA;;;ACQxC,IAAM,aAAA,GAAgBA,sBAAK,IAAA,CAAKC,0BAAA,CAAQ,QAAQ,KAAK,CAAA,EAAG,IAAA,EAAM,IAAA,EAAM,IAAI,CAAA;AACjE,IAAM,wBAAA,GAA2BD,qBAAA,CAAK,IAAA,CAAK,aAAA,EAAe,OAAO,wBAAwB,CAAA;AAMhG,eAAe,8BAAA,CAA+B,EAAE,eAAA,EAAgB,EAAoC;AAClG,EAAA,MAAME,oBAAG,QAAA,CAAS,KAAA,CAAM,iBAAiB,EAAE,SAAA,EAAW,MAAM,CAAA;AAE5D,EAAA,MAAM,eAAA,GAAkBF,qBAAA,CAAK,IAAA,CAAK,eAAA,EAAiB,wBAAwB,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Q,MAAA;;;ACjLf,KAAK,WAAA,EAAO","file":"cli.js","sourcesContent":["{\n \"name\": \"@zimic/interceptor\",\n \"description\": \"Next-gen TypeScript-first HTTP intercepting and mocking\",\n \"keywords\": [\n \"zimic\",\n \"typescript\",\n \"types\",\n \"typegen\",\n \"validation\",\n \"inference\",\n \"http\",\n \"interceptor\",\n \"mock\",\n \"api\",\n \"static\"\n ],\n \"version\": \"1.1.2-canary.4\",\n \"homepage\": \"https://zimic.dev/docs/interceptor\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/zimicjs/zimic.git\",\n \"directory\": \"packages/zimic-interceptor\"\n },\n \"author\": {\n \"name\": \"Diego Aquino\",\n \"url\": \"https://github.com/diego-aquino\"\n },\n \"funding\": {\n \"type\": \"github\",\n \"url\": \"https://github.com/sponsors/zimicjs\"\n },\n \"private\": false,\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n },\n \"engines\": {\n \"node\": \">=20.0.0\"\n },\n \"license\": \"MIT\",\n \"files\": [\n \"package.json\",\n \"README.md\",\n \"LICENSE.md\",\n \"src\",\n \"!src/**/tests\",\n \"!src/**/__tests__\",\n \"!src/**/*.test.ts\",\n \"dist\",\n \"index.d.ts\",\n \"http.d.ts\",\n \"server.d.ts\"\n ],\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"index.d.ts\",\n \"bin\": {\n \"zimic-interceptor\": \"./dist/cli.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"default\": \"./dist/index.js\"\n },\n \"./http\": {\n \"types\": \"./http.d.ts\",\n \"import\": \"./dist/http.mjs\",\n \"require\": \"./dist/http.js\",\n \"default\": \"./dist/http.js\"\n },\n \"./server\": {\n \"types\": \"./server.d.ts\",\n \"import\": \"./dist/server.mjs\",\n \"require\": \"./dist/server.js\",\n \"default\": \"./dist/server.js\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"scripts\": {\n \"dev\": \"tsup --watch\",\n \"cli\": \"node --enable-source-maps ./dist/cli.js\",\n \"build\": \"tsup\",\n \"lint\": \"eslint --cache --no-error-on-unmatched-pattern --no-warn-ignored --fix\",\n \"lint:turbo\": \"pnpm lint . --max-warnings 0\",\n \"style\": \"prettier --log-level warn --ignore-unknown --no-error-on-unmatched-pattern --cache\",\n \"style:check\": \"pnpm style --check\",\n \"style:format\": \"pnpm style --write\",\n \"test\": \"dotenv -v NODE_ENV=test -v FORCE_COLOR=1 -- vitest\",\n \"test:turbo\": \"dotenv -v CI=true -- pnpm run test run --coverage\",\n \"types:check\": \"tsc --noEmit\",\n \"deps:install-playwright\": \"playwright install chromium\",\n \"deps:init-msw\": \"msw init ./public --no-save\",\n \"deps:prepare\": \"pnpm deps:install-playwright && pnpm deps:init-msw\",\n \"postinstall\": \"node --enable-source-maps -e \\\"try{require('./dist/scripts/postinstall')}catch(error){console.error(error)}\\\"\"\n },\n \"dependencies\": {\n \"@whatwg-node/server\": \"0.10.12\",\n \"execa\": \"9.6.0\",\n \"isomorphic-ws\": \"5.0.0\",\n \"msw\": \"2.11.1\",\n \"picocolors\": \"^1.1.1\",\n \"ws\": \"8.18.3\",\n \"yargs\": \"18.0.0\",\n \"zod\": \"^4.1.11\"\n },\n \"optionalDependencies\": {\n \"bufferutil\": \"4.0.9\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^24.5.2\",\n \"@types/ws\": \"^8.18.1\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.2.4\",\n \"@vitest/coverage-istanbul\": \"^3.2.4\",\n \"@zimic/eslint-config-node\": \"workspace:*\",\n \"@zimic/lint-staged-config\": \"workspace:*\",\n \"@zimic/tsconfig\": \"workspace:*\",\n \"@zimic/utils\": \"workspace:*\",\n \"dotenv-cli\": \"^10.0.0\",\n \"eslint\": \"^9.36.0\",\n \"playwright\": \"^1.55.0\",\n \"tsup\": \"^8.4.0\",\n \"typescript\": \"^5.9.2\",\n \"vitest\": \"^3.2.4\"\n },\n \"peerDependencies\": {\n \"@zimic/http\": \"^1.1.0 || workspace:*\",\n \"typescript\": \">=5.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"typescript\": {\n \"optional\": true\n }\n }\n}\n","export const SERVICE_WORKER_FILE_NAME = 'mockServiceWorker.js';\n","import fs from 'fs';\nimport path from 'path';\nimport color from 'picocolors';\n\nimport { logger } from '@/utils/logging';\n\nimport { SERVICE_WORKER_FILE_NAME } from './shared/constants';\n\nconst MSW_ROOT_PATH = path.join(require.resolve('msw'), '..', '..', '..');\nexport const MOCK_SERVICE_WORKER_PATH = path.join(MSW_ROOT_PATH, 'lib', SERVICE_WORKER_FILE_NAME);\n\ninterface BrowserServiceWorkerInitOptions {\n publicDirectory: string;\n}\n\nasync function initializeBrowserServiceWorker({ publicDirectory }: BrowserServiceWorkerInitOptions) {\n await fs.promises.mkdir(publicDirectory, { recursive: true });\n\n const destinationPath = path.join(publicDirectory, SERVICE_WORKER_FILE_NAME);\n await fs.promises.copyFile(MOCK_SERVICE_WORKER_PATH, destinationPath);\n\n logger.info(`Service worker script saved to ${color.magenta(destinationPath)}.`);\n}\n\nexport default initializeBrowserServiceWorker;\n","import createCachedDynamicImport from '@zimic/utils/import/createCachedDynamicImport';\n\nexport const PROCESS_EXIT_EVENTS = Object.freeze([\n 'beforeExit',\n 'uncaughtExceptionMonitor',\n 'SIGINT',\n 'SIGTERM',\n 'SIGHUP',\n 'SIGBREAK',\n] as const);\n\nexport type ProcessExitEvent = (typeof PROCESS_EXIT_EVENTS)[number];\n\n// Having an undefined exit code means that the process will already exit with the default exit code.\nexport const PROCESS_EXIT_CODE_BY_EXIT_EVENT: Record<string, number | undefined> = {\n beforeExit: undefined,\n uncaughtExceptionMonitor: undefined,\n SIGINT: 130,\n SIGTERM: 143,\n SIGHUP: 129,\n SIGBREAK: 131,\n} satisfies Record<ProcessExitEvent, number | undefined>;\n\nexport const importExeca = createCachedDynamicImport(() => import('execa'));\n\ninterface CommandErrorOptions {\n command?: string[];\n exitCode?: number;\n signal?: NodeJS.Signals;\n originalMessage?: string;\n}\n\nexport class CommandError extends Error {\n static readonly DEFAULT_EXIT_CODE = 1;\n\n readonly command: string[];\n readonly exitCode: number;\n readonly signal?: NodeJS.Signals;\n\n constructor(executable: string, options: CommandErrorOptions) {\n const message = CommandError.createMessage(executable, options);\n super(message);\n\n this.name = 'CommandError';\n this.command = options.command ?? [executable];\n this.exitCode = this.getExitCode(options);\n this.signal = options.signal;\n }\n\n private getExitCode(options: CommandErrorOptions): number {\n const existingExitCode = options.exitCode;\n const exitCodeInferredFromSignal =\n options.signal === undefined ? undefined : PROCESS_EXIT_CODE_BY_EXIT_EVENT[options.signal];\n\n return existingExitCode ?? exitCodeInferredFromSignal ?? CommandError.DEFAULT_EXIT_CODE;\n }\n\n private static createMessage(command: string, options: CommandErrorOptions) {\n const suffix = options.originalMessage ? `: ${options.originalMessage}` : '';\n\n if (options.exitCode === undefined && options.signal === undefined) {\n return `Command '${command}' failed${suffix}`;\n }\n\n const prefix = `Command '${command}' exited `;\n const infix = options.exitCode === undefined ? `after signal ${options.signal}` : `with code ${options.exitCode}`;\n\n return `${prefix}${infix}${suffix}`;\n }\n}\n\nexport async function runCommand(commandEntry: string, commandArguments: string[]) {\n const { execa: $, ExecaError } = await importExeca();\n\n try {\n await $(commandEntry, commandArguments, { stdio: 'inherit' });\n } catch (error) {\n /* istanbul ignore if -- @preserve\n * This is a safeguard if the error is not an ExecaError. It is not expected to run. */\n if (!(error instanceof ExecaError)) {\n throw error;\n }\n\n const commandError = new CommandError(commandEntry, {\n command: [commandEntry, ...commandArguments],\n exitCode: error.exitCode,\n signal: error.signal,\n originalMessage: error.originalMessage,\n });\n\n throw commandError;\n }\n}\n","import color from 'picocolors';\n\nimport { InterceptorServer, createInterceptorServer } from '@/server';\nimport { InterceptorServerOptions } from '@/server/types/options';\nimport { logger } from '@/utils/logging';\nimport {\n CommandError,\n PROCESS_EXIT_CODE_BY_EXIT_EVENT,\n PROCESS_EXIT_EVENTS,\n ProcessExitEvent,\n runCommand,\n} from '@/utils/processes';\n\ninterface InterceptorServerStartOptions extends InterceptorServerOptions {\n ephemeral: boolean;\n onReady?: { command: string; arguments: string[] };\n}\n\nexport let serverSingleton: InterceptorServer | undefined;\n\nasync function startInterceptorServer({\n hostname,\n port,\n logUnhandledRequests,\n tokensDirectory,\n ephemeral,\n onReady,\n}: InterceptorServerStartOptions) {\n const server = createInterceptorServer({\n hostname,\n port,\n logUnhandledRequests,\n tokensDirectory,\n });\n\n async function handleExitEvent(exitEvent: ProcessExitEvent | undefined) {\n await server.stop();\n\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n for (const { exitEvent, exitHandler } of exitHandlerGroups) {\n process.off(exitEvent, exitHandler);\n }\n\n const exitCode = exitEvent ? PROCESS_EXIT_CODE_BY_EXIT_EVENT[exitEvent] : undefined;\n if (exitCode !== undefined) {\n process.exit(exitCode);\n }\n }\n\n const exitHandlerGroups = PROCESS_EXIT_EVENTS.map((exitEvent) => ({\n exitEvent,\n exitHandler: handleExitEvent.bind(null, exitEvent),\n }));\n\n for (const { exitEvent, exitHandler } of exitHandlerGroups) {\n process.on(exitEvent, exitHandler);\n }\n\n serverSingleton = server;\n\n await server.start();\n\n logger.info(\n `${ephemeral ? 'Ephemeral s' : 'S'}erver is running on ${color.yellow(`${server.hostname}:${server.port}`)}`,\n );\n\n const isDangerouslyUnprotected = !tokensDirectory && process.env.NODE_ENV === 'production';\n\n if (isDangerouslyUnprotected) {\n logger.warn(\n [\n `Attention: this interceptor server is ${color.bold(color.red('unprotected'))}. Do not expose it publicly without authentication.`,\n '',\n 'Learn more: https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#interceptor-server-authentication',\n ].join('\\n'),\n );\n }\n\n if (onReady) {\n try {\n await runCommand(onReady.command, onReady.arguments);\n } catch (error) {\n console.error(error);\n\n /* istanbul ignore if -- @preserve\n * A CommandError is always expected here. */\n if (!(error instanceof CommandError)) {\n throw error;\n }\n\n process.exit(error.exitCode);\n }\n }\n\n if (ephemeral) {\n await handleExitEvent(undefined);\n process.exit(0);\n }\n}\n\nexport default startInterceptorServer;\n","import color from 'picocolors';\n\nimport { createInterceptorToken } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerCreateTokenOptions {\n tokenName?: string;\n tokensDirectory: string;\n}\n\nexport async function createInterceptorServerToken({\n tokenName,\n tokensDirectory,\n}: InterceptorServerCreateTokenOptions) {\n const token = await createInterceptorToken({ name: tokenName, tokensDirectory });\n\n logger.info(\n [\n `${color.green(color.bold('✔'))} Token${tokenName ? ` ${color.green(tokenName)}` : ''} created:`,\n '',\n color.yellow(token.value),\n '',\n 'Store this token securely. It cannot be retrieved later.',\n '',\n `To enable authentication in your interceptor server, use the ${color.cyan('--tokens-dir')} option. Only ` +\n 'remote interceptors bearing a valid token will be allowed to connect.',\n '',\n `${color.dim('$')} zimic-interceptor server start ${color.cyan('--tokens-dir')} ${color.magenta(tokensDirectory)}`,\n '',\n 'Learn more: https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#interceptor-server-authentication',\n ].join('\\n'),\n );\n}\n","import { listInterceptorTokens } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerListTokensOptions {\n tokensDirectory: string;\n}\n\nexport async function listInterceptorServerTokens({ tokensDirectory }: InterceptorServerListTokensOptions) {\n const tokens = await listInterceptorTokens({ tokensDirectory });\n\n logger.raw.table(\n [\n { title: 'ID', property: 'id' },\n { title: 'NAME', property: 'name' },\n { title: 'CREATED AT', property: 'createdAt' },\n ],\n tokens.map((token) => ({\n id: token.id,\n name: token.name ?? '',\n createdAt: token.createdAt.toISOString(),\n })),\n );\n}\n","import color from 'picocolors';\n\nimport { readInterceptorTokenFromFile, removeInterceptorToken } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerCreateTokenOptions {\n tokenId: string;\n tokensDirectory: string;\n}\n\nexport async function removeInterceptorServerToken({ tokenId, tokensDirectory }: InterceptorServerCreateTokenOptions) {\n const token = await readInterceptorTokenFromFile(tokenId, { tokensDirectory });\n\n if (!token) {\n logger.error(`${color.red(color.bold('✘'))} Token ${color.red(tokenId)} not found.`);\n process.exit(1);\n }\n\n await removeInterceptorToken(token.id, { tokensDirectory });\n\n logger.info(`${color.green(color.bold('✔'))} Token ${color.green(token.name ?? token.id)} removed.`);\n}\n","import yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport { version } from '@@/package.json';\n\nimport { DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY } from '../server/utils/auth';\nimport initializeBrowserServiceWorker from './browser/init';\nimport startInterceptorServer from './server/start';\nimport { createInterceptorServerToken } from './server/token/create';\nimport { listInterceptorServerTokens } from './server/token/list';\nimport { removeInterceptorServerToken } from './server/token/remove';\n\nasync function runCLI() {\n await yargs(hideBin(process.argv))\n .scriptName('zimic-interceptor')\n .version(version)\n .showHelpOnFail(false)\n .strict()\n\n .command('browser', 'Manage your browser mock configuration.', (yargs) =>\n yargs.demandCommand().command(\n 'init <publicDirectory>',\n 'Initialize the browser service worker configuration.',\n (yargs) =>\n yargs.positional('publicDirectory', {\n type: 'string',\n description: 'The path to the public directory of your application.',\n demandOption: true,\n }),\n async (cliArguments) => {\n await initializeBrowserServiceWorker({\n publicDirectory: cliArguments.publicDirectory,\n });\n },\n ),\n )\n\n .command('server', 'Manage interceptor servers.', (yargs) =>\n yargs\n .demandCommand()\n .command(\n 'start [-- onReady]',\n 'Start an interceptor server.',\n (yargs) =>\n yargs\n .positional('onReady', {\n description: 'A command to run when the server is ready to accept connections.',\n type: 'string',\n })\n .option('hostname', {\n type: 'string',\n description: 'The hostname to start the server on.',\n alias: 'h',\n default: 'localhost',\n })\n .option('port', {\n type: 'number',\n description: 'The port to start the server on.',\n alias: 'p',\n })\n .option('ephemeral', {\n type: 'boolean',\n description:\n 'Whether the server should stop automatically after the on-ready command finishes. ' +\n 'If no on-ready command is provided and ephemeral is true, the server will stop immediately after ' +\n 'starting.',\n alias: 'e',\n default: false,\n })\n .option('log-unhandled-requests', {\n type: 'boolean',\n description:\n 'Whether to log a warning when no interceptors were found for the base URL of a request. ' +\n 'If an interceptor was matched, the logging behavior for that base URL is configured in the ' +\n 'interceptor itself.',\n alias: 'l',\n })\n .option('tokens-dir', {\n type: 'string',\n description:\n 'The directory where the authorized interceptor authentication tokens are saved. If provided, only ' +\n 'remote interceptors bearing a valid token will be accepted. This option is essential if you are ' +\n 'exposing your interceptor server publicly. For local development and testing, though, ' +\n '`--tokens-dir` is optional.',\n alias: 't',\n }),\n async (cliArguments) => {\n const onReadyCommand = cliArguments._.at(2)?.toString();\n const onReadyCommandArguments = cliArguments._.slice(3).map((argument) => argument.toString());\n\n await startInterceptorServer({\n hostname: cliArguments.hostname,\n port: cliArguments.port,\n ephemeral: cliArguments.ephemeral,\n logUnhandledRequests: cliArguments.logUnhandledRequests,\n tokensDirectory: cliArguments.tokensDir,\n onReady: onReadyCommand\n ? {\n command: onReadyCommand.toString(),\n arguments: onReadyCommandArguments,\n }\n : undefined,\n });\n },\n )\n\n .command('token', 'Manage remote interceptor authentication tokens.', (yargs) =>\n yargs\n .demandCommand()\n .command(\n 'create',\n 'Create an interceptor token.',\n (yargs) =>\n yargs\n .option('name', {\n type: 'string',\n description: 'The name of the token to create.',\n alias: 'n',\n })\n .option('tokens-dir', {\n type: 'string',\n description: 'The directory where the created interceptor token will be saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await createInterceptorServerToken({\n tokenName: cliArguments.name,\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n )\n\n .command(\n ['ls', 'list'],\n 'List the authorized interceptor tokens.',\n (yargs) =>\n yargs.option('tokens-dir', {\n type: 'string',\n description: 'The directory where the interceptor tokens are saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await listInterceptorServerTokens({\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n )\n\n .command(\n ['rm <tokenId>', 'remove <tokenId>'],\n 'Remove (invalidate) an interceptor token. Existing connections will not be affected, so restarting the ' +\n 'server is recommended to disconnect all interceptors.',\n (yargs) =>\n yargs\n .positional('tokenId', {\n type: 'string',\n description: 'The identifier of the token to remove.',\n demandOption: true,\n })\n .option('tokens-dir', {\n type: 'string',\n description: 'The directory where the interceptor tokens are saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await removeInterceptorServerToken({\n tokenId: cliArguments.tokenId,\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n ),\n ),\n )\n\n .parse();\n}\n\nexport default runCLI;\n","#!/usr/bin/env node\nimport runCLI from './cli';\n\nvoid runCLI();\n"]}
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { createCachedDynamicImport_default, DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY, logger, createInterceptorServer, createInterceptorToken, listInterceptorTokens, readInterceptorTokenFromFile, removeInterceptorToken } from './chunk-CSKTIZSC.mjs';
2
+ import { createCachedDynamicImport_default, DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY, logger, createInterceptorServer, createInterceptorToken, listInterceptorTokens, readInterceptorTokenFromFile, removeInterceptorToken } from './chunk-AMKVGJZN.mjs';
3
3
  import { __require } from './chunk-BJTO5JO5.mjs';
4
4
  import yargs from 'yargs';
5
5
  import { hideBin } from 'yargs/helpers';
@@ -8,7 +8,7 @@ import path from 'path';
8
8
  import color3 from 'picocolors';
9
9
 
10
10
  // package.json
11
- var version = "1.1.2-canary.2";
11
+ var version = "1.1.2-canary.4";
12
12
 
13
13
  // src/cli/browser/shared/constants.ts
14
14
  var SERVICE_WORKER_FILE_NAME = "mockServiceWorker.js";
package/dist/cli.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../package.json","../src/cli/browser/shared/constants.ts","../src/cli/browser/init.ts","../src/utils/processes.ts","../src/cli/server/start.ts","../src/cli/server/token/create.ts","../src/cli/server/token/list.ts","../src/cli/server/token/remove.ts","../src/cli/cli.ts","../src/cli/index.ts"],"names":["color","exitEvent","yargs"],"mappings":";;;;;;;;;;AAgBE,IAAA,OAAA,GAAW,gBAAA;;;AChBN,IAAM,wBAAA,GAA2B,sBAAA;;;ACQxC,IAAM,aAAA,GAAgB,KAAK,IAAA,CAAK,SAAA,CAAQ,QAAQ,KAAK,CAAA,EAAG,IAAA,EAAM,IAAA,EAAM,IAAI,CAAA;AACjE,IAAM,wBAAA,GAA2B,IAAA,CAAK,IAAA,CAAK,aAAA,EAAe,OAAO,wBAAwB,CAAA;AAMhG,eAAe,8BAAA,CAA+B,EAAE,eAAA,EAAgB,EAAoC;AAClG,EAAA,MAAM,GAAG,QAAA,CAAS,KAAA,CAAM,iBAAiB,EAAE,SAAA,EAAW,MAAM,CAAA;AAE5D,EAAA,MAAM,eAAA,GAAkB,IAAA,CAAK,IAAA,CAAK,eAAA,EAAiB,wBAAwB,CAAA;AAC3E,EAAA,MAAM,EAAA,CAAG,QAAA,CAAS,QAAA,CAAS,wBAAA,EAA0B,eAAe,CAAA;AAEpE,EAAA,MAAA,CAAO,KAAK,CAAA,+BAAA,EAAkCA,MAAA,CAAM,OAAA,CAAQ,eAAe,CAAC,CAAA,CAAA,CAAG,CAAA;AACjF;AAEA,IAAO,YAAA,GAAQ,8BAAA;;;ACtBR,IAAM,mBAAA,GAAsB,OAAO,MAAA,CAAO;AAAA,EAC/C,YAAA;AAAA,EACA,0BAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAU,CAAA;AAKH,IAAM,+BAAA,GAAsE;AAAA,EACjF,UAAA,EAAY,MAAA;AAAA,EACZ,wBAAA,EAA0B,MAAA;AAAA,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;AAAA,YAChC,iBAAiB,YAAA,CAAa;AAAA,WAC/B,CAAA;AAAA;AACH,OACF,CAEC,OAAA;AAAA,QACC,CAAC,gBAAgB,kBAAkB,CAAA;AAAA,QACnC,8JAAA;AAAA,QAEA,CAACA,MAAAA,KACCA,MAAAA,CACG,UAAA,CAAW,SAAA,EAAW;AAAA,UACrB,IAAA,EAAM,QAAA;AAAA,UACN,WAAA,EAAa,wCAAA;AAAA,UACb,YAAA,EAAc;AAAA,SACf,CAAA,CACA,MAAA,CAAO,YAAA,EAAc;AAAA,UACpB,IAAA,EAAM,QAAA;AAAA,UACN,WAAA,EAAa,uDAAA;AAAA,UACb,KAAA,EAAO,GAAA;AAAA,UACP,OAAA,EAAS;AAAA,SACV,CAAA;AAAA,QACL,OAAO,YAAA,KAAiB;AACtB,UAAA,MAAM,4BAAA,CAA6B;AAAA,YACjC,SAAS,YAAA,CAAa,OAAA;AAAA,YACtB,iBAAiB,YAAA,CAAa;AAAA,WAC/B,CAAA;AAAA;AACH;AACF;AACJ,IAGH,KAAA,EAAM;AACX;AAEA,IAAO,WAAA,GAAQ,MAAA;;;ACjLf,KAAK,WAAA,EAAO","file":"cli.mjs","sourcesContent":["{\n \"name\": \"@zimic/interceptor\",\n \"description\": \"Next-gen TypeScript-first HTTP intercepting and mocking\",\n \"keywords\": [\n \"zimic\",\n \"typescript\",\n \"types\",\n \"typegen\",\n \"validation\",\n \"inference\",\n \"http\",\n \"interceptor\",\n \"mock\",\n \"api\",\n \"static\"\n ],\n \"version\": \"1.1.2-canary.2\",\n \"homepage\": \"https://zimic.dev/docs/interceptor\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/zimicjs/zimic.git\",\n \"directory\": \"packages/zimic-interceptor\"\n },\n \"author\": {\n \"name\": \"Diego Aquino\",\n \"url\": \"https://github.com/diego-aquino\"\n },\n \"funding\": {\n \"type\": \"github\",\n \"url\": \"https://github.com/sponsors/zimicjs\"\n },\n \"private\": false,\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n },\n \"engines\": {\n \"node\": \">=20.0.0\"\n },\n \"license\": \"MIT\",\n \"files\": [\n \"package.json\",\n \"README.md\",\n \"LICENSE.md\",\n \"src\",\n \"!src/**/tests\",\n \"!src/**/__tests__\",\n \"!src/**/*.test.ts\",\n \"dist\",\n \"index.d.ts\",\n \"http.d.ts\",\n \"server.d.ts\"\n ],\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"index.d.ts\",\n \"bin\": {\n \"zimic-interceptor\": \"./dist/cli.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"default\": \"./dist/index.js\"\n },\n \"./http\": {\n \"types\": \"./http.d.ts\",\n \"import\": \"./dist/http.mjs\",\n \"require\": \"./dist/http.js\",\n \"default\": \"./dist/http.js\"\n },\n \"./server\": {\n \"types\": \"./server.d.ts\",\n \"import\": \"./dist/server.mjs\",\n \"require\": \"./dist/server.js\",\n \"default\": \"./dist/server.js\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"scripts\": {\n \"dev\": \"tsup --watch\",\n \"cli\": \"node --enable-source-maps ./dist/cli.js\",\n \"build\": \"tsup\",\n \"lint\": \"eslint --cache --no-error-on-unmatched-pattern --no-warn-ignored --fix\",\n \"lint:turbo\": \"pnpm lint . --max-warnings 0\",\n \"style\": \"prettier --log-level warn --ignore-unknown --no-error-on-unmatched-pattern --cache\",\n \"style:check\": \"pnpm style --check\",\n \"style:format\": \"pnpm style --write\",\n \"test\": \"dotenv -v NODE_ENV=test -v FORCE_COLOR=1 -- vitest\",\n \"test:turbo\": \"dotenv -v CI=true -- pnpm run test run --coverage\",\n \"types:check\": \"tsc --noEmit\",\n \"deps:install-playwright\": \"playwright install chromium\",\n \"deps:init-msw\": \"msw init ./public --no-save\",\n \"deps:prepare\": \"pnpm deps:install-playwright && pnpm deps:init-msw\",\n \"postinstall\": \"node --enable-source-maps -e \\\"try{require('./dist/scripts/postinstall')}catch(error){console.error(error)}\\\"\"\n },\n \"dependencies\": {\n \"@whatwg-node/server\": \"0.10.12\",\n \"execa\": \"9.6.0\",\n \"isomorphic-ws\": \"5.0.0\",\n \"msw\": \"2.11.1\",\n \"picocolors\": \"^1.1.1\",\n \"ws\": \"8.18.3\",\n \"yargs\": \"18.0.0\",\n \"zod\": \"^4.1.11\"\n },\n \"optionalDependencies\": {\n \"bufferutil\": \"4.0.9\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^24.5.2\",\n \"@types/ws\": \"^8.18.1\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.2.4\",\n \"@vitest/coverage-istanbul\": \"^3.2.4\",\n \"@zimic/eslint-config-node\": \"workspace:*\",\n \"@zimic/lint-staged-config\": \"workspace:*\",\n \"@zimic/tsconfig\": \"workspace:*\",\n \"@zimic/utils\": \"workspace:*\",\n \"dotenv-cli\": \"^10.0.0\",\n \"eslint\": \"^9.36.0\",\n \"playwright\": \"^1.55.0\",\n \"tsup\": \"^8.4.0\",\n \"typescript\": \"^5.9.2\",\n \"vitest\": \"^3.2.4\"\n },\n \"peerDependencies\": {\n \"@zimic/http\": \"^1.1.0 || workspace:*\",\n \"typescript\": \">=5.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"typescript\": {\n \"optional\": true\n }\n }\n}\n","export const SERVICE_WORKER_FILE_NAME = 'mockServiceWorker.js';\n","import fs from 'fs';\nimport path from 'path';\nimport color from 'picocolors';\n\nimport { logger } from '@/utils/logging';\n\nimport { SERVICE_WORKER_FILE_NAME } from './shared/constants';\n\nconst MSW_ROOT_PATH = path.join(require.resolve('msw'), '..', '..', '..');\nexport const MOCK_SERVICE_WORKER_PATH = path.join(MSW_ROOT_PATH, 'lib', SERVICE_WORKER_FILE_NAME);\n\ninterface BrowserServiceWorkerInitOptions {\n publicDirectory: string;\n}\n\nasync function initializeBrowserServiceWorker({ publicDirectory }: BrowserServiceWorkerInitOptions) {\n await fs.promises.mkdir(publicDirectory, { recursive: true });\n\n const destinationPath = path.join(publicDirectory, SERVICE_WORKER_FILE_NAME);\n await fs.promises.copyFile(MOCK_SERVICE_WORKER_PATH, destinationPath);\n\n logger.info(`Service worker script saved to ${color.magenta(destinationPath)}.`);\n}\n\nexport default initializeBrowserServiceWorker;\n","import createCachedDynamicImport from '@zimic/utils/import/createCachedDynamicImport';\n\nexport const PROCESS_EXIT_EVENTS = Object.freeze([\n 'beforeExit',\n 'uncaughtExceptionMonitor',\n 'SIGINT',\n 'SIGTERM',\n 'SIGHUP',\n 'SIGBREAK',\n] as const);\n\nexport type ProcessExitEvent = (typeof PROCESS_EXIT_EVENTS)[number];\n\n// Having an undefined exit code means that the process will already exit with the default exit code.\nexport const PROCESS_EXIT_CODE_BY_EXIT_EVENT: Record<string, number | undefined> = {\n beforeExit: undefined,\n uncaughtExceptionMonitor: undefined,\n SIGINT: 130,\n SIGTERM: 143,\n SIGHUP: 129,\n SIGBREAK: 131,\n} satisfies Record<ProcessExitEvent, number | undefined>;\n\nexport const importExeca = createCachedDynamicImport(() => import('execa'));\n\ninterface CommandErrorOptions {\n command?: string[];\n exitCode?: number;\n signal?: NodeJS.Signals;\n originalMessage?: string;\n}\n\nexport class CommandError extends Error {\n static readonly DEFAULT_EXIT_CODE = 1;\n\n readonly command: string[];\n readonly exitCode: number;\n readonly signal?: NodeJS.Signals;\n\n constructor(executable: string, options: CommandErrorOptions) {\n const message = CommandError.createMessage(executable, options);\n super(message);\n\n this.name = 'CommandError';\n this.command = options.command ?? [executable];\n this.exitCode = this.getExitCode(options);\n this.signal = options.signal;\n }\n\n private getExitCode(options: CommandErrorOptions): number {\n const existingExitCode = options.exitCode;\n const exitCodeInferredFromSignal =\n options.signal === undefined ? undefined : PROCESS_EXIT_CODE_BY_EXIT_EVENT[options.signal];\n\n return existingExitCode ?? exitCodeInferredFromSignal ?? CommandError.DEFAULT_EXIT_CODE;\n }\n\n private static createMessage(command: string, options: CommandErrorOptions) {\n const suffix = options.originalMessage ? `: ${options.originalMessage}` : '';\n\n if (options.exitCode === undefined && options.signal === undefined) {\n return `Command '${command}' failed${suffix}`;\n }\n\n const prefix = `Command '${command}' exited `;\n const infix = options.exitCode === undefined ? `after signal ${options.signal}` : `with code ${options.exitCode}`;\n\n return `${prefix}${infix}${suffix}`;\n }\n}\n\nexport async function runCommand(commandEntry: string, commandArguments: string[]) {\n const { execa: $, ExecaError } = await importExeca();\n\n try {\n await $(commandEntry, commandArguments, { stdio: 'inherit' });\n } catch (error) {\n /* istanbul ignore if -- @preserve\n * This is a safeguard if the error is not an ExecaError. It is not expected to run. */\n if (!(error instanceof ExecaError)) {\n throw error;\n }\n\n const commandError = new CommandError(commandEntry, {\n command: [commandEntry, ...commandArguments],\n exitCode: error.exitCode,\n signal: error.signal,\n originalMessage: error.originalMessage,\n });\n\n throw commandError;\n }\n}\n","import color from 'picocolors';\n\nimport { InterceptorServer, createInterceptorServer } from '@/server';\nimport { InterceptorServerOptions } from '@/server/types/options';\nimport { logger } from '@/utils/logging';\nimport {\n CommandError,\n PROCESS_EXIT_CODE_BY_EXIT_EVENT,\n PROCESS_EXIT_EVENTS,\n ProcessExitEvent,\n runCommand,\n} from '@/utils/processes';\n\ninterface InterceptorServerStartOptions extends InterceptorServerOptions {\n ephemeral: boolean;\n onReady?: { command: string; arguments: string[] };\n}\n\nexport let serverSingleton: InterceptorServer | undefined;\n\nasync function startInterceptorServer({\n hostname,\n port,\n logUnhandledRequests,\n tokensDirectory,\n ephemeral,\n onReady,\n}: InterceptorServerStartOptions) {\n const server = createInterceptorServer({\n hostname,\n port,\n logUnhandledRequests,\n tokensDirectory,\n });\n\n async function handleExitEvent(exitEvent: ProcessExitEvent | undefined) {\n await server.stop();\n\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n for (const { exitEvent, exitHandler } of exitHandlerGroups) {\n process.off(exitEvent, exitHandler);\n }\n\n const exitCode = exitEvent ? PROCESS_EXIT_CODE_BY_EXIT_EVENT[exitEvent] : undefined;\n if (exitCode !== undefined) {\n process.exit(exitCode);\n }\n }\n\n const exitHandlerGroups = PROCESS_EXIT_EVENTS.map((exitEvent) => ({\n exitEvent,\n exitHandler: handleExitEvent.bind(null, exitEvent),\n }));\n\n for (const { exitEvent, exitHandler } of exitHandlerGroups) {\n process.on(exitEvent, exitHandler);\n }\n\n serverSingleton = server;\n\n await server.start();\n\n logger.info(\n `${ephemeral ? 'Ephemeral s' : 'S'}erver is running on ${color.yellow(`${server.hostname}:${server.port}`)}`,\n );\n\n const isDangerouslyUnprotected = !tokensDirectory && process.env.NODE_ENV === 'production';\n\n if (isDangerouslyUnprotected) {\n logger.warn(\n [\n `Attention: this interceptor server is ${color.bold(color.red('unprotected'))}. Do not expose it publicly without authentication.`,\n '',\n 'Learn more: https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#interceptor-server-authentication',\n ].join('\\n'),\n );\n }\n\n if (onReady) {\n try {\n await runCommand(onReady.command, onReady.arguments);\n } catch (error) {\n console.error(error);\n\n /* istanbul ignore if -- @preserve\n * A CommandError is always expected here. */\n if (!(error instanceof CommandError)) {\n throw error;\n }\n\n process.exit(error.exitCode);\n }\n }\n\n if (ephemeral) {\n await handleExitEvent(undefined);\n process.exit(0);\n }\n}\n\nexport default startInterceptorServer;\n","import color from 'picocolors';\n\nimport { createInterceptorToken } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerCreateTokenOptions {\n tokenName?: string;\n tokensDirectory: string;\n}\n\nexport async function createInterceptorServerToken({\n tokenName,\n tokensDirectory,\n}: InterceptorServerCreateTokenOptions) {\n const token = await createInterceptorToken({ name: tokenName, tokensDirectory });\n\n logger.info(\n [\n `${color.green(color.bold('✔'))} Token${tokenName ? ` ${color.green(tokenName)}` : ''} created:`,\n '',\n color.yellow(token.value),\n '',\n 'Store this token securely. It cannot be retrieved later.',\n '',\n `To enable authentication in your interceptor server, use the ${color.cyan('--tokens-dir')} option. Only ` +\n 'remote interceptors bearing a valid token will be allowed to connect.',\n '',\n `${color.dim('$')} zimic-interceptor server start ${color.cyan('--tokens-dir')} ${color.magenta(tokensDirectory)}`,\n '',\n 'Learn more: https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#interceptor-server-authentication',\n ].join('\\n'),\n );\n}\n","import { listInterceptorTokens } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerListTokensOptions {\n tokensDirectory: string;\n}\n\nexport async function listInterceptorServerTokens({ tokensDirectory }: InterceptorServerListTokensOptions) {\n const tokens = await listInterceptorTokens({ tokensDirectory });\n\n logger.raw.table(\n [\n { title: 'ID', property: 'id' },\n { title: 'NAME', property: 'name' },\n { title: 'CREATED AT', property: 'createdAt' },\n ],\n tokens.map((token) => ({\n id: token.id,\n name: token.name ?? '',\n createdAt: token.createdAt.toISOString(),\n })),\n );\n}\n","import color from 'picocolors';\n\nimport { readInterceptorTokenFromFile, removeInterceptorToken } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerCreateTokenOptions {\n tokenId: string;\n tokensDirectory: string;\n}\n\nexport async function removeInterceptorServerToken({ tokenId, tokensDirectory }: InterceptorServerCreateTokenOptions) {\n const token = await readInterceptorTokenFromFile(tokenId, { tokensDirectory });\n\n if (!token) {\n logger.error(`${color.red(color.bold('✘'))} Token ${color.red(tokenId)} not found.`);\n process.exit(1);\n }\n\n await removeInterceptorToken(token.id, { tokensDirectory });\n\n logger.info(`${color.green(color.bold('✔'))} Token ${color.green(token.name ?? token.id)} removed.`);\n}\n","import yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport { version } from '@@/package.json';\n\nimport { DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY } from '../server/utils/auth';\nimport initializeBrowserServiceWorker from './browser/init';\nimport startInterceptorServer from './server/start';\nimport { createInterceptorServerToken } from './server/token/create';\nimport { listInterceptorServerTokens } from './server/token/list';\nimport { removeInterceptorServerToken } from './server/token/remove';\n\nasync function runCLI() {\n await yargs(hideBin(process.argv))\n .scriptName('zimic-interceptor')\n .version(version)\n .showHelpOnFail(false)\n .strict()\n\n .command('browser', 'Manage your browser mock configuration.', (yargs) =>\n yargs.demandCommand().command(\n 'init <publicDirectory>',\n 'Initialize the browser service worker configuration.',\n (yargs) =>\n yargs.positional('publicDirectory', {\n type: 'string',\n description: 'The path to the public directory of your application.',\n demandOption: true,\n }),\n async (cliArguments) => {\n await initializeBrowserServiceWorker({\n publicDirectory: cliArguments.publicDirectory,\n });\n },\n ),\n )\n\n .command('server', 'Manage interceptor servers.', (yargs) =>\n yargs\n .demandCommand()\n .command(\n 'start [-- onReady]',\n 'Start an interceptor server.',\n (yargs) =>\n yargs\n .positional('onReady', {\n description: 'A command to run when the server is ready to accept connections.',\n type: 'string',\n })\n .option('hostname', {\n type: 'string',\n description: 'The hostname to start the server on.',\n alias: 'h',\n default: 'localhost',\n })\n .option('port', {\n type: 'number',\n description: 'The port to start the server on.',\n alias: 'p',\n })\n .option('ephemeral', {\n type: 'boolean',\n description:\n 'Whether the server should stop automatically after the on-ready command finishes. ' +\n 'If no on-ready command is provided and ephemeral is true, the server will stop immediately after ' +\n 'starting.',\n alias: 'e',\n default: false,\n })\n .option('log-unhandled-requests', {\n type: 'boolean',\n description:\n 'Whether to log a warning when no interceptors were found for the base URL of a request. ' +\n 'If an interceptor was matched, the logging behavior for that base URL is configured in the ' +\n 'interceptor itself.',\n alias: 'l',\n })\n .option('tokens-dir', {\n type: 'string',\n description:\n 'The directory where the authorized interceptor authentication tokens are saved. If provided, only ' +\n 'remote interceptors bearing a valid token will be accepted. This option is essential if you are ' +\n 'exposing your interceptor server publicly. For local development and testing, though, ' +\n '`--tokens-dir` is optional.',\n alias: 't',\n }),\n async (cliArguments) => {\n const onReadyCommand = cliArguments._.at(2)?.toString();\n const onReadyCommandArguments = cliArguments._.slice(3).map((argument) => argument.toString());\n\n await startInterceptorServer({\n hostname: cliArguments.hostname,\n port: cliArguments.port,\n ephemeral: cliArguments.ephemeral,\n logUnhandledRequests: cliArguments.logUnhandledRequests,\n tokensDirectory: cliArguments.tokensDir,\n onReady: onReadyCommand\n ? {\n command: onReadyCommand.toString(),\n arguments: onReadyCommandArguments,\n }\n : undefined,\n });\n },\n )\n\n .command('token', 'Manage remote interceptor authentication tokens.', (yargs) =>\n yargs\n .demandCommand()\n .command(\n 'create',\n 'Create an interceptor token.',\n (yargs) =>\n yargs\n .option('name', {\n type: 'string',\n description: 'The name of the token to create.',\n alias: 'n',\n })\n .option('tokens-dir', {\n type: 'string',\n description: 'The directory where the created interceptor token will be saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await createInterceptorServerToken({\n tokenName: cliArguments.name,\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n )\n\n .command(\n ['ls', 'list'],\n 'List the authorized interceptor tokens.',\n (yargs) =>\n yargs.option('tokens-dir', {\n type: 'string',\n description: 'The directory where the interceptor tokens are saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await listInterceptorServerTokens({\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n )\n\n .command(\n ['rm <tokenId>', 'remove <tokenId>'],\n 'Remove (invalidate) an interceptor token. Existing connections will not be affected, so restarting the ' +\n 'server is recommended to disconnect all interceptors.',\n (yargs) =>\n yargs\n .positional('tokenId', {\n type: 'string',\n description: 'The identifier of the token to remove.',\n demandOption: true,\n })\n .option('tokens-dir', {\n type: 'string',\n description: 'The directory where the interceptor tokens are saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await removeInterceptorServerToken({\n tokenId: cliArguments.tokenId,\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n ),\n ),\n )\n\n .parse();\n}\n\nexport default runCLI;\n","#!/usr/bin/env node\nimport runCLI from './cli';\n\nvoid runCLI();\n"]}
1
+ {"version":3,"sources":["../package.json","../src/cli/browser/shared/constants.ts","../src/cli/browser/init.ts","../src/utils/processes.ts","../src/cli/server/start.ts","../src/cli/server/token/create.ts","../src/cli/server/token/list.ts","../src/cli/server/token/remove.ts","../src/cli/cli.ts","../src/cli/index.ts"],"names":["color","exitEvent","yargs"],"mappings":";;;;;;;;;;AAgBE,IAAA,OAAA,GAAW,gBAAA;;;AChBN,IAAM,wBAAA,GAA2B,sBAAA;;;ACQxC,IAAM,aAAA,GAAgB,KAAK,IAAA,CAAK,SAAA,CAAQ,QAAQ,KAAK,CAAA,EAAG,IAAA,EAAM,IAAA,EAAM,IAAI,CAAA;AACjE,IAAM,wBAAA,GAA2B,IAAA,CAAK,IAAA,CAAK,aAAA,EAAe,OAAO,wBAAwB,CAAA;AAMhG,eAAe,8BAAA,CAA+B,EAAE,eAAA,EAAgB,EAAoC;AAClG,EAAA,MAAM,GAAG,QAAA,CAAS,KAAA,CAAM,iBAAiB,EAAE,SAAA,EAAW,MAAM,CAAA;AAE5D,EAAA,MAAM,eAAA,GAAkB,IAAA,CAAK,IAAA,CAAK,eAAA,EAAiB,wBAAwB,CAAA;AAC3E,EAAA,MAAM,EAAA,CAAG,QAAA,CAAS,QAAA,CAAS,wBAAA,EAA0B,eAAe,CAAA;AAEpE,EAAA,MAAA,CAAO,KAAK,CAAA,+BAAA,EAAkCA,MAAA,CAAM,OAAA,CAAQ,eAAe,CAAC,CAAA,CAAA,CAAG,CAAA;AACjF;AAEA,IAAO,YAAA,GAAQ,8BAAA;;;ACtBR,IAAM,mBAAA,GAAsB,OAAO,MAAA,CAAO;AAAA,EAC/C,YAAA;AAAA,EACA,0BAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAU,CAAA;AAKH,IAAM,+BAAA,GAAsE;AAAA,EACjF,UAAA,EAAY,MAAA;AAAA,EACZ,wBAAA,EAA0B,MAAA;A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AA4B;AAAA,YAChC,iBAAiB,YAAA,CAAa;AAAA,WAC/B,CAAA;AAAA;AACH,OACF,CAEC,OAAA;AAAA,QACC,CAAC,gBAAgB,kBAAkB,CAAA;AAAA,QACnC,8JAAA;AAAA,QAEA,CAACA,MAAAA,KACCA,MAAAA,CACG,UAAA,CAAW,SAAA,EAAW;AAAA,UACrB,IAAA,EAAM,QAAA;AAAA,UACN,WAAA,EAAa,wCAAA;AAAA,UACb,YAAA,EAAc;AAAA,SACf,CAAA,CACA,MAAA,CAAO,YAAA,EAAc;AAAA,UACpB,IAAA,EAAM,QAAA;AAAA,UACN,WAAA,EAAa,uDAAA;AAAA,UACb,KAAA,EAAO,GAAA;AAAA,UACP,OAAA,EAAS;AAAA,SACV,CAAA;AAAA,QACL,OAAO,YAAA,KAAiB;AACtB,UAAA,MAAM,4BAAA,CAA6B;AAAA,YACjC,SAAS,YAAA,CAAa,OAAA;AAAA,YACtB,iBAAiB,YAAA,CAAa;AAAA,WAC/B,CAAA;AAAA;AACH;AACF;AACJ,IAGH,KAAA,EAAM;AACX;AAEA,IAAO,WAAA,GAAQ,MAAA;;;ACjLf,KAAK,WAAA,EAAO","file":"cli.mjs","sourcesContent":["{\n \"name\": \"@zimic/interceptor\",\n \"description\": \"Next-gen TypeScript-first HTTP intercepting and mocking\",\n \"keywords\": [\n \"zimic\",\n \"typescript\",\n \"types\",\n \"typegen\",\n \"validation\",\n \"inference\",\n \"http\",\n \"interceptor\",\n \"mock\",\n \"api\",\n \"static\"\n ],\n \"version\": \"1.1.2-canary.4\",\n \"homepage\": \"https://zimic.dev/docs/interceptor\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/zimicjs/zimic.git\",\n \"directory\": \"packages/zimic-interceptor\"\n },\n \"author\": {\n \"name\": \"Diego Aquino\",\n \"url\": \"https://github.com/diego-aquino\"\n },\n \"funding\": {\n \"type\": \"github\",\n \"url\": \"https://github.com/sponsors/zimicjs\"\n },\n \"private\": false,\n \"publishConfig\": {\n \"access\": \"public\",\n \"provenance\": true\n },\n \"engines\": {\n \"node\": \">=20.0.0\"\n },\n \"license\": \"MIT\",\n \"files\": [\n \"package.json\",\n \"README.md\",\n \"LICENSE.md\",\n \"src\",\n \"!src/**/tests\",\n \"!src/**/__tests__\",\n \"!src/**/*.test.ts\",\n \"dist\",\n \"index.d.ts\",\n \"http.d.ts\",\n \"server.d.ts\"\n ],\n \"sideEffects\": false,\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"index.d.ts\",\n \"bin\": {\n \"zimic-interceptor\": \"./dist/cli.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.js\",\n \"default\": \"./dist/index.js\"\n },\n \"./http\": {\n \"types\": \"./http.d.ts\",\n \"import\": \"./dist/http.mjs\",\n \"require\": \"./dist/http.js\",\n \"default\": \"./dist/http.js\"\n },\n \"./server\": {\n \"types\": \"./server.d.ts\",\n \"import\": \"./dist/server.mjs\",\n \"require\": \"./dist/server.js\",\n \"default\": \"./dist/server.js\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"scripts\": {\n \"dev\": \"tsup --watch\",\n \"cli\": \"node --enable-source-maps ./dist/cli.js\",\n \"build\": \"tsup\",\n \"lint\": \"eslint --cache --no-error-on-unmatched-pattern --no-warn-ignored --fix\",\n \"lint:turbo\": \"pnpm lint . --max-warnings 0\",\n \"style\": \"prettier --log-level warn --ignore-unknown --no-error-on-unmatched-pattern --cache\",\n \"style:check\": \"pnpm style --check\",\n \"style:format\": \"pnpm style --write\",\n \"test\": \"dotenv -v NODE_ENV=test -v FORCE_COLOR=1 -- vitest\",\n \"test:turbo\": \"dotenv -v CI=true -- pnpm run test run --coverage\",\n \"types:check\": \"tsc --noEmit\",\n \"deps:install-playwright\": \"playwright install chromium\",\n \"deps:init-msw\": \"msw init ./public --no-save\",\n \"deps:prepare\": \"pnpm deps:install-playwright && pnpm deps:init-msw\",\n \"postinstall\": \"node --enable-source-maps -e \\\"try{require('./dist/scripts/postinstall')}catch(error){console.error(error)}\\\"\"\n },\n \"dependencies\": {\n \"@whatwg-node/server\": \"0.10.12\",\n \"execa\": \"9.6.0\",\n \"isomorphic-ws\": \"5.0.0\",\n \"msw\": \"2.11.1\",\n \"picocolors\": \"^1.1.1\",\n \"ws\": \"8.18.3\",\n \"yargs\": \"18.0.0\",\n \"zod\": \"^4.1.11\"\n },\n \"optionalDependencies\": {\n \"bufferutil\": \"4.0.9\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^24.5.2\",\n \"@types/ws\": \"^8.18.1\",\n \"@types/yargs\": \"^17.0.33\",\n \"@vitest/browser\": \"^3.2.4\",\n \"@vitest/coverage-istanbul\": \"^3.2.4\",\n \"@zimic/eslint-config-node\": \"workspace:*\",\n \"@zimic/lint-staged-config\": \"workspace:*\",\n \"@zimic/tsconfig\": \"workspace:*\",\n \"@zimic/utils\": \"workspace:*\",\n \"dotenv-cli\": \"^10.0.0\",\n \"eslint\": \"^9.36.0\",\n \"playwright\": \"^1.55.0\",\n \"tsup\": \"^8.4.0\",\n \"typescript\": \"^5.9.2\",\n \"vitest\": \"^3.2.4\"\n },\n \"peerDependencies\": {\n \"@zimic/http\": \"^1.1.0 || workspace:*\",\n \"typescript\": \">=5.0.0\"\n },\n \"peerDependenciesMeta\": {\n \"typescript\": {\n \"optional\": true\n }\n }\n}\n","export const SERVICE_WORKER_FILE_NAME = 'mockServiceWorker.js';\n","import fs from 'fs';\nimport path from 'path';\nimport color from 'picocolors';\n\nimport { logger } from '@/utils/logging';\n\nimport { SERVICE_WORKER_FILE_NAME } from './shared/constants';\n\nconst MSW_ROOT_PATH = path.join(require.resolve('msw'), '..', '..', '..');\nexport const MOCK_SERVICE_WORKER_PATH = path.join(MSW_ROOT_PATH, 'lib', SERVICE_WORKER_FILE_NAME);\n\ninterface BrowserServiceWorkerInitOptions {\n publicDirectory: string;\n}\n\nasync function initializeBrowserServiceWorker({ publicDirectory }: BrowserServiceWorkerInitOptions) {\n await fs.promises.mkdir(publicDirectory, { recursive: true });\n\n const destinationPath = path.join(publicDirectory, SERVICE_WORKER_FILE_NAME);\n await fs.promises.copyFile(MOCK_SERVICE_WORKER_PATH, destinationPath);\n\n logger.info(`Service worker script saved to ${color.magenta(destinationPath)}.`);\n}\n\nexport default initializeBrowserServiceWorker;\n","import createCachedDynamicImport from '@zimic/utils/import/createCachedDynamicImport';\n\nexport const PROCESS_EXIT_EVENTS = Object.freeze([\n 'beforeExit',\n 'uncaughtExceptionMonitor',\n 'SIGINT',\n 'SIGTERM',\n 'SIGHUP',\n 'SIGBREAK',\n] as const);\n\nexport type ProcessExitEvent = (typeof PROCESS_EXIT_EVENTS)[number];\n\n// Having an undefined exit code means that the process will already exit with the default exit code.\nexport const PROCESS_EXIT_CODE_BY_EXIT_EVENT: Record<string, number | undefined> = {\n beforeExit: undefined,\n uncaughtExceptionMonitor: undefined,\n SIGINT: 130,\n SIGTERM: 143,\n SIGHUP: 129,\n SIGBREAK: 131,\n} satisfies Record<ProcessExitEvent, number | undefined>;\n\nexport const importExeca = createCachedDynamicImport(() => import('execa'));\n\ninterface CommandErrorOptions {\n command?: string[];\n exitCode?: number;\n signal?: NodeJS.Signals;\n originalMessage?: string;\n}\n\nexport class CommandError extends Error {\n static readonly DEFAULT_EXIT_CODE = 1;\n\n readonly command: string[];\n readonly exitCode: number;\n readonly signal?: NodeJS.Signals;\n\n constructor(executable: string, options: CommandErrorOptions) {\n const message = CommandError.createMessage(executable, options);\n super(message);\n\n this.name = 'CommandError';\n this.command = options.command ?? [executable];\n this.exitCode = this.getExitCode(options);\n this.signal = options.signal;\n }\n\n private getExitCode(options: CommandErrorOptions): number {\n const existingExitCode = options.exitCode;\n const exitCodeInferredFromSignal =\n options.signal === undefined ? undefined : PROCESS_EXIT_CODE_BY_EXIT_EVENT[options.signal];\n\n return existingExitCode ?? exitCodeInferredFromSignal ?? CommandError.DEFAULT_EXIT_CODE;\n }\n\n private static createMessage(command: string, options: CommandErrorOptions) {\n const suffix = options.originalMessage ? `: ${options.originalMessage}` : '';\n\n if (options.exitCode === undefined && options.signal === undefined) {\n return `Command '${command}' failed${suffix}`;\n }\n\n const prefix = `Command '${command}' exited `;\n const infix = options.exitCode === undefined ? `after signal ${options.signal}` : `with code ${options.exitCode}`;\n\n return `${prefix}${infix}${suffix}`;\n }\n}\n\nexport async function runCommand(commandEntry: string, commandArguments: string[]) {\n const { execa: $, ExecaError } = await importExeca();\n\n try {\n await $(commandEntry, commandArguments, { stdio: 'inherit' });\n } catch (error) {\n /* istanbul ignore if -- @preserve\n * This is a safeguard if the error is not an ExecaError. It is not expected to run. */\n if (!(error instanceof ExecaError)) {\n throw error;\n }\n\n const commandError = new CommandError(commandEntry, {\n command: [commandEntry, ...commandArguments],\n exitCode: error.exitCode,\n signal: error.signal,\n originalMessage: error.originalMessage,\n });\n\n throw commandError;\n }\n}\n","import color from 'picocolors';\n\nimport { InterceptorServer, createInterceptorServer } from '@/server';\nimport { InterceptorServerOptions } from '@/server/types/options';\nimport { logger } from '@/utils/logging';\nimport {\n CommandError,\n PROCESS_EXIT_CODE_BY_EXIT_EVENT,\n PROCESS_EXIT_EVENTS,\n ProcessExitEvent,\n runCommand,\n} from '@/utils/processes';\n\ninterface InterceptorServerStartOptions extends InterceptorServerOptions {\n ephemeral: boolean;\n onReady?: { command: string; arguments: string[] };\n}\n\nexport let serverSingleton: InterceptorServer | undefined;\n\nasync function startInterceptorServer({\n hostname,\n port,\n logUnhandledRequests,\n tokensDirectory,\n ephemeral,\n onReady,\n}: InterceptorServerStartOptions) {\n const server = createInterceptorServer({\n hostname,\n port,\n logUnhandledRequests,\n tokensDirectory,\n });\n\n async function handleExitEvent(exitEvent: ProcessExitEvent | undefined) {\n await server.stop();\n\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n for (const { exitEvent, exitHandler } of exitHandlerGroups) {\n process.off(exitEvent, exitHandler);\n }\n\n const exitCode = exitEvent ? PROCESS_EXIT_CODE_BY_EXIT_EVENT[exitEvent] : undefined;\n if (exitCode !== undefined) {\n process.exit(exitCode);\n }\n }\n\n const exitHandlerGroups = PROCESS_EXIT_EVENTS.map((exitEvent) => ({\n exitEvent,\n exitHandler: handleExitEvent.bind(null, exitEvent),\n }));\n\n for (const { exitEvent, exitHandler } of exitHandlerGroups) {\n process.on(exitEvent, exitHandler);\n }\n\n serverSingleton = server;\n\n await server.start();\n\n logger.info(\n `${ephemeral ? 'Ephemeral s' : 'S'}erver is running on ${color.yellow(`${server.hostname}:${server.port}`)}`,\n );\n\n const isDangerouslyUnprotected = !tokensDirectory && process.env.NODE_ENV === 'production';\n\n if (isDangerouslyUnprotected) {\n logger.warn(\n [\n `Attention: this interceptor server is ${color.bold(color.red('unprotected'))}. Do not expose it publicly without authentication.`,\n '',\n 'Learn more: https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#interceptor-server-authentication',\n ].join('\\n'),\n );\n }\n\n if (onReady) {\n try {\n await runCommand(onReady.command, onReady.arguments);\n } catch (error) {\n console.error(error);\n\n /* istanbul ignore if -- @preserve\n * A CommandError is always expected here. */\n if (!(error instanceof CommandError)) {\n throw error;\n }\n\n process.exit(error.exitCode);\n }\n }\n\n if (ephemeral) {\n await handleExitEvent(undefined);\n process.exit(0);\n }\n}\n\nexport default startInterceptorServer;\n","import color from 'picocolors';\n\nimport { createInterceptorToken } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerCreateTokenOptions {\n tokenName?: string;\n tokensDirectory: string;\n}\n\nexport async function createInterceptorServerToken({\n tokenName,\n tokensDirectory,\n}: InterceptorServerCreateTokenOptions) {\n const token = await createInterceptorToken({ name: tokenName, tokensDirectory });\n\n logger.info(\n [\n `${color.green(color.bold('✔'))} Token${tokenName ? ` ${color.green(tokenName)}` : ''} created:`,\n '',\n color.yellow(token.value),\n '',\n 'Store this token securely. It cannot be retrieved later.',\n '',\n `To enable authentication in your interceptor server, use the ${color.cyan('--tokens-dir')} option. Only ` +\n 'remote interceptors bearing a valid token will be allowed to connect.',\n '',\n `${color.dim('$')} zimic-interceptor server start ${color.cyan('--tokens-dir')} ${color.magenta(tokensDirectory)}`,\n '',\n 'Learn more: https://zimic.dev/docs/interceptor/guides/http/remote-interceptors#interceptor-server-authentication',\n ].join('\\n'),\n );\n}\n","import { listInterceptorTokens } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerListTokensOptions {\n tokensDirectory: string;\n}\n\nexport async function listInterceptorServerTokens({ tokensDirectory }: InterceptorServerListTokensOptions) {\n const tokens = await listInterceptorTokens({ tokensDirectory });\n\n logger.raw.table(\n [\n { title: 'ID', property: 'id' },\n { title: 'NAME', property: 'name' },\n { title: 'CREATED AT', property: 'createdAt' },\n ],\n tokens.map((token) => ({\n id: token.id,\n name: token.name ?? '',\n createdAt: token.createdAt.toISOString(),\n })),\n );\n}\n","import color from 'picocolors';\n\nimport { readInterceptorTokenFromFile, removeInterceptorToken } from '@/server/utils/auth';\nimport { logger } from '@/utils/logging';\n\ninterface InterceptorServerCreateTokenOptions {\n tokenId: string;\n tokensDirectory: string;\n}\n\nexport async function removeInterceptorServerToken({ tokenId, tokensDirectory }: InterceptorServerCreateTokenOptions) {\n const token = await readInterceptorTokenFromFile(tokenId, { tokensDirectory });\n\n if (!token) {\n logger.error(`${color.red(color.bold('✘'))} Token ${color.red(tokenId)} not found.`);\n process.exit(1);\n }\n\n await removeInterceptorToken(token.id, { tokensDirectory });\n\n logger.info(`${color.green(color.bold('✔'))} Token ${color.green(token.name ?? token.id)} removed.`);\n}\n","import yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport { version } from '@@/package.json';\n\nimport { DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY } from '../server/utils/auth';\nimport initializeBrowserServiceWorker from './browser/init';\nimport startInterceptorServer from './server/start';\nimport { createInterceptorServerToken } from './server/token/create';\nimport { listInterceptorServerTokens } from './server/token/list';\nimport { removeInterceptorServerToken } from './server/token/remove';\n\nasync function runCLI() {\n await yargs(hideBin(process.argv))\n .scriptName('zimic-interceptor')\n .version(version)\n .showHelpOnFail(false)\n .strict()\n\n .command('browser', 'Manage your browser mock configuration.', (yargs) =>\n yargs.demandCommand().command(\n 'init <publicDirectory>',\n 'Initialize the browser service worker configuration.',\n (yargs) =>\n yargs.positional('publicDirectory', {\n type: 'string',\n description: 'The path to the public directory of your application.',\n demandOption: true,\n }),\n async (cliArguments) => {\n await initializeBrowserServiceWorker({\n publicDirectory: cliArguments.publicDirectory,\n });\n },\n ),\n )\n\n .command('server', 'Manage interceptor servers.', (yargs) =>\n yargs\n .demandCommand()\n .command(\n 'start [-- onReady]',\n 'Start an interceptor server.',\n (yargs) =>\n yargs\n .positional('onReady', {\n description: 'A command to run when the server is ready to accept connections.',\n type: 'string',\n })\n .option('hostname', {\n type: 'string',\n description: 'The hostname to start the server on.',\n alias: 'h',\n default: 'localhost',\n })\n .option('port', {\n type: 'number',\n description: 'The port to start the server on.',\n alias: 'p',\n })\n .option('ephemeral', {\n type: 'boolean',\n description:\n 'Whether the server should stop automatically after the on-ready command finishes. ' +\n 'If no on-ready command is provided and ephemeral is true, the server will stop immediately after ' +\n 'starting.',\n alias: 'e',\n default: false,\n })\n .option('log-unhandled-requests', {\n type: 'boolean',\n description:\n 'Whether to log a warning when no interceptors were found for the base URL of a request. ' +\n 'If an interceptor was matched, the logging behavior for that base URL is configured in the ' +\n 'interceptor itself.',\n alias: 'l',\n })\n .option('tokens-dir', {\n type: 'string',\n description:\n 'The directory where the authorized interceptor authentication tokens are saved. If provided, only ' +\n 'remote interceptors bearing a valid token will be accepted. This option is essential if you are ' +\n 'exposing your interceptor server publicly. For local development and testing, though, ' +\n '`--tokens-dir` is optional.',\n alias: 't',\n }),\n async (cliArguments) => {\n const onReadyCommand = cliArguments._.at(2)?.toString();\n const onReadyCommandArguments = cliArguments._.slice(3).map((argument) => argument.toString());\n\n await startInterceptorServer({\n hostname: cliArguments.hostname,\n port: cliArguments.port,\n ephemeral: cliArguments.ephemeral,\n logUnhandledRequests: cliArguments.logUnhandledRequests,\n tokensDirectory: cliArguments.tokensDir,\n onReady: onReadyCommand\n ? {\n command: onReadyCommand.toString(),\n arguments: onReadyCommandArguments,\n }\n : undefined,\n });\n },\n )\n\n .command('token', 'Manage remote interceptor authentication tokens.', (yargs) =>\n yargs\n .demandCommand()\n .command(\n 'create',\n 'Create an interceptor token.',\n (yargs) =>\n yargs\n .option('name', {\n type: 'string',\n description: 'The name of the token to create.',\n alias: 'n',\n })\n .option('tokens-dir', {\n type: 'string',\n description: 'The directory where the created interceptor token will be saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await createInterceptorServerToken({\n tokenName: cliArguments.name,\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n )\n\n .command(\n ['ls', 'list'],\n 'List the authorized interceptor tokens.',\n (yargs) =>\n yargs.option('tokens-dir', {\n type: 'string',\n description: 'The directory where the interceptor tokens are saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await listInterceptorServerTokens({\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n )\n\n .command(\n ['rm <tokenId>', 'remove <tokenId>'],\n 'Remove (invalidate) an interceptor token. Existing connections will not be affected, so restarting the ' +\n 'server is recommended to disconnect all interceptors.',\n (yargs) =>\n yargs\n .positional('tokenId', {\n type: 'string',\n description: 'The identifier of the token to remove.',\n demandOption: true,\n })\n .option('tokens-dir', {\n type: 'string',\n description: 'The directory where the interceptor tokens are saved.',\n alias: 't',\n default: DEFAULT_INTERCEPTOR_TOKENS_DIRECTORY,\n }),\n async (cliArguments) => {\n await removeInterceptorServerToken({\n tokenId: cliArguments.tokenId,\n tokensDirectory: cliArguments.tokensDir,\n });\n },\n ),\n ),\n )\n\n .parse();\n}\n\nexport default runCLI;\n","#!/usr/bin/env node\nimport runCLI from './cli';\n\nvoid runCLI();\n"]}
package/dist/http.js CHANGED
@@ -883,28 +883,31 @@ var LocalHttpRequestHandler = class {
883
883
  };
884
884
  var LocalHttpRequestHandler_default = LocalHttpRequestHandler;
885
885
 
886
- // ../zimic-utils/dist/chunk-46M3OXFU.mjs
887
- function getExtraPatternsToEscape() {
886
+ // ../zimic-utils/dist/chunk-TYSDS3LQ.mjs
887
+ function createPathCharactersToEscapeRegex() {
888
888
  return /([.(){}+$])/g;
889
889
  }
890
- function getURIEncodedBackSlashPattern() {
891
- return /%5C/g;
890
+ function preparePathForRegex(path) {
891
+ const pathURLPrefix = `data:${path.startsWith("/") ? "" : "/"}`;
892
+ const pathAsURL = new URL(`${pathURLPrefix}${path}`);
893
+ const encodedPath = pathAsURL.href.replace(pathURLPrefix, "");
894
+ return encodedPath.replace(/^\/+/g, "").replace(/\/+$/g, "").replace(createPathCharactersToEscapeRegex(), "\\$1");
892
895
  }
893
- function getPathParamPattern() {
896
+ function createPathParamRegex() {
894
897
  return /(?<escape>\\)?:(?<identifier>[$_\p{ID_Start}][$\p{ID_Continue}]+)/gu;
895
898
  }
896
- function getRepeatingPathParamPattern() {
899
+ function createRepeatingPathParamRegex() {
897
900
  return /(?<escape>\\)?:(?<identifier>[$_\p{ID_Start}][$\p{ID_Continue}]+)\\+/gu;
898
901
  }
899
- function getOptionalPathParamPattern() {
902
+ function createOptionalPathParamRegex() {
900
903
  return /(?<leadingSlash>\/)?(?<escape>\\)?:(?<identifier>[$_\p{ID_Start}][$\p{ID_Continue}]+)\?(?<trailingSlash>\/)?/gu;
901
904
  }
902
- function getOptionalRepeatingPathParamPattern() {
905
+ function createOptionalRepeatingPathParamRegex() {
903
906
  return /(?<leadingSlash>\/)?(?<escape>\\)?:(?<identifier>[$_\p{ID_Start}][$\p{ID_Continue}]+)\*(?<trailingSlash>\/)?/gu;
904
907
  }
905
- function createParametrizedPathPattern(path) {
906
- const replacedURL = encodeURI(path).replace(/^\/+/g, "").replace(/\/+$/g, "").replace(getExtraPatternsToEscape(), "\\$1").replace(getURIEncodedBackSlashPattern(), "\\").replace(
907
- getOptionalRepeatingPathParamPattern(),
908
+ function createRegexFromPath(path) {
909
+ const pathRegexContent = preparePathForRegex(path).replace(
910
+ createOptionalRepeatingPathParamRegex(),
908
911
  (_match, leadingSlash, escape, identifier, trailingSlash) => {
909
912
  if (escape) {
910
913
  return `:${identifier}`;
@@ -923,10 +926,10 @@ function createParametrizedPathPattern(path) {
923
926
  return `(?<${identifier}>.+?)?`;
924
927
  }
925
928
  }
926
- ).replace(getRepeatingPathParamPattern(), (_match, escape, identifier) => {
929
+ ).replace(createRepeatingPathParamRegex(), (_match, escape, identifier) => {
927
930
  return escape ? `:${identifier}` : `(?<${identifier}>.+)`;
928
931
  }).replace(
929
- getOptionalPathParamPattern(),
932
+ createOptionalPathParamRegex(),
930
933
  (_match, leadingSlash, escape, identifier, trailingSlash) => {
931
934
  if (escape) {
932
935
  return `:${identifier}`;
@@ -945,12 +948,12 @@ function createParametrizedPathPattern(path) {
945
948
  return `(?<${identifier}>[^\\/]+?)?`;
946
949
  }
947
950
  }
948
- ).replace(getPathParamPattern(), (_match, escape, identifier) => {
951
+ ).replace(createPathParamRegex(), (_match, escape, identifier) => {
949
952
  return escape ? `:${identifier}` : `(?<${identifier}>[^\\/]+?)`;
950
953
  });
951
- return new RegExp(`^/?${replacedURL}/?$`);
954
+ return new RegExp(`^/?${pathRegexContent}/?$`);
952
955
  }
953
- var createParametrizedPathPattern_default = createParametrizedPathPattern;
956
+ var createRegexFromPath_default = createRegexFromPath;
954
957
 
955
958
  // ../zimic-utils/dist/url/excludeURLParams.mjs
956
959
  function excludeURLParams(url) {
@@ -1246,8 +1249,13 @@ var HttpInterceptorWorker = class _HttpInterceptorWorker {
1246
1249
  return HTTP_INTERCEPTOR_RESPONSE_HIDDEN_PROPERTIES.has(property);
1247
1250
  }
1248
1251
  static parseRawPathParams(request, options) {
1249
- const match = options?.pathPattern.exec(request.url.replace(options.baseURL, ""));
1250
- return { ...match?.groups };
1252
+ const requestPath = request.url.replace(options?.baseURL ?? "", "");
1253
+ const paramsMatch = options?.pathRegex.exec(requestPath);
1254
+ const params = {};
1255
+ for (const [paramName, paramValue] of Object.entries(paramsMatch?.groups ?? {})) {
1256
+ params[paramName] = typeof paramValue === "string" ? decodeURIComponent(paramValue) : void 0;
1257
+ }
1258
+ return params;
1251
1259
  }
1252
1260
  static async parseRawBody(resource) {
1253
1261
  const contentType = resource.headers.get("content-type");
@@ -1594,12 +1602,12 @@ var HttpInterceptorClient = class {
1594
1602
  return;
1595
1603
  }
1596
1604
  this.handlerClientsByMethod[handler.method].set(handler.path, handlerClients);
1597
- const pathPattern = createParametrizedPathPattern_default(handler.path);
1605
+ const pathRegex = createRegexFromPath_default(handler.path);
1598
1606
  const registrationResult = this.workerOrThrow.use(this, handler.method, handler.path, async (context) => {
1599
1607
  const response = await this.handleInterceptedRequest(
1600
1608
  handler.method,
1601
1609
  handler.path,
1602
- pathPattern,
1610
+ pathRegex,
1603
1611
  context
1604
1612
  );
1605
1613
  return response;
@@ -1608,10 +1616,10 @@ var HttpInterceptorClient = class {
1608
1616
  handler.registerSyncPromise(registrationResult);
1609
1617
  }
1610
1618
  }
1611
- async handleInterceptedRequest(method, path, pathPattern, { request }) {
1619
+ async handleInterceptedRequest(method, path, pathRegex, { request }) {
1612
1620
  const parsedRequest = await HttpInterceptorWorker_default.parseRawRequest(request, {
1613
1621
  baseURL: this.baseURLAsString,
1614
- pathPattern
1622
+ pathRegex
1615
1623
  });
1616
1624
  const matchedHandler = await this.findMatchedHandler(method, path, parsedRequest);
1617
1625
  if (!matchedHandler) {
@@ -1693,7 +1701,7 @@ var DuplicatedPathParamError = class extends Error {
1693
1701
  }
1694
1702
  };
1695
1703
  function validatePathParams(path) {
1696
- const pathParamMatches = path.toString().matchAll(getPathParamPattern());
1704
+ const pathParamMatches = path.toString().matchAll(createPathParamRegex());
1697
1705
  const uniqueParamNames = /* @__PURE__ */ new Set();
1698
1706
  for (const paramMatch of pathParamMatches) {
1699
1707
  const paramName = paramMatch.groups?.identifier;
@@ -1817,7 +1825,7 @@ var LocalHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
1817
1825
  const handler = {
1818
1826
  baseURL: interceptor.baseURLAsString,
1819
1827
  method,
1820
- pathPattern: createParametrizedPathPattern_default(path),
1828
+ pathRegex: createRegexFromPath_default(path),
1821
1829
  interceptor,
1822
1830
  createResponse: async (context) => {
1823
1831
  const request = context.request;
@@ -1854,7 +1862,7 @@ var LocalHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
1854
1862
  continue;
1855
1863
  }
1856
1864
  const requestPath = requestURLAsString.replace(handler.baseURL, "");
1857
- const matchesPath = handler.pathPattern.test(requestPath);
1865
+ const matchesPath = handler.pathRegex.test(requestPath);
1858
1866
  if (!matchesPath) {
1859
1867
  continue;
1860
1868
  }