UNPKG

azion

Version:

Azion Packages for Edge Computing.

1 lines 68.4 kB
var V=["args","device_group","domain","geoip_city","geoip_city_continent_code","geoip_city_country_code","geoip_city_country_name","geoip_continent_code","geoip_country_code","geoip_country_name","geoip_region","geoip_region_name","host","remote_addr","remote_port","remote_user","request","request_body","request_method","request_uri","scheme","uri"],qe=["server_addr","server_port"],Pe=["ssl_client_fingerprint","ssl_client_escaped_cert","ssl_client_s_dn","ssl_client_s_dn_parsed","ssl_client_cert","ssl_client_i_dn","ssl_client_serial","ssl_client_v_end","ssl_client_v_remain","ssl_client_v_start","ssl_client_verify"],Oe=["sent_http_name","status","tcpinfo_rtt","upstream_addr","upstream_status"],$=["cookie_time_offset","encode_base64"],M=[...V,...qe,...Pe],w=[...V,...Oe];var f=["is_equal","is_not_equal","starts_with","does_not_start_with","matches","does_not_match"],y=["exists","does_not_exist"],T=["if","and","or"],H=["arg_[a-zA-Z0-9_]+","cookie_[a-zA-Z0-9_]+","http_[a-zA-Z0-9_]+","sent_http_[a-zA-Z0-9_]+","upstream_cookie_[a-zA-Z0-9_]+","upstream_http_[a-zA-Z0-9_]+"],C=[...new Set([...M,...w])],U=["deny","drop","set_rate_limit","set_waf_ruleset","run_function","tag_event","set_custom_response"],h=["second","minute"],b=["clientIp","global"],E=["learning","blocking"],v=["header_accept","header_accept_encoding","header_accept_language","header_cookie","header_origin","header_referer","header_user_agent","host","network","request_args","request_method","request_uri","scheme","client_certificate_validation","ssl_verification_status"],R=["ip_cidr","asn","countries"],g=["learning","blocking","counting"],l=["low","medium","high"],D=["is_equal","is_not_equal","starts_with","does_not_start_with","matches","does_not_match","exists","does_not_exist","is_in_list","is_not_in_list"],Y=["if","and","or"];var G=["http,https","http"],Z=["","tls_1_0","tls_1_1","tls_1_2","tls_1_3"],Q=["all","TLSv1.2_2018","TLSv1.2_2019","TLSv1.2_2021","TLSv1.3_2022"],K=[80,8008,8080],J=[443,8443,9440,9441,9442,9443],X=["honor","override"],ee=["honor","override"],te=["ignore","whitelist","blacklist","all"],re=["ignore","whitelist","blacklist","all"],ie=["ignore","whitelist"],se=[null,"sa-brazil","na-united-states"],ae=["single_origin","load_balancer","live_ingest","object_storage"],oe=["preserve","http","https"],ne=["ip_hash","least_connections","round_robin"],le=["request","response"],pe=["add_request_cookie","add_request_header","add_response_header","bypass_cache_phase","capture_match_groups","deliver","deny","enable_gzip","filter_request_cookie","filter_response_cookie","filter_request_header","filter_response_header","forward_cookies","no_content","optimize_images","redirect_http_to_https","redirect_to_301","redirect_to_302","rewrite_request","run_function","set_cache_policy","set_cookie","set_origin"];var je={type:"object",properties:{id:{type:"number",errorMessage:"The 'id' field must be a number."},list_type:{type:"string",enum:R,errorMessage:"The 'list_type' field must be a string. Accepted values are 'ip_cidr', 'asn' or 'countries'."},items_values:{type:"array",items:{type:["string","number"],errorMessage:"The 'items_values' field must be an array of strings or numbers."}}},required:["id","list_type","items_values"],additionalProperties:!1,errorMessage:{additionalProperties:"No additional properties are allowed in network list items.",required:"The 'id, list_type and items_values' fields are required in each network list item."}},ke={type:"object",properties:{id:{type:"number",errorMessage:"The WAF configuration must have an 'id' field of type number"},name:{type:"string",errorMessage:"The 'name' field must be a string."},mode:{type:"string",enum:g,errorMessage:`The 'mode' field must be one of: ${g.join(", ")}`},active:{type:"boolean",errorMessage:"The 'active' field must be a boolean."},sql_injection:{type:"boolean",errorMessage:"The 'sql_injection' field must be a boolean."},sql_injection_sensitivity:{type:"string",enum:l,errorMessage:`The 'sql_injection_sensitivity' field must be one of: ${l.join(", ")}`},remote_file_inclusion:{type:"boolean",errorMessage:"The 'remote_file_inclusion' field must be a boolean."},remote_file_inclusion_sensitivity:{type:"string",enum:l,errorMessage:`The 'remote_file_inclusion_sensitivity' field must be one of: ${l.join(", ")}`},directory_traversal:{type:"boolean",errorMessage:"The 'directory_traversal' field must be a boolean."},directory_traversal_sensitivity:{type:"string",enum:l,errorMessage:`The 'directory_traversal_sensitivity' field must be one of: ${l.join(", ")}`},cross_site_scripting:{type:"boolean",errorMessage:"The 'cross_site_scripting' field must be a boolean."},cross_site_scripting_sensitivity:{type:"string",enum:l,errorMessage:`The 'cross_site_scripting_sensitivity' field must be one of: ${l.join(", ")}`},evading_tricks:{type:"boolean",errorMessage:"The 'evading_tricks' field must be a boolean."},evading_tricks_sensitivity:{type:"string",enum:l,errorMessage:`The 'evading_tricks_sensitivity' field must be one of: ${l.join(", ")}`},file_upload:{type:"boolean",errorMessage:"The 'file_upload' field must be a boolean."},file_upload_sensitivity:{type:"string",enum:l,errorMessage:`The 'file_upload_sensitivity' field must be one of: ${l.join(", ")}`},unwanted_access:{type:"boolean",errorMessage:"The 'unwanted_access' field must be a boolean."},unwanted_access_sensitivity:{type:"string",enum:l,errorMessage:`The 'unwanted_access_sensitivity' field must be one of: ${l.join(", ")}`},identified_attack:{type:"boolean",errorMessage:"The 'identified_attack' field must be a boolean."},identified_attack_sensitivity:{type:"string",enum:l,errorMessage:`The 'identified_attack_sensitivity' field must be one of: ${l.join(", ")}`},bypass_addresses:{type:"array",items:{type:"string",errorMessage:"The 'bypass_addresses' field must be an array of strings."},errorMessage:"The 'bypass_addresses' field must be an array of strings."}},required:["name","mode","active","sql_injection","sql_injection_sensitivity","remote_file_inclusion","remote_file_inclusion_sensitivity","directory_traversal","directory_traversal_sensitivity","cross_site_scripting","cross_site_scripting_sensitivity","evading_tricks","evading_tricks_sensitivity","file_upload","file_upload_sensitivity","unwanted_access","unwanted_access_sensitivity","identified_attack","identified_attack_sensitivity","bypass_addresses"],additionalProperties:!1,errorMessage:{additionalProperties:"No additional properties are allowed in waf items.",required:"The 'name, mode, active, sql_injection, sql_injection_sensitivity, remote_file_inclusion, remote_file_inclusion_sensitivity, directory_traversal, directory_traversal_sensitivity, cross_site_scripting, cross_site_scripting_sensitivity, evading_tricks, evading_tricks_sensitivity, file_upload, file_upload_sensitivity, unwanted_access, unwanted_access_sensitivity, identified_attack, identified_attack_sensitivity and bypass_addresses' fields are required in each waf item."}},xe={type:["object","null"],properties:{id:{type:"number",errorMessage:"The 'id' field must be a number."},name:{type:"string",errorMessage:"The 'name' field must be a string."},edge_application_id:{type:"number",errorMessage:"The 'edge_application_id' field must be a number."},cnames:{type:"array",items:{type:"string"},errorMessage:"The 'cnames' field must be an array of strings."},cname_access_only:{type:"boolean",errorMessage:"The 'cname_access_only' field must be a boolean."},digital_certificate_id:{oneOf:[{type:"number"},{type:"string",enum:["lets_encrypt"]},{type:"null"}],errorMessage:"The 'digital_certificate_id' field must be a number, 'lets_encrypt' or null."},is_active:{type:"boolean",default:!0,errorMessage:"The 'is_active' field must be a boolean."},domain_name:{type:"string",errorMessage:"The 'domain_name' field must be a string."},is_mtls_enabled:{type:"boolean",errorMessage:"The 'is_mtls_enabled' field must be a boolean."},mtls_verification:{type:"string",enum:["enforce","permissive"],errorMessage:"The 'mtls_verification' field must be either 'enforce' or 'permissive'."},mtls_trusted_ca_certificate_id:{type:"number",errorMessage:"The 'mtls_trusted_ca_certificate_id' field must be a number."},edge_firewall_id:{type:"number",errorMessage:"The 'edge_firewall_id' field must be a number."},crl_list:{type:"array",items:{type:"number"},errorMessage:"The 'crl_list' field must be an array of numbers."}},required:["name"],dependencies:{is_mtls_enabled:{oneOf:[{properties:{is_mtls_enabled:{enum:[!1]}}},{properties:{is_mtls_enabled:{enum:[!0]}},required:["mtls_verification","mtls_trusted_ca_certificate_id"]}]}},additionalProperties:!1,errorMessage:{additionalProperties:"No additional properties are allowed in domain items.",required:"The 'name', 'edge_application_id', 'cnames', 'cname_access_only', and 'digital_certificate_id' fields are required.",dependencies:{is_mtls_enabled:"When mTLS is enabled, 'mtls_verification' and 'mtls_trusted_ca_certificate_id' are required."}}},Be={type:"object",properties:{variable:{type:"string",enum:v,errorMessage:"The 'variable' field must be a valid firewall variable."},operator:{type:"string",enum:D,errorMessage:"The 'operator' field must be a valid operator."},conditional:{type:"string",enum:Y,errorMessage:"The 'conditional' field must be one of: if, and, or"},input_value:{type:"string",errorMessage:"The 'input_value' field must be a string."}},required:["variable","operator","conditional"],additionalProperties:!1,errorMessage:{required:"The 'variable', 'operator' and 'conditional' fields are required in criteria.",additionalProperties:"No additional properties are allowed in criteria."}},I={set_rate_limit:{type:"object",properties:{type:{type:"string",enum:h,errorMessage:"The rate limit 'type' must be either 'second' or 'minute'."},limit_by:{type:"string",enum:b,errorMessage:"The 'limit_by' field must be either 'client_ip' or 'global'."},average_rate_limit:{type:"string",pattern:"^[0-9]+$",errorMessage:"The 'average_rate_limit' must be a string containing a number."},maximum_burst_size:{type:"string",pattern:"^[0-9]+$",errorMessage:"The 'maximum_burst_size' must be a string containing a number."}},required:["type","limit_by","average_rate_limit"],additionalProperties:!1},set_waf_ruleset:{type:"object",properties:{waf_id:{type:"integer"},mode:{type:"string",enum:g}},required:["waf_id","mode"],additionalProperties:!1},set_custom_response:{type:"object",properties:{status_code:{oneOf:[{type:"integer",minimum:200,maximum:499},{type:"string",pattern:"^[2-4][0-9]{2}$"}]},content_body:{type:"string",maxLength:500},content_type:{type:"string"}},required:["status_code","content_body","content_type"],additionalProperties:!1}},Ne={type:"object",properties:{name:{type:"string",enum:U,errorMessage:"The behavior 'name' must be a valid firewall behavior."},target:{oneOf:[{type:"null"},{type:"string"},I.set_rate_limit,I.set_waf_ruleset,I.set_custom_response],errorMessage:"The 'target' must be a string, object, or null depending on the behavior."}},required:["name"],additionalProperties:!1,errorMessage:{required:"The 'name' field is required in firewall behaviors.",additionalProperties:"No additional properties are allowed in firewall behaviors."}},ze={type:"object",properties:{id:{type:"integer",errorMessage:"The 'id' field must be an integer."},name:{type:"string",errorMessage:"The 'name' field must be a string."},criteria:{type:"array",items:{type:"array",items:Be,errorMessage:"The 'criteria' field must be an array of criteria objects."},errorMessage:"The 'criteria' field must be an array of criteria objects."},behaviors:{type:"array",items:Ne,errorMessage:"The 'behaviors' field must be an array of behavior objects."},description:{type:"string",maxLength:1e3,pattern:"^[\\u0000-\\uFFFF]*$",errorMessage:"The 'description' must not exceed 1000 characters and must not contain 4-byte unicode characters."},is_active:{type:"boolean",default:!0,errorMessage:"The 'is_active' field must be a boolean."},order:{type:"integer",errorMessage:"The 'order' field must be an integer."}},required:["name","criteria","behaviors"],additionalProperties:!1,errorMessage:{type:"The 'firewall' field must be an object",required:"The 'name', 'criteria' and 'behaviors' fields are required in firewall rules.",additionalProperties:"No additional properties are allowed in firewall rules."}},Fe={type:["object","null"],properties:{main_settings:{type:"object",properties:{name:{type:"string",errorMessage:"The 'name' field must be a string."},domains:{type:"array",items:{type:"string",errorMessage:"Each domain in the firewall's domains list must be a string"}},is_active:{type:"boolean",errorMessage:"The 'is_active' field must be a boolean."},edge_functions_enabled:{type:"boolean",errorMessage:"The 'edge_functions_enabled' field must be a boolean."},network_protection_enabled:{type:"boolean",errorMessage:"The 'network_protection_enabled' field must be a boolean."},waf_enabled:{type:"boolean",errorMessage:"The 'waf_enabled' field must be a boolean."},debug_rules:{type:"boolean",errorMessage:"The 'debug_rules' field must be a boolean."}},required:["name"],additionalProperties:!1,errorMessage:{additionalProperties:"No additional properties are allowed in firewall main settings.",required:"The 'name' field is required in firewall main settings."}},rules_engine:{type:"array",items:ze,errorMessage:{type:"The 'rules_engine' field must be an array",required:"The 'rules_engine' field must be an array of firewall rules.",additionalProperties:"No additional properties are allowed in firewall rules."}}},required:["main_settings"],additionalProperties:!1,errorMessage:{additionalProperties:"No additional properties are allowed in firewall object.",required:"The 'main_settings' field is required in firewall object."}},We={type:"object",properties:{name:{type:"string",errorMessage:"The 'name' field must be a string."},browser_cache_settings:{type:"string",enum:X,errorMessage:"The 'browser_cache_settings' must be either 'honor' or 'override'."},cdn_cache_settings:{type:"string",enum:ee,errorMessage:"The 'cdn_cache_settings' must be either 'honor' or 'override'."},cache_by_query_string:{type:"string",enum:te,errorMessage:"The 'cache_by_query_string' must be one of: ignore, whitelist, blacklist, all."},cache_by_cookie:{type:"string",enum:re,errorMessage:"The 'cache_by_cookie' must be one of: ignore, whitelist, blacklist, all."},adaptive_delivery_action:{type:"string",enum:ie,errorMessage:"The 'adaptive_delivery_action' must be either 'ignore' or 'whitelist'."},l2_caching_enabled:{type:"boolean",errorMessage:"The 'l2_caching_enabled' field must be a boolean."},l2_region:{type:["string","null"],enum:se,errorMessage:"The 'l2_region' must be either null, 'sa-brazil' or 'na-united-states'."}},required:["name"],additionalProperties:!1},Ve={type:"object",properties:{name:{type:"string",errorMessage:"The 'name' field must be a string."},origin_type:{type:"string",enum:ae,errorMessage:"The 'origin_type' field must be one of: single_origin, load_balancer, live_ingest, object_storage."},origin_protocol_policy:{type:"string",enum:oe,errorMessage:"The 'origin_protocol_policy' must be one of: preserve, http, https."},host_header:{type:"string",errorMessage:"The 'host_header' field must be a string."},bucket:{type:"string",errorMessage:"The 'bucket' field must be a string."},addresses:{type:"array",items:{type:"object",properties:{address:{type:"string",errorMessage:"The 'address' field must be a string."},weight:{type:"number",minimum:0,maximum:100,errorMessage:"The 'weight' field must be a number between 0 and 100."},server_role:{type:"string",enum:["primary","backup"],errorMessage:"The 'server_role' field must be either 'primary' or 'backup'."}},required:["address"],additionalProperties:!1}},load_balancer:{type:"object",properties:{method:{type:"string",enum:ne,errorMessage:"The 'method' field must be one of: ip_hash, least_connections, round_robin."}},required:["method"],additionalProperties:!1}},required:["name","origin_type","addresses"],allOf:[{if:{properties:{origin_type:{const:"object_storage"}}},then:{required:["bucket"],errorMessage:"When origin_type is 'object_storage', the 'bucket' field is required."}}],additionalProperties:!1},$e={type:"object",properties:{name:{type:"string",errorMessage:"The 'name' field must be a string."},phase:{type:"string",enum:le,errorMessage:"The 'phase' field must be either 'request' or 'response'."},behaviors:{type:"array",items:{type:"object",properties:{name:{type:"string",enum:pe,errorMessage:"The 'name' field must be a valid behavior name."},target:{oneOf:[{type:"string"},{type:"null"}],errorMessage:"The 'target' must be a string or null."}},required:["name"],additionalProperties:!1}},criteria:{type:"array",items:{type:"array",items:{type:"object",properties:{variable:{type:"string",enum:Array.from(new Set(C)),errorMessage:"The 'variable' field must be a valid variable name."},operator:{type:"string",enum:[...f,...y],errorMessage:"The 'operator' field must be a valid operator."},conditional:{type:"string",enum:T,errorMessage:"The 'conditional' field must be one of: if, and, or."},input_value:{type:"string",errorMessage:"The 'input_value' field must be a string."}},required:["variable","operator","conditional"],dependencies:{operator:{oneOf:[{properties:{operator:{enum:f}},required:["input_value"],errorMessage:"The operator 'matches' requires an input_value."}]}},additionalProperties:!1}}}},required:["name","behaviors","criteria"],additionalProperties:!1},He={type:"object",properties:{main_settings:{type:"object",properties:{name:{type:"string",errorMessage:"The 'name' field must be a string."},delivery_protocol:{type:"string",enum:G,default:"http",errorMessage:"The 'delivery_protocol' field must be either 'http,https' or 'http'."},http3:{type:"boolean",errorMessage:"The 'http3' field must be a boolean."},http_port:{type:"array",items:{type:"integer",enum:K},errorMessage:{enum:"The 'http_port' field must be an array of valid HTTP ports.",type:"The 'http_port' field must be an array"}},https_port:{type:"array",items:{type:"integer",enum:J},default:[443],errorMessage:"The 'https_port' field must be an array of valid HTTPS ports."},minimum_tls_version:{type:"string",enum:Z,default:"",errorMessage:"The 'minimum_tls_version' field must be a valid TLS version."},supported_ciphers:{type:"string",enum:Q,default:"all",errorMessage:"The 'supported_ciphers' field must be a valid cipher suite."},active:{type:"boolean",default:!0,errorMessage:"The 'active' field must be a boolean."}},additionalProperties:!1,required:["name"]},cache_settings:{type:"array",items:We,errorMessage:"The 'cache_settings' field must be an array of cache setting items."},origins:{type:"array",items:Ve,errorMessage:"The 'origins' field must be an array of origin items."},rules:{type:"array",items:$e,errorMessage:"The 'rules' field must be an array of application rule items."}},required:["main_settings"],additionalProperties:!1,errorMessage:{additionalProperties:"No additional properties are allowed in application items.",required:"The 'name' and 'main_settings' fields are required."}},de={type:"object",properties:{networkList:{type:"array",items:je,errorMessage:"The 'networkList' field must be an array of network list items."},waf:{type:"array",items:ke,errorMessage:{type:"The 'waf' field must be an array"}},domain:{...xe,errorMessage:{type:"The 'domain' field must be an object"}},firewall:{...Fe,errorMessage:{type:"The 'firewall' field must be an object"}},application:{type:"array",items:He,errorMessage:"The 'application' field must be an array of application items."}}};var L=class{transformToManifest(s,e){return e}transformToConfig(s,e){return s}},p=L;var q=class extends p{transformToManifest(s){let e=s?.build;return e||void 0}transformToConfig(s,e){let t=s?.build;return e.build=t,e.build}},ce=q;import{all as Ue,create as De}from"mathjs";var Ye=De(Ue),P=class extends p{evaluateMathExpression=s=>{if(typeof s=="number")return s;if(/^[0-9+\-*/.() ]+$/.test(s))return Ye.evaluate(s);throw new Error(`Expression is not purely mathematical: ${s}`)};transformToManifest(s){let e=[];if(!(!Array.isArray(s?.cache)||s?.cache.length===0))return s?.cache.forEach(t=>{let i=t?.browser?this.evaluateMathExpression(t.browser.maxAgeSeconds):0,a=t?.edge?this.evaluateMathExpression(t.edge.maxAgeSeconds):60,o={name:t.name,browser_cache_settings:t?.browser?"override":"honor",browser_cache_settings_maximum_ttl:i,cdn_cache_settings:t?.edge?"override":"honor",cdn_cache_settings_maximum_ttl:a,enable_caching_for_post:t?.methods?.post||!1,enable_caching_for_options:t?.methods?.options||!1,enable_query_string_sort:t?.queryStringSort||!1};t.cacheByQueryString&&(o.cache_by_query_string=t.cacheByQueryString.option==="varies"?"all":t.cacheByQueryString.option,t.cacheByQueryString.option==="whitelist"||t.cacheByQueryString.option==="blacklist"?o.query_string_fields=t.cacheByQueryString.list||[]:o.query_string_fields=[]),t.cacheByCookie&&(o.cache_by_cookie=t.cacheByCookie.option==="varies"?"all":t.cacheByCookie.option,t.cacheByCookie.option==="whitelist"||t.cacheByCookie.option==="blacklist"?o.cookie_names=t.cacheByCookie.list||[]:o.cookie_names=[]),e.push(o)}),e}transformToConfig(s,e){let t=s.cache;if(!(!Array.isArray(t)||t.length===0))return e.cache=[],t.forEach(i=>{let a=i.browser_cache_settings_maximum_ttl?this.evaluateMathExpression(i.browser_cache_settings_maximum_ttl):0,o=i.cdn_cache_settings_maximum_ttl?this.evaluateMathExpression(i.cdn_cache_settings_maximum_ttl):60,n={name:i.name,stale:i.stale,browser:{maxAgeSeconds:a},edge:{maxAgeSeconds:o},methods:{post:i.enable_caching_for_post,options:i.enable_caching_for_options},queryStringSort:i.enable_query_string_sort};i.cache_by_query_string&&(n.cacheByQueryString={option:i.cache_by_query_string==="varies"?"all":i.cache_by_query_string},i.cache_by_query_string==="whitelist"||i.cache_by_query_string==="blacklist"?n.cacheByQueryString={...n.cacheByQueryString,list:i.query_string_fields||[]}:n.cacheByQueryString={...n.cacheByQueryString,list:[]}),i.cache_by_cookie&&(n.cacheByCookie={option:i.cache_by_cookie==="varies"?"all":i.cache_by_cookie},i.cache_by_cookie==="whitelist"||i.cache_by_cookie==="blacklist"?n.cacheByCookie={...n.cacheByCookie,list:i.cookie_names||[]}:n.cacheByCookie={...n.cacheByCookie,list:[]}),e.cache.push(n)}),e.cache}},ue=P;var O=class extends p{transformToManifest(s){let e=s?.domain;if(!e||Object.keys(e).length===0)return;if(e.digitalCertificateId&&typeof e.digitalCertificateId=="string"&&e.digitalCertificateId!=="lets_encrypt")throw new Error(`Domain ${e.name} has an invalid digital certificate ID: ${e.digitalCertificateId}. Only 'lets_encrypt' or null is supported.`);if(e.mtls?.verification&&e.mtls.verification!=="enforce"&&e.mtls.verification!=="permissive")throw new Error(`Domain ${e.name} has an invalid verification value: ${e.mtls.verification}. Only 'enforce' or 'permissive' is supported.`);let t={name:e.name,cname_access_only:e.cnameAccessOnly??!1,cnames:e.cnames||[],digital_certificate_id:e.digitalCertificateId||null,edge_application_id:e.edgeApplicationId||null,edge_firewall_id:e.edgeFirewallId||null,is_active:e.active===void 0?!0:e.active};return e.mtls?(t.is_mtls_enabled=!0,t.mtls_verification=e.mtls.verification,t.mtls_trusted_ca_certificate_id=e.mtls.trustedCaCertificateId,t.crl_list=e.mtls.crlList||[]):t.is_mtls_enabled=!1,t}transformToConfig(s,e){let t=s.domain;if(!(!t||Object.keys(t).length===0))return e.domain={name:t.name,cnameAccessOnly:t.cname_access_only,cnames:t.cnames,digitalCertificateId:t.digital_certificate_id,edgeApplicationId:t.edge_application_id,edgeFirewallId:t.edge_firewall_id,active:t.is_active===void 0?!0:t.is_active,mtls:t.mtls_verification?{verification:t.mtls_verification,trustedCaCertificateId:t.mtls_trusted_ca_certificate_id,crlList:t.crl_list}:void 0},e.domain}},me=O;var j=class extends p{transformToManifest(s){let e=[];if(!Array.isArray(s?.origin)||s?.origin.length===0)return;let t=["single_origin","object_storage","load_balancer","live_ingest"];return s?.origin.forEach(i=>{if(t.indexOf(i.type)===-1)throw new Error(`Rule setOrigin originType '${i.type}' is not supported`);let a={id:i.id,key:i.key,name:i.name,origin_type:i.type};if(i.type!=="object_storage"){if(i.path==="/")throw new Error('Origin path cannot be "/". Please use empty string or "/path"');if(a.origin_path=i.path||"",a.origin_protocol_policy=i.protocolPolicy||"preserve",a.method=i.method||"ip_hash",a.is_origin_redirection_enabled=i.redirection??!1,a.connection_timeout=i.connectionTimeout||60,a.timeout_between_bytes=i.timeoutBetweenBytes||120,i.addresses&&i.addresses.length>0){let o=[];i?.addresses.forEach(n=>{if(typeof n=="string"){o.push({address:n});return}if(n?.weight<0||n?.weight>10)throw new Error(`When origin type is ${i.type}, weight must be between 0 and 10`);o.push(n)}),a.addresses=o}else throw new Error(`When origin type is ${i.type}, addresses is required`);a.host_header=i.hostHeader||"${host}",i?.hmac&&(a.hmac_authentication=!0,a.hmac_region_name=i.hmac?.region,a.hmac_access_key=i.hmac?.accessKey,a.hmac_secret_key=i.hmac?.secretKey)}else i.type==="object_storage"&&(a.bucket=i.bucket,a.prefix=i.prefix||"");e.push(a)}),e}transformToConfig(s,e){let t=s.origin;if(!Array.isArray(t)||t.length===0)return;e.origin=[];let i=["single_origin","object_storage","load_balancer","live_ingest"];return t.forEach(a=>{if(i.indexOf(a.origin_type)===-1)throw new Error(`originType '${a.origin_type}' is not supported`);let o={id:a.id,key:a.key,name:a.name,type:a.origin_type};if(o.type!=="object_storage"){if(a.path==="/")throw new Error('Origin path cannot be "/". Please use empty string or "/path"');o.path=a.origin_path,o.protocolPolicy=a.origin_protocol_policy,o.method=a.method,o.redirection=a.is_origin_redirection_enabled??!1,o.connectionTimeout=a.connection_timeout,o.timeoutBetweenBytes=a.timeout_between_bytes,o.addresses=a.addresses,o.hostHeader=a.host_header,a.hmac_authentication&&(o.hmac={region:a.hmac_region_name,accessKey:a.hmac_access_key,secretKey:a.hmac_secret_key})}else o.type==="object_storage"&&(o.bucket=a.bucket,o.prefix=a.prefix);e.origin.push(o)}),e.origin}},_e=j;var k=class extends p{transformToManifest(s){let e=[];if(!(!Array.isArray(s?.purge)||s?.purge.length===0))return s?.purge.forEach(t=>{t?.urls.forEach(a=>{if(!a.includes("http://")&&!a.includes("https://"))throw new Error("The URL must contain the protocol (http:// or https://).");if(t?.type==="wildcard"&&!a.includes("*"))throw new Error("The URL must not contain the wildcard character (*).")});let i={type:t.type,urls:t.urls||[],method:t.method||"delete"};t?.type==="cachekey"&&(i.layer=t.layer||"edge_caching"),e.push(i)}),e}transformToConfig(s,e){let t=s.purge;if(!(!Array.isArray(t)||t.length===0))return e.purge=[],t.forEach(i=>{i.urls.forEach(o=>{if(!o.includes("http://")&&!o.includes("https://"))throw new Error("The URL must contain the protocol (http:// or https://).");if(i?.type==="wildcard"&&!o.includes("*"))throw new Error("The URL must not contain the wildcard character (*).")});let a={type:i.type,urls:i.urls||[],method:i.method||"delete"};i?.type==="cachekey"&&(a.layer=i.layer||"edge_caching"),e.purge.push(a)}),e.purge}},fe=k;var ge={setOrigin:{transform:(r,s)=>{let e=s.origin?.find(t=>t.name===r.name&&t.origin_type===r.type);if(e){if(e.origin_type!==r.type)throw new Error(`Rule setOrigin originType '${r.type}' does not match the origin settings`)}else throw new Error(`Rule setOrigin name '${r.name}' not found in the origin settings`);return{name:"set_origin",target:e.name}}},rewrite:{transform:r=>{let s=[];return s.push({name:"rewrite_request",target:r}),s}},deliver:{transform:()=>({name:"deliver",target:null})},setCookie:{transform:r=>({name:"add_request_cookie",target:r})},setHeaders:{transform:r=>r.map(s=>({name:"add_request_header",target:s}))},setCache:{transform:(r,s)=>{if(typeof r=="string")return{name:"set_cache_policy",target:r};if(typeof r=="object"){s.cache=s.cache||[];let e={name:r.name,...r};return s.cache.push(e),{name:"set_cache_policy",target:r.name}}}},forwardCookies:{transform:r=>{if(r)return{name:"forward_cookies",target:null}}},runFunction:{transform:r=>({name:"run_function",target:r})},enableGZIP:{transform:r=>{if(r)return{name:"enable_gzip",target:""}}},bypassCache:{transform:r=>{if(r)return{name:"bypass_cache_phase",target:null}}},httpToHttps:{transform:r=>{if(r)return{name:"redirect_http_to_https",target:null}}},redirectTo301:{transform:r=>({name:"redirect_to_301",target:r})},redirectTo302:{transform:r=>({name:"redirect_to_302",target:r})},capture:{transform:r=>({name:"capture_match_groups",target:{regex:r.match,captured_array:r.captured,subject:`\${${r.subject??"uri"}}`}})},filterCookie:{transform:r=>({name:"filter_request_cookie",target:r})},filterHeader:{transform:r=>({name:"filter_request_header",target:r})},noContent:{transform:r=>{if(r)return{name:"no_content",target:null}}},optimizeImages:{transform:r=>{if(r)return{name:"optimize_images",target:null}}},deny:{transform:r=>{if(r)return{name:"deny",target:null}}}},ye={setCookie:{transform:r=>({name:"set_cookie",target:r})},setHeaders:{transform:r=>r.map(s=>({name:"add_response_header",target:s}))},enableGZIP:{transform:r=>{if(r)return{name:"enable_gzip",target:""}}},filterCookie:{transform:r=>({name:"filter_response_cookie",target:r})},filterHeader:{transform:r=>({name:"filter_response_header",target:r})},runFunction:{transform:r=>({name:"run_function",target:r})},redirectTo301:{transform:r=>({name:"redirect_to_301",target:r})},redirectTo302:{transform:r=>({name:"redirect_to_302",target:r})},capture:{transform:r=>({name:"capture_match_groups",target:{regex:r.match,captured_array:r.captured,subject:`\${${r.subject??"uri"}}`}})},deliver:{transform:r=>{if(r)return{name:"deliver",target:null}}}},he={set_origin:{transform:(r,s)=>{let e=s.origin?.find(t=>t.name===r);if(!e)throw new Error(`Rule setOrigin name '${r.name}' not found in the origin settings`);return{setOrigin:{name:r,type:e.type}}}},rewrite_request:{transform:r=>({rewrite:r})},deliver:{transform:()=>({deliver:!0})},add_request_cookie:{transform:r=>({setCookie:r})},add_request_header:{transform:r=>({setHeaders:[r]})},set_cache_policy:{transform:r=>{if(typeof r=="string")return{setCache:r};if(typeof r=="object")return{setCache:{name:r.name,...r}}}},forward_cookies:{transform:()=>({forwardCookies:!0})},run_function:{transform:r=>({runFunction:r})},enable_gzip:{transform:()=>({enableGZIP:!0})},bypass_cache_phase:{transform:()=>({bypassCache:!0})},redirect_http_to_https:{transform:()=>({httpToHttps:!0})},redirect_to_301:{transform:r=>({redirectTo301:r})},redirect_to_302:{transform:r=>({redirectTo302:r})},capture_match_groups:{transform:r=>({capture:{match:r.regex,captured:r.captured_array,subject:r.subject}})},filter_request_cookie:{transform:r=>({filterCookie:r})},filter_request_header:{transform:r=>({filterHeader:r})},no_content:{transform:()=>({noContent:!0})},optimize_images:{transform:()=>({optimizeImages:!0})},deny:{transform:()=>({deny:!0})}},be={set_cookie:{transform:r=>({setCookie:r})},add_response_header:{transform:r=>({setHeaders:[r]})},enable_gzip:{transform:()=>({enableGZIP:!0})},filter_response_cookie:{transform:r=>({filterCookie:r})},filter_response_header:{transform:r=>({filterHeader:r})},run_function:{transform:r=>({runFunction:r})},redirect_to_301:{transform:r=>({redirectTo301:r})},redirect_to_302:{transform:r=>({redirectTo302:r})},deliver:{transform:()=>({deliver:!0})}};var x=class extends p{addBehaviors(s,e,t,i){e&&typeof e=="object"&&Object.entries(e).forEach(([a,o])=>{if(t[a]){let n=t[a].transform(o,i);Array.isArray(n)?s.behaviors.push(...n):n&&s.behaviors.push(n)}else console.warn(`Unknown behavior: ${a}`)})}validateFunctionReferences(s){if(!s?.rules?.request||!s?.functions)return;let e=new Set(s.functions.map(t=>t.name));for(let t of s.rules.request)if(t.behavior?.runFunction&&!e.has(t.behavior.runFunction))throw new Error(`Function "${t.behavior.runFunction}" referenced in rule "${t.name}" is not defined in the functions array.`)}transformToManifest(s,e){this.validateFunctionReferences(s);let t=[];if(!(s?.rules===void 0||Object.keys(s.rules).length===0))return Array.isArray(s?.rules?.request)&&s?.rules?.request?.forEach((i,a)=>{let o={name:i.name,phase:"request",description:i.description??"",is_active:i.active!==void 0?i.active:!0,order:a+2,criteria:i.criteria?[i.criteria.map(n=>{let d="inputValue"in n,{inputValue:c,...u}=n;return{...u,variable:n.variable.startsWith("${")?n.variable:`\${${n.variable}}`,...d&&{input_value:c}}})]:[[{variable:i.variable?.startsWith("${")?i.variable:`\${${i.variable??"uri"}}`,operator:"matches",conditional:"if",input_value:i.match}]],behaviors:[]};this.addBehaviors(o,i.behavior,ge,e),t.push(o)}),Array.isArray(s?.rules?.response)&&s?.rules?.response.forEach((i,a)=>{let o={name:i.name,phase:"response",description:i.description??"",is_active:i.active!==void 0?i.active:!0,order:a+2,criteria:i.criteria?[i.criteria.map(n=>{let d="inputValue"in n,{inputValue:c,...u}=n;return{...u,variable:n.variable.startsWith("${")?n.variable:`\${${n.variable}}`,...d&&{input_value:c}}})]:[[{variable:i.variable?.startsWith("${")?i.variable:`\${${i.variable??"uri"}}`,operator:"matches",conditional:"if",input_value:i.match}]],behaviors:[]};this.addBehaviors(o,i.behavior,ye,e),t.push(o)}),t}transformToConfig(s,e){let t=(a,o,n)=>{if(a&&Array.isArray(a))return a.map(u=>{let _=u.name;return o[_]?o[_].transform(u.target,n):(console.warn(`Unknown behavior: ${_}`),{})}).reduce((u,_)=>_.setHeaders?{...u,setHeaders:[...u.setHeaders||[],..._.setHeaders]}:{...u,..._},{})},i=s.rules;if(!(!i||Object.keys(i).length===0))return e.rules={request:[],response:[]},i.forEach(a=>{a.phase==="request"?e.rules.request.push({name:a.name,description:a.description,active:a.is_active,criteria:Array.isArray(a.criteria)&&Array.isArray(a.criteria[0])?a.criteria[0].map(o=>{let n="input_value"in o,{input_value:d,...c}=o;return{...c,...n&&{inputValue:d}}}):[],behavior:t(a.behaviors,he,e)}):a.phase==="response"&&e.rules.response.push({name:a.name,description:a.description,active:a.is_active,criteria:Array.isArray(a.criteria)&&Array.isArray(a.criteria[0])?a.criteria[0].map(o=>{let n="input_value"in o,{input_value:d,...c}=o;return{...c,...n&&{inputValue:d}}}):[],behavior:t(a.behaviors,be,e)})}),e.rules}},Te=x;var B=class extends p{transformToManifest(s){let e=s?.networkList;if(!Array.isArray(e)||e.length===0)return;let t=[];return e.forEach(i=>{let a={id:i.id,list_type:i.listType,items_values:i.listContent};t.push(a)}),t}transformToConfig(s,e){let t=s?.networkList;if(!(!Array.isArray(t)||t.length===0))return e.networkList=[],t.forEach(i=>{let a={id:i.id,listType:i.list_type,listContent:i.items_values};e.networkList.push(a)}),e.networkList}},ve=B;var N=class extends p{transformToManifest(s){let e=s?.waf;if(!Array.isArray(e)||e.length===0)return;let t=(a,o)=>a?{[o]:!0,[`${o}_sensitivity`]:a.sensitivity}:{[o]:!1,[`${o}_sensitivity`]:"low"},i=[];return e.forEach(a=>{let o={name:a.name,active:a.active,mode:a.mode,...t(a.crossSiteScripting,"cross_site_scripting"),...t(a.directoryTraversal,"directory_traversal"),...t(a.evadingTricks,"evading_tricks"),...t(a.fileUpload,"file_upload"),...t(a.remoteFileInclusion,"remote_file_inclusion"),...t(a.sqlInjection,"sql_injection"),...t(a.unwantedAccess,"unwanted_access"),...t(a.identifiedAttack,"identified_attack"),bypass_addresses:a.bypassAddresses||[]};i.push(o)}),i}transformToConfig(s,e){let t=s?.waf;if(!(!Array.isArray(t)||t.length===0))return e.waf=[],t.forEach(i=>{let a=n=>{if(i[n])return{sensitivity:i[`${n}_sensitivity`]}},o={name:i.name,active:i.active,mode:i.mode,crossSiteScripting:a("cross_site_scripting"),directoryTraversal:a("directory_traversal"),evadingTricks:a("evading_tricks"),fileUpload:a("file_upload"),remoteFileInclusion:a("remote_file_inclusion"),sqlInjection:a("sql_injection"),unwantedAccess:a("unwanted_access"),identifiedAttack:a("identified_attack"),bypassAddresses:i.bypass_addresses||[]};e.waf.push(o)}),e.waf}},Ae=N;var z=class{strategies;constructor(){this.strategies={}}setStrategy(s,e){this.strategies[s]=e}transformToManifest(s,e){return Object.keys(this.strategies).forEach(t=>{e[t]=this.strategies[t].transformToManifest(s,e)}),e}transformToConfig(s,e){return Object.keys(this.strategies).forEach(t=>{e[t]=this.strategies[t].transformToConfig(s,e)}),e}},Me=z;var F=class extends p{transformToManifest(s){if(!(!Array.isArray(s?.functions)||s?.functions.length===0))return s.functions.map(e=>({name:e.name,target:e.path,args:e.args||{}}))}transformToConfig(s,e){if(!(!Array.isArray(s?.functions)||s?.functions.length===0))return e.functions=s.functions.map(t=>({name:t.name,path:t.target,args:t.args||{}})),e.functions}},we=F;var W=class extends p{transformToManifest(s){let e=s?.firewall;if(!e||Object.keys(e).length===0)return;let t={main_settings:{name:e.name,domains:e.domains||[],is_active:e.active??!0,edge_functions_enabled:e.edgeFunctions??!1,network_protection_enabled:e.networkProtection??!1,waf_enabled:e.waf??!1,debug_rules:e.debugRules??!1}};return e.rules&&e.rules.length>0&&(t.rules_engine=e.rules.map(i=>({name:i.name,description:i.description||"",is_active:i.active??!0,behaviors:this.transformBehaviorsToManifest(i.behavior),criteria:i.criteria?[i.criteria.map(a=>{let o="inputValue"in a,{inputValue:n,...d}=a;return{...d,variable:a.variable,...o&&{input_value:n}}})]:[[{variable:i.variable,operator:"matches",conditional:"if",input_value:i.match}]]}))),t}transformBehaviorsToManifest(s){let e=[];return s.runFunction&&e.push({name:"run_function",target:s.runFunction}),s.setWafRuleset&&e.push({name:"set_waf_ruleset",target:{mode:s.setWafRuleset.wafMode,waf_id:s.setWafRuleset.wafId}}),s.setRateLimit&&e.push({name:"set_rate_limit",target:{type:s.setRateLimit.type,value:s.setRateLimit.value,limit_by:s.setRateLimit.limitBy}}),s.deny&&e.push({name:"deny",target:""}),s.drop&&e.push({name:"drop",target:""}),s.setCustomResponse&&e.push({name:"set_custom_response",target:{status_code:s.setCustomResponse.statusCode,content_type:s.setCustomResponse.contentType,content_body:s.setCustomResponse.contentBody}}),e}transformToConfig(s,e){let t=s.firewall;if(!t||Object.keys(t).length===0)return;let i={name:t.main_settings?.name,domains:t?.main_settings?.domains||[],active:t?.main_settings?.is_active??!0,edgeFunctions:t?.main_settings?.edge_functions_enabled??!1,networkProtection:t?.main_settings?.network_protection_enabled??!1,waf:t?.main_settings?.waf_enabled??!1,debugRules:t?.main_settings?.debug_rules??!1};return t.rules_engine&&t.rules_engine.length>0&&(i.rules=t.rules_engine.map(a=>({name:a.name,description:a.description||"",active:a.is_active??!0,behavior:this.transformBehaviorsToConfig(a.behaviors),criteria:a.criteria?.[0].map(n=>{let d="input_value"in n,{input_value:c,...u}=n;return{...u,...d&&{inputValue:c}}})||[]}))),e.firewall=i,e.firewall}transformBehaviorsToConfig(s){let e={};return s.forEach(t=>{switch(t.name){case"run_function":e.runFunction={path:t.target};break;case"set_waf_ruleset":e.setWafRuleset={wafMode:t.target.mode,wafId:t.target.waf_id};break;case"set_rate_limit":e.setRateLimit={type:t.target.type,value:t.target.value,limitBy:t.target.limit_by};break;case"deny":e.deny=!0;break;case"drop":e.drop=!0;break;case"set_custom_response":e.setCustomResponse={statusCode:t.target.status_code,contentType:t.target.content_type,contentBody:t.target.content_body};break}}),e}},Ce=W;function S(){let r=new Me;return r.setStrategy("build",new ce),r.setStrategy("origin",new _e),r.setStrategy("cache",new ue),r.setStrategy("domain",new me),r.setStrategy("purge",new fe),r.setStrategy("networkList",new ve),r.setStrategy("waf",new Ae),r.setStrategy("firewall",new Ce),r.setStrategy("functions",new we),r.setStrategy("rules",new Te),r}import Je from"ajv";import Xe from"ajv-errors";import et from"ajv-keywords";function Ge(r){let s={...r},e=["httpToHttps","bypassCache","forwardCookies","capture","setOrigin","rewrite","setCookie","setHeaders","runFunction","setCache","redirectTo301","redirectTo302","deliver"],t=["enableGZIP","capture","setCookie","setHeaders","filterHeader","filterCookie","runFunction","redirectTo301","redirectTo302","deliver"],i=(a,o)=>a.map(n=>{let d={...n,behavior:{...n.behavior}};return Object.keys(n).forEach(c=>{o.includes(c)&&(d.behavior[c]=n[c],delete d[c])}),d});return s.rules&&s.rules.request&&(s.rules.request=i(s.rules.request,e)),s.rules&&s.rules.response&&(s.rules.response=i(s.rules.response,t)),s}var Ee=Ge;var Ze={type:"object",properties:{variable:{type:"string",anyOf:[{type:"string",pattern:"^\\$\\{("+C.join("|")+")\\}$"},{type:"string",pattern:"^\\$\\{("+H.join("|").replace(/\$/g,"\\$")+")\\}$"}],errorMessage:"The 'variable' field must be wrapped in ${} and be either a valid static variable or follow the dynamic patterns (arg_*, cookie_*, http_*, sent_http_*, upstream_cookie_*, upstream_http_*)"},conditional:{type:"string",enum:T,errorMessage:`The 'conditional' field must be one of: ${T.join(", ")}`},operator:{type:"string",enum:[...f,...y],errorMessage:`The 'operator' field must be one of: ${[...f,...y].join(", ")}`}},required:["variable","conditional","operator"],allOf:[{if:{properties:{operator:{enum:f}}},then:{required:["inputValue"],properties:{inputValue:{type:"string",errorMessage:"The 'inputValue' field must be a string"}}}},{if:{properties:{operator:{enum:y}}},then:{not:{required:["inputValue"]}}}]},Qe=(r=!1)=>({type:"string",anyOf:[{enum:[...new Set(r?M:w)],errorMessage:"The 'variable' field must be a valid variable"},{type:"string",pattern:"^\\$\\{("+[...new Set(r?M:w)].join("|")+")\\}$",errorMessage:"The 'variable' field must be a valid variable wrapped in ${}"},{type:"string",pattern:r?"^(arg_|cookie_|http_)[a-zA-Z0-9_]+$":"^(arg_|cookie_|http_|sent_http_|upstream_cookie_|upstream_http_)[a-zA-Z0-9_]+$"},{type:"string",pattern:r?"^\\$\\{(arg_|cookie_|http_)[a-zA-Z0-9_]+\\}$":"^\\$\\{(arg_|cookie_|http_|sent_http_|upstream_cookie_|upstream_http_)[a-zA-Z0-9_]+\\}$"},{type:"string",pattern:`^(${$.join("|")})\\([^)]+\\)$`}],errorMessage:r?"The 'variable' field must be either a valid request phase variable, mTLS variable, follow the patterns (arg_*, cookie_*, http_*), or be a special function variable (cookie_time_offset, encode_base64)":"The 'variable' field must be either a valid response phase variable, follow the patterns (arg_*, cookie_*, http_*, sent_http_*, upstream_cookie_*, upstream_http_*), or be a special function variable (cookie_time_offset, encode_base64)"}),m={type:"string",enum:l,errorMessage:`The 'sensitivity' field must be one of: ${l.join(", ")}`},Re=(r=!1)=>({type:"object",properties:{name:{type:"string",errorMessage:"The 'name' field must be a string"},description:{type:"string",errorMessage:"The 'description' field must be a string"},active:{type:"boolean",errorMessage:"The 'active' field must be a boolean"},match:{type:"string",errorMessage:"The 'match' field must be a string"},variable:Qe(r),criteria:{type:"array",items:Ze,errorMessage:{type:"Each criteria item must follow the criteria format"}},behavior:{type:"object",properties:{setOrigin:{type:"object",properties:{name:{type:"string",errorMessage:"The 'name' field must be a string."},type:{type:"string",errorMessage:"The 'type' field must be a string."}},required:["name","type"],additionalProperties:!1,errorMessage:{additionalProperties:"No additional properties are allowed in the 'setOrigin' object.",required:"The 'name or type' field is required in the 'setOrigin' object."}},rewrite:{type:"string",errorMessage:"The 'rewrite' field must be a string."},setHeaders:{type:"array",items:{type:"string",errorMessage:"Each item in 'setHeaders' must be a string."},errorMessage:{type:"The 'setHeaders' field must be an array of strings."}},bypassCache:{type:["boolean","null"],errorMessage:"The 'bypassCache' field must be a boolean or null."},httpToHttps:{type:["boolean","null"],errorMessage:"The 'httpToHttps' field must be a boolean or null."},redirectTo301:{type:["string","null"],errorMessage:"The 'redirectTo301' field must be a string or null."},redirectTo302:{type:["string","null"],errorMessage:"The 'redirectTo302' field must be a string or null."},forwardCookies:{type:["boolean","null"],errorMessage:"The 'forwardCookies' field must be a boolean or null."},setCookie:{type:["string","null"],errorMessage:"The 'setCookie' field must be a string or null."},deliver:{type:["boolean","null"],errorMessage:"The 'deliver' field must be a boolean or null."},capture:{type:"object",properties:{match:{type:"string",errorMessage:"The 'match' field must be a string."},captured:{type:"string",errorMessage:"The 'captured' field must be a string."},subject:{type:"string",errorMessage:"The 'subject' field must be a string."}},required:["match","captured","subject"],additionalProperties:!1,errorMessage:{additionalProperties:"No additional properties are allowed in the 'capture' object.",required:"All properties ('match', 'captured', 'subject') are required in the 'capture' object."}},runFunction:{type:"string",errorMessage:"The 'runFunction' behavior must be a string"},setWafRuleset:{type:"object",properties:{wafMode:{type:"string",enum:E,errorMessage:`The wafMode must be one of: ${E.join(", ")}`},wafId:{type:"string",errorMessage:"The wafId must be a string"}},required:["wafMode","wafId"],additionalProperties:!1},setRateLimit:{type:"object",properties:{type:{type:"string",enum:h,errorMessage:`The rate limit type must be one of: ${h.join(", ")}`},limitBy:{type:"string",enum:b,errorMessage:`The rate limit must be applied by one of: ${b.join(", ")}`},averageRateLimit:{type:"string",errorMessage:"The averageRateLimit must be a string"},maximumBurstSize:{type:"string",errorMessage:"The maximumBurstSize must be a string"}},required:["type","limitBy","averageRateLimit","maximumBurstSize"],additionalProperties:!1},deny:{type:"boolean",errorMessage:"The deny behavior must be a boolean"},drop:{type:"boolean",errorMessage:"The drop behavior must be a boolean"},setCustomResponse:{type:"object",properties:{statusCode:{type:["integer","string"],minimum:200,maximum:499,errorMessage:"The statusCode must be a number or string between 200 and 499"},contentType:{type:"string",errorMessage:"The contentType must be a string"},contentBody:{type:"string",errorMessage:"The contentBody must be a string"}},required:["statusCode","contentType","contentBody"],additionalProperties:!1},tagEvent:{type:"object",properties:{name:{type:"string",errorMessage:"The tagEvent name must be a string"}},required:["name"],additionalProperties:!1},setCache:{oneOf:[{type:"string",errorMessage:"The 'setCache' field must be a string."},{type:"object",properties:{name:{type:"string",errorMessage:"The 'name' field must be a string."},browser_cache_settings_maximum_ttl:{type:"number",nullable:!0,errorMessage:"The 'browser_cache_settings_maximum_ttl' field must be a number or null."},cdn_cache_settings_maximum_ttl:{type:"number",nullable:!0,errorMessage:"The 'cdn_cache_settings_maximum_ttl' field must be a number or null."}},required:["name"],additionalProperties:!1,errorMessage:{additionalProperties:"No additional properties are allowed in the cache object.",required:"The 'name' field is required in the cache object."}}],errorMessage:"The 'cache' field must be either a string or an object with specified properties."},filterCookie:{type:["string","null"],errorMessage:"The 'filterCookie' field must be a string or null."},filterHeader:{type:["string","null"],errorMessage:"The 'filterHeader' field must be a string or null."},enableGZIP:{type:["boolean","null"],errorMessage:"The 'enableGZIP' field must be a boolean or null."},noContent:{type:["boolean","null"],errorMessage:"The 'noContent' field must be a boolean or null."},optimizeImages:{type:["boolean","null"],errorMessage:"The 'optimizeImages' field must be a boolean or null."}},additionalProperties:!1,allOf:[{not:{anyOf:[{required:["deny","drop"]},{required:["deny","setCustomResponse"]},{required:["deny","setRateLimit"]},{required:["drop","setCustomResponse"]},{required:["drop","setRateLimit"]},{required:["setCustomResponse","setRateLimit"]}]},errorMessage:"Cannot use multiple final behaviors (deny, drop, setRateLimit, setCustomResponse) together. You can combine non-final behaviors (runFunction, setWafRuleset, tagEvent) with only one final behavior."}],minProperties:1,errorMessage:{additionalProperties:"No additional properties are allowed in the 'behavior' object.",minProperties:"At least one behavior must be specified"}}},required:["name"],oneOf:[{anyOf:[{required:["match"]},{required:["variable"]}],not:{required:["criteria"]},errorMessage:"Cannot use 'match' or 'variable' together with 'criteria'."},{required:["criteria"],not:{anyOf:[{required:["match"]},{required:["variable"]}]},errorMessage:"Cannot use 'criteria' together with 'match' or 'variable'."}],errorMessage:{oneOf:"You must use either 'match/variable' OR 'criteria', but not both at the same time"}}),Ke={$id:"azionConfig",definitions:{mainConfig:{type:"object",properties:{build:{type:"object",properties:{entry:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}},{type:"object",additionalProperties:{type:"string"}}],errorMessage:"The 'build.entry' must be a string, array of strings, or object with string values"},bundler:{type:"string",enum:["webpack","esbuild"],errorMessage:"The 'build.bundler' must be either 'webpack' or 'esbuild'"},preset:{anyOf:[{type:"string"},{type:"object",properties:{metadata:{type:"object",properties:{name:{type:"string",errorMessage:"The 'name' field in preset metadata must be a string"},ext:{type:"string",errorMessage:"The 'ext' field in preset metadata must be a string"}},required:["name"],additionalProperties:!1,errorMessage:{additionalProperties:"No additional properties are allowed in preset metadata",required:"The 'name' field is required in preset metadata"}},config:{