"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.INTER_PROCCES_SIGNAL_MESSAGE = exports.INVOKE_ACTIONS = exports.INVOKE_SOURCES = exports.FAR_FUTURE_TTL = exports.DEFLATE_ENCODING = exports.GZIP_ENCODING = exports.BROTLI_ENCODING = exports.IS_BROWSER = exports.EDGIO_CACHE_MANIFEST_RULE_IGNORE_COMMENT = exports.EDGIO_PREFETCH_CDN_SW_PATH = exports.EDGIO_PREFETCH_CDN_PATH = exports.EDGIO_PREFETCH_CDN_BASE_PATH = exports.EDGIO_CACHE_MANIFEST_JS_VAR_NAME = exports.EDGIO_CACHE_MANIFEST_PATH = exports.HOSTS_NOINDEX_PERMALINK_REGEX = exports.ROUTES_NOINDEX_GROUP = exports.ROUTES_CATCH_GROUP = exports.ROUTES_FALLBACK = exports.METHOD_QUERY_PARAM = exports.POST_BODY_QUERY_PARAM = exports.HEAD_QUERY_PARAM = exports.DEVTOOLS_PREFETCH_QUERY_PARAM = exports.PREFETCH_TTL_PARAM = exports.PREFETCH_QUERY_PARAM = exports.THROTTLED_QUERY_PARAM = exports.CACHING_DEBUG_CACHEABLE = exports.CACHING_DEBUG_STATUS = exports.CACHING_DEBUG_HEADERS = exports.CACHEABLE_METHODS = exports.CACHING_STATUS = exports.HTTP_HEADERS = exports.HTTP_METHODS = exports.JS_BACKEND_HOSTNAME = exports.BACKENDS = exports.ACTIONS = exports.EDGIO_VIA_HEADER_VALUE = exports.EDGIO_MAX_NESTED_REQUESTS = exports.EDGIO_UNCACHED_PREFETCH_STATUS = exports.EDGIO_TOO_MANY_HEADERS_STATUS_CODE = exports.EDGIO_MAX_USER_HEADERS_ALLOWED = exports.EDGIO_CLOUD_FUNCTIONS_HINTS = exports.EDGIO_CLOUD_FUNCTIONS_HINT_HEADER = exports.EDGIO_HEADERS_PREFIX = exports.EDGIO_DEPLOYMENT_TYPE_AWS = exports.EDGIO_EDGE_FUNCTION_DEFAULT_VERSION = exports.EDGIO_EDGE_FUNCTION_ENV_VARIABLES = exports.EDGIO_ENV_VARIABLES = exports.EDGIO_ASSET_ALIASES_FILE = exports.EDGIO_CONFIG_FILE = void 0;
/**
 * Edgio configuration file name.
 */
exports.EDGIO_CONFIG_FILE = 'edgio.config.js';
/**
 * Indicate asset files that need to be uploaded under a different
 * bucket key.
 * It contains values like
 * {
 *   '/posts' => '/posts/index.html'
 * }
 */
exports.EDGIO_ASSET_ALIASES_FILE = 'asset-aliases.json';
/**
 * Environment variables used by Edgio.
 */
exports.EDGIO_ENV_VARIABLES = {
    /**
     * Edgio configuration environment variable key.
     */
    config: 'EDGIO_CONFIG',
    /**
     * Edgio internal configuration environment variable key.
     */
    internalConfig: 'EDGIO_INTERNAL_CONFIG',
    /**
     * Indicates whether code is running locally or in the cloud.
     * @private
     */
    deploymentType: 'EDGIO_DEPLOYMENT_TYPE',
    /**
     * Allows Edgio development team to easily override Edgio version
     * during development process.
     * @private
     */
    versionOverride: 'EDGIO_VERSION_OVERRIDE',
    /**
     * Indicates that we are running a production build.
     * @private
     */
    productionBuild: 'EDGIO_PRODUCTION_BUILD',
    /**
     * Indicates that we are running app locally.
     * @private
     */
    local: 'EDGIO_LOCAL',
    /**
     * Turns on the cache when set to 'true'.
     * @private
     */
    cache: 'EDGIO_CACHE',
    /**
     * The hostname of currently used permalink.
     * @private
     */
    permalinkHost: 'EDGIO_PERMALINK_HOST',
    /**
     * The image optimizer host.
     * This is same as the permalink host, but it's used for old image optimizer.
     * @deprecated This will be replaced by EDGIO_PERMALINK_HOST when console-api changes are released.
     * @private
     */
    imageOptimizerHost: 'EDGIO_IMAGE_OPTIMIZER_HOST',
};
/**
 * Environment variables used by Edgio Edge Functions.
 */
exports.EDGIO_EDGE_FUNCTION_ENV_VARIABLES = {
    /**
     * The path to the edge function within the project.
     */
    path: '__EDGE_FUNCTION_PATH__',
    /**
     * The edge function's QuickJS bytecode (base64 encoded).
     */
    quickjsBytecodeBase64: '__EDGE_FUNCTION_QUICKJS_BYTECODE_BASE64__',
    /**
     * When 'enabled' turn on edge function debugging.
     */
    debug: 'debug',
};
/**
 * The default version of edge functions to use.
 * @private
 */
exports.EDGIO_EDGE_FUNCTION_DEFAULT_VERSION = 2;
/**
 * Indicates that code is running in AWS.
 * @private
 */
exports.EDGIO_DEPLOYMENT_TYPE_AWS = 'AWS';
/**
 * Prefix of all Edgio headers.
 */
exports.EDGIO_HEADERS_PREFIX = 'x-edg-';
/**
 * Instructs the runtime to forward the request directly to the user's app or a function rather than processing
 * edge-control rules.
 * @private
 */
exports.EDGIO_CLOUD_FUNCTIONS_HINT_HEADER = 'x-cloud-functions-hint';
/**
 * Instructs the runtime to forward the request directly one of the router's functions by hint name.
 * @private
 */
exports.EDGIO_CLOUD_FUNCTIONS_HINTS = {
    // Instructs the runtime to forward the request directly to the user's app.
    app: 'app',
    // Instructs the runtime to forward the request directly one of the router's functions by index.
    compute: 'compute',
    // Instructs the runtime to invoke a compute that will execute a redirect and return early.
    redirect: 'redirect',
    // Instructs the runtime to invoke a compute that will execute a redirect and return early.
    proxy: 'proxy',
};
/**
 * Maximum number of user headers allowed by Edgio platform.
 *
 * We limit the request and response headers allowed to 70. This is due to a limitation that edge has
 * which at the moment supports up to 96 headers. Edge provider itself needs to use some of those headers
 * with the remainder used by our edge code.
 *
 * NOTE: This constant must be equal ot the constant of the same name defined in Edgio buffer proxy.
 * NOTE: If this constant is updated then the constant of the same name has to be updated in @edgio/build-lambda module.
 */
exports.EDGIO_MAX_USER_HEADERS_ALLOWED = 70;
/**
 * Status code returned when there are too many request or response headers.
 *
 * Must be equal to HeaderOverflowError status code as defined in build lambda and Edgio buffer proxy.
 */
exports.EDGIO_TOO_MANY_HEADERS_STATUS_CODE = 542;
/**
 * The status code returned when the edgio_prefetch query param is present and a response could not be found in the cache.
 */
exports.EDGIO_UNCACHED_PREFETCH_STATUS = 412;
/**
 * The maximum number of nested requests allowed by Edgio platform,
 * where a site is the upstream of itself or another site.
 * If this limit is exceeded, the request will be terminated with a 538 status code,
 * to prevent infinite loops and generating excessive traffic.
 */
exports.EDGIO_MAX_NESTED_REQUESTS = 3;
/**
 * The value that is appended to the 'Via' header
 * everytime request goes through the @edgio/core.
 */
exports.EDGIO_VIA_HEADER_VALUE = 'Edgio Core';
/**
 * CDN-as-code configuration actions
 */
exports.ACTIONS = {
    setHeader: 'set-header',
    updateHeader: 'update-header',
    removeHeader: 'remove-header',
    syntheticRes: 'synthetic-response',
    updatePath: 'update-path',
    proxy: 'proxy',
    addCookie: 'add-cookie',
    updateCookie: 'update-cookie',
    removeCookie: 'remove-cookie',
};
/**
 * The backend for cloud functions
 */
exports.BACKENDS = {
    js: '__js__',
    static: '__static__',
    permanentStatic: '__permanent_static__',
    imageOptimizer: '__image_optimizer__',
};
/**
 * The hostname used for the internal service running the user's application.
 */
exports.JS_BACKEND_HOSTNAME = '127.0.0.1';
exports.HTTP_METHODS = {
    head: 'head',
    get: 'get',
    post: 'post',
    delete: 'delete',
    put: 'put',
    patch: 'patch',
    options: 'options',
};
/**
 * Common HTTP headers.
 */
exports.HTTP_HEADERS = {
    accept: 'accept',
    acceptCh: 'accept-CH',
    acceptEncoding: 'accept-encoding',
    authorization: 'authorization',
    cacheControl: 'cache-control',
    contentEncoding: 'content-encoding',
    contentLength: 'content-length',
    contentType: 'content-type',
    cookie: 'cookie',
    expires: 'expires',
    host: 'host',
    location: 'location',
    range: 'range',
    serverTiming: 'server-timing',
    setCookie: 'set-cookie',
    userAgent: 'user-agent',
    vary: 'vary',
    via: 'via',
    transferEncoding: 'transfer-encoding',
    strictTransportSecurity: 'strict-transport-security',
    referrerPolicy: 'referrer-policy',
    featurePolicy: 'feature-policy',
    xHost: 'x-host',
    xEcPop: 'x-ec-pop',
    xEcDebug: 'x-ec-debug',
    xForwardedFor: 'x-forwarded-for',
    xForwardedProto: 'x-forwarded-proto',
    xForwardedPort: 'x-forwarded-port',
    xFrameOptions: 'x-frame-options',
    xXssProtection: 'x-xss-protection',
    xContentTypeOptions: 'x-content-type-options',
    xRequestId: 'x-request-id',
    xSwCacheControl: 'x-sw-cache-control',
    xEdgeBrowser: 'x-edg-browser',
    xEdgeCacheControl: 'x-edg-cache-control',
    xEdgeCachingStatus: 'x-edg-caching-status',
    xEdgeClientIp: 'x-edg-client-ip',
    xEdgeComponents: 'x-edg-components',
    xEdgeDestination: 'x-edg-destination',
    xEdgeDevice: 'x-edg-device',
    xEdgeDeviceIsBot: 'x-edg-device-is-bot',
    xEdgeGeoCity: 'x-edg-geo-city',
    xEdgeGeoCountryCode: 'x-edg-geo-country-code',
    xEdgeGeoLatitude: 'x-edg-geo-latitude',
    xEdgeGeoLongitude: 'x-edg-geo-longitude',
    xEdgeGeoPostalCode: 'x-edg-geo-postal-code',
    xEdgeMatchedRoutes: 'x-edg-matched-routes',
    xEdgeProtocol: 'x-edg-protocol',
    xEdgeRoute: 'x-edg-route',
    xEdgeStatus: 'x-edg-status',
    xEdgeSurrogateKey: 'x-edg-surrogate-key',
    xEdgeT: 'x-edg-t',
    xEdgeUserT: 'x-edg-user-t',
    xEdgeVendor: 'x-edg-vendor',
    xEdgeVersion: 'x-edg-version',
    xEdgServerlessError: 'x-edg-serverless-error',
    xEdgInvokeSource: 'x-edg-invoke-source',
    xEdgInvokeAction: 'x-edg-invoke-action',
    xEdgErrorMessage: 'x-edg-error-message',
    xEdgErrorDetails: 'x-edg-error-details',
    xEdgErrorLevel: 'x-edg-error-level',
    xEdgRawUrl: 'x-edg-raw-url',
    xCloudFunctionsHint: exports.EDGIO_CLOUD_FUNCTIONS_HINT_HEADER,
    x0ClientIp: 'x-0-client-ip',
    x0Protocol: 'x-0-protocol',
    x0Version: 'x-0-version',
    xEcEdgeIoDebug: 'x-ec-edgeio-debug',
    xEcEdgeIoDisable: 'x-ec-edgeio-disable',
    xEdgeIoInfo: 'x-edgeio-info',
    xEdgeIoStatus: 'x-edgeio-status',
    xEdgeIoError: 'x-edgeio-error',
    xEcUUID: 'x-ec-uuid',
};
/**
 * Values for x-edg-caching-status
 */
exports.CACHING_STATUS = {
    cached: 'cached',
    hit: 'hit',
    bypassed: 'bypassed',
    private: 'private',
    method: 'method',
    bodyTooBig: 'body-too-big',
    code: 'code',
    setCookie: 'set-cookie',
    noMaxAge: 'no-max-age',
};
exports.CACHEABLE_METHODS = new Set(['get', 'head']);
/**
 * Values for x-edg-caching-status
 */
exports.CACHING_DEBUG_HEADERS = {
    cache: 'x-ec-cache',
    checkCacheable: 'x-ec-check-cacheable',
    cacheState: 'x-ec-cache-state',
    cacheKey: 'x-ec-cache-key',
};
// Caching debug status codes.
// https://docs.edgecast.com/cdn/Content/Reference/Cache_Status_Codes.htm
exports.CACHING_DEBUG_STATUS = {
    configNoCache: 'CONFIG_NOCACHE',
    none: 'NONE',
    tcpClientRefreshMiss: 'TCP_CLIENT_REFRESH_MISS',
    tcpExpiredHit: 'TCP_EXPIRED_HIT',
    tcpExpiredMiss: 'TCP_EXPIRED_MISS',
    tcpHit: 'TCP_HIT',
    tcpMiss: 'TCP_MISS',
    tcpPartialHit: 'TCP_PARTIAL_HIT',
    uncacheable: 'UNCACHEABLE',
};
exports.CACHING_DEBUG_CACHEABLE = {
    yes: 'YES',
    no: 'NO',
};
/**
 * When present, this query parameter will cause Edgio to return a 412 status
 * if a response could not be found in the cache.
 */
exports.THROTTLED_QUERY_PARAM = 'edgio_prefetch';
/**
 * Same value as above but DEPRECATED.
 */
exports.PREFETCH_QUERY_PARAM = exports.THROTTLED_QUERY_PARAM;
/**
 Adds query parameter with custom maxAgeSecond value for service-worker cache if it's specified in PrefetchConfiguration
 */
exports.PREFETCH_TTL_PARAM = 'edgio_prefetch_ttl';
/**
 Labels the request so that devtools will display as prefetched
 */
exports.DEVTOOLS_PREFETCH_QUERY_PARAM = 'edgio_dt_pf';
/**
 * The name of the query parameter used to detect HEAD requests.
 */
exports.HEAD_QUERY_PARAM = 'edgio_head';
/**
 * The name of the query parameter used for the body of POST requests, which is used for the cache key
 */
exports.POST_BODY_QUERY_PARAM = 'pref_edgio_body';
/**
 * The name of the query parameter used for the method of requests, which is used for the cache key
 */
exports.METHOD_QUERY_PARAM = 'pref_edgio_method';
/**
 * Route Group name, which is used in router for fallback routes
 */
exports.ROUTES_FALLBACK = 'fallback';
/**
 * Route Group name, which is used in router for error page routes
 */
exports.ROUTES_CATCH_GROUP = 'catch';
/**
 * Route Group name, which is used in router for noindex routes
 */
exports.ROUTES_NOINDEX_GROUP = 'noindex';
/**
 * Regex used to determine if the host should be excluded from
 * SE indexing
 */
exports.HOSTS_NOINDEX_PERMALINK_REGEX = /\.edgio\.link|\.edgio-perma\.link/;
/**
 * The path where cache-manifest file is served by built-in rule.
 * Connascence of value with console-api/app/services/cache_manifest/constants.rb
 */
exports.EDGIO_CACHE_MANIFEST_PATH = '/__edgio__/cache-manifest.js';
/**
 * The name of the JS global constant which contains the cache-manifest content
 * when cache-manifest is imported as a script to site.
 * Connascence of value with console-api/app/services/cache_manifest/constants.rb
 */
exports.EDGIO_CACHE_MANIFEST_JS_VAR_NAME = '__EDGIO_CACHE_MANIFEST__';
/**
 * The base path of the URL where the install.js file of @edgio/prefetch is served from CDN.
 * Connascence of value with console-api/app/services/edge_control/internal_config.rb
 */
exports.EDGIO_PREFETCH_CDN_BASE_PATH = '/__edgio__/prefetch';
/**
 * The path in express style where the install.js file of @edgio/prefetch is served from CDN.
 * Connascence of value with console-api/app/services/edge_control/internal_config.rb
 * @example /__edgio__/prefetch/install.js
 * @example /__edgio__/prefetch/v7.2.2/install.js
 */
exports.EDGIO_PREFETCH_CDN_PATH = `${exports.EDGIO_PREFETCH_CDN_BASE_PATH}/:path*`;
/**
 * The path in express style where the service-worker file of @edgio/prefetch is served from CDN.
 * Connascence of value with console-api/app/services/edge_control/internal_config.rb
 * @example /__edgio__service_worker_v7.2.2.js
 */
exports.EDGIO_PREFETCH_CDN_SW_PATH = '/__edgio__service_worker_:version.js';
/**
 * The value of cache-manifest rule comment which indicates that the rule should be ignored when
 * building cache-manifest by console-api. This allows customers to exclude certain rules from it.
 * We simulate it here in @edgio/core to provide the same experience in local simulation.
 * Connascence of value with console-api/app/services/cache_manifest/cache_manifest_builder.rb
 */
exports.EDGIO_CACHE_MANIFEST_RULE_IGNORE_COMMENT = 'cache-manifest-ignore';
/**
 * Is current environment 'browser'
 */
exports.IS_BROWSER = typeof window !== 'undefined';
/**
 * Brotli encoding code.
 */
exports.BROTLI_ENCODING = 'br';
/**
 * Gzip encoding code.
 */
exports.GZIP_ENCODING = 'gzip';
/**
 * Deflate encoding code.
 */
exports.DEFLATE_ENCODING = 'deflate';
/**
 * One year in seconds
 */
exports.FAR_FUTURE_TTL = '1y';
exports.INVOKE_SOURCES = {
    functionUrl: 'function-url',
    console: 'console',
    bufferProxy: 'buffer-proxy',
};
exports.INVOKE_ACTIONS = {
    getEdgeConfig: 'getEdgeConfig',
    getPreloadConfig: 'getPreloadConfig',
    serverless: 'serverless',
    simulator: 'simulator',
};
// this is used to signal the handler.ts that the server is ready
// we use unique string to avoid any conflicts with outputs from other processes
exports.INTER_PROCCES_SIGNAL_MESSAGE = '<.!$@,<*#-%';
