@zuplo/graphql 5.1586.0 → 5.1588.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +6 -6
- package/index.minified.js +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -56,26 +56,26 @@ declare type CorsPolicy = string | "anything-goes" | "none";
|
|
|
56
56
|
export declare const GraphQLComplexityLimitInboundPolicy: InboundPolicyHandler<GraphQLComplexityLimitInboundPolicyOptions>;
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
|
-
* The options for this policy
|
|
59
|
+
* The options for this policy.
|
|
60
60
|
*/
|
|
61
61
|
export declare interface GraphQLComplexityLimitInboundPolicyOptions {
|
|
62
62
|
useComplexityLimit: {
|
|
63
63
|
/**
|
|
64
|
-
* The maximum complexity a query is allowed to have
|
|
64
|
+
* The maximum complexity a query is allowed to have.
|
|
65
65
|
*/
|
|
66
66
|
complexityLimit?: number;
|
|
67
67
|
/**
|
|
68
|
-
* The endpoint URL to use for the complexity calculation
|
|
68
|
+
* The endpoint URL to use for the complexity calculation.
|
|
69
69
|
*/
|
|
70
70
|
endpointUrl?: string;
|
|
71
71
|
};
|
|
72
72
|
useDepthLimit: {
|
|
73
73
|
/**
|
|
74
|
-
* The maximum depth a query is allowed to have
|
|
74
|
+
* The maximum depth a query is allowed to have.
|
|
75
75
|
*/
|
|
76
76
|
depthLimit?: number;
|
|
77
77
|
/**
|
|
78
|
-
* The fields to ignore when calculating the depth of a query
|
|
78
|
+
* The fields to ignore when calculating the depth of a query.
|
|
79
79
|
*/
|
|
80
80
|
ignore?: string[];
|
|
81
81
|
};
|
|
@@ -99,7 +99,7 @@ export declare interface GraphQLComplexityLimitInboundPolicyOptions {
|
|
|
99
99
|
export declare const GraphQLDisableIntrospectionInboundPolicy: InboundPolicyHandler<GraphqlDisableIntrospectionInboundPolicyOptions>;
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
|
-
* The options for this policy
|
|
102
|
+
* The options for this policy.
|
|
103
103
|
*/
|
|
104
104
|
export declare interface GraphqlDisableIntrospectionInboundPolicyOptions {
|
|
105
105
|
}
|
package/index.minified.js
CHANGED
|
@@ -62,7 +62,7 @@ ${r}
|
|
|
62
62
|
`,this.signedHeaders,await this.hexBodyHash()].join(`
|
|
63
63
|
`)}async hexBodyHash(){let t=this.headers.get("X-Amz-Content-Sha256");if(t==null){if(this.body&&typeof this.body!="string"&&!("byteLength"in this.body))throw new xy.RuntimeError("body must be a string, ArrayBuffer or ArrayBufferView, unless you include the X-Amz-Content-Sha256 header");t=ld(await Ry(this.body||""))}return t}};yn.AwsV4Signer=ks;async function yi(e,t){let r=await crypto.subtle.importKey("raw",typeof e=="string"?dd.encode(e):e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return crypto.subtle.sign("HMAC",r,dd.encode(t))}o(yi,"hmac");async function Ry(e){return crypto.subtle.digest("SHA-256",typeof e=="string"?dd.encode(e):e)}o(Ry,"hash");function ld(e){return Array.prototype.map.call(new Uint8Array(e),t=>("0"+t.toString(16)).slice(-2)).join("")}o(ld,"buf2hex");function Oy(e){return e.replace(/[!'()*]/g,t=>"%"+t.charCodeAt(0).toString(16).toUpperCase())}o(Oy,"encodeRfc3986");function wI(e,t){let{hostname:r,pathname:n}=e,i=r.replace("dualstack.","").match(/([^.]+)\.(?:([^.]*)\.)?amazonaws\.com(?:\.cn)?$/),[s,a]=(i||["",""]).slice(1,3);if(a==="us-gov")a="us-gov-west-1";else if(a==="s3"||a==="s3-accelerate")a="us-east-1",s="s3";else if(s==="iot")r.startsWith("iot.")?s="execute-api":r.startsWith("data.jobs.iot.")?s="iot-jobs-data":s=n==="/mqtt"?"iotdevicegateway":"iotdata";else if(s==="autoscaling"){let c=(t.get("X-Amz-Target")||"").split(".")[0];c==="AnyScaleFrontendService"?s="application-autoscaling":c==="AnyScaleScalingPlannerFrontendService"&&(s="autoscaling-plans")}else a==null&&s.startsWith("s3-")?(a=s.slice(3).replace(/^fips-|^external-1/,""),s="s3"):s.endsWith("-fips")?s=s.slice(0,-5):a&&/-\d$/.test(s)&&!/-\d$/.test(a)&&([s,a]=[a,s]);return s in Py?[Py[s],a]:[s,a]}o(wI,"guessServiceRegion")});var Ny=g(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.convertStringToUtf8Array=Tt.convertUtf8ArrayToString=Tt.base64Encode=Tt.base64Decode=void 0;function vI(e){return e>64&&e<91?e-65:e>96&&e<123?e-71:e>47&&e<58?e+4:e===43?62:e===47?63:0}o(vI,"b64ToUint6");function TI(e,t){let r=e.replace(/[^A-Za-z0-9+/]/g,""),n=r.length,i=t?Math.ceil((n*3+1>>2)/t)*t:n*3+1>>2,s=new Uint8Array(i),a,c,u=0,l=0;for(let d=0;d<n;d++)if(c=d&3,u|=vI(r.charCodeAt(d))<<6*(3-c),c===3||n-d===1){for(a=0;a<3&&l<i;)s[l]=u>>>(16>>>a&24)&255,a++,l++;u=0}return s}o(TI,"base64Decode");Tt.base64Decode=TI;function Fs(e){return e<26?e+65:e<52?e+71:e<62?e-4:e===62?43:e===63?47:65}o(Fs,"uint6ToB64");function SI(e){let t=2,r="",n=e.length,i=0;for(let s=0;s<n;s++)t=s%3,i|=e[s]<<(16>>>t&24),(t===2||e.length-s===1)&&(r+=String.fromCodePoint(Fs(i>>>18&63),Fs(i>>>12&63),Fs(i>>>6&63),Fs(i&63)),i=0);return r.substring(0,r.length-2+t)+(t===2?"":t===1?"=":"==")}o(SI,"base64Encode");Tt.base64Encode=SI;function II(e){let t="",r,n=e.length;for(let i=0;i<n;i++)r=e[i],t+=String.fromCodePoint(r>251&&r<254&&i+5<n?(r-252)*1073741824+(e[++i]-128<<24)+(e[++i]-128<<18)+(e[++i]-128<<12)+(e[++i]-128<<6)+e[++i]-128:r>247&&r<252&&i+4<n?(r-248<<24)+(e[++i]-128<<18)+(e[++i]-128<<12)+(e[++i]-128<<6)+e[++i]-128:r>239&&r<248&&i+3<n?(r-240<<18)+(e[++i]-128<<12)+(e[++i]-128<<6)+e[++i]-128:r>223&&r<240&&i+2<n?(r-224<<12)+(e[++i]-128<<6)+e[++i]-128:r>191&&r<224&&i+1<n?(r-192<<6)+e[++i]-128:r);return t}o(II,"convertUtf8ArrayToString");Tt.convertUtf8ArrayToString=II;function AI(e){let t,r=e.length,n=0;for(let c=0;c<r;c++)t=e.codePointAt(c),t>=65536&&c++,n+=t<128?1:t<2048?2:t<65536?3:t<2097152?4:t<67108864?5:6;let i=new Uint8Array(n),s=0,a=0;for(;s<n;)t=e.codePointAt(a),t<128?i[s++]=t:t<2048?(i[s++]=192+(t>>>6),i[s++]=128+(t&63)):t<65536?(i[s++]=224+(t>>>12),i[s++]=128+(t>>>6&63),i[s++]=128+(t&63)):t<2097152?(i[s++]=240+(t>>>18),i[s++]=128+(t>>>12&63),i[s++]=128+(t>>>6&63),i[s++]=128+(t&63),a++):t<67108864?(i[s++]=248+(t>>>24),i[s++]=128+(t>>>18&63),i[s++]=128+(t>>>12&63),i[s++]=128+(t>>>6&63),i[s++]=128+(t&63),a++):(i[s++]=252+(t>>>30),i[s++]=128+(t>>>24&63),i[s++]=128+(t>>>18&63),i[s++]=128+(t>>>12&63),i[s++]=128+(t>>>6&63),i[s++]=128+(t&63),a++),a++;return i}o(AI,"convertStringToUtf8Array");Tt.convertStringToUtf8Array=AI});var Cy=g(Hs=>{"use strict";Object.defineProperty(Hs,"__esModule",{value:!0});Hs.toCLFDate=void 0;function gn(e){let t=e.toString();return`${t.length===1?"0":""}${t}`}o(gn,"numberToString");function PI(e){let t=e.getTimezoneOffset(),r=Math.abs(t),n=t>0?"-":"+",i=gn(Math.floor(r/60)),s=gn(r%60);return`${n}${i}${s}`}o(PI,"getCLFOffset");function RI(e=new Date){if(!(e instanceof Date))throw new Error("clf-date: invalid parameter");let t=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=gn(e.getDate()),n=t[e.getMonth()],i=e.getFullYear(),s=gn(e.getHours()),a=gn(e.getMinutes()),c=gn(e.getSeconds()),u=PI(e);return`${r}/${n}/${i}:${s}:${a}:${c} ${u}`}o(RI,"toCLFDate");Hs.toCLFDate=RI});var Hy=g(cr=>{"use strict";Object.defineProperty(cr,"__esModule",{value:!0});cr.getResponse=cr.awsLambdaHandler=cr.AwsLambdaHandlerExtensions=void 0;var OI=vr(),Ly=Ay(),gi=L(),xI=xt(),NI=hd(),Uy=Ny(),My=Cy(),Dy=(0,OI.debug)("zuplo:runtime"),CI="X-Amzn-Trace-Id",LI="x-amzn-errortype",ky=[],DI=o(async(e,t,r)=>{let n=r;for await(let i of ky)n=await i(e,t,r);return n},"onSendingAwsLambdaEvent"),Ke=class extends gi.RuntimeError{static{o(this,"AwsLambdaError")}traceId;errorType;constructor(t,r){super(`Failed to invoke AWS Lambda function. ${t}`),this.traceId=r.get(CI)??void 0,this.errorType=r.get(LI)??void 0}};cr.AwsLambdaHandlerExtensions={addSendingAwsLambdaEventHook:e=>{ky.push(e)}};async function UI(e,t){let{accessKeyId:r,secretAccessKey:n,region:i,functionName:s,useLambdaProxyIntegration:a=!0,useAwsResourcePathStyle:c=!1,binaryMediaTypes:u}=t.route.handler.options;if(!r)throw new gi.ConfigurationError("awsAccessKeyId is not set in the handler options");if(!n)throw new gi.ConfigurationError("secretAccessKey is not set in the handler options");if(!i)throw new gi.ConfigurationError("region is not set in the handler options");if(!s)throw new gi.ConfigurationError("functionName is not set in the handler options");let l=new NI.AwsClient({accessKeyId:r,secretAccessKey:n}),d=`https://lambda.${i}.amazonaws.com/2015-03-31/functions/${s}/invocations`;if(Dy(`AWS Lambda URL: ${d}`),!a)return l.fetch(d,{body:await e.arrayBuffer()});let[p,y]=await FI(e,{binaryMediaTypes:u}),{options:h}=t.route.handler,m;h&&typeof h=="object"&&"payloadFormatVersion"in h&&h.payloadFormatVersion==="2.0"?m=kI(e,t):m=await MI(e,t,{useAwsResourcePathStyle:c}),Dy("Calling onSendingAwsLambdaEvent hook");let v=await DI(e,t,m);v.body=p,v.isBase64Encoded=y;let T=await l.fetch(d,{body:JSON.stringify(v)});try{return Fy(T)}catch(S){if(S instanceof Ke){let k=h&&typeof h=="object"&&"returnAmazonTraceIdHeader"in h&&h.returnAmazonTraceIdHeader&&S.traceId?{AMZN_TRACE_ID_HEADER:S.traceId}:void 0;return xI.HttpProblems.internalServerError(e,t,void 0,k)}throw S}}o(UI,"awsLambdaHandler");cr.awsLambdaHandler=UI;async function Fy(e){let t;try{t=await e.json()}catch{throw new Ke("Lambda response did not contain valid JSON",e.headers)}if(e.status!==200)throw t&&typeof t=="object"&&"message"in t&&typeof t.message=="string"?new Ke(t.message,e.headers):new Ke(`Status: ${e.statusText}`,e.headers);if(t&&typeof t=="object"&&"errorMessage"in t&&typeof t.errorMessage=="string")throw new Ke(t.errorMessage,e.headers);if(!t||typeof t!="object"||!("statusCode"in t)||typeof t.statusCode!="number")return new Response(JSON.stringify(t),{status:e.status,headers:{"content-type":"application/json"}});let r=new Headers;if("headers"in t&&t.headers){if(typeof t.headers!="object")throw new Ke(`Response headers must be an object. Received ${typeof t.headers}`,e.headers);for(let[i,s]of Object.entries(t.headers))r.set(i,s)}if("cookies"in t&&t.cookies){if(!Array.isArray(t.cookies))throw new Ke(`Response cookies must be an array. Received ${typeof t.cookies}`,e.headers);r.set("cookie",t.cookies.join(";"))}let n;if("isBase64Encoded"in t&&typeof t.isBase64Encoded!="boolean")throw new Ke(`Response property isBase64Encoded must be a boolean. Received ${typeof t.isBase64Encoded}`,e.headers);if("isBase64Encoded"in t&&t.isBase64Encoded===!0){if(!("body"in t))throw new Ke("Response was set to base64 encoded but no body was set",e.headers);if(typeof t.body!="string")throw new Ke("Response was set to base64 encoded but body was not a string",e.headers);n=(0,Uy.base64Decode)(t.body)}else"body"in t&&typeof t.body=="string"?n=t.statusCode===204&&t.body===""?null:t.body:"body"in t&&t.body!==null&&t.body!==void 0?n=JSON.stringify(t.body):n=null;if(n!==null&&"bodyEncoding"in t){if(typeof t.bodyEncoding!="string"||!(t.bodyEncoding==="gzip"||t.bodyEncoding==="deflate"))throw new Ke(`Response property bodyEncoding can only be set to 'gzip' or 'deflate'. Received ${t.bodyEncoding}`,e.headers);let i=new Blob([n]).stream().pipeThrough(new DecompressionStream(t.bodyEncoding));n=await new Response(i).arrayBuffer()}return new Response(n,{headers:r,status:t.statusCode})}o(Fy,"getResponse");cr.getResponse=Fy;async function MI(e,t,{useAwsResourcePathStyle:r}){let n={},i={};e.headers.forEach((l,d)=>{n[d]=l,i[d]=[l]});let s=e.query,a={};for(let[l,d]of Object.entries(s))a[l]=[d];let c=new URL(e.url);return{version:"1.0",resource:c.pathname,path:c.pathname,httpMethod:e.method,headers:n,multiValueHeaders:i,queryStringParameters:s,multiValueQueryStringParameters:a,requestContext:{accountId:null,apiId:null,authorizer:{claims:{},scopes:[]},domainName:c.hostname,domainPrefix:null,extendedRequestId:t.requestId,httpMethod:e.method,identity:{accessKey:null,accountId:null,caller:null,cognitoAuthenticationProvider:null,cognitoAuthenticationType:null,cognitoIdentityId:null,cognitoIdentityPoolId:null,principalOrgId:null,sourceIp:e.headers.get("CF-Connecting-IP"),user:null,userAgent:e.headers.get("user-agent"),userArn:null,clientCert:{clientCertPem:null,subjectDN:null,issuerDN:null,serialNumber:null,validity:{notBefore:null,notAfter:null}}},path:c.pathname,protocol:"HTTP/1.1",requestId:t.requestId,requestTime:(0,My.toCLFDate)(),requestTimeEpoch:new Date().valueOf(),resourceId:t.route.operationId??null,resourcePath:qI(t.route.path,r),stage:null},pathParameters:e.params,stageVariables:null}}o(MI,"buildEventVersion1");function kI(e,t){let r={};e.headers.forEach((s,a)=>{r[a]=s});let n=new URL(e.url);return{version:"2.0",routeKey:null,rawPath:n.pathname,rawQueryString:n.search,cookies:[],headers:r,queryStringParameters:e.query,requestContext:{accountId:null,apiId:null,authentication:{clientCert:{clientCertPem:null,subjectDN:null,issuerDN:null,serialNumber:null,validity:{notBefore:null,notAfter:null}}},authorizer:{jwt:{claims:{},scopes:[]}},domainName:n.hostname,domainPrefix:null,http:{method:e.method,path:n.pathname,protocol:"HTTP/1.1",sourceIp:e.headers.get("CF-Connecting-IP"),userAgent:e.headers.get("user-agent")},requestId:t.requestId,routeKey:null,stage:null,time:(0,My.toCLFDate)(),timeEpoch:new Date().valueOf()},pathParameters:e.params,stageVariables:null}}o(kI,"buildEventVersion2");async function FI(e,{binaryMediaTypes:t}){let r,n=!1,i=e.headers.get("content-type");if(e.method==="GET"||e.method==="HEAD")r=null;else if(t&&i&&HI(t,i)){let s=await e.arrayBuffer();r=(0,Uy.base64Encode)(new Uint8Array(s)),n=!0}else r=await e.clone().text();return[r,n]}o(FI,"getBodyResult");function HI(e,t){let r=t.split(";")[0].trim().toLowerCase();return e.findIndex(n=>n==="*/*"?!0:n.toLowerCase()===r)>-1}o(HI,"matchesContentType");function qI(e,t=!1){if(!t)return e;let r=(0,Ly.parse)(e),n=(0,Ly.compile)(e),i={};return r.forEach(s=>{typeof s=="string"?i[s]=`{${s}}`:i[s.name]=`{${s.name}}`}),n(i)}o(qI,"getResourcePath")});var bn=g(_n=>{"use strict";Object.defineProperty(_n,"__esModule",{value:!0});_n.getHandlerUserLogFunction=_n.logBadGatewayResponses=void 0;var $I=Ge(),jI=ee(),VI=[502,503,504];async function GI(e,t){if(VI.includes(e.status)){let r=$I.SystemLogMap.getLogger(t),i=await e.clone().text(),s={};for(let[a,c]of e.headers)s[a]=c;r.warn(`BadGatewayResponse ${e.status}`,{status:e.status,statusText:e.statusText,body:i,headers:s})}}o(GI,"logBadGatewayResponses");_n.logBadGatewayResponses=GI;var fd;function BI(e){if(fd===void 0){let r=jI.Environment.instance.runtime.ZUPLO_HANDLER_WRITE_LOG_LEVEL;["debug","info","warn","error"].includes(r??"")||(r="debug"),fd=r}return e.log[fd]}o(BI,"getHandlerUserLogFunction");_n.getHandlerUserLogFunction=BI});var $y=g(qs=>{"use strict";Object.defineProperty(qs,"__esModule",{value:!0});qs.openApiSpecHandler=void 0;var qy=L(),KI=ge(),md=ee(),JI=bn();async function zI(e,t){let r=md.Environment.instance.build.BUILD_ID,{buildAssetsUrl:n}=md.Environment.instance,i=t.route.handler.options,{openApiFilePath:s}=i;if(!s)throw new qy.ConfigurationError("Open API Spec Handler must have 'openApiFilePath' specified");let a=WI(s);if(!a.isValid)throw new qy.ConfigurationError(a.error);let c;md.Environment.instance.isLocalDevelopment?c=`${n}/${s.substring(1)}`:c=`${n}/${r}${s.substring(1)}`;let u=await fetch(c,{method:e.method,body:e.body,headers:e.headers});if(u.status!==200)return KI.HttpProblems.notFound(e,t,{detail:"OpenAPI file could not be found."});let l=new Response(u.body,{headers:{"content-type":"application/json"},status:u.status,statusText:u.statusText});return(0,JI.logBadGatewayResponses)(l,t),l}o(zI,"openApiSpecHandler");qs.openApiSpecHandler=zI;var WI=o(e=>e.startsWith("./")?e.startsWith("./config")?e.endsWith(".oas.json")?{isValid:!0}:{isValid:!1,error:"'openApiFilePath' must point to a file ending in '.oas.json'"}:{isValid:!1,error:"'openApiFilePath' must point to a file in your /config directory"}:{isValid:!1,error:"'openApiFilePath' must start with './'"},"validateOpenApiPath")});var jy=g($s=>{"use strict";Object.defineProperty($s,"__esModule",{value:!0});$s.redirectHandler=void 0;var QI=L();async function YI(e,t){let r=t.route.handler.options;if(!r.location)throw new QI.ConfigurationError("Redirect Handler must have 'location' specified");let n=r.status??302;return new Response(null,{status:n,headers:{location:r.location}})}o(YI,"redirectHandler");$s.redirectHandler=YI});var Gy=g(js=>{"use strict";Object.defineProperty(js,"__esModule",{value:!0});js.urlForwardHandler=void 0;var ZI=L(),Vy=bn();function XI(e,t){let r=e.endsWith("/"),n=t.startsWith("/");return r&&n?`${e.substring(0,e.length-1)}${t}`:!r&&!n?`${e}/${t}`:`${e}${t}`}o(XI,"join");async function eA(e,t){let r=(0,Vy.getHandlerUserLogFunction)(t),n=t.route.handler.options,i=n.forwardSearch!==!1;if(!n.baseUrl)throw new Error("URL Forward Handler must have 'baseUrl' specified");if(!n||typeof n.__rewriteFunction!="function")throw new ZI.ConfigurationError("Invalid options for this route");let s={incomingRequestProperties:t.incomingRequestProperties,requestId:t.requestId,route:t.route,custom:t.custom},a=new URL(e.url),c=n.__rewriteFunction(e,s),u=XI(c,a.pathname),l=i?`${u}${a.search}`:u.toString(),d=Date.now();r(`URL Forwarding to '${l}'`);let p=await fetch(l,{method:e.method,body:e.body,headers:e.headers}),y=Date.now()-d;return r(`URL Forward received response ${p.status} - ${p.statusText} in ${y}ms`),(0,Vy.logBadGatewayResponses)(p,t),p}o(eA,"urlForwardHandler");js.urlForwardHandler=eA});var Ky=g(Vs=>{"use strict";Object.defineProperty(Vs,"__esModule",{value:!0});Vs.urlRewriteHandler=void 0;var tA=L(),By=bn(),rA=o((e,t)=>{let r=new URL(e),n=new URL(t);for(let[i,s]of n.searchParams.entries())r.searchParams.append(i,s);return r.toString()},"addQuery");async function nA(e,t){let r=(0,By.getHandlerUserLogFunction)(t),n=t.route.handler.options,i=n.forwardSearch!==!1,s=n.followRedirects??!1;if(!n||typeof n.__rewriteFunction!="function")throw new tA.ConfigurationError("Invalid options for this route");let a={incomingRequestProperties:t.incomingRequestProperties,requestId:t.requestId,route:t.route,custom:t.custom},c=n.__rewriteFunction(e,a),u=i?rA(c,e.url):c,l=Date.now();r(`URL Rewriting to '${u}'`);let d=await fetch(u.toString(),{method:e.method,body:e.body,headers:e.headers,redirect:s?"follow":"manual"}),p=Date.now()-l;return r(`URL Rewrite received response ${d.status} - ${d.statusText} in ${p}ms`),(0,By.logBadGatewayResponses)(d,t),d}o(nA,"urlRewriteHandler");Vs.urlRewriteHandler=nA});var zy=g(Gs=>{"use strict";Object.defineProperty(Gs,"__esModule",{value:!0});Gs.webSocketHandler=void 0;var Jy=L(),iA=id(),oA=xt(),sA=ee(),aA=bn();async function cA(e,t){let r=sA.Environment.instance,n=t.route.handler.options,i=(0,aA.getHandlerUserLogFunction)(t);if(!n||!n.rewritePattern)throw new Jy.ConfigurationError("WebSocket Handler must have option 'rewritePattern' specified");let s=e.headers.get("Upgrade");if(!s||s!=="websocket")return oA.HttpProblems.badRequest(e,t,{detail:"Request must include header 'Upgrade: websocket'"});if(!n||typeof n.__rewriteFunction!="function")throw new Jy.ConfigurationError("Invalid options for this route");let a={incomingRequestProperties:t.incomingRequestProperties,requestId:t.requestId,route:t.route,custom:t.custom},c=n.__rewriteFunction(e,a),u=Date.now();if(i(`Attempting WebSocket connection to '${c}'`),r.isDeno){let p=new Headers(e.headers);if(c.startsWith("service:")){let h=await(0,iA.externalServiceTunnelConfig)(c),m=new URL(c);c=new URL(`${h.serviceBaseUrl}${m.pathname}${m.search}`).toString();for(let T in h.tunnelHeaders)p.set(T,h.tunnelHeaders[T])}c=c.replace(/^(http)/,"ws");try{if(p.get("Authorization")){let h=p.get("Authorization")?.replace("Bearer ","");c+=`?apiKey=${h}`}}catch{}let y=JSON.stringify({url:c});return new Response(y,{headers:p})}c=c.replace(/^(ws)/,"http");let l=await fetch(c,{method:e.method,headers:e.headers,body:e.body});if(l.status!==101||!l.webSocket){let p=await l.text(),y=`WebSocket connection error - ${l.status}: ${l.statusText}, content: '${p}'`;throw new Error(y)}let d=Date.now()-u;return i(`WebSocket connected, received response ${l.status} - ${l.statusText} in ${d}ms`),new Response(null,{status:101,webSocket:l.webSocket})}o(cA,"webSocketHandler");Gs.webSocketHandler=cA});var Wy=g(En=>{"use strict";Object.defineProperty(En,"__esModule",{value:!0});En.webSocketPolicyProcessor=En.getWebSocketPolicyFunctions=void 0;var uA=L(),lA=o((e,t)=>e.map((n,i)=>{let s;if(typeof n.module=="object"&&(s=n.module[n.export]),!s||typeof s!="function"){let a=t==="inbound"?"WebSocketInboundPolicy":"WebSocketOutboundPolicy",c=`policy in position: ${i+1}, export name: ${n.export}`;throw new uA.ConfigurationError(`${a} - Websocket policy must be a valid function (${c})`)}return s}),"getWebSocketPolicyFunctions");En.getWebSocketPolicyFunctions=lA;var dA=o(async(e,t,r,n,i,s)=>{let a=e.data;if(s&&s.length>0){let c=[...s];for(;c.length>0;){let u=c.shift();if(!u)return a;if(a=await u(a,r,t,n,i),a===void 0)return}}return a},"webSocketPolicyProcessor");En.webSocketPolicyProcessor=dA});var Yy=g(Bs=>{"use strict";Object.defineProperty(Bs,"__esModule",{value:!0});Bs.webSocketPipelineHandler=void 0;var yd=L(),pA=xt(),hA=ee(),fA=bn(),gd=Wy();function Qy(e,t,r,n,i){e.addEventListener("close",()=>{t.close()}),e.addEventListener("error",s=>{n.log.error("WebSocket error: ",s),t.send(JSON.stringify(s))}),e.addEventListener("message",s=>{try{o(async c=>{let u=await(0,gd.webSocketPolicyProcessor)(c,e,t,r,n,i);u!==void 0&&t.send(u)},"innerPipeline")(s).catch(n.log.error)}catch(a){n.log.error(a)}})}o(Qy,"wireUpListeners");async function mA(e,t){let r=hA.Environment.instance,n=t.route.handler.options,i=(0,fA.getHandlerUserLogFunction)(t);if(!n||!n.rewritePattern)throw new yd.ConfigurationError("WebSocket Pipeline Handler must have option 'rewritePattern' specified");let s=e.headers.get("Upgrade");if(!s||s!=="websocket")return pA.HttpProblems.badRequest(e,t,{detail:"Request must include header 'Upgrade: websocket'"});if(!n||typeof n.__rewriteFunction!="function")throw new yd.ConfigurationError("Invalid options for this route");let a={incomingRequestProperties:t.incomingRequestProperties,requestId:t.requestId,route:t.route,custom:t.custom},c=n.__rewriteFunction(e,a),u=Date.now();if(i(`Attempting WebSocket connection to '${c}'`),r.isDeno)throw new yd.ConfigurationError("Websocket pipeline handler is currently not supported on working-copy environments");c=c.replace(/^(ws)/,"http");let l=await fetch(c,{method:e.method,headers:e.headers,body:e.body});if(l.status!==101||!l.webSocket){let S=await l.text(),k=`WebSocket connection error - ${l.status}: ${l.statusText}, content: '${S}'`;throw new Error(k)}let d=new WebSocketPair,[p,y]=Object.values(d),h=Date.now()-u;i(`WebSocket connected, received response ${l.status} - ${l.statusText} in ${h}ms`);let m=l.webSocket;m.accept(),y.accept();let v=n.policies&&n.policies.inbound?(0,gd.getWebSocketPolicyFunctions)(n.policies.inbound,"inbound"):[],T=n.policies&&n.policies.outbound?(0,gd.getWebSocketPolicyFunctions)(n.policies.outbound,"outbound"):[];return Qy(y,m,e,t,v),Qy(m,y,e,t,T),new Response(null,{status:101,webSocket:p})}o(mA,"webSocketPipelineHandler");Bs.webSocketPipelineHandler=mA});var Zy=g(Ks=>{"use strict";Object.defineProperty(Ks,"__esModule",{value:!0});Ks.DynaTraceLoggingPlugin=void 0;var yA=ve(),_d=ee(),gA=Or(),_A=Ct(),bA=yt(),bd=class extends _A.LogPlugin{static{o(this,"DynaTraceLoggingPlugin")}options;constructor(t){super(),this.options=t}getTransport(){return new Ed(this.options)}};Ks.DynaTraceLoggingPlugin=bd;var Ed=class{static{o(this,"DynaTraceTransport")}constructor(t){this.#e=t.url,this.#t=t.apiToken,this.#n=_d.Environment.instance.loggingEnvironmentType,this.#i=_d.Environment.instance.loggingEnvironmentStage,this.#r=_d.Environment.instance.deploymentName}#e;#t;#r;#n;#i;async log(t,r){t.messages.forEach(n=>{let i={timestamp:new Date().toISOString(),message:(0,bA.stringifyNonString)((0,gA.serializeError)(n)),severity:t.level,"log.source":t.logSource,requestId:t.requestId,"custom.environment":this.#r,"custom.environmentStage":this.#i,"custom.environmentType":this.#n,"custom.loggingId":t.loggingId,"custom.rayId":t.rayId===null?void 0:t.rayId};this.batcher.enqueue(i)}),r.waitUntil(this.batcher.waitUntilFlushed())}#o=async t=>{t.length!==0&&await fetch(this.#e,{method:"POST",body:JSON.stringify(t),headers:{"content-type":"application/json; charset=utf-8",authorization:`Api-Token ${this.#t}`}})};batcher=new yA.BatchDispatch("dyna-trace-log-transport",10,this.#o)}});var Xy=g(Js=>{"use strict";Object.defineProperty(Js,"__esModule",{value:!0});Js.LokiLoggingPlugin=void 0;var EA=ve(),wd=ee(),wA=Or(),vA=Ct(),TA=yt(),vd=class extends vA.LogPlugin{static{o(this,"LokiLoggingPlugin")}options;constructor(t){super(),this.options=t}getTransport(){return new Sd(this.options)}};Js.LokiLoggingPlugin=vd;var Td=class{static{o(this,"LokiStream")}constructor(t,r,n,i,s){this.level=t,this.environment=r,this.environmentType=n,this.environmentStage=i,this.requestId=s}job="zuplo";level;environment;environmentType;environmentStage;requestId;equals=t=>this.level===t.level&&this.requestId===t.requestId};function SA(e,t){return btoa(`${e}:${t}`)}o(SA,"createBasicDigest");var Sd=class{static{o(this,"LokiTransport")}constructor(t){this.#e=t.url,this.#t=SA(t.username,t.password),this.#n=wd.Environment.instance.loggingEnvironmentType,this.#i=wd.Environment.instance.loggingEnvironmentStage,this.#r=wd.Environment.instance.deploymentName}#e;#t;#r;#n;#i;async log(t,r){let n=new Td(t.level,this.#r,this.#n,this.#i,t.requestId);t.messages.forEach(i=>{let s={stream:n,message:(0,TA.stringifyNonString)((0,wA.serializeError)(i)),nanoSecondEpoch:`${t.timestamp.getTime()}000000`};this.batcher.enqueue(s)}),r.waitUntil(this.batcher.waitUntilFlushed())}#o=t=>{let r={streams:[]};return t.forEach(n=>{let i=r.streams.find(s=>s.stream.equals(n.stream));i||(i={stream:n.stream,values:[]},r.streams.push(i)),i.values.push([n.nanoSecondEpoch,n.message])}),r};#s=async t=>{if(t.length===0)return;let r=this.#o(t);await fetch(this.#e,{method:"POST",body:JSON.stringify(r),headers:{"content-type":"application/json",authorization:`Basic ${this.#t}`}})};batcher=new EA.BatchDispatch("loki-log-transport",10,this.#s)}});var eg=g(zs=>{"use strict";Object.defineProperty(zs,"__esModule",{value:!0});zs.SumoLogicLoggingPlugin=void 0;var IA=ve(),Id=ee(),AA=Or(),PA=Ct(),RA=yt(),Ad=class extends PA.LogPlugin{static{o(this,"SumoLogicLoggingPlugin")}options;constructor(t){super(),this.options=t}getTransport(){return new Pd(this.options)}};zs.SumoLogicLoggingPlugin=Ad;var Pd=class{static{o(this,"SumoLogicTransport")}constructor(t){this.#e=t.url,this.#i=t.category,this.#o=t.name,this.#r=Id.Environment.instance.loggingEnvironmentType,this.#n=Id.Environment.instance.loggingEnvironmentStage,this.#t=Id.Environment.instance.deploymentName}#e;#t;#r;#n;#i;#o;async log(t,r){t.messages.forEach(n=>{let i={timestamp:new Date().toISOString(),message:(0,RA.stringifyNonString)((0,AA.serializeError)(n)),severity:t.level,source:t.logSource,requestId:t.requestId,environment:this.#t,environmentType:this.#r,environmentStage:this.#n,rayId:t.rayId===null?void 0:t.rayId};this.batcher.enqueue(i)}),r.waitUntil(this.batcher.waitUntilFlushed())}#s=async t=>{if(t.length===0)return;let r=t.map(i=>JSON.stringify(i)).join(`
|
|
64
64
|
`),n=new Headers({"content-type":"application/json; charset=utf-8"});this.#o&&n.set("X-Sumo-Name",this.#o),this.#i&&n.set("X-Sumo-Category",this.#i),await fetch(this.#e,{method:"POST",body:r,headers:n})};batcher=new IA.BatchDispatch("sumo-logic-log-transport",10,this.#s)}});var rg=g(wn=>{"use strict";Object.defineProperty(wn,"__esModule",{value:!0});wn.VMWareLogInsightTransport=wn.VMWareLogInsightLoggingPlugin=void 0;var OA=L(),xA=ve(),Rd=ee(),NA=Ct(),tg=yt(),CA="d3a5b78f-8236-48f5-b1df-4fe269d41172",Od=class extends NA.LogPlugin{static{o(this,"VMWareLogInsightLoggingPlugin")}options;constructor(t){super(),this.options=t}getTransport(){return new Ws(this.options)}};wn.VMWareLogInsightLoggingPlugin=Od;var Ws=class{static{o(this,"VMWareLogInsightTransport")}constructor(t){let r;try{r=new URL(t.url)}catch{throw new OA.ConfigurationError(`Invalid option 'url' on 'VMWareLogInsightTransport' plugin. Must be a valid URL, received '${t.url}'`)}this.#e=r.origin,this.#r=Rd.Environment.instance.loggingEnvironmentType,this.#n=Rd.Environment.instance.loggingEnvironmentStage,this.#t=Rd.Environment.instance.deploymentName,this.#i=t.onMessageSending,t.fields&&(this.#o=Object.entries(t.fields).map(([n,i])=>({name:n,content:i})))}#e;#t;#r;#n;#i;#o;async log(t,r){let n=this.buildEntry(t,r);this.batcher.enqueue(n),r.waitUntil(this.batcher.waitUntilFlushed())}buildEntry(t,r){let n=(0,tg.messagesToMultilineText)(t.messages),i={timestamp:Date.now(),text:n,fields:[{name:"severity",content:t.level.toUpperCase()},{name:"request_id",content:t.requestId},{name:"environment_type",content:this.#r},{name:"environment_stage",content:this.#n},{name:"log_source",content:t.logSource},{name:"atomic_counter",content:t.vectorClock}]};return t.rayId&&i.fields.push({name:"request_ray_id",content:t.rayId}),this.#t&&i.fields.push({name:"environment",content:this.#t}),this.#o&&i.fields.push(...this.#o),r.custom&&Object.entries(r.custom).forEach(([s,a])=>{let c=(0,tg.stringifyNonStringToText)(a);c&&i.fields.push({name:s,content:c})}),this.#i&&(i=this.#i(i)),i}#s=async t=>{if(t.length===0)return;let r=await fetch(`${this.#e}/api/v1/events/ingest/${CA}`,{method:"POST",body:JSON.stringify(t),headers:{"content-type":"application/json; charset=utf-8"}});if(r.status!==200)try{let n=await r.text();console.error("Error logging to Log Insight",n)}catch(n){console.error(n)}};batcher=new xA.BatchDispatch("vmware-log-insights-log-transport",10,this.#s)};wn.VMWareLogInsightTransport=Ws});var ig=g(vn=>{"use strict";Object.defineProperty(vn,"__esModule",{value:!0});vn.AWSLogTransport=vn.AWSLoggingPlugin=void 0;var LA=ve(),ng=ee(),DA=Or(),UA=Ct(),MA=yt(),kA=hd(),xd=class extends UA.LogPlugin{static{o(this,"AWSLoggingPlugin")}options;constructor(t){super(),this.options=t}getTransport(){return new Qs(this.options)}};vn.AWSLoggingPlugin=xd;var Qs=class{static{o(this,"AWSLogTransport")}awsClient;environment;environmentType;logGroupName;logStreamName;region;batcher=new LA.BatchDispatch("aws-log-transport",10,async t=>{if(t.length===0)return;let r=JSON.stringify({logGroupName:this.logGroupName,logStreamName:this.logStreamName,logEvents:t});await this.awsClient.fetch(`https://logs.${this.region}.amazonaws.com`,{headers:{"Content-Type":"application/x-amz-json-1.1","x-amz-Target":"Logs_20140328.PutLogEvents"},body:r,aws:{accessKeyId:this.awsClient.accessKeyId,secretAccessKey:this.awsClient.secretAccessKey,service:this.awsClient.service,region:this.awsClient.region}})});constructor({accessKeyId:t,logStreamName:r,logGroupName:n,secretAccessKey:i,region:s}){this.awsClient=new kA.AwsClient({accessKeyId:t,secretAccessKey:i,service:"logs",region:s}),this.logGroupName=n,this.logStreamName=r,this.region=s,this.environmentType=ng.Environment.instance.loggingEnvironmentType,this.environment=ng.Environment.instance.deploymentName}async log(t,r){t.messages.forEach(n=>{let i={timestamp:new Date().getTime(),message:JSON.stringify({data:(0,MA.stringifyNonString)((0,DA.serializeError)(n)),severity:t.level,source:t.logSource,environment:this.environment,requestId:t.requestId,environmentType:this.environmentType,rayId:t.rayId===null?void 0:t.rayId})};this.batcher.enqueue(i)}),r.waitUntil(this.batcher.waitUntilFlushed())}};vn.AWSLogTransport=Qs});var og=g(Oe=>{"use strict";Object.defineProperty(Oe,"__esModule",{value:!0});Oe.AWSLoggingPlugin=Oe.VMWareLogInsightLoggingPlugin=Oe.SumoLogicLoggingPlugin=Oe.LokiLoggingPlugin=Oe.GoogleCloudLoggingPlugin=Oe.DynaTraceLoggingPlugin=Oe.DataDogLoggingPlugin=void 0;var FA=Hl();Object.defineProperty(Oe,"DataDogLoggingPlugin",{enumerable:!0,get:function(){return FA.DataDogLoggingPlugin}});var HA=Zy();Object.defineProperty(Oe,"DynaTraceLoggingPlugin",{enumerable:!0,get:function(){return HA.DynaTraceLoggingPlugin}});var qA=Es();Object.defineProperty(Oe,"GoogleCloudLoggingPlugin",{enumerable:!0,get:function(){return qA.GoogleCloudLoggingPlugin}});var $A=Xy();Object.defineProperty(Oe,"LokiLoggingPlugin",{enumerable:!0,get:function(){return $A.LokiLoggingPlugin}});var jA=eg();Object.defineProperty(Oe,"SumoLogicLoggingPlugin",{enumerable:!0,get:function(){return jA.SumoLogicLoggingPlugin}});var VA=rg();Object.defineProperty(Oe,"VMWareLogInsightLoggingPlugin",{enumerable:!0,get:function(){return VA.VMWareLogInsightLoggingPlugin}});var GA=ig();Object.defineProperty(Oe,"AWSLoggingPlugin",{enumerable:!0,get:function(){return GA.AWSLoggingPlugin}})});var sg=g(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});ur.DataDogMetricsError=ur.DataDogMetricsTransport=ur.DataDogMetricsPlugin=void 0;var BA=Ge(),KA=ve(),JA=ho(),Nd=new WeakMap,zA={tags:[]},Cd=class extends JA.MetricsPlugin{static{o(this,"DataDogMetricsPlugin")}options;constructor(t){super(),this.options=t}getTransport(){return new Ys(this.options)}static setContext(t,r){let n=Nd.get(t);n||(n=zA);let i=Object.assign({...n},r);Nd.set(t,i)}};ur.DataDogMetricsPlugin=Cd;var Ys=class{static{o(this,"DataDogMetricsTransport")}#e;#t;#r;#n;#i;#o=void 0;constructor(t){this.#e=t.apiKey,this.#t=t.url??"https://api.datadoghq.com/api/v2/series",this.#r=Object.assign({latency:!0,requestContentLength:!0,responseContentLength:!0},t.metrics),this.#i=t.include??{},this.#n=t.tags??[]}pushMetrics(t,r){this.#o===void 0&&(this.#o=new KA.BatchDispatch("data-dog-metrics-transport",10,this.dispatchFunction,BA.SystemLogMap.getLogger(r)));let n=Math.floor(t.timestamp.getTime()/1e3),i=this.#n.concat(Nd.get(r)?.tags??[]);if(this.#i.country&&i.push(`country:${t.country}`),this.#i.httpMethod&&i.push(`httpMethod:${t.method}`),this.#i.statusCode&&i.push(`statusCode:${t.statusCode}`),this.#i.path){let s=t.systemRouteName||t.routePath;i.push(`path:${s}`)}this.#r.latency&&this.#o.enqueue({metric:"zuplo.request.latency",type:3,points:[{timestamp:n,value:t.durationMs}],tags:i}),this.#r.requestContentLength&&t.requestContentLength&&this.#o.enqueue({metric:"zuplo.request.content_length",type:3,points:[{timestamp:n,value:t.requestContentLength}],tags:i}),this.#r.responseContentLength&&t.responseContentLength&&this.#o.enqueue({metric:"zuplo.response.content_length",type:3,points:[{timestamp:n,value:t.responseContentLength}],tags:i}),r.waitUntil(this.#o.waitUntilFlushed())}dispatchFunction=async t=>{if(t.length===0)return;let r=JSON.stringify({series:t}),n=await fetch(this.#t,{method:"POST",body:r,headers:{"content-type":"application/json","DD-API-KEY":this.#e}});if(!n.ok)throw new Zs(await n.text())}};ur.DataDogMetricsTransport=Ys;var Zs=class e extends Error{static{o(this,"DataDogMetricsError")}constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};ur.DataDogMetricsError=Zs});var ag=g(lr=>{"use strict";Object.defineProperty(lr,"__esModule",{value:!0});lr.DynaTraceMetricsError=lr.DynaTraceMetricsTransport=lr.DynatraceMetricsPlugin=void 0;var WA=Ge(),QA=ve(),YA=ho(),Ld=new WeakMap,ZA={dimensions:[]},Dd=class extends YA.MetricsPlugin{static{o(this,"DynatraceMetricsPlugin")}options;constructor(t){super(),this.options=t}getTransport(){return new Xs(this.options)}static setContext(t,r){let n=Ld.get(t);n||(n=ZA);let i=Object.assign({...n},r);Ld.set(t,i)}};lr.DynatraceMetricsPlugin=Dd;var Xs=class{static{o(this,"DynaTraceMetricsTransport")}apiToken;#e;#t;dimensions;#r;#n=void 0;constructor(t){this.apiToken=t.apiToken,this.#e=t.url,this.#t=Object.assign({latency:!0,requestContentLength:!0,responseContentLength:!0},t.metrics),this.#r=t.include??{},this.dimensions=t.dimensions??[]}pushMetrics(t,r){this.#n===void 0&&(this.#n=new QA.BatchDispatch("dynatrace-metrics-transport",10,this.dispatchFunction,WA.SystemLogMap.getLogger(r)));let n=Math.floor(t.timestamp.getTime()),i=this.dimensions.concat(Ld.get(r)?.dimensions??[]);if(this.#r.country&&i.push(`country="${t.country}"`),this.#r.httpMethod&&i.push(`http_method="${t.method}"`),this.#r.statusCode&&i.push(`status_code="${t.statusCode}"`),this.#r.path){let a=t.systemRouteName||t.routePath;i.push(`path="${a}"`)}let s=i.join(",");this.#t.latency&&this.#n.enqueue(`zuplo.request.latency,${s} ${t.durationMs} ${n}`),this.#t.requestContentLength&&t.requestContentLength&&this.#n.enqueue(`zuplo.request.content_length,${s} ${t.requestContentLength} ${n}`),this.#t.responseContentLength&&t.responseContentLength&&this.#n.enqueue(`zuplo.response.content_length,${s} ${t.responseContentLength} ${n}`),r.waitUntil(this.#n.waitUntilFlushed())}dispatchFunction=async t=>{if(t.length===0)return;let r=t.join(`
|
|
65
|
-
`),n=await fetch(this.#e,{method:"POST",body:r,headers:{"content-type":"text/plain",Authorization:`Api-Token ${this.apiToken}`}});if(!n.ok)throw new ea(await n.text())}};lr.DynaTraceMetricsTransport=Xs;var ea=class e extends Error{static{o(this,"DynaTraceMetricsError")}constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};lr.DynaTraceMetricsError=ea});var cg=g(Tn=>{"use strict";Object.defineProperty(Tn,"__esModule",{value:!0});Tn.DynatraceMetricsPlugin=Tn.DataDogMetricsPlugin=void 0;var XA=sg();Object.defineProperty(Tn,"DataDogMetricsPlugin",{enumerable:!0,get:function(){return XA.DataDogMetricsPlugin}});var eP=ag();Object.defineProperty(Tn,"DynatraceMetricsPlugin",{enumerable:!0,get:function(){return eP.DynatraceMetricsPlugin}})});var ug=g(ta=>{"use strict";Object.defineProperty(ta,"__esModule",{value:!0});ta.AuditLogDataStaxProvider=void 0;var Ud=class{static{o(this,"AuditLogDataStaxProvider")}constructor(t){this.#e=t}#e;writeLogBatch=async t=>{await Promise.allSettled(t.map(async r=>{await fetch(this.#e.url,{method:"POST",headers:{"X-Cassandra-Token":this.#e.xCassandraToken,"content-type":"application/json"},body:JSON.stringify(r)})}))}};ta.AuditLogDataStaxProvider=Ud});var dg=g(ra=>{"use strict";Object.defineProperty(ra,"__esModule",{value:!0});ra.AuditLogPlugin=void 0;var tP=Ot(),rP=ve(),Md=class extends tP.InitializableRuntimePlugin{static{o(this,"AuditLogPlugin")}constructor(t,r){super(),this.#e=t,this.#t=r}#e;#t;async initialize(t){new kd(t,this.#e,this.#t)}};ra.AuditLogPlugin=Md;var lg=o(e=>{let t={};return e.forEach((r,n)=>{t[n]=r}),t},"serializableHeaders"),nP={requestFilter:async()=>!0,include:{request:{headers:!0,body:!0},response:{headers:!0,body:!0}}},kd=class{static{o(this,"AuditPluginImpl")}constructor(t,r,n){this.#t=r;let i={...nP};n?.requestFilter&&(i.requestFilter=n.requestFilter),n?.include?.request&&Object.assign(i,n.include.request),n?.include?.response&&Object.assign(i,n.include.response),this.#e=i,t.addRequestHook(this.#o),this.#r=new rP.BatchDispatch("audit-log",10,this.#n)}#e;#t;#r;#n=async t=>{await this.#t.writeLogBatch(t)};#i=async(t,r,n,i,s,a)=>{try{let c={timestamp:i,durationMs:s,routePath:n.route.path,requestId:n.requestId,userSub:a,request:{url:r.url,method:r.method,headers:this.#e.include?.request?.headers?lg(r.headers):void 0,body:this.#e.include?.request?.body?await r.text():void 0},response:{status:t.status,statusText:t.statusText,headers:this.#e.include?.response?.headers?lg(t.headers):void 0,body:this.#e.include?.response?.body?await t.text():void 0}};this.#r.enqueue(c),n.waitUntil(this.#r.waitUntilFlushed())}catch(c){n.log.error(c)}};#o=async(t,r)=>{try{if(!await this.#e.requestFilter(t,r))return t;let i=new Date,s=Date.now(),a=t.clone();return r.addResponseSendingFinalHook(async(c,u)=>{let l=Date.now(),d=c.clone(),p=this.#i(d,a,r,i,l-s,u.user?.sub).catch(y=>{r.log.error(y)});r.waitUntil(p)}),t}catch(n){return r.log.error(n),t}}}});var yg=g(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.AmberfloMeteringInboundPolicy=Sn.AmberfloMeteringPolicy=void 0;var pg=L(),iP=ve(),hg=Qn(),mg=new WeakMap,fg={},Fd=class{static{o(this,"AmberfloMeteringPolicy")}static setRequestProperties(t,r){mg.set(t,r)}};Sn.AmberfloMeteringPolicy=Fd;async function oP(e,t,r,n){if(!r.statusCodes)throw new pg.ConfigurationError(`Invalid AmberfloMeterInboundPolicy '${n}': options.statusCodes must be an array of HTTP status code numbers`);let i=Array.isArray(r.statusCodes)?r.statusCodes:(0,hg.statusCodesStringToNumberArray)(r.statusCodes);return t.addResponseSendingFinalHook(async s=>{if(i.includes(s.status)){let a=mg.get(t),c=r.customerId;if(r.customerIdPropertyPath){if(!e.user)throw new pg.RuntimeError(`Unable to apply customerIdPropertyPath '${r.customerIdPropertyPath}' as request.user is 'undefined'.`);c=(0,hg.getValueFromRequestUser)(e.user,r.customerIdPropertyPath,"customerIdPropertyPath")}let u=a?.customerId??c;if(!u){t.log.error(`Error in AmberfloMeterInboundPolicy '${n}': customerId cannot be undefined`);return}let l=a?.meterApiName??r.meterApiName;if(!l){t.log.error(`Error in AmberfloMeterInboundPolicy '${n}': meterApiName cannot be undefined`);return}let d=a?.meterValue??r.meterValue;if(!d){t.log.error(`Error in AmberfloMeterInboundPolicy '${n}': meterValue cannot be undefined`);return}let p={customerId:u,meterApiName:l,meterValue:d,meterTimeInMillis:Date.now(),dimensions:Object.apply(r.dimensions??{},a?.dimensions)},y=fg[r.apiKey];if(!y){let h=r.apiKey,m=e.headers.get("zm-test-id")??"";y=new iP.BatchDispatch("amberflo-ingest-meter",10,async v=>{try{let T=r.url??"https://app.amberflo.io/ingest",S=await fetch(T,{method:"POST",body:JSON.stringify(v),headers:{"content-type":"application/json","x-api-key":h,"zm-test-id":m}});S.ok||t.log.error(`Unexpected response in AmberfloMeteringInboundPolicy '${n}'. ${S.status}: ${await S.text()}`)}catch(T){throw t.log.error(`Error in AmberfloMeteringInboundPolicy '${n}': ${T.message}`),T}}),fg[h]=y}y.enqueue(p),t.waitUntil(y.waitUntilFlushed())}}),e}o(oP,"AmberfloMeteringInboundPolicy");Sn.AmberfloMeteringInboundPolicy=oP});var Hd=g(na=>{"use strict";Object.defineProperty(na,"__esModule",{value:!0});na.sha256=void 0;async function sP(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest({name:"SHA-256"},t);return[...new Uint8Array(r)].map(i=>i.toString(16).padStart(2,"0")).join("")}o(sP,"sha256");na.sha256=sP});var dr=g(ia=>{"use strict";Object.defineProperty(ia,"__esModule",{value:!0});ia.getPolicyCacheName=void 0;var aP=Hd(),gg=new Map;async function cP(e,t){let r,n=gg.get(e);return n!==void 0?r=n:(r=`zuplo-policy-${await(0,aP.sha256)(JSON.stringify({policyName:e,options:t}))}`,gg.set(e,r)),r}o(cP,"getPolicyCacheName");ia.getPolicyCacheName=cP});var Vd=g(oa=>{"use strict";Object.defineProperty(oa,"__esModule",{value:!0});oa.ApiKeyInboundPolicy=void 0;var uP=dr(),lP=Er(),_g=nd(),qd=L(),dP=xt(),$d=Ge(),jd=ee(),pP=_s(),bg="key-metadata-cache-type";function hP(e,t){return t.authScheme===""?e:e.replace(`${t.authScheme} `,"")}o(hP,"getKeyValue");async function fP(e,t,r,n){if(!r.bucketName)if(_g.environment.ZUPLO_API_KEY_SERVICE_BUCKET_NAME)r.bucketName=_g.environment.ZUPLO_API_KEY_SERVICE_BUCKET_NAME;else throw new qd.ConfigurationError(`ApiKeyInboundPolicy '${n}' - no bucketName property provided`);let i={authHeader:r.authHeader??"authorization",authScheme:r.authScheme??"Bearer",bucketName:r.bucketName,cacheTtlSeconds:r.cacheTtlSeconds??60,allowUnauthenticatedRequests:r.allowUnauthenticatedRequests??!1,disableAutomaticallyAddingKeyHeaderToOpenApi:r.disableAutomaticallyAddingKeyHeaderToOpenApi??!1};if(i.cacheTtlSeconds<60)throw new qd.ConfigurationError(`ApiKeyInboundPolicy '${n}' - minimum cacheTtlSeconds value is 60s, '${i.cacheTtlSeconds}' is invalid`);let s=o(T=>i.allowUnauthenticatedRequests?e:dP.HttpProblems.unauthorized(e,t,{detail:T}),"unauthorizedResponse"),a=e.headers.get(i.authHeader);if(!a)return s("No Authorization Header");if(!a.toLowerCase().startsWith(i.authScheme.toLowerCase()))return s("Invalid Authorization Scheme");let c=hP(a,i);if(!c||c==="")return s("No key present");let u=await mP(c),l=await(0,uP.getPolicyCacheName)(n,i),d=new lP.MemoryZoneReadThroughCache(l,{logger:$d.SystemLogMap.getLogger(t)}),p=await d.get(u);if(p&&p.isValid===!0)return e.user=p.user,e;if(p&&!p.isValid)return p.typeId!==bg&&$d.SystemLogMap.getLogger(t).error(`ApiKeyInboundPolicy '${n}' - cached metadata has invalid typeId '${p.typeId}'`,p),s("Authorization Failed");let y={key:c},h=await(0,pP.fetchRetry)({retryDelayMs:5,retries:2,logger:$d.SystemLogMap.getLogger(t)},`${jd.Environment.instance.apiKeyServiceUrl}/v1/$validate/${i.bucketName}`,{method:"POST",headers:{"content-type":"application/json","zp-rid":t.requestId,"zp-dn":jd.Environment.instance.deploymentName??"unknown","User-Agent":jd.Environment.instance.systemUserAgent},body:JSON.stringify(y)});if(h.status===401)return t.log.info(`ApiKeyInboundPolicy '${n}' - 401 response from Key Service`),s("Authorization Failed");if(h.status!==200){try{let T=await h.text(),S=JSON.parse(T);t.log.error("Unexpected response from key service",S)}catch{t.log.error("Invalid response from key service")}throw new qd.RuntimeError(`ApiKeyInboundPolicy '${n}' - unexpected response from Key Service. Status: ${h.status}`)}let m=await h.json(),v={isValid:!0,typeId:bg,user:{sub:m.name,data:m.metadata}};return e.user=v.user,d.put(u,v,i.cacheTtlSeconds),e}o(fP,"ApiKeyInboundPolicy");oa.ApiKeyInboundPolicy=fP;async function mP(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r)).map(s=>s.toString(16).padStart(2,"0")).join("")}o(mP,"hashValue")});var Eg=g(sa=>{"use strict";Object.defineProperty(sa,"__esModule",{value:!0});sa.ApiAuthKeyInboundPolicy=void 0;var yP=Vd();sa.ApiAuthKeyInboundPolicy=yP.ApiKeyInboundPolicy});var kt=g(aa=>{"use strict";Object.defineProperty(aa,"__esModule",{value:!0});aa.OpenIdJwtInboundPolicy=void 0;var Bd=(ys(),Gi(ms)),Kd=L(),gP=ge(),Gd={},_P=o(async(e,t)=>{if(!t.jwkUrl||typeof t.jwkUrl!="string")throw new Kd.ConfigurationError("Invalid State - jwkUrl not set");Gd[t.jwkUrl]||(Gd[t.jwkUrl]=(0,Bd.createRemoteJWKSet)(new URL(t.jwkUrl),t.headers?{headers:t.headers}:void 0));let{payload:r}=await(0,Bd.jwtVerify)(e,Gd[t.jwkUrl],{issuer:t.issuer,audience:t.audience});return r},"jwkVerifier"),bP=o(async(e,t)=>{let r;if(t.secret===void 0)throw new Error("secretVerifier requires secret to be defined");if(typeof t.secret=="string"){let s=new TextEncoder().encode(t.secret);r=new Uint8Array(s)}else r=t.secret;let{payload:n}=await(0,Bd.jwtVerify)(e,r,{issuer:t.issuer,audience:t.audience});return n},"secretVerifier"),EP=o(async(e,t,r,n)=>{let i=e.headers.get("Authorization"),s="bearer ",a=o(y=>gP.HttpProblems.unauthorized(e,t,{detail:y}),"unauthorizedResponse");if(!r.jwkUrl&&!r.secret)throw new Kd.ConfigurationError(`OpenIdJwtInboundPolicy policy '${n}': One of 'jwkUrl' or 'secret' options are required.`);if(r.jwkUrl&&r.secret)throw new Kd.ConfigurationError(`OpenIdJwtInboundPolicy policy '${n}': Only one of 'jwkUrl' and 'secret' options should be provided.`);let c=r.jwkUrl?_P:bP,l=await o(async()=>{if(!i)return a("No authorization header");if(i.toLowerCase().indexOf(s)!==0)return a("Invalid bearer token format for authorization header");let y=i.substring(s.length);if(!y||y.length===0)return a("No bearer token on authorization header");try{return await c(y,r)}catch(h){let m=new URL(e.url);return"code"in h&&h.code==="ERR_JWT_EXPIRED"?t.log.warn(`Expired token used on url: ${m.pathname} `,h):t.log.warn(`Invalid token on: ${e.method} ${m.pathname}`,h),a("Invalid token")}},"getJwtOrRejectedResponse")();if(l instanceof Response)return r.allowUnauthenticatedRequests===!0?e:l;let d=r.subPropertyName??"sub",p=l[d];return p?(e.user={sub:p,data:l},e):a(`Token is not valid, no '${d}' property found.`)},"OpenIdJwtInboundPolicy");aa.OpenIdJwtInboundPolicy=EP});var wg=g(ca=>{"use strict";Object.defineProperty(ca,"__esModule",{value:!0});ca.Auth0JwtInboundPolicy=void 0;var wP=kt(),vP=o(async(e,t,r,n)=>(0,wP.OpenIdJwtInboundPolicy)(e,t,{issuer:`https://${r.auth0Domain}/`,audience:r.audience,jwkUrl:`https://${r.auth0Domain}/.well-known/jwks.json`,allowUnauthenticatedRequests:r.allowUnauthenticatedRequests},n),"Auth0JwtInboundPolicy");ca.Auth0JwtInboundPolicy=vP});var vg=g(ua=>{"use strict";Object.defineProperty(ua,"__esModule",{value:!0});ua.BasicAuthInboundPolicy=void 0;var TP=ge(),SP=o(async(e,t,r)=>{let n=e.headers.get("Authorization"),i="basic ",s=o(l=>TP.HttpProblems.unauthorized(e,t,{detail:l}),"unauthorizedResponse"),c=await o(async()=>{if(!n)return await s("No Authorization header");if(n.toLowerCase().indexOf(i)!==0)return await s("Invalid Basic token format for Authorization header");let l=n.substring(i.length);if(!l||l.length===0)return await s("No username:password provided");let d=atob(l).normalize(),p=d.indexOf(":");if(p===-1||/[\0-\x1F\x7F]/.test(d))return await s("Invalid basic token value - see https://tools.ietf.org/html/rfc5234#appendix-B.1");let y=d.substring(0,p),h=d.substring(p+1),m=r.accounts.find(v=>v.username===y&&v.password===h);return m||await s("Invalid username or password")},"getAccountOrRejectedResponse")();if(c instanceof Response)return r.allowUnauthenticatedRequests?e:c;let u=c.username;return e.user={sub:u,data:c.data},e},"BasicAuthInboundPolicy");ua.BasicAuthInboundPolicy=SP});var Tg=g(la=>{"use strict";Object.defineProperty(la,"__esModule",{value:!0});la.CachingInboundPolicy=void 0;var IP=dr(),AP=["cdn-cache-control","cloudflare-cdn-cache-control","surrogate-control","cache-tag","expires"];async function PP(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r)).map(s=>s.toString(16).padStart(2,"0")).join("")}o(PP,"digestMessage");var RP=o(async(e,t)=>{let r=[...t.dangerouslyIgnoreAuthorizationHeader===!0?[]:["authorization"],...t.headers??[]],n=[];for(let[d,p]of e.headers.entries())r.includes(d)&&n.push({key:d.toLowerCase(),value:p});n.sort((d,p)=>d.key.localeCompare(p.key));let i=await PP(JSON.stringify(n)),s=new URL(e.url),a=new URLSearchParams(s.searchParams);a.set("_z-hdr-dgst",i);let c=t.cacheHttpMethods?.includes(e.method.toUpperCase())&&e.method.toUpperCase()!=="GET";c&&a.set("_z-original-method",e.method);let u=`${s.origin}${s.pathname}?${a}`;return new Request(u,{method:c?"GET":e.method})},"createCacheKeyRequest");async function OP(e,t,r,n){let i=await(0,IP.getPolicyCacheName)(n,r),s=await caches.open(i),a=r?.cacheHttpMethods?.map(l=>l.toUpperCase())??["GET"],c=await RP(e,r),u=await s.match(c);return u||(t.addEventListener("responseSent",l=>{try{let d=r.statusCodes??[200,206,301,302,303,404,410],p=l.response.clone();if(!d.includes(p.status)||!a.includes(e.method.toUpperCase()))return;let y=r?.expirationSecondsTtl??60,h=new Response(p.body,p);AP.forEach(m=>h.headers.delete(m)),h.headers.set("cache-control",`s-maxage=${y}`),t.waitUntil(s.put(c,h))}catch(d){t.log.error(`Error in caching-inbound-policy '${n}': "${d.message}"`,d)}}),e)}o(OP,"CachingInboundPolicy");la.CachingInboundPolicy=OP});var Sg=g(da=>{"use strict";Object.defineProperty(da,"__esModule",{value:!0});da.ChangeMethodInboundPolicy=void 0;var xP=L(),NP=Be(),CP=o(async(e,t,r,n)=>{if(!r.method)throw new xP.ConfigurationError(`ChangeMethodInboundPolicy '${n}' options.method must be valid HttpMethod`);return new NP.ZuploRequest(e,{method:r.method})},"ChangeMethodInboundPolicy");da.ChangeMethodInboundPolicy=CP});var Ig=g(pa=>{"use strict";Object.defineProperty(pa,"__esModule",{value:!0});pa.ClearHeadersInboundPolicy=void 0;var LP=Be(),DP=o(async(e,t,r)=>{let n=[...r.exclude??[]],i=new Headers;return n.forEach(a=>{let c=e.headers.get(a);c&&i.set(a,c)}),new LP.ZuploRequest(e,{headers:i})},"ClearHeadersInboundPolicy");pa.ClearHeadersInboundPolicy=DP});var Ag=g(ha=>{"use strict";Object.defineProperty(ha,"__esModule",{value:!0});ha.ClearHeadersOutboundPolicy=void 0;var UP=o(async(e,t,r,n)=>{let i=[...n.exclude??[]],s=new Headers;return i.forEach(c=>{let u=e.headers.get(c);u&&s.set(c,u)}),new Response(e.body,{headers:s,status:e.status,statusText:e.statusText})},"ClearHeadersOutboundPolicy");ha.ClearHeadersOutboundPolicy=UP});var Pg=g(fa=>{"use strict";Object.defineProperty(fa,"__esModule",{value:!0});fa.ClerkJwtInboundPolicy=void 0;var MP=kt(),kP=o(async(e,t,r,n)=>{let i=new URL(r.frontendApiUrl.startsWith("https://")||r.frontendApiUrl.startsWith("http://")?r.frontendApiUrl:`https://${r.frontendApiUrl}`),s=new URL(i);return s.pathname="/.well-known/jwks.json",(0,MP.OpenIdJwtInboundPolicy)(e,t,{issuer:i.href.slice(0,-1),jwkUrl:s.toString(),allowUnauthenticatedRequests:r.allowUnauthenticatedRequests},n)},"ClerkJwtInboundPolicy");fa.ClerkJwtInboundPolicy=kP});var Og=g(ma=>{"use strict";Object.defineProperty(ma,"__esModule",{value:!0});ma.CognitoJwtInboundPolicy=void 0;var Rg=L(),FP=kt(),HP=o(async(e,t,r,n)=>{if(!r.userPoolId)throw new Rg.ConfigurationError("userPoolId must be set in the options for CognitoJwtInboundPolicy");if(!r.region)throw new Rg.ConfigurationError("region must be set in the options for CognitoJwtInboundPolicy");return(0,FP.OpenIdJwtInboundPolicy)(e,t,{issuer:`https://cognito-idp.${r.region}.amazonaws.com/${r.userPoolId}`,jwkUrl:`https://cognito-idp.${r.region}.amazonaws.com/${r.userPoolId}/.well-known/jwks.json`,allowUnauthenticatedRequests:r.allowUnauthenticatedRequests},n)},"CognitoJwtInboundPolicy");ma.CognitoJwtInboundPolicy=HP});var Ng=g(ya=>{"use strict";Object.defineProperty(ya,"__esModule",{value:!0});ya.CompositeInboundPolicy=void 0;var qP=L(),$P=dn(),xg=Yn(),jP=o(async(e,t,r,n)=>{if(!r.policies||r.policies.length===0)throw new qP.ConfigurationError(`CompositeInboundPolicy '${n}' must have valid policies defined`);let i=$P.Gateway.instance,s=(0,xg.getInboundPolicyHandlerAndOptions)(r.policies,i?.routeData.policies);return(0,xg.toStackedInboundHandler)(s)(e,t)},"CompositeInboundPolicy");ya.CompositeInboundPolicy=jP});var pr=g(ga=>{"use strict";Object.defineProperty(ga,"__esModule",{value:!0});ga.optionValidator=void 0;var _i=L();function VP(e,t){let r=o((s,a,c)=>{let u=e[s];if(!(c&&u===void 0)){if(u===void 0)throw new _i.ConfigurationError(`Value of '${String(s)}' on policy '${t}' is required, but no value was set. If using an environment variable, check that it is set correctly.`);if(a==="array"&&Array.isArray(u))throw new _i.ConfigurationError(`Value of '${String(s)}' on policy '${t}' must be an array. Received type ${typeof u}.`);if(typeof u!==a)throw new _i.ConfigurationError(`Value of '${String(s)}' on policy '${t}' must be of type ${a}. Received type ${typeof u}.`);if(typeof u=="string"&&u.length===0)throw new _i.ConfigurationError(`Value of '${String(s)}' on policy '${t}' must be a non-empty string. The value received is empty. If using an environment variable, check that it is set correctly.`);if(typeof u=="number"&&isNaN(u))throw new _i.ConfigurationError(`Value of '${String(s)}' on policy '${t}' must be valid number. If using an environment variable, check that it is set correctly.`)}},"validate"),n=o((s,a)=>(r(s,a,!0),{optional:n,required:i}),"optional"),i=o((s,a)=>(r(s,a,!1),{optional:n,required:i}),"required");return{optional:n,required:i}}o(VP,"optionValidator");ga.optionValidator=VP});var Cg=g(_a=>{"use strict";Object.defineProperty(_a,"__esModule",{value:!0});_a.FirebaseJwtInboundPolicy=void 0;var GP=pr(),BP=kt(),KP=o(async(e,t,r,n)=>((0,GP.optionValidator)(r,n).required("projectId","string").optional("allowUnauthenticatedRequests","boolean"),(0,BP.OpenIdJwtInboundPolicy)(e,t,{issuer:`https://securetoken.google.com/${r.projectId}`,audience:r.projectId,jwkUrl:"https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com",allowUnauthenticatedRequests:r.allowUnauthenticatedRequests},n)),"FirebaseJwtInboundPolicy");_a.FirebaseJwtInboundPolicy=KP});var Lg=g(ba=>{"use strict";Object.defineProperty(ba,"__esModule",{value:!0});ba.FormDataToJsonInboundPolicy=void 0;var JP=Be(),zP=o(async(e,t,r)=>{let n="application/x-www-form-urlencoded",i="multipart/form-data",s=e.headers.get("content-type")?.toLowerCase();if(!s||![i,n].includes(s))return r&&r.badRequestIfNotFormData?new Response(`Bad Request - expected content-type '${n}' or ${i}`,{status:400,statusText:"Bad Request"}):e;let a=await e.formData();if(r&&r.optionalHoneypotName&&a.get(r.optionalHoneypotName)!=="")return new Response("Bad Request",{status:400,statusText:"Bad Request"});let c={};for(let[d,p]of a)c[d]=p.toString();let u=new Headers(e.headers);return u.set("content-type","application/json"),u.delete("content-length"),new JP.ZuploRequest(e,{body:JSON.stringify(c),headers:u})},"FormDataToJsonInboundPolicy");ba.FormDataToJsonInboundPolicy=zP});var Dg=g(Ea=>{"use strict";Object.defineProperty(Ea,"__esModule",{value:!0});Ea.GeoFilterInboundPolicy=void 0;var WP=L(),QP=ge(),In="__unknown__",YP=o(async(e,t,r,n)=>{let i={allow:{countries:Pn(r.allow?.countries,"allow.countries",n),regionCodes:Pn(r.allow?.regionCodes,"allow.regionCode",n),asns:Pn(r.allow?.asns,"allow.asOrganization",n)},block:{countries:Pn(r.block?.countries,"block.countries",n),regionCodes:Pn(r.block?.regionCodes,"block.regionCode",n),asns:Pn(r.block?.asns,"block.asOrganization",n)},ignoreUnknown:r.ignoreUnknown!==!1},s=t.incomingRequestProperties.country?.toLowerCase()??In,a=t.incomingRequestProperties.regionCode?.toLowerCase()??In,c=t.incomingRequestProperties.asn?.toString()??In,u=i.ignoreUnknown&&s===In,l=i.ignoreUnknown&&a===In,d=i.ignoreUnknown&&c===In,p=i.allow.countries,y=i.allow.regionCodes,h=i.allow.asns;if(p.length>0&&!p.includes(s)&&!u||y.length>0&&!y.includes(a)&&!l||h.length>0&&!h.includes(c)&&!d)return An(e,t,n,s,a,c);let m=i.block.countries,v=i.block.regionCodes,T=i.block.asns;return m.length>0&&m.includes(s)&&!u||v.length>0&&v.includes(a)&&!l||T.length>0&&T.includes(c)&&!d?An(e,t,n,s,a,c):e},"GeoFilterInboundPolicy");Ea.GeoFilterInboundPolicy=YP;function An(e,t,r,n,i,s){return t.log.debug(`Request blocked by GeoFilterInboundPolicy '${r}' (country: '${n}', regionCode: '${i}', asn: '${s}')`),QP.HttpProblems.forbidden(e,t,{geographicContext:{country:n,regionCode:i,asn:s}})}o(An,"blockedResponse");function Pn(e,t,r){if(typeof e=="string")return e.split(",").map(n=>n.trim().toLowerCase());if(typeof e>"u")return[];if(Array.isArray(e))return e.map(n=>n.trim().toLowerCase());throw new WP.ConfigurationError(`Invalid '${t}' for GeoFilterInboundPolicy '${r}': '${e}', must be a string or string[]`)}o(Pn,"toLowerStringArray")});var Ug=g(wa=>{"use strict";Object.defineProperty(wa,"__esModule",{value:!0});wa.JWTScopeValidationInboundPolicy=void 0;var ZP=o(async(e,t,r)=>{let n=e.user?.data.scope.split(" ")||[];if(!o((s,a)=>a.every(c=>s.includes(c)),"scopeChecker")(n,r.scopes)){let s={code:"UNAUTHORIZED",help_url:"https://zup.fail/UNAUTHORIZED",message:`JWT must have all the following scopes: ${r.scopes}`};return new Response(JSON.stringify(s),{status:401,statusText:"Unauthorized",headers:{"content-type":"application/json"}})}return e},"JWTScopeValidationInboundPolicy");wa.JWTScopeValidationInboundPolicy=ZP});var kg=g(va=>{"use strict";Object.defineProperty(va,"__esModule",{value:!0});va.MockApiInboundPolicy=void 0;var XP=ge(),eR=o(async(e,t,r,n)=>{let i=t.route.raw().responses;if(!i)return Jd(n,e,t,"No responses defined in the OpenAPI document. Add some responses with examples to use this policy.");let s=Object.keys(i),a=[];if(s.length===0)return Jd(n,e,t,"No response object defined under responses in the OpenAPI document. Add some response objects with examples to use this policy.");if(s.forEach(c=>{i[c].content&&Object.keys(i[c].content).forEach(l=>{let d=i[c].content[l].examples;d&&Object.keys(d).forEach(y=>{a.push({responseName:c,contentName:l,exampleName:y,exampleValue:d[y]})})})}),a=a.filter(c=>!(r.responsePrefixFilter&&!c.responseName.startsWith(r.responsePrefixFilter)||r.contentType&&c.contentName!==r.contentType||r.exampleName&&c.exampleName!==r.exampleName)),r.random&&a.length>1){let c=Math.floor(Math.random()*a.length);return Mg(a[c])}else return a.length>0?Mg(a[0]):Jd(n,e,t,"No examples matching the mocking options found in the OpenAPI document. Add examples to the OpenAPI document matching the options for this policy or change the mocking options to match the examples in the OpenAPI document.")},"MockApiInboundPolicy");va.MockApiInboundPolicy=eR;function Mg(e){let t=JSON.stringify(e.exampleValue,null,2),r=new Headers;switch(r.set("Content-Type",e.contentName),e.responseName){case"1XX":return new Response(t,{status:100,headers:r});case"2XX":return new Response(t,{status:200,headers:r});case"3XX":return new Response(t,{status:300,headers:r});case"4XX":return new Response(t,{status:400,headers:r});case"5XX":case"default":return new Response(t,{status:500,headers:r});default:return new Response(t,{status:Number(e.responseName),headers:r})}}o(Mg,"generateResponse");var Jd=o((e,t,r,n)=>{let i=`Error in policy: ${e} - On route ${t.method} ${r.route.path}. ${n}`;return XP.HttpProblems.internalServerError(t,r,{detail:i})},"getProblemDetailResponse")});var jg=g(Rn=>{"use strict";Object.defineProperty(Rn,"__esModule",{value:!0});Rn.MoesifInboundPolicy=Rn.setMoesifContext=void 0;var tR=L(),rR=ve(),nR="Incoming",iR={logRequestBody:!0,logResponseBody:!0};function Fg(e){let t={};return e.forEach((r,n)=>{t[n]=r}),t}o(Fg,"headersToObject");function Hg(){return new Date().toISOString()}o(Hg,"timestamp");var zd=new WeakMap,oR={};function sR(e,t){let r=zd.get(e);r||(r=oR);let n=Object.assign({...r},t);zd.set(e,n)}o(sR,"setMoesifContext");Rn.setMoesifContext=sR;async function qg(e,t){let r=e.headers.get("content-type"),n=e.clone();if(r&&r.indexOf("json")!==0)try{return await n.json()}catch(s){t.log.error(s)}let i=await n.text();return t.log.debug({textBody:i}),i}o(qg,"readBody");var aR={},Wd;function $g(){if(!Wd)throw new tR.RuntimeError("Invalid State - no _lastLogger");return Wd}o($g,"getLastLogger");function cR(e){let t=aR[e];return t||(t=new rR.BatchDispatch("moesif-inbound",100,async r=>{let n=JSON.stringify(r);$g().debug("posting",n);let i=await fetch("https://api.moesif.net/v1/events/batch",{method:"POST",headers:{"content-type":"application/json","X-Moesif-Application-Id":e},body:n});i.ok||$g().error({status:i.status,body:await i.text()})})),t}o(cR,"getDispatcher");async function uR(e,t,r,n){Wd=t.log;let i=Hg(),s=Object.assign(iR,r);if(!s.applicationId)throw new Error(`Invalid configuration for MoesifInboundPolicy '${n}' - applicationId is required`);let a=s.logRequestBody?await qg(e,t):void 0;return t.addResponseSendingFinalHook(async(c,u)=>{let l=cR(s.applicationId),d=e.headers.get("true-client-ip"),p=zd.get(t)??{},y={time:i,uri:e.url,verb:e.method,body:a,ip_address:d??void 0,api_version:p.apiVersion,headers:Fg(e.headers)},h=s.logResponseBody?await qg(c,t):void 0,m={time:Hg(),status:c.status,headers:Fg(c.headers),body:h},v={request:y,response:m,user_id:p.userId??u.user?.sub,session_token:p.sessionToken,company_id:p.companyId,metadata:p.metadata,direction:nR};l.enqueue(v),t.waitUntil(l.waitUntilFlushed())}),e}o(uR,"MoesifInboundPolicy");Rn.MoesifInboundPolicy=uR});var Vg=g(Ta=>{"use strict";Object.defineProperty(Ta,"__esModule",{value:!0});Ta.OktaJwtInboundPolicy=void 0;var lR=kt(),dR=o(async(e,t,r,n)=>(0,lR.OpenIdJwtInboundPolicy)(e,t,{issuer:r.issuerUrl,audience:r.audience,jwkUrl:`${r.issuerUrl}/v1/keys`,allowUnauthenticatedRequests:r.allowUnauthenticatedRequests},n),"OktaJwtInboundPolicy");Ta.OktaJwtInboundPolicy=dR});var Gg=g(Sa=>{"use strict";Object.defineProperty(Sa,"__esModule",{value:!0});Sa.PropelAuthJwtInboundPolicy=void 0;var pR=(ys(),Gi(ms)),hR=kt(),Qd,fR=o(async(e,t,r,n)=>{if(!Qd)try{Qd=await(0,pR.importSPKI)(r.verifierKey,"RS256")}catch(i){throw t.log.error("Could not import verifier key"),i}return(0,hR.OpenIdJwtInboundPolicy)(e,t,{issuer:r.authUrl,secret:Qd,allowUnauthenticatedRequests:r.allowUnauthenticatedRequests,subPropertyName:"user_id"},n)},"PropelAuthJwtInboundPolicy");Sa.PropelAuthJwtInboundPolicy=fR});var Bg=g(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.throwIfStateNotObject=G.throwIfStateNotNumber=G.throwIfStateNotString=G.throwIfStateUndefinedOrNull=G.throwIfStateUndefined=G.throwIfOptionNotObject=G.throwIfOptionNotNumber=G.throwIfOptionNotString=G.throwIfOptionUndefinedOrNull=G.throwIfOptionUndefined=G.OptionTypeError=G.OptionUndefinedError=G.throwIfNotNumber=G.throwIfNotString=G.throwIfUndefinedOrNull=G.throwIfUndefined=G.ArgumentTypeError=G.ArgumentUndefinedError=G.ValidationError=void 0;var qe=Kt(),et=class extends Error{static{o(this,"ValidationError")}constructor(t){super(t)}};G.ValidationError=et;var bi=class extends et{static{o(this,"ArgumentUndefinedError")}constructor(t){super(`The argument '${t}' is undefined.`)}};G.ArgumentUndefinedError=bi;var Ei=class extends et{static{o(this,"ArgumentTypeError")}constructor(t,r){super(`The argument '${t}' must be of type '${r}'.`)}};G.ArgumentTypeError=Ei;function mR(e,t){if((0,qe.isUndefined)(e))throw new bi(t)}o(mR,"throwIfUndefined");G.throwIfUndefined=mR;function Yd(e,t){if((0,qe.isUndefinedOrNull)(e))throw new bi(t)}o(Yd,"throwIfUndefinedOrNull");G.throwIfUndefinedOrNull=Yd;function yR(e,t){if(Yd(e,t),!(0,qe.isString)(e))throw new Ei(t,"string")}o(yR,"throwIfNotString");G.throwIfNotString=yR;function gR(e,t){if(Yd(e,t),!(0,qe.isNumber)(e))throw new Ei(t,"number")}o(gR,"throwIfNotNumber");G.throwIfNotNumber=gR;var wi=class extends et{static{o(this,"OptionUndefinedError")}constructor(t,r,n){super(`The option '${n}' on the ${t} named '${r}' is undefined.`)}};G.OptionUndefinedError=wi;var On=class extends et{static{o(this,"OptionTypeError")}constructor(t,r,n,i){super(`The option '${n}' on the ${t} named '${r}' must be of type '${i}'.`)}};G.OptionTypeError=On;function _R(e,t,r,n){if((0,qe.isUndefined)(n))throw new wi(e,t,r)}o(_R,"throwIfOptionUndefined");G.throwIfOptionUndefined=_R;function Ia(e,t,r,n){if((0,qe.isUndefinedOrNull)(n))throw new wi(e,t,r)}o(Ia,"throwIfOptionUndefinedOrNull");G.throwIfOptionUndefinedOrNull=Ia;function bR(e,t,r,n){if(Ia(e,t,r,n),!(0,qe.isString)(n))throw new On(e,t,r,"string")}o(bR,"throwIfOptionNotString");G.throwIfOptionNotString=bR;function ER(e,t,r,n){if(Ia(e,t,r,n),!(0,qe.isNumber)(n))throw new On(e,t,r,"number")}o(ER,"throwIfOptionNotNumber");G.throwIfOptionNotNumber=ER;function wR(e,t,r,n){if(Ia(e,t,r,n),!(0,qe.isObject)(n))throw new On(e,t,r,"object")}o(wR,"throwIfOptionNotObject");G.throwIfOptionNotObject=wR;function vR(e,t){if((0,qe.isUndefined)(e))throw new et(t)}o(vR,"throwIfStateUndefined");G.throwIfStateUndefined=vR;function Aa(e,t){if((0,qe.isUndefinedOrNull)(e))throw new et(t)}o(Aa,"throwIfStateUndefinedOrNull");G.throwIfStateUndefinedOrNull=Aa;function TR(e,t){if(Aa(e,t),!(0,qe.isString)(e))throw new et(t);return!0}o(TR,"throwIfStateNotString");G.throwIfStateNotString=TR;function SR(e,t){if(Aa(e,t),!(0,qe.isNumber)(e))throw new et(t);return!0}o(SR,"throwIfStateNotNumber");G.throwIfStateNotNumber=SR;function IR(e,t){if(Aa(e,t),!(0,qe.isObject)(e))throw new et(t);return!0}o(IR,"throwIfStateNotObject");G.throwIfStateNotObject=IR});var Kg=g(xn=>{"use strict";Object.defineProperty(xn,"__esModule",{value:!0});xn.InMemoryRedisClient=xn.StandardRedisClient=void 0;var Zd=L(),Pa=Bg(),Xd=class e{static{o(this,"StandardRedisClient")}static instance;redisClientUrl;clientAuthToken;userAgent;deploymentName;constructor(t,r,n,i){this.redisClientUrl=t,this.clientAuthToken=r,this.deploymentName=n,this.userAgent=i}static initialize(t,r,n,i){return(0,Pa.throwIfNotString)(t,"redisClientUrl"),(0,Pa.throwIfNotString)(r,"clientAuthToken"),e.instance||(e.instance=new e(t,r,n,i)),e.instance}isEnabled(){return this.redisClientUrl!==void 0&&this.clientAuthToken!==void 0}async fetch({url:t,body:r,method:n,requestId:i}){(0,Pa.throwIfNotString)(t,"url");let s=await fetch(`${this.redisClientUrl}${t}`,{method:n,body:r,headers:{"content-type":"application/json",authorization:`Bearer ${this.clientAuthToken}`,"zp-rid":i,"zp-dn":this.deploymentName,"User-Agent":this.userAgent}}),a=s.headers.get("Content-Type")?.includes("application/json")?await s.json():await s.text();if(s.ok)return a;throw s.status===401?new Zd.SystemError("Redis client failed with 401: Unauthorized"):new Zd.SystemError(`Redis client failed with (${s.status}): ${typeof a=="string"?a:JSON.stringify(a,null,2)}`)}};xn.StandardRedisClient=Xd;var ep=class{static{o(this,"InMemoryRedisClient")}keyValueStore;constructor(){this.keyValueStore=new Map}isEnabled(){return!0}fetch({url:t,body:r,method:n}){if((0,Pa.throwIfNotString)(t,"url"),n==="POST"&&t==="/rate-limit"){let{incrBy:i,expire:s,key:a}=JSON.parse(r),c=Date.now()+s*1e3,u=this.keyValueStore.get(a);u?Date.now()>u.expiresAt?this.keyValueStore.set(a,{value:i,expiresAt:c}):this.keyValueStore.set(a,{value:u.value+i,expiresAt:u.expiresAt}):this.keyValueStore.set(a,{value:i,expiresAt:c});let l=this.keyValueStore.get(a);return Promise.resolve({count:l.value,ttlSeconds:Math.round((l.expiresAt-Date.now())/1e3)})}throw new Zd.SystemError("The in-memory redis client only supports /rate-limit calls")}};xn.InMemoryRedisClient=ep});var Yg=g(xa=>{"use strict";Object.defineProperty(xa,"__esModule",{value:!0});xa.RateLimitInboundPolicy=void 0;var AR=vr(),PR=dr(),RR=Wi(),Ft=L(),OR=ge(),Jg=Ge(),vi=ee(),zg=Kg(),Wg=Kt(),Ra=(0,AR.debug)("zuplo:policies:RateLimitInboundPolicy"),xR="strict",NR=o(e=>{let t=e.headers.get("cf-connecting-ip")??e.headers.get("true-client-ip");if(t)return t;let r=e.headers.get("x-forwarded-for");return r?r.split(",")[0]:"127.0.0.1"},"getRealIP"),CR=o(async e=>({key:`ip-${NR(e)}`}),"getIP"),LR=o(async e=>({key:`user-${e.user?.sub??"anonymous"}`}),"getUser"),DR=o(async()=>({key:"all-2d77ce9d-9a3c-4206-9ab2-668cfd271095"}),"getAll"),Oa;function UR(e,t){let r;if(Oa)return Oa;if(vi.Environment.instance.isLocalDevelopment)return t.info("Using in-memory redis client for local development."),r=new zg.InMemoryRedisClient,Oa=r,r;let{authApiJWT:n,redisURL:i}=vi.Environment.instance;if(!(0,Wg.isString)(i))throw new Ft.SystemError(`RateLimitInboundPolicy '${e}' - rate limit service URL not configured`);if(!(0,Wg.isString)(n))throw new Ft.SystemError(`RateLimitInboundPolicy '${e}' - service authentication not configured`);if(i&&(r=zg.StandardRedisClient.initialize(i,n,vi.Environment.instance.deploymentName??"unknown",vi.Environment.instance.systemUserAgent)),!r||!r.isEnabled())throw new Ft.SystemError(`RateLimitInboundPolicy '${e}' - no redis ('${r}') or redis.isEnabled ('${r?.isEnabled}) is false`);return Oa=r,r}o(UR,"getRedisClient");async function Qg(e,t,r,n,i){let s=Math.floor(t*60);return await r.fetch({url:"/rate-limit",method:"POST",body:JSON.stringify({incrBy:1,expire:s,key:e}),requestId:i})}o(Qg,"getCountAndUpdateExpiry");function MR(e,t){let r;if(e.rateLimitBy==="function"){if(!e.identifier)throw new Ft.ConfigurationError(`RateLimitInboundPolicy '${t}' - If rateLimitBy set to 'function' options.identifier must be specified`);if(!e.identifier.module)throw new Ft.ConfigurationError(`RateLimitInboundPolicy '${t}' - If rateLimitBy set to 'function' options.identifier.module must be specified`);if(!e.identifier.export)throw new Ft.ConfigurationError(`RateLimitInboundPolicy '${t}' - If rateLimitBy set to 'function' options.identifier.export must be specified`);if(r=e.identifier.module[e.identifier.export],!r||typeof r!="function")throw new Ft.ConfigurationError(`RateLimitInboundPolicy '${t}' - Custom rate limit function must be a valid function`)}return o(async(i,s,a)=>{let c=await r(i,s,a);if(!c.key){let u=`RateLimitInboundPolicy '${a}' - Custom rate limit function must return a valid key property '${JSON.stringify(c,null,2)}'`;throw s.log.error(u),new Ft.RuntimeError(u)}return c},"outerFunction")}o(MR,"wrapUserFunction");var kR="Retry-After",FR=o(async(e,t,r,n)=>{let i=Date.now(),s=Jg.SystemLogMap.getLogger(t),a=o((u,l)=>{if(r.throwOnFailure)throw new Ft.SystemError(u,{cause:l});s.error(u,l)},"throwOrLog"),c=o((u,l)=>{let d={};return(!u||u==="retry-after")&&(d[kR]=l.toString()),OR.HttpProblems.tooManyRequests(e,t,void 0,d)},"rateLimited");try{let l={function:MR(r,n),user:LR,ip:CR,all:DR}[r.rateLimitBy],d=await l(e,t,n),p=d.key,y=d.requestsAllowed??r.requestsAllowed,h=d.timeWindowMinutes??r.timeWindowMinutes,m=r.headerMode??"retry-after",v=UR(n,s),S=`bucket/${vi.Environment.instance.build.BUILD_ID}/${n}/${p}`;if((r.mode??xR)==="async"){let C=await(0,PR.getPolicyCacheName)(n,r),re=new RR.ZoneCache(C,{logger:Jg.SystemLogMap.getLogger(t)}),ne=Qg(S,h,v,s,t.requestId),fe=await re.get(S);if(fe!==void 0&&fe<=Date.now()){Ra(`RateLimitInboundPolicy '${n}' - returning 429 from cache for '${S}' (async mode)`);let Ve=Math.round((fe-Date.now())/1e3);return c(m,Ve)}return t.addEventListener("responseSending",Ve=>{try{let E=Ve,F=E.mutableResponse;E.mutableResponse=(async()=>{let Ce=await ne;if(Ce.count>y){let jc=Date.now()+Ce.ttlSeconds*1e3;return re.put(S,jc,Ce.ttlSeconds).catch($p=>{throw s.error($p),$p}),Ra(`RateLimitInboundPolicy '${n}' - returning 429 from redis for '${S}' (async mode)`),c(m,Ce.ttlSeconds)}return F})()}catch(E){s.error(`RateLimitInboundPolicy '${n}' -error in responseSending`,E)}}),e}let j=await Qg(S,h,v,s,t.requestId);return j.count>y?(Ra(`RateLimitInboundPolicy '${n}' - returning 429 from redis for '${S}' (strict mode)`),c(m,j.ttlSeconds)):e}catch(u){return a(u.message,u),e}finally{let u=Date.now()-i;Ra(`RateLimitInboundPolicy '${n}' - latency ${u}ms`)}},"RateLimitInboundPolicy");xa.RateLimitInboundPolicy=FR});var t_=g(Na=>{"use strict";Object.defineProperty(Na,"__esModule",{value:!0});Na.ReadmeMetricsInboundPolicy=void 0;var HR=ve(),tp=ee(),Zg=Qn(),rp;function Xg(e){let t=[];for(let[r,n]of e)t.push({name:r,value:n});return t}o(Xg,"headersToNameValuePairs");function qR(e){let t=[];return Object.entries(e).forEach(([r,n])=>{t.push({name:r,value:n})}),t}o(qR,"queryToNameValueParis");function $R(e){if(e===null)return;let t=parseFloat(e);if(!isNaN(t))return t}o($R,"parseIntOrUndefined");var e_={};async function jR(e,t,r,n){let i=new Date,s=Date.now();return rp||(rp={name:"zuplo",version:tp.Environment.instance.build.ZUPLO_VERSION,comment:`zuplo/${tp.Environment.instance.build.ZUPLO_VERSION}`}),t.addResponseSendingFinalHook(async a=>{try{let c=r.userLabelPropertyPath&&e.user?(0,Zg.getValueFromRequestUser)(e.user,r.userLabelPropertyPath,"userLabelPropertyPath"):e.user?.sub,u=r.userEmailPropertyPath&&e.user?(0,Zg.getValueFromRequestUser)(e.user,r.userEmailPropertyPath,"userEmailPropertyPath"):void 0,l={clientIPAddress:e.headers.get("true-client-ip")??"",development:r.development!==void 0?r.development:tp.Environment.instance.isDeno,group:{label:c,email:u,id:e.user?.sub??"anonymous"},request:{log:{creator:rp,entries:[{startedDateTime:i.toISOString(),time:Date.now()-s,request:{method:e.method,url:r.useFullRequestPath?new URL(e.url).pathname:t.route.path,httpVersion:"2",headers:Xg(e.headers),queryString:qR(e.query)},response:{status:a.status,statusText:a.statusText,headers:Xg(a.headers),content:{size:$R(e.headers.get("content-length"))}}}]}}},d=e_[r.apiKey];if(!d){let p=r.apiKey;d=new HR.BatchDispatch("readme-metering-inbound-policy",10,async y=>{try{let h=r.url??"https://metrics.readme.io/request",m=await fetch(h,{method:"POST",body:JSON.stringify(y),headers:{"content-type":"application/json",authorization:`Basic ${btoa(p+":")}`}});m.status!==202&&t.log.error(`Unexpected response in ReadmeMeteringInboundPolicy '${n}'. ${m.status}: '${await m.text()}'`)}catch(h){throw t.log.error(`Error in ReadmeMeteringInboundPolicy '${n}': '${h.message}'`),h}}),e_[p]=d}d.enqueue(l),t.waitUntil(d.waitUntilFlushed())}catch(c){t.log.error(c)}}),e}o(jR,"ReadmeMetricsInboundPolicy");Na.ReadmeMetricsInboundPolicy=jR});var r_=g(Ca=>{"use strict";Object.defineProperty(Ca,"__esModule",{value:!0});Ca.RemoveHeadersInboundPolicy=void 0;var VR=L(),GR=Be(),BR=o(async(e,t,r,n)=>{let i=r?.headers;if(!i||!Array.isArray(i)||i.length===0)throw new VR.ConfigurationError(`RemoveHeadersInboundPolicy '${n}' options.headers must be a non-empty string array of header names`);let s=new Headers(e.headers);return i.forEach(c=>{s.delete(c)}),new GR.ZuploRequest(e,{headers:s})},"RemoveHeadersInboundPolicy");Ca.RemoveHeadersInboundPolicy=BR});var n_=g(La=>{"use strict";Object.defineProperty(La,"__esModule",{value:!0});La.RemoveHeadersOutboundPolicy=void 0;var KR=L(),JR=o(async(e,t,r,n,i)=>{let s=n?.headers;if(!s||!Array.isArray(s)||s.length===0)throw new KR.ConfigurationError(`RemoveHeadersOutboundPolicy '${i}' options.headers must be a non-empty string array of header names`);let a=new Headers(e.headers);return s.forEach(u=>{a.delete(u)}),new Response(e.body,{headers:a,status:e.status,statusText:e.statusText})},"RemoveHeadersOutboundPolicy");La.RemoveHeadersOutboundPolicy=JR});var i_=g(Da=>{"use strict";Object.defineProperty(Da,"__esModule",{value:!0});Da.RemoveQueryParamsInboundPolicy=void 0;var zR=L(),WR=Be(),QR=o(async(e,t,r,n)=>{let i=r.params;if(!i||!Array.isArray(i)||i.length===0)throw new zR.ConfigurationError(`RemoveQueryParamsInboundPolicy '${n}' options.params must be a non-empty string array of header names`);let s=new URL(e.url);return i.forEach(c=>{s.searchParams.delete(c)}),new WR.ZuploRequest(s.toString(),e)},"RemoveQueryParamsInboundPolicy");Da.RemoveQueryParamsInboundPolicy=QR});var o_=g(Ua=>{"use strict";Object.defineProperty(Ua,"__esModule",{value:!0});Ua.ReplaceStringOutboundPolicy=void 0;var YR=o(async(e,t,r,n)=>{let i=await e.text(),s=n.mode==="regexp"?new RegExp(n.match,"gm"):n.match,a=i.replaceAll(s,n.replaceWith);return new Response(a,{headers:e.headers,status:e.status,statusText:e.statusText})},"ReplaceStringOutboundPolicy");Ua.ReplaceStringOutboundPolicy=YR});var a_=g(Ma=>{"use strict";Object.defineProperty(Ma,"__esModule",{value:!0});Ma.RequestSizeLimitInboundPolicy=void 0;var s_=o(()=>new Response("Maximum request size exceeded",{status:413,statusText:"Payload Too Large"}),"payloadTooLarge"),ZR=o(async(e,t,r)=>{let n=r.trustContentLengthHeader??!1;if(["GET","HEAD"].includes(e.method))return e;let i=e.headers.get("content-length"),s=i!==null?parseInt(i):void 0;return s&&!isNaN(s)&&s>r.maxSizeInBytes?s_():s&&n?e:(await e.clone().text()).length>r.maxSizeInBytes?s_():e},"RequestSizeLimitInboundPolicy");Ma.RequestSizeLimitInboundPolicy=ZR});var ka=g(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.sanitizedIdentifierName=tt.getIdForRefSchema=tt.getIdForRequestBodySchema=tt.getIdForParameterSchema=tt.getRawOperationDataIdentifierName=void 0;function XR(e,t,r){return`_${Ur(e+"_"+t+"_"+r)}`}o(XR,"getRawOperationDataIdentifierName");tt.getRawOperationDataIdentifierName=XR;function e0(e,t,r,n){return`_${Ur(e.toLowerCase())}_`+t.toLowerCase()+"_"+r.toLowerCase()+`_${n.toLowerCase()}`}o(e0,"getIdForParameterSchema");tt.getIdForParameterSchema=e0;function t0(e,t,r){return`_${Ur(e.toLowerCase())}_`+t.toLowerCase()+`_rb_${Ur(r.toLowerCase())}`}o(t0,"getIdForRequestBodySchema");tt.getIdForRequestBodySchema=t0;function r0(e,t){return`_${Ur(e)}__${Ur(t)}`}o(r0,"getIdForRefSchema");tt.getIdForRefSchema=r0;function Ur(e){let t=[];for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);n>="0".charCodeAt(0)&&n<="9".charCodeAt(0)||n>="A".charCodeAt(0)&&n<="Z".charCodeAt(0)||n>="a".charCodeAt(0)&&n<="z".charCodeAt(0)?t.push(e.charAt(r)):t.push("_")}return t.join("")}o(Ur,"sanitizedIdentifierName");tt.sanitizedIdentifierName=Ur});var Ti=g(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});Le.getErrorsFromValidator=Le.shouldReject=Le.shouldLog=Le.logErrors=Le.validateParameters=Le.getParametersForOperation=void 0;var n0=dn(),i0=ka(),o0=o(e=>{let t=e.route.raw();return t.parameters?t.parameters.map(n=>({name:n.name,location:n.in,required:n.required,deprecated:n.deprecated,allowEmptyValue:n.allowEmptyValue})):[]},"getParametersForOperation");Le.getParametersForOperation=o0;var s0=o((e,t,r,n,i)=>{let s=[],a=!0,c=[];return e.forEach(u=>{if(u.required&&!t[u.name])a=!1,s.push(`Required ${i} parameter '${u.name}' not found`);else{let l=(0,i0.getIdForParameterSchema)(r,n,i,u.name),d=n0.Gateway.instance.schemaValidator[l],p=d(t[u.name]),y=(0,Le.getErrorsFromValidator)(d.errors);p||(a=!1,c.push(`${i} parameter: ${u.name} : ${t[u.name]}`),s.push(`Invalid value for ${i} parameter: '${u.name}' ${y.join(", ")}`))}}),{isValid:a,invalidValues:c,errors:s}},"validateParameters");Le.validateParameters=s0;var a0=o((e,t,r,n,i)=>{n?e.log[t](r,n,i):e.log[t](r,i)},"logErrors");Le.logErrors=a0;var c0=o(e=>e==="log-only"||e==="reject-and-log","shouldLog");Le.shouldLog=c0;var u0=o(e=>e==="reject-only"||e==="reject-and-log","shouldReject");Le.shouldReject=u0;var l0=o(e=>e?.map(t=>t.instancePath===void 0||t.instancePath===""?t.message??"Unknown validation error":t.instancePath.replace("/","")+" "+t.message)??["Unknown validation error"],"getErrorsFromValidator");Le.getErrorsFromValidator=l0});var c_=g(Ha=>{"use strict";Object.defineProperty(Ha,"__esModule",{value:!0});Ha.handleBodyValidation=void 0;var d0=dn(),Fa=ge(),p0=ka(),Je=Ti();async function h0(e,t,r){if(!r.validateBody||r.validateBody==="none")return;let n;try{n=await t.clone().json()}catch(h){let m=`Error in request body for method : ${t.method} in route: ${e.route.path} with content-type: ${t.headers.get("Content-Type")}`,v=Fa.HttpProblems.badRequest(t,e,{detail:`${m}, see errors property for more details`,errors:`${h}`});if((0,Je.shouldLog)(r.validateBody)&&(0,Je.logErrors)(e,r.logLevel??"info",m,[n],h),(0,Je.shouldReject)(r.validateBody))return v}if(!t.headers.get("Content-Type")){let h=`No content-type header defined in incoming request to ${t.method} in route: ${e.route.path}`,m=Fa.HttpProblems.badRequest(t,e,{detail:h});return(0,Je.shouldLog)(r.validateBody)&&(0,Je.logErrors)(e,r.logLevel??"info",h,[n],[h]),(0,Je.shouldReject)(r.validateBody)?m:void 0}let i=t.headers.get("Content-Type"),s=i.indexOf(";");s>-1&&(i=i.substring(0,s));let a=(0,p0.getIdForRequestBodySchema)(e.route.path,t.method,i),c=d0.Gateway.instance.schemaValidator[a];if(!c){let h=`No schema defined for method: ${t.method} in route: ${e.route.path} with content-type: ${t.headers.get("Content-Type")}`,m=Fa.HttpProblems.badRequest(t,e,{detail:h});return(0,Je.shouldLog)(r.validateBody)&&(0,Je.logErrors)(e,r.logLevel??"info",h,[n],[h]),(0,Je.shouldReject)(r.validateBody)?m:void 0}if(c(n))return;let l=c.errors,d="Request body did not pass validation",p=(0,Je.getErrorsFromValidator)(l),y=Fa.HttpProblems.badRequest(t,e,{detail:`${d}, see errors property for more details`,errors:p});if((0,Je.shouldLog)(r.validateBody)&&(0,Je.logErrors)(e,r.logLevel??"info",d,[n],p),(0,Je.shouldReject)(r.validateBody))return y}o(h0,"handleBodyValidation");Ha.handleBodyValidation=h0});var u_=g(qa=>{"use strict";Object.defineProperty(qa,"__esModule",{value:!0});qa.handleHeadersValidation=void 0;var f0=ge(),Si=Ti();function m0(e,t,r){if(!r.validateHeaders||r.validateHeaders==="none")return;let n={};t.headers.forEach((a,c)=>{n[c]=a});let i=(0,Si.getParametersForOperation)(e),s=(0,Si.validateParameters)(i.filter(a=>a.location==="header"),n,e.route.path,t.method.toLowerCase(),"header");if(!s.isValid){let a="Header validation failed",c=f0.HttpProblems.badRequest(t,e,{detail:`${a}, see errors property for more details`,errors:s.errors});if((0,Si.shouldLog)(r.validateHeaders)&&(0,Si.logErrors)(e,r.logLevel??"info",a,s.invalidValues,s.errors),(0,Si.shouldReject)(r.validateHeaders))return c}}o(m0,"handleHeadersValidation");qa.handleHeadersValidation=m0});var l_=g($a=>{"use strict";Object.defineProperty($a,"__esModule",{value:!0});$a.handlePathParameterValidation=void 0;var y0=ge(),Ii=Ti();function g0(e,t,r){if(!r.validatePathParameters||r.validatePathParameters==="none")return;let n=(0,Ii.getParametersForOperation)(e),i=(0,Ii.validateParameters)(n.filter(s=>s.location==="path"),t.params,e.route.path,t.method.toLowerCase(),"path");if(!i.isValid){let s="Path parameters validation failed",a=y0.HttpProblems.badRequest(t,e,{detail:`${s}, see errors property for more details`,errors:i.errors});if((0,Ii.shouldLog)(r.validatePathParameters)&&(0,Ii.logErrors)(e,r.logLevel??"info",s,i.invalidValues,i.errors),(0,Ii.shouldReject)(r.validatePathParameters))return a}}o(g0,"handlePathParameterValidation");$a.handlePathParameterValidation=g0});var d_=g(ja=>{"use strict";Object.defineProperty(ja,"__esModule",{value:!0});ja.handleQueryParameterValidation=void 0;var _0=ge(),Ai=Ti();function b0(e,t,r){if(!r.validateQueryParameters||r.validateQueryParameters==="none")return;let n=(0,Ai.getParametersForOperation)(e),i=(0,Ai.validateParameters)(n.filter(s=>s.location==="query"),t.query,e.route.path,t.method.toLowerCase(),"query");if(!i.isValid){let s="Query parameters validation failed",a=_0.HttpProblems.badRequest(t,e,{detail:`${s}, see errors property for more details`,errors:i.errors});if((0,Ai.shouldLog)(r.validateQueryParameters)&&(0,Ai.logErrors)(e,r.logLevel??"info",s,i.invalidValues,i.errors),(0,Ai.shouldReject)(r.validateQueryParameters))return a}}o(b0,"handleQueryParameterValidation");ja.handleQueryParameterValidation=b0});var p_=g(Mr=>{"use strict";Object.defineProperty(Mr,"__esModule",{value:!0});Mr.SchemaBasedRequestValidation=Mr.RequestValidationInboundPolicy=void 0;var E0=c_(),w0=u_(),v0=l_(),T0=d_(),S0=o(async(e,t,r)=>{let n=(0,T0.handleQueryParameterValidation)(t,e,r);if(n!==void 0||(n=(0,v0.handlePathParameterValidation)(t,e,r),n!==void 0)||(n=(0,w0.handleHeadersValidation)(t,e,r),n!==void 0))return n;let i=await(0,E0.handleBodyValidation)(t,e,r);return i!==void 0?i:e},"RequestValidationInboundPolicy");Mr.RequestValidationInboundPolicy=S0;Mr.SchemaBasedRequestValidation=Mr.RequestValidationInboundPolicy});var h_=g(Va=>{"use strict";Object.defineProperty(Va,"__esModule",{value:!0});Va.RequireOriginInboundPolicy=void 0;var I0=L(),A0=ge(),P0=o(async(e,t,r,n)=>{if(r.origins===void 0||r.origins.length===0)throw new I0.ConfigurationError(`RequireOriginInboundPolicy '${n}' configuration error - no allowed origins specified`);let i=typeof r.origins=="string"?r.origins.split(","):r.origins;i=i.map(a=>a.trim());let s=e.headers.get("origin");if(!s||!i.includes(s)){let a=r.failureDetail??"Forbidden";return A0.HttpProblems.forbidden(e,t,{detail:a})}return e},"RequireOriginInboundPolicy");Va.RequireOriginInboundPolicy=P0});var f_=g(Ga=>{"use strict";Object.defineProperty(Ga,"__esModule",{value:!0});Ga.SetBodyInboundPolicy=void 0;var R0=Be(),O0=o(async(e,t,r)=>new R0.ZuploRequest(e,{body:r.body}),"SetBodyInboundPolicy");Ga.SetBodyInboundPolicy=O0});var y_=g(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.SetHeadersInboundPolicy=void 0;var m_=L(),x0=Be(),N0=o(async(e,t,r,n)=>{let i=r.headers;if(!i||!Array.isArray(i)||i.length==0)throw new m_.ConfigurationError(`SetHeadersInboundPolicy '${n}' options.headers must be a valid array of { name, value }`);let s=new Headers(e.headers);return i.forEach(c=>{if(!c.name||c.name.length===0)throw new m_.ConfigurationError(`SetHeadersInboundPolicy '${n}' each option.headers[] entry must have a name property`);let u=c.overwrite===void 0?!0:c.overwrite;(!s.has(c.name)||u)&&s.set(c.name,c.value)}),new x0.ZuploRequest(e,{headers:s})},"SetHeadersInboundPolicy");Ba.SetHeadersInboundPolicy=N0});var __=g(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});Ka.SetHeadersOutboundPolicy=void 0;var g_=L(),C0=o(async(e,t,r,n,i)=>{let s=n.headers;if(!s||!Array.isArray(s)||s.length==0)throw new g_.ConfigurationError(`SetHeadersOutboundPolicy '${i}' options.headers must be a valid array of { name, value }`);let a=new Headers(e.headers);return s.forEach(u=>{if(!u.name||u.name.length===0)throw new g_.ConfigurationError(`SetHeadersOutboundPolicy '${i}' each option.headers[] entry must have a name property`);let l=u.overwrite===void 0?!0:u.overwrite;(!a.has(u.name)||l)&&a.set(u.name,u.value)}),new Response(e.body,{headers:a,status:e.status,statusText:e.statusText})},"SetHeadersOutboundPolicy");Ka.SetHeadersOutboundPolicy=C0});var E_=g(Ja=>{"use strict";Object.defineProperty(Ja,"__esModule",{value:!0});Ja.SetQueryParamsInboundPolicy=void 0;var b_=L(),L0=Be(),D0=o(async(e,t,r,n)=>{let i=r.params;if(!i||!Array.isArray(i)||i.length==0)throw new b_.ConfigurationError(`SetQueryParamsInboundPolicy '${n}' options.params must be a valid array of { name, value }`);let s=new URL(e.url);return i.forEach(c=>{if(!c.name||c.name.length===0)throw new b_.ConfigurationError(`SetQueryParamsInboundPolicy '${n}' each option.params[] entry must have a name property`);let u=c.overwrite===void 0?!0:c.overwrite;(!s.searchParams.has(c.name)||u)&&s.searchParams.set(c.name,c.value)}),new L0.ZuploRequest(s.toString(),e)},"SetQueryParamsInboundPolicy");Ja.SetQueryParamsInboundPolicy=D0});var w_=g(za=>{"use strict";Object.defineProperty(za,"__esModule",{value:!0});za.SetStatusOutboundPolicy=void 0;var U0=o(async(e,t,r,n,i)=>{if(!n.status||isNaN(n.status)||n.status<100||n.status>599)throw new Error(`Invalid SetStatusOutboundPolicy '${i}' - status must be a valid number between 100 and 599, not '${n.status}'`);return new Response(e.body,{headers:e.headers,status:n.status,statusText:n.statusText??e.statusText})},"SetStatusOutboundPolicy");za.SetStatusOutboundPolicy=U0});var v_=g(Wa=>{"use strict";Object.defineProperty(Wa,"__esModule",{value:!0});Wa.SleepInboundPolicy=void 0;var M0=L(),k0=o(async e=>new Promise(r=>{setTimeout(r,e)}),"sleep"),F0=o(async(e,t,r,n)=>{if(!r||r.sleepInMs===void 0||isNaN(r.sleepInMs))throw new M0.ConfigurationError(`SleepInboundPolicy '${n} must have a valid options.sleepInMs value`);return await k0(r.sleepInMs),e},"SleepInboundPolicy");Wa.SleepInboundPolicy=F0});var S_=g(Qa=>{"use strict";Object.defineProperty(Qa,"__esModule",{value:!0});Qa.SupabaseJwtInboundPolicy=void 0;var T_=L(),H0=ge(),q0=Be(),$0=pr(),j0=kt(),V0=o(async(e,t,r,n)=>{(0,$0.optionValidator)(r,n).required("secret","string").optional("allowUnauthenticatedRequests","boolean").optional("requiredClaims","object");let i={secret:r.secret,allowUnauthenticatedRequests:r.allowUnauthenticatedRequests??!1},s=await(0,j0.OpenIdJwtInboundPolicy)(e,t,i,n);if(s instanceof Response)return s;if(!(s instanceof q0.ZuploRequest))throw new T_.SystemError("Invalid State - SupabaseJwtInboundPolicy encountered a non-response that wasn't a ZuploRequest type')");let a=r.requiredClaims;if(!a)return s;let c=e.user?.data.app_metadata;if(!c)throw new T_.RuntimeError(`SupabaseJwtInboundPolicy policy '${n}' - has requiredClaims but the JWT token had no app_metadata property`);let u=Object.keys(a),l=[];return u.forEach(d=>{let p=a[d];Array.isArray(p)?p.includes(c[d])||l.push(d):p!==c[d]&&l.push(d)}),l.length>0?H0.HttpProblems.unauthorized(e,t,{detail:`Invalid JWT token - missing valid claims ${l.join(", ")}`}):s},"SupabaseJwtInboundPolicy");Qa.SupabaseJwtInboundPolicy=V0});var A_=g(Ya=>{"use strict";Object.defineProperty(Ya,"__esModule",{value:!0});Ya.UpstreamAzureAdServiceAuthInboundPolicy=void 0;var G0=dr(),B0=Er(),I_=L(),K0=Ge(),J0=_s(),z0=pr(),W0=o(async(e,t,r,n)=>{(0,z0.optionValidator)(r,n).required("activeDirectoryTenantId","string").required("activeDirectoryClientId","string").required("activeDirectoryClientSecret","string").optional("tokenRetries","number").optional("expirationOffsetSeconds","number");let i=await(0,G0.getPolicyCacheName)(n,r),s=new B0.MemoryZoneReadThroughCache(i,{logger:K0.SystemLogMap.getLogger(t)}),a=await s.get(n);if(!a){let c=await Q0(r,t);s.put(n,c.access_token,c.expires_in-(r.expirationOffsetSeconds??300)),a=c.access_token}return e.headers.set("Authorization",`Bearer ${a}`),e},"UpstreamAzureAdServiceAuthInboundPolicy");Ya.UpstreamAzureAdServiceAuthInboundPolicy=W0;async function Q0(e,t){let r=new URLSearchParams({client_id:e.activeDirectoryClientId,scope:`${e.activeDirectoryClientId}/.default`,client_secret:e.activeDirectoryClientSecret,grant_type:"client_credentials"}),n=await(0,J0.fetchRetry)({retries:e.tokenRetries??3,retryDelayMs:10},`https://login.microsoftonline.com/${e.activeDirectoryTenantId}/oauth2/v2.0/token`,{headers:{"content-type":"application/x-www-form-urlencoded"},method:"POST",body:r});if(n.status!==200){try{let s=await n.text();t.log.error("Could not get token from Azure AD",s)}catch{}throw new I_.RuntimeError("Could not get token from Azure AD")}let i=await n.json();if(i&&typeof i=="object"&&"access_token"in i&&typeof i.access_token=="string"&&"expires_in"in i&&typeof i.expires_in=="number")return{access_token:i.access_token,expires_in:i.expires_in};throw new I_.RuntimeError("Response returned from Azure AD is not in the expected format.")}o(Q0,"getAccessToken")});var R_=g(Za=>{"use strict";Object.defineProperty(Za,"__esModule",{value:!0});Za.UpstreamFirebaseAdminAuthInboundPolicy=void 0;var Y0=dr(),Z0=Er(),X0=L(),eO=Ge(),np=cn(),tO=pr(),P_="https://accounts.google.com/o/oauth2/token",ip,rO=o(async(e,t,r,n)=>{(0,tO.optionValidator)(r,n).required("serviceAccountJson","string"),ip||(ip=await np.GcpServiceAccount.init(r.serviceAccountJson));let i={scope:["https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/firebase.database","https://www.googleapis.com/auth/firebase.messaging","https://www.googleapis.com/auth/identitytoolkit","https://www.googleapis.com/auth/userinfo.email"].join(" ")},s=await(0,Y0.getPolicyCacheName)(n,r),a=new Z0.MemoryZoneReadThroughCache(s,{logger:eO.SystemLogMap.getLogger(t)}),c=await a.get(n);if(!c){let u=await(0,np.getTokenFromGcpServiceAccount)({serviceAccount:ip,audience:P_,payload:i}),l=await(0,np.exchangeGgpJwtForIdToken)(P_,u,{retries:r.tokenRetries??3,retryDelayMs:10});if(!l.access_token)throw new X0.RuntimeError("Invalid OAuth response from Firebase");c=l.access_token,a.put(n,c,(l.expires_in??3600)-(r.expirationOffsetSeconds??300))}return e.headers.set("Authorization",`Bearer ${c}`),e},"UpstreamFirebaseAdminAuthInboundPolicy");Za.UpstreamFirebaseAdminAuthInboundPolicy=rO});var O_=g(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});Xa.UpstreamFirebaseUserAuthInboundPolicy=void 0;var nO=dr(),iO=Er(),Nn=L(),oO=Ge(),sO=Hd(),op=cn(),aO=Qn(),cO=pr(),uO="https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit",lO=["acr","amr","at_hash","aud","auth_time","azp","cnf","c_hash","exp","iat","iss","jti","nbf","nonce"],sp,dO=o(async(e,t,r,n)=>{if((0,cO.optionValidator)(r,n).required("serviceAccountJson","string").required("webApiKey","string").optional("developerClaims","object").optional("userId","string").optional("userIdPropertyPath","string"),!r.userId&&!r.userIdPropertyPath)throw new Nn.ConfigurationError(`Either 'userId' or 'userIdPropertyPath' options must be set on policy '${n}'.`);let i={};if(typeof r.developerClaims<"u"){for(let p in r.developerClaims)if(Object.prototype.hasOwnProperty.call(r.developerClaims,p)){if(lO.indexOf(p)!==-1)throw new Nn.ConfigurationError(`Developer claim "${p}" is reserved and cannot be specified.`);i[p]=r.developerClaims[p]}}sp||(sp=await op.GcpServiceAccount.init(r.serviceAccountJson));let s=r.userId;if(!s&&!r.userIdPropertyPath){if(!e.user)throw new Nn.RuntimeError("Unable to set userId for upstream auth policy as request.user is 'undefined'. Do you have an authentication policy before this policy?.");s=e.user?.sub}else if(r.userIdPropertyPath){if(!e.user)throw new Nn.RuntimeError(`Unable to apply userIdPropertyPath '${r.userIdPropertyPath}' as request.user is 'undefined'. Do you have an authentication policy before this policy?`);s=(0,aO.getValueFromRequestUser)(e.user,r.userIdPropertyPath,"userIdPropertyPath")}if(!s)throw new Nn.RuntimeError(`Unable to determine user from for the policy ${n}`);let a=await(0,nO.getPolicyCacheName)(n,r),c=new iO.MemoryZoneReadThroughCache(a,{logger:oO.SystemLogMap.getLogger(t)}),u={uid:s,claims:i},l=await(0,sO.sha256)(JSON.stringify(u)),d=await c.get(l);if(!d){let p=await(0,op.getTokenFromGcpServiceAccount)({serviceAccount:sp,audience:uO,payload:u}),y=`https://identitytoolkit.googleapis.com/v1/accounts:signInWithCustomToken?key=${r.webApiKey}`,h=await(0,op.exchangeFirebaseJwtForIdToken)(y,p,{retries:r.tokenRetries??3,retryDelayMs:10});if(!h.idToken)throw new Nn.RuntimeError("Invalid token response from Firebase");d=h.idToken,c.put(l,d,(h.expiresIn?parseInt(h.expiresIn):3600)-(r.expirationOffsetSeconds??300))}return e.headers.set("Authorization",`Bearer ${d}`),e},"UpstreamFirebaseUserAuthInboundPolicy");Xa.UpstreamFirebaseUserAuthInboundPolicy=dO});var N_=g(ec=>{"use strict";Object.defineProperty(ec,"__esModule",{value:!0});ec.UpstreamGcpJwtInboundPolicy=void 0;var x_=cn(),pO=pr(),ap,hO=o(async(e,t,r,n)=>{(0,pO.optionValidator)(r,n).required("audience","string").required("serviceAccountJson","string"),ap||(ap=await x_.GcpServiceAccount.init(r.serviceAccountJson));let i=await(0,x_.getTokenFromGcpServiceAccount)({serviceAccount:ap,audience:r.audience});return e.headers.set("Authorization",`Bearer ${i}`),e},"UpstreamGcpJwtInboundPolicy");ec.UpstreamGcpJwtInboundPolicy=hO});var L_=g(tc=>{"use strict";Object.defineProperty(tc,"__esModule",{value:!0});tc.UpstreamGcpServiceAuthInboundPolicy=void 0;var fO=dr(),mO=Wc(),yO=Er(),gO=L(),cp=cn(),_O=pr(),C_="https://www.googleapis.com/oauth2/v4/token",up,bO=o(async(e,t,r,n)=>{(0,_O.optionValidator)(r,n).required("audience","string").required("serviceAccountJson","string").optional("tokenRetries","number").optional("expirationOffsetSeconds","number"),up||(up=await cp.GcpServiceAccount.init(r.serviceAccountJson));let i=await(0,fO.getPolicyCacheName)(n,r),s;r.useMemoryCacheOnly?s=new mO.MemoryCache(i):s=new yO.MemoryZoneReadThroughCache(i,t);let a=await s.get(n);if(!a){let c=await(0,cp.getTokenFromGcpServiceAccount)({serviceAccount:up,audience:C_,payload:{target_audience:`${r.audience}`}}),{id_token:u}=await(0,cp.exchangeGgpJwtForIdToken)(C_,c,{retries:r.tokenRetries??3,retryDelayMs:10});if(!u)throw new gO.RuntimeError("Invalid token response from GCP");a=u,s.put(n,a,3600-(r.expirationOffsetSeconds??300))}return e.headers.set("Authorization",`Bearer ${a}`),e},"UpstreamGcpServiceAuthInboundPolicy");tc.UpstreamGcpServiceAuthInboundPolicy=bO});var U_=g(rc=>{"use strict";Object.defineProperty(rc,"__esModule",{value:!0});rc.ValidateJsonSchemaInbound=void 0;var EO=L(),D_=ge(),wO=o(async(e,t,r)=>{let n=e.clone(),i;try{i=await n.json()}catch{return D_.HttpProblems.badRequest(e,t,{detail:"Invalid JSON body - expected well-formed JSON document"})}if(r.validator(i))return e;let{errors:a}=r.validator;if(!a)throw new EO.SystemError("Invalid state - validator error object is undefined even though validation failed.");let c=a.map(u=>u.instancePath===void 0||u.instancePath===""?"Body "+u.message:u.instancePath.replace("/","")+" "+u.message);return D_.HttpProblems.badRequest(e,t,{detail:"Incoming body did not pass schema validation",errors:c})},"ValidateJsonSchemaInbound");rc.ValidateJsonSchemaInbound=wO});var M_=g(hr=>{"use strict";Object.defineProperty(hr,"__esModule",{value:!0});hr.serialize=hr.ContentTypes=void 0;hr.ContentTypes={Json:"application/json",Form:"application/x-www-form-urlencoded"};function vO(e,t){if(e!==null)return t&&typeof e=="string"?e:typeof e=="object"&&t?.startsWith(hr.ContentTypes.Form)?new URLSearchParams(e).toString():typeof e=="object"&&t?.startsWith(hr.ContentTypes.Json)||!t?JSON.stringify(e):e}o(vO,"serialize");hr.serialize=vO});var k_=g(nc=>{"use strict";Object.defineProperty(nc,"__esModule",{value:!0});nc.ServiceProviderImpl=void 0;var TO=L(),lp=class e{static{o(this,"ServiceProviderImpl")}static#e;services=new Map;constructor(){}static getInstance(){return e.#e||(e.#e=new e),e.#e}setInstance(t){e.#e=t}addService(t,r){if(this.services.get(t))throw new TO.SystemError(`A service with the name ${t} already exists -- you cannot have duplicate services`);this.services.set(t,r)}getService(t){return this.services.get(t)}};nc.ServiceProviderImpl=lp});var F_=g(dp=>{"use strict";Object.defineProperty(dp,"__esModule",{value:!0});var SO={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a Teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"};dp.default=SO});var lo=g(f=>{"use strict";var IO=f&&f.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),H_=f&&f.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&IO(t,e,r)},AO=f&&f.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(f,"__esModule",{value:!0});f.ReadmeMetricsInboundPolicy=f.RateLimitInboundPolicy=f.BasicRateLimitInboundPolicy=f.PropelAuthJwtInboundPolicy=f.OpenIdJwtInboundPolicy=f.OktaJwtInboundPolicy=f.setMoesifContext=f.MoesifInboundPolicy=f.MockApiInboundPolicy=f.JWTScopeValidationInboundPolicy=f.GeoFilterInboundPolicy=f.FormDataToJsonInboundPolicy=f.FirebaseJwtInboundPolicy=f.CompositeInboundPolicy=f.CognitoJwtInboundPolicy=f.ClerkJwtInboundPolicy=f.ClearHeadersOutboundPolicy=f.ClearHeadersInboundPolicy=f.ChangeMethodInboundPolicy=f.CachingInboundPolicy=f.BasicAuthInboundPolicy=f.Auth0JwtInboundPolicy=f.ApiKeyInboundPolicy=f.ApiAuthKeyInboundPolicy=f.AmberfloMeteringPolicy=f.AmberfloMeteringInboundPolicy=f.AuditLogPlugin=f.AuditLogDataStaxProvider=f.HttpStatusCode=f.webSocketPipelineHandler=f.webSocketHandler=f.urlRewriteHandler=f.urlForwardHandler=f.redirectHandler=f.openApiSpecHandler=f.awsLambdaHandler=f.AwsLambdaHandlerExtensions=f.purgeGatewayCache=f.Handler=f.originalFetch=f.ConfigurationError=f.isZuploReadableEnvVariableName=f.isRestrictedEnvVariableName=f.environment=f.ContextData=f.ResponseSentEvent=f.ResponseSendingEvent=f.VALID_COMPATIBILITY_DATES=f.ZoneCache=f.MemoryZoneReadThroughCache=void 0;f.sanitizedIdentifierName=f.getRawOperationDataIdentifierName=f.getIdForRequestBodySchema=f.getIdForRefSchema=f.getIdForParameterSchema=f.SystemLogMap=f.httpStatuses=f.SYSTEM_LOGGER=f.API_KEY=f.ServiceProviderImpl=f.serialize=f.ContentTypes=f.Router=f.LookupResult=f.SystemRouteName=f.ZuploRequest=f.ProblemResponseFormatter=f.HttpProblems=f.ValidateJsonSchemaInbound=f.UpstreamGcpServiceAuthInboundPolicy=f.UpstreamGcpJwtInboundPolicy=f.UpstreamFirebaseUserAuthInboundPolicy=f.UpstreamFirebaseAdminAuthInboundPolicy=f.UpstreamAzureAdServiceAuthInboundPolicy=f.SupabaseJwtInboundPolicy=f.SleepInboundPolicy=f.SetStatusOutboundPolicy=f.SetQueryParamsInboundPolicy=f.SetHeadersOutboundPolicy=f.SetHeadersInboundPolicy=f.SetBodyInboundPolicy=f.RequireOriginInboundPolicy=f.SchemaBasedRequestValidation=f.RequestValidationInboundPolicy=f.RequestSizeLimitInboundPolicy=f.ReplaceStringOutboundPolicy=f.RemoveQueryParamsInboundPolicy=f.RemoveHeadersOutboundPolicy=f.RemoveHeadersInboundPolicy=void 0;Jp();var PO=Er();Object.defineProperty(f,"MemoryZoneReadThroughCache",{enumerable:!0,get:function(){return PO.MemoryZoneReadThroughCache}});var RO=Wi();Object.defineProperty(f,"ZoneCache",{enumerable:!0,get:function(){return RO.ZoneCache}});var OO=Wp();Object.defineProperty(f,"VALID_COMPATIBILITY_DATES",{enumerable:!0,get:function(){return OO.VALID_COMPATIBILITY_DATES}});var q_=Tr();Object.defineProperty(f,"ResponseSendingEvent",{enumerable:!0,get:function(){return q_.ResponseSendingEvent}});Object.defineProperty(f,"ResponseSentEvent",{enumerable:!0,get:function(){return q_.ResponseSentEvent}});var xO=hy();Object.defineProperty(f,"ContextData",{enumerable:!0,get:function(){return xO.ContextData}});var pp=nd();Object.defineProperty(f,"environment",{enumerable:!0,get:function(){return pp.environment}});Object.defineProperty(f,"isRestrictedEnvVariableName",{enumerable:!0,get:function(){return pp.isRestrictedEnvVariableName}});Object.defineProperty(f,"isZuploReadableEnvVariableName",{enumerable:!0,get:function(){return pp.isZuploReadableEnvVariableName}});var NO=L();Object.defineProperty(f,"ConfigurationError",{enumerable:!0,get:function(){return NO.ConfigurationError}});var CO=od();Object.defineProperty(f,"originalFetch",{enumerable:!0,get:function(){return CO.originalFetch}});var $_=vy();Object.defineProperty(f,"Handler",{enumerable:!0,get:function(){return $_.Handler}});Object.defineProperty(f,"purgeGatewayCache",{enumerable:!0,get:function(){return $_.purgeGatewayCache}});var j_=Hy();Object.defineProperty(f,"AwsLambdaHandlerExtensions",{enumerable:!0,get:function(){return j_.AwsLambdaHandlerExtensions}});Object.defineProperty(f,"awsLambdaHandler",{enumerable:!0,get:function(){return j_.awsLambdaHandler}});var LO=$y();Object.defineProperty(f,"openApiSpecHandler",{enumerable:!0,get:function(){return LO.openApiSpecHandler}});var DO=jy();Object.defineProperty(f,"redirectHandler",{enumerable:!0,get:function(){return DO.redirectHandler}});var UO=Gy();Object.defineProperty(f,"urlForwardHandler",{enumerable:!0,get:function(){return UO.urlForwardHandler}});var MO=Ky();Object.defineProperty(f,"urlRewriteHandler",{enumerable:!0,get:function(){return MO.urlRewriteHandler}});var kO=zy();Object.defineProperty(f,"webSocketHandler",{enumerable:!0,get:function(){return kO.webSocketHandler}});var FO=Yy();Object.defineProperty(f,"webSocketPipelineHandler",{enumerable:!0,get:function(){return FO.webSocketPipelineHandler}});var HO=yu();Object.defineProperty(f,"HttpStatusCode",{enumerable:!0,get:function(){return HO.HttpStatusCode}});H_(og(),f);H_(cg(),f);var qO=ug();Object.defineProperty(f,"AuditLogDataStaxProvider",{enumerable:!0,get:function(){return qO.AuditLogDataStaxProvider}});var $O=dg();Object.defineProperty(f,"AuditLogPlugin",{enumerable:!0,get:function(){return $O.AuditLogPlugin}});var V_=yg();Object.defineProperty(f,"AmberfloMeteringInboundPolicy",{enumerable:!0,get:function(){return V_.AmberfloMeteringInboundPolicy}});Object.defineProperty(f,"AmberfloMeteringPolicy",{enumerable:!0,get:function(){return V_.AmberfloMeteringPolicy}});var jO=Eg();Object.defineProperty(f,"ApiAuthKeyInboundPolicy",{enumerable:!0,get:function(){return jO.ApiAuthKeyInboundPolicy}});var VO=Vd();Object.defineProperty(f,"ApiKeyInboundPolicy",{enumerable:!0,get:function(){return VO.ApiKeyInboundPolicy}});var GO=wg();Object.defineProperty(f,"Auth0JwtInboundPolicy",{enumerable:!0,get:function(){return GO.Auth0JwtInboundPolicy}});var BO=vg();Object.defineProperty(f,"BasicAuthInboundPolicy",{enumerable:!0,get:function(){return BO.BasicAuthInboundPolicy}});var KO=Tg();Object.defineProperty(f,"CachingInboundPolicy",{enumerable:!0,get:function(){return KO.CachingInboundPolicy}});var JO=Sg();Object.defineProperty(f,"ChangeMethodInboundPolicy",{enumerable:!0,get:function(){return JO.ChangeMethodInboundPolicy}});var zO=Ig();Object.defineProperty(f,"ClearHeadersInboundPolicy",{enumerable:!0,get:function(){return zO.ClearHeadersInboundPolicy}});var WO=Ag();Object.defineProperty(f,"ClearHeadersOutboundPolicy",{enumerable:!0,get:function(){return WO.ClearHeadersOutboundPolicy}});var QO=Pg();Object.defineProperty(f,"ClerkJwtInboundPolicy",{enumerable:!0,get:function(){return QO.ClerkJwtInboundPolicy}});var YO=Og();Object.defineProperty(f,"CognitoJwtInboundPolicy",{enumerable:!0,get:function(){return YO.CognitoJwtInboundPolicy}});var ZO=Ng();Object.defineProperty(f,"CompositeInboundPolicy",{enumerable:!0,get:function(){return ZO.CompositeInboundPolicy}});var XO=Cg();Object.defineProperty(f,"FirebaseJwtInboundPolicy",{enumerable:!0,get:function(){return XO.FirebaseJwtInboundPolicy}});var ex=Lg();Object.defineProperty(f,"FormDataToJsonInboundPolicy",{enumerable:!0,get:function(){return ex.FormDataToJsonInboundPolicy}});var tx=Dg();Object.defineProperty(f,"GeoFilterInboundPolicy",{enumerable:!0,get:function(){return tx.GeoFilterInboundPolicy}});var rx=Ug();Object.defineProperty(f,"JWTScopeValidationInboundPolicy",{enumerable:!0,get:function(){return rx.JWTScopeValidationInboundPolicy}});var nx=kg();Object.defineProperty(f,"MockApiInboundPolicy",{enumerable:!0,get:function(){return nx.MockApiInboundPolicy}});var G_=jg();Object.defineProperty(f,"MoesifInboundPolicy",{enumerable:!0,get:function(){return G_.MoesifInboundPolicy}});Object.defineProperty(f,"setMoesifContext",{enumerable:!0,get:function(){return G_.setMoesifContext}});var ix=Vg();Object.defineProperty(f,"OktaJwtInboundPolicy",{enumerable:!0,get:function(){return ix.OktaJwtInboundPolicy}});var ox=kt();Object.defineProperty(f,"OpenIdJwtInboundPolicy",{enumerable:!0,get:function(){return ox.OpenIdJwtInboundPolicy}});var sx=Gg();Object.defineProperty(f,"PropelAuthJwtInboundPolicy",{enumerable:!0,get:function(){return sx.PropelAuthJwtInboundPolicy}});var B_=Yg();Object.defineProperty(f,"BasicRateLimitInboundPolicy",{enumerable:!0,get:function(){return B_.RateLimitInboundPolicy}});Object.defineProperty(f,"RateLimitInboundPolicy",{enumerable:!0,get:function(){return B_.RateLimitInboundPolicy}});var ax=t_();Object.defineProperty(f,"ReadmeMetricsInboundPolicy",{enumerable:!0,get:function(){return ax.ReadmeMetricsInboundPolicy}});var cx=r_();Object.defineProperty(f,"RemoveHeadersInboundPolicy",{enumerable:!0,get:function(){return cx.RemoveHeadersInboundPolicy}});var ux=n_();Object.defineProperty(f,"RemoveHeadersOutboundPolicy",{enumerable:!0,get:function(){return ux.RemoveHeadersOutboundPolicy}});var lx=i_();Object.defineProperty(f,"RemoveQueryParamsInboundPolicy",{enumerable:!0,get:function(){return lx.RemoveQueryParamsInboundPolicy}});var dx=o_();Object.defineProperty(f,"ReplaceStringOutboundPolicy",{enumerable:!0,get:function(){return dx.ReplaceStringOutboundPolicy}});var px=a_();Object.defineProperty(f,"RequestSizeLimitInboundPolicy",{enumerable:!0,get:function(){return px.RequestSizeLimitInboundPolicy}});var K_=p_();Object.defineProperty(f,"RequestValidationInboundPolicy",{enumerable:!0,get:function(){return K_.RequestValidationInboundPolicy}});Object.defineProperty(f,"SchemaBasedRequestValidation",{enumerable:!0,get:function(){return K_.SchemaBasedRequestValidation}});var hx=h_();Object.defineProperty(f,"RequireOriginInboundPolicy",{enumerable:!0,get:function(){return hx.RequireOriginInboundPolicy}});var fx=f_();Object.defineProperty(f,"SetBodyInboundPolicy",{enumerable:!0,get:function(){return fx.SetBodyInboundPolicy}});var mx=y_();Object.defineProperty(f,"SetHeadersInboundPolicy",{enumerable:!0,get:function(){return mx.SetHeadersInboundPolicy}});var yx=__();Object.defineProperty(f,"SetHeadersOutboundPolicy",{enumerable:!0,get:function(){return yx.SetHeadersOutboundPolicy}});var gx=E_();Object.defineProperty(f,"SetQueryParamsInboundPolicy",{enumerable:!0,get:function(){return gx.SetQueryParamsInboundPolicy}});var _x=w_();Object.defineProperty(f,"SetStatusOutboundPolicy",{enumerable:!0,get:function(){return _x.SetStatusOutboundPolicy}});var bx=v_();Object.defineProperty(f,"SleepInboundPolicy",{enumerable:!0,get:function(){return bx.SleepInboundPolicy}});var Ex=S_();Object.defineProperty(f,"SupabaseJwtInboundPolicy",{enumerable:!0,get:function(){return Ex.SupabaseJwtInboundPolicy}});var wx=A_();Object.defineProperty(f,"UpstreamAzureAdServiceAuthInboundPolicy",{enumerable:!0,get:function(){return wx.UpstreamAzureAdServiceAuthInboundPolicy}});var vx=R_();Object.defineProperty(f,"UpstreamFirebaseAdminAuthInboundPolicy",{enumerable:!0,get:function(){return vx.UpstreamFirebaseAdminAuthInboundPolicy}});var Tx=O_();Object.defineProperty(f,"UpstreamFirebaseUserAuthInboundPolicy",{enumerable:!0,get:function(){return Tx.UpstreamFirebaseUserAuthInboundPolicy}});var Sx=N_();Object.defineProperty(f,"UpstreamGcpJwtInboundPolicy",{enumerable:!0,get:function(){return Sx.UpstreamGcpJwtInboundPolicy}});var Ix=L_();Object.defineProperty(f,"UpstreamGcpServiceAuthInboundPolicy",{enumerable:!0,get:function(){return Ix.UpstreamGcpServiceAuthInboundPolicy}});var Ax=U_();Object.defineProperty(f,"ValidateJsonSchemaInbound",{enumerable:!0,get:function(){return Ax.ValidateJsonSchemaInbound}});var Px=ge();Object.defineProperty(f,"HttpProblems",{enumerable:!0,get:function(){return Px.HttpProblems}});var Rx=oo();Object.defineProperty(f,"ProblemResponseFormatter",{enumerable:!0,get:function(){return Rx.ProblemResponseFormatter}});var Ox=Be();Object.defineProperty(f,"ZuploRequest",{enumerable:!0,get:function(){return Ox.ZuploRequest}});var xx=Ar();Object.defineProperty(f,"SystemRouteName",{enumerable:!0,get:function(){return xx.SystemRouteName}});var J_=zl();Object.defineProperty(f,"LookupResult",{enumerable:!0,get:function(){return J_.LookupResult}});Object.defineProperty(f,"Router",{enumerable:!0,get:function(){return J_.Router}});var z_=M_();Object.defineProperty(f,"ContentTypes",{enumerable:!0,get:function(){return z_.ContentTypes}});Object.defineProperty(f,"serialize",{enumerable:!0,get:function(){return z_.serialize}});var Nx=k_();Object.defineProperty(f,"ServiceProviderImpl",{enumerable:!0,get:function(){return Nx.ServiceProviderImpl}});var W_=Ru();Object.defineProperty(f,"API_KEY",{enumerable:!0,get:function(){return W_.API_KEY}});Object.defineProperty(f,"SYSTEM_LOGGER",{enumerable:!0,get:function(){return W_.SYSTEM_LOGGER}});var Cx=F_();Object.defineProperty(f,"httpStatuses",{enumerable:!0,get:function(){return AO(Cx).default}});var Lx=Ge();Object.defineProperty(f,"SystemLogMap",{enumerable:!0,get:function(){return Lx.SystemLogMap}});var Pi=ka();Object.defineProperty(f,"getIdForParameterSchema",{enumerable:!0,get:function(){return Pi.getIdForParameterSchema}});Object.defineProperty(f,"getIdForRefSchema",{enumerable:!0,get:function(){return Pi.getIdForRefSchema}});Object.defineProperty(f,"getIdForRequestBodySchema",{enumerable:!0,get:function(){return Pi.getIdForRequestBodySchema}});Object.defineProperty(f,"getRawOperationDataIdentifierName",{enumerable:!0,get:function(){return Pi.getRawOperationDataIdentifierName}});Object.defineProperty(f,"sanitizedIdentifierName",{enumerable:!0,get:function(){return Pi.sanitizedIdentifierName}})});var Q_=g(Cn=>{"use strict";Object.defineProperty(Cn,"__esModule",{value:!0});Cn.BaseCryptoBeta=Cn.supportedDigests=void 0;Cn.supportedDigests=["sha-1","sha-256","sha-384","sha-512"];var hp=class{static{o(this,"BaseCryptoBeta")}};Cn.BaseCryptoBeta=hp});var Y_=g(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});ic.WorkerCryptoBeta=void 0;var fp=Q_(),Dx=L(),mp=class extends fp.BaseCryptoBeta{static{o(this,"WorkerCryptoBeta")}async digest(t,r){if(!fp.supportedDigests.includes(t.toLowerCase()))throw new Dx.RuntimeError(`Algorithm ${t} is not supported. Try using ${fp.supportedDigests.join(", ")}`);let n=new TextEncoder().encode(r),i=await crypto.subtle.digest(t,n);return Array.from(new Uint8Array(i)).map(c=>c.toString(16).padStart(2,"0")).join("")}};ic.WorkerCryptoBeta=mp});var Z_=g(oc=>{"use strict";Object.defineProperty(oc,"__esModule",{value:!0});oc.BaseKeyValueStore=void 0;var yp=class{static{o(this,"BaseKeyValueStore")}context;constructor(t){this.context=t}};oc.BaseKeyValueStore=yp});var eb=g(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});sc.WorkerKeyValueStore=void 0;var X_=L(),Ux=Z_(),gp=class extends Ux.BaseKeyValueStore{static{o(this,"WorkerKeyValueStore")}#e;constructor(t){super(t);let n=globalThis.ZUPLO_KV;if(!n)throw new X_.FeatureNotEnabledError("The Key Value Store feature is not enabled for this project.");this.#e=n}put(t,r,n){if(typeof t!="string")throw new X_.ConfigurationError("value must be of type string");return this.#e.put(t,r,n?{expirationTtl:n.expirationSecondsTtl}:void 0)}get(t,r){return this.#e.get(t,{type:"text",cacheTtl:r?.cacheSecondsTtl})}delete(t){return this.#e.delete(t)}};sc.WorkerKeyValueStore=gp});var xt=g(ct=>{"use strict";var Mx=ct&&ct.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),kx=ct&&ct.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Mx(t,e,r)};Object.defineProperty(ct,"__esModule",{value:!0});ct.KeyValueStore=ct.CryptoBeta=void 0;kx(lo(),ct);var Fx=Y_();Object.defineProperty(ct,"CryptoBeta",{enumerable:!0,get:function(){return Fx.WorkerCryptoBeta}});var Hx=eb();Object.defineProperty(ct,"KeyValueStore",{enumerable:!0,get:function(){return Hx.WorkerKeyValueStore}})});var KN={};Vi(KN,{GraphQLComplexityLimitInboundPolicy:()=>Cb,GraphQLDisableIntrospectionInboundPolicy:()=>Db});module.exports=Gi(KN);var Gn=Vp(xt());function B(e,t){if(!!!e)throw new Error(t)}o(B,"devAssert");function Ee(e){return typeof e=="object"&&e!==null}o(Ee,"isObjectLike");function St(e,t){if(!!!e)throw new Error(t??"Unexpected invariant triggered.")}o(St,"invariant");var qx=/\r\n|[\n\r]/g;function Ln(e,t){let r=0,n=1;for(let i of e.body.matchAll(qx)){if(typeof i.index=="number"||St(!1),i.index>=t)break;r=i.index+i[0].length,n+=1}return{line:n,column:t+1-r}}o(Ln,"getLocation");function _p(e){return ac(e.source,Ln(e.source,e.start))}o(_p,"printLocation");function ac(e,t){let r=e.locationOffset.column-1,n="".padStart(r)+e.body,i=t.line-1,s=e.locationOffset.line-1,a=t.line+s,c=t.line===1?r:0,u=t.column+c,l=`${e.name}:${a}:${u}
|
|
65
|
+
`),n=await fetch(this.#e,{method:"POST",body:r,headers:{"content-type":"text/plain",Authorization:`Api-Token ${this.apiToken}`}});if(!n.ok)throw new ea(await n.text())}};lr.DynaTraceMetricsTransport=Xs;var ea=class e extends Error{static{o(this,"DynaTraceMetricsError")}constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};lr.DynaTraceMetricsError=ea});var cg=g(Tn=>{"use strict";Object.defineProperty(Tn,"__esModule",{value:!0});Tn.DynatraceMetricsPlugin=Tn.DataDogMetricsPlugin=void 0;var XA=sg();Object.defineProperty(Tn,"DataDogMetricsPlugin",{enumerable:!0,get:function(){return XA.DataDogMetricsPlugin}});var eP=ag();Object.defineProperty(Tn,"DynatraceMetricsPlugin",{enumerable:!0,get:function(){return eP.DynatraceMetricsPlugin}})});var ug=g(ta=>{"use strict";Object.defineProperty(ta,"__esModule",{value:!0});ta.AuditLogDataStaxProvider=void 0;var Ud=class{static{o(this,"AuditLogDataStaxProvider")}constructor(t){this.#e=t}#e;writeLogBatch=async t=>{await Promise.allSettled(t.map(async r=>{await fetch(this.#e.url,{method:"POST",headers:{"X-Cassandra-Token":this.#e.xCassandraToken,"content-type":"application/json"},body:JSON.stringify(r)})}))}};ta.AuditLogDataStaxProvider=Ud});var dg=g(ra=>{"use strict";Object.defineProperty(ra,"__esModule",{value:!0});ra.AuditLogPlugin=void 0;var tP=Ot(),rP=ve(),Md=class extends tP.InitializableRuntimePlugin{static{o(this,"AuditLogPlugin")}constructor(t,r){super(),this.#e=t,this.#t=r}#e;#t;async initialize(t){new kd(t,this.#e,this.#t)}};ra.AuditLogPlugin=Md;var lg=o(e=>{let t={};return e.forEach((r,n)=>{t[n]=r}),t},"serializableHeaders"),nP={requestFilter:async()=>!0,include:{request:{headers:!0,body:!0},response:{headers:!0,body:!0}}},kd=class{static{o(this,"AuditPluginImpl")}constructor(t,r,n){this.#t=r;let i={...nP};n?.requestFilter&&(i.requestFilter=n.requestFilter),n?.include?.request&&Object.assign(i,n.include.request),n?.include?.response&&Object.assign(i,n.include.response),this.#e=i,t.addRequestHook(this.#o),this.#r=new rP.BatchDispatch("audit-log",10,this.#n)}#e;#t;#r;#n=async t=>{await this.#t.writeLogBatch(t)};#i=async(t,r,n,i,s,a)=>{try{let c={timestamp:i,durationMs:s,routePath:n.route.path,requestId:n.requestId,userSub:a,request:{url:r.url,method:r.method,headers:this.#e.include?.request?.headers?lg(r.headers):void 0,body:this.#e.include?.request?.body?await r.text():void 0},response:{status:t.status,statusText:t.statusText,headers:this.#e.include?.response?.headers?lg(t.headers):void 0,body:this.#e.include?.response?.body?await t.text():void 0}};this.#r.enqueue(c),n.waitUntil(this.#r.waitUntilFlushed())}catch(c){n.log.error(c)}};#o=async(t,r)=>{try{if(!await this.#e.requestFilter(t,r))return t;let i=new Date,s=Date.now(),a=t.clone();return r.addResponseSendingFinalHook(async(c,u)=>{let l=Date.now(),d=c.clone(),p=this.#i(d,a,r,i,l-s,u.user?.sub).catch(y=>{r.log.error(y)});r.waitUntil(p)}),t}catch(n){return r.log.error(n),t}}}});var yg=g(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.AmberfloMeteringInboundPolicy=Sn.AmberfloMeteringPolicy=void 0;var pg=L(),iP=ve(),hg=Qn(),mg=new WeakMap,fg={},Fd=class{static{o(this,"AmberfloMeteringPolicy")}static setRequestProperties(t,r){mg.set(t,r)}};Sn.AmberfloMeteringPolicy=Fd;async function oP(e,t,r,n){if(!r.statusCodes)throw new pg.ConfigurationError(`Invalid AmberfloMeterInboundPolicy '${n}': options.statusCodes must be an array of HTTP status code numbers`);let i=Array.isArray(r.statusCodes)?r.statusCodes:(0,hg.statusCodesStringToNumberArray)(r.statusCodes);return t.addResponseSendingFinalHook(async s=>{if(i.includes(s.status)){let a=mg.get(t),c=r.customerId;if(r.customerIdPropertyPath){if(!e.user)throw new pg.RuntimeError(`Unable to apply customerIdPropertyPath '${r.customerIdPropertyPath}' as request.user is 'undefined'.`);c=(0,hg.getValueFromRequestUser)(e.user,r.customerIdPropertyPath,"customerIdPropertyPath")}let u=a?.customerId??c;if(!u){t.log.error(`Error in AmberfloMeterInboundPolicy '${n}': customerId cannot be undefined`);return}let l=a?.meterApiName??r.meterApiName;if(!l){t.log.error(`Error in AmberfloMeterInboundPolicy '${n}': meterApiName cannot be undefined`);return}let d=a?.meterValue??r.meterValue;if(!d){t.log.error(`Error in AmberfloMeterInboundPolicy '${n}': meterValue cannot be undefined`);return}let p={customerId:u,meterApiName:l,meterValue:d,meterTimeInMillis:Date.now(),dimensions:Object.apply(r.dimensions??{},a?.dimensions)},y=fg[r.apiKey];if(!y){let h=r.apiKey,m=e.headers.get("zm-test-id")??"";y=new iP.BatchDispatch("amberflo-ingest-meter",10,async v=>{try{let T=r.url??"https://app.amberflo.io/ingest",S=await fetch(T,{method:"POST",body:JSON.stringify(v),headers:{"content-type":"application/json","x-api-key":h,"zm-test-id":m}});S.ok||t.log.error(`Unexpected response in AmberfloMeteringInboundPolicy '${n}'. ${S.status}: ${await S.text()}`)}catch(T){throw t.log.error(`Error in AmberfloMeteringInboundPolicy '${n}': ${T.message}`),T}}),fg[h]=y}y.enqueue(p),t.waitUntil(y.waitUntilFlushed())}}),e}o(oP,"AmberfloMeteringInboundPolicy");Sn.AmberfloMeteringInboundPolicy=oP});var Hd=g(na=>{"use strict";Object.defineProperty(na,"__esModule",{value:!0});na.sha256=void 0;async function sP(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest({name:"SHA-256"},t);return[...new Uint8Array(r)].map(i=>i.toString(16).padStart(2,"0")).join("")}o(sP,"sha256");na.sha256=sP});var dr=g(ia=>{"use strict";Object.defineProperty(ia,"__esModule",{value:!0});ia.getPolicyCacheName=void 0;var aP=Hd(),gg=new Map;async function cP(e,t){let r,n=gg.get(e);return n!==void 0?r=n:(r=`zuplo-policy-${await(0,aP.sha256)(JSON.stringify({policyName:e,options:t}))}`,gg.set(e,r)),r}o(cP,"getPolicyCacheName");ia.getPolicyCacheName=cP});var Vd=g(oa=>{"use strict";Object.defineProperty(oa,"__esModule",{value:!0});oa.ApiKeyInboundPolicy=void 0;var uP=dr(),lP=Er(),_g=nd(),qd=L(),dP=xt(),$d=Ge(),jd=ee(),pP=_s(),bg="key-metadata-cache-type";function hP(e,t){return t.authScheme===""?e:e.replace(`${t.authScheme} `,"")}o(hP,"getKeyValue");async function fP(e,t,r,n){if(!r.bucketName)if(_g.environment.ZUPLO_API_KEY_SERVICE_BUCKET_NAME)r.bucketName=_g.environment.ZUPLO_API_KEY_SERVICE_BUCKET_NAME;else throw new qd.ConfigurationError(`ApiKeyInboundPolicy '${n}' - no bucketName property provided`);let i={authHeader:r.authHeader??"authorization",authScheme:r.authScheme??"Bearer",bucketName:r.bucketName,cacheTtlSeconds:r.cacheTtlSeconds??60,allowUnauthenticatedRequests:r.allowUnauthenticatedRequests??!1,disableAutomaticallyAddingKeyHeaderToOpenApi:r.disableAutomaticallyAddingKeyHeaderToOpenApi??!1};if(i.cacheTtlSeconds<60)throw new qd.ConfigurationError(`ApiKeyInboundPolicy '${n}' - minimum cacheTtlSeconds value is 60s, '${i.cacheTtlSeconds}' is invalid`);let s=o(T=>i.allowUnauthenticatedRequests?e:dP.HttpProblems.unauthorized(e,t,{detail:T}),"unauthorizedResponse"),a=e.headers.get(i.authHeader);if(!a)return s("No Authorization Header");if(!a.toLowerCase().startsWith(i.authScheme.toLowerCase()))return s("Invalid Authorization Scheme");let c=hP(a,i);if(!c||c==="")return s("No key present");let u=await mP(c),l=await(0,uP.getPolicyCacheName)(n,i),d=new lP.MemoryZoneReadThroughCache(l,{logger:$d.SystemLogMap.getLogger(t)}),p=await d.get(u);if(p&&p.isValid===!0)return e.user=p.user,e;if(p&&!p.isValid)return p.typeId!==bg&&$d.SystemLogMap.getLogger(t).error(`ApiKeyInboundPolicy '${n}' - cached metadata has invalid typeId '${p.typeId}'`,p),s("Authorization Failed");let y={key:c},h=await(0,pP.fetchRetry)({retryDelayMs:5,retries:2,logger:$d.SystemLogMap.getLogger(t)},`${jd.Environment.instance.apiKeyServiceUrl}/v1/$validate/${i.bucketName}`,{method:"POST",headers:{"content-type":"application/json","zp-rid":t.requestId,"zp-dn":jd.Environment.instance.deploymentName??"unknown","User-Agent":jd.Environment.instance.systemUserAgent},body:JSON.stringify(y)});if(h.status===401)return t.log.info(`ApiKeyInboundPolicy '${n}' - 401 response from Key Service`),s("Authorization Failed");if(h.status!==200){try{let T=await h.text(),S=JSON.parse(T);t.log.error("Unexpected response from key service",S)}catch{t.log.error("Invalid response from key service")}throw new qd.RuntimeError(`ApiKeyInboundPolicy '${n}' - unexpected response from Key Service. Status: ${h.status}`)}let m=await h.json(),v={isValid:!0,typeId:bg,user:{sub:m.name,data:m.metadata}};return e.user=v.user,d.put(u,v,i.cacheTtlSeconds),e}o(fP,"ApiKeyInboundPolicy");oa.ApiKeyInboundPolicy=fP;async function mP(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r)).map(s=>s.toString(16).padStart(2,"0")).join("")}o(mP,"hashValue")});var Eg=g(sa=>{"use strict";Object.defineProperty(sa,"__esModule",{value:!0});sa.ApiAuthKeyInboundPolicy=void 0;var yP=Vd();sa.ApiAuthKeyInboundPolicy=yP.ApiKeyInboundPolicy});var kt=g(aa=>{"use strict";Object.defineProperty(aa,"__esModule",{value:!0});aa.OpenIdJwtInboundPolicy=void 0;var Bd=(ys(),Gi(ms)),Kd=L(),gP=ge(),Gd={},_P=o(async(e,t)=>{if(!t.jwkUrl||typeof t.jwkUrl!="string")throw new Kd.ConfigurationError("Invalid State - jwkUrl not set");Gd[t.jwkUrl]||(Gd[t.jwkUrl]=(0,Bd.createRemoteJWKSet)(new URL(t.jwkUrl),t.headers?{headers:t.headers}:void 0));let{payload:r}=await(0,Bd.jwtVerify)(e,Gd[t.jwkUrl],{issuer:t.issuer,audience:t.audience});return r},"jwkVerifier"),bP=o(async(e,t)=>{let r;if(t.secret===void 0)throw new Error("secretVerifier requires secret to be defined");if(typeof t.secret=="string"){let s=new TextEncoder().encode(t.secret);r=new Uint8Array(s)}else r=t.secret;let{payload:n}=await(0,Bd.jwtVerify)(e,r,{issuer:t.issuer,audience:t.audience});return n},"secretVerifier"),EP=o(async(e,t,r,n)=>{let i=e.headers.get("Authorization"),s="bearer ",a=o(y=>gP.HttpProblems.unauthorized(e,t,{detail:y}),"unauthorizedResponse");if(!r.jwkUrl&&!r.secret)throw new Kd.ConfigurationError(`OpenIdJwtInboundPolicy policy '${n}': One of 'jwkUrl' or 'secret' options are required.`);if(r.jwkUrl&&r.secret)throw new Kd.ConfigurationError(`OpenIdJwtInboundPolicy policy '${n}': Only one of 'jwkUrl' and 'secret' options should be provided.`);let c=r.jwkUrl?_P:bP,l=await o(async()=>{if(!i)return a("No authorization header");if(i.toLowerCase().indexOf(s)!==0)return a("Invalid bearer token format for authorization header");let y=i.substring(s.length);if(!y||y.length===0)return a("No bearer token on authorization header");try{return await c(y,r)}catch(h){let m=new URL(e.url);return"code"in h&&h.code==="ERR_JWT_EXPIRED"?t.log.warn(`Expired token used on url: ${m.pathname} `,h):t.log.warn(`Invalid token on: ${e.method} ${m.pathname}`,h),a("Invalid token")}},"getJwtOrRejectedResponse")();if(l instanceof Response)return r.allowUnauthenticatedRequests===!0?e:l;let d=r.subPropertyName??"sub",p=l[d];return p?(e.user={sub:p,data:l},e):a(`Token is not valid, no '${d}' property found.`)},"OpenIdJwtInboundPolicy");aa.OpenIdJwtInboundPolicy=EP});var wg=g(ca=>{"use strict";Object.defineProperty(ca,"__esModule",{value:!0});ca.Auth0JwtInboundPolicy=void 0;var wP=kt(),vP=o(async(e,t,r,n)=>(0,wP.OpenIdJwtInboundPolicy)(e,t,{issuer:`https://${r.auth0Domain}/`,audience:r.audience,jwkUrl:`https://${r.auth0Domain}/.well-known/jwks.json`,allowUnauthenticatedRequests:r.allowUnauthenticatedRequests},n),"Auth0JwtInboundPolicy");ca.Auth0JwtInboundPolicy=vP});var vg=g(ua=>{"use strict";Object.defineProperty(ua,"__esModule",{value:!0});ua.BasicAuthInboundPolicy=void 0;var TP=ge(),SP=o(async(e,t,r)=>{let n=e.headers.get("Authorization"),i="basic ",s=o(l=>TP.HttpProblems.unauthorized(e,t,{detail:l}),"unauthorizedResponse"),c=await o(async()=>{if(!n)return await s("No Authorization header");if(n.toLowerCase().indexOf(i)!==0)return await s("Invalid Basic token format for Authorization header");let l=n.substring(i.length);if(!l||l.length===0)return await s("No username:password provided");let d=atob(l).normalize(),p=d.indexOf(":");if(p===-1||/[\0-\x1F\x7F]/.test(d))return await s("Invalid basic token value - see https://tools.ietf.org/html/rfc5234#appendix-B.1");let y=d.substring(0,p),h=d.substring(p+1),m=r.accounts.find(v=>v.username===y&&v.password===h);return m||await s("Invalid username or password")},"getAccountOrRejectedResponse")();if(c instanceof Response)return r.allowUnauthenticatedRequests?e:c;let u=c.username;return e.user={sub:u,data:c.data},e},"BasicAuthInboundPolicy");ua.BasicAuthInboundPolicy=SP});var Tg=g(la=>{"use strict";Object.defineProperty(la,"__esModule",{value:!0});la.CachingInboundPolicy=void 0;var IP=dr(),AP=["cdn-cache-control","cloudflare-cdn-cache-control","surrogate-control","cache-tag","expires"];async function PP(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r)).map(s=>s.toString(16).padStart(2,"0")).join("")}o(PP,"digestMessage");var RP=o(async(e,t)=>{let r=[...t.dangerouslyIgnoreAuthorizationHeader===!0?[]:["authorization"],...t.headers??[]],n=[];for(let[d,p]of e.headers.entries())r.includes(d)&&n.push({key:d.toLowerCase(),value:p});n.sort((d,p)=>d.key.localeCompare(p.key));let i=await PP(JSON.stringify(n)),s=new URL(e.url),a=new URLSearchParams(s.searchParams);a.set("_z-hdr-dgst",i);let c=t.cacheHttpMethods?.includes(e.method.toUpperCase())&&e.method.toUpperCase()!=="GET";c&&a.set("_z-original-method",e.method);let u=`${s.origin}${s.pathname}?${a}`;return new Request(u,{method:c?"GET":e.method})},"createCacheKeyRequest");async function OP(e,t,r,n){let i=await(0,IP.getPolicyCacheName)(n,r),s=await caches.open(i),a=r?.cacheHttpMethods?.map(l=>l.toUpperCase())??["GET"],c=await RP(e,r),u=await s.match(c);return u||(t.addEventListener("responseSent",l=>{try{let d=r.statusCodes??[200,206,301,302,303,404,410],p=l.response.clone();if(!d.includes(p.status)||!a.includes(e.method.toUpperCase()))return;let y=r?.expirationSecondsTtl??60,h=new Response(p.body,p);AP.forEach(m=>h.headers.delete(m)),h.headers.set("cache-control",`s-maxage=${y}`),t.waitUntil(s.put(c,h))}catch(d){t.log.error(`Error in caching-inbound-policy '${n}': "${d.message}"`,d)}}),e)}o(OP,"CachingInboundPolicy");la.CachingInboundPolicy=OP});var Sg=g(da=>{"use strict";Object.defineProperty(da,"__esModule",{value:!0});da.ChangeMethodInboundPolicy=void 0;var xP=L(),NP=Be(),CP=o(async(e,t,r,n)=>{if(!r.method)throw new xP.ConfigurationError(`ChangeMethodInboundPolicy '${n}' options.method must be valid HttpMethod`);return new NP.ZuploRequest(e,{method:r.method})},"ChangeMethodInboundPolicy");da.ChangeMethodInboundPolicy=CP});var Ig=g(pa=>{"use strict";Object.defineProperty(pa,"__esModule",{value:!0});pa.ClearHeadersInboundPolicy=void 0;var LP=Be(),DP=o(async(e,t,r)=>{let n=[...r.exclude??[]],i=new Headers;return n.forEach(a=>{let c=e.headers.get(a);c&&i.set(a,c)}),new LP.ZuploRequest(e,{headers:i})},"ClearHeadersInboundPolicy");pa.ClearHeadersInboundPolicy=DP});var Ag=g(ha=>{"use strict";Object.defineProperty(ha,"__esModule",{value:!0});ha.ClearHeadersOutboundPolicy=void 0;var UP=o(async(e,t,r,n)=>{let i=[...n.exclude??[]],s=new Headers;return i.forEach(c=>{let u=e.headers.get(c);u&&s.set(c,u)}),new Response(e.body,{headers:s,status:e.status,statusText:e.statusText})},"ClearHeadersOutboundPolicy");ha.ClearHeadersOutboundPolicy=UP});var Pg=g(fa=>{"use strict";Object.defineProperty(fa,"__esModule",{value:!0});fa.ClerkJwtInboundPolicy=void 0;var MP=kt(),kP=o(async(e,t,r,n)=>{let i=new URL(r.frontendApiUrl.startsWith("https://")||r.frontendApiUrl.startsWith("http://")?r.frontendApiUrl:`https://${r.frontendApiUrl}`),s=new URL(i);return s.pathname="/.well-known/jwks.json",(0,MP.OpenIdJwtInboundPolicy)(e,t,{issuer:i.href.slice(0,-1),jwkUrl:s.toString(),allowUnauthenticatedRequests:r.allowUnauthenticatedRequests},n)},"ClerkJwtInboundPolicy");fa.ClerkJwtInboundPolicy=kP});var Og=g(ma=>{"use strict";Object.defineProperty(ma,"__esModule",{value:!0});ma.CognitoJwtInboundPolicy=void 0;var Rg=L(),FP=kt(),HP=o(async(e,t,r,n)=>{if(!r.userPoolId)throw new Rg.ConfigurationError("userPoolId must be set in the options for CognitoJwtInboundPolicy");if(!r.region)throw new Rg.ConfigurationError("region must be set in the options for CognitoJwtInboundPolicy");return(0,FP.OpenIdJwtInboundPolicy)(e,t,{issuer:`https://cognito-idp.${r.region}.amazonaws.com/${r.userPoolId}`,jwkUrl:`https://cognito-idp.${r.region}.amazonaws.com/${r.userPoolId}/.well-known/jwks.json`,allowUnauthenticatedRequests:r.allowUnauthenticatedRequests},n)},"CognitoJwtInboundPolicy");ma.CognitoJwtInboundPolicy=HP});var Ng=g(ya=>{"use strict";Object.defineProperty(ya,"__esModule",{value:!0});ya.CompositeInboundPolicy=void 0;var qP=L(),$P=dn(),xg=Yn(),jP=o(async(e,t,r,n)=>{if(!r.policies||r.policies.length===0)throw new qP.ConfigurationError(`CompositeInboundPolicy '${n}' must have valid policies defined`);let i=$P.Gateway.instance,s=(0,xg.getInboundPolicyHandlerAndOptions)(r.policies,i?.routeData.policies);return(0,xg.toStackedInboundHandler)(s)(e,t)},"CompositeInboundPolicy");ya.CompositeInboundPolicy=jP});var pr=g(ga=>{"use strict";Object.defineProperty(ga,"__esModule",{value:!0});ga.optionValidator=void 0;var _i=L();function VP(e,t){let r=o((s,a,c)=>{let u=e[s];if(!(c&&u===void 0)){if(u===void 0)throw new _i.ConfigurationError(`Value of '${String(s)}' on policy '${t}' is required, but no value was set. If using an environment variable, check that it is set correctly.`);if(a==="array"&&Array.isArray(u))throw new _i.ConfigurationError(`Value of '${String(s)}' on policy '${t}' must be an array. Received type ${typeof u}.`);if(typeof u!==a)throw new _i.ConfigurationError(`Value of '${String(s)}' on policy '${t}' must be of type ${a}. Received type ${typeof u}.`);if(typeof u=="string"&&u.length===0)throw new _i.ConfigurationError(`Value of '${String(s)}' on policy '${t}' must be a non-empty string. The value received is empty. If using an environment variable, check that it is set correctly.`);if(typeof u=="number"&&isNaN(u))throw new _i.ConfigurationError(`Value of '${String(s)}' on policy '${t}' must be valid number. If using an environment variable, check that it is set correctly.`)}},"validate"),n=o((s,a)=>(r(s,a,!0),{optional:n,required:i}),"optional"),i=o((s,a)=>(r(s,a,!1),{optional:n,required:i}),"required");return{optional:n,required:i}}o(VP,"optionValidator");ga.optionValidator=VP});var Cg=g(_a=>{"use strict";Object.defineProperty(_a,"__esModule",{value:!0});_a.FirebaseJwtInboundPolicy=void 0;var GP=pr(),BP=kt(),KP=o(async(e,t,r,n)=>((0,GP.optionValidator)(r,n).required("projectId","string").optional("allowUnauthenticatedRequests","boolean"),(0,BP.OpenIdJwtInboundPolicy)(e,t,{issuer:`https://securetoken.google.com/${r.projectId}`,audience:r.projectId,jwkUrl:"https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com",allowUnauthenticatedRequests:r.allowUnauthenticatedRequests},n)),"FirebaseJwtInboundPolicy");_a.FirebaseJwtInboundPolicy=KP});var Lg=g(ba=>{"use strict";Object.defineProperty(ba,"__esModule",{value:!0});ba.FormDataToJsonInboundPolicy=void 0;var JP=Be(),zP=o(async(e,t,r)=>{let n="application/x-www-form-urlencoded",i="multipart/form-data",s=e.headers.get("content-type")?.toLowerCase();if(!s||![i,n].includes(s))return r&&r.badRequestIfNotFormData?new Response(`Bad Request - expected content-type '${n}' or ${i}`,{status:400,statusText:"Bad Request"}):e;let a=await e.formData();if(r&&r.optionalHoneypotName&&a.get(r.optionalHoneypotName)!=="")return new Response("Bad Request",{status:400,statusText:"Bad Request"});let c={};for(let[d,p]of a)c[d]=p.toString();let u=new Headers(e.headers);return u.set("content-type","application/json"),u.delete("content-length"),new JP.ZuploRequest(e,{body:JSON.stringify(c),headers:u})},"FormDataToJsonInboundPolicy");ba.FormDataToJsonInboundPolicy=zP});var Dg=g(Ea=>{"use strict";Object.defineProperty(Ea,"__esModule",{value:!0});Ea.GeoFilterInboundPolicy=void 0;var WP=L(),QP=ge(),In="__unknown__",YP=o(async(e,t,r,n)=>{let i={allow:{countries:Pn(r.allow?.countries,"allow.countries",n),regionCodes:Pn(r.allow?.regionCodes,"allow.regionCode",n),asns:Pn(r.allow?.asns,"allow.asOrganization",n)},block:{countries:Pn(r.block?.countries,"block.countries",n),regionCodes:Pn(r.block?.regionCodes,"block.regionCode",n),asns:Pn(r.block?.asns,"block.asOrganization",n)},ignoreUnknown:r.ignoreUnknown!==!1},s=t.incomingRequestProperties.country?.toLowerCase()??In,a=t.incomingRequestProperties.regionCode?.toLowerCase()??In,c=t.incomingRequestProperties.asn?.toString()??In,u=i.ignoreUnknown&&s===In,l=i.ignoreUnknown&&a===In,d=i.ignoreUnknown&&c===In,p=i.allow.countries,y=i.allow.regionCodes,h=i.allow.asns;if(p.length>0&&!p.includes(s)&&!u||y.length>0&&!y.includes(a)&&!l||h.length>0&&!h.includes(c)&&!d)return An(e,t,n,s,a,c);let m=i.block.countries,v=i.block.regionCodes,T=i.block.asns;return m.length>0&&m.includes(s)&&!u||v.length>0&&v.includes(a)&&!l||T.length>0&&T.includes(c)&&!d?An(e,t,n,s,a,c):e},"GeoFilterInboundPolicy");Ea.GeoFilterInboundPolicy=YP;function An(e,t,r,n,i,s){return t.log.debug(`Request blocked by GeoFilterInboundPolicy '${r}' (country: '${n}', regionCode: '${i}', asn: '${s}')`),QP.HttpProblems.forbidden(e,t,{geographicContext:{country:n,regionCode:i,asn:s}})}o(An,"blockedResponse");function Pn(e,t,r){if(typeof e=="string")return e.split(",").map(n=>n.trim().toLowerCase());if(typeof e>"u")return[];if(Array.isArray(e))return e.map(n=>n.trim().toLowerCase());throw new WP.ConfigurationError(`Invalid '${t}' for GeoFilterInboundPolicy '${r}': '${e}', must be a string or string[]`)}o(Pn,"toLowerStringArray")});var Ug=g(wa=>{"use strict";Object.defineProperty(wa,"__esModule",{value:!0});wa.JWTScopeValidationInboundPolicy=void 0;var ZP=o(async(e,t,r)=>{let n=e.user?.data.scope.split(" ")||[];if(!o((s,a)=>a.every(c=>s.includes(c)),"scopeChecker")(n,r.scopes)){let s={code:"UNAUTHORIZED",help_url:"https://zup.fail/UNAUTHORIZED",message:`JWT must have all the following scopes: ${r.scopes}`};return new Response(JSON.stringify(s),{status:401,statusText:"Unauthorized",headers:{"content-type":"application/json"}})}return e},"JWTScopeValidationInboundPolicy");wa.JWTScopeValidationInboundPolicy=ZP});var kg=g(va=>{"use strict";Object.defineProperty(va,"__esModule",{value:!0});va.MockApiInboundPolicy=void 0;var XP=ge(),eR=o(async(e,t,r,n)=>{let i=t.route.raw().responses;if(!i)return Jd(n,e,t,"No responses defined in the OpenAPI document. Add some responses with examples to use this policy.");let s=Object.keys(i),a=[];if(s.length===0)return Jd(n,e,t,"No response object defined under responses in the OpenAPI document. Add some response objects with examples to use this policy.");if(s.forEach(c=>{i[c].content&&Object.keys(i[c].content).forEach(l=>{let d=i[c].content[l].examples;d&&Object.keys(d).forEach(y=>{a.push({responseName:c,contentName:l,exampleName:y,exampleValue:d[y]})})})}),a=a.filter(c=>!(r.responsePrefixFilter&&!c.responseName.startsWith(r.responsePrefixFilter)||r.contentType&&c.contentName!==r.contentType||r.exampleName&&c.exampleName!==r.exampleName)),r.random&&a.length>1){let c=Math.floor(Math.random()*a.length);return Mg(a[c])}else return a.length>0?Mg(a[0]):Jd(n,e,t,"No examples matching the mocking options found in the OpenAPI document. Add examples to the OpenAPI document matching the options for this policy or change the mocking options to match the examples in the OpenAPI document.")},"MockApiInboundPolicy");va.MockApiInboundPolicy=eR;function Mg(e){let t=JSON.stringify(e.exampleValue,null,2),r=new Headers;switch(r.set("Content-Type",e.contentName),e.responseName){case"1XX":return new Response(t,{status:100,headers:r});case"2XX":return new Response(t,{status:200,headers:r});case"3XX":return new Response(t,{status:300,headers:r});case"4XX":return new Response(t,{status:400,headers:r});case"5XX":case"default":return new Response(t,{status:500,headers:r});default:return new Response(t,{status:Number(e.responseName),headers:r})}}o(Mg,"generateResponse");var Jd=o((e,t,r,n)=>{let i=`Error in policy: ${e} - On route ${t.method} ${r.route.path}. ${n}`;return XP.HttpProblems.internalServerError(t,r,{detail:i})},"getProblemDetailResponse")});var jg=g(Rn=>{"use strict";Object.defineProperty(Rn,"__esModule",{value:!0});Rn.MoesifInboundPolicy=Rn.setMoesifContext=void 0;var tR=L(),rR=ve(),nR="Incoming",iR={logRequestBody:!0,logResponseBody:!0};function Fg(e){let t={};return e.forEach((r,n)=>{t[n]=r}),t}o(Fg,"headersToObject");function Hg(){return new Date().toISOString()}o(Hg,"timestamp");var zd=new WeakMap,oR={};function sR(e,t){let r=zd.get(e);r||(r=oR);let n=Object.assign({...r},t);zd.set(e,n)}o(sR,"setMoesifContext");Rn.setMoesifContext=sR;async function qg(e,t){let r=e.headers.get("content-type");if(r&&r.indexOf("json")!==0)try{return await e.clone().json()}catch(i){t.log.error(i)}let n=await e.clone().text();return t.log.debug({textBody:n}),n}o(qg,"readBody");var aR={},Wd;function $g(){if(!Wd)throw new tR.RuntimeError("Invalid State - no _lastLogger");return Wd}o($g,"getLastLogger");function cR(e){let t=aR[e];return t||(t=new rR.BatchDispatch("moesif-inbound",100,async r=>{let n=JSON.stringify(r);$g().debug("posting",n);let i=await fetch("https://api.moesif.net/v1/events/batch",{method:"POST",headers:{"content-type":"application/json","X-Moesif-Application-Id":e},body:n});i.ok||$g().error({status:i.status,body:await i.text()})})),t}o(cR,"getDispatcher");async function uR(e,t,r,n){Wd=t.log;let i=Hg(),s=Object.assign(iR,r);if(!s.applicationId)throw new Error(`Invalid configuration for MoesifInboundPolicy '${n}' - applicationId is required`);let a=s.logRequestBody?await qg(e,t):void 0;return t.addResponseSendingFinalHook(async(c,u)=>{let l=cR(s.applicationId),d=e.headers.get("true-client-ip"),p=zd.get(t)??{},y={time:i,uri:e.url,verb:e.method,body:a,ip_address:d??void 0,api_version:p.apiVersion,headers:Fg(e.headers)},h=s.logResponseBody?await qg(c,t):void 0,m={time:Hg(),status:c.status,headers:Fg(c.headers),body:h},v={request:y,response:m,user_id:p.userId??u.user?.sub,session_token:p.sessionToken,company_id:p.companyId,metadata:p.metadata,direction:nR};l.enqueue(v),t.waitUntil(l.waitUntilFlushed())}),e}o(uR,"MoesifInboundPolicy");Rn.MoesifInboundPolicy=uR});var Vg=g(Ta=>{"use strict";Object.defineProperty(Ta,"__esModule",{value:!0});Ta.OktaJwtInboundPolicy=void 0;var lR=kt(),dR=o(async(e,t,r,n)=>(0,lR.OpenIdJwtInboundPolicy)(e,t,{issuer:r.issuerUrl,audience:r.audience,jwkUrl:`${r.issuerUrl}/v1/keys`,allowUnauthenticatedRequests:r.allowUnauthenticatedRequests},n),"OktaJwtInboundPolicy");Ta.OktaJwtInboundPolicy=dR});var Gg=g(Sa=>{"use strict";Object.defineProperty(Sa,"__esModule",{value:!0});Sa.PropelAuthJwtInboundPolicy=void 0;var pR=(ys(),Gi(ms)),hR=kt(),Qd,fR=o(async(e,t,r,n)=>{if(!Qd)try{Qd=await(0,pR.importSPKI)(r.verifierKey,"RS256")}catch(i){throw t.log.error("Could not import verifier key"),i}return(0,hR.OpenIdJwtInboundPolicy)(e,t,{issuer:r.authUrl,secret:Qd,allowUnauthenticatedRequests:r.allowUnauthenticatedRequests,subPropertyName:"user_id"},n)},"PropelAuthJwtInboundPolicy");Sa.PropelAuthJwtInboundPolicy=fR});var Bg=g(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.throwIfStateNotObject=G.throwIfStateNotNumber=G.throwIfStateNotString=G.throwIfStateUndefinedOrNull=G.throwIfStateUndefined=G.throwIfOptionNotObject=G.throwIfOptionNotNumber=G.throwIfOptionNotString=G.throwIfOptionUndefinedOrNull=G.throwIfOptionUndefined=G.OptionTypeError=G.OptionUndefinedError=G.throwIfNotNumber=G.throwIfNotString=G.throwIfUndefinedOrNull=G.throwIfUndefined=G.ArgumentTypeError=G.ArgumentUndefinedError=G.ValidationError=void 0;var qe=Kt(),et=class extends Error{static{o(this,"ValidationError")}constructor(t){super(t)}};G.ValidationError=et;var bi=class extends et{static{o(this,"ArgumentUndefinedError")}constructor(t){super(`The argument '${t}' is undefined.`)}};G.ArgumentUndefinedError=bi;var Ei=class extends et{static{o(this,"ArgumentTypeError")}constructor(t,r){super(`The argument '${t}' must be of type '${r}'.`)}};G.ArgumentTypeError=Ei;function mR(e,t){if((0,qe.isUndefined)(e))throw new bi(t)}o(mR,"throwIfUndefined");G.throwIfUndefined=mR;function Yd(e,t){if((0,qe.isUndefinedOrNull)(e))throw new bi(t)}o(Yd,"throwIfUndefinedOrNull");G.throwIfUndefinedOrNull=Yd;function yR(e,t){if(Yd(e,t),!(0,qe.isString)(e))throw new Ei(t,"string")}o(yR,"throwIfNotString");G.throwIfNotString=yR;function gR(e,t){if(Yd(e,t),!(0,qe.isNumber)(e))throw new Ei(t,"number")}o(gR,"throwIfNotNumber");G.throwIfNotNumber=gR;var wi=class extends et{static{o(this,"OptionUndefinedError")}constructor(t,r,n){super(`The option '${n}' on the ${t} named '${r}' is undefined.`)}};G.OptionUndefinedError=wi;var On=class extends et{static{o(this,"OptionTypeError")}constructor(t,r,n,i){super(`The option '${n}' on the ${t} named '${r}' must be of type '${i}'.`)}};G.OptionTypeError=On;function _R(e,t,r,n){if((0,qe.isUndefined)(n))throw new wi(e,t,r)}o(_R,"throwIfOptionUndefined");G.throwIfOptionUndefined=_R;function Ia(e,t,r,n){if((0,qe.isUndefinedOrNull)(n))throw new wi(e,t,r)}o(Ia,"throwIfOptionUndefinedOrNull");G.throwIfOptionUndefinedOrNull=Ia;function bR(e,t,r,n){if(Ia(e,t,r,n),!(0,qe.isString)(n))throw new On(e,t,r,"string")}o(bR,"throwIfOptionNotString");G.throwIfOptionNotString=bR;function ER(e,t,r,n){if(Ia(e,t,r,n),!(0,qe.isNumber)(n))throw new On(e,t,r,"number")}o(ER,"throwIfOptionNotNumber");G.throwIfOptionNotNumber=ER;function wR(e,t,r,n){if(Ia(e,t,r,n),!(0,qe.isObject)(n))throw new On(e,t,r,"object")}o(wR,"throwIfOptionNotObject");G.throwIfOptionNotObject=wR;function vR(e,t){if((0,qe.isUndefined)(e))throw new et(t)}o(vR,"throwIfStateUndefined");G.throwIfStateUndefined=vR;function Aa(e,t){if((0,qe.isUndefinedOrNull)(e))throw new et(t)}o(Aa,"throwIfStateUndefinedOrNull");G.throwIfStateUndefinedOrNull=Aa;function TR(e,t){if(Aa(e,t),!(0,qe.isString)(e))throw new et(t);return!0}o(TR,"throwIfStateNotString");G.throwIfStateNotString=TR;function SR(e,t){if(Aa(e,t),!(0,qe.isNumber)(e))throw new et(t);return!0}o(SR,"throwIfStateNotNumber");G.throwIfStateNotNumber=SR;function IR(e,t){if(Aa(e,t),!(0,qe.isObject)(e))throw new et(t);return!0}o(IR,"throwIfStateNotObject");G.throwIfStateNotObject=IR});var Kg=g(xn=>{"use strict";Object.defineProperty(xn,"__esModule",{value:!0});xn.InMemoryRedisClient=xn.StandardRedisClient=void 0;var Zd=L(),Pa=Bg(),Xd=class e{static{o(this,"StandardRedisClient")}static instance;redisClientUrl;clientAuthToken;userAgent;deploymentName;constructor(t,r,n,i){this.redisClientUrl=t,this.clientAuthToken=r,this.deploymentName=n,this.userAgent=i}static initialize(t,r,n,i){return(0,Pa.throwIfNotString)(t,"redisClientUrl"),(0,Pa.throwIfNotString)(r,"clientAuthToken"),e.instance||(e.instance=new e(t,r,n,i)),e.instance}isEnabled(){return this.redisClientUrl!==void 0&&this.clientAuthToken!==void 0}async fetch({url:t,body:r,method:n,requestId:i}){(0,Pa.throwIfNotString)(t,"url");let s=await fetch(`${this.redisClientUrl}${t}`,{method:n,body:r,headers:{"content-type":"application/json",authorization:`Bearer ${this.clientAuthToken}`,"zp-rid":i,"zp-dn":this.deploymentName,"User-Agent":this.userAgent}}),a=s.headers.get("Content-Type")?.includes("application/json")?await s.json():await s.text();if(s.ok)return a;throw s.status===401?new Zd.SystemError("Redis client failed with 401: Unauthorized"):new Zd.SystemError(`Redis client failed with (${s.status}): ${typeof a=="string"?a:JSON.stringify(a,null,2)}`)}};xn.StandardRedisClient=Xd;var ep=class{static{o(this,"InMemoryRedisClient")}keyValueStore;constructor(){this.keyValueStore=new Map}isEnabled(){return!0}fetch({url:t,body:r,method:n}){if((0,Pa.throwIfNotString)(t,"url"),n==="POST"&&t==="/rate-limit"){let{incrBy:i,expire:s,key:a}=JSON.parse(r),c=Date.now()+s*1e3,u=this.keyValueStore.get(a);u?Date.now()>u.expiresAt?this.keyValueStore.set(a,{value:i,expiresAt:c}):this.keyValueStore.set(a,{value:u.value+i,expiresAt:u.expiresAt}):this.keyValueStore.set(a,{value:i,expiresAt:c});let l=this.keyValueStore.get(a);return Promise.resolve({count:l.value,ttlSeconds:Math.round((l.expiresAt-Date.now())/1e3)})}throw new Zd.SystemError("The in-memory redis client only supports /rate-limit calls")}};xn.InMemoryRedisClient=ep});var Yg=g(xa=>{"use strict";Object.defineProperty(xa,"__esModule",{value:!0});xa.RateLimitInboundPolicy=void 0;var AR=vr(),PR=dr(),RR=Wi(),Ft=L(),OR=ge(),Jg=Ge(),vi=ee(),zg=Kg(),Wg=Kt(),Ra=(0,AR.debug)("zuplo:policies:RateLimitInboundPolicy"),xR="strict",NR=o(e=>{let t=e.headers.get("cf-connecting-ip")??e.headers.get("true-client-ip");if(t)return t;let r=e.headers.get("x-forwarded-for");return r?r.split(",")[0]:"127.0.0.1"},"getRealIP"),CR=o(async e=>({key:`ip-${NR(e)}`}),"getIP"),LR=o(async e=>({key:`user-${e.user?.sub??"anonymous"}`}),"getUser"),DR=o(async()=>({key:"all-2d77ce9d-9a3c-4206-9ab2-668cfd271095"}),"getAll"),Oa;function UR(e,t){let r;if(Oa)return Oa;if(vi.Environment.instance.isLocalDevelopment)return t.info("Using in-memory redis client for local development."),r=new zg.InMemoryRedisClient,Oa=r,r;let{authApiJWT:n,redisURL:i}=vi.Environment.instance;if(!(0,Wg.isString)(i))throw new Ft.SystemError(`RateLimitInboundPolicy '${e}' - rate limit service URL not configured`);if(!(0,Wg.isString)(n))throw new Ft.SystemError(`RateLimitInboundPolicy '${e}' - service authentication not configured`);if(i&&(r=zg.StandardRedisClient.initialize(i,n,vi.Environment.instance.deploymentName??"unknown",vi.Environment.instance.systemUserAgent)),!r||!r.isEnabled())throw new Ft.SystemError(`RateLimitInboundPolicy '${e}' - no redis ('${r}') or redis.isEnabled ('${r?.isEnabled}) is false`);return Oa=r,r}o(UR,"getRedisClient");async function Qg(e,t,r,n,i){let s=Math.floor(t*60);return await r.fetch({url:"/rate-limit",method:"POST",body:JSON.stringify({incrBy:1,expire:s,key:e}),requestId:i})}o(Qg,"getCountAndUpdateExpiry");function MR(e,t){let r;if(e.rateLimitBy==="function"){if(!e.identifier)throw new Ft.ConfigurationError(`RateLimitInboundPolicy '${t}' - If rateLimitBy set to 'function' options.identifier must be specified`);if(!e.identifier.module)throw new Ft.ConfigurationError(`RateLimitInboundPolicy '${t}' - If rateLimitBy set to 'function' options.identifier.module must be specified`);if(!e.identifier.export)throw new Ft.ConfigurationError(`RateLimitInboundPolicy '${t}' - If rateLimitBy set to 'function' options.identifier.export must be specified`);if(r=e.identifier.module[e.identifier.export],!r||typeof r!="function")throw new Ft.ConfigurationError(`RateLimitInboundPolicy '${t}' - Custom rate limit function must be a valid function`)}return o(async(i,s,a)=>{let c=await r(i,s,a);if(!c.key){let u=`RateLimitInboundPolicy '${a}' - Custom rate limit function must return a valid key property '${JSON.stringify(c,null,2)}'`;throw s.log.error(u),new Ft.RuntimeError(u)}return c},"outerFunction")}o(MR,"wrapUserFunction");var kR="Retry-After",FR=o(async(e,t,r,n)=>{let i=Date.now(),s=Jg.SystemLogMap.getLogger(t),a=o((u,l)=>{if(r.throwOnFailure)throw new Ft.SystemError(u,{cause:l});s.error(u,l)},"throwOrLog"),c=o((u,l)=>{let d={};return(!u||u==="retry-after")&&(d[kR]=l.toString()),OR.HttpProblems.tooManyRequests(e,t,void 0,d)},"rateLimited");try{let l={function:MR(r,n),user:LR,ip:CR,all:DR}[r.rateLimitBy],d=await l(e,t,n),p=d.key,y=d.requestsAllowed??r.requestsAllowed,h=d.timeWindowMinutes??r.timeWindowMinutes,m=r.headerMode??"retry-after",v=UR(n,s),S=`bucket/${vi.Environment.instance.build.BUILD_ID}/${n}/${p}`;if((r.mode??xR)==="async"){let C=await(0,PR.getPolicyCacheName)(n,r),re=new RR.ZoneCache(C,{logger:Jg.SystemLogMap.getLogger(t)}),ne=Qg(S,h,v,s,t.requestId),fe=await re.get(S);if(fe!==void 0&&fe<=Date.now()){Ra(`RateLimitInboundPolicy '${n}' - returning 429 from cache for '${S}' (async mode)`);let Ve=Math.round((fe-Date.now())/1e3);return c(m,Ve)}return t.addEventListener("responseSending",Ve=>{try{let E=Ve,F=E.mutableResponse;E.mutableResponse=(async()=>{let Ce=await ne;if(Ce.count>y){let jc=Date.now()+Ce.ttlSeconds*1e3;return re.put(S,jc,Ce.ttlSeconds).catch($p=>{throw s.error($p),$p}),Ra(`RateLimitInboundPolicy '${n}' - returning 429 from redis for '${S}' (async mode)`),c(m,Ce.ttlSeconds)}return F})()}catch(E){s.error(`RateLimitInboundPolicy '${n}' -error in responseSending`,E)}}),e}let j=await Qg(S,h,v,s,t.requestId);return j.count>y?(Ra(`RateLimitInboundPolicy '${n}' - returning 429 from redis for '${S}' (strict mode)`),c(m,j.ttlSeconds)):e}catch(u){return a(u.message,u),e}finally{let u=Date.now()-i;Ra(`RateLimitInboundPolicy '${n}' - latency ${u}ms`)}},"RateLimitInboundPolicy");xa.RateLimitInboundPolicy=FR});var t_=g(Na=>{"use strict";Object.defineProperty(Na,"__esModule",{value:!0});Na.ReadmeMetricsInboundPolicy=void 0;var HR=ve(),tp=ee(),Zg=Qn(),rp;function Xg(e){let t=[];for(let[r,n]of e)t.push({name:r,value:n});return t}o(Xg,"headersToNameValuePairs");function qR(e){let t=[];return Object.entries(e).forEach(([r,n])=>{t.push({name:r,value:n})}),t}o(qR,"queryToNameValueParis");function $R(e){if(e===null)return;let t=parseFloat(e);if(!isNaN(t))return t}o($R,"parseIntOrUndefined");var e_={};async function jR(e,t,r,n){let i=new Date,s=Date.now();return rp||(rp={name:"zuplo",version:tp.Environment.instance.build.ZUPLO_VERSION,comment:`zuplo/${tp.Environment.instance.build.ZUPLO_VERSION}`}),t.addResponseSendingFinalHook(async a=>{try{let c=r.userLabelPropertyPath&&e.user?(0,Zg.getValueFromRequestUser)(e.user,r.userLabelPropertyPath,"userLabelPropertyPath"):e.user?.sub,u=r.userEmailPropertyPath&&e.user?(0,Zg.getValueFromRequestUser)(e.user,r.userEmailPropertyPath,"userEmailPropertyPath"):void 0,l={clientIPAddress:e.headers.get("true-client-ip")??"",development:r.development!==void 0?r.development:tp.Environment.instance.isDeno,group:{label:c,email:u,id:e.user?.sub??"anonymous"},request:{log:{creator:rp,entries:[{startedDateTime:i.toISOString(),time:Date.now()-s,request:{method:e.method,url:r.useFullRequestPath?new URL(e.url).pathname:t.route.path,httpVersion:"2",headers:Xg(e.headers),queryString:qR(e.query)},response:{status:a.status,statusText:a.statusText,headers:Xg(a.headers),content:{size:$R(e.headers.get("content-length"))}}}]}}},d=e_[r.apiKey];if(!d){let p=r.apiKey;d=new HR.BatchDispatch("readme-metering-inbound-policy",10,async y=>{try{let h=r.url??"https://metrics.readme.io/request",m=await fetch(h,{method:"POST",body:JSON.stringify(y),headers:{"content-type":"application/json",authorization:`Basic ${btoa(p+":")}`}});m.status!==202&&t.log.error(`Unexpected response in ReadmeMeteringInboundPolicy '${n}'. ${m.status}: '${await m.text()}'`)}catch(h){throw t.log.error(`Error in ReadmeMeteringInboundPolicy '${n}': '${h.message}'`),h}}),e_[p]=d}d.enqueue(l),t.waitUntil(d.waitUntilFlushed())}catch(c){t.log.error(c)}}),e}o(jR,"ReadmeMetricsInboundPolicy");Na.ReadmeMetricsInboundPolicy=jR});var r_=g(Ca=>{"use strict";Object.defineProperty(Ca,"__esModule",{value:!0});Ca.RemoveHeadersInboundPolicy=void 0;var VR=L(),GR=Be(),BR=o(async(e,t,r,n)=>{let i=r?.headers;if(!i||!Array.isArray(i)||i.length===0)throw new VR.ConfigurationError(`RemoveHeadersInboundPolicy '${n}' options.headers must be a non-empty string array of header names`);let s=new Headers(e.headers);return i.forEach(c=>{s.delete(c)}),new GR.ZuploRequest(e,{headers:s})},"RemoveHeadersInboundPolicy");Ca.RemoveHeadersInboundPolicy=BR});var n_=g(La=>{"use strict";Object.defineProperty(La,"__esModule",{value:!0});La.RemoveHeadersOutboundPolicy=void 0;var KR=L(),JR=o(async(e,t,r,n,i)=>{let s=n?.headers;if(!s||!Array.isArray(s)||s.length===0)throw new KR.ConfigurationError(`RemoveHeadersOutboundPolicy '${i}' options.headers must be a non-empty string array of header names`);let a=new Headers(e.headers);return s.forEach(u=>{a.delete(u)}),new Response(e.body,{headers:a,status:e.status,statusText:e.statusText})},"RemoveHeadersOutboundPolicy");La.RemoveHeadersOutboundPolicy=JR});var i_=g(Da=>{"use strict";Object.defineProperty(Da,"__esModule",{value:!0});Da.RemoveQueryParamsInboundPolicy=void 0;var zR=L(),WR=Be(),QR=o(async(e,t,r,n)=>{let i=r.params;if(!i||!Array.isArray(i)||i.length===0)throw new zR.ConfigurationError(`RemoveQueryParamsInboundPolicy '${n}' options.params must be a non-empty string array of header names`);let s=new URL(e.url);return i.forEach(c=>{s.searchParams.delete(c)}),new WR.ZuploRequest(s.toString(),e)},"RemoveQueryParamsInboundPolicy");Da.RemoveQueryParamsInboundPolicy=QR});var o_=g(Ua=>{"use strict";Object.defineProperty(Ua,"__esModule",{value:!0});Ua.ReplaceStringOutboundPolicy=void 0;var YR=o(async(e,t,r,n)=>{let i=await e.text(),s=n.mode==="regexp"?new RegExp(n.match,"gm"):n.match,a=i.replaceAll(s,n.replaceWith);return new Response(a,{headers:e.headers,status:e.status,statusText:e.statusText})},"ReplaceStringOutboundPolicy");Ua.ReplaceStringOutboundPolicy=YR});var a_=g(Ma=>{"use strict";Object.defineProperty(Ma,"__esModule",{value:!0});Ma.RequestSizeLimitInboundPolicy=void 0;var s_=o(()=>new Response("Maximum request size exceeded",{status:413,statusText:"Payload Too Large"}),"payloadTooLarge"),ZR=o(async(e,t,r)=>{let n=r.trustContentLengthHeader??!1;if(["GET","HEAD"].includes(e.method))return e;let i=e.headers.get("content-length"),s=i!==null?parseInt(i):void 0;return s&&!isNaN(s)&&s>r.maxSizeInBytes?s_():s&&n?e:(await e.clone().text()).length>r.maxSizeInBytes?s_():e},"RequestSizeLimitInboundPolicy");Ma.RequestSizeLimitInboundPolicy=ZR});var ka=g(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.sanitizedIdentifierName=tt.getIdForRefSchema=tt.getIdForRequestBodySchema=tt.getIdForParameterSchema=tt.getRawOperationDataIdentifierName=void 0;function XR(e,t,r){return`_${Ur(e+"_"+t+"_"+r)}`}o(XR,"getRawOperationDataIdentifierName");tt.getRawOperationDataIdentifierName=XR;function e0(e,t,r,n){return`_${Ur(e.toLowerCase())}_`+t.toLowerCase()+"_"+r.toLowerCase()+`_${n.toLowerCase()}`}o(e0,"getIdForParameterSchema");tt.getIdForParameterSchema=e0;function t0(e,t,r){return`_${Ur(e.toLowerCase())}_`+t.toLowerCase()+`_rb_${Ur(r.toLowerCase())}`}o(t0,"getIdForRequestBodySchema");tt.getIdForRequestBodySchema=t0;function r0(e,t){return`_${Ur(e)}__${Ur(t)}`}o(r0,"getIdForRefSchema");tt.getIdForRefSchema=r0;function Ur(e){let t=[];for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);n>="0".charCodeAt(0)&&n<="9".charCodeAt(0)||n>="A".charCodeAt(0)&&n<="Z".charCodeAt(0)||n>="a".charCodeAt(0)&&n<="z".charCodeAt(0)?t.push(e.charAt(r)):t.push("_")}return t.join("")}o(Ur,"sanitizedIdentifierName");tt.sanitizedIdentifierName=Ur});var Ti=g(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});Le.getErrorsFromValidator=Le.shouldReject=Le.shouldLog=Le.logErrors=Le.validateParameters=Le.getParametersForOperation=void 0;var n0=dn(),i0=ka(),o0=o(e=>{let t=e.route.raw();return t.parameters?t.parameters.map(n=>({name:n.name,location:n.in,required:n.required,deprecated:n.deprecated,allowEmptyValue:n.allowEmptyValue})):[]},"getParametersForOperation");Le.getParametersForOperation=o0;var s0=o((e,t,r,n,i)=>{let s=[],a=!0,c=[];return e.forEach(u=>{if(u.required&&!t[u.name])a=!1,s.push(`Required ${i} parameter '${u.name}' not found`);else{let l=(0,i0.getIdForParameterSchema)(r,n,i,u.name),d=n0.Gateway.instance.schemaValidator[l],p=d(t[u.name]),y=(0,Le.getErrorsFromValidator)(d.errors);p||(a=!1,c.push(`${i} parameter: ${u.name} : ${t[u.name]}`),s.push(`Invalid value for ${i} parameter: '${u.name}' ${y.join(", ")}`))}}),{isValid:a,invalidValues:c,errors:s}},"validateParameters");Le.validateParameters=s0;var a0=o((e,t,r,n,i)=>{n?e.log[t](r,n,i):e.log[t](r,i)},"logErrors");Le.logErrors=a0;var c0=o(e=>e==="log-only"||e==="reject-and-log","shouldLog");Le.shouldLog=c0;var u0=o(e=>e==="reject-only"||e==="reject-and-log","shouldReject");Le.shouldReject=u0;var l0=o(e=>e?.map(t=>t.instancePath===void 0||t.instancePath===""?t.message??"Unknown validation error":t.instancePath.replace("/","")+" "+t.message)??["Unknown validation error"],"getErrorsFromValidator");Le.getErrorsFromValidator=l0});var c_=g(Ha=>{"use strict";Object.defineProperty(Ha,"__esModule",{value:!0});Ha.handleBodyValidation=void 0;var d0=dn(),Fa=ge(),p0=ka(),Je=Ti();async function h0(e,t,r){if(!r.validateBody||r.validateBody==="none")return;let n;try{n=await t.clone().json()}catch(h){let m=`Error in request body for method : ${t.method} in route: ${e.route.path} with content-type: ${t.headers.get("Content-Type")}`,v=Fa.HttpProblems.badRequest(t,e,{detail:`${m}, see errors property for more details`,errors:`${h}`});if((0,Je.shouldLog)(r.validateBody)&&(0,Je.logErrors)(e,r.logLevel??"info",m,[n],h),(0,Je.shouldReject)(r.validateBody))return v}if(!t.headers.get("Content-Type")){let h=`No content-type header defined in incoming request to ${t.method} in route: ${e.route.path}`,m=Fa.HttpProblems.badRequest(t,e,{detail:h});return(0,Je.shouldLog)(r.validateBody)&&(0,Je.logErrors)(e,r.logLevel??"info",h,[n],[h]),(0,Je.shouldReject)(r.validateBody)?m:void 0}let i=t.headers.get("Content-Type"),s=i.indexOf(";");s>-1&&(i=i.substring(0,s));let a=(0,p0.getIdForRequestBodySchema)(e.route.path,t.method,i),c=d0.Gateway.instance.schemaValidator[a];if(!c){let h=`No schema defined for method: ${t.method} in route: ${e.route.path} with content-type: ${t.headers.get("Content-Type")}`,m=Fa.HttpProblems.badRequest(t,e,{detail:h});return(0,Je.shouldLog)(r.validateBody)&&(0,Je.logErrors)(e,r.logLevel??"info",h,[n],[h]),(0,Je.shouldReject)(r.validateBody)?m:void 0}if(c(n))return;let l=c.errors,d="Request body did not pass validation",p=(0,Je.getErrorsFromValidator)(l),y=Fa.HttpProblems.badRequest(t,e,{detail:`${d}, see errors property for more details`,errors:p});if((0,Je.shouldLog)(r.validateBody)&&(0,Je.logErrors)(e,r.logLevel??"info",d,[n],p),(0,Je.shouldReject)(r.validateBody))return y}o(h0,"handleBodyValidation");Ha.handleBodyValidation=h0});var u_=g(qa=>{"use strict";Object.defineProperty(qa,"__esModule",{value:!0});qa.handleHeadersValidation=void 0;var f0=ge(),Si=Ti();function m0(e,t,r){if(!r.validateHeaders||r.validateHeaders==="none")return;let n={};t.headers.forEach((a,c)=>{n[c]=a});let i=(0,Si.getParametersForOperation)(e),s=(0,Si.validateParameters)(i.filter(a=>a.location==="header"),n,e.route.path,t.method.toLowerCase(),"header");if(!s.isValid){let a="Header validation failed",c=f0.HttpProblems.badRequest(t,e,{detail:`${a}, see errors property for more details`,errors:s.errors});if((0,Si.shouldLog)(r.validateHeaders)&&(0,Si.logErrors)(e,r.logLevel??"info",a,s.invalidValues,s.errors),(0,Si.shouldReject)(r.validateHeaders))return c}}o(m0,"handleHeadersValidation");qa.handleHeadersValidation=m0});var l_=g($a=>{"use strict";Object.defineProperty($a,"__esModule",{value:!0});$a.handlePathParameterValidation=void 0;var y0=ge(),Ii=Ti();function g0(e,t,r){if(!r.validatePathParameters||r.validatePathParameters==="none")return;let n=(0,Ii.getParametersForOperation)(e),i=(0,Ii.validateParameters)(n.filter(s=>s.location==="path"),t.params,e.route.path,t.method.toLowerCase(),"path");if(!i.isValid){let s="Path parameters validation failed",a=y0.HttpProblems.badRequest(t,e,{detail:`${s}, see errors property for more details`,errors:i.errors});if((0,Ii.shouldLog)(r.validatePathParameters)&&(0,Ii.logErrors)(e,r.logLevel??"info",s,i.invalidValues,i.errors),(0,Ii.shouldReject)(r.validatePathParameters))return a}}o(g0,"handlePathParameterValidation");$a.handlePathParameterValidation=g0});var d_=g(ja=>{"use strict";Object.defineProperty(ja,"__esModule",{value:!0});ja.handleQueryParameterValidation=void 0;var _0=ge(),Ai=Ti();function b0(e,t,r){if(!r.validateQueryParameters||r.validateQueryParameters==="none")return;let n=(0,Ai.getParametersForOperation)(e),i=(0,Ai.validateParameters)(n.filter(s=>s.location==="query"),t.query,e.route.path,t.method.toLowerCase(),"query");if(!i.isValid){let s="Query parameters validation failed",a=_0.HttpProblems.badRequest(t,e,{detail:`${s}, see errors property for more details`,errors:i.errors});if((0,Ai.shouldLog)(r.validateQueryParameters)&&(0,Ai.logErrors)(e,r.logLevel??"info",s,i.invalidValues,i.errors),(0,Ai.shouldReject)(r.validateQueryParameters))return a}}o(b0,"handleQueryParameterValidation");ja.handleQueryParameterValidation=b0});var p_=g(Mr=>{"use strict";Object.defineProperty(Mr,"__esModule",{value:!0});Mr.SchemaBasedRequestValidation=Mr.RequestValidationInboundPolicy=void 0;var E0=c_(),w0=u_(),v0=l_(),T0=d_(),S0=o(async(e,t,r)=>{let n=(0,T0.handleQueryParameterValidation)(t,e,r);if(n!==void 0||(n=(0,v0.handlePathParameterValidation)(t,e,r),n!==void 0)||(n=(0,w0.handleHeadersValidation)(t,e,r),n!==void 0))return n;let i=await(0,E0.handleBodyValidation)(t,e,r);return i!==void 0?i:e},"RequestValidationInboundPolicy");Mr.RequestValidationInboundPolicy=S0;Mr.SchemaBasedRequestValidation=Mr.RequestValidationInboundPolicy});var h_=g(Va=>{"use strict";Object.defineProperty(Va,"__esModule",{value:!0});Va.RequireOriginInboundPolicy=void 0;var I0=L(),A0=ge(),P0=o(async(e,t,r,n)=>{if(r.origins===void 0||r.origins.length===0)throw new I0.ConfigurationError(`RequireOriginInboundPolicy '${n}' configuration error - no allowed origins specified`);let i=typeof r.origins=="string"?r.origins.split(","):r.origins;i=i.map(a=>a.trim());let s=e.headers.get("origin");if(!s||!i.includes(s)){let a=r.failureDetail??"Forbidden";return A0.HttpProblems.forbidden(e,t,{detail:a})}return e},"RequireOriginInboundPolicy");Va.RequireOriginInboundPolicy=P0});var f_=g(Ga=>{"use strict";Object.defineProperty(Ga,"__esModule",{value:!0});Ga.SetBodyInboundPolicy=void 0;var R0=Be(),O0=o(async(e,t,r)=>new R0.ZuploRequest(e,{body:r.body}),"SetBodyInboundPolicy");Ga.SetBodyInboundPolicy=O0});var y_=g(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.SetHeadersInboundPolicy=void 0;var m_=L(),x0=Be(),N0=o(async(e,t,r,n)=>{let i=r.headers;if(!i||!Array.isArray(i)||i.length==0)throw new m_.ConfigurationError(`SetHeadersInboundPolicy '${n}' options.headers must be a valid array of { name, value }`);let s=new Headers(e.headers);return i.forEach(c=>{if(!c.name||c.name.length===0)throw new m_.ConfigurationError(`SetHeadersInboundPolicy '${n}' each option.headers[] entry must have a name property`);let u=c.overwrite===void 0?!0:c.overwrite;(!s.has(c.name)||u)&&s.set(c.name,c.value)}),new x0.ZuploRequest(e,{headers:s})},"SetHeadersInboundPolicy");Ba.SetHeadersInboundPolicy=N0});var __=g(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});Ka.SetHeadersOutboundPolicy=void 0;var g_=L(),C0=o(async(e,t,r,n,i)=>{let s=n.headers;if(!s||!Array.isArray(s)||s.length==0)throw new g_.ConfigurationError(`SetHeadersOutboundPolicy '${i}' options.headers must be a valid array of { name, value }`);let a=new Headers(e.headers);return s.forEach(u=>{if(!u.name||u.name.length===0)throw new g_.ConfigurationError(`SetHeadersOutboundPolicy '${i}' each option.headers[] entry must have a name property`);let l=u.overwrite===void 0?!0:u.overwrite;(!a.has(u.name)||l)&&a.set(u.name,u.value)}),new Response(e.body,{headers:a,status:e.status,statusText:e.statusText})},"SetHeadersOutboundPolicy");Ka.SetHeadersOutboundPolicy=C0});var E_=g(Ja=>{"use strict";Object.defineProperty(Ja,"__esModule",{value:!0});Ja.SetQueryParamsInboundPolicy=void 0;var b_=L(),L0=Be(),D0=o(async(e,t,r,n)=>{let i=r.params;if(!i||!Array.isArray(i)||i.length==0)throw new b_.ConfigurationError(`SetQueryParamsInboundPolicy '${n}' options.params must be a valid array of { name, value }`);let s=new URL(e.url);return i.forEach(c=>{if(!c.name||c.name.length===0)throw new b_.ConfigurationError(`SetQueryParamsInboundPolicy '${n}' each option.params[] entry must have a name property`);let u=c.overwrite===void 0?!0:c.overwrite;(!s.searchParams.has(c.name)||u)&&s.searchParams.set(c.name,c.value)}),new L0.ZuploRequest(s.toString(),e)},"SetQueryParamsInboundPolicy");Ja.SetQueryParamsInboundPolicy=D0});var w_=g(za=>{"use strict";Object.defineProperty(za,"__esModule",{value:!0});za.SetStatusOutboundPolicy=void 0;var U0=o(async(e,t,r,n,i)=>{if(!n.status||isNaN(n.status)||n.status<100||n.status>599)throw new Error(`Invalid SetStatusOutboundPolicy '${i}' - status must be a valid number between 100 and 599, not '${n.status}'`);return new Response(e.body,{headers:e.headers,status:n.status,statusText:n.statusText??e.statusText})},"SetStatusOutboundPolicy");za.SetStatusOutboundPolicy=U0});var v_=g(Wa=>{"use strict";Object.defineProperty(Wa,"__esModule",{value:!0});Wa.SleepInboundPolicy=void 0;var M0=L(),k0=o(async e=>new Promise(r=>{setTimeout(r,e)}),"sleep"),F0=o(async(e,t,r,n)=>{if(!r||r.sleepInMs===void 0||isNaN(r.sleepInMs))throw new M0.ConfigurationError(`SleepInboundPolicy '${n} must have a valid options.sleepInMs value`);return await k0(r.sleepInMs),e},"SleepInboundPolicy");Wa.SleepInboundPolicy=F0});var S_=g(Qa=>{"use strict";Object.defineProperty(Qa,"__esModule",{value:!0});Qa.SupabaseJwtInboundPolicy=void 0;var T_=L(),H0=ge(),q0=Be(),$0=pr(),j0=kt(),V0=o(async(e,t,r,n)=>{(0,$0.optionValidator)(r,n).required("secret","string").optional("allowUnauthenticatedRequests","boolean").optional("requiredClaims","object");let i={secret:r.secret,allowUnauthenticatedRequests:r.allowUnauthenticatedRequests??!1},s=await(0,j0.OpenIdJwtInboundPolicy)(e,t,i,n);if(s instanceof Response)return s;if(!(s instanceof q0.ZuploRequest))throw new T_.SystemError("Invalid State - SupabaseJwtInboundPolicy encountered a non-response that wasn't a ZuploRequest type')");let a=r.requiredClaims;if(!a)return s;let c=e.user?.data.app_metadata;if(!c)throw new T_.RuntimeError(`SupabaseJwtInboundPolicy policy '${n}' - has requiredClaims but the JWT token had no app_metadata property`);let u=Object.keys(a),l=[];return u.forEach(d=>{let p=a[d];Array.isArray(p)?p.includes(c[d])||l.push(d):p!==c[d]&&l.push(d)}),l.length>0?H0.HttpProblems.unauthorized(e,t,{detail:`Invalid JWT token - missing valid claims ${l.join(", ")}`}):s},"SupabaseJwtInboundPolicy");Qa.SupabaseJwtInboundPolicy=V0});var A_=g(Ya=>{"use strict";Object.defineProperty(Ya,"__esModule",{value:!0});Ya.UpstreamAzureAdServiceAuthInboundPolicy=void 0;var G0=dr(),B0=Er(),I_=L(),K0=Ge(),J0=_s(),z0=pr(),W0=o(async(e,t,r,n)=>{(0,z0.optionValidator)(r,n).required("activeDirectoryTenantId","string").required("activeDirectoryClientId","string").required("activeDirectoryClientSecret","string").optional("tokenRetries","number").optional("expirationOffsetSeconds","number");let i=await(0,G0.getPolicyCacheName)(n,r),s=new B0.MemoryZoneReadThroughCache(i,{logger:K0.SystemLogMap.getLogger(t)}),a=await s.get(n);if(!a){let c=await Q0(r,t);s.put(n,c.access_token,c.expires_in-(r.expirationOffsetSeconds??300)),a=c.access_token}return e.headers.set("Authorization",`Bearer ${a}`),e},"UpstreamAzureAdServiceAuthInboundPolicy");Ya.UpstreamAzureAdServiceAuthInboundPolicy=W0;async function Q0(e,t){let r=new URLSearchParams({client_id:e.activeDirectoryClientId,scope:`${e.activeDirectoryClientId}/.default`,client_secret:e.activeDirectoryClientSecret,grant_type:"client_credentials"}),n=await(0,J0.fetchRetry)({retries:e.tokenRetries??3,retryDelayMs:10},`https://login.microsoftonline.com/${e.activeDirectoryTenantId}/oauth2/v2.0/token`,{headers:{"content-type":"application/x-www-form-urlencoded"},method:"POST",body:r});if(n.status!==200){try{let s=await n.text();t.log.error("Could not get token from Azure AD",s)}catch{}throw new I_.RuntimeError("Could not get token from Azure AD")}let i=await n.json();if(i&&typeof i=="object"&&"access_token"in i&&typeof i.access_token=="string"&&"expires_in"in i&&typeof i.expires_in=="number")return{access_token:i.access_token,expires_in:i.expires_in};throw new I_.RuntimeError("Response returned from Azure AD is not in the expected format.")}o(Q0,"getAccessToken")});var R_=g(Za=>{"use strict";Object.defineProperty(Za,"__esModule",{value:!0});Za.UpstreamFirebaseAdminAuthInboundPolicy=void 0;var Y0=dr(),Z0=Er(),X0=L(),eO=Ge(),np=cn(),tO=pr(),P_="https://accounts.google.com/o/oauth2/token",ip,rO=o(async(e,t,r,n)=>{(0,tO.optionValidator)(r,n).required("serviceAccountJson","string"),ip||(ip=await np.GcpServiceAccount.init(r.serviceAccountJson));let i={scope:["https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/firebase.database","https://www.googleapis.com/auth/firebase.messaging","https://www.googleapis.com/auth/identitytoolkit","https://www.googleapis.com/auth/userinfo.email"].join(" ")},s=await(0,Y0.getPolicyCacheName)(n,r),a=new Z0.MemoryZoneReadThroughCache(s,{logger:eO.SystemLogMap.getLogger(t)}),c=await a.get(n);if(!c){let u=await(0,np.getTokenFromGcpServiceAccount)({serviceAccount:ip,audience:P_,payload:i}),l=await(0,np.exchangeGgpJwtForIdToken)(P_,u,{retries:r.tokenRetries??3,retryDelayMs:10});if(!l.access_token)throw new X0.RuntimeError("Invalid OAuth response from Firebase");c=l.access_token,a.put(n,c,(l.expires_in??3600)-(r.expirationOffsetSeconds??300))}return e.headers.set("Authorization",`Bearer ${c}`),e},"UpstreamFirebaseAdminAuthInboundPolicy");Za.UpstreamFirebaseAdminAuthInboundPolicy=rO});var O_=g(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});Xa.UpstreamFirebaseUserAuthInboundPolicy=void 0;var nO=dr(),iO=Er(),Nn=L(),oO=Ge(),sO=Hd(),op=cn(),aO=Qn(),cO=pr(),uO="https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit",lO=["acr","amr","at_hash","aud","auth_time","azp","cnf","c_hash","exp","iat","iss","jti","nbf","nonce"],sp,dO=o(async(e,t,r,n)=>{if((0,cO.optionValidator)(r,n).required("serviceAccountJson","string").required("webApiKey","string").optional("developerClaims","object").optional("userId","string").optional("userIdPropertyPath","string"),!r.userId&&!r.userIdPropertyPath)throw new Nn.ConfigurationError(`Either 'userId' or 'userIdPropertyPath' options must be set on policy '${n}'.`);let i={};if(typeof r.developerClaims<"u"){for(let p in r.developerClaims)if(Object.prototype.hasOwnProperty.call(r.developerClaims,p)){if(lO.indexOf(p)!==-1)throw new Nn.ConfigurationError(`Developer claim "${p}" is reserved and cannot be specified.`);i[p]=r.developerClaims[p]}}sp||(sp=await op.GcpServiceAccount.init(r.serviceAccountJson));let s=r.userId;if(!s&&!r.userIdPropertyPath){if(!e.user)throw new Nn.RuntimeError("Unable to set userId for upstream auth policy as request.user is 'undefined'. Do you have an authentication policy before this policy?.");s=e.user?.sub}else if(r.userIdPropertyPath){if(!e.user)throw new Nn.RuntimeError(`Unable to apply userIdPropertyPath '${r.userIdPropertyPath}' as request.user is 'undefined'. Do you have an authentication policy before this policy?`);s=(0,aO.getValueFromRequestUser)(e.user,r.userIdPropertyPath,"userIdPropertyPath")}if(!s)throw new Nn.RuntimeError(`Unable to determine user from for the policy ${n}`);let a=await(0,nO.getPolicyCacheName)(n,r),c=new iO.MemoryZoneReadThroughCache(a,{logger:oO.SystemLogMap.getLogger(t)}),u={uid:s,claims:i},l=await(0,sO.sha256)(JSON.stringify(u)),d=await c.get(l);if(!d){let p=await(0,op.getTokenFromGcpServiceAccount)({serviceAccount:sp,audience:uO,payload:u}),y=`https://identitytoolkit.googleapis.com/v1/accounts:signInWithCustomToken?key=${r.webApiKey}`,h=await(0,op.exchangeFirebaseJwtForIdToken)(y,p,{retries:r.tokenRetries??3,retryDelayMs:10});if(!h.idToken)throw new Nn.RuntimeError("Invalid token response from Firebase");d=h.idToken,c.put(l,d,(h.expiresIn?parseInt(h.expiresIn):3600)-(r.expirationOffsetSeconds??300))}return e.headers.set("Authorization",`Bearer ${d}`),e},"UpstreamFirebaseUserAuthInboundPolicy");Xa.UpstreamFirebaseUserAuthInboundPolicy=dO});var N_=g(ec=>{"use strict";Object.defineProperty(ec,"__esModule",{value:!0});ec.UpstreamGcpJwtInboundPolicy=void 0;var x_=cn(),pO=pr(),ap,hO=o(async(e,t,r,n)=>{(0,pO.optionValidator)(r,n).required("audience","string").required("serviceAccountJson","string"),ap||(ap=await x_.GcpServiceAccount.init(r.serviceAccountJson));let i=await(0,x_.getTokenFromGcpServiceAccount)({serviceAccount:ap,audience:r.audience});return e.headers.set("Authorization",`Bearer ${i}`),e},"UpstreamGcpJwtInboundPolicy");ec.UpstreamGcpJwtInboundPolicy=hO});var L_=g(tc=>{"use strict";Object.defineProperty(tc,"__esModule",{value:!0});tc.UpstreamGcpServiceAuthInboundPolicy=void 0;var fO=dr(),mO=Wc(),yO=Er(),gO=L(),cp=cn(),_O=pr(),C_="https://www.googleapis.com/oauth2/v4/token",up,bO=o(async(e,t,r,n)=>{(0,_O.optionValidator)(r,n).required("audience","string").required("serviceAccountJson","string").optional("tokenRetries","number").optional("expirationOffsetSeconds","number"),up||(up=await cp.GcpServiceAccount.init(r.serviceAccountJson));let i=await(0,fO.getPolicyCacheName)(n,r),s;r.useMemoryCacheOnly?s=new mO.MemoryCache(i):s=new yO.MemoryZoneReadThroughCache(i,t);let a=await s.get(n);if(!a){let c=await(0,cp.getTokenFromGcpServiceAccount)({serviceAccount:up,audience:C_,payload:{target_audience:`${r.audience}`}}),{id_token:u}=await(0,cp.exchangeGgpJwtForIdToken)(C_,c,{retries:r.tokenRetries??3,retryDelayMs:10});if(!u)throw new gO.RuntimeError("Invalid token response from GCP");a=u,s.put(n,a,3600-(r.expirationOffsetSeconds??300))}return e.headers.set("Authorization",`Bearer ${a}`),e},"UpstreamGcpServiceAuthInboundPolicy");tc.UpstreamGcpServiceAuthInboundPolicy=bO});var U_=g(rc=>{"use strict";Object.defineProperty(rc,"__esModule",{value:!0});rc.ValidateJsonSchemaInbound=void 0;var EO=L(),D_=ge(),wO=o(async(e,t,r)=>{let n=e.clone(),i;try{i=await n.json()}catch{return D_.HttpProblems.badRequest(e,t,{detail:"Invalid JSON body - expected well-formed JSON document"})}if(r.validator(i))return e;let{errors:a}=r.validator;if(!a)throw new EO.SystemError("Invalid state - validator error object is undefined even though validation failed.");let c=a.map(u=>u.instancePath===void 0||u.instancePath===""?"Body "+u.message:u.instancePath.replace("/","")+" "+u.message);return D_.HttpProblems.badRequest(e,t,{detail:"Incoming body did not pass schema validation",errors:c})},"ValidateJsonSchemaInbound");rc.ValidateJsonSchemaInbound=wO});var M_=g(hr=>{"use strict";Object.defineProperty(hr,"__esModule",{value:!0});hr.serialize=hr.ContentTypes=void 0;hr.ContentTypes={Json:"application/json",Form:"application/x-www-form-urlencoded"};function vO(e,t){if(e!==null)return t&&typeof e=="string"?e:typeof e=="object"&&t?.startsWith(hr.ContentTypes.Form)?new URLSearchParams(e).toString():typeof e=="object"&&t?.startsWith(hr.ContentTypes.Json)||!t?JSON.stringify(e):e}o(vO,"serialize");hr.serialize=vO});var k_=g(nc=>{"use strict";Object.defineProperty(nc,"__esModule",{value:!0});nc.ServiceProviderImpl=void 0;var TO=L(),lp=class e{static{o(this,"ServiceProviderImpl")}static#e;services=new Map;constructor(){}static getInstance(){return e.#e||(e.#e=new e),e.#e}setInstance(t){e.#e=t}addService(t,r){if(this.services.get(t))throw new TO.SystemError(`A service with the name ${t} already exists -- you cannot have duplicate services`);this.services.set(t,r)}getService(t){return this.services.get(t)}};nc.ServiceProviderImpl=lp});var F_=g(dp=>{"use strict";Object.defineProperty(dp,"__esModule",{value:!0});var SO={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a Teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"};dp.default=SO});var lo=g(f=>{"use strict";var IO=f&&f.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),H_=f&&f.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&IO(t,e,r)},AO=f&&f.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(f,"__esModule",{value:!0});f.ReadmeMetricsInboundPolicy=f.RateLimitInboundPolicy=f.BasicRateLimitInboundPolicy=f.PropelAuthJwtInboundPolicy=f.OpenIdJwtInboundPolicy=f.OktaJwtInboundPolicy=f.setMoesifContext=f.MoesifInboundPolicy=f.MockApiInboundPolicy=f.JWTScopeValidationInboundPolicy=f.GeoFilterInboundPolicy=f.FormDataToJsonInboundPolicy=f.FirebaseJwtInboundPolicy=f.CompositeInboundPolicy=f.CognitoJwtInboundPolicy=f.ClerkJwtInboundPolicy=f.ClearHeadersOutboundPolicy=f.ClearHeadersInboundPolicy=f.ChangeMethodInboundPolicy=f.CachingInboundPolicy=f.BasicAuthInboundPolicy=f.Auth0JwtInboundPolicy=f.ApiKeyInboundPolicy=f.ApiAuthKeyInboundPolicy=f.AmberfloMeteringPolicy=f.AmberfloMeteringInboundPolicy=f.AuditLogPlugin=f.AuditLogDataStaxProvider=f.HttpStatusCode=f.webSocketPipelineHandler=f.webSocketHandler=f.urlRewriteHandler=f.urlForwardHandler=f.redirectHandler=f.openApiSpecHandler=f.awsLambdaHandler=f.AwsLambdaHandlerExtensions=f.purgeGatewayCache=f.Handler=f.originalFetch=f.ConfigurationError=f.isZuploReadableEnvVariableName=f.isRestrictedEnvVariableName=f.environment=f.ContextData=f.ResponseSentEvent=f.ResponseSendingEvent=f.VALID_COMPATIBILITY_DATES=f.ZoneCache=f.MemoryZoneReadThroughCache=void 0;f.sanitizedIdentifierName=f.getRawOperationDataIdentifierName=f.getIdForRequestBodySchema=f.getIdForRefSchema=f.getIdForParameterSchema=f.SystemLogMap=f.httpStatuses=f.SYSTEM_LOGGER=f.API_KEY=f.ServiceProviderImpl=f.serialize=f.ContentTypes=f.Router=f.LookupResult=f.SystemRouteName=f.ZuploRequest=f.ProblemResponseFormatter=f.HttpProblems=f.ValidateJsonSchemaInbound=f.UpstreamGcpServiceAuthInboundPolicy=f.UpstreamGcpJwtInboundPolicy=f.UpstreamFirebaseUserAuthInboundPolicy=f.UpstreamFirebaseAdminAuthInboundPolicy=f.UpstreamAzureAdServiceAuthInboundPolicy=f.SupabaseJwtInboundPolicy=f.SleepInboundPolicy=f.SetStatusOutboundPolicy=f.SetQueryParamsInboundPolicy=f.SetHeadersOutboundPolicy=f.SetHeadersInboundPolicy=f.SetBodyInboundPolicy=f.RequireOriginInboundPolicy=f.SchemaBasedRequestValidation=f.RequestValidationInboundPolicy=f.RequestSizeLimitInboundPolicy=f.ReplaceStringOutboundPolicy=f.RemoveQueryParamsInboundPolicy=f.RemoveHeadersOutboundPolicy=f.RemoveHeadersInboundPolicy=void 0;Jp();var PO=Er();Object.defineProperty(f,"MemoryZoneReadThroughCache",{enumerable:!0,get:function(){return PO.MemoryZoneReadThroughCache}});var RO=Wi();Object.defineProperty(f,"ZoneCache",{enumerable:!0,get:function(){return RO.ZoneCache}});var OO=Wp();Object.defineProperty(f,"VALID_COMPATIBILITY_DATES",{enumerable:!0,get:function(){return OO.VALID_COMPATIBILITY_DATES}});var q_=Tr();Object.defineProperty(f,"ResponseSendingEvent",{enumerable:!0,get:function(){return q_.ResponseSendingEvent}});Object.defineProperty(f,"ResponseSentEvent",{enumerable:!0,get:function(){return q_.ResponseSentEvent}});var xO=hy();Object.defineProperty(f,"ContextData",{enumerable:!0,get:function(){return xO.ContextData}});var pp=nd();Object.defineProperty(f,"environment",{enumerable:!0,get:function(){return pp.environment}});Object.defineProperty(f,"isRestrictedEnvVariableName",{enumerable:!0,get:function(){return pp.isRestrictedEnvVariableName}});Object.defineProperty(f,"isZuploReadableEnvVariableName",{enumerable:!0,get:function(){return pp.isZuploReadableEnvVariableName}});var NO=L();Object.defineProperty(f,"ConfigurationError",{enumerable:!0,get:function(){return NO.ConfigurationError}});var CO=od();Object.defineProperty(f,"originalFetch",{enumerable:!0,get:function(){return CO.originalFetch}});var $_=vy();Object.defineProperty(f,"Handler",{enumerable:!0,get:function(){return $_.Handler}});Object.defineProperty(f,"purgeGatewayCache",{enumerable:!0,get:function(){return $_.purgeGatewayCache}});var j_=Hy();Object.defineProperty(f,"AwsLambdaHandlerExtensions",{enumerable:!0,get:function(){return j_.AwsLambdaHandlerExtensions}});Object.defineProperty(f,"awsLambdaHandler",{enumerable:!0,get:function(){return j_.awsLambdaHandler}});var LO=$y();Object.defineProperty(f,"openApiSpecHandler",{enumerable:!0,get:function(){return LO.openApiSpecHandler}});var DO=jy();Object.defineProperty(f,"redirectHandler",{enumerable:!0,get:function(){return DO.redirectHandler}});var UO=Gy();Object.defineProperty(f,"urlForwardHandler",{enumerable:!0,get:function(){return UO.urlForwardHandler}});var MO=Ky();Object.defineProperty(f,"urlRewriteHandler",{enumerable:!0,get:function(){return MO.urlRewriteHandler}});var kO=zy();Object.defineProperty(f,"webSocketHandler",{enumerable:!0,get:function(){return kO.webSocketHandler}});var FO=Yy();Object.defineProperty(f,"webSocketPipelineHandler",{enumerable:!0,get:function(){return FO.webSocketPipelineHandler}});var HO=yu();Object.defineProperty(f,"HttpStatusCode",{enumerable:!0,get:function(){return HO.HttpStatusCode}});H_(og(),f);H_(cg(),f);var qO=ug();Object.defineProperty(f,"AuditLogDataStaxProvider",{enumerable:!0,get:function(){return qO.AuditLogDataStaxProvider}});var $O=dg();Object.defineProperty(f,"AuditLogPlugin",{enumerable:!0,get:function(){return $O.AuditLogPlugin}});var V_=yg();Object.defineProperty(f,"AmberfloMeteringInboundPolicy",{enumerable:!0,get:function(){return V_.AmberfloMeteringInboundPolicy}});Object.defineProperty(f,"AmberfloMeteringPolicy",{enumerable:!0,get:function(){return V_.AmberfloMeteringPolicy}});var jO=Eg();Object.defineProperty(f,"ApiAuthKeyInboundPolicy",{enumerable:!0,get:function(){return jO.ApiAuthKeyInboundPolicy}});var VO=Vd();Object.defineProperty(f,"ApiKeyInboundPolicy",{enumerable:!0,get:function(){return VO.ApiKeyInboundPolicy}});var GO=wg();Object.defineProperty(f,"Auth0JwtInboundPolicy",{enumerable:!0,get:function(){return GO.Auth0JwtInboundPolicy}});var BO=vg();Object.defineProperty(f,"BasicAuthInboundPolicy",{enumerable:!0,get:function(){return BO.BasicAuthInboundPolicy}});var KO=Tg();Object.defineProperty(f,"CachingInboundPolicy",{enumerable:!0,get:function(){return KO.CachingInboundPolicy}});var JO=Sg();Object.defineProperty(f,"ChangeMethodInboundPolicy",{enumerable:!0,get:function(){return JO.ChangeMethodInboundPolicy}});var zO=Ig();Object.defineProperty(f,"ClearHeadersInboundPolicy",{enumerable:!0,get:function(){return zO.ClearHeadersInboundPolicy}});var WO=Ag();Object.defineProperty(f,"ClearHeadersOutboundPolicy",{enumerable:!0,get:function(){return WO.ClearHeadersOutboundPolicy}});var QO=Pg();Object.defineProperty(f,"ClerkJwtInboundPolicy",{enumerable:!0,get:function(){return QO.ClerkJwtInboundPolicy}});var YO=Og();Object.defineProperty(f,"CognitoJwtInboundPolicy",{enumerable:!0,get:function(){return YO.CognitoJwtInboundPolicy}});var ZO=Ng();Object.defineProperty(f,"CompositeInboundPolicy",{enumerable:!0,get:function(){return ZO.CompositeInboundPolicy}});var XO=Cg();Object.defineProperty(f,"FirebaseJwtInboundPolicy",{enumerable:!0,get:function(){return XO.FirebaseJwtInboundPolicy}});var ex=Lg();Object.defineProperty(f,"FormDataToJsonInboundPolicy",{enumerable:!0,get:function(){return ex.FormDataToJsonInboundPolicy}});var tx=Dg();Object.defineProperty(f,"GeoFilterInboundPolicy",{enumerable:!0,get:function(){return tx.GeoFilterInboundPolicy}});var rx=Ug();Object.defineProperty(f,"JWTScopeValidationInboundPolicy",{enumerable:!0,get:function(){return rx.JWTScopeValidationInboundPolicy}});var nx=kg();Object.defineProperty(f,"MockApiInboundPolicy",{enumerable:!0,get:function(){return nx.MockApiInboundPolicy}});var G_=jg();Object.defineProperty(f,"MoesifInboundPolicy",{enumerable:!0,get:function(){return G_.MoesifInboundPolicy}});Object.defineProperty(f,"setMoesifContext",{enumerable:!0,get:function(){return G_.setMoesifContext}});var ix=Vg();Object.defineProperty(f,"OktaJwtInboundPolicy",{enumerable:!0,get:function(){return ix.OktaJwtInboundPolicy}});var ox=kt();Object.defineProperty(f,"OpenIdJwtInboundPolicy",{enumerable:!0,get:function(){return ox.OpenIdJwtInboundPolicy}});var sx=Gg();Object.defineProperty(f,"PropelAuthJwtInboundPolicy",{enumerable:!0,get:function(){return sx.PropelAuthJwtInboundPolicy}});var B_=Yg();Object.defineProperty(f,"BasicRateLimitInboundPolicy",{enumerable:!0,get:function(){return B_.RateLimitInboundPolicy}});Object.defineProperty(f,"RateLimitInboundPolicy",{enumerable:!0,get:function(){return B_.RateLimitInboundPolicy}});var ax=t_();Object.defineProperty(f,"ReadmeMetricsInboundPolicy",{enumerable:!0,get:function(){return ax.ReadmeMetricsInboundPolicy}});var cx=r_();Object.defineProperty(f,"RemoveHeadersInboundPolicy",{enumerable:!0,get:function(){return cx.RemoveHeadersInboundPolicy}});var ux=n_();Object.defineProperty(f,"RemoveHeadersOutboundPolicy",{enumerable:!0,get:function(){return ux.RemoveHeadersOutboundPolicy}});var lx=i_();Object.defineProperty(f,"RemoveQueryParamsInboundPolicy",{enumerable:!0,get:function(){return lx.RemoveQueryParamsInboundPolicy}});var dx=o_();Object.defineProperty(f,"ReplaceStringOutboundPolicy",{enumerable:!0,get:function(){return dx.ReplaceStringOutboundPolicy}});var px=a_();Object.defineProperty(f,"RequestSizeLimitInboundPolicy",{enumerable:!0,get:function(){return px.RequestSizeLimitInboundPolicy}});var K_=p_();Object.defineProperty(f,"RequestValidationInboundPolicy",{enumerable:!0,get:function(){return K_.RequestValidationInboundPolicy}});Object.defineProperty(f,"SchemaBasedRequestValidation",{enumerable:!0,get:function(){return K_.SchemaBasedRequestValidation}});var hx=h_();Object.defineProperty(f,"RequireOriginInboundPolicy",{enumerable:!0,get:function(){return hx.RequireOriginInboundPolicy}});var fx=f_();Object.defineProperty(f,"SetBodyInboundPolicy",{enumerable:!0,get:function(){return fx.SetBodyInboundPolicy}});var mx=y_();Object.defineProperty(f,"SetHeadersInboundPolicy",{enumerable:!0,get:function(){return mx.SetHeadersInboundPolicy}});var yx=__();Object.defineProperty(f,"SetHeadersOutboundPolicy",{enumerable:!0,get:function(){return yx.SetHeadersOutboundPolicy}});var gx=E_();Object.defineProperty(f,"SetQueryParamsInboundPolicy",{enumerable:!0,get:function(){return gx.SetQueryParamsInboundPolicy}});var _x=w_();Object.defineProperty(f,"SetStatusOutboundPolicy",{enumerable:!0,get:function(){return _x.SetStatusOutboundPolicy}});var bx=v_();Object.defineProperty(f,"SleepInboundPolicy",{enumerable:!0,get:function(){return bx.SleepInboundPolicy}});var Ex=S_();Object.defineProperty(f,"SupabaseJwtInboundPolicy",{enumerable:!0,get:function(){return Ex.SupabaseJwtInboundPolicy}});var wx=A_();Object.defineProperty(f,"UpstreamAzureAdServiceAuthInboundPolicy",{enumerable:!0,get:function(){return wx.UpstreamAzureAdServiceAuthInboundPolicy}});var vx=R_();Object.defineProperty(f,"UpstreamFirebaseAdminAuthInboundPolicy",{enumerable:!0,get:function(){return vx.UpstreamFirebaseAdminAuthInboundPolicy}});var Tx=O_();Object.defineProperty(f,"UpstreamFirebaseUserAuthInboundPolicy",{enumerable:!0,get:function(){return Tx.UpstreamFirebaseUserAuthInboundPolicy}});var Sx=N_();Object.defineProperty(f,"UpstreamGcpJwtInboundPolicy",{enumerable:!0,get:function(){return Sx.UpstreamGcpJwtInboundPolicy}});var Ix=L_();Object.defineProperty(f,"UpstreamGcpServiceAuthInboundPolicy",{enumerable:!0,get:function(){return Ix.UpstreamGcpServiceAuthInboundPolicy}});var Ax=U_();Object.defineProperty(f,"ValidateJsonSchemaInbound",{enumerable:!0,get:function(){return Ax.ValidateJsonSchemaInbound}});var Px=ge();Object.defineProperty(f,"HttpProblems",{enumerable:!0,get:function(){return Px.HttpProblems}});var Rx=oo();Object.defineProperty(f,"ProblemResponseFormatter",{enumerable:!0,get:function(){return Rx.ProblemResponseFormatter}});var Ox=Be();Object.defineProperty(f,"ZuploRequest",{enumerable:!0,get:function(){return Ox.ZuploRequest}});var xx=Ar();Object.defineProperty(f,"SystemRouteName",{enumerable:!0,get:function(){return xx.SystemRouteName}});var J_=zl();Object.defineProperty(f,"LookupResult",{enumerable:!0,get:function(){return J_.LookupResult}});Object.defineProperty(f,"Router",{enumerable:!0,get:function(){return J_.Router}});var z_=M_();Object.defineProperty(f,"ContentTypes",{enumerable:!0,get:function(){return z_.ContentTypes}});Object.defineProperty(f,"serialize",{enumerable:!0,get:function(){return z_.serialize}});var Nx=k_();Object.defineProperty(f,"ServiceProviderImpl",{enumerable:!0,get:function(){return Nx.ServiceProviderImpl}});var W_=Ru();Object.defineProperty(f,"API_KEY",{enumerable:!0,get:function(){return W_.API_KEY}});Object.defineProperty(f,"SYSTEM_LOGGER",{enumerable:!0,get:function(){return W_.SYSTEM_LOGGER}});var Cx=F_();Object.defineProperty(f,"httpStatuses",{enumerable:!0,get:function(){return AO(Cx).default}});var Lx=Ge();Object.defineProperty(f,"SystemLogMap",{enumerable:!0,get:function(){return Lx.SystemLogMap}});var Pi=ka();Object.defineProperty(f,"getIdForParameterSchema",{enumerable:!0,get:function(){return Pi.getIdForParameterSchema}});Object.defineProperty(f,"getIdForRefSchema",{enumerable:!0,get:function(){return Pi.getIdForRefSchema}});Object.defineProperty(f,"getIdForRequestBodySchema",{enumerable:!0,get:function(){return Pi.getIdForRequestBodySchema}});Object.defineProperty(f,"getRawOperationDataIdentifierName",{enumerable:!0,get:function(){return Pi.getRawOperationDataIdentifierName}});Object.defineProperty(f,"sanitizedIdentifierName",{enumerable:!0,get:function(){return Pi.sanitizedIdentifierName}})});var Q_=g(Cn=>{"use strict";Object.defineProperty(Cn,"__esModule",{value:!0});Cn.BaseCryptoBeta=Cn.supportedDigests=void 0;Cn.supportedDigests=["sha-1","sha-256","sha-384","sha-512"];var hp=class{static{o(this,"BaseCryptoBeta")}};Cn.BaseCryptoBeta=hp});var Y_=g(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});ic.WorkerCryptoBeta=void 0;var fp=Q_(),Dx=L(),mp=class extends fp.BaseCryptoBeta{static{o(this,"WorkerCryptoBeta")}async digest(t,r){if(!fp.supportedDigests.includes(t.toLowerCase()))throw new Dx.RuntimeError(`Algorithm ${t} is not supported. Try using ${fp.supportedDigests.join(", ")}`);let n=new TextEncoder().encode(r),i=await crypto.subtle.digest(t,n);return Array.from(new Uint8Array(i)).map(c=>c.toString(16).padStart(2,"0")).join("")}};ic.WorkerCryptoBeta=mp});var Z_=g(oc=>{"use strict";Object.defineProperty(oc,"__esModule",{value:!0});oc.BaseKeyValueStore=void 0;var yp=class{static{o(this,"BaseKeyValueStore")}context;constructor(t){this.context=t}};oc.BaseKeyValueStore=yp});var eb=g(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});sc.WorkerKeyValueStore=void 0;var X_=L(),Ux=Z_(),gp=class extends Ux.BaseKeyValueStore{static{o(this,"WorkerKeyValueStore")}#e;constructor(t){super(t);let n=globalThis.ZUPLO_KV;if(!n)throw new X_.FeatureNotEnabledError("The Key Value Store feature is not enabled for this project.");this.#e=n}put(t,r,n){if(typeof t!="string")throw new X_.ConfigurationError("value must be of type string");return this.#e.put(t,r,n?{expirationTtl:n.expirationSecondsTtl}:void 0)}get(t,r){return this.#e.get(t,{type:"text",cacheTtl:r?.cacheSecondsTtl})}delete(t){return this.#e.delete(t)}};sc.WorkerKeyValueStore=gp});var xt=g(ct=>{"use strict";var Mx=ct&&ct.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),kx=ct&&ct.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Mx(t,e,r)};Object.defineProperty(ct,"__esModule",{value:!0});ct.KeyValueStore=ct.CryptoBeta=void 0;kx(lo(),ct);var Fx=Y_();Object.defineProperty(ct,"CryptoBeta",{enumerable:!0,get:function(){return Fx.WorkerCryptoBeta}});var Hx=eb();Object.defineProperty(ct,"KeyValueStore",{enumerable:!0,get:function(){return Hx.WorkerKeyValueStore}})});var KN={};Vi(KN,{GraphQLComplexityLimitInboundPolicy:()=>Cb,GraphQLDisableIntrospectionInboundPolicy:()=>Db});module.exports=Gi(KN);var Gn=Vp(xt());function B(e,t){if(!!!e)throw new Error(t)}o(B,"devAssert");function Ee(e){return typeof e=="object"&&e!==null}o(Ee,"isObjectLike");function St(e,t){if(!!!e)throw new Error(t??"Unexpected invariant triggered.")}o(St,"invariant");var qx=/\r\n|[\n\r]/g;function Ln(e,t){let r=0,n=1;for(let i of e.body.matchAll(qx)){if(typeof i.index=="number"||St(!1),i.index>=t)break;r=i.index+i[0].length,n+=1}return{line:n,column:t+1-r}}o(Ln,"getLocation");function _p(e){return ac(e.source,Ln(e.source,e.start))}o(_p,"printLocation");function ac(e,t){let r=e.locationOffset.column-1,n="".padStart(r)+e.body,i=t.line-1,s=e.locationOffset.line-1,a=t.line+s,c=t.line===1?r:0,u=t.column+c,l=`${e.name}:${a}:${u}
|
|
66
66
|
`,d=n.split(/\r\n|[\n\r]/g),p=d[i];if(p.length>120){let y=Math.floor(u/80),h=u%80,m=[];for(let v=0;v<p.length;v+=80)m.push(p.slice(v,v+80));return l+tb([[`${a} |`,m[0]],...m.slice(1,y+1).map(v=>["|",v]),["|","^".padStart(h)],["|",m[y+1]]])}return l+tb([[`${a-1} |`,d[i-1]],[`${a} |`,p],["|","^".padStart(u)],[`${a+1} |`,d[i+1]]])}o(ac,"printSourceLocation");function tb(e){let t=e.filter(([n,i])=>i!==void 0),r=Math.max(...t.map(([n])=>n.length));return t.map(([n,i])=>n.padStart(r)+(i?" "+i:"")).join(`
|
|
67
67
|
`)}o(tb,"printPrefixedLines");function $x(e){let t=e[0];return t==null||"kind"in t||"length"in t?{nodes:t,source:e[1],positions:e[2],path:e[3],originalError:e[4],extensions:e[5]}:t}o($x,"toNormalizedOptions");var N=class e extends Error{static{o(this,"GraphQLError")}constructor(t,...r){var n,i,s;let{nodes:a,source:c,positions:u,path:l,originalError:d,extensions:p}=$x(r);super(t),this.name="GraphQLError",this.path=l??void 0,this.originalError=d??void 0,this.nodes=rb(Array.isArray(a)?a:a?[a]:void 0);let y=rb((n=this.nodes)===null||n===void 0?void 0:n.map(m=>m.loc).filter(m=>m!=null));this.source=c??(y==null||(i=y[0])===null||i===void 0?void 0:i.source),this.positions=u??y?.map(m=>m.start),this.locations=u&&c?u.map(m=>Ln(c,m)):y?.map(m=>Ln(m.source,m.start));let h=Ee(d?.extensions)?d?.extensions:void 0;this.extensions=(s=p??h)!==null&&s!==void 0?s:Object.create(null),Object.defineProperties(this,{message:{writable:!0,enumerable:!0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),d!=null&&d.stack?Object.defineProperty(this,"stack",{value:d.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,e):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}get[Symbol.toStringTag](){return"GraphQLError"}toString(){let t=this.message;if(this.nodes)for(let r of this.nodes)r.loc&&(t+=`
|
|
68
68
|
|