import { RequireAtLeastOne } from 'type-fest'; import { DCRoute, DCService, DCUpstream } from './declarative-config'; import { Taggable } from './outputs'; export declare type XKongProperty = `x-kong-${Property}`; export declare const xKongName: XKongProperty<'name'>; export interface XKongName { [xKongName]?: string; } export declare const xKongRouteDefaults: XKongProperty<'route-defaults'>; export interface XKongRouteDefaults { [xKongRouteDefaults]?: Partial; } export declare const xKongUpstreamDefaults: XKongProperty<'upstream-defaults'>; export interface XKongUpstreamDefaults { [xKongUpstreamDefaults]?: Partial; } export declare const xKongServiceDefaults: XKongProperty<'service-defaults'>; export interface XKongServiceDefaults { [xKongServiceDefaults]?: Partial; } export declare type XKongPluginProperty = XKongProperty<`plugin-${Name}`>; export interface PluginBase extends Taggable { /** * Whether this plugin will be applied. * * @defaultValue true */ enabled?: boolean; /** The name of the plugin to use. */ name: Name; config?: Record; service?: { /** The ID of the Service the plugin targets. */ id: string; }; route?: { /** The ID of the Route the plugin targets. */ id: string; }; consumer?: { /** The ID of the Consumer the plugin targets. */ id: string; }; } /** * A plugin which is not associated to any service, route, or consumer is considered global, and will be run on every request. * * see: https://docs.konghq.com/hub/kong-inc/openid-connect/#enabling-the-plugin-globally */ export declare type GlobalPluginBase = Omit, 'service' | 'route' | 'consumer'>; /** used for user-defined or yet-untyped plugins */ export declare type XKongPlugin> = Partial, Plugin>>; export interface BodySchema { /** The request body schema specification */ body_schema: string; } export interface ParameterSchemaRequired { /** * The name of the parameter. Parameter names are case sensitive, and corresponds to the parameter name used by the in property. * * If in is "path", the name field MUST correspond to the named capture group from the configured route. */ name: string; /** * The location of the parameter. Possible values are query, header, or path. */ in: string; /** * Determines whether this parameter is mandatory. */ required: boolean; } export interface ParameterSchemaOptional { /** * Describes how the parameter value will be serialized depending on the type of the parameter value */ style: string; /** * The schema defining the type used for the parameter. * * It is validated using draft4 for JSONschema draft 4 compliant validator. */ schema: string; /** * When this is true, parameter values of type array or object generate separate parameters for each value of the array or key-value pair of the map. * * For other types of parameters this property has no effect. Permalink */ explode: boolean; } /** see: https://docs.konghq.com/hub/kong-inc/request-validator/#parameter-schema-definition */ export declare type ParameterSchema = ParameterSchemaRequired | (ParameterSchemaRequired & ParameterSchemaOptional); export interface ParameterSchemas { /** * Array of parameter validator specifications. For details and examples, see Parameter Schema Definition https://docs.konghq.com/hub/kong-inc/request-validator/#parameter-schema-definition. */ parameter_schema: ParameterSchema[]; } export declare const isBodySchema: (value?: Partial) => value is BodySchema; export declare const isParameterSchema: (value?: Partial) => value is ParameterSchemas; /** see: https://docs.konghq.com/hub/kong-inc/request-validator/#parameters */ export declare type RequestValidator = 'request-validator'; export interface RequestValidatorPlugin extends PluginBase { config: { /** * List of allowed content types. * * Note: Body validation is only done for application/json and skipped for any other allowed content types. * * @defaultValue application/json */ allowed_content_types?: string[]; /** * Which validator to use. * * Supported values are kong (default) for using Kong’s own schema validator, or draft4 for using a JSON Schema Draft 4-compliant validator. * * @defaultValue kong */ version?: 'draft4' | 'kong'; /** * If enabled, the plugin returns more verbose and detailed validation errors (for example, the name of the required field that is missing). * * @defaultValue false */ verbose_response?: boolean; } & RequireAtLeastOne; } export declare const xKongPluginRequestValidator: XKongPluginProperty; export declare type XKongPluginRequestValidator = XKongPlugin; /** see: https://docs.konghq.com/hub/kong-inc/key-auth/#parameters */ export declare type KeyAuth = 'key-auth'; export interface KeyAuthPlugin extends PluginBase { config: { /** * Describes an array of parameter names where the plugin will look for a key. * * The client must send the authentication key in one of those key names, and the plugin will try to read the credential from a header, request body, or query string parameter with the same name. * * Note: The key names may only contain [a-z], [A-Z], [0-9], [_] underscore, and [-] hyphen. * * @defaultValue apikey */ key_names: string[]; /** * If enabled, the plugin reads the request body (if said request has one and its MIME type is supported) and tries to find the key in it. * * Supported MIME types: application/www-form-urlencoded, application/json, and multipart/form-data. * * @defaultValue false */ key_in_body?: boolean; /** * If enabled (default), the plugin reads the request header and tries to find the key in it. * * @defaultValue true */ key_in_header?: boolean; /** * If enabled (default), the plugin reads the query parameter in the request and tries to find the key in it. * * @defaultValue true */ key_in_query?: boolean; /** * An optional boolean value telling the plugin to show or hide the credential from the upstream service. * * If true, the plugin strips the credential from the request (i.e., the header, query string, or request body containing the key) before proxying it. * * @defaultValue false */ hide_credentials?: boolean; /** * An optional string (Consumer UUID) value to use as an anonymous Consumer if authentication fails. * * If empty (default), the request will fail with an authentication failure 4xx. * * Note that this value must refer to the Consumer id attribute that is internal to Kong, and not its custom_id. */ anonymous?: string; /** * A boolean value that indicates whether the plugin should run (and try to authenticate) on OPTIONS preflight requests. * * If set to false, then OPTIONS requests are always allowed. * * @defaultValue true */ run_on_preflight?: boolean; }; } export declare const xKongPluginKeyAuth: XKongPluginProperty; export declare type XKongPluginKeyAuth = XKongPlugin; /** see: https://docs.konghq.com/hub/kong-inc/request-termination/#parameters */ export declare type RequestTermination = 'request-termination'; export interface RequestTerminationPlugin extends PluginBase { config?: { /** * the response code to send * * must be an integer between 100 and 599 */ status_code?: number; /** the message to send, if using the default response generator */ message?: string; /** * the raw response body to send * * this is mutually exclusive with the config.message field */ body?: string; /** * content type of the raw response configured with `config.body` * * @defaultValue application/json; charset=utf-8 */ content_type?: string; }; } export declare const xKongPluginRequestTermination: XKongPluginProperty; export declare type XKongPluginRequestTermination = XKongPlugin; /** see: https://docs.konghq.com/hub/kong-inc/basic-auth/#parameters */ export declare type BasicAuth = 'basic-auth'; export interface BasicAuthPlugin extends Omit, 'consumer'> { config?: { /** * An optional boolean value telling the plugin to show or hide the credential from the upstream service. * * If true, the plugin will strip the credential from the request (i.e. the Authorization header) before proxying it. * * @defaultValue false */ hide_credentials?: boolean; /** * An optional string (consumer uuid) value to use as an “anonymous” consumer if authentication fails. * * If empty (default), the request will fail with an authentication failure 4xx. * * Please note that this value must refer to the Consumer id attribute which is internal to Kong, and not its custom_id. */ anonymous?: string; }; } export declare const xKongBasicAuth: XKongPluginProperty; export declare type XKongBasicAuthPlugin = XKongPlugin; export declare type AuthMethod = 'password' | 'client_credentials' | 'authorization_code' | 'bearer' | 'introspection' | 'kong_oauth2' | 'refresh_token' | 'session'; export declare type OpenIDConnect = 'openid-connect'; /** * Note: These types are incomplete, as there are dozens of parameters for the config. * * Note: This is a global plugin, not associated to any service, route, or consumer. * * see: https://docs.konghq.com/hub/kong-inc/openid-connect/#parameter-descriptions */ export interface OpenIDConnectPlugin extends GlobalPluginBase { enabled?: boolean; config?: { issuer?: string; scopes_required?: string[]; auth_methods?: AuthMethod[]; }; } export declare const xKongOpenIDConnect: XKongPluginProperty; export declare type XOpenIDConnectPlugin = XKongPlugin; export declare type Plugin = RequestValidatorPlugin | KeyAuthPlugin | RequestTerminationPlugin | BasicAuthPlugin | OpenIDConnectPlugin; //# sourceMappingURL=kong.d.ts.map