Insomnia-Script-SDK-Docs
    Preparing search index...

    Class ProxyConfig

    Represents a proxy configuration object used to define the settings for a proxy server.

    This class provides methods to construct, update, and test proxy configurations, as well as retrieve information such as the proxy URL and supported protocols.

    The proxy configuration includes properties such as the host, port, authentication credentials, tunneling options, and bypass list.

    Hierarchy (View Summary)

    Index

    Constructors

    • Constructs a new instance of the proxy configuration object.

      Parameters

      • def: {
            authenticate: boolean;
            bypass?: string[];
            disabled?: boolean;
            host: string;
            id?: string;
            match: string;
            name?: string;
            password: string;
            port?: number;
            protocol: string;
            tunnel: boolean;
            username: string;
        }

        The definition object containing the proxy configuration properties.

        • authenticate: boolean

          Indicates whether the proxy requires authentication.

        • Optionalbypass?: string[]

          (Optional) A list of hosts to bypass the proxy.

        • Optionaldisabled?: boolean

          (Optional) Indicates whether the proxy configuration is disabled.

        • host: string

          The host address of the proxy server.

        • Optionalid?: string

          (Optional) The unique identifier for the proxy configuration.

        • match: string

          The match pattern for the proxy configuration. It is used to initialize the UrlMatchPattern object internally.

        • Optionalname?: string

          (Optional) The name of the proxy configuration.

        • password: string

          The password for proxy authentication.

        • Optionalport?: number

          (Optional) The port number of the proxy server.

        • protocol: string

          The protocol used by the proxy (e.g., HTTP, HTTPS).

        • tunnel: boolean

          Indicates whether the proxy uses tunneling.

        • username: string

          The username for proxy authentication.

      Returns ProxyConfig

    Properties

    _parent: undefined | PropertyBase = undefined

    A reference to the parent property, if any. This allows for hierarchical relationships between properties. If no parent exists, the value will be undefined.

    authenticate: boolean

    Indicates whether authentication is required for the proxy configuration.

    bypass: string[]

    A list of hostnames or IP addresses to bypass the proxy for.

    description?: string

    An optional description providing additional details or context.

    disabled?: boolean

    Indicates whether the property is disabled. When set to true, the property is considered inactive or unavailable.

    host: string

    The hostname or IP address of the proxy server.

    id: string

    A unique identifier represented as a string.

    match: string

    A string pattern used to match specific criteria or conditions. This can be used for filtering or identifying relevant configurations.

    name?: string

    The optional name property. This can be used to specify a name or identifier.

    password: string

    The password associated with the proxy configuration.

    port?: number

    The port number to be used for the proxy configuration. This is an optional property and, if not specified, the default port for the protocol being used will be applied.

    protocol: string

    The protocol used in the proxy configuration, such as "http" or "https".

    tunnel: boolean
    username: string

    The username associated with the proxy configuration.

    _index: string = 'key'

    Methods

    • Traverses up the parent hierarchy to find an ancestor that contains the specified property. Optionally, a customizer function can be provided to determine if the ancestor should be returned.

      Parameters

      • property: string

        The name of the property to search for in the ancestors.

      • Optionalcustomizer: (ancester: PropertyBase) => boolean

        An optional function that takes an ancestor as input and returns a boolean. If provided, the traversal continues until the customizer returns a truthy value. If not provided, the traversal stops at the first ancestor that contains the property.

      Returns undefined | PropertyBase

      The first ancestor that satisfies the search criteria, or undefined if no such ancestor is found.

    • Iterates through the parent hierarchy of the current object, starting from its immediate parent. The iteration continues until the provided iterator function returns false or there are no more parents.

      Parameters

      • options: { withRoot?: boolean }

        Options to control the iteration behavior.

        • withRoot (optional): A flag to include the root object in the iteration.
      • iterator: (obj: PropertyBase) => boolean

        A callback function that is invoked for each parent object in the hierarchy.

        • The function receives a cloned instance of the parent object as its argument.
        • If the function returns false, the iteration stops.

      Returns undefined | PropertyBase | PropertyBase[]

      An array of cloned parent objects that were iterated over.

    • Retrieves the list of protocols specified in the match pattern.

      The match pattern is expected to follow a format such as 'http+https://example.com/*', where protocols are separated by a '+'. This method parses the match pattern and extracts the protocols.

      Returns string[]

      An array of protocol strings extracted from the match pattern.

    • Constructs and returns the full proxy URL as a string.

      The URL is built based on the protocol, host, port, and optional authentication credentials (username and password) of the proxy.

      Returns string

      The full proxy URL in the format:

      • With authentication: protocol://username:password@host:port
      • Without authentication: protocol://host:port
    • Tests whether a given URL matches the proxy configuration.

      Parameters

      • Optionalurl: string

        The URL to test. If not provided, the method will return false.

      Returns boolean

      true if the URL matches the proxy configuration and is not bypassed; otherwise, false.

    • Updates the proxy configuration with the provided options.

      Parameters

      • options: Omit<ProxyConfigOptions, "bypass" | "protocol">

        An object containing the new proxy configuration options. The bypass and protocol properties are omitted and cannot be updated. The following properties can be updated: - host: The hostname or IP address of the proxy server. - match: A pattern to match URLs for which the proxy should be used. - port: The port number of the proxy server. - tunnel: A boolean indicating whether to use tunneling. - authenticate: A boolean indicating whether authentication is required. - username: The username for proxy authentication. - password: The password for proxy authentication.

      Returns void

    • Updates the list of protocols. Currently this method is not supported in Insomnia

      Parameters

      • _protocols: string[]

        An array of protocol strings to update.

      Returns void

      Always throws an error indicating that this method is not supported.

    • Determines if a given property key is considered a "meta" property. In the context of Insomnia, meta properties are defined as those that start with an underscore (_). The underscore character itself is also rejected as a valid meta property key.

      Parameters

      • _value: any

        The value associated with the property (currently unused in this method).

      • key: string

        The property key to evaluate.

      Returns boolean | ""

      true if the key starts with an underscore (_), otherwise false.

    • Replaces placeholders in the given content string with values from the provided variables. The placeholders are resolved using an interpolation mechanism, and the variables are merged in reverse order to determine the final context for substitution.

      Parameters

      • content: string

        The string containing placeholders to be replaced.

      • ...variables: object[]

        A list of objects containing key-value pairs for substitution. The objects are merged in reverse order to form the final context.

      Returns string

      The content string with placeholders replaced by corresponding values from the context.

      If the content parameter is not a string or if variables is not an array.

    • Replaces substitutions in the given object using the provided variables.

      This method takes an object and a list of variable objects, and replaces placeholders in the object with corresponding values from the variables. The variables are merged in reverse order, meaning the last variable in the list has the highest priority.

      Parameters

      • obj: object

        The object containing placeholders to be replaced.

      • ...variables: object[]

        A list of objects containing substitution values.

      Returns object

      A new object with substitutions replaced.

      If the first parameter is not an object or if the variables are not provided as an array.

      If an error occurs during the substitution process.