Augments the CLI spec to add all pure runtime properties, that can be defined through the configuration file only

interface ConfigurationSpec {
    console?: ConsoleSpec;
    delay?: Delay;
    harFileCacheTime?: number;
    harMimeTypesParseJson?: string[];
    hostname?: string;
    http2?: boolean;
    mocksFolder?: string;
    mocksFormat?: MocksFormat;
    mocksHarFile?: string;
    mocksHarKeyManager?: HarKeyManager;
    mode?: Mode;
    port?: number;
    proxyConnectMode?: ProxyConnectMode;
    remoteURL?: null | string;
    saveChecksumContent?: boolean;
    saveDetailedTimings?: boolean;
    saveForwardedRequestBody?: null | boolean;
    saveForwardedRequestData?: null | boolean;
    saveInputRequestBody?: boolean;
    saveInputRequestData?: boolean;
    skipLog?: boolean;
    tlsCAKeyPath?: null | string;
    tlsKeySize?: number;
    hook?(parameters): void | Promise<void>;
    onExit?(): void;
    onListen?(parameters): void;
    onProxyConnect?(parameters): void | Promise<void>;
}

Hierarchy

Properties

console?: ConsoleSpec

Custom implementation of the ConsoleSpec interface, with methods log and error, each receiving one single argument of any type. Useful to capture the logs of the application.

delay?: Delay

The default delay.

Remarks

It can be changed at request level in the hook method through mock.setDelay.

harFileCacheTime?: number

Time in milliseconds during which a har file is kept in memory after its last usage.

harMimeTypesParseJson?: string[]

Used only when the mocks format is 'har', specifies a list of mime types that will attempt to parse the request/response body as JSON. If the list includes an empty string: '' and there is no mimeType set in the request, it will attempt to parse the body as JSON. This will only be applicable to request bodies if saveInputRequestBody is set to true Default value will be [] and will only be overridden by setHarMimeTypesParseJson

hostname?: string

The hostname on which the proxy should listen. Uses 127.0.0.1 by default, which only allows local connections. To allow remote connections, use the ip address of the specific network interface that should be allowed to connect or the unspecified IPv4 (0.0.0.0) or IPv6 (::) address.

Remarks

Note that kassette has not been reviewed for security issues. It is intended to be used in a safe local/testing environment. Binding it to an open connection can result in compromising your computer or your network.

http2?: boolean

Enables http/2.0 protocol in the kassette server.

mocksFolder?: string

When the mocks format is 'folder', specifies the default root folder of all mocks, from which specific mocks paths will be resolved.

Remarks

It can be changed at a request level in the hook method through mock.setMocksFolder.

mocksFormat?: MocksFormat

The default mocks format.

Remarks

It can be changed at request level in the hook method through mock.setMocksFormat.

The default value of the global mocksFormat setting is folder, except in the following case: if the global mocksHarFile setting is defined and the global mocksFolder setting is not defined, then the default value of the global mocksFormat setting is har.

mocksHarFile?: string

When the mocks format is 'har', specifies the default har file to use. If the file name has the .yml or .yaml extension, the YAML format is used instead of the standard JSON format to read and write the file.

Remarks

It can be changed at a request level in the hook method through mock.setMocksHarFile.

mocksHarKeyManager?: HarKeyManager

Function called to get or set the key of a mock in a har file, as explained in HarKeyManager.

Remarks

It can be changed at a request level in the hook method through mock.setMocksHarKeyManager.

mode?: Mode

The default mode.

Remarks

It can be changed at request level in the hook method through mock.setMode.

port?: number

The port on which the proxy should listen. Note that kassette accepts both http and https connections on this port.

Remarks

If the port is not available, it will fail and stop the program; try again with another, available port. If the port is set to 0, the proxy will listen on a random port (actually depends on the OS implementation): use the callback onListen to catch its value.

proxyConnectMode?: ProxyConnectMode

Default mode for CONNECT requests.

Remarks

It can be changed at a request level in the onProxyConnect method through setMode.

remoteURL?: null | string

The URL of the remote backend, from which only the protocol, hostname and port are used. Can be left null, in which case anything leading to sending the request to the remote backend will trigger an exception. Can also contain the special "*" value, which means reading from the request the remote backend to target. This is useful when using kassette as a browser proxy.

Remarks

It can be changed at a request level in the hook method through mock.setRemoteURL.

saveChecksumContent?: boolean

Whether to save the content used to create a checksum when creating a new mock with a checksum.

Remarks

The default value of the global saveChecksumContent setting is true.

It can be changed at request level in the hook method through mock.setSaveChecksumContent.

saveDetailedTimings?: boolean

Whether to save detailed timings when creating a new mock.

Remarks

The default value of the global saveDetailedTimings setting is true.

It can be changed at request level in the hook method through mock.setSaveDetailedTimings.

saveForwardedRequestBody?: null | boolean

Whether to save the forwarded request body when creating a new mock.

Remarks

The default value of the global saveForwardedRequestData setting is null, which means true when mocksFormat is folder (for backward-compatibility), and false when mocksFormat is har.

It can be changed at request level in the hook method through mock.setSaveForwardedRequestBody.

saveForwardedRequestData?: null | boolean

Whether to save the forwarded request data (headers, method, URL) when creating a new mock.

Remarks

The default value of the global saveForwardedRequestData setting is null, which means true when mocksFormat is folder (for backward-compatibility), and false when mocksFormat is har.

It can be changed at request level in the hook method through mock.setSaveForwardedRequestData.

saveInputRequestBody?: boolean

Whether to save the content of the input request body when creating a new mock.

Remarks

The default value of the global saveInputRequestBody setting is true.

It can be changed at request level in the hook method through mock.setSaveInputRequestBody.

saveInputRequestData?: boolean

Whether to save the input request data (headers, method, URL) when creating a new mock.

Remarks

The default value of the global saveInputRequestData setting is true.

It can be changed at request level in the hook method through mock.setSaveInputRequestData.

skipLog?: boolean

If true, will simplify the logging output, logging only one line when the request is received but nothing else afterwards.

tlsCAKeyPath?: null | string

Path to a PEM-encoded CA (Certificate Authority) certificate and key file, created if it does not exist. If not provided, the certificate and key are generated but only kept in memory. This certificate and key are used as needed to sign certificates generated on the fly for any HTTPS connection intercepted by kassette.

Remarks

You can optionally import in the browser the TLS certificate from this file in order to remove the warning when connecting to HTTPS websites through kassette.

tlsKeySize?: number

Size in bits of generated RSA keys.

Methods

  • Callback called for every HTTP request that kassette receives (with the exception of CONNECT requests, which trigger the call of onProxyConnect instead).

    Parameters

    • parameters: HookAPI

      exposes the API to control how to process the request

    Returns void | Promise<void>

  • Callback called when the proxy is started and listening.

    Parameters

    • parameters: {
          port: number;
      }

      the port property contains the port on which the proxy is listening.

      • port: number

    Returns void

  • Callback called when kassette receives a request with the CONNECT method, which usually happens when kassette is used as a browser proxy and the browser is trying to connect to a secure web site with the https protocol.

    Parameters

    • parameters: IProxyConnectAPI

      exposes the API to control how to process the request

    Returns void | Promise<void>

Generated using TypeDoc