@ahmadissa/cloudworker-proxy 1.0.22 → 1.0.24
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/dist/index.js +16 -5
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";var fs=Object.create;var Tt=Object.defineProperty;var ps=Object.getOwnPropertyDescriptor;var ms=Object.getOwnPropertyNames;var gs=Object.getPrototypeOf,ys=Object.prototype.hasOwnProperty;var S=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var As=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ms(t))!ys.call(e,n)&&n!==r&&Tt(e,n,{get:()=>t[n],enumerable:!(s=ps(t,n))||s.enumerable});return e};var E=(e,t,r)=>(r=e!=null?fs(gs(e)):{},As(t||!e||!e.__esModule?Tt(r,"default",{value:e,enumerable:!0}):r,e));var Ne=S((Xo,_t)=>{function ws({host:e=".*",path:t=".*",excludePath:r=null,method:s=[".*"],handler:n,protocol:a=".*",handlerName:o,headers:i={},data:c}){let h=[],f=[],d=e.replace(/(:([^.]+))/g,(T,P,_)=>(h.push(_),"([^.]+)")),l=t.replace(/(:([^/]+))/g,(T,P,_)=>_.slice(-1)==="*"?(f.push(_.slice(0,_.length-1)),"(.*)"):(f.push(_),"([^/]*)")),m=new RegExp(`^${d}$`,"i"),y=new RegExp(`^${l}$`,"i"),A=r?new RegExp(`^${r}$`,"i"):null,p=new RegExp(`^${s.join("|")}$`,"i"),g=new RegExp(`^${a}$`,"i");return{hostVariables:h,pathVariables:f,host:m,path:y,excludePath:A,method:p,protocol:g,handler:n,handlerName:o,headers:i,data:c}}function Ot(e){return[...e].reduce((t,r)=>{let s={};return s[r[0]]=r[1],{...t,...s}},{})}async function Ss(e,t=1024*1024){let r=[],s=e.getReader(),n=new TextDecoder,a=0;for(;t&&a<t;){let{done:i,value:c}=await s.read();if(i)break;a+=c.byteLength,r.push(n.decode(c))}let o=r.join("");return t?o.substring(0,t):o}function bs(e){let t=new URL(e.url),r=Ot(t.searchParams),s=Ot(e.headers);s.host&&(t.hostname=s.host);let n,a;async function o(i){if(a>=i)return n.substring(0,i);let c=e.clone();return n=await Ss(c.body,i),n}return{body:e.body,headers:s,host:t.host,hostname:t.hostname,href:t.href,json:async i=>JSON.parse(o(i)),method:e.method,origin:`${t.protocol}//${t.host}`,path:t.pathname,protocol:t.protocol.slice(0,-1),query:r,querystring:t.search.slice(1),search:t.search,text:async i=>e.headers.get("content-type")==="application/x-www-form-urlencoded"?decodeURIComponent(await o(i)):o(i)}}_t.exports={parseRoute:ws,parseRequest:bs}});var Pt=S((xo,qt)=>{function vs(e,t){let r={},s=t.host.exec(e.host);t.hostVariables.forEach((a,o)=>{r[a]=s[o+1]});let n=t.path.exec(e.path);return t.pathVariables.forEach((a,o)=>{r[a]=n[o+1]}),r}function Cs(e,t){let r=!0;return Object.keys(e.headers).forEach(s=>{t.headers[s]!==e.headers[s]&&(r=!1)}),r}function Es(e,t){return e.protocol.test(t.protocol)}function Ts(e,t){return e.method.test(t.method)&&e.host.test(t.host)&&e.path.test(t.path)&&Cs(e,t)&&Es(e,t)&&(!e.excludePath||!e.excludePath.test(t.path))}async function Re(e,t){let[r,...s]=t;if(!r)return new Response("NOT_FOUND",{status:404});if(!Ts(r,e.request))return Re(e,s);e.state.handlers=e.state.handlers||[],e.state.handlers.push(r.handlerName||r.handler.name),e.params=vs(e.request,r);try{return r.handler(e,async n=>Re(n,s))}catch(n){throw n.route=r.handler.name,n}}qt.exports={recurseRoutes:Re}});var kt=S((Yo,Ut)=>{Ut.exports={methods:{DELETE:"DELETE",GET:"GET",HEAD:"HEAD",OPTIONS:"OPTIONS",PATCH:"PATCH",POST:"POST"},statusMessages:{404:"Not found",429:"Rate limited"}}});var $t=S((Zo,Rt)=>{var Os=Ne();Rt.exports=class Nt{constructor(t){this.request=Os.parseRequest(t.request),this.event=t,this.state={},this.cloned=!1,this.response={headers:{}},this.body="",this.status=404,this.query=this.request.query}header(t){return this.request.headers[t]}set(t,r){this.response.headers[t]=r}clone(){let t=new Nt(this.event);return t.cloned=!0,t}}});var Ft=S((ei,Ht)=>{var J=Ne(),_s=Pt(),re=kt(),qs=$t();Ht.exports=class{constructor(){this.routes=[]}get(t,r){let s=J.parseRoute({method:[re.methods.GET,re.methods.HEAD],path:t,handler:r});this.routes.push(s)}post(t,r){let s=J.parseRoute({method:[re.methods.POST],path:t,handler:r});this.routes.push(s)}patch(t,r){let s=J.parseRoute({method:[re.methods.PATCH],path:t,handler:r});this.routes.push(s)}del(t,r){let s=J.parseRoute({method:[re.methods.DELETE],path:t,handler:r});this.routes.push(s)}use(t){let r=J.parseRoute({handler:t,middleware:!0});this.routes.push(r)}add({host:t,path:r,excludePath:s,method:n,handlerName:a,headers:o,protocol:i},c){let h=J.parseRoute({method:n,host:t,path:r,excludePath:s,handler:c,headers:o,handlerName:a,protocol:i});this.routes.push(h)}async resolve(t){let r=new qs(t);try{return await _s.recurseRoutes(r,this.routes),new Response(r.body,{status:r.status,headers:r.response.headers})}catch(s){return new Response(s.message,{status:500})}}}});var $=S((ti,Xt)=>{var Ps="Expected a function",Dt="__lodash_hash_undefined__",Lt=1/0,Us="[object Function]",ks="[object GeneratorFunction]",Ns="[object Symbol]",Rs=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,$s=/^\w*$/,Hs=/^\./,Fs=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ms=/[\\^$.*+?()[\]{}|]/g,js=/\\(\\)?/g,Is=/^\[object .+?Constructor\]$/,Ks=typeof global=="object"&&global&&global.Object===Object&&global,Ds=typeof self=="object"&&self&&self.Object===Object&&self,He=Ks||Ds||Function("return this")();function Ls(e,t){return e?.[t]}function Gs(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var Bs=Array.prototype,zs=Function.prototype,Gt=Object.prototype,$e=He["__core-js_shared__"],Mt=function(){var e=/[^.]+$/.exec($e&&$e.keys&&$e.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Bt=zs.toString,Fe=Gt.hasOwnProperty,zt=Gt.toString,Vs=RegExp("^"+Bt.call(Fe).replace(Ms,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),jt=He.Symbol,Ws=Bs.splice,Js=Vt(He,"Map"),se=Vt(Object,"create"),It=jt?jt.prototype:void 0,Kt=It?It.toString:void 0;function K(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var s=e[t];this.set(s[0],s[1])}}function Xs(){this.__data__=se?se(null):{}}function xs(e){return this.has(e)&&delete this.__data__[e]}function Ys(e){var t=this.__data__;if(se){var r=t[e];return r===Dt?void 0:r}return Fe.call(t,e)?t[e]:void 0}function Zs(e){var t=this.__data__;return se?t[e]!==void 0:Fe.call(t,e)}function Qs(e,t){var r=this.__data__;return r[e]=se&&t===void 0?Dt:t,this}K.prototype.clear=Xs;K.prototype.delete=xs;K.prototype.get=Ys;K.prototype.has=Zs;K.prototype.set=Qs;function X(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var s=e[t];this.set(s[0],s[1])}}function en(){this.__data__=[]}function tn(e){var t=this.__data__,r=fe(t,e);if(r<0)return!1;var s=t.length-1;return r==s?t.pop():Ws.call(t,r,1),!0}function rn(e){var t=this.__data__,r=fe(t,e);return r<0?void 0:t[r][1]}function sn(e){return fe(this.__data__,e)>-1}function nn(e,t){var r=this.__data__,s=fe(r,e);return s<0?r.push([e,t]):r[s][1]=t,this}X.prototype.clear=en;X.prototype.delete=tn;X.prototype.get=rn;X.prototype.has=sn;X.prototype.set=nn;function D(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var s=e[t];this.set(s[0],s[1])}}function an(){this.__data__={hash:new K,map:new(Js||X),string:new K}}function on(e){return pe(this,e).delete(e)}function cn(e){return pe(this,e).get(e)}function un(e){return pe(this,e).has(e)}function hn(e,t){return pe(this,e).set(e,t),this}D.prototype.clear=an;D.prototype.delete=on;D.prototype.get=cn;D.prototype.has=un;D.prototype.set=hn;function fe(e,t){for(var r=e.length;r--;)if(bn(e[r][0],t))return r;return-1}function ln(e,t){t=mn(t,e)?[t]:pn(t);for(var r=0,s=t.length;e!=null&&r<s;)e=e[wn(t[r++])];return r&&r==s?e:void 0}function dn(e){if(!Jt(e)||yn(e))return!1;var t=vn(e)||Gs(e)?Vs:Is;return t.test(Sn(e))}function fn(e){if(typeof e=="string")return e;if(je(e))return Kt?Kt.call(e):"";var t=e+"";return t=="0"&&1/e==-Lt?"-0":t}function pn(e){return Wt(e)?e:An(e)}function pe(e,t){var r=e.__data__;return gn(t)?r[typeof t=="string"?"string":"hash"]:r.map}function Vt(e,t){var r=Ls(e,t);return dn(r)?r:void 0}function mn(e,t){if(Wt(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||je(e)?!0:$s.test(e)||!Rs.test(e)||t!=null&&e in Object(t)}function gn(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function yn(e){return!!Mt&&Mt in e}var An=Me(function(e){e=En(e);var t=[];return Hs.test(e)&&t.push(""),e.replace(Fs,function(r,s,n,a){t.push(n?a.replace(js,"$1"):s||r)}),t});function wn(e){if(typeof e=="string"||je(e))return e;var t=e+"";return t=="0"&&1/e==-Lt?"-0":t}function Sn(e){if(e!=null){try{return Bt.call(e)}catch{}try{return e+""}catch{}}return""}function Me(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(Ps);var r=function(){var s=arguments,n=t?t.apply(this,s):s[0],a=r.cache;if(a.has(n))return a.get(n);var o=e.apply(this,s);return r.cache=a.set(n,o),o};return r.cache=new(Me.Cache||D),r}Me.Cache=D;function bn(e,t){return e===t||e!==e&&t!==t}var Wt=Array.isArray;function vn(e){var t=Jt(e)?zt.call(e):"";return t==Us||t==ks}function Jt(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function Cn(e){return!!e&&typeof e=="object"}function je(e){return typeof e=="symbol"||Cn(e)&&zt.call(e)==Ns}function En(e){return e==null?"":fn(e)}function Tn(e,t,r){var s=e==null?void 0:ln(e,t);return s===void 0?r:s}Xt.exports=Tn});var ge=S((me,tr)=>{(function(e,t){typeof me=="object"&&typeof tr<"u"?t(me):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.aws4fetch={}))})(me,function(e){"use strict";let t=new TextEncoder,r={appstream2:"appstream",cloudhsmv2:"cloudhsm",email:"ses",marketplace:"aws-marketplace",mobile:"AWSMobileHubService",pinpoint:"mobiletargeting",queue:"sqs","git-codecommit":"codecommit","mturk-requester-sandbox":"mturk-requester","personalize-runtime":"personalize"},s=["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id","range","connection"];class n{constructor({accessKeyId:l,secretAccessKey:m,sessionToken:y,service:A,region:p,cache:g,retries:T,initRetryMs:P}){if(l==null)throw new TypeError("accessKeyId is a required option");if(m==null)throw new TypeError("secretAccessKey is a required option");this.accessKeyId=l,this.secretAccessKey=m,this.sessionToken=y,this.service=A,this.region=p,this.cache=g||new Map,this.retries=T??10,this.initRetryMs=P||50}async sign(l,m){if(l instanceof Request){let{method:p,url:g,headers:T,body:P}=l;m=Object.assign({method:p,url:g,headers:T},m),m.body==null&&T.has("Content-Type")&&(m.body=P!=null&&T.has("X-Amz-Content-Sha256")?P:await l.clone().arrayBuffer()),l=g}let y=new a(Object.assign({url:l},m,this,m&&m.aws)),A=Object.assign({},m,await y.sign());return delete A.aws,new Request(A.url.toString(),A)}async fetch(l,m){for(let y=0;y<=this.retries;y++){let A=fetch(await this.sign(l,m));if(y===this.retries)return A;let p=await A;if(p.status<500&&p.status!==429)return p;await new Promise(g=>setTimeout(g,Math.random()*this.initRetryMs*Math.pow(2,y)))}throw new Error("An unknown error occurred, ensure retries is not negative")}}class a{constructor({method:l,url:m,headers:y,body:A,accessKeyId:p,secretAccessKey:g,sessionToken:T,service:P,region:_,cache:j,datetime:Z,signQuery:_e,appendSessionToken:qe,allHeaders:he,singleEncode:Pe}){if(m==null)throw new TypeError("url is a required option");if(p==null)throw new TypeError("accessKeyId is a required option");if(g==null)throw new TypeError("secretAccessKey is a required option");this.method=l||(A?"POST":"GET"),this.url=new URL(m),this.headers=new Headers(y||{}),this.body=A,this.accessKeyId=p,this.secretAccessKey=g,this.sessionToken=T;let F,Q;(!P||!_)&&([F,Q]=f(this.url,this.headers)),this.service=P||F||"",this.region=_||Q||"us-east-1",this.cache=j||new Map,this.datetime=Z||new Date().toISOString().replace(/[:-]|\.\d{3}/g,""),this.signQuery=_e,this.appendSessionToken=qe||this.service==="iotdevicegateway",this.headers.delete("Host");let k=this.signQuery?this.url.searchParams:this.headers;if(this.service==="s3"&&!this.headers.has("X-Amz-Content-Sha256")&&this.headers.set("X-Amz-Content-Sha256","UNSIGNED-PAYLOAD"),k.set("X-Amz-Date",this.datetime),this.sessionToken&&!this.appendSessionToken&&k.set("X-Amz-Security-Token",this.sessionToken),this.signableHeaders=["host",...this.headers.keys()].filter(w=>he||!s.includes(w)).sort(),this.signedHeaders=this.signableHeaders.join(";"),this.canonicalHeaders=this.signableHeaders.map(w=>w+":"+(w==="host"?this.url.host:(this.headers.get(w)||"").replace(/\s+/g," "))).join(`
|
|
2
|
-
`),this.credentialString=[this.datetime.slice(0,8),this.region,this.service,"aws4_request"].join("/"),this.signQuery&&(this.service==="s3"&&!
|
|
1
|
+
"use strict";var hi=Object.create;var Qt=Object.defineProperty;var fi=Object.getOwnPropertyDescriptor;var li=Object.getOwnPropertyNames;var pi=Object.getPrototypeOf,di=Object.prototype.hasOwnProperty;var E=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var yi=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of li(e))!di.call(t,i)&&i!==r&&Qt(t,i,{get:()=>e[i],enumerable:!(n=fi(e,i))||n.enumerable});return t};var C=(t,e,r)=>(r=t!=null?hi(pi(t)):{},yi(e||!t||!t.__esModule?Qt(r,"default",{value:t,enumerable:!0}):r,t));var Je=E((Tu,tr)=>{function mi({host:t=".*",path:e=".*",excludePath:r=null,method:n=[".*"],handler:i,protocol:s=".*",handlerName:o,headers:a={},data:u}){let h=[],l=[],f=t.replace(/(:([^.]+))/g,(x,O,_)=>(h.push(_),"([^.]+)")),d=e.replace(/(:([^/]+))/g,(x,O,_)=>_.slice(-1)==="*"?(l.push(_.slice(0,_.length-1)),"(.*)"):(l.push(_),"([^/]*)")),y=new RegExp(`^${f}$`,"i"),g=new RegExp(`^${d}$`,"i"),A=r?new RegExp(`^${r}$`,"i"):null,m=new RegExp(`^${n.join("|")}$`,"i"),w=new RegExp(`^${s}$`,"i");return{hostVariables:h,pathVariables:l,host:y,path:g,excludePath:A,method:m,protocol:w,handler:i,handlerName:o,headers:a,data:u}}function er(t){return[...t].reduce((e,r)=>{let n={};return n[r[0]]=r[1],{...e,...n}},{})}async function gi(t,e=1024*1024){let r=[],n=t.getReader(),i=new TextDecoder,s=0;for(;e&&s<e;){let{done:a,value:u}=await n.read();if(a)break;s+=u.byteLength,r.push(i.decode(u))}let o=r.join("");return e?o.substring(0,e):o}function wi(t){let e=new URL(t.url),r=er(e.searchParams),n=er(t.headers);n.host&&(e.hostname=n.host);let i,s;async function o(a){if(s>=a)return i.substring(0,a);let u=t.clone();return i=await gi(u.body,a),i}return{body:t.body,headers:n,host:e.host,hostname:e.hostname,href:e.href,json:async a=>JSON.parse(o(a)),method:t.method,origin:`${e.protocol}//${e.host}`,path:e.pathname,protocol:e.protocol.slice(0,-1),query:r,querystring:e.search.slice(1),search:e.search,text:async a=>t.headers.get("content-type")==="application/x-www-form-urlencoded"?decodeURIComponent(await o(a)):o(a)}}tr.exports={parseRoute:mi,parseRequest:wi}});var nr=E((Bu,rr)=>{function Ai(t,e){let r={},n=e.host.exec(t.host);e.hostVariables.forEach((s,o)=>{r[s]=n[o+1]});let i=e.path.exec(t.path);return e.pathVariables.forEach((s,o)=>{r[s]=i[o+1]}),r}function Ei(t,e){let r=!0;return Object.keys(t.headers).forEach(n=>{e.headers[n]!==t.headers[n]&&(r=!1)}),r}function Si(t,e){return t.protocol.test(e.protocol)}function bi(t,e){return t.method.test(e.method)&&t.host.test(e.host)&&t.path.test(e.path)&&Ei(t,e)&&Si(t,e)&&(!t.excludePath||!t.excludePath.test(e.path))}async function Ye(t,e){let[r,...n]=e;if(!r)return new Response("NOT_FOUND",{status:404});if(!bi(r,t.request))return Ye(t,n);t.state.handlers=t.state.handlers||[],t.state.handlers.push(r.handlerName||r.handler.name),t.params=Ai(t.request,r);try{return r.handler(t,async i=>Ye(i,n))}catch(i){throw i.route=r.handler.name,i}}rr.exports={recurseRoutes:Ye}});var sr=E((Iu,ir)=>{ir.exports={methods:{DELETE:"DELETE",GET:"GET",HEAD:"HEAD",OPTIONS:"OPTIONS",PATCH:"PATCH",POST:"POST"},statusMessages:{404:"Not found",429:"Rate limited"}}});var ur=E((xu,ar)=>{var Ci=Je();ar.exports=class or{constructor(e){this.request=Ci.parseRequest(e.request),this.event=e,this.state={},this.cloned=!1,this.response={headers:{}},this.body="",this.status=404,this.query=this.request.query}header(e){return this.request.headers[e]}set(e,r){this.response.headers[e]=r}clone(){let e=new or(this.event);return e.cloned=!0,e}}});var hr=E((Fu,cr)=>{var ie=Je(),Ti=nr(),me=sr(),Bi=ur();cr.exports=class{constructor(){this.routes=[]}get(e,r){let n=ie.parseRoute({method:[me.methods.GET,me.methods.HEAD],path:e,handler:r});this.routes.push(n)}post(e,r){let n=ie.parseRoute({method:[me.methods.POST],path:e,handler:r});this.routes.push(n)}patch(e,r){let n=ie.parseRoute({method:[me.methods.PATCH],path:e,handler:r});this.routes.push(n)}del(e,r){let n=ie.parseRoute({method:[me.methods.DELETE],path:e,handler:r});this.routes.push(n)}use(e){let r=ie.parseRoute({handler:e,middleware:!0});this.routes.push(r)}add({host:e,path:r,excludePath:n,method:i,handlerName:s,headers:o,protocol:a},u){let h=ie.parseRoute({method:i,host:e,path:r,excludePath:n,handler:u,headers:o,handlerName:s,protocol:a});this.routes.push(h)}async resolve(e){let r=new Bi(e);try{return await Ti.recurseRoutes(r,this.routes),new Response(r.body,{status:r.status,headers:r.response.headers})}catch(n){return new Response(n.message,{status:500})}}}});var H=E((_u,Cr)=>{var Ii="Expected a function",yr="__lodash_hash_undefined__",mr=1/0,xi="[object Function]",Ui="[object GeneratorFunction]",Fi="[object Symbol]",_i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ri=/^\w*$/,Oi=/^\./,ki=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ni=/[\\^$.*+?()[\]{}|]/g,Pi=/\\(\\)?/g,$i=/^\[object .+?Constructor\]$/,vi=typeof global=="object"&&global&&global.Object===Object&&global,qi=typeof self=="object"&&self&&self.Object===Object&&self,Qe=vi||qi||Function("return this")();function Mi(t,e){return t?.[e]}function Hi(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch{}return e}var Di=Array.prototype,Li=Function.prototype,gr=Object.prototype,Ze=Qe["__core-js_shared__"],fr=function(){var t=/[^.]+$/.exec(Ze&&Ze.keys&&Ze.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),wr=Li.toString,et=gr.hasOwnProperty,Ar=gr.toString,ji=RegExp("^"+wr.call(et).replace(Ni,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),lr=Qe.Symbol,Ki=Di.splice,Gi=Er(Qe,"Map"),ge=Er(Object,"create"),pr=lr?lr.prototype:void 0,dr=pr?pr.toString:void 0;function V(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function zi(){this.__data__=ge?ge(null):{}}function Wi(t){return this.has(t)&&delete this.__data__[t]}function Vi(t){var e=this.__data__;if(ge){var r=e[t];return r===yr?void 0:r}return et.call(e,t)?e[t]:void 0}function Xi(t){var e=this.__data__;return ge?e[t]!==void 0:et.call(e,t)}function Ji(t,e){var r=this.__data__;return r[t]=ge&&e===void 0?yr:e,this}V.prototype.clear=zi;V.prototype.delete=Wi;V.prototype.get=Vi;V.prototype.has=Xi;V.prototype.set=Ji;function se(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Yi(){this.__data__=[]}function Zi(t){var e=this.__data__,r=Ue(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():Ki.call(e,r,1),!0}function Qi(t){var e=this.__data__,r=Ue(e,t);return r<0?void 0:e[r][1]}function es(t){return Ue(this.__data__,t)>-1}function ts(t,e){var r=this.__data__,n=Ue(r,t);return n<0?r.push([t,e]):r[n][1]=e,this}se.prototype.clear=Yi;se.prototype.delete=Zi;se.prototype.get=Qi;se.prototype.has=es;se.prototype.set=ts;function X(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function rs(){this.__data__={hash:new V,map:new(Gi||se),string:new V}}function ns(t){return Fe(this,t).delete(t)}function is(t){return Fe(this,t).get(t)}function ss(t){return Fe(this,t).has(t)}function os(t,e){return Fe(this,t).set(t,e),this}X.prototype.clear=rs;X.prototype.delete=ns;X.prototype.get=is;X.prototype.has=ss;X.prototype.set=os;function Ue(t,e){for(var r=t.length;r--;)if(gs(t[r][0],e))return r;return-1}function as(t,e){e=fs(e,t)?[e]:hs(e);for(var r=0,n=e.length;t!=null&&r<n;)t=t[ys(e[r++])];return r&&r==n?t:void 0}function us(t){if(!br(t)||ps(t))return!1;var e=ws(t)||Hi(t)?ji:$i;return e.test(ms(t))}function cs(t){if(typeof t=="string")return t;if(rt(t))return dr?dr.call(t):"";var e=t+"";return e=="0"&&1/t==-mr?"-0":e}function hs(t){return Sr(t)?t:ds(t)}function Fe(t,e){var r=t.__data__;return ls(e)?r[typeof e=="string"?"string":"hash"]:r.map}function Er(t,e){var r=Mi(t,e);return us(r)?r:void 0}function fs(t,e){if(Sr(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||rt(t)?!0:Ri.test(t)||!_i.test(t)||e!=null&&t in Object(e)}function ls(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function ps(t){return!!fr&&fr in t}var ds=tt(function(t){t=Es(t);var e=[];return Oi.test(t)&&e.push(""),t.replace(ki,function(r,n,i,s){e.push(i?s.replace(Pi,"$1"):n||r)}),e});function ys(t){if(typeof t=="string"||rt(t))return t;var e=t+"";return e=="0"&&1/t==-mr?"-0":e}function ms(t){if(t!=null){try{return wr.call(t)}catch{}try{return t+""}catch{}}return""}function tt(t,e){if(typeof t!="function"||e&&typeof e!="function")throw new TypeError(Ii);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],s=r.cache;if(s.has(i))return s.get(i);var o=t.apply(this,n);return r.cache=s.set(i,o),o};return r.cache=new(tt.Cache||X),r}tt.Cache=X;function gs(t,e){return t===e||t!==t&&e!==e}var Sr=Array.isArray;function ws(t){var e=br(t)?Ar.call(t):"";return e==xi||e==Ui}function br(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function As(t){return!!t&&typeof t=="object"}function rt(t){return typeof t=="symbol"||As(t)&&Ar.call(t)==Fi}function Es(t){return t==null?"":cs(t)}function Ss(t,e,r){var n=t==null?void 0:as(t,e);return n===void 0?r:n}Cr.exports=Ss});var Re=E((_e,Fr)=>{(function(t,e){typeof _e=="object"&&typeof Fr<"u"?e(_e):typeof define=="function"&&define.amd?define(["exports"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t.aws4fetch={}))})(_e,function(t){"use strict";let e=new TextEncoder,r={appstream2:"appstream",cloudhsmv2:"cloudhsm",email:"ses",marketplace:"aws-marketplace",mobile:"AWSMobileHubService",pinpoint:"mobiletargeting",queue:"sqs","git-codecommit":"codecommit","mturk-requester-sandbox":"mturk-requester","personalize-runtime":"personalize"},n=["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id","range","connection"];class i{constructor({accessKeyId:d,secretAccessKey:y,sessionToken:g,service:A,region:m,cache:w,retries:x,initRetryMs:O}){if(d==null)throw new TypeError("accessKeyId is a required option");if(y==null)throw new TypeError("secretAccessKey is a required option");this.accessKeyId=d,this.secretAccessKey=y,this.sessionToken=g,this.service=A,this.region=m,this.cache=w||new Map,this.retries=x??10,this.initRetryMs=O||50}async sign(d,y){if(d instanceof Request){let{method:m,url:w,headers:x,body:O}=d;y=Object.assign({method:m,url:w,headers:x},y),y.body==null&&x.has("Content-Type")&&(y.body=O!=null&&x.has("X-Amz-Content-Sha256")?O:await d.clone().arrayBuffer()),d=w}let g=new s(Object.assign({url:d},y,this,y&&y.aws)),A=Object.assign({},y,await g.sign());return delete A.aws,new Request(A.url.toString(),A)}async fetch(d,y){for(let g=0;g<=this.retries;g++){let A=fetch(await this.sign(d,y));if(g===this.retries)return A;let m=await A;if(m.status<500&&m.status!==429)return m;await new Promise(w=>setTimeout(w,Math.random()*this.initRetryMs*Math.pow(2,g)))}throw new Error("An unknown error occurred, ensure retries is not negative")}}class s{constructor({method:d,url:y,headers:g,body:A,accessKeyId:m,secretAccessKey:w,sessionToken:x,service:O,region:_,cache:z,datetime:le,signQuery:Ge,appendSessionToken:ze,allHeaders:Be,singleEncode:We}){if(y==null)throw new TypeError("url is a required option");if(m==null)throw new TypeError("accessKeyId is a required option");if(w==null)throw new TypeError("secretAccessKey is a required option");this.method=d||(A?"POST":"GET"),this.url=new URL(y),this.headers=new Headers(g||{}),this.body=A,this.accessKeyId=m,this.secretAccessKey=w,this.sessionToken=x;let j,pe;(!O||!_)&&([j,pe]=l(this.url,this.headers)),this.service=O||j||"",this.region=_||pe||"us-east-1",this.cache=z||new Map,this.datetime=le||new Date().toISOString().replace(/[:-]|\.\d{3}/g,""),this.signQuery=Ge,this.appendSessionToken=ze||this.service==="iotdevicegateway",this.headers.delete("Host");let P=this.signQuery?this.url.searchParams:this.headers;if(this.service==="s3"&&!this.headers.has("X-Amz-Content-Sha256")&&this.headers.set("X-Amz-Content-Sha256","UNSIGNED-PAYLOAD"),P.set("X-Amz-Date",this.datetime),this.sessionToken&&!this.appendSessionToken&&P.set("X-Amz-Security-Token",this.sessionToken),this.signableHeaders=["host",...this.headers.keys()].filter(S=>Be||!n.includes(S)).sort(),this.signedHeaders=this.signableHeaders.join(";"),this.canonicalHeaders=this.signableHeaders.map(S=>S+":"+(S==="host"?this.url.host:(this.headers.get(S)||"").replace(/\s+/g," "))).join(`
|
|
2
|
+
`),this.credentialString=[this.datetime.slice(0,8),this.region,this.service,"aws4_request"].join("/"),this.signQuery&&(this.service==="s3"&&!P.has("X-Amz-Expires")&&P.set("X-Amz-Expires","86400"),P.set("X-Amz-Algorithm","AWS4-HMAC-SHA256"),P.set("X-Amz-Credential",this.accessKeyId+"/"+this.credentialString),P.set("X-Amz-SignedHeaders",this.signedHeaders)),this.service==="s3")try{this.encodedPath=decodeURIComponent(this.url.pathname.replace(/\+/g," "))}catch{this.encodedPath=this.url.pathname}else this.encodedPath=this.url.pathname.replace(/\/+/g,"/");We||(this.encodedPath=encodeURIComponent(this.encodedPath).replace(/%2F/g,"/")),this.encodedPath=h(this.encodedPath);let Ie=new Set;this.encodedSearch=[...this.url.searchParams].filter(([S])=>{if(!S)return!1;if(this.service==="s3"){if(Ie.has(S))return!1;Ie.add(S)}return!0}).map(S=>S.map(de=>h(encodeURIComponent(de)))).sort(([S,de],[ye,xe])=>S<ye?-1:S>ye?1:de<xe?-1:de>xe?1:0).map(S=>S.join("=")).join("&")}async sign(){return this.signQuery?(this.url.searchParams.set("X-Amz-Signature",await this.signature()),this.sessionToken&&this.appendSessionToken&&this.url.searchParams.set("X-Amz-Security-Token",this.sessionToken)):this.headers.set("Authorization",await this.authHeader()),{method:this.method,url:this.url,headers:this.headers,body:this.body}}async authHeader(){return["AWS4-HMAC-SHA256 Credential="+this.accessKeyId+"/"+this.credentialString,"SignedHeaders="+this.signedHeaders,"Signature="+await this.signature()].join(", ")}async signature(){let d=this.datetime.slice(0,8),y=[this.secretAccessKey,d,this.region,this.service].join(),g=this.cache.get(y);if(!g){let A=await o("AWS4"+this.secretAccessKey,d),m=await o(A,this.region),w=await o(m,this.service);g=await o(w,"aws4_request"),this.cache.set(y,g)}return u(await o(g,await this.stringToSign()))}async stringToSign(){return["AWS4-HMAC-SHA256",this.datetime,this.credentialString,u(await a(await this.canonicalString()))].join(`
|
|
3
3
|
`)}async canonicalString(){return[this.method.toUpperCase(),this.encodedPath,this.encodedSearch,this.canonicalHeaders+`
|
|
4
4
|
`,this.signedHeaders,await this.hexBodyHash()].join(`
|
|
5
|
-
`)}async hexBodyHash(){let l=this.headers.get("X-Amz-Content-Sha256");if(l==null){if(this.body&&typeof this.body!="string"&&!("byteLength"in this.body))throw new Error("body must be a string, ArrayBuffer or ArrayBufferView, unless you include the X-Amz-Content-Sha256 header");l=c(await i(this.body||""))}return l}}async function o(d,l){let m=await crypto.subtle.importKey("raw",typeof d=="string"?t.encode(d):d,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return crypto.subtle.sign("HMAC",m,t.encode(l))}async function i(d){return crypto.subtle.digest("SHA-256",typeof d=="string"?t.encode(d):d)}function c(d){return Array.prototype.map.call(new Uint8Array(d),l=>("0"+l.toString(16)).slice(-2)).join("")}function h(d){return d.replace(/[!'()*]/g,l=>"%"+l.charCodeAt(0).toString(16).toUpperCase())}function f(d,l){let{hostname:m,pathname:y}=d,A=m.replace("dualstack.","").match(/([^.]+)\.(?:([^.]*)\.)?amazonaws\.com(?:\.cn)?$/),[p,g]=(A||["",""]).slice(1,3);if(g==="us-gov")g="us-gov-west-1";else if(g==="s3"||g==="s3-accelerate")g="us-east-1",p="s3";else if(p==="iot")m.startsWith("iot.")?p="execute-api":m.startsWith("data.jobs.iot.")?p="iot-jobs-data":p=y==="/mqtt"?"iotdevicegateway":"iotdata";else if(p==="autoscaling"){let T=(l.get("X-Amz-Target")||"").split(".")[0];T==="AnyScaleFrontendService"?p="application-autoscaling":T==="AnyScaleScalingPlannerFrontendService"&&(p="autoscaling-plans")}else g==null&&p.startsWith("s3-")?(g=p.slice(3).replace(/^fips-|^external-1/,""),p="s3"):p.endsWith("-fips")?p=p.slice(0,-5):g&&/-\d$/.test(p)&&!/-\d$/.test(g)&&([p,g]=[g,p]);return[r[p]||p,g]}e.AwsClient=n,e.AwsV4Signer=a,Object.defineProperty(e,"__esModule",{value:!0})})});var be=S((Ei,mr)=>{var Vn="Expected a function",ir="__lodash_hash_undefined__",cr=1/0,Wn=9007199254740991,Jn="[object Function]",Xn="[object GeneratorFunction]",xn="[object Symbol]",Yn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Zn=/^\w*$/,Qn=/^\./,ea=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ta=/[\\^$.*+?()[\]{}|]/g,ra=/\\(\\)?/g,sa=/^\[object .+?Constructor\]$/,na=/^(?:0|[1-9]\d*)$/,aa=typeof global=="object"&&global&&global.Object===Object&&global,oa=typeof self=="object"&&self&&self.Object===Object&&self,Ze=aa||oa||Function("return this")();function ia(e,t){return e?.[t]}function ca(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var ua=Array.prototype,ha=Function.prototype,ur=Object.prototype,Ye=Ze["__core-js_shared__"],sr=function(){var e=/[^.]+$/.exec(Ye&&Ye.keys&&Ye.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),hr=ha.toString,Ae=ur.hasOwnProperty,lr=ur.toString,la=RegExp("^"+hr.call(Ae).replace(ta,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),nr=Ze.Symbol,da=ua.splice,fa=dr(Ze,"Map"),ne=dr(Object,"create"),ar=nr?nr.prototype:void 0,or=ar?ar.toString:void 0;function G(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var s=e[t];this.set(s[0],s[1])}}function pa(){this.__data__=ne?ne(null):{}}function ma(e){return this.has(e)&&delete this.__data__[e]}function ga(e){var t=this.__data__;if(ne){var r=t[e];return r===ir?void 0:r}return Ae.call(t,e)?t[e]:void 0}function ya(e){var t=this.__data__;return ne?t[e]!==void 0:Ae.call(t,e)}function Aa(e,t){var r=this.__data__;return r[e]=ne&&t===void 0?ir:t,this}G.prototype.clear=pa;G.prototype.delete=ma;G.prototype.get=ga;G.prototype.has=ya;G.prototype.set=Aa;function x(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var s=e[t];this.set(s[0],s[1])}}function wa(){this.__data__=[]}function Sa(e){var t=this.__data__,r=we(t,e);if(r<0)return!1;var s=t.length-1;return r==s?t.pop():da.call(t,r,1),!0}function ba(e){var t=this.__data__,r=we(t,e);return r<0?void 0:t[r][1]}function va(e){return we(this.__data__,e)>-1}function Ca(e,t){var r=this.__data__,s=we(r,e);return s<0?r.push([e,t]):r[s][1]=t,this}x.prototype.clear=wa;x.prototype.delete=Sa;x.prototype.get=ba;x.prototype.has=va;x.prototype.set=Ca;function B(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var s=e[t];this.set(s[0],s[1])}}function Ea(){this.__data__={hash:new G,map:new(fa||x),string:new G}}function Ta(e){return Se(this,e).delete(e)}function Oa(e){return Se(this,e).get(e)}function _a(e){return Se(this,e).has(e)}function qa(e,t){return Se(this,e).set(e,t),this}B.prototype.clear=Ea;B.prototype.delete=Ta;B.prototype.get=Oa;B.prototype.has=_a;B.prototype.set=qa;function Pa(e,t,r){var s=e[t];(!(Ae.call(e,t)&&fr(s,r))||r===void 0&&!(t in e))&&(e[t]=r)}function we(e,t){for(var r=e.length;r--;)if(fr(e[r][0],t))return r;return-1}function Ua(e){if(!ye(e)||Ma(e))return!1;var t=Da(e)||ca(e)?la:sa;return t.test(Ka(e))}function ka(e,t,r,s){if(!ye(e))return e;t=Ha(t,e)?[t]:Ra(t);for(var n=-1,a=t.length,o=a-1,i=e;i!=null&&++n<a;){var c=Ia(t[n]),h=r;if(n!=o){var f=i[c];h=s?s(f,c,i):void 0,h===void 0&&(h=ye(f)?f:$a(t[n+1])?[]:{})}Pa(i,c,h),i=i[c]}return e}function Na(e){if(typeof e=="string")return e;if(et(e))return or?or.call(e):"";var t=e+"";return t=="0"&&1/e==-cr?"-0":t}function Ra(e){return pr(e)?e:ja(e)}function Se(e,t){var r=e.__data__;return Fa(t)?r[typeof t=="string"?"string":"hash"]:r.map}function dr(e,t){var r=ia(e,t);return Ua(r)?r:void 0}function $a(e,t){return t=t??Wn,!!t&&(typeof e=="number"||na.test(e))&&e>-1&&e%1==0&&e<t}function Ha(e,t){if(pr(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||et(e)?!0:Zn.test(e)||!Yn.test(e)||t!=null&&e in Object(t)}function Fa(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Ma(e){return!!sr&&sr in e}var ja=Qe(function(e){e=Ga(e);var t=[];return Qn.test(e)&&t.push(""),e.replace(ea,function(r,s,n,a){t.push(n?a.replace(ra,"$1"):s||r)}),t});function Ia(e){if(typeof e=="string"||et(e))return e;var t=e+"";return t=="0"&&1/e==-cr?"-0":t}function Ka(e){if(e!=null){try{return hr.call(e)}catch{}try{return e+""}catch{}}return""}function Qe(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(Vn);var r=function(){var s=arguments,n=t?t.apply(this,s):s[0],a=r.cache;if(a.has(n))return a.get(n);var o=e.apply(this,s);return r.cache=a.set(n,o),o};return r.cache=new(Qe.Cache||B),r}Qe.Cache=B;function fr(e,t){return e===t||e!==e&&t!==t}var pr=Array.isArray;function Da(e){var t=ye(e)?lr.call(e):"";return t==Jn||t==Xn}function ye(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function La(e){return!!e&&typeof e=="object"}function et(e){return typeof e=="symbol"||La(e)&&lr.call(e)==xn}function Ga(e){return e==null?"":Na(e)}function Ba(e,t,r){return e==null?e:ka(e,t,r)}mr.exports=Ba});var vr=S(nt=>{"use strict";nt.parse=Za;nt.serialize=Qa;var Xa=decodeURIComponent,xa=encodeURIComponent,Ya=/; */,Ce=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function Za(e,t){if(typeof e!="string")throw new TypeError("argument str must be a string");for(var r={},s=t||{},n=e.split(Ya),a=s.decode||Xa,o=0;o<n.length;o++){var i=n[o],c=i.indexOf("=");if(!(c<0)){var h=i.substr(0,c).trim(),f=i.substr(++c,i.length).trim();f[0]=='"'&&(f=f.slice(1,-1)),r[h]==null&&(r[h]=eo(f,a))}}return r}function Qa(e,t,r){var s=r||{},n=s.encode||xa;if(typeof n!="function")throw new TypeError("option encode is invalid");if(!Ce.test(e))throw new TypeError("argument name is invalid");var a=n(t);if(a&&!Ce.test(a))throw new TypeError("argument val is invalid");var o=e+"="+a;if(s.maxAge!=null){var i=s.maxAge-0;if(isNaN(i)||!isFinite(i))throw new TypeError("option maxAge is invalid");o+="; Max-Age="+Math.floor(i)}if(s.domain){if(!Ce.test(s.domain))throw new TypeError("option domain is invalid");o+="; Domain="+s.domain}if(s.path){if(!Ce.test(s.path))throw new TypeError("option path is invalid");o+="; Path="+s.path}if(s.expires){if(typeof s.expires.toUTCString!="function")throw new TypeError("option expires is invalid");o+="; Expires="+s.expires.toUTCString()}if(s.httpOnly&&(o+="; HttpOnly"),s.secure&&(o+="; Secure"),s.sameSite){var c=typeof s.sameSite=="string"?s.sameSite.toLowerCase():s.sameSite;switch(c){case!0:o+="; SameSite=Strict";break;case"lax":o+="; SameSite=Lax";break;case"strict":o+="; SameSite=Strict";break;case"none":o+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return o}function eo(e,t){try{return t(e)}catch{return e}}});var Er=S((Li,Cr)=>{"use strict";var Ee=1;function to(){return Ee=(Ee*9301+49297)%233280,Ee/233280}function ro(e){Ee=e}Cr.exports={nextValue:to,seed:ro}});var ce=S((Gi,qr)=>{"use strict";var at=Er(),V="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-",M,Tr,ie;function ot(){ie=!1}function Or(e){if(!e){M!==V&&(M=V,ot());return}if(e!==M){if(e.length!==V.length)throw new Error("Custom alphabet for shortid must be "+V.length+" unique characters. You submitted "+e.length+" characters: "+e);var t=e.split("").filter(function(r,s,n){return s!==n.lastIndexOf(r)});if(t.length)throw new Error("Custom alphabet for shortid must be "+V.length+" unique characters. These characters were not unique: "+t.join(", "));M=e,ot()}}function so(e){return Or(e),M}function no(e){at.seed(e),Tr!==e&&(ot(),Tr=e)}function ao(){M||Or(V);for(var e=M.split(""),t=[],r=at.nextValue(),s;e.length>0;)r=at.nextValue(),s=Math.floor(r*e.length),t.push(e.splice(s,1)[0]);return t.join("")}function _r(){return ie||(ie=ao(),ie)}function oo(e){var t=_r();return t[e]}function io(){return M||V}qr.exports={get:io,characters:so,seed:no,lookup:oo,shuffled:_r}});var Ur=S((Bi,Pr)=>{"use strict";var it=typeof window=="object"&&(window.crypto||window.msCrypto),ct;!it||!it.getRandomValues?ct=function(e){for(var t=[],r=0;r<e;r++)t.push(Math.floor(Math.random()*256));return t}:ct=function(e){return it.getRandomValues(new Uint8Array(e))};Pr.exports=ct});var Nr=S((zi,kr)=>{kr.exports=function(e,t,r){for(var s=(2<<Math.log(t.length-1)/Math.LN2)-1,n=-~(1.6*s*r/t.length),a="";;)for(var o=e(n),i=n;i--;)if(a+=t[o[i]&s]||"",a.length===+r)return a}});var $r=S((Vi,Rr)=>{"use strict";var co=ce(),uo=Ur(),ho=Nr();function lo(e){for(var t=0,r,s="";!r;)s=s+ho(uo,co.get(),1),r=e<Math.pow(16,t+1),t++;return s}Rr.exports=lo});var Mr=S((Ji,Fr)=>{"use strict";var Te=$r(),Wi=ce(),fo=1567752802062,po=7,Oe,Hr;function mo(e){var t="",r=Math.floor((Date.now()-fo)*.001);return r===Hr?Oe++:(Oe=0,Hr=r),t=t+Te(po),t=t+Te(e),Oe>0&&(t=t+Te(Oe)),t=t+Te(r),t}Fr.exports=mo});var Ir=S((Xi,jr)=>{"use strict";var go=ce();function yo(e){if(!e||typeof e!="string"||e.length<6)return!1;var t=new RegExp("[^"+go.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]");return!t.test(e)}jr.exports=yo});var Dr=S((xi,Kr)=>{"use strict";Kr.exports=0});var Br=S((Yi,H)=>{"use strict";var ut=ce(),Ao=Mr(),wo=Ir(),Lr=Dr()||0;function So(e){return ut.seed(e),H.exports}function bo(e){return Lr=e,H.exports}function vo(e){return e!==void 0&&ut.characters(e),ut.shuffled()}function Gr(){return Ao(Lr)}H.exports=Gr;H.exports.generate=Gr;H.exports.seed=So;H.exports.worker=bo;H.exports.characters=vo;H.exports.isValid=wo});var Vr=S((Zi,zr)=>{"use strict";zr.exports=Br()});var is=E(Ft());var xt=E($()),On={get:xt.default};function Ie(e){e.status=401,e.body="Unauthorized",e.set("WWW-Authenticate","Basic")}function Ke(e){return async(t,r)=>{if(t.request.path===e.logoutPath)return Ie(t);let s=On.get(t,"request.headers.authorization");if(!s||!s.startsWith("Basic "))return Ie(t);let n=e.users.map(i=>i.authToken),a=s.substring(6),o=n.indexOf(a);return o===-1?Ie(t):(t.state.user=e.users[o].username,r(t))}}var Yt=caches.default;async function _n(e){return await Yt.match(e)}async function qn(e,t){return Yt.put(e.href,t)}var De={get:_n,set:qn};async function Pn(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r)).map(a=>a.toString(16).padStart(2,"0")).join("")}var Zt=Pn;function Un(e,t={}){return Object.keys(t).reduce((r,s)=>r.replace(`{${s}}`,t[s]),e)}function Le(e){return[...e].reduce((t,r)=>{let s={};return s[r[0]]=r[1],{...t,...s}},{})}var v={resolveParams:Un,instanceToJson:Le};var kn=["x-ratelimit-count","x-ratelimit-limit","x-ratelimit-reset","x-cache-hit"];async function Nn(e){return["POST","PATCH"].indexOf(e.method)===-1?null:e.text()}async function Rn(e,t){if(!t)return e.event.request;let r=t.match(/{.*?}/gi).map(a=>a.slice(1,-1)),s={};for(let a=0;a<r.length;a+=1){let o=r[a],i=o.split(":");switch(i[0]){case"method":s[o]=e.request.method;break;case"path":s[o]=e.request.path;break;case"bodyHash":s[o]=await Zt(await Nn(e.request));break;case"header":s[o]=e.request.headers[i[1]]||"";break;default:s[o]=o}}let n=encodeURIComponent(t.replace(/({(.*?)})/gi,(a,o,i)=>s[i]));return new Request(`http://${e.request.hostname}/${n}`)}function Ge({cacheDuration:e,cacheKeyTemplate:t,headerBlacklist:r=kn}){return async(s,n)=>{let a=await Rn(s,t),o=await De.get(a);if(o){s.body=o.body,s.status=o.status;let i=Le(o.headers);Object.keys(i).forEach(c=>{s.set(c,i[c])}),s.set("X-Cache-Hit",!0)}else{await n(s);let i;s.body.tee?[s.body,i]=s.body.tee():i=s.body;let c=new Response(i,{status:s.status});Object.keys(s.response.headers).forEach(h=>{r.indexOf(h.toLowerCase())===-1&&c.headers.set(h,s.response.headers[h])}),e&&(c.headers.delete("Cache-Control"),c.headers.set("Cache-Control",`max-age=${e}`)),s.event.waitUntil(De.set(a,c))}}}function Be({allowedOrigins:e=["*"],allowedMethods:t=["GET","PUT","POST","PATCH","DELETE","HEAD","OPTIONS"],allowCredentials:r=!0,allowedHeaders:s=["Content-Type"],allowedExposeHeaders:n=["WWW-Authenticate","Server-Authorization"],maxAge:a=600,optionsSuccessStatus:o=204,terminatePreflight:i=!1}){return async(c,h)=>{let{method:f}=c.request,{origin:d}=c.request.headers,l=c.request.headers["access-control-request-headers"];if($n(c,d,e),Hn(c,r),In(c,n),f==="OPTIONS"&&(Fn(c,t),Mn(c,l,s),jn(c,a),i)){c.status=o,c.set("Content-Length","0"),c.body="";return}await h(c)}}function $n(e,t,r){Array.isArray(r)&&(r[0]==="*"?e.set("Access-Control-Allow-Origin","*"):r.indexOf(t)!==-1&&(e.set("Access-Control-Allow-Origin",t),e.set("Vary","Origin")))}function Hn(e,t){t&&e.set("Access-Control-Allow-Credentials",t)}function Fn(e,t){e.set("Access-Control-Allow-Methods",t.join(","))}function Mn(e,t,r){r.length===0&&t?e.set("Access-Control-Allow-Headers",t):r.length&&e.set("Access-Control-Allow-Headers",r.join(","))}function jn(e,t){t&&e.set("Access-Control-Max-Age",t)}function In(e,t){t.length&&e.set("Access-Control-Expose-Headers",t.join(","))}var Kn={AF:"AS",AL:"EU",AQ:"AN",DZ:"AF",AS:"OC",AD:"EU",AO:"AF",AG:"NA",AZ:"EU",AR:"SA",AU:"OC",AT:"EU",BS:"NA",BH:"AS",BD:"AS",AM:"EU",BB:"NA",BE:"EU",BM:"NA",BT:"AS",BO:"SA",BA:"EU",BW:"AF",BV:"AN",BR:"SA",BZ:"NA",IO:"AS",SB:"OC",VG:"NA",BN:"AS",BG:"EU",MM:"AS",BI:"AF",BY:"EU",KH:"AS",CM:"AF",CA:"NA",CV:"AF",KY:"NA",CF:"AF",LK:"AS",TD:"AF",CL:"SA",CN:"AS",TW:"AS",CX:"AS",CC:"AS",CO:"SA",KM:"AF",YT:"AF",CG:"AF",CD:"AF",CK:"OC",CR:"NA",HR:"EU",CU:"NA",CY:"EU",CZ:"EU",BJ:"AF",DK:"EU",DM:"NA",DO:"NA",EC:"SA",SV:"NA",GQ:"AF",ET:"AF",ER:"AF",EE:"EU",FO:"EU",FK:"SA",GS:"AN",FJ:"OC",FI:"EU",AX:"EU",FR:"EU",GF:"SA",PF:"OC",TF:"AN",DJ:"AF",GA:"AF",GE:"EU",GM:"AF",PS:"AS",DE:"EU",GH:"AF",GI:"EU",KI:"OC",GR:"EU",GL:"NA",GD:"NA",GP:"NA",GU:"OC",GT:"NA",GN:"AF",GY:"SA",HT:"NA",HM:"AN",VA:"EU",HN:"NA",HK:"AS",HU:"EU",IS:"EU",IN:"AS",ID:"AS",IR:"AS",IQ:"AS",IE:"EU",IL:"AS",IT:"EU",CI:"AF",JM:"NA",JP:"AS",KZ:"EU",JO:"AS",KE:"AF",KP:"AS",KR:"AS",KW:"AS",KG:"AS",LA:"AS",LB:"AS",LS:"AF",LV:"EU",LR:"AF",LY:"AF",LI:"EU",LT:"EU",LU:"EU",MO:"AS",MG:"AF",MW:"AF",MY:"AS",MV:"AS",ML:"AF",MT:"EU",MQ:"NA",MR:"AF",MU:"AF",MX:"NA",MC:"EU",MN:"AS",MD:"EU",ME:"EU",MS:"NA",MA:"AF",MZ:"AF",OM:"AS",NA:"AF",NR:"OC",NP:"AS",NL:"EU",AN:"NA",CW:"NA",AW:"NA",SX:"NA",BQ:"NA",NC:"OC",VU:"OC",NZ:"OC",NI:"NA",NE:"AF",NG:"AF",NU:"OC",NF:"OC",NO:"EU",MP:"OC",UM:"OC",FM:"OC",MH:"OC",PW:"OC",PK:"AS",PA:"NA",PG:"OC",PY:"SA",PE:"SA",PH:"AS",PN:"OC",PL:"EU",PT:"EU",GW:"AF",TL:"AS",PR:"NA",QA:"AS",RE:"AF",RO:"EU",RU:"EU",RW:"AF",BL:"NA",SH:"AF",KN:"NA",AI:"NA",LC:"NA",MF:"NA",PM:"NA",VC:"NA",SM:"EU",ST:"AF",SA:"AS",SN:"AF",RS:"EU",SC:"AF",SL:"AF",SG:"AS",SK:"EU",VN:"AS",SI:"EU",SO:"AF",ZA:"AF",ZW:"AF",ES:"EU",SS:"AF",EH:"AF",SD:"AF",SR:"SA",SJ:"EU",SZ:"AF",SE:"EU",CH:"EU",SY:"AS",TJ:"AS",TH:"AS",TG:"AF",TK:"OC",TO:"OC",TT:"NA",AE:"AS",TN:"AF",TR:"EU",TM:"AS",TC:"NA",TV:"OC",UG:"AF",UA:"EU",MK:"EU",EG:"AF",GB:"EU",GG:"EU",JE:"EU",IM:"EU",TZ:"AF",US:"NA",VI:"NA",BF:"AF",UY:"SA",UZ:"AS",VE:"SA",WF:"OC",WS:"OC",YE:"AS",ZM:"AF",XX:"XX"};function ze(){return async(e,t)=>{let r=e.request.headers["cf-ipcountry"]||"XX";e.request.headers["proxy-continent"]=Kn[r],await t(e)}}function Dn(e){let t=e.split("."),r=JSON.parse(atob(t[0])),s=JSON.parse(atob(t[1])),n=atob(t[2].replace(/-/g,"+").replace(/_/g,"/"));return{header:r,payload:s,signature:n,raw:{header:t[0],payload:t[1],signature:t[2]}}}function Ve({jwksUri:e,allowPublicAccess:t=!1}){async function r(){return(await(await fetch(e)).json()).keys}async function s(a){let i=new TextEncoder().encode([a.raw.header,a.raw.payload].join(".")),c=new Uint8Array(Array.from(a.signature).map(d=>d.charCodeAt(0))),h=await r();return(await Promise.all(h.map(async d=>{let l=await crypto.subtle.importKey("jwk",d,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]);return crypto.subtle.verify("RSASSA-PKCS1-v1_5",l,c,i)}))).some(d=>d)}async function n(a,o){if(a.request.method==="OPTIONS")return o(a);if((a.request.headers.authorization||"").toLowerCase().startsWith("bearer")){let c=Dn(a.request.headers.authorization.slice(7)),h=new Date(c.payload.exp*1e3),f=new Date(Date.now());if(h<=f)return!1;if(await s(c))return a.state.user=c.payload,o(a)}return t?o(a):(a.status=403,a.body="Forbidden",a)}return n}var Qt=E($()),Ln={get:Qt.default},L=class{constructor({accountId:t,namespace:r,authEmail:s,authKey:n,ttl:a}){this.accountId=t,this.namespace=r,this.authEmail=s,this.authKey=n,this.ttl=a}getNamespaceUrl(){return new URL(`https://api.cloudflare.com/client/v4/accounts/${this.accountId}/storage/kv/namespaces/${this.namespace}`)}getUrlForKey(t){return new URL(`${this.getNamespaceUrl()}/values/${t}`)}async list(t,r=10){let s=`${this.getNamespaceUrl()}/keys?prefix=${t}&limit=${r}`,n=await fetch(s,{headers:{"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey}});return n.ok?n.json():null}async get(t,r){let s=this.getUrlForKey(t),n=await fetch(s,{headers:{"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey}});if(n.ok)switch(r){case"json":return n.json();case"stream":return n;case"arrayBuffer":return n.arrayBuffer();default:return n.text()}return null}async getWithMetadata(t,r){let[s,n]=await Promise.all([this.get(t,r),this.list(t)]),a=Ln.get(n,"result.0.metadata",{});return{value:s,metadata:a}}async put(t,r,s={}){let n=this.getUrlForKey(t),a=new URLSearchParams;this.ttl&&a.append("expiration_ttl",this.ttl.toString());let o={"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey};n.search=a.toString();let i=new FormData;return i.append("value",r),i.append("metadata",JSON.stringify(s)),(await fetch(n.toString(),{method:"PUT",headers:o,body:r})).ok}async delete(t){let r=this.getUrlForKey(t);return fetch(r,{method:"DELETE",headers:{"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey}})}};var U={methodsMethodsWithBody:["POST","PUT","PATCH"],http:{statusMessages:{404:"Not Found"}},mime:{css:"text/css",csv:"text/csv",html:"text/html",ico:"image/microsoft.vnd.icon",jpeg:"image/jpeg",js:"application/javascript",json:"application/json",png:"image/png",svg:"image/svg+xml",xml:"application/xml"}};function Gn(e,t,r){if(e==="/"&&r)return r;let s=e.split("/").pop();return s.split(".").pop()!==s?e:`${e}.${t}`}function We({kvAccountId:e,kvNamespace:t,kvAuthEmail:r,kvAuthKey:s,kvBasePath:n="",kvKey:a="{file}",defaultExtension:o="html",defaultIndexDocument:i,defaultErrorDocument:c,mime:h={},mode:f="rest"}){let d=new L({accountId:e,namespace:t,authEmail:r,authKey:s,mode:f}),l={...U.mime,...h};return async m=>{let y=v.resolveParams(a,m.params),A=y===""&&i?i:Gn(y,o),p=await d.get(n+A);!p&&c&&(p=await d.get(n+c)),p?(m.status=200,m.body=p,m.set("Content-Type",l[A.split(".").pop()]||"text/plain")):(m.status=404,m.body=U.http.statusMessages[404],m.set("Content-Type","text/plain"))}}var er=E($());var Je={get:er.default};function Bn(e,t,r){if(e==="/"&&r)return r;let s=e.split("/").pop();return s.split(".").pop()!==s?e:`${e}.${t}`}function zn(e,t){let r=Je.get(e,"headers.if-none-match"),s=Je.get(t,"metadata.headers.etag");return r?r===s:!1}function Xe({kvNamespaceBinding:e,kvBasePath:t="",kvKey:r="{file}",defaultExtension:s="html",defaultIndexDocument:n,defaultErrorDocument:a}){async function o(i){return await global[e].getWithMetadata(i)}return async i=>{let c=v.resolveParams(r,i.params),h=c===""&&n?n:Bn(c,s),f=await o(t+h);if(!f&&a&&(f=await o(t+a)),f)if(zn(i.request,f))i.status=304;else{i.status=f.status,i.body=f.value;let d=Je.get(f,"metadata.headers",{});Object.keys(d).forEach(l=>{i.set(l,d[l])})}else i.status=404,i.body=U.http.statusMessages[404],i.set("Content-Type","text/plain")}}var rr=E(ge());function xe({accessKeyId:e,secretAccessKey:t,region:r,lambdaName:s}){let n=new rr.AwsClient({accessKeyId:e,secretAccessKey:t});return async a=>{let o=`https://lambda.${r}.amazonaws.com/2015-03-31/functions/${s}/invocations`,i={},c=await n.fetch(o,{body:JSON.stringify(i)});a.status=c.status,a.body=c.body;let h=v.instanceToJson(c.headers);Object.keys(h).forEach(f=>{a.set(f,h[f])})}}var yr=E($()),Ar=E(be());var gr={get:yr.default,set:Ar.default};function za(e){let t={};return Object.keys(e).forEach(r=>{r.startsWith("cf")||(t[r]=e[r])}),t}function Va(e){return e[Math.floor(Math.random()*e.length)]}function tt({sources:e=[]}){return async t=>{let r=Va(e),s={method:t.request.method,headers:za(t.request.headers),redirect:"manual",cf:t.request.cf};if(U.methodsMethodsWithBody.indexOf(t.request.method)!==-1&&gr.get(t,"event.request.body")){let i=t.event.request.clone();s.body=i.body}let n=v.resolveParams(r.url,t.params);if(r.resolveOverride){let i=v.resolveParams(r.resolveOverride,t.request.params);gr.set(s,"cf.resolveOverride",i)}let a=await fetch(n+t.request.search,s);t.body=a.body,t.status=a.status;let o=v.instanceToJson(a.headers);Object.keys(o).forEach(i=>{t.set(i,o[i])})}}var br=E($());var rt={name:"@ahmadissa/cloudworker-proxy",version:"1.0.22",description:"An api gateway for cloudflare workers",license:"MIT",repository:{type:"git",url:"git+https://github.com/ahmadissa/cloudworker-proxy.git"},bugs:{url:"https://github.com/ahmadissa/cloudworker-proxy/issues"},homepage:"https://github.com/ahmadissa/cloudworker-proxy#readme",author:"Markus Ahlstrand",keywords:["cloudflare","workers","api","gateway","proxy"],main:"dist/index.js",files:["dist/**"],scripts:{build:"esbuild --bundle src/index.ts --format=cjs --outdir=dist --sourcemap --minify",lint:"eslint src",package:"bun install; npm run build",test:"npm run unit && npm run lint","test:integration":"node integration/run.js",unit:"bun test","semantic-release":"semantic-release",prepare:"husky install"},release:{branches:["master"],plugins:["@semantic-release/commit-analyzer","@semantic-release/release-notes-generator",["@semantic-release/npm",{npmPublish:!1}],["@semantic-release/git",{assets:["docs","package.json"],message:"chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"}]]},dependencies:{aws4fetch:"1.0.13","cloudworker-router":"1.11.2",cookie:"0.4.1","lodash.get":"4.4.2","lodash.set":"4.3.2",shortid:"2.2.16"},devDependencies:{"@semantic-release/git":"^10.0.1","@types/jest":"^29.5.5","@types/mocha":"^10.0.1","@types/node":"^20.5.9","@typescript-eslint/eslint-plugin":"^6.6.0","@typescript-eslint/parser":"^6.6.0",bun:"1.0.3",dotenv:"8.2.0",esbuild:"^0.19.2",eslint:"7.13.0","eslint-config-airbnb-base":"14.2.1","eslint-config-prettier":"6.15.0","eslint-plugin-import":"2.22.1","eslint-plugin-prettier":"3.1.4","fetch-mock":"9.11.0",husky:"^8.0.3","node-fetch":"2.6.1",prettier:"2.1.2","semantic-release":"^22.0.4",typescript:"^5.2.2",wrangler:"^3.7.0"},directories:{example:"examples",test:"test"}};var z=class{constructor({maxSize:t=10,maxSeconds:r=10,sink:s}){this.maxSize=t,this.maxSeconds=r,this.queue=[],this.sink=s,this.flushing=!1,this.timer=null}async push(t){return this.queue.push(t),this.queue.length>this.maxSize?this.flush():(this.timer||(this.timer=new Promise((r,s)=>{this.resolveTimer=r,this.rejectTimer=s,this.cancelationToken=setTimeout(async()=>{try{r(await this.flush())}catch(n){s(n)}},this.maxSeconds*1e3)})),this.timer)}async flush(){if(!this.flushing){this.flushing=!0;try{let t=this.queue.join(`
|
|
6
|
-
`);this.queue=[];let r=await this.sink(
|
|
7
|
-
`),s=JSON.stringify({DeliveryStreamName:this.streamName,Record:{Data:r}}),n=`https://firehose.${this.region}.amazonaws.com`,a=new Request(n,{method:"POST",body:s,headers:{"X-Amz-Target":"Firehose_20150804.PutRecord","Content-Type":" application/x-amz-json-1.1"}});return this.awsClient.fetch(a)}};var q={get:br.default};async function Ja(e){return["POST","PATCH"].indexOf(e.method)===-1?null:e.text()}function st(e){let t;switch(e.type){case"http":t=new ae(e);break;case"kinesis":t=new oe(e);break;default:throw new Error(`Log service type not supported: ${e.type}`)}return async(r,s)=>{r.state["logger-startDate"]=new Date;let n=await Ja(r.request);try{await s(r);let a={message:"START",requestIp:q.get(r,"request.headers.x-real-ip"),requestId:q.get(r,"request.requestId"),request:{headers:q.get(r,"request.headers"),method:q.get(r,"request.method"),url:q.get(r,"request.href"),protocol:q.get(r,"request.protocol"),body:n},response:{status:r.status,headers:q.get(r,"response.headers")},handlers:q.get(r,"state.handlers",[]).join(","),route:q.get(r,"route.name"),timestamp:new Date().toISOString(),ttfb:new Date-r.state["logger-startDate"],redirectUrl:r.userRedirect,severity:30,proxyVersion:rt.version};r.event.waitUntil(t.log(a))}catch(a){let o={request:{headers:q.get(r,"request.headers"),method:q.get(r,"request.method"),handlers:q.get(r,"state.handlers",[]).join(","),url:q.get(r,"request.href"),body:n},message:"ERROR",stack:a.stack,error:a.message,severity:50,proxyVersion:rt.version};r.event.waitUntil(t.log(o))}}}var ue=E(vr()),xr=E($()),Yr=E(be()),Zr=E(Vr());async function ht({refresh_token:e,authDomain:t,clientId:r,clientSecret:s}){let n=`${t}/oauth/token`,a=await fetch(n,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",client_id:r,client_secret:s,refresh_token:e})});if(!a.ok)throw new Error("Authentication failed");let o=await a.json();return{...o,expires:Date.now()+o.expires_in*1e3,refresh_token:e}}var Wr="PBKDF2",lt="AES-GCM",Co="SHA-256",Eo="raw";function To(e){let t=atob(e.replace(/_/g,"/").replace(/-/g,"+")),r=t.length,s=new Uint8Array(r);for(let n=0;n<r;n+=1)s[n]=t.charCodeAt(n);return s.buffer}function Jr(e){let t="",r=new Uint8Array(e),s=r.byteLength;for(let n=0;n<s;n+=1)t+=String.fromCharCode(r[n]);return btoa(t).replace(/\//g,"_").replace(/\+/g,"-")}function Oo(e){return String.fromCharCode.apply(null,new Uint16Array(e))}function _o(e){let t=new ArrayBuffer(e.length*2),r=new Uint16Array(t);for(let s=0,n=e.length;s<n;s+=1)r[s]=e.charCodeAt(s);return t}async function qo(e){let t=new TextEncoder;return crypto.subtle.importKey(Eo,t.encode(e),{name:Wr},!1,["deriveKey"])}async function Po(e,t){let r=await qo(e),n=new TextEncoder().encode(t.replace(/_/g,"/").replace(/-/g,"+"));return crypto.subtle.deriveKey({name:Wr,salt:n,iterations:1e3,hash:{name:Co}},r,{name:lt,length:256},!0,["encrypt","decrypt"])}async function Uo(){let e=crypto.getRandomValues(new Uint8Array(8));return Jr(e)}async function ko(e,t){let r=To(t),s=r.slice(0,16),n=r.slice(16),a=await crypto.subtle.decrypt({name:lt,iv:s},e,n);return Oo(a)}async function No(e,t){let r=crypto.getRandomValues(new Uint8Array(16)),s=await crypto.subtle.encrypt({name:lt,iv:r},e,_o(t)),n=new Uint8Array(s.byteLength+r.byteLength);return n.set(r,0),n.set(new Uint8Array(s),r.byteLength),Jr(n)}var W={decrypt:ko,deriveAesGcmKey:Po,encrypt:No,getSalt:Uo};var Y={get:xr.default,set:Yr.default};function Xr({cookieHeader:e="",cookieName:t}){return ue.default.parse(e)[t]}function Ro(e){return Object.keys(e).map(t=>`${t}=${encodeURIComponent(e[t])}`).join("&")}function $o(e=""){return e.split(",").indexOf("text/html")!==-1}function dt({cookieName:e="proxy",cookieHttpOnly:t=!0,allowPublicAccess:r=!1,kvAccountId:s,kvNamespace:n,kvAuthEmail:a,kvAuthKey:o,kvTtl:i=2592e3,oauth2AuthDomain:c,oauth2ClientId:h,oauth2ClientSecret:f,oauth2Audience:d,oauth2Scopes:l=[],oauth2CallbackPath:m="/callback",oauth2CallbackType:y="cookie",oauth2LogoutPath:A="/logout",oauth2LoginPath:p="/login",oauth2ServerTokenPath:g="/oauth/token",oauth2ServerAuthorizePath:T="",oauth2ServerLogoutPath:P}){let _=new L({accountId:s,namespace:n,authEmail:a,authKey:o,ttl:i}),j=c,Z=m,_e=y,qe=g,he=T,Pe=P,F=h,Q=f,k=d,le=A,w=p,te=l.join("%20");async function de(u,C){let b=`${j}${qe}`,O=await fetch(b,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:Ro({code:u,grant_type:"authorization_code",client_id:F,client_secret:Q,redirect_uri:C})});if(!O.ok)throw new Error("Authentication failed");let N=await O.json();return{...N,expires:Date.now()+N.expires_in*1e3}}async function cs(u){if(Xr({cookieHeader:u.request.headers.cookie,cookieName:e})){let O=u.request.hostname.match(/[^.]+\.[^.]+$/i)[0];u.set("Set-Cookie",ue.default.serialize(e,"",{domain:`.${O}`,path:"/",maxAge:0}))}let b=Et(u);if(P){let O=encodeURIComponent(`${u.request.protocol}://${u.request.host}${b}`);u.set("Location",`${j}${Pe}?client_id=${F}&returnTo=${O}`)}else u.set("Location",b);u.status=302}async function us(u){let C=u.request.href.split("?")[0],b=await de(u.request.query.code,C),O=Zr.default.generate(),N=await W.getSalt(),R=`${O}.${N}`,Ue=await W.deriveAesGcmKey(O,N),I=await W.encrypt(Ue,JSON.stringify(b));await _.put(O,I);let ke=u.request.hostname.match(/[^.]+\.[^.]+$/i)[0];u.status=302,_e==="query"?u.set("Location",`${u.request.query.state}?auth=${R}`):(u.set("Set-Cookie",ue.default.serialize(e,R,{httpOnly:t,domain:`.${ke}`,path:"/",maxAge:60*60*24*365})),u.set("Location",u.request.query.state))}async function hs(u,C){let[b,O]=C.split("."),N=await _.get(b);if(N){let R=await W.deriveAesGcmKey(b,O),Ue=await W.decrypt(R,N),I=JSON.parse(Ue);if(I.expires<Date.now()){I=await ht({refresh_token:I.refresh_token,clientId:F,authDomain:j,clientSecret:Q});let ke=await W.encrypt(R,JSON.stringify(I));await _.put(b,ke)}u.state.accessToken=I.access_token,u.state.accessToken&&(u.request.headers.authorization=`bearer ${u.state.accessToken}`)}else{let R=u.request.hostname.match(/[^.]+\.[^.]+$/i)[0];u.set("Set-Cookie",ue.default.serialize(e,"",{domain:`.${R}`,maxAge:0}))}}function Et(u){let C=Y.get(u,"request.query.redirect-to");if(C)return C;let b=Y.get(u,"request.headers.referer");return b||"/"}async function ls(u){if(u.request.method==="OPTIONS")u.status=200;else{let C=Et(u),b=encodeURIComponent(C||"/"),O=encodeURIComponent(`${u.request.protocol}://${u.request.host}${Z}`);u.status=302,u.set("location",`${j}${he}/authorize?state=${b}&client_id=${F}&response_type=code&scope=${te}&audience=${k}&redirect_uri=${O}`)}}async function ds(u,C){if(u.request.method==="OPTIONS")await C(u);else if(Y.get(u,"request.headers.authorization","").toLowerCase().startsWith("bearer "))Y.set(u,"state.access_token",u.request.headers.authorization.slice(7)),await C(u);else{let b=Y.get(u,"request.query.auth")||Xr({cookieHeader:u.request.headers.cookie,cookieName:e});if(b&&await hs(u,b),Y.get(u,"state.accessToken")||r)await C(u);else if($o(u.request.headers.accept)){let N=encodeURIComponent(u.request.href),R=encodeURIComponent(`${u.request.protocol}://${u.request.host}${Z}`);u.status=302,u.set("location",`${j}${he}/authorize?state=${N}&client_id=${F}&response_type=code&scope=${te}&audience=${k}&redirect_uri=${R}`)}else u.status=403,u.body="Forbidden"}}return async(u,C)=>{switch(u.request.path){case Z:await us(u);break;case le:await cs(u);break;case w:await ls(u);break;default:await ds(u,C)}}}var Qr=E($());var Ho={get:Qr.default};function Fo(e){let t={};return Object.keys(e).forEach(r=>{r.startsWith("cf")||(t[r]=e[r])}),t}function ft(e){let{localOriginOverride:t,backend:r}=e;return async s=>{let n=process.env.LOCAL?`${t||s.request.origin}${s.request.path}`:`${r}${s.request.path}`,a={headers:Fo(s.request.headers),method:s.request.method,redirect:"manual"};if(U.methodsMethodsWithBody.indexOf(s.request.method)!==-1&&Ho.get(s,"event.request.body")){let c=s.event.request.clone();a.body=c.body}let o=await fetch(n,a);s.body=o.body,s.status=o.status;let i=v.instanceToJson(o.headers);Object.keys(i).forEach(c=>{s.set(c,i[c])})}}function pt({body:e="",headers:t={},status:r=200}){return async s=>{e instanceof Object?(s.body=JSON.stringify(e),s.set("Content-Type","application/json")):s.body=v.resolveParams(e,s.params),s.status=r,Object.keys(t).forEach(n=>{s.set(n,v.resolveParams(t[n],s.params))})}}var es=E($()),ts=E(be()),mt={get:es.default,set:ts.default};function gt({type:e="IP",scope:t="default",limit:r=1e3}){let s={};function n(o,i){let c=i["x-real-ip"];return e==="IP"?`minute.${o}.${t}.${c}`:`minute.${o}.${t}.account`}function a(o){let i=mt.get(s,"minutes",{});Object.keys(i).forEach(c=>{c!==o&&delete s.minutes.minute})}return async(o,i)=>{let c=Math.trunc(Date.now()/6e4),h=Math.trunc(c*60+60-Date.now()/1e3),f=n(c,o.request.headers),d=mt.get(s,f,0);if(["HEAD","OPTIONS"].indexOf(o.request.method)===-1&&(d+=1),mt.set(s,f,d),r<d){o.status=429;return}a(c),await i(o)}}var rs=E(ge());function Mo(e,t={}){if(e&&t.forcePathStyle){let r=new URL(e);return`${r.protocol}//${r.host}/${t.bucket}`}if(e){let r=new URL(e);return`${r.protocol}//${t.bucket}.${r.host}`}return t.forcePathStyle&&t.region?`https://s3.${t.region}.amazonaws.com/${t.bucket}`:t.forcePathStyle?`https://s3.amazonaws.com/${t.bucket}`:t.region?`https://${t.bucket}.s3.${t.region}.amazonaws.com`:`https://${t.bucket}.s3.amazonaws.com`}function yt({accessKeyId:e,secretAccessKey:t,bucket:r,region:s,endpoint:n,forcePathStyle:a,enableBucketOperations:o=!1}){let i=new rs.AwsClient({accessKeyId:e,region:s,secretAccessKey:t}),c=Mo(n,{region:s,bucket:r,forcePathStyle:a});return async h=>{if(h.params.file===void 0&&!o){h.status=404,h.body=U.http.statusMessages[404],h.set("Content-Type","text/plain");return}let f=h.params.file?v.resolveParams(`${c}/{file}`,h.params):c,d={};h.request.headers.range&&(d.range=h.request.headers.range);let l=await i.fetch(f,{method:h.method||h.request.method,headers:d});h.status=l.status,h.body=l.body;let m=v.instanceToJson(l.headers);Object.keys(m).forEach(y=>{h.set(y,m[y])})}}var At;function ss(e){return new Uint8Array(e.split("").map(r=>r.charCodeAt(0)))}async function jo(e){return At||(At=await crypto.subtle.importKey("raw",ss(e),{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign","verify"])),At}async function Io(e,t){let r=await jo(t),s=await crypto.subtle.sign({name:"HMAC"},r,ss(e));return btoa(String.fromCharCode.apply(null,new Uint8Array(s))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function wt({secret:e}){return async(t,r)=>{let s=(t.request.path+t.request.search).replace(/([?|&]sign=[\w|-]+)/,"");if(await Io(s,e)!==t.query.sign){t.status=403;return}await r(t)}}function St({host:e}){if(!e)throw new Error("Need to specify a host for the split middleware.");return async(t,r)=>{let s=t.clone();s.cloned=!0,s.request={...s.request,href:s.request.href.replace(s.request.href,e),host:e},t.event.waitUntil(r(s)),await r(t)}}async function Ko(e,t,r){let s=e.getReader(),n=t.getWriter(),a=new TextDecoder,o=new TextEncoder;for(;;){let{done:i,value:c}=await s.read();if(i)break;let h=a.decode(c),f=ns(h,r),d=o.encode(f);await n.write(d)}await n.close()}function Do(e,t){return e.replace(/{{\$(\d)}}/g,(r,s)=>t[parseInt(s,10)])}function ns(e,t){return t.reduce((r,s)=>r.replace(s.regex,(...n)=>Do(s.replace,n)),e)}function bt({transforms:e=[],statusCodes:t=[200]}){let r=e.map(s=>({regex:new RegExp(s.regex,"g"),replace:s.replace}));return async(s,n)=>{await n(s);let{body:a}=s;if(t.indexOf(s.status)!==-1)if(typeof a=="string")s.body=ns(a,r);else{let{readable:o,writable:i}=new TransformStream;Ko(a,i,r),s.body=o}}}async function Lo({projectID:e="your-project-id",API_KEY:t="GCP_API_KEY",token:r="action-token",siteKey:s="siteKey",expectedAction:n="action-name"}){let o=await(await fetch(`https://recaptchaenterprise.googleapis.com/v1/projects/${e}/assessments?key=${t}`,{body:JSON.stringify({event:{token:r,siteKey:s,expectedAction:n}}),headers:{"Content-Type":"application/json"},method:"POST"})).json();return o.tokenProperties.valid?o.tokenProperties.action===n?(o.riskAnalysis.reasons.forEach(i=>{console.log(i)}),o.riskAnalysis.score):(console.error("The action attribute in your reCAPTCHA tag does not match the action you are expecting to score"),null):(console.error("The CreateAssessment call failed because the token was: "+o.tokenProperties.invalidReason),0)}function vt({projectID:e,API_KEY:t,siteKey:r}){function s(n){return{token:n["g-recaptcha-token"],expectedAction:n["g-recaptcha-action"]}}return async(n,a)=>{let{token:o,expectedAction:i}=s(n.request.headers);if((await Lo({projectID:e,API_KEY:t,token:o,siteKey:r,expectedAction:i})||0)<.5){n.status=409;return}await a(n)}}var Go=e=>!new RegExp("(\b)(onS+)(s*)=|javascript|<(|/|[^/>][^>]+|/[^>][^>]+)>").test(e),Bo=(e,t,r)=>{if(!Go(t)||!r[e](t))return!1};var zo=e=>!(e===null||typeof e!="object"||Array.isArray(e)&&(!e[0]||typeof e[0]!="object")),as=(e,t)=>{Object.keys(e).forEach(function(r){if(!t[r]&&isNaN(r))return!1;e[r]===null&&(e[r]=""),zo(e[r])?as(e[r],t):Bo(r,e[r],t)})},Vo=e=>!(e==null||typeof e!="object"),Wo=(e,t)=>{let r=e.query;return Vo(r)?as(r,t):!1};function Ct({allowedKeys:e}){return async(t,r)=>{if(!e){t.status=501;return}if(t.body=JSON.stringify({...e,...t.query}),!Wo(t,e)){t.status=402;return}await r(t)}}var os={basicAuth:Ke,cache:Ge,cors:Be,geoDecorator:ze,jwt:Ve,kvStorage:We,kvStorageBinding:Xe,lambda:xe,loadbalancer:tt,logger:st,oauth2:dt,origin:ft,rateLimit:gt,response:pt,s3:yt,signature:wt,split:St,transform:bt,recaptcha:vt,userInputValidation:Ct};module.exports=class{constructor(t=[],r={}){this.router=new is.default,t.forEach(s=>{let n=r[s.handlerName]||os[s.handlerName];if(!n)throw new Error(`Handler ${s.handlerName} is not supported`);this.router.add(s,n(s.options))})}async resolve(t){return this.router.resolve(t)}};
|
|
5
|
+
`)}async hexBodyHash(){let d=this.headers.get("X-Amz-Content-Sha256");if(d==null){if(this.body&&typeof this.body!="string"&&!("byteLength"in this.body))throw new Error("body must be a string, ArrayBuffer or ArrayBufferView, unless you include the X-Amz-Content-Sha256 header");d=u(await a(this.body||""))}return d}}async function o(f,d){let y=await crypto.subtle.importKey("raw",typeof f=="string"?e.encode(f):f,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return crypto.subtle.sign("HMAC",y,e.encode(d))}async function a(f){return crypto.subtle.digest("SHA-256",typeof f=="string"?e.encode(f):f)}function u(f){return Array.prototype.map.call(new Uint8Array(f),d=>("0"+d.toString(16)).slice(-2)).join("")}function h(f){return f.replace(/[!'()*]/g,d=>"%"+d.charCodeAt(0).toString(16).toUpperCase())}function l(f,d){let{hostname:y,pathname:g}=f,A=y.replace("dualstack.","").match(/([^.]+)\.(?:([^.]*)\.)?amazonaws\.com(?:\.cn)?$/),[m,w]=(A||["",""]).slice(1,3);if(w==="us-gov")w="us-gov-west-1";else if(w==="s3"||w==="s3-accelerate")w="us-east-1",m="s3";else if(m==="iot")y.startsWith("iot.")?m="execute-api":y.startsWith("data.jobs.iot.")?m="iot-jobs-data":m=g==="/mqtt"?"iotdevicegateway":"iotdata";else if(m==="autoscaling"){let x=(d.get("X-Amz-Target")||"").split(".")[0];x==="AnyScaleFrontendService"?m="application-autoscaling":x==="AnyScaleScalingPlannerFrontendService"&&(m="autoscaling-plans")}else w==null&&m.startsWith("s3-")?(w=m.slice(3).replace(/^fips-|^external-1/,""),m="s3"):m.endsWith("-fips")?m=m.slice(0,-5):w&&/-\d$/.test(m)&&!/-\d$/.test(w)&&([m,w]=[w,m]);return[r[m]||m,w]}t.AwsClient=i,t.AwsV4Signer=s,Object.defineProperty(t,"__esModule",{value:!0})})});var $e=E((Qu,jr)=>{var Ls="Expected a function",Pr="__lodash_hash_undefined__",$r=1/0,js=9007199254740991,Ks="[object Function]",Gs="[object GeneratorFunction]",zs="[object Symbol]",Ws=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Vs=/^\w*$/,Xs=/^\./,Js=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ys=/[\\^$.*+?()[\]{}|]/g,Zs=/\\(\\)?/g,Qs=/^\[object .+?Constructor\]$/,eo=/^(?:0|[1-9]\d*)$/,to=typeof global=="object"&&global&&global.Object===Object&&global,ro=typeof self=="object"&&self&&self.Object===Object&&self,mt=to||ro||Function("return this")();function no(t,e){return t?.[e]}function io(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch{}return e}var so=Array.prototype,oo=Function.prototype,vr=Object.prototype,yt=mt["__core-js_shared__"],Rr=function(){var t=/[^.]+$/.exec(yt&&yt.keys&&yt.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),qr=oo.toString,ke=vr.hasOwnProperty,Mr=vr.toString,ao=RegExp("^"+qr.call(ke).replace(Ys,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Or=mt.Symbol,uo=so.splice,co=Hr(mt,"Map"),we=Hr(Object,"create"),kr=Or?Or.prototype:void 0,Nr=kr?kr.toString:void 0;function Y(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function ho(){this.__data__=we?we(null):{}}function fo(t){return this.has(t)&&delete this.__data__[t]}function lo(t){var e=this.__data__;if(we){var r=e[t];return r===Pr?void 0:r}return ke.call(e,t)?e[t]:void 0}function po(t){var e=this.__data__;return we?e[t]!==void 0:ke.call(e,t)}function yo(t,e){var r=this.__data__;return r[t]=we&&e===void 0?Pr:e,this}Y.prototype.clear=ho;Y.prototype.delete=fo;Y.prototype.get=lo;Y.prototype.has=po;Y.prototype.set=yo;function oe(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function mo(){this.__data__=[]}function go(t){var e=this.__data__,r=Ne(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():uo.call(e,r,1),!0}function wo(t){var e=this.__data__,r=Ne(e,t);return r<0?void 0:e[r][1]}function Ao(t){return Ne(this.__data__,t)>-1}function Eo(t,e){var r=this.__data__,n=Ne(r,t);return n<0?r.push([t,e]):r[n][1]=e,this}oe.prototype.clear=mo;oe.prototype.delete=go;oe.prototype.get=wo;oe.prototype.has=Ao;oe.prototype.set=Eo;function Z(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function So(){this.__data__={hash:new Y,map:new(co||oe),string:new Y}}function bo(t){return Pe(this,t).delete(t)}function Co(t){return Pe(this,t).get(t)}function To(t){return Pe(this,t).has(t)}function Bo(t,e){return Pe(this,t).set(t,e),this}Z.prototype.clear=So;Z.prototype.delete=bo;Z.prototype.get=Co;Z.prototype.has=To;Z.prototype.set=Bo;function Io(t,e,r){var n=t[e];(!(ke.call(t,e)&&Dr(n,r))||r===void 0&&!(e in t))&&(t[e]=r)}function Ne(t,e){for(var r=t.length;r--;)if(Dr(t[r][0],e))return r;return-1}function xo(t){if(!Oe(t)||No(t))return!1;var e=qo(t)||io(t)?ao:Qs;return e.test(vo(t))}function Uo(t,e,r,n){if(!Oe(t))return t;e=Oo(e,t)?[e]:_o(e);for(var i=-1,s=e.length,o=s-1,a=t;a!=null&&++i<s;){var u=$o(e[i]),h=r;if(i!=o){var l=a[u];h=n?n(l,u,a):void 0,h===void 0&&(h=Oe(l)?l:Ro(e[i+1])?[]:{})}Io(a,u,h),a=a[u]}return t}function Fo(t){if(typeof t=="string")return t;if(wt(t))return Nr?Nr.call(t):"";var e=t+"";return e=="0"&&1/t==-$r?"-0":e}function _o(t){return Lr(t)?t:Po(t)}function Pe(t,e){var r=t.__data__;return ko(e)?r[typeof e=="string"?"string":"hash"]:r.map}function Hr(t,e){var r=no(t,e);return xo(r)?r:void 0}function Ro(t,e){return e=e??js,!!e&&(typeof t=="number"||eo.test(t))&&t>-1&&t%1==0&&t<e}function Oo(t,e){if(Lr(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||wt(t)?!0:Vs.test(t)||!Ws.test(t)||e!=null&&t in Object(e)}function ko(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function No(t){return!!Rr&&Rr in t}var Po=gt(function(t){t=Ho(t);var e=[];return Xs.test(t)&&e.push(""),t.replace(Js,function(r,n,i,s){e.push(i?s.replace(Zs,"$1"):n||r)}),e});function $o(t){if(typeof t=="string"||wt(t))return t;var e=t+"";return e=="0"&&1/t==-$r?"-0":e}function vo(t){if(t!=null){try{return qr.call(t)}catch{}try{return t+""}catch{}}return""}function gt(t,e){if(typeof t!="function"||e&&typeof e!="function")throw new TypeError(Ls);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],s=r.cache;if(s.has(i))return s.get(i);var o=t.apply(this,n);return r.cache=s.set(i,o),o};return r.cache=new(gt.Cache||Z),r}gt.Cache=Z;function Dr(t,e){return t===e||t!==t&&e!==e}var Lr=Array.isArray;function qo(t){var e=Oe(t)?Mr.call(t):"";return e==Ks||e==Gs}function Oe(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function Mo(t){return!!t&&typeof t=="object"}function wt(t){return typeof t=="symbol"||Mo(t)&&Mr.call(t)==zs}function Ho(t){return t==null?"":Fo(t)}function Do(t,e,r){return t==null?t:Uo(t,e,r)}jr.exports=Do});var Jr=E(bt=>{"use strict";bt.parse=Xo;bt.serialize=Jo;var zo=decodeURIComponent,Wo=encodeURIComponent,Vo=/; */,qe=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function Xo(t,e){if(typeof t!="string")throw new TypeError("argument str must be a string");for(var r={},n=e||{},i=t.split(Vo),s=n.decode||zo,o=0;o<i.length;o++){var a=i[o],u=a.indexOf("=");if(!(u<0)){var h=a.substr(0,u).trim(),l=a.substr(++u,a.length).trim();l[0]=='"'&&(l=l.slice(1,-1)),r[h]==null&&(r[h]=Yo(l,s))}}return r}function Jo(t,e,r){var n=r||{},i=n.encode||Wo;if(typeof i!="function")throw new TypeError("option encode is invalid");if(!qe.test(t))throw new TypeError("argument name is invalid");var s=i(e);if(s&&!qe.test(s))throw new TypeError("argument val is invalid");var o=t+"="+s;if(n.maxAge!=null){var a=n.maxAge-0;if(isNaN(a)||!isFinite(a))throw new TypeError("option maxAge is invalid");o+="; Max-Age="+Math.floor(a)}if(n.domain){if(!qe.test(n.domain))throw new TypeError("option domain is invalid");o+="; Domain="+n.domain}if(n.path){if(!qe.test(n.path))throw new TypeError("option path is invalid");o+="; Path="+n.path}if(n.expires){if(typeof n.expires.toUTCString!="function")throw new TypeError("option expires is invalid");o+="; Expires="+n.expires.toUTCString()}if(n.httpOnly&&(o+="; HttpOnly"),n.secure&&(o+="; Secure"),n.sameSite){var u=typeof n.sameSite=="string"?n.sameSite.toLowerCase():n.sameSite;switch(u){case!0:o+="; SameSite=Strict";break;case"lax":o+="; SameSite=Lax";break;case"strict":o+="; SameSite=Strict";break;case"none":o+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return o}function Yo(t,e){try{return e(t)}catch{return t}}});var Zr=E((gc,Yr)=>{"use strict";var Me=1;function Zo(){return Me=(Me*9301+49297)%233280,Me/233280}function Qo(t){Me=t}Yr.exports={nextValue:Zo,seed:Qo}});var be=E((wc,rn)=>{"use strict";var Ct=Zr(),ee="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-",K,Qr,Se;function Tt(){Se=!1}function en(t){if(!t){K!==ee&&(K=ee,Tt());return}if(t!==K){if(t.length!==ee.length)throw new Error("Custom alphabet for shortid must be "+ee.length+" unique characters. You submitted "+t.length+" characters: "+t);var e=t.split("").filter(function(r,n,i){return n!==i.lastIndexOf(r)});if(e.length)throw new Error("Custom alphabet for shortid must be "+ee.length+" unique characters. These characters were not unique: "+e.join(", "));K=t,Tt()}}function ea(t){return en(t),K}function ta(t){Ct.seed(t),Qr!==t&&(Tt(),Qr=t)}function ra(){K||en(ee);for(var t=K.split(""),e=[],r=Ct.nextValue(),n;t.length>0;)r=Ct.nextValue(),n=Math.floor(r*t.length),e.push(t.splice(n,1)[0]);return e.join("")}function tn(){return Se||(Se=ra(),Se)}function na(t){var e=tn();return e[t]}function ia(){return K||ee}rn.exports={get:ia,characters:ea,seed:ta,lookup:na,shuffled:tn}});var sn=E((Ac,nn)=>{"use strict";var Bt=typeof window=="object"&&(window.crypto||window.msCrypto),It;!Bt||!Bt.getRandomValues?It=function(t){for(var e=[],r=0;r<t;r++)e.push(Math.floor(Math.random()*256));return e}:It=function(t){return Bt.getRandomValues(new Uint8Array(t))};nn.exports=It});var an=E((Ec,on)=>{on.exports=function(t,e,r){for(var n=(2<<Math.log(e.length-1)/Math.LN2)-1,i=-~(1.6*n*r/e.length),s="";;)for(var o=t(i),a=i;a--;)if(s+=e[o[a]&n]||"",s.length===+r)return s}});var cn=E((Sc,un)=>{"use strict";var sa=be(),oa=sn(),aa=an();function ua(t){for(var e=0,r,n="";!r;)n=n+aa(oa,sa.get(),1),r=t<Math.pow(16,e+1),e++;return n}un.exports=ua});var ln=E((Cc,fn)=>{"use strict";var He=cn(),bc=be(),ca=1567752802062,ha=7,De,hn;function fa(t){var e="",r=Math.floor((Date.now()-ca)*.001);return r===hn?De++:(De=0,hn=r),e=e+He(ha),e=e+He(t),De>0&&(e=e+He(De)),e=e+He(r),e}fn.exports=fa});var dn=E((Tc,pn)=>{"use strict";var la=be();function pa(t){if(!t||typeof t!="string"||t.length<6)return!1;var e=new RegExp("[^"+la.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]");return!e.test(t)}pn.exports=pa});var mn=E((Bc,yn)=>{"use strict";yn.exports=0});var An=E((Ic,D)=>{"use strict";var xt=be(),da=ln(),ya=dn(),gn=mn()||0;function ma(t){return xt.seed(t),D.exports}function ga(t){return gn=t,D.exports}function wa(t){return t!==void 0&&xt.characters(t),xt.shuffled()}function wn(){return da(gn)}D.exports=wn;D.exports.generate=wn;D.exports.seed=ma;D.exports.worker=ga;D.exports.characters=wa;D.exports.isValid=ya});var Sn=E((xc,En)=>{"use strict";En.exports=An()});var $n=E(Le=>{"use strict";Le.byteLength=Ha;Le.toByteArray=La;Le.fromByteArray=Ga;var v=[],k=[],Ma=typeof Uint8Array<"u"?Uint8Array:Array,Dt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(re=0,Nn=Dt.length;re<Nn;++re)v[re]=Dt[re],k[Dt.charCodeAt(re)]=re;var re,Nn;k["-".charCodeAt(0)]=62;k["_".charCodeAt(0)]=63;function Pn(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function Ha(t){var e=Pn(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Da(t,e,r){return(e+r)*3/4-r}function La(t){var e,r=Pn(t),n=r[0],i=r[1],s=new Ma(Da(t,n,i)),o=0,a=i>0?n-4:n,u;for(u=0;u<a;u+=4)e=k[t.charCodeAt(u)]<<18|k[t.charCodeAt(u+1)]<<12|k[t.charCodeAt(u+2)]<<6|k[t.charCodeAt(u+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=k[t.charCodeAt(u)]<<2|k[t.charCodeAt(u+1)]>>4,s[o++]=e&255),i===1&&(e=k[t.charCodeAt(u)]<<10|k[t.charCodeAt(u+1)]<<4|k[t.charCodeAt(u+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function ja(t){return v[t>>18&63]+v[t>>12&63]+v[t>>6&63]+v[t&63]}function Ka(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),i.push(ja(n));return i.join("")}function Ga(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(Ka(t,o,o+s>a?a:o+s));return n===1?(e=t[r-1],i.push(v[e>>2]+v[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(v[e>>10]+v[e>>4&63]+v[e<<2&63]+"=")),i.join("")}});var vn=E(Lt=>{Lt.read=function(t,e,r,n,i){var s,o,a=i*8-n-1,u=(1<<a)-1,h=u>>1,l=-7,f=r?i-1:0,d=r?-1:1,y=t[e+f];for(f+=d,s=y&(1<<-l)-1,y>>=-l,l+=a;l>0;s=s*256+t[e+f],f+=d,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=n;l>0;o=o*256+t[e+f],f+=d,l-=8);if(s===0)s=1-h;else{if(s===u)return o?NaN:(y?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-h}return(y?-1:1)*o*Math.pow(2,s-n)};Lt.write=function(t,e,r,n,i,s){var o,a,u,h=s*8-i-1,l=(1<<h)-1,f=l>>1,d=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=n?0:s-1,g=n?1:-1,A=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+f>=1?e+=d/u:e+=d*Math.pow(2,1-f),e*u>=2&&(o++,u/=2),o+f>=l?(a=0,o=l):o+f>=1?(a=(e*u-1)*Math.pow(2,i),o=o+f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+y]=a&255,y+=g,a/=256,i-=8);for(o=o<<i|a,h+=i;h>0;t[r+y]=o&255,y+=g,o/=256,h-=8);t[r+y-g]|=A*128}});var ei=E(fe=>{"use strict";var jt=$n(),ce=vn(),qn=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;fe.Buffer=c;fe.SlowBuffer=Ya;fe.INSPECT_MAX_BYTES=50;var je=2147483647;fe.kMaxLength=je;c.TYPED_ARRAY_SUPPORT=za();!c.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function za(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}});Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function L(t){if(t>je)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,c.prototype),e}function c(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Wt(t)}return Ln(t,e,r)}c.poolSize=8192;function Ln(t,e,r){if(typeof t=="string")return Va(t,e);if(ArrayBuffer.isView(t))return Xa(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(q(t,ArrayBuffer)||t&&q(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(q(t,SharedArrayBuffer)||t&&q(t.buffer,SharedArrayBuffer)))return Gt(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return c.from(n,e,r);let i=Ja(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return c.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}c.from=function(t,e,r){return Ln(t,e,r)};Object.setPrototypeOf(c.prototype,Uint8Array.prototype);Object.setPrototypeOf(c,Uint8Array);function jn(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function Wa(t,e,r){return jn(t),t<=0?L(t):e!==void 0?typeof r=="string"?L(t).fill(e,r):L(t).fill(e):L(t)}c.alloc=function(t,e,r){return Wa(t,e,r)};function Wt(t){return jn(t),L(t<0?0:Vt(t)|0)}c.allocUnsafe=function(t){return Wt(t)};c.allocUnsafeSlow=function(t){return Wt(t)};function Va(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!c.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=Kn(t,e)|0,n=L(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Kt(t){let e=t.length<0?0:Vt(t.length)|0,r=L(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function Xa(t){if(q(t,Uint8Array)){let e=new Uint8Array(t);return Gt(e.buffer,e.byteOffset,e.byteLength)}return Kt(t)}function Gt(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,c.prototype),n}function Ja(t){if(c.isBuffer(t)){let e=Vt(t.length)|0,r=L(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Jt(t.length)?L(0):Kt(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Kt(t.data)}function Vt(t){if(t>=je)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+je.toString(16)+" bytes");return t|0}function Ya(t){return+t!=t&&(t=0),c.alloc(+t)}c.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==c.prototype};c.compare=function(e,r){if(q(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),q(r,Uint8Array)&&(r=c.from(r,r.offset,r.byteLength)),!c.isBuffer(e)||!c.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==r[s]){n=e[s],i=r[s];break}return n<i?-1:i<n?1:0};c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};c.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return c.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=c.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){let o=e[n];if(q(o,Uint8Array))s+o.length>i.length?(c.isBuffer(o)||(o=c.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(c.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function Kn(t,e){if(c.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||q(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return zt(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Qn(t).length;default:if(i)return n?-1:zt(t).length;e=(""+e).toLowerCase(),i=!0}}c.byteLength=Kn;function Za(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return uu(this,e,r);case"utf8":case"utf-8":return zn(this,e,r);case"ascii":return ou(this,e,r);case"latin1":case"binary":return au(this,e,r);case"base64":return iu(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return cu(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}c.prototype._isBuffer=!0;function ne(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}c.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)ne(this,r,r+1);return this};c.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)ne(this,r,r+3),ne(this,r+1,r+2);return this};c.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)ne(this,r,r+7),ne(this,r+1,r+6),ne(this,r+2,r+5),ne(this,r+3,r+4);return this};c.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?zn(this,0,e):Za.apply(this,arguments)};c.prototype.toLocaleString=c.prototype.toString;c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:c.compare(this,e)===0};c.prototype.inspect=function(){let e="",r=fe.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};qn&&(c.prototype[qn]=c.prototype.inspect);c.prototype.compare=function(e,r,n,i,s){if(q(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;let o=s-i,a=n-r,u=Math.min(o,a),h=this.slice(i,s),l=e.slice(r,n);for(let f=0;f<u;++f)if(h[f]!==l[f]){o=h[f],a=l[f];break}return o<a?-1:a<o?1:0};function Gn(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Jt(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=c.from(e,n)),c.isBuffer(e))return e.length===0?-1:Mn(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):Mn(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Mn(t,e,r,n,i){let s=1,o=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;s=2,o/=2,a/=2,r/=2}function u(l,f){return s===1?l[f]:l.readUInt16BE(f*s)}let h;if(i){let l=-1;for(h=r;h<o;h++)if(u(t,h)===u(e,l===-1?0:h-l)){if(l===-1&&(l=h),h-l+1===a)return l*s}else l!==-1&&(h-=h-l),l=-1}else for(r+a>o&&(r=o-a),h=r;h>=0;h--){let l=!0;for(let f=0;f<a;f++)if(u(t,h+f)!==u(e,f)){l=!1;break}if(l)return h}return-1}c.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};c.prototype.indexOf=function(e,r,n){return Gn(this,e,r,n,!0)};c.prototype.lastIndexOf=function(e,r,n){return Gn(this,e,r,n,!1)};function Qa(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let a=parseInt(e.substr(o*2,2),16);if(Jt(a))return o;t[r+o]=a}return o}function eu(t,e,r,n){return Ke(zt(e,t.length-r),t,r,n)}function tu(t,e,r,n){return Ke(pu(e),t,r,n)}function ru(t,e,r,n){return Ke(Qn(e),t,r,n)}function nu(t,e,r,n){return Ke(du(e,t.length-r),t,r,n)}c.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-r;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return Qa(this,e,r,n);case"utf8":case"utf-8":return eu(this,e,r,n);case"ascii":case"latin1":case"binary":return tu(this,e,r,n);case"base64":return ru(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return nu(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function iu(t,e,r){return e===0&&r===t.length?jt.fromByteArray(t):jt.fromByteArray(t.slice(e,r))}function zn(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let s=t[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){let u,h,l,f;switch(a){case 1:s<128&&(o=s);break;case 2:u=t[i+1],(u&192)===128&&(f=(s&31)<<6|u&63,f>127&&(o=f));break;case 3:u=t[i+1],h=t[i+2],(u&192)===128&&(h&192)===128&&(f=(s&15)<<12|(u&63)<<6|h&63,f>2047&&(f<55296||f>57343)&&(o=f));break;case 4:u=t[i+1],h=t[i+2],l=t[i+3],(u&192)===128&&(h&192)===128&&(l&192)===128&&(f=(s&15)<<18|(u&63)<<12|(h&63)<<6|l&63,f>65535&&f<1114112&&(o=f))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return su(n)}var Hn=4096;function su(t){let e=t.length;if(e<=Hn)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Hn));return r}function ou(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function au(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function uu(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let s=e;s<r;++s)i+=yu[t[s]];return i}function cu(t,e,r){let n=t.slice(e,r),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}c.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,c.prototype),i};function B(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||B(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return i};c.prototype.readUintBE=c.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||B(e,r,this.length);let i=this[e+--r],s=1;for(;r>0&&(s*=256);)i+=this[e+--r]*s;return i};c.prototype.readUint8=c.prototype.readUInt8=function(e,r){return e=e>>>0,r||B(e,1,this.length),this[e]};c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||B(e,2,this.length),this[e]|this[e+1]<<8};c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||B(e,2,this.length),this[e]<<8|this[e+1]};c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||B(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||B(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};c.prototype.readBigUInt64LE=G(function(e){e=e>>>0,he(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Te(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});c.prototype.readBigUInt64BE=G(function(e){e=e>>>0,he(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Te(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});c.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||B(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};c.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||B(e,r,this.length);let i=r,s=1,o=this[e+--i];for(;i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};c.prototype.readInt8=function(e,r){return e=e>>>0,r||B(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};c.prototype.readInt16LE=function(e,r){e=e>>>0,r||B(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};c.prototype.readInt16BE=function(e,r){e=e>>>0,r||B(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};c.prototype.readInt32LE=function(e,r){return e=e>>>0,r||B(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};c.prototype.readInt32BE=function(e,r){return e=e>>>0,r||B(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};c.prototype.readBigInt64LE=G(function(e){e=e>>>0,he(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Te(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});c.prototype.readBigInt64BE=G(function(e){e=e>>>0,he(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Te(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});c.prototype.readFloatLE=function(e,r){return e=e>>>0,r||B(e,4,this.length),ce.read(this,e,!0,23,4)};c.prototype.readFloatBE=function(e,r){return e=e>>>0,r||B(e,4,this.length),ce.read(this,e,!1,23,4)};c.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||B(e,8,this.length),ce.read(this,e,!0,52,8)};c.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||B(e,8,this.length),ce.read(this,e,!1,52,8)};function F(t,e,r,n,i,s){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;F(this,e,r,n,a,0)}let s=1,o=0;for(this[r]=e&255;++o<n&&(s*=256);)this[r+o]=e/s&255;return r+n};c.prototype.writeUintBE=c.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;F(this,e,r,n,a,0)}let s=n-1,o=1;for(this[r+s]=e&255;--s>=0&&(o*=256);)this[r+s]=e/o&255;return r+n};c.prototype.writeUint8=c.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||F(this,e,r,1,255,0),this[r]=e&255,r+1};c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||F(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||F(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||F(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||F(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function Wn(t,e,r,n,i){Zn(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,r}function Vn(t,e,r,n,i){Zn(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s=s>>8,t[r+6]=s,s=s>>8,t[r+5]=s,s=s>>8,t[r+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=o,o=o>>8,t[r+2]=o,o=o>>8,t[r+1]=o,o=o>>8,t[r]=o,r+8}c.prototype.writeBigUInt64LE=G(function(e,r=0){return Wn(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeBigUInt64BE=G(function(e,r=0){return Vn(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});c.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let u=Math.pow(2,8*n-1);F(this,e,r,n,u-1,-u)}let s=0,o=1,a=0;for(this[r]=e&255;++s<n&&(o*=256);)e<0&&a===0&&this[r+s-1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};c.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let u=Math.pow(2,8*n-1);F(this,e,r,n,u-1,-u)}let s=n-1,o=1,a=0;for(this[r+s]=e&255;--s>=0&&(o*=256);)e<0&&a===0&&this[r+s+1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};c.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||F(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};c.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||F(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};c.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||F(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};c.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||F(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};c.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||F(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};c.prototype.writeBigInt64LE=G(function(e,r=0){return Wn(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});c.prototype.writeBigInt64BE=G(function(e,r=0){return Vn(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Xn(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Jn(t,e,r,n,i){return e=+e,r=r>>>0,i||Xn(t,e,r,4,34028234663852886e22,-34028234663852886e22),ce.write(t,e,r,n,23,4),r+4}c.prototype.writeFloatLE=function(e,r,n){return Jn(this,e,r,!0,n)};c.prototype.writeFloatBE=function(e,r,n){return Jn(this,e,r,!1,n)};function Yn(t,e,r,n,i){return e=+e,r=r>>>0,i||Xn(t,e,r,8,17976931348623157e292,-17976931348623157e292),ce.write(t,e,r,n,52,8),r+8}c.prototype.writeDoubleLE=function(e,r,n){return Yn(this,e,r,!0,n)};c.prototype.writeDoubleBE=function(e,r,n){return Yn(this,e,r,!1,n)};c.prototype.copy=function(e,r,n,i){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let s=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),s};c.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!c.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let s;if(typeof e=="number")for(s=r;s<n;++s)this[s]=e;else{let o=c.isBuffer(e)?e:c.from(e,i),a=o.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=o[s%a]}return this};var ue={};function Xt(t,e,r){ue[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}Xt("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Xt("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Xt("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=Dn(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Dn(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Dn(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function hu(t,e,r){he(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Te(e,t.length-(r+1))}function Zn(t,e,r,n,i,s){if(t>r||t<e){let o=typeof e=="bigint"?"n":"",a;throw s>3?e===0||e===BigInt(0)?a=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:a=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:a=`>= ${e}${o} and <= ${r}${o}`,new ue.ERR_OUT_OF_RANGE("value",a,t)}hu(n,i,s)}function he(t,e){if(typeof t!="number")throw new ue.ERR_INVALID_ARG_TYPE(e,"number",t)}function Te(t,e,r){throw Math.floor(t)!==t?(he(t,r),new ue.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new ue.ERR_BUFFER_OUT_OF_BOUNDS:new ue.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var fu=/[^+/0-9A-Za-z-_]/g;function lu(t){if(t=t.split("=")[0],t=t.trim().replace(fu,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function zt(t,e){e=e||1/0;let r,n=t.length,i=null,s=[];for(let o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function pu(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function du(t,e){let r,n,i,s=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function Qn(t){return jt.toByteArray(lu(t))}function Ke(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function q(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Jt(t){return t!==t}var yu=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function G(t){return typeof BigInt>"u"?mu:t}function mu(){throw new Error("BigInt not supported")}});var ii=C(hr());var Tr=C(H()),bs={get:Tr.default};function nt(t){t.status=401,t.body="Unauthorized",t.set("WWW-Authenticate","Basic")}function it(t){return async(e,r)=>{if(e.request.path===t.logoutPath)return nt(e);let n=bs.get(e,"request.headers.authorization");if(!n||!n.startsWith("Basic "))return nt(e);let i=t.users.map(a=>a.authToken),s=n.substring(6),o=i.indexOf(s);return o===-1?nt(e):(e.state.user=t.users[o].username,r(e))}}var Br=caches.default;async function Cs(t){return await Br.match(t)}async function Ts(t,e){return Br.put(t.href,e)}var st={get:Cs,set:Ts};async function Bs(t){let e=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(r)).map(s=>s.toString(16).padStart(2,"0")).join("")}var Ir=Bs;function Is(t,e={}){return Object.keys(e).reduce((r,n)=>r.replace(`{${n}}`,e[n]),t)}function ot(t){return[...t].reduce((e,r)=>{let n={};return n[r[0]]=r[1],{...e,...n}},{})}var T={resolveParams:Is,instanceToJson:ot};var xs=["x-ratelimit-count","x-ratelimit-limit","x-ratelimit-reset","x-cache-hit"];async function Us(t){return["POST","PATCH"].indexOf(t.method)===-1?null:t.text()}async function Fs(t,e){if(!e)return t.event.request;let r=e.match(/{.*?}/gi).map(s=>s.slice(1,-1)),n={};for(let s=0;s<r.length;s+=1){let o=r[s],a=o.split(":");switch(a[0]){case"method":n[o]=t.request.method;break;case"path":n[o]=t.request.path;break;case"bodyHash":n[o]=await Ir(await Us(t.request));break;case"header":n[o]=t.request.headers[a[1]]||"";break;default:n[o]=o}}let i=encodeURIComponent(e.replace(/({(.*?)})/gi,(s,o,a)=>n[a]));return new Request(`http://${t.request.hostname}/${i}`)}function at({cacheDuration:t,cacheKeyTemplate:e,headerBlacklist:r=xs}){return async(n,i)=>{let s=await Fs(n,e),o=await st.get(s);if(o){n.body=o.body,n.status=o.status;let a=ot(o.headers);Object.keys(a).forEach(u=>{n.set(u,a[u])}),n.set("X-Cache-Hit",!0)}else{await i(n);let a;n.body.tee?[n.body,a]=n.body.tee():a=n.body;let u=new Response(a,{status:n.status});Object.keys(n.response.headers).forEach(h=>{r.indexOf(h.toLowerCase())===-1&&u.headers.set(h,n.response.headers[h])}),t&&(u.headers.delete("Cache-Control"),u.headers.set("Cache-Control",`max-age=${t}`)),n.event.waitUntil(st.set(s,u))}}}function ut({allowedOrigins:t=["*"],allowedMethods:e=["GET","PUT","POST","PATCH","DELETE","HEAD","OPTIONS"],allowCredentials:r=!0,allowedHeaders:n=["Content-Type"],allowedExposeHeaders:i=["WWW-Authenticate","Server-Authorization"],maxAge:s=600,optionsSuccessStatus:o=204,terminatePreflight:a=!1}){return async(u,h)=>{let{method:l}=u.request,{origin:f}=u.request.headers,d=u.request.headers["access-control-request-headers"];if(_s(u,f,t),Rs(u,r),Ps(u,i),l==="OPTIONS"&&(Os(u,e),ks(u,d,n),Ns(u,s),a)){u.status=o,u.set("Content-Length","0"),u.body="";return}await h(u)}}function _s(t,e,r){Array.isArray(r)&&(r[0]==="*"?t.set("Access-Control-Allow-Origin","*"):r.indexOf(e)!==-1&&(t.set("Access-Control-Allow-Origin",e),t.set("Vary","Origin")))}function Rs(t,e){e&&t.set("Access-Control-Allow-Credentials",e)}function Os(t,e){t.set("Access-Control-Allow-Methods",e.join(","))}function ks(t,e,r){r.length===0&&e?t.set("Access-Control-Allow-Headers",e):r.length&&t.set("Access-Control-Allow-Headers",r.join(","))}function Ns(t,e){e&&t.set("Access-Control-Max-Age",e)}function Ps(t,e){e.length&&t.set("Access-Control-Expose-Headers",e.join(","))}var $s={AF:"AS",AL:"EU",AQ:"AN",DZ:"AF",AS:"OC",AD:"EU",AO:"AF",AG:"NA",AZ:"EU",AR:"SA",AU:"OC",AT:"EU",BS:"NA",BH:"AS",BD:"AS",AM:"EU",BB:"NA",BE:"EU",BM:"NA",BT:"AS",BO:"SA",BA:"EU",BW:"AF",BV:"AN",BR:"SA",BZ:"NA",IO:"AS",SB:"OC",VG:"NA",BN:"AS",BG:"EU",MM:"AS",BI:"AF",BY:"EU",KH:"AS",CM:"AF",CA:"NA",CV:"AF",KY:"NA",CF:"AF",LK:"AS",TD:"AF",CL:"SA",CN:"AS",TW:"AS",CX:"AS",CC:"AS",CO:"SA",KM:"AF",YT:"AF",CG:"AF",CD:"AF",CK:"OC",CR:"NA",HR:"EU",CU:"NA",CY:"EU",CZ:"EU",BJ:"AF",DK:"EU",DM:"NA",DO:"NA",EC:"SA",SV:"NA",GQ:"AF",ET:"AF",ER:"AF",EE:"EU",FO:"EU",FK:"SA",GS:"AN",FJ:"OC",FI:"EU",AX:"EU",FR:"EU",GF:"SA",PF:"OC",TF:"AN",DJ:"AF",GA:"AF",GE:"EU",GM:"AF",PS:"AS",DE:"EU",GH:"AF",GI:"EU",KI:"OC",GR:"EU",GL:"NA",GD:"NA",GP:"NA",GU:"OC",GT:"NA",GN:"AF",GY:"SA",HT:"NA",HM:"AN",VA:"EU",HN:"NA",HK:"AS",HU:"EU",IS:"EU",IN:"AS",ID:"AS",IR:"AS",IQ:"AS",IE:"EU",IL:"AS",IT:"EU",CI:"AF",JM:"NA",JP:"AS",KZ:"EU",JO:"AS",KE:"AF",KP:"AS",KR:"AS",KW:"AS",KG:"AS",LA:"AS",LB:"AS",LS:"AF",LV:"EU",LR:"AF",LY:"AF",LI:"EU",LT:"EU",LU:"EU",MO:"AS",MG:"AF",MW:"AF",MY:"AS",MV:"AS",ML:"AF",MT:"EU",MQ:"NA",MR:"AF",MU:"AF",MX:"NA",MC:"EU",MN:"AS",MD:"EU",ME:"EU",MS:"NA",MA:"AF",MZ:"AF",OM:"AS",NA:"AF",NR:"OC",NP:"AS",NL:"EU",AN:"NA",CW:"NA",AW:"NA",SX:"NA",BQ:"NA",NC:"OC",VU:"OC",NZ:"OC",NI:"NA",NE:"AF",NG:"AF",NU:"OC",NF:"OC",NO:"EU",MP:"OC",UM:"OC",FM:"OC",MH:"OC",PW:"OC",PK:"AS",PA:"NA",PG:"OC",PY:"SA",PE:"SA",PH:"AS",PN:"OC",PL:"EU",PT:"EU",GW:"AF",TL:"AS",PR:"NA",QA:"AS",RE:"AF",RO:"EU",RU:"EU",RW:"AF",BL:"NA",SH:"AF",KN:"NA",AI:"NA",LC:"NA",MF:"NA",PM:"NA",VC:"NA",SM:"EU",ST:"AF",SA:"AS",SN:"AF",RS:"EU",SC:"AF",SL:"AF",SG:"AS",SK:"EU",VN:"AS",SI:"EU",SO:"AF",ZA:"AF",ZW:"AF",ES:"EU",SS:"AF",EH:"AF",SD:"AF",SR:"SA",SJ:"EU",SZ:"AF",SE:"EU",CH:"EU",SY:"AS",TJ:"AS",TH:"AS",TG:"AF",TK:"OC",TO:"OC",TT:"NA",AE:"AS",TN:"AF",TR:"EU",TM:"AS",TC:"NA",TV:"OC",UG:"AF",UA:"EU",MK:"EU",EG:"AF",GB:"EU",GG:"EU",JE:"EU",IM:"EU",TZ:"AF",US:"NA",VI:"NA",BF:"AF",UY:"SA",UZ:"AS",VE:"SA",WF:"OC",WS:"OC",YE:"AS",ZM:"AF",XX:"XX"};function ct(){return async(t,e)=>{let r=t.request.headers["cf-ipcountry"]||"XX";t.request.headers["proxy-continent"]=$s[r],await e(t)}}function vs(t){let e=t.split("."),r=JSON.parse(atob(e[0])),n=JSON.parse(atob(e[1])),i=atob(e[2].replace(/-/g,"+").replace(/_/g,"/"));return{header:r,payload:n,signature:i,raw:{header:e[0],payload:e[1],signature:e[2]}}}function ht({jwksUri:t,allowPublicAccess:e=!1}){async function r(){return(await(await fetch(t)).json()).keys}async function n(s){let a=new TextEncoder().encode([s.raw.header,s.raw.payload].join(".")),u=new Uint8Array(Array.from(s.signature).map(f=>f.charCodeAt(0))),h=await r();return(await Promise.all(h.map(async f=>{let d=await crypto.subtle.importKey("jwk",f,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]);return crypto.subtle.verify("RSASSA-PKCS1-v1_5",d,u,a)}))).some(f=>f)}async function i(s,o){if(s.request.method==="OPTIONS")return o(s);if((s.request.headers.authorization||"").toLowerCase().startsWith("bearer")){let u=vs(s.request.headers.authorization.slice(7)),h=new Date(u.payload.exp*1e3),l=new Date(Date.now());if(h<=l)return!1;if(await n(u))return s.state.user=u.payload,o(s)}return e?o(s):(s.status=403,s.body="Forbidden",s)}return i}var xr=C(H()),qs={get:xr.default},J=class{constructor({accountId:e,namespace:r,authEmail:n,authKey:i,ttl:s}){this.accountId=e,this.namespace=r,this.authEmail=n,this.authKey=i,this.ttl=s}getNamespaceUrl(){return new URL(`https://api.cloudflare.com/client/v4/accounts/${this.accountId}/storage/kv/namespaces/${this.namespace}`)}getUrlForKey(e){return new URL(`${this.getNamespaceUrl()}/values/${e}`)}async list(e,r=10){let n=`${this.getNamespaceUrl()}/keys?prefix=${e}&limit=${r}`,i=await fetch(n,{headers:{"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey}});return i.ok?i.json():null}async get(e,r){let n=this.getUrlForKey(e),i=await fetch(n,{headers:{"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey}});if(i.ok)switch(r){case"json":return i.json();case"stream":return i;case"arrayBuffer":return i.arrayBuffer();default:return i.text()}return null}async getWithMetadata(e,r){let[n,i]=await Promise.all([this.get(e,r),this.list(e)]),s=qs.get(i,"result.0.metadata",{});return{value:n,metadata:s}}async put(e,r,n={}){let i=this.getUrlForKey(e),s=new URLSearchParams;this.ttl&&s.append("expiration_ttl",this.ttl.toString());let o={"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey};i.search=s.toString();let a=new FormData;return a.append("value",r),a.append("metadata",JSON.stringify(n)),(await fetch(i.toString(),{method:"PUT",headers:o,body:r})).ok}async delete(e){let r=this.getUrlForKey(e);return fetch(r,{method:"DELETE",headers:{"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey}})}};var N={methodsMethodsWithBody:["POST","PUT","PATCH"],http:{statusMessages:{404:"Not Found"}},mime:{css:"text/css",csv:"text/csv",html:"text/html",ico:"image/microsoft.vnd.icon",jpeg:"image/jpeg",js:"application/javascript",json:"application/json",png:"image/png",svg:"image/svg+xml",xml:"application/xml"}};function Ms(t,e,r){if(t==="/"&&r)return r;let n=t.split("/").pop();return n.split(".").pop()!==n?t:`${t}.${e}`}function ft({kvAccountId:t,kvNamespace:e,kvAuthEmail:r,kvAuthKey:n,kvBasePath:i="",kvKey:s="{file}",defaultExtension:o="html",defaultIndexDocument:a,defaultErrorDocument:u,mime:h={},mode:l="rest"}){let f=new J({accountId:t,namespace:e,authEmail:r,authKey:n,mode:l}),d={...N.mime,...h};return async y=>{let g=T.resolveParams(s,y.params),A=g===""&&a?a:Ms(g,o),m=await f.get(i+A);!m&&u&&(m=await f.get(i+u)),m?(y.status=200,y.body=m,y.set("Content-Type",d[A.split(".").pop()]||"text/plain")):(y.status=404,y.body=N.http.statusMessages[404],y.set("Content-Type","text/plain"))}}var Ur=C(H());var lt={get:Ur.default};function Hs(t,e,r){if(t==="/"&&r)return r;let n=t.split("/").pop();return n.split(".").pop()!==n?t:`${t}.${e}`}function Ds(t,e){let r=lt.get(t,"headers.if-none-match"),n=lt.get(e,"metadata.headers.etag");return r?r===n:!1}function pt({kvNamespaceBinding:t,kvBasePath:e="",kvKey:r="{file}",defaultExtension:n="html",defaultIndexDocument:i,defaultErrorDocument:s}){async function o(a){return await global[t].getWithMetadata(a)}return async a=>{let u=T.resolveParams(r,a.params),h=u===""&&i?i:Hs(u,n),l=await o(e+h);if(!l&&s&&(l=await o(e+s)),l)if(Ds(a.request,l))a.status=304;else{a.status=l.status,a.body=l.value;let f=lt.get(l,"metadata.headers",{});Object.keys(f).forEach(d=>{a.set(d,f[d])})}else a.status=404,a.body=N.http.statusMessages[404],a.set("Content-Type","text/plain")}}var _r=C(Re());function dt({accessKeyId:t,secretAccessKey:e,region:r,lambdaName:n}){let i=new _r.AwsClient({accessKeyId:t,secretAccessKey:e});return async s=>{let o=`https://lambda.${r}.amazonaws.com/2015-03-31/functions/${n}/invocations`,a={},u=await i.fetch(o,{body:JSON.stringify(a)});s.status=u.status,s.body=u.body;let h=T.instanceToJson(u.headers);Object.keys(h).forEach(l=>{s.set(l,h[l])})}}var Gr=C(H()),zr=C($e());var Kr={get:Gr.default,set:zr.default};function Lo(t){let e={};return Object.keys(t).forEach(r=>{r.startsWith("cf")||(e[r]=t[r])}),e}function jo(t){return t[Math.floor(Math.random()*t.length)]}function At({sources:t=[]}){return async e=>{let r=jo(t),n={method:e.request.method,headers:Lo(e.request.headers),redirect:"manual",cf:e.request.cf};if(N.methodsMethodsWithBody.indexOf(e.request.method)!==-1&&Kr.get(e,"event.request.body")){let a=e.event.request.clone();n.body=a.body}let i=T.resolveParams(r.url,e.params);if(r.resolveOverride){let a=T.resolveParams(r.resolveOverride,e.request.params);Kr.set(n,"cf.resolveOverride",a)}let s=await fetch(i+e.request.search,n);e.body=s.body,e.status=s.status;let o=T.instanceToJson(s.headers);Object.keys(o).forEach(a=>{e.set(a,o[a])})}}var Xr=C(H());var Et={name:"@ahmadissa/cloudworker-proxy",version:"1.0.24",description:"An api gateway for cloudflare workers",license:"MIT",repository:{type:"git",url:"git+https://github.com/ahmadissa/cloudworker-proxy.git"},bugs:{url:"https://github.com/ahmadissa/cloudworker-proxy/issues"},homepage:"https://github.com/ahmadissa/cloudworker-proxy#readme",author:"Markus Ahlstrand",keywords:["cloudflare","workers","api","gateway","proxy"],main:"dist/index.js",files:["dist/**"],scripts:{build:"esbuild --bundle src/index.ts --format=cjs --outdir=dist --sourcemap --minify",lint:"eslint src",package:"bun install; npm run build",test:"npm run unit && npm run lint","test:integration":"node integration/run.js",unit:"bun test","semantic-release":"semantic-release",prepare:"husky install"},release:{branches:["master"],plugins:["@semantic-release/commit-analyzer","@semantic-release/release-notes-generator",["@semantic-release/npm",{npmPublish:!1}],["@semantic-release/git",{assets:["docs","package.json"],message:"chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"}]]},dependencies:{aws4fetch:"1.0.13","cloudworker-router":"1.11.2",cookie:"0.4.1","lodash.get":"4.4.2","lodash.set":"4.3.2",shortid:"2.2.16"},devDependencies:{"@semantic-release/git":"^10.0.1","@types/jest":"^29.5.5","@types/mocha":"^10.0.1","@types/node":"^20.5.9","@typescript-eslint/eslint-plugin":"^6.6.0","@typescript-eslint/parser":"^6.6.0",bun:"1.0.3",dotenv:"8.2.0",esbuild:"^0.19.2",eslint:"7.13.0","eslint-config-airbnb-base":"14.2.1","eslint-config-prettier":"6.15.0","eslint-plugin-import":"2.22.1","eslint-plugin-prettier":"3.1.4","fetch-mock":"9.11.0",husky:"^8.0.3","node-fetch":"2.6.1",prettier:"2.1.2","semantic-release":"^22.0.4",typescript:"^5.2.2",wrangler:"^3.7.0"},directories:{example:"examples",test:"test"}};var Q=class{constructor({maxSize:e=10,maxSeconds:r=10,sink:n}){this.maxSize=e,this.maxSeconds=r,this.queue=[],this.sink=n,this.flushing=!1,this.timer=null}async push(e){return this.queue.push(e),this.queue.length>this.maxSize?this.flush():(this.timer||(this.timer=new Promise((r,n)=>{this.resolveTimer=r,this.rejectTimer=n,this.cancelationToken=setTimeout(async()=>{try{r(await this.flush())}catch(i){n(i)}},this.maxSeconds*1e3)})),this.timer)}async flush(){if(!this.flushing){this.flushing=!0;try{let e=this.queue.join(`
|
|
6
|
+
`);this.queue=[];let r=await this.sink(e);this.timer&&(clearTimeout(this.cancelationToken),this.resolveTimer(r))}catch(e){this.timer&&this.rejectTimer(e)}finally{this.timer=null,this.flushing=!1}}}};function Wr(t,e=".",r=""){return t instanceof Object?Object.keys(t).reduce((n,i)=>t[i]==null?n:{...n,...Wr(t[i],e,r+i+e)},{}):r.endsWith(e)?{[r.slice(0,r.length-1)]:t}:{[r]:t}}var ve=Wr;var Ae=class{constructor(e){this.url=e.url,this.contentType=e.contentType,this.delimiter=e.delimiter,this.chunker=new Q({sink:this.sendMessage.bind(this),...e})}async log(e){let r=ve(e,this.delimiter);await this.chunker.push(JSON.stringify(r))}async sendMessage(e){return fetch(this.url,{body:e,method:"POST",headers:{"Content-Type":this.contentType}})}};var Vr=C(Re());var Ee=class{constructor(e){this.delimiter=e.delimiter,this.chunker=new Q({sink:this.sendMessage.bind(this),...e}),this.awsClient=new Vr.AwsClient({accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,region:e.region}),this.streamName=e.streamName,this.region=e.region}async log(e){let r=ve(e,this.delimiter);await this.chunker.push(JSON.stringify(r))}async sendMessage(e){let r=btoa(`${JSON.stringify(e)}
|
|
7
|
+
`),n=JSON.stringify({DeliveryStreamName:this.streamName,Record:{Data:r}}),i=`https://firehose.${this.region}.amazonaws.com`,s=new Request(i,{method:"POST",body:n,headers:{"X-Amz-Target":"Firehose_20150804.PutRecord","Content-Type":" application/x-amz-json-1.1"}});return this.awsClient.fetch(s)}};var R={get:Xr.default};async function Go(t){return["POST","PATCH"].indexOf(t.method)===-1?null:t.text()}function St(t){let e;switch(t.type){case"http":e=new Ae(t);break;case"kinesis":e=new Ee(t);break;default:throw new Error(`Log service type not supported: ${t.type}`)}return async(r,n)=>{r.state["logger-startDate"]=new Date;let i=await Go(r.request);try{await n(r);let s={message:"START",requestIp:R.get(r,"request.headers.x-real-ip"),requestId:R.get(r,"request.requestId"),request:{headers:R.get(r,"request.headers"),method:R.get(r,"request.method"),url:R.get(r,"request.href"),protocol:R.get(r,"request.protocol"),body:i},response:{status:r.status,headers:R.get(r,"response.headers")},handlers:R.get(r,"state.handlers",[]).join(","),route:R.get(r,"route.name"),timestamp:new Date().toISOString(),ttfb:new Date-r.state["logger-startDate"],redirectUrl:r.userRedirect,severity:30,proxyVersion:Et.version};r.event.waitUntil(e.log(s))}catch(s){let o={request:{headers:R.get(r,"request.headers"),method:R.get(r,"request.method"),handlers:R.get(r,"state.handlers",[]).join(","),url:R.get(r,"request.href"),body:i},message:"ERROR",stack:s.stack,error:s.message,severity:50,proxyVersion:Et.version};r.event.waitUntil(e.log(o))}}}var Ce=C(Jr()),Bn=C(H()),In=C($e()),xn=C(Sn());async function Ut({refresh_token:t,authDomain:e,clientId:r,clientSecret:n}){let i=`${e}/oauth/token`,s=await fetch(i,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",client_id:r,client_secret:n,refresh_token:t})});if(!s.ok)throw new Error("Authentication failed");let o=await s.json();return{...o,expires:Date.now()+o.expires_in*1e3,refresh_token:t}}var bn="PBKDF2",Ft="AES-GCM",Aa="SHA-256",Ea="raw";function Sa(t){let e=atob(t.replace(/_/g,"/").replace(/-/g,"+")),r=e.length,n=new Uint8Array(r);for(let i=0;i<r;i+=1)n[i]=e.charCodeAt(i);return n.buffer}function Cn(t){let e="",r=new Uint8Array(t),n=r.byteLength;for(let i=0;i<n;i+=1)e+=String.fromCharCode(r[i]);return btoa(e).replace(/\//g,"_").replace(/\+/g,"-")}function ba(t){return String.fromCharCode.apply(null,new Uint16Array(t))}function Ca(t){let e=new ArrayBuffer(t.length*2),r=new Uint16Array(e);for(let n=0,i=t.length;n<i;n+=1)r[n]=t.charCodeAt(n);return e}async function Ta(t){let e=new TextEncoder;return crypto.subtle.importKey(Ea,e.encode(t),{name:bn},!1,["deriveKey"])}async function Ba(t,e){let r=await Ta(t),i=new TextEncoder().encode(e.replace(/_/g,"/").replace(/-/g,"+"));return crypto.subtle.deriveKey({name:bn,salt:i,iterations:1e3,hash:{name:Aa}},r,{name:Ft,length:256},!0,["encrypt","decrypt"])}async function Ia(){let t=crypto.getRandomValues(new Uint8Array(8));return Cn(t)}async function xa(t,e){let r=Sa(e),n=r.slice(0,16),i=r.slice(16),s=await crypto.subtle.decrypt({name:Ft,iv:n},t,i);return ba(s)}async function Ua(t,e){let r=crypto.getRandomValues(new Uint8Array(16)),n=await crypto.subtle.encrypt({name:Ft,iv:r},t,Ca(e)),i=new Uint8Array(n.byteLength+r.byteLength);return i.set(r,0),i.set(new Uint8Array(n),r.byteLength),Cn(i)}var te={decrypt:xa,deriveAesGcmKey:Ba,encrypt:Ua,getSalt:Ia};var ae={get:Bn.default,set:In.default};function Tn({cookieHeader:t="",cookieName:e}){return Ce.default.parse(t)[e]}function Fa(t){return Object.keys(t).map(e=>`${e}=${encodeURIComponent(t[e])}`).join("&")}function _a(t=""){return t.split(",").indexOf("text/html")!==-1}function _t({cookieName:t="proxy",cookieHttpOnly:e=!0,allowPublicAccess:r=!1,kvAccountId:n,kvNamespace:i,kvAuthEmail:s,kvAuthKey:o,kvTtl:a=2592e3,oauth2AuthDomain:u,oauth2ClientId:h,oauth2ClientSecret:l,oauth2Audience:f,oauth2Scopes:d=[],oauth2CallbackPath:y="/callback",oauth2CallbackType:g="cookie",oauth2LogoutPath:A="/logout",oauth2LoginPath:m="/login",oauth2ServerTokenPath:w="/oauth/token",oauth2ServerAuthorizePath:x="",oauth2ServerLogoutPath:O}){let _=new J({accountId:n,namespace:i,authEmail:s,authKey:o,ttl:a}),z=u,le=y,Ge=g,ze=w,Be=x,We=O,j=h,pe=l,P=f,Ie=A,S=m,ye=d.join("%20");async function xe(p,I){let b=`${z}${ze}`,U=await fetch(b,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:Fa({code:p,grant_type:"authorization_code",client_id:j,client_secret:pe,redirect_uri:I})});if(!U.ok)throw new Error("Authentication failed");let $=await U.json();return{...$,expires:Date.now()+$.expires_in*1e3}}async function si(p){if(Tn({cookieHeader:p.request.headers.cookie,cookieName:t})){let U=p.request.hostname.match(/[^.]+\.[^.]+$/i)[0];p.set("Set-Cookie",Ce.default.serialize(t,"",{domain:`.${U}`,path:"/",maxAge:0}))}let b=Zt(p);if(O){let U=encodeURIComponent(`${p.request.protocol}://${p.request.host}${b}`);p.set("Location",`${z}${We}?client_id=${j}&returnTo=${U}`)}else p.set("Location",b);p.status=302}async function oi(p){let I=p.request.href.split("?")[0],b=await xe(p.request.query.code,I),U=xn.default.generate(),$=await te.getSalt(),M=`${U}.${$}`,Ve=await te.deriveAesGcmKey(U,$),W=await te.encrypt(Ve,JSON.stringify(b));await _.put(U,W);let Xe=p.request.hostname.match(/[^.]+\.[^.]+$/i)[0];p.status=302,Ge==="query"?p.set("Location",`${p.request.query.state}?auth=${M}`):(p.set("Set-Cookie",Ce.default.serialize(t,M,{httpOnly:e,domain:`.${Xe}`,path:"/",maxAge:60*60*24*365})),p.set("Location",p.request.query.state))}async function ai(p,I){let[b,U]=I.split("."),$=await _.get(b);if($){let M=await te.deriveAesGcmKey(b,U),Ve=await te.decrypt(M,$),W=JSON.parse(Ve);if(W.expires<Date.now()){W=await Ut({refresh_token:W.refresh_token,clientId:j,authDomain:z,clientSecret:pe});let Xe=await te.encrypt(M,JSON.stringify(W));await _.put(b,Xe)}p.state.accessToken=W.access_token,p.state.accessToken&&(p.request.headers.authorization=`bearer ${p.state.accessToken}`)}else{let M=p.request.hostname.match(/[^.]+\.[^.]+$/i)[0];p.set("Set-Cookie",Ce.default.serialize(t,"",{domain:`.${M}`,maxAge:0}))}}function Zt(p){let I=ae.get(p,"request.query.redirect-to");if(I)return I;let b=ae.get(p,"request.headers.referer");return b||"/"}async function ui(p){if(p.request.method==="OPTIONS")p.status=200;else{let I=Zt(p),b=encodeURIComponent(I||"/"),U=encodeURIComponent(`${p.request.protocol}://${p.request.host}${le}`);p.status=302,p.set("location",`${z}${Be}/authorize?state=${b}&client_id=${j}&response_type=code&scope=${ye}&audience=${P}&redirect_uri=${U}`)}}async function ci(p,I){if(p.request.method==="OPTIONS")await I(p);else if(ae.get(p,"request.headers.authorization","").toLowerCase().startsWith("bearer "))ae.set(p,"state.access_token",p.request.headers.authorization.slice(7)),await I(p);else{let b=ae.get(p,"request.query.auth")||Tn({cookieHeader:p.request.headers.cookie,cookieName:t});if(b&&await ai(p,b),ae.get(p,"state.accessToken")||r)await I(p);else if(_a(p.request.headers.accept)){let $=encodeURIComponent(p.request.href),M=encodeURIComponent(`${p.request.protocol}://${p.request.host}${le}`);p.status=302,p.set("location",`${z}${Be}/authorize?state=${$}&client_id=${j}&response_type=code&scope=${ye}&audience=${P}&redirect_uri=${M}`)}else p.status=403,p.body="Forbidden"}}return async(p,I)=>{switch(p.request.path){case le:await oi(p);break;case Ie:await si(p);break;case S:await ui(p);break;default:await ci(p,I)}}}var Un=C(H());var Ra={get:Un.default};function Oa(t){let e={};return Object.keys(t).forEach(r=>{r.startsWith("cf")||(e[r]=t[r])}),e}function Rt(t){let{localOriginOverride:e,backend:r}=t;return async n=>{let i=process.env.LOCAL?`${e||n.request.origin}${n.request.path}`:`${r}${n.request.path}`,s={headers:Oa(n.request.headers),method:n.request.method,redirect:"manual"};if(N.methodsMethodsWithBody.indexOf(n.request.method)!==-1&&Ra.get(n,"event.request.body")){let u=n.event.request.clone();s.body=u.body}let o=await fetch(i,s);n.body=o.body,n.status=o.status;let a=T.instanceToJson(o.headers);Object.keys(a).forEach(u=>{n.set(u,a[u])})}}function Ot({body:t="",headers:e={},status:r=200}){return async n=>{t instanceof Object?(n.body=JSON.stringify(t),n.set("Content-Type","application/json")):n.body=T.resolveParams(t,n.params),n.status=r,Object.keys(e).forEach(i=>{n.set(i,T.resolveParams(e[i],n.params))})}}var Fn=C(H()),_n=C($e()),kt={get:Fn.default,set:_n.default};function Nt({type:t="IP",scope:e="default",limit:r=1e3}){let n={};function i(o,a){let u=a["x-real-ip"];return t==="IP"?`minute.${o}.${e}.${u}`:`minute.${o}.${e}.account`}function s(o){let a=kt.get(n,"minutes",{});Object.keys(a).forEach(u=>{u!==o&&delete n.minutes.minute})}return async(o,a)=>{let u=Math.trunc(Date.now()/6e4),h=Math.trunc(u*60+60-Date.now()/1e3),l=i(u,o.request.headers),f=kt.get(n,l,0);if(["HEAD","OPTIONS"].indexOf(o.request.method)===-1&&(f+=1),kt.set(n,l,f),r<f){o.status=429;return}s(u),await a(o)}}var Rn=C(Re());function ka(t,e={}){if(t&&e.forcePathStyle){let r=new URL(t);return`${r.protocol}//${r.host}/${e.bucket}`}if(t){let r=new URL(t);return`${r.protocol}//${e.bucket}.${r.host}`}return e.forcePathStyle&&e.region?`https://s3.${e.region}.amazonaws.com/${e.bucket}`:e.forcePathStyle?`https://s3.amazonaws.com/${e.bucket}`:e.region?`https://${e.bucket}.s3.${e.region}.amazonaws.com`:`https://${e.bucket}.s3.amazonaws.com`}function Pt({accessKeyId:t,secretAccessKey:e,bucket:r,region:n,endpoint:i,forcePathStyle:s,enableBucketOperations:o=!1}){let a=new Rn.AwsClient({accessKeyId:t,region:n,secretAccessKey:e}),u=ka(i,{region:n,bucket:r,forcePathStyle:s});return async h=>{if(h.params.file===void 0&&!o){h.status=404,h.body=N.http.statusMessages[404],h.set("Content-Type","text/plain");return}let l=h.params.file?T.resolveParams(`${u}/{file}`,h.params):u,f={};h.request.headers.range&&(f.range=h.request.headers.range);let d=await a.fetch(l,{method:h.method||h.request.method,headers:f});h.status=d.status,h.body=d.body;let y=T.instanceToJson(d.headers);Object.keys(y).forEach(g=>{h.set(g,y[g])})}}var $t;function On(t){return new Uint8Array(t.split("").map(r=>r.charCodeAt(0)))}async function Na(t){return $t||($t=await crypto.subtle.importKey("raw",On(t),{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign","verify"])),$t}async function Pa(t,e){let r=await Na(e),n=await crypto.subtle.sign({name:"HMAC"},r,On(t));return btoa(String.fromCharCode.apply(null,new Uint8Array(n))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function vt({secret:t}){return async(e,r)=>{let n=(e.request.path+e.request.search).replace(/([?|&]sign=[\w|-]+)/,"");if(await Pa(n,t)!==e.query.sign){e.status=403;return}await r(e)}}function qt({host:t}){if(!t)throw new Error("Need to specify a host for the split middleware.");return async(e,r)=>{let n=e.clone();n.cloned=!0,n.request={...n.request,href:n.request.href.replace(n.request.href,t),host:t},e.event.waitUntil(r(n)),await r(e)}}async function $a(t,e,r){let n=t.getReader(),i=e.getWriter(),s=new TextDecoder,o=new TextEncoder;for(;;){let{done:a,value:u}=await n.read();if(a)break;let h=s.decode(u),l=kn(h,r),f=o.encode(l);await i.write(f)}await i.close()}function va(t,e){return t.replace(/{{\$(\d)}}/g,(r,n)=>e[parseInt(n,10)])}function kn(t,e){return e.reduce((r,n)=>r.replace(n.regex,(...i)=>va(n.replace,i)),t)}function Mt({transforms:t=[],statusCodes:e=[200]}){let r=t.map(n=>({regex:new RegExp(n.regex,"g"),replace:n.replace}));return async(n,i)=>{await i(n);let{body:s}=n;if(e.indexOf(n.status)!==-1)if(typeof s=="string")n.body=kn(s,r);else{let{readable:o,writable:a}=new TransformStream;$a(s,a,r),n.body=o}}}async function qa({projectID:t="your-project-id",API_KEY:e="GCP_API_KEY",token:r="action-token",siteKey:n="siteKey",expectedAction:i="action-name"}){let o=await(await fetch(`https://recaptchaenterprise.googleapis.com/v1/projects/${t}/assessments?key=${e}`,{body:JSON.stringify({event:{token:r,siteKey:n,expectedAction:i}}),headers:{"Content-Type":"application/json"},method:"POST"})).json();return o.tokenProperties.valid?o.tokenProperties.action===i?(o.riskAnalysis.reasons.forEach(a=>{console.log(a)}),o.riskAnalysis.score):(console.error("The action attribute in your reCAPTCHA tag does not match the action you are expecting to score"),null):(console.error("The CreateAssessment call failed because the token was: "+o.tokenProperties.invalidReason),0)}function Ht({projectID:t,API_KEY:e,siteKey:r}){function n(i){return{token:i["g-recaptcha-token"],expectedAction:i["g-recaptcha-action"]}}return async(i,s)=>{let{token:o,expectedAction:a}=n(i.request.headers);if((await qa({projectID:t,API_KEY:e,token:o,siteKey:r,expectedAction:a})||0)<.5){i.status=409;return}await s(i)}}var ti=C(ei());var gu=t=>{if(typeof t!="string"||t===""||t.trim()==="")return!1;var e=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;return e.test(t)},wu=t=>(gu(t)&&(t=ti.Buffer.from(t,"base64").toString()),!new RegExp("(\b)(onS+)(s*)=|javascript|<(|/|[^/>][^>]+|/[^>][^>]+)>").test(t)),Au=(t,e,r)=>!(!wu(e)||!r[t](e));var Eu=t=>!(t===null||typeof t!="object"||Array.isArray(t)&&(!t[0]||typeof t[0]!="object")),ri=(t,e)=>{let r=Object.keys(t);for(let n of r){if(!e[n]&&isNaN(n))return!1;if(t[n]===null&&(t[n]=""),Eu(t[n])){if(!ri(t[n],e))return!1}else if(!Au(n,t[n],e))return!1}return!0},Su=t=>!(t==null||typeof t!="object"),bu=(t,e)=>{let r=t.query;return Su(r)?ri(r,e):!1};function Yt({allowedKeys:t}){return async(r,n)=>{if(!t){r.status=501;return}if(!bu(r,t)){r.status=422;return}await n(r)}}var ni={basicAuth:it,cache:at,cors:ut,geoDecorator:ct,jwt:ht,kvStorage:ft,kvStorageBinding:pt,lambda:dt,loadbalancer:At,logger:St,oauth2:_t,origin:Rt,rateLimit:Nt,response:Ot,s3:Pt,signature:vt,split:qt,transform:Mt,recaptcha:Ht,userInputValidation:Yt};module.exports=class{constructor(e=[],r={}){this.router=new ii.default,e.forEach(n=>{let i=r[n.handlerName]||ni[n.handlerName];if(!i)throw new Error(`Handler ${n.handlerName} is not supported`);this.router.add(n,i(n.options))})}async resolve(e){return this.router.resolve(e)}};
|
|
8
8
|
/*! Bundled license information:
|
|
9
9
|
|
|
10
10
|
aws4fetch/dist/aws4fetch.umd.js:
|
|
@@ -20,5 +20,16 @@ cookie/index.js:
|
|
|
20
20
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
21
21
|
* MIT Licensed
|
|
22
22
|
*)
|
|
23
|
+
|
|
24
|
+
ieee754/index.js:
|
|
25
|
+
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
26
|
+
|
|
27
|
+
buffer/index.js:
|
|
28
|
+
(*!
|
|
29
|
+
* The buffer module from node.js, for the browser.
|
|
30
|
+
*
|
|
31
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
32
|
+
* @license MIT
|
|
33
|
+
*)
|
|
23
34
|
*/
|
|
24
35
|
//# sourceMappingURL=index.js.map
|