@ahmadissa/cloudworker-proxy 1.1.22 → 1.1.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 +4 -4
- 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 Ao=Object.create;var fr=Object.defineProperty;var So=Object.getOwnPropertyDescriptor;var Eo=Object.getOwnPropertyNames;var bo=Object.getPrototypeOf,Co=Object.prototype.hasOwnProperty;var _=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var _o=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Eo(t))!Co.call(e,o)&&o!==r&&fr(e,o,{get:()=>t[o],enumerable:!(n=So(t,o))||n.enumerable});return e};var v=(e,t,r)=>(r=e!=null?Ao(bo(e)):{},_o(t||!e||!e.__esModule?fr(r,"default",{value:e,enumerable:!0}):r,e));var ht=_((Lc,mr)=>{function vo({host:e=".*",path:t=".*",excludePath:r=null,method:n=[".*"],handler:o,protocol:a=".*",handlerName:s,headers:i={},data:c}){let u=[],f=[],d=e.replace(/(:([^.]+))/g,(K,k,U)=>(u.push(U),"([^.]+)")),l=t.replace(/(:([^/]+))/g,(K,k,U)=>U.slice(-1)==="*"?(f.push(U.slice(0,U.length-1)),"(.*)"):(f.push(U),"([^/]*)")),h=new RegExp(`^${d}$`,"i"),y=new RegExp(`^${l}$`,"i"),w=r?new RegExp(`^${r}$`,"i"):null,m=new RegExp(`^${n.join("|")}$`,"i"),g=new RegExp(`^${a}$`,"i");return{hostVariables:u,pathVariables:f,host:h,path:y,excludePath:w,method:m,protocol:g,handler:o,handlerName:s,headers:i,data:c}}function lr(e){return[...e].reduce((t,r)=>{let n={};return n[r[0]]=r[1],{...t,...n}},{})}async function Po(e,t=1024*1024){let r=[],n=e.getReader(),o=new TextDecoder,a=0;for(;t&&a<t;){let{done:i,value:c}=await n.read();if(i)break;a+=c.byteLength,r.push(o.decode(c))}let s=r.join("");return t?s.substring(0,t):s}function Ho(e){let t=new URL(e.url),r=lr(t.searchParams),n=lr(e.headers);n.host&&(t.hostname=n.host);let o,a;async function s(i){if(a>=i)return o.substring(0,i);let c=e.clone();return o=await Po(c.body,i),o}return{body:e.body,headers:n,host:t.host,hostname:t.hostname,href:t.href,json:async i=>JSON.parse(s(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 s(i)):s(i)}}mr.exports={parseRoute:vo,parseRequest:Ho}});var gr=_((Bc,yr)=>{function Ko(e,t){let r={},n=t.host.exec(e.host);t.hostVariables.forEach((a,s)=>{r[a]=n[s+1]});let o=t.path.exec(e.path);return t.pathVariables.forEach((a,s)=>{r[a]=o[s+1]}),r}function To(e,t){let r=!0;return Object.keys(e.headers).forEach(n=>{t.headers[n]!==e.headers[n]&&(r=!1)}),r}function Oo(e,t){return e.protocol.test(t.protocol)}function xo(e,t){return e.method.test(t.method)&&e.host.test(t.host)&&e.path.test(t.path)&&To(e,t)&&Oo(e,t)&&(!e.excludePath||!e.excludePath.test(t.path))}async function ft(e,t){let[r,...n]=t;if(!r)return new Response("NOT_FOUND",{status:404});if(!xo(r,e.request))return ft(e,n);e.state.handlers=e.state.handlers||[],e.state.handlers.push(r.handlerName||r.handler.name),e.params=Ko(e.request,r);try{return r.handler(e,async o=>ft(o,n))}catch(o){throw o.route=r.handler.name,o}}yr.exports={recurseRoutes:ft}});var Ar=_((Gc,wr)=>{wr.exports={methods:{DELETE:"DELETE",GET:"GET",HEAD:"HEAD",OPTIONS:"OPTIONS",PATCH:"PATCH",POST:"POST"},statusMessages:{404:"Not found",429:"Rate limited"}}});var br=_((Vc,Er)=>{var Ro=ht();Er.exports=class Sr{constructor(t){this.request=Ro.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 Sr(this.event);return t.cloned=!0,t}}});var _r=_((Xc,Cr)=>{var ue=ht(),Uo=gr(),_e=Ar(),Io=br();Cr.exports=class{constructor(){this.routes=[]}get(t,r){let n=ue.parseRoute({method:[_e.methods.GET,_e.methods.HEAD],path:t,handler:r});this.routes.push(n)}post(t,r){let n=ue.parseRoute({method:[_e.methods.POST],path:t,handler:r});this.routes.push(n)}patch(t,r){let n=ue.parseRoute({method:[_e.methods.PATCH],path:t,handler:r});this.routes.push(n)}del(t,r){let n=ue.parseRoute({method:[_e.methods.DELETE],path:t,handler:r});this.routes.push(n)}use(t){let r=ue.parseRoute({handler:t,middleware:!0});this.routes.push(r)}add({host:t,path:r,excludePath:n,method:o,handlerName:a,headers:s,protocol:i},c){let u=ue.parseRoute({method:o,host:t,path:r,excludePath:n,handler:c,headers:s,handlerName:a,protocol:i});this.routes.push(u)}async resolve(t){let r=new Io(t);try{return await Uo.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 M=_((jc,Nr)=>{var Wo="Expected a function",Tr="__lodash_hash_undefined__",Or=1/0,Jo="[object Function]",No="[object GeneratorFunction]",ko="[object Symbol]",Do=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Mo=/^\w*$/,$o=/^\./,qo=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Fo=/[\\^$.*+?()[\]{}|]/g,Lo=/\\(\\)?/g,Bo=/^\[object .+?Constructor\]$/,Go=typeof global=="object"&&global&&global.Object===Object&&global,Vo=typeof self=="object"&&self&&self.Object===Object&&self,mt=Go||Vo||Function("return this")();function zo(e,t){return e?.[t]}function Xo(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var jo=Array.prototype,Yo=Function.prototype,xr=Object.prototype,lt=mt["__core-js_shared__"],vr=function(){var e=/[^.]+$/.exec(lt&<.keys&<.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Rr=Yo.toString,yt=xr.hasOwnProperty,Ur=xr.toString,Zo=RegExp("^"+Rr.call(yt).replace(Fo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Pr=mt.Symbol,Qo=jo.splice,ea=Ir(mt,"Map"),ve=Ir(Object,"create"),Hr=Pr?Pr.prototype:void 0,Kr=Hr?Hr.toString:void 0;function re(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function ta(){this.__data__=ve?ve(null):{}}function ra(e){return this.has(e)&&delete this.__data__[e]}function na(e){var t=this.__data__;if(ve){var r=t[e];return r===Tr?void 0:r}return yt.call(t,e)?t[e]:void 0}function oa(e){var t=this.__data__;return ve?t[e]!==void 0:yt.call(t,e)}function aa(e,t){var r=this.__data__;return r[e]=ve&&t===void 0?Tr:t,this}re.prototype.clear=ta;re.prototype.delete=ra;re.prototype.get=na;re.prototype.has=oa;re.prototype.set=aa;function pe(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function sa(){this.__data__=[]}function ia(e){var t=this.__data__,r=Me(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():Qo.call(t,r,1),!0}function ca(e){var t=this.__data__,r=Me(t,e);return r<0?void 0:t[r][1]}function da(e){return Me(this.__data__,e)>-1}function ua(e,t){var r=this.__data__,n=Me(r,e);return n<0?r.push([e,t]):r[n][1]=t,this}pe.prototype.clear=sa;pe.prototype.delete=ia;pe.prototype.get=ca;pe.prototype.has=da;pe.prototype.set=ua;function ne(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function pa(){this.__data__={hash:new re,map:new(ea||pe),string:new re}}function ha(e){return $e(this,e).delete(e)}function fa(e){return $e(this,e).get(e)}function la(e){return $e(this,e).has(e)}function ma(e,t){return $e(this,e).set(e,t),this}ne.prototype.clear=pa;ne.prototype.delete=ha;ne.prototype.get=fa;ne.prototype.has=la;ne.prototype.set=ma;function Me(e,t){for(var r=e.length;r--;)if(Pa(e[r][0],t))return r;return-1}function ya(e,t){t=Sa(t,e)?[t]:Aa(t);for(var r=0,n=t.length;e!=null&&r<n;)e=e[_a(t[r++])];return r&&r==n?e:void 0}function ga(e){if(!Jr(e)||ba(e))return!1;var t=Ha(e)||Xo(e)?Zo:Bo;return t.test(va(e))}function wa(e){if(typeof e=="string")return e;if(wt(e))return Kr?Kr.call(e):"";var t=e+"";return t=="0"&&1/e==-Or?"-0":t}function Aa(e){return Wr(e)?e:Ca(e)}function $e(e,t){var r=e.__data__;return Ea(t)?r[typeof t=="string"?"string":"hash"]:r.map}function Ir(e,t){var r=zo(e,t);return ga(r)?r:void 0}function Sa(e,t){if(Wr(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||wt(e)?!0:Mo.test(e)||!Do.test(e)||t!=null&&e in Object(t)}function Ea(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function ba(e){return!!vr&&vr in e}var Ca=gt(function(e){e=Ta(e);var t=[];return $o.test(e)&&t.push(""),e.replace(qo,function(r,n,o,a){t.push(o?a.replace(Lo,"$1"):n||r)}),t});function _a(e){if(typeof e=="string"||wt(e))return e;var t=e+"";return t=="0"&&1/e==-Or?"-0":t}function va(e){if(e!=null){try{return Rr.call(e)}catch{}try{return e+""}catch{}}return""}function gt(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(Wo);var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],a=r.cache;if(a.has(o))return a.get(o);var s=e.apply(this,n);return r.cache=a.set(o,s),s};return r.cache=new(gt.Cache||ne),r}gt.Cache=ne;function Pa(e,t){return e===t||e!==e&&t!==t}var Wr=Array.isArray;function Ha(e){var t=Jr(e)?Ur.call(e):"";return t==Jo||t==No}function Jr(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function Ka(e){return!!e&&typeof e=="object"}function wt(e){return typeof e=="symbol"||Ka(e)&&Ur.call(e)==ko}function Ta(e){return e==null?"":wa(e)}function Oa(e,t,r){var n=e==null?void 0:ya(e,t);return n===void 0?r:n}Nr.exports=Oa});var Fe=_((qe,Fr)=>{(function(e,t){typeof qe=="object"&&typeof Fr<"u"?t(qe):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.aws4fetch={}))})(qe,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"},n=["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id","range","connection"];class o{constructor({accessKeyId:l,secretAccessKey:h,sessionToken:y,service:w,region:m,cache:g,retries:K,initRetryMs:k}){if(l==null)throw new TypeError("accessKeyId is a required option");if(h==null)throw new TypeError("secretAccessKey is a required option");this.accessKeyId=l,this.secretAccessKey=h,this.sessionToken=y,this.service=w,this.region=m,this.cache=g||new Map,this.retries=K??10,this.initRetryMs=k||50}async sign(l,h){if(l instanceof Request){let{method:m,url:g,headers:K,body:k}=l;h=Object.assign({method:m,url:g,headers:K},h),h.body==null&&K.has("Content-Type")&&(h.body=k!=null&&K.has("X-Amz-Content-Sha256")?k:await l.clone().arrayBuffer()),l=g}let y=new a(Object.assign({url:l},h,this,h&&h.aws)),w=Object.assign({},h,await y.sign());return delete w.aws,new Request(w.url.toString(),w)}async fetch(l,h){for(let y=0;y<=this.retries;y++){let w=fetch(await this.sign(l,h));if(y===this.retries)return w;let m=await w;if(m.status<500&&m.status!==429)return m;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:h,headers:y,body:w,accessKeyId:m,secretAccessKey:g,sessionToken:K,service:k,region:U,cache:ee,datetime:Se,signQuery:it,appendSessionToken:ct,allHeaders:Ne,singleEncode:dt}){if(h==null)throw new TypeError("url is a required option");if(m==null)throw new TypeError("accessKeyId is a required option");if(g==null)throw new TypeError("secretAccessKey is a required option");this.method=l||(w?"POST":"GET"),this.url=new URL(h),this.headers=new Headers(y||{}),this.body=w,this.accessKeyId=m,this.secretAccessKey=g,this.sessionToken=K;let V,Ee;(!k||!U)&&([V,Ee]=f(this.url,this.headers)),this.service=k||V||"",this.region=U||Ee||"us-east-1",this.cache=ee||new Map,this.datetime=Se||new Date().toISOString().replace(/[:-]|\.\d{3}/g,""),this.signQuery=it,this.appendSessionToken=ct||this.service==="iotdevicegateway",this.headers.delete("Host");let q=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"),q.set("X-Amz-Date",this.datetime),this.sessionToken&&!this.appendSessionToken&&q.set("X-Amz-Security-Token",this.sessionToken),this.signableHeaders=["host",...this.headers.keys()].filter(C=>Ne||!n.includes(C)).sort(),this.signedHeaders=this.signableHeaders.join(";"),this.canonicalHeaders=this.signableHeaders.map(C=>C+":"+(C==="host"?this.url.host:(this.headers.get(C)||"").replace(/\s+/g," "))).join(`
|
|
1
|
+
"use strict";var So=Object.create;var lr=Object.defineProperty;var Eo=Object.getOwnPropertyDescriptor;var bo=Object.getOwnPropertyNames;var Co=Object.getPrototypeOf,_o=Object.prototype.hasOwnProperty;var _=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var vo=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of bo(t))!_o.call(e,o)&&o!==r&&lr(e,o,{get:()=>t[o],enumerable:!(n=Eo(t,o))||n.enumerable});return e};var v=(e,t,r)=>(r=e!=null?So(Co(e)):{},vo(t||!e||!e.__esModule?lr(r,"default",{value:e,enumerable:!0}):r,e));var ht=_((Bc,yr)=>{function Po({host:e=".*",path:t=".*",excludePath:r=null,method:n=[".*"],handler:o,protocol:a=".*",handlerName:s,headers:i={},data:c}){let u=[],f=[],d=e.replace(/(:([^.]+))/g,(K,k,U)=>(u.push(U),"([^.]+)")),l=t.replace(/(:([^/]+))/g,(K,k,U)=>U.slice(-1)==="*"?(f.push(U.slice(0,U.length-1)),"(.*)"):(f.push(U),"([^/]*)")),h=new RegExp(`^${d}$`,"i"),y=new RegExp(`^${l}$`,"i"),w=r?new RegExp(`^${r}$`,"i"):null,m=new RegExp(`^${n.join("|")}$`,"i"),g=new RegExp(`^${a}$`,"i");return{hostVariables:u,pathVariables:f,host:h,path:y,excludePath:w,method:m,protocol:g,handler:o,handlerName:s,headers:i,data:c}}function mr(e){return[...e].reduce((t,r)=>{let n={};return n[r[0]]=r[1],{...t,...n}},{})}async function Ho(e,t=1024*1024){let r=[],n=e.getReader(),o=new TextDecoder,a=0;for(;t&&a<t;){let{done:i,value:c}=await n.read();if(i)break;a+=c.byteLength,r.push(o.decode(c))}let s=r.join("");return t?s.substring(0,t):s}function Ko(e){let t=new URL(e.url),r=mr(t.searchParams),n=mr(e.headers);n.host&&(t.hostname=n.host);let o,a;async function s(i){if(a>=i)return o.substring(0,i);let c=e.clone();return o=await Ho(c.body,i),o}return{body:e.body,headers:n,host:t.host,hostname:t.hostname,href:t.href,json:async i=>JSON.parse(s(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 s(i)):s(i)}}yr.exports={parseRoute:Po,parseRequest:Ko}});var wr=_((Gc,gr)=>{function To(e,t){let r={},n=t.host.exec(e.host);t.hostVariables.forEach((a,s)=>{r[a]=n[s+1]});let o=t.path.exec(e.path);return t.pathVariables.forEach((a,s)=>{r[a]=o[s+1]}),r}function Oo(e,t){let r=!0;return Object.keys(e.headers).forEach(n=>{t.headers[n]!==e.headers[n]&&(r=!1)}),r}function xo(e,t){return e.protocol.test(t.protocol)}function Ro(e,t){return e.method.test(t.method)&&e.host.test(t.host)&&e.path.test(t.path)&&Oo(e,t)&&xo(e,t)&&(!e.excludePath||!e.excludePath.test(t.path))}async function ft(e,t){let[r,...n]=t;if(!r)return new Response("NOT_FOUND",{status:404});if(!Ro(r,e.request))return ft(e,n);e.state.handlers=e.state.handlers||[],e.state.handlers.push(r.handlerName||r.handler.name),e.params=To(e.request,r);try{return r.handler(e,async o=>ft(o,n))}catch(o){throw o.route=r.handler.name,o}}gr.exports={recurseRoutes:ft}});var Sr=_((Vc,Ar)=>{Ar.exports={methods:{DELETE:"DELETE",GET:"GET",HEAD:"HEAD",OPTIONS:"OPTIONS",PATCH:"PATCH",POST:"POST"},statusMessages:{404:"Not found",429:"Rate limited"}}});var Cr=_((zc,br)=>{var Uo=ht();br.exports=class Er{constructor(t){this.request=Uo.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 Er(this.event);return t.cloned=!0,t}}});var vr=_((jc,_r)=>{var ue=ht(),Io=wr(),_e=Sr(),Wo=Cr();_r.exports=class{constructor(){this.routes=[]}get(t,r){let n=ue.parseRoute({method:[_e.methods.GET,_e.methods.HEAD],path:t,handler:r});this.routes.push(n)}post(t,r){let n=ue.parseRoute({method:[_e.methods.POST],path:t,handler:r});this.routes.push(n)}patch(t,r){let n=ue.parseRoute({method:[_e.methods.PATCH],path:t,handler:r});this.routes.push(n)}del(t,r){let n=ue.parseRoute({method:[_e.methods.DELETE],path:t,handler:r});this.routes.push(n)}use(t){let r=ue.parseRoute({handler:t,middleware:!0});this.routes.push(r)}add({host:t,path:r,excludePath:n,method:o,handlerName:a,headers:s,protocol:i},c){let u=ue.parseRoute({method:o,host:t,path:r,excludePath:n,handler:c,headers:s,handlerName:a,protocol:i});this.routes.push(u)}async resolve(t){let r=new Wo(t);try{return await Io.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 M=_((Yc,kr)=>{var Jo="Expected a function",Or="__lodash_hash_undefined__",xr=1/0,No="[object Function]",ko="[object GeneratorFunction]",Do="[object Symbol]",Mo=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,$o=/^\w*$/,qo=/^\./,Fo=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Lo=/[\\^$.*+?()[\]{}|]/g,Bo=/\\(\\)?/g,Go=/^\[object .+?Constructor\]$/,Vo=typeof global=="object"&&global&&global.Object===Object&&global,zo=typeof self=="object"&&self&&self.Object===Object&&self,mt=Vo||zo||Function("return this")();function Xo(e,t){return e?.[t]}function jo(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var Yo=Array.prototype,Zo=Function.prototype,Rr=Object.prototype,lt=mt["__core-js_shared__"],Pr=function(){var e=/[^.]+$/.exec(lt&<.keys&<.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Ur=Zo.toString,yt=Rr.hasOwnProperty,Ir=Rr.toString,Qo=RegExp("^"+Ur.call(yt).replace(Lo,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Hr=mt.Symbol,ea=Yo.splice,ta=Wr(mt,"Map"),ve=Wr(Object,"create"),Kr=Hr?Hr.prototype:void 0,Tr=Kr?Kr.toString:void 0;function re(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function ra(){this.__data__=ve?ve(null):{}}function na(e){return this.has(e)&&delete this.__data__[e]}function oa(e){var t=this.__data__;if(ve){var r=t[e];return r===Or?void 0:r}return yt.call(t,e)?t[e]:void 0}function aa(e){var t=this.__data__;return ve?t[e]!==void 0:yt.call(t,e)}function sa(e,t){var r=this.__data__;return r[e]=ve&&t===void 0?Or:t,this}re.prototype.clear=ra;re.prototype.delete=na;re.prototype.get=oa;re.prototype.has=aa;re.prototype.set=sa;function pe(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function ia(){this.__data__=[]}function ca(e){var t=this.__data__,r=Me(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():ea.call(t,r,1),!0}function da(e){var t=this.__data__,r=Me(t,e);return r<0?void 0:t[r][1]}function ua(e){return Me(this.__data__,e)>-1}function pa(e,t){var r=this.__data__,n=Me(r,e);return n<0?r.push([e,t]):r[n][1]=t,this}pe.prototype.clear=ia;pe.prototype.delete=ca;pe.prototype.get=da;pe.prototype.has=ua;pe.prototype.set=pa;function ne(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function ha(){this.__data__={hash:new re,map:new(ta||pe),string:new re}}function fa(e){return $e(this,e).delete(e)}function la(e){return $e(this,e).get(e)}function ma(e){return $e(this,e).has(e)}function ya(e,t){return $e(this,e).set(e,t),this}ne.prototype.clear=ha;ne.prototype.delete=fa;ne.prototype.get=la;ne.prototype.has=ma;ne.prototype.set=ya;function Me(e,t){for(var r=e.length;r--;)if(Ha(e[r][0],t))return r;return-1}function ga(e,t){t=Ea(t,e)?[t]:Sa(t);for(var r=0,n=t.length;e!=null&&r<n;)e=e[va(t[r++])];return r&&r==n?e:void 0}function wa(e){if(!Nr(e)||Ca(e))return!1;var t=Ka(e)||jo(e)?Qo:Go;return t.test(Pa(e))}function Aa(e){if(typeof e=="string")return e;if(wt(e))return Tr?Tr.call(e):"";var t=e+"";return t=="0"&&1/e==-xr?"-0":t}function Sa(e){return Jr(e)?e:_a(e)}function $e(e,t){var r=e.__data__;return ba(t)?r[typeof t=="string"?"string":"hash"]:r.map}function Wr(e,t){var r=Xo(e,t);return wa(r)?r:void 0}function Ea(e,t){if(Jr(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||wt(e)?!0:$o.test(e)||!Mo.test(e)||t!=null&&e in Object(t)}function ba(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Ca(e){return!!Pr&&Pr in e}var _a=gt(function(e){e=Oa(e);var t=[];return qo.test(e)&&t.push(""),e.replace(Fo,function(r,n,o,a){t.push(o?a.replace(Bo,"$1"):n||r)}),t});function va(e){if(typeof e=="string"||wt(e))return e;var t=e+"";return t=="0"&&1/e==-xr?"-0":t}function Pa(e){if(e!=null){try{return Ur.call(e)}catch{}try{return e+""}catch{}}return""}function gt(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(Jo);var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],a=r.cache;if(a.has(o))return a.get(o);var s=e.apply(this,n);return r.cache=a.set(o,s),s};return r.cache=new(gt.Cache||ne),r}gt.Cache=ne;function Ha(e,t){return e===t||e!==e&&t!==t}var Jr=Array.isArray;function Ka(e){var t=Nr(e)?Ir.call(e):"";return t==No||t==ko}function Nr(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function Ta(e){return!!e&&typeof e=="object"}function wt(e){return typeof e=="symbol"||Ta(e)&&Ir.call(e)==Do}function Oa(e){return e==null?"":Aa(e)}function xa(e,t,r){var n=e==null?void 0:ga(e,t);return n===void 0?r:n}kr.exports=xa});var Fe=_((qe,Lr)=>{(function(e,t){typeof qe=="object"&&typeof Lr<"u"?t(qe):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.aws4fetch={}))})(qe,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"},n=["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id","range","connection"];class o{constructor({accessKeyId:l,secretAccessKey:h,sessionToken:y,service:w,region:m,cache:g,retries:K,initRetryMs:k}){if(l==null)throw new TypeError("accessKeyId is a required option");if(h==null)throw new TypeError("secretAccessKey is a required option");this.accessKeyId=l,this.secretAccessKey=h,this.sessionToken=y,this.service=w,this.region=m,this.cache=g||new Map,this.retries=K??10,this.initRetryMs=k||50}async sign(l,h){if(l instanceof Request){let{method:m,url:g,headers:K,body:k}=l;h=Object.assign({method:m,url:g,headers:K},h),h.body==null&&K.has("Content-Type")&&(h.body=k!=null&&K.has("X-Amz-Content-Sha256")?k:await l.clone().arrayBuffer()),l=g}let y=new a(Object.assign({url:l},h,this,h&&h.aws)),w=Object.assign({},h,await y.sign());return delete w.aws,new Request(w.url.toString(),w)}async fetch(l,h){for(let y=0;y<=this.retries;y++){let w=fetch(await this.sign(l,h));if(y===this.retries)return w;let m=await w;if(m.status<500&&m.status!==429)return m;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:h,headers:y,body:w,accessKeyId:m,secretAccessKey:g,sessionToken:K,service:k,region:U,cache:ee,datetime:Se,signQuery:it,appendSessionToken:ct,allHeaders:Ne,singleEncode:dt}){if(h==null)throw new TypeError("url is a required option");if(m==null)throw new TypeError("accessKeyId is a required option");if(g==null)throw new TypeError("secretAccessKey is a required option");this.method=l||(w?"POST":"GET"),this.url=new URL(h),this.headers=new Headers(y||{}),this.body=w,this.accessKeyId=m,this.secretAccessKey=g,this.sessionToken=K;let V,Ee;(!k||!U)&&([V,Ee]=f(this.url,this.headers)),this.service=k||V||"",this.region=U||Ee||"us-east-1",this.cache=ee||new Map,this.datetime=Se||new Date().toISOString().replace(/[:-]|\.\d{3}/g,""),this.signQuery=it,this.appendSessionToken=ct||this.service==="iotdevicegateway",this.headers.delete("Host");let q=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"),q.set("X-Amz-Date",this.datetime),this.sessionToken&&!this.appendSessionToken&&q.set("X-Amz-Security-Token",this.sessionToken),this.signableHeaders=["host",...this.headers.keys()].filter(C=>Ne||!n.includes(C)).sort(),this.signedHeaders=this.signableHeaders.join(";"),this.canonicalHeaders=this.signableHeaders.map(C=>C+":"+(C==="host"?this.url.host:(this.headers.get(C)||"").replace(/\s+/g," "))).join(`
|
|
2
2
|
`),this.credentialString=[this.datetime.slice(0,8),this.region,this.service,"aws4_request"].join("/"),this.signQuery&&(this.service==="s3"&&!q.has("X-Amz-Expires")&&q.set("X-Amz-Expires","86400"),q.set("X-Amz-Algorithm","AWS4-HMAC-SHA256"),q.set("X-Amz-Credential",this.accessKeyId+"/"+this.credentialString),q.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,"/");dt||(this.encodedPath=encodeURIComponent(this.encodedPath).replace(/%2F/g,"/")),this.encodedPath=u(this.encodedPath);let ke=new Set;this.encodedSearch=[...this.url.searchParams].filter(([C])=>{if(!C)return!1;if(this.service==="s3"){if(ke.has(C))return!1;ke.add(C)}return!0}).map(C=>C.map(be=>u(encodeURIComponent(be)))).sort(([C,be],[Ce,De])=>C<Ce?-1:C>Ce?1:be<De?-1:be>De?1:0).map(C=>C.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 l=this.datetime.slice(0,8),h=[this.secretAccessKey,l,this.region,this.service].join(),y=this.cache.get(h);if(!y){let w=await s("AWS4"+this.secretAccessKey,l),m=await s(w,this.region),g=await s(m,this.service);y=await s(g,"aws4_request"),this.cache.set(h,y)}return c(await s(y,await this.stringToSign()))}async stringToSign(){return["AWS4-HMAC-SHA256",this.datetime,this.credentialString,c(await i(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 s(d,l){let h=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",h,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 u(d){return d.replace(/[!'()*]/g,l=>"%"+l.charCodeAt(0).toString(16).toUpperCase())}function f(d,l){let{hostname:h,pathname:y}=d,w=h.replace("dualstack.","").match(/([^.]+)\.(?:([^.]*)\.)?amazonaws\.com(?:\.cn)?$/),[m,g]=(w||["",""]).slice(1,3);if(g==="us-gov")g="us-gov-west-1";else if(g==="s3"||g==="s3-accelerate")g="us-east-1",m="s3";else if(m==="iot")h.startsWith("iot.")?m="execute-api":h.startsWith("data.jobs.iot.")?m="iot-jobs-data":m=y==="/mqtt"?"iotdevicegateway":"iotdata";else if(m==="autoscaling"){let K=(l.get("X-Amz-Target")||"").split(".")[0];K==="AnyScaleFrontendService"?m="application-autoscaling":K==="AnyScaleScalingPlannerFrontendService"&&(m="autoscaling-plans")}else g==null&&m.startsWith("s3-")?(g=m.slice(3).replace(/^fips-|^external-1/,""),m="s3"):m.endsWith("-fips")?m=m.slice(0,-5):g&&/-\d$/.test(m)&&!/-\d$/.test(g)&&([m,g]=[g,m]);return[r[m]||m,g]}e.AwsClient=o,e.AwsV4Signer=a,Object.defineProperty(e,"__esModule",{value:!0})})});var ze=_((Ad,nn)=>{var Ya="Expected a function",Xr="__lodash_hash_undefined__",jr=1/0,Za=9007199254740991,Qa="[object Function]",es="[object GeneratorFunction]",ts="[object Symbol]",rs=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ns=/^\w*$/,os=/^\./,as=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ss=/[\\^$.*+?()[\]{}|]/g,is=/\\(\\)?/g,cs=/^\[object .+?Constructor\]$/,ds=/^(?:0|[1-9]\d*)$/,us=typeof global=="object"&&global&&global.Object===Object&&global,ps=typeof self=="object"&&self&&self.Object===Object&&self,Rt=us||ps||Function("return this")();function hs(e,t){return e?.[t]}function fs(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var ls=Array.prototype,ms=Function.prototype,Yr=Object.prototype,xt=Rt["__core-js_shared__"],Br=function(){var e=/[^.]+$/.exec(xt&&xt.keys&&xt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Zr=ms.toString,Be=Yr.hasOwnProperty,Qr=Yr.toString,ys=RegExp("^"+Zr.call(Be).replace(ss,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Gr=Rt.Symbol,gs=ls.splice,ws=en(Rt,"Map"),Pe=en(Object,"create"),Vr=Gr?Gr.prototype:void 0,zr=Vr?Vr.toString:void 0;function ae(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function As(){this.__data__=Pe?Pe(null):{}}function Ss(e){return this.has(e)&&delete this.__data__[e]}function Es(e){var t=this.__data__;if(Pe){var r=t[e];return r===Xr?void 0:r}return Be.call(t,e)?t[e]:void 0}function bs(e){var t=this.__data__;return Pe?t[e]!==void 0:Be.call(t,e)}function Cs(e,t){var r=this.__data__;return r[e]=Pe&&t===void 0?Xr:t,this}ae.prototype.clear=As;ae.prototype.delete=Ss;ae.prototype.get=Es;ae.prototype.has=bs;ae.prototype.set=Cs;function he(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function _s(){this.__data__=[]}function vs(e){var t=this.__data__,r=Ge(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():gs.call(t,r,1),!0}function Ps(e){var t=this.__data__,r=Ge(t,e);return r<0?void 0:t[r][1]}function Hs(e){return Ge(this.__data__,e)>-1}function Ks(e,t){var r=this.__data__,n=Ge(r,e);return n<0?r.push([e,t]):r[n][1]=t,this}he.prototype.clear=_s;he.prototype.delete=vs;he.prototype.get=Ps;he.prototype.has=Hs;he.prototype.set=Ks;function se(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Ts(){this.__data__={hash:new ae,map:new(ws||he),string:new ae}}function Os(e){return Ve(this,e).delete(e)}function xs(e){return Ve(this,e).get(e)}function Rs(e){return Ve(this,e).has(e)}function Us(e,t){return Ve(this,e).set(e,t),this}se.prototype.clear=Ts;se.prototype.delete=Os;se.prototype.get=xs;se.prototype.has=Rs;se.prototype.set=Us;function Is(e,t,r){var n=e[t];(!(Be.call(e,t)&&tn(n,r))||r===void 0&&!(t in e))&&(e[t]=r)}function Ge(e,t){for(var r=e.length;r--;)if(tn(e[r][0],t))return r;return-1}function Ws(e){if(!Le(e)||qs(e))return!1;var t=Gs(e)||fs(e)?ys:cs;return t.test(Bs(e))}function Js(e,t,r,n){if(!Le(e))return e;t=Ms(t,e)?[t]:ks(t);for(var o=-1,a=t.length,s=a-1,i=e;i!=null&&++o<a;){var c=Ls(t[o]),u=r;if(o!=s){var f=i[c];u=n?n(f,c,i):void 0,u===void 0&&(u=Le(f)?f:Ds(t[o+1])?[]:{})}Is(i,c,u),i=i[c]}return e}function Ns(e){if(typeof e=="string")return e;if(It(e))return zr?zr.call(e):"";var t=e+"";return t=="0"&&1/e==-jr?"-0":t}function ks(e){return rn(e)?e:Fs(e)}function Ve(e,t){var r=e.__data__;return $s(t)?r[typeof t=="string"?"string":"hash"]:r.map}function en(e,t){var r=hs(e,t);return Ws(r)?r:void 0}function Ds(e,t){return t=t??Za,!!t&&(typeof e=="number"||ds.test(e))&&e>-1&&e%1==0&&e<t}function Ms(e,t){if(rn(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||It(e)?!0:ns.test(e)||!rs.test(e)||t!=null&&e in Object(t)}function $s(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function qs(e){return!!Br&&Br in e}var Fs=Ut(function(e){e=zs(e);var t=[];return os.test(e)&&t.push(""),e.replace(as,function(r,n,o,a){t.push(o?a.replace(is,"$1"):n||r)}),t});function Ls(e){if(typeof e=="string"||It(e))return e;var t=e+"";return t=="0"&&1/e==-jr?"-0":t}function Bs(e){if(e!=null){try{return Zr.call(e)}catch{}try{return e+""}catch{}}return""}function Ut(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(Ya);var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],a=r.cache;if(a.has(o))return a.get(o);var s=e.apply(this,n);return r.cache=a.set(o,s),s};return r.cache=new(Ut.Cache||se),r}Ut.Cache=se;function tn(e,t){return e===t||e!==e&&t!==t}var rn=Array.isArray;function Gs(e){var t=Le(e)?Qr.call(e):"";return t==Qa||t==es}function Le(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function Vs(e){return!!e&&typeof e=="object"}function It(e){return typeof e=="symbol"||Vs(e)&&Qr.call(e)==ts}function zs(e){return e==null?"":Ns(e)}function Xs(e,t,r){return e==null?e:Js(e,t,r)}nn.exports=Xs});var pn=_(kt=>{"use strict";kt.parse=ni;kt.serialize=oi;var ei=decodeURIComponent,ti=encodeURIComponent,ri=/; */,je=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function ni(e,t){if(typeof e!="string")throw new TypeError("argument str must be a string");for(var r={},n=t||{},o=e.split(ri),a=n.decode||ei,s=0;s<o.length;s++){var i=o[s],c=i.indexOf("=");if(!(c<0)){var u=i.substr(0,c).trim(),f=i.substr(++c,i.length).trim();f[0]=='"'&&(f=f.slice(1,-1)),r[u]==null&&(r[u]=ai(f,a))}}return r}function oi(e,t,r){var n=r||{},o=n.encode||ti;if(typeof o!="function")throw new TypeError("option encode is invalid");if(!je.test(e))throw new TypeError("argument name is invalid");var a=o(t);if(a&&!je.test(a))throw new TypeError("argument val is invalid");var s=e+"="+a;if(n.maxAge!=null){var i=n.maxAge-0;if(isNaN(i)||!isFinite(i))throw new TypeError("option maxAge is invalid");s+="; Max-Age="+Math.floor(i)}if(n.domain){if(!je.test(n.domain))throw new TypeError("option domain is invalid");s+="; Domain="+n.domain}if(n.path){if(!je.test(n.path))throw new TypeError("option path is invalid");s+="; Path="+n.path}if(n.expires){if(typeof n.expires.toUTCString!="function")throw new TypeError("option expires is invalid");s+="; Expires="+n.expires.toUTCString()}if(n.httpOnly&&(s+="; HttpOnly"),n.secure&&(s+="; Secure"),n.sameSite){var c=typeof n.sameSite=="string"?n.sameSite.toLowerCase():n.sameSite;switch(c){case!0:s+="; SameSite=Strict";break;case"lax":s+="; SameSite=Lax";break;case"strict":s+="; SameSite=Strict";break;case"none":s+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return s}function ai(e,t){try{return t(e)}catch{return e}}});var fn=_((Nd,hn)=>{"use strict";var Ye=1;function si(){return Ye=(Ye*9301+49297)%233280,Ye/233280}function ii(e){Ye=e}hn.exports={nextValue:si,seed:ii}});var Oe=_((kd,gn)=>{"use strict";var Dt=fn(),ce="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-",z,ln,Te;function Mt(){Te=!1}function mn(e){if(!e){z!==ce&&(z=ce,Mt());return}if(e!==z){if(e.length!==ce.length)throw new Error("Custom alphabet for shortid must be "+ce.length+" unique characters. You submitted "+e.length+" characters: "+e);var t=e.split("").filter(function(r,n,o){return n!==o.lastIndexOf(r)});if(t.length)throw new Error("Custom alphabet for shortid must be "+ce.length+" unique characters. These characters were not unique: "+t.join(", "));z=e,Mt()}}function ci(e){return mn(e),z}function di(e){Dt.seed(e),ln!==e&&(Mt(),ln=e)}function ui(){z||mn(ce);for(var e=z.split(""),t=[],r=Dt.nextValue(),n;e.length>0;)r=Dt.nextValue(),n=Math.floor(r*e.length),t.push(e.splice(n,1)[0]);return t.join("")}function yn(){return Te||(Te=ui(),Te)}function pi(e){var t=yn();return t[e]}function hi(){return z||ce}gn.exports={get:hi,characters:ci,seed:di,lookup:pi,shuffled:yn}});var An=_((Dd,wn)=>{"use strict";var $t=typeof window=="object"&&(window.crypto||window.msCrypto),qt;!$t||!$t.getRandomValues?qt=function(e){for(var t=[],r=0;r<e;r++)t.push(Math.floor(Math.random()*256));return t}:qt=function(e){return $t.getRandomValues(new Uint8Array(e))};wn.exports=qt});var En=_((Md,Sn)=>{Sn.exports=function(e,t,r){for(var n=(2<<Math.log(t.length-1)/Math.LN2)-1,o=-~(1.6*n*r/t.length),a="";;)for(var s=e(o),i=o;i--;)if(a+=t[s[i]&n]||"",a.length===+r)return a}});var Cn=_(($d,bn)=>{"use strict";var fi=Oe(),li=An(),mi=En();function yi(e){for(var t=0,r,n="";!r;)n=n+mi(li,fi.get(),1),r=e<Math.pow(16,t+1),t++;return n}bn.exports=yi});var Pn=_((Fd,vn)=>{"use strict";var Ze=Cn(),qd=Oe(),gi=1567752802062,wi=7,Qe,_n;function Ai(e){var t="",r=Math.floor((Date.now()-gi)*.001);return r===_n?Qe++:(Qe=0,_n=r),t=t+Ze(wi),t=t+Ze(e),Qe>0&&(t=t+Ze(Qe)),t=t+Ze(r),t}vn.exports=Ai});var Kn=_((Ld,Hn)=>{"use strict";var Si=Oe();function Ei(e){if(!e||typeof e!="string"||e.length<6)return!1;var t=new RegExp("[^"+Si.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]");return!t.test(e)}Hn.exports=Ei});var On=_((Bd,Tn)=>{"use strict";Tn.exports=0});var Un=_((Gd,B)=>{"use strict";var Ft=Oe(),bi=Pn(),Ci=Kn(),xn=On()||0;function _i(e){return Ft.seed(e),B.exports}function vi(e){return xn=e,B.exports}function Pi(e){return e!==void 0&&Ft.characters(e),Ft.shuffled()}function Rn(){return bi(xn)}B.exports=Rn;B.exports.generate=Rn;B.exports.seed=_i;B.exports.worker=vi;B.exports.characters=Pi;B.exports.isValid=Ci});var Wn=_((Vd,In)=>{"use strict";In.exports=Un()});var fo=v(_r());var kr=v(M()),xa={get:kr.default};function At(e){e.status=401,e.body="Unauthorized",e.set("WWW-Authenticate","Basic")}function St(e){return async(t,r)=>{if(t.request.path===e.logoutPath)return At(t);let n=xa.get(t,"request.headers.authorization");if(!n||!n.startsWith("Basic "))return At(t);let o=e.users.map(i=>i.authToken),a=n.substring(6),s=o.indexOf(a);return s===-1?At(t):(t.state.user=e.users[s].username,r(t))}}var Dr=caches.default;async function Ra(e){return await Dr.match(e)}async function Ua(e,t){return Dr.put(e.href,t)}var Et={get:Ra,set:Ua};async function Ia(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 Mr=Ia;function Wa(e,t={}){return Object.keys(t).reduce((r,n)=>r.replace(`{${n}}`,t[n]),e)}function bt(e){return[...e].reduce((t,r)=>{let n={};return n[r[0]]=r[1],{...t,...n}},{})}var S={resolveParams:Wa,instanceToJson:bt};var Ja=["x-ratelimit-count","x-ratelimit-limit","x-ratelimit-reset","x-cache-hit"];async function Na(e){return["POST","PATCH","PUT","DELETE"].indexOf(e.method)===-1?null:e.text()}async function ka(e,t){if(!t)return e.event.request;let r=t.match(/{.*?}/gi).map(a=>a.slice(1,-1)),n={};for(let a=0;a<r.length;a+=1){let s=r[a],i=s.split(":");switch(i[0]){case"method":n[s]=e.request.method;break;case"path":n[s]=e.request.path;break;case"bodyHash":n[s]=await Mr(await Na(e.request));break;case"header":n[s]=e.request.headers[i[1]]||"";break;default:n[s]=s}}let o=encodeURIComponent(t.replace(/({(.*?)})/gi,(a,s,i)=>n[i]));return new Request(`http://${e.request.hostname}/${o}`)}function Ct({cacheDuration:e,cacheKeyTemplate:t,headerBlacklist:r=Ja}){return async(n,o)=>{let a=await ka(n,t),s=await Et.get(a);if(s){n.body=s.body,n.status=s.status;let i=bt(s.headers);Object.keys(i).forEach(c=>{n.set(c,i[c])}),n.set("X-Cache-Hit",!0)}else{await o(n);let i;n.body.tee?[n.body,i]=n.body.tee():i=n.body;let c=new Response(i,{status:n.status});Object.keys(n.response.headers).forEach(u=>{r.indexOf(u.toLowerCase())===-1&&c.headers.set(u,n.response.headers[u])}),e&&(c.headers.delete("Cache-Control"),c.headers.set("Cache-Control",`max-age=${e}`)),n.event.waitUntil(Et.set(a,c))}}}function _t({allowedOrigins:e=["*"],allowedMethods:t=["GET","PUT","POST","PATCH","DELETE","HEAD","OPTIONS"],allowCredentials:r=!0,allowedHeaders:n=["Content-Type"],allowedExposeHeaders:o=["WWW-Authenticate","Server-Authorization"],maxAge:a=600,optionsSuccessStatus:s=204,terminatePreflight:i=!1}){return async(c,u)=>{let{method:f}=c.request,{origin:d}=c.request.headers,l=c.request.headers["access-control-request-headers"];if(Da(c,d,e),Ma(c,r),La(c,o),f==="OPTIONS"&&($a(c,t),qa(c,l,n),Fa(c,a),i)){c.status=s,c.set("Content-Length","0"),c.body="";return}await u(c)}}function Da(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 Ma(e,t){t&&e.set("Access-Control-Allow-Credentials",t)}function $a(e,t){e.set("Access-Control-Allow-Methods",t.join(","))}function qa(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 Fa(e,t){t&&e.set("Access-Control-Max-Age",t)}function La(e,t){t.length&&e.set("Access-Control-Expose-Headers",t.join(","))}var Ba={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 vt(){return async(e,t)=>{let r=e.request.headers["cf-ipcountry"]||"XX";e.request.headers["proxy-continent"]=Ba[r],await t(e)}}function Ga(e){let t=e.split("."),r=JSON.parse(atob(t[0])),n=JSON.parse(atob(t[1])),o=atob(t[2].replace(/-/g,"+").replace(/_/g,"/"));return{header:r,payload:n,signature:o,raw:{header:t[0],payload:t[1],signature:t[2]}}}function Pt({jwksUri:e,iss:t,aud:r,allowPublicAccess:n=!1}){async function o(){return(await(await fetch(e)).json()).keys}function a(c){return c.status=403,c.body="Forbidden",c}async function s(c){let f=new TextEncoder().encode([c.raw.header,c.raw.payload].join(".")),d=new Uint8Array(Array.from(c.signature).map(y=>y.charCodeAt(0))),l=await o();return(await Promise.all(l.map(async y=>{let w=await crypto.subtle.importKey("jwk",y,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]);return crypto.subtle.verify("RSASSA-PKCS1-v1_5",w,d,f)}))).some(y=>y)}async function i(c,u){if(c.request.method==="OPTIONS"||n)return u(c);if((c.request.headers.authorization||"").toLowerCase().startsWith("bearer")){let d=Ga(c.request.headers.authorization.slice(7)),l=new Date(d.payload.exp*1e3),h=new Date(Date.now());return l<=h||!t||d.payload.iss!==t||!r||d.payload.aud!==r||!await s(d)?a(c):(c.state.user=d.payload,u(c))}return a(c)}return i}var $r=v(M()),Va={get:$r.default},oe=class{constructor({accountId:t,namespace:r,authEmail:n,authKey:o,ttl:a}){this.accountId=t,this.namespace=r,this.authEmail=n,this.authKey=o,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 n=`${this.getNamespaceUrl()}/keys?prefix=${t}&limit=${r}`,o=await fetch(n,{headers:{"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey}});return o.ok?o.json():null}async get(t,r){let n=this.getUrlForKey(t),o=await fetch(n,{headers:{"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey}});if(o.ok)switch(r){case"json":return o.json();case"stream":return o;case"arrayBuffer":return o.arrayBuffer();default:return o.text()}return null}async getWithMetadata(t,r){let[n,o]=await Promise.all([this.get(t,r),this.list(t)]),a=Va.get(o,"result.0.metadata",{});return{value:n,metadata:a}}async put(t,r,n={}){let o=this.getUrlForKey(t),a=new URLSearchParams;this.ttl&&a.append("expiration_ttl",this.ttl.toString());let s={"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey};o.search=a.toString();let i=new FormData;return i.append("value",r),i.append("metadata",JSON.stringify(n)),(await fetch(o.toString(),{method:"PUT",headers:s,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 O={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 za(e,t,r){if(e==="/"&&r)return r;let n=e.split("/").pop();return n.split(".").pop()!==n?e:`${e}.${t}`}function Ht({kvAccountId:e,kvNamespace:t,kvAuthEmail:r,kvAuthKey:n,kvBasePath:o="",kvKey:a="{file}",defaultExtension:s="html",defaultIndexDocument:i,defaultErrorDocument:c,mime:u={},mode:f="rest"}){let d=new oe({accountId:e,namespace:t,authEmail:r,authKey:n,mode:f}),l={...O.mime,...u};return async h=>{let y=S.resolveParams(a,h.params),w=y===""&&i?i:za(y,s),m=await d.get(o+w);!m&&c&&(m=await d.get(o+c)),m?(h.status=200,h.body=m,h.set("Content-Type",l[w.split(".").pop()]||"text/plain")):(h.status=404,h.body=O.http.statusMessages[404],h.set("Content-Type","text/plain"))}}var qr=v(M());var Kt={get:qr.default};function Xa(e,t,r){if(e==="/"&&r)return r;let n=e.split("/").pop();return n.split(".").pop()!==n?e:`${e}.${t}`}function ja(e,t){let r=Kt.get(e,"headers.if-none-match"),n=Kt.get(t,"metadata.headers.etag");return r?r===n:!1}function Tt({kvNamespaceBinding:e,kvBasePath:t="",kvKey:r="{file}",defaultExtension:n="html",defaultIndexDocument:o,defaultErrorDocument:a}){async function s(i){return await global[e].getWithMetadata(i)}return async i=>{let c=S.resolveParams(r,i.params),u=c===""&&o?o:Xa(c,n),f=await s(t+u);if(!f&&a&&(f=await s(t+a)),f)if(ja(i.request,f))i.status=304;else{i.status=f.status,i.body=f.value;let d=Kt.get(f,"metadata.headers",{});Object.keys(d).forEach(l=>{i.set(l,d[l])})}else i.status=404,i.body=O.http.statusMessages[404],i.set("Content-Type","text/plain")}}var Lr=v(Fe());function Ot({accessKeyId:e,secretAccessKey:t,region:r,lambdaName:n}){let o=new Lr.AwsClient({accessKeyId:e,secretAccessKey:t});return async a=>{let s=`https://lambda.${r}.amazonaws.com/2015-03-31/functions/${n}/invocations`,i={},c=await o.fetch(s,{body:JSON.stringify(i)});a.status=c.status,a.body=c.body;let u=S.instanceToJson(c.headers);Object.keys(u).forEach(f=>{a.set(f,u[f])})}}var an=v(M()),sn=v(ze());var on={get:an.default,set:sn.default};function js(e){let t={};return Object.keys(e).forEach(r=>{r.startsWith("cf")||(t[r]=e[r])}),t}function Ys(e){return e[Math.floor(Math.random()*e.length)]}function Wt({sources:e=[]}){return async t=>{let r=Ys(e),n={method:t.request.method,headers:js(t.request.headers),redirect:"manual",cf:t.request.cf};if(O.methodsMethodsWithBody.indexOf(t.request.method)!==-1&&on.get(t,"event.request.body")){let i=t.event.request.clone();n.body=i.body}let o=S.resolveParams(r.url,t.params);if(r.resolveOverride){let i=S.resolveParams(r.resolveOverride,t.request.params);on.set(n,"cf.resolveOverride",i)}let a=await fetch(o+t.request.search,n);t.body=a.body,t.status=a.status;let s=S.instanceToJson(a.headers);Object.keys(s).forEach(i=>{t.set(i,s[i])})}}var un=v(M());var Jt={name:"@ahmadissa/cloudworker-proxy",version:"1.1.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",jose:"^5.1.0","lodash.get":"4.4.2","lodash.set":"4.3.2",redaxios:"^0.5.1",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 ie=class{constructor({maxSize:t=10,maxSeconds:r=10,sink:n}){this.maxSize=t,this.maxSeconds=r,this.queue=[],this.sink=n,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,n)=>{this.resolveTimer=r,this.rejectTimer=n,this.cancelationToken=setTimeout(async()=>{try{r(await this.flush())}catch(o){n(o)}},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(t);this.timer&&(clearTimeout(this.cancelationToken),this.resolveTimer(r))}catch(t){this.timer&&this.rejectTimer(t)}finally{this.timer=null,this.flushing=!1}}}};function
|
|
7
|
-
`),n=JSON.stringify({DeliveryStreamName:this.streamName,Record:{Data:r}}),o=`https://firehose.${this.region}.amazonaws.com`,a=new Request(o,{method:"POST",body:n,headers:{"X-Amz-Target":"Firehose_20150804.PutRecord","Content-Type":" application/x-amz-json-1.1"}});return this.awsClient.fetch(a)}};var I={get:un.default};async function Qs(e){return["POST","PATCH","PUT","DELETE"].indexOf(e.method)===-1?null:e.text()}function Nt(e){let t;switch(e.type){case"http":t=new He(e);break;case"kinesis":t=new Ke(e);break;default:throw new Error(`Log service type not supported: ${e.type}`)}return async(r,n)=>{r.state["logger-startDate"]=new Date;let o=await Qs(r.request);try{await n(r);let a={message:"START",requestIp:I.get(r,"request.headers.x-real-ip"),requestId:I.get(r,"request.requestId"),request:{headers:I.get(r,"request.headers"),method:I.get(r,"request.method"),url:I.get(r,"request.href"),protocol:I.get(r,"request.protocol"),body:o},response:{status:r.status,headers:I.get(r,"response.headers")},handlers:I.get(r,"state.handlers",[]).join(","),route:I.get(r,"route.name"),timestamp:new Date().toISOString(),ttfb:new Date-r.state["logger-startDate"],redirectUrl:r.userRedirect,severity:30,proxyVersion:Jt.version};r.event.waitUntil(t.log(a))}catch(a){let s={request:{headers:I.get(r,"request.headers"),method:I.get(r,"request.method"),handlers:I.get(r,"state.handlers",[]).join(","),url:I.get(r,"request.href"),body:o},message:"ERROR",stack:a.stack,error:a.message,severity:50,proxyVersion:Jt.version};r.event.waitUntil(t.log(s))}}}var xe=v(pn()),Dn=v(M()),Mn=v(ze()),$n=v(Wn());async function Lt({refresh_token:e,authDomain:t,clientId:r,clientSecret:n}){let o=`${t}/oauth/token`,a=await fetch(o,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",client_id:r,client_secret:n,refresh_token:e})});if(!a.ok)throw new Error("Authentication failed");let s=await a.json();return{...s,expires:Date.now()+s.expires_in*1e3,refresh_token:e}}var Jn="PBKDF2",Bt="AES-GCM",Hi="SHA-256",Ki="raw";function Ti(e){let t=atob(e.replace(/_/g,"/").replace(/-/g,"+")),r=t.length,n=new Uint8Array(r);for(let o=0;o<r;o+=1)n[o]=t.charCodeAt(o);return n.buffer}function Nn(e){let t="",r=new Uint8Array(e),n=r.byteLength;for(let o=0;o<n;o+=1)t+=String.fromCharCode(r[o]);return btoa(t).replace(/\//g,"_").replace(/\+/g,"-")}function Oi(e){return String.fromCharCode.apply(null,new Uint16Array(e))}function xi(e){let t=new ArrayBuffer(e.length*2),r=new Uint16Array(t);for(let n=0,o=e.length;n<o;n+=1)r[n]=e.charCodeAt(n);return t}async function Ri(e){let t=new TextEncoder;return crypto.subtle.importKey(Ki,t.encode(e),{name:Jn},!1,["deriveKey"])}async function Ui(e,t){let r=await Ri(e),o=new TextEncoder().encode(t.replace(/_/g,"/").replace(/-/g,"+"));return crypto.subtle.deriveKey({name:Jn,salt:o,iterations:1e3,hash:{name:Hi}},r,{name:Bt,length:256},!0,["encrypt","decrypt"])}async function Ii(){let e=crypto.getRandomValues(new Uint8Array(8));return Nn(e)}async function Wi(e,t){let r=Ti(t),n=r.slice(0,16),o=r.slice(16),a=await crypto.subtle.decrypt({name:Bt,iv:n},e,o);return Oi(a)}async function Ji(e,t){let r=crypto.getRandomValues(new Uint8Array(16)),n=await crypto.subtle.encrypt({name:Bt,iv:r},e,xi(t)),o=new Uint8Array(n.byteLength+r.byteLength);return o.set(r,0),o.set(new Uint8Array(n),r.byteLength),Nn(o)}var de={decrypt:Wi,deriveAesGcmKey:Ui,encrypt:Ji,getSalt:Ii};var fe={get:Dn.default,set:Mn.default};function kn({cookieHeader:e="",cookieName:t}){return xe.default.parse(e)[t]}function Ni(e){return Object.keys(e).map(t=>`${t}=${encodeURIComponent(e[t])}`).join("&")}function ki(e=""){return e.split(",").indexOf("text/html")!==-1}function Gt({cookieName:e="proxy",cookieHttpOnly:t=!0,allowPublicAccess:r=!1,kvAccountId:n,kvNamespace:o,kvAuthEmail:a,kvAuthKey:s,kvTtl:i=2592e3,oauth2AuthDomain:c,oauth2ClientId:u,oauth2ClientSecret:f,oauth2Audience:d,oauth2Scopes:l=[],oauth2CallbackPath:h="/callback",oauth2CallbackType:y="cookie",oauth2LogoutPath:w="/logout",oauth2LoginPath:m="/login",oauth2ServerTokenPath:g="/oauth/token",oauth2ServerAuthorizePath:K="",oauth2ServerLogoutPath:k}){let U=new oe({accountId:n,namespace:o,authEmail:a,authKey:s,ttl:i}),ee=c,Se=h,it=y,ct=g,Ne=K,dt=k,V=u,Ee=f,q=d,ke=w,C=m,Ce=l.join("%20");async function De(p,H){let P=`${ee}${ct}`,T=await fetch(P,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:Ni({code:p,grant_type:"authorization_code",client_id:V,client_secret:Ee,redirect_uri:H})});if(!T.ok)throw new Error("Authentication failed");let F=await T.json();return{...F,expires:Date.now()+F.expires_in*1e3}}async function lo(p){if(kn({cookieHeader:p.request.headers.cookie,cookieName:e})){let T=p.request.hostname.match(/[^.]+\.[^.]+$/i)[0];p.set("Set-Cookie",xe.default.serialize(e,"",{domain:`.${T}`,path:"/",maxAge:0}))}let P=hr(p);if(k){let T=encodeURIComponent(`${p.request.protocol}://${p.request.host}${P}`);p.set("Location",`${ee}${dt}?client_id=${V}&returnTo=${T}`)}else p.set("Location",P);p.status=302}async function mo(p){let H=p.request.href.split("?")[0],P=await De(p.request.query.code,H),T=$n.default.generate(),F=await de.getSalt(),L=`${T}.${F}`,ut=await de.deriveAesGcmKey(T,F),te=await de.encrypt(ut,JSON.stringify(P));await U.put(T,te);let pt=p.request.hostname.match(/[^.]+\.[^.]+$/i)[0];p.status=302,it==="query"?p.set("Location",`${p.request.query.state}?auth=${L}`):(p.set("Set-Cookie",xe.default.serialize(e,L,{httpOnly:t,domain:`.${pt}`,path:"/",maxAge:60*60*24*365})),p.set("Location",p.request.query.state))}async function yo(p,H){let[P,T]=H.split("."),F=await U.get(P);if(F){let L=await de.deriveAesGcmKey(P,T),ut=await de.decrypt(L,F),te=JSON.parse(ut);if(te.expires<Date.now()){te=await Lt({refresh_token:te.refresh_token,clientId:V,authDomain:ee,clientSecret:Ee});let pt=await de.encrypt(L,JSON.stringify(te));await U.put(P,pt)}p.state.accessToken=te.access_token,p.state.accessToken&&(p.request.headers.authorization=`bearer ${p.state.accessToken}`)}else{let L=p.request.hostname.match(/[^.]+\.[^.]+$/i)[0];p.set("Set-Cookie",xe.default.serialize(e,"",{domain:`.${L}`,maxAge:0}))}}function hr(p){let H=fe.get(p,"request.query.redirect-to");if(H)return H;let P=fe.get(p,"request.headers.referer");return P||"/"}async function go(p){if(p.request.method==="OPTIONS")p.status=200;else{let H=hr(p),P=encodeURIComponent(H||"/"),T=encodeURIComponent(`${p.request.protocol}://${p.request.host}${Se}`);p.status=302,p.set("location",`${ee}${Ne}/authorize?state=${P}&client_id=${V}&response_type=code&scope=${Ce}&audience=${q}&redirect_uri=${T}`)}}async function wo(p,H){if(p.request.method==="OPTIONS")await H(p);else if(fe.get(p,"request.headers.authorization","").toLowerCase().startsWith("bearer "))fe.set(p,"state.access_token",p.request.headers.authorization.slice(7)),await H(p);else{let P=fe.get(p,"request.query.auth")||kn({cookieHeader:p.request.headers.cookie,cookieName:e});if(P&&await yo(p,P),fe.get(p,"state.accessToken")||r)await H(p);else if(ki(p.request.headers.accept)){let F=encodeURIComponent(p.request.href),L=encodeURIComponent(`${p.request.protocol}://${p.request.host}${Se}`);p.status=302,p.set("location",`${ee}${Ne}/authorize?state=${F}&client_id=${V}&response_type=code&scope=${Ce}&audience=${q}&redirect_uri=${L}`)}else p.status=403,p.body="Forbidden"}}return async(p,H)=>{switch(p.request.path){case Se:await mo(p);break;case ke:await lo(p);break;case C:await go(p);break;default:await wo(p,H)}}}var qn=v(M());var Di={get:qn.default};function Mi(e){let t={};return Object.keys(e).forEach(r=>{r.startsWith("cf")||(t[r]=e[r])}),t}function Vt(e){let{localOriginOverride:t,backend:r}=e;return async n=>{let o=process.env.LOCAL?`${t||n.request.origin}${n.request.path}`:`${r}${n.request.path}`,a={headers:Mi(n.request.headers),method:n.request.method,redirect:"manual"};if(O.methodsMethodsWithBody.indexOf(n.request.method)!==-1&&Di.get(n,"event.request.body")){let c=n.event.request.clone();a.body=c.body}let s=await fetch(o,a);n.body=s.body,n.status=s.status;let i=S.instanceToJson(s.headers);Object.keys(i).forEach(c=>{n.set(c,i[c])})}}function zt({body:e="",headers:t={},status:r=200}){return async n=>{e instanceof Object?(n.body=JSON.stringify(e),n.set("Content-Type","application/json")):n.body=S.resolveParams(e,n.params),n.status=r,Object.keys(t).forEach(o=>{n.set(o,S.resolveParams(t[o],n.params))})}}var Fn=v(M()),Ln=v(ze()),Xt={get:Fn.default,set:Ln.default};function jt({type:e="IP",scope:t="default",limit:r=1e3}){let n={};function o(s,i){let c=i["x-real-ip"];return e==="IP"?`minute.${s}.${t}.${c}`:`minute.${s}.${t}.account`}function a(s){let i=Xt.get(n,"minutes",{});Object.keys(i).forEach(c=>{c!==s&&delete n.minutes.minute})}return async(s,i)=>{let c=Math.trunc(Date.now()/6e4),u=Math.trunc(c*60+60-Date.now()/1e3),f=o(c,s.request.headers),d=Xt.get(n,f,0);if(["HEAD","OPTIONS"].indexOf(s.request.method)===-1&&(d+=1),Xt.set(n,f,d),r<d){s.status=429;return}a(c),await i(s)}}var Bn=v(Fe());function $i(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:n,endpoint:o,forcePathStyle:a,enableBucketOperations:s=!1}){let i=new Bn.AwsClient({accessKeyId:e,region:n,secretAccessKey:t}),c=$i(o,{region:n,bucket:r,forcePathStyle:a});return async u=>{if(u.params.file===void 0&&!s){u.status=404,u.body=O.http.statusMessages[404],u.set("Content-Type","text/plain");return}let f=u.params.file?S.resolveParams(`${c}/{file}`,u.params):c,d={};u.request.headers.range&&(d.range=u.request.headers.range);let l=await i.fetch(f,{method:u.method||u.request.method,headers:d});u.status=l.status,u.body=l.body;let h=S.instanceToJson(l.headers);Object.keys(h).forEach(y=>{u.set(y,h[y])})}}var Zt;function Gn(e){return new Uint8Array(e.split("").map(r=>r.charCodeAt(0)))}async function qi(e){return Zt||(Zt=await crypto.subtle.importKey("raw",Gn(e),{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign","verify"])),Zt}async function Fi(e,t){let r=await qi(t),n=await crypto.subtle.sign({name:"HMAC"},r,Gn(e));return btoa(String.fromCharCode.apply(null,new Uint8Array(n))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Qt({secret:e}){return async(t,r)=>{let n=(t.request.path+t.request.search).replace(/([?|&]sign=[\w|-]+)/,"");if(await Fi(n,e)!==t.query.sign){t.status=403;return}await r(t)}}function er({host:e}){if(!e)throw new Error("Need to specify a host for the split middleware.");return async(t,r)=>{let n=t.clone();n.cloned=!0,n.request={...n.request,href:n.request.href.replace(n.request.href,e),host:e},t.event.waitUntil(r(n)),await r(t)}}async function Li(e,t,r){let n=e.getReader(),o=t.getWriter(),a=new TextDecoder,s=new TextEncoder;for(;;){let{done:i,value:c}=await n.read();if(i)break;let u=a.decode(c),f=Vn(u,r),d=s.encode(f);await o.write(d)}await o.close()}function Bi(e,t){return e.replace(/{{\$(\d)}}/g,(r,n)=>t[parseInt(n,10)])}function Vn(e,t){return t.reduce((r,n)=>r.replace(n.regex,(...o)=>Bi(n.replace,o)),e)}function tr({transforms:e=[],statusCodes:t=[200]}){let r=e.map(n=>({regex:new RegExp(n.regex,"g"),replace:n.replace}));return async(n,o)=>{await o(n);let{body:a}=n;if(t.indexOf(n.status)!==-1)if(typeof a=="string")n.body=Vn(a,r);else{let{readable:s,writable:i}=new TransformStream;Li(a,i,r),n.body=s}}}async function Gi({projectID:e="your-project-id",API_KEY:t="GCP_API_KEY",token:r="action-token",siteKey:n="siteKey",expectedAction:o="action-name"}){let s=await(await fetch(`https://recaptchaenterprise.googleapis.com/v1/projects/${e}/assessments?key=${t}`,{body:JSON.stringify({event:{token:r,siteKey:n,expectedAction:o}}),headers:{"Content-Type":"application/json"},method:"POST"})).json();return s.tokenProperties.valid?s.tokenProperties.action===o?(s.riskAnalysis.reasons.forEach(i=>{console.log(i)}),s.riskAnalysis.score):(console.error("reCAPTCHA action error:"+o+":action:"+s.tokenProperties.action),null):(console.error("The CreateAssessment call failed because the token was: "+s.tokenProperties.invalidReason),0)}var Vi=e=>(e=e.split("?")[0],e.replace(/\W/g,"").slice(0,100));function rr({projectID:e,API_KEY:t,siteKey:r}){function n(o){return{token:o["g-recaptcha-token"]}}return async(o,a)=>{let{token:s}=n(o.request.headers),i=Vi(o.request.path);if((await Gi({projectID:e,API_KEY:t,token:s,siteKey:r,expectedAction:i})||0)<.5){o.status=409;return}await a(o)}}var zi=e=>!new RegExp("(\b)(onS+)(s*)=|javascript|<(|/|[^/>][^>]+|/[^>][^>]+)>").test(e),Xi=(e,t,r)=>!(!zi(t)||!r[e](t)),ji=e=>!(e===null||typeof e!="object"||Array.isArray(e)&&(!e[0]||typeof e[0]!="object")),nr=(e,t)=>{let r=Object.keys(e);for(let n of r){if(!t[n])return console.error("key not allowed",n),!1;if(e[n]===null&&(e[n]=""),ji(e[n])){if(!nr(e[n],t))return console.error("error validating key+validateObject:",n),!1}else if(!Xi(n,e[n],t))return console.error("error validating key+validateKeyValue:",n),!1}return!0},Yi=e=>!(e==null||typeof e!="object"),Zi=(e,t)=>{let r=e.query;return Yi(r)?nr(r,t):!1};async function Qi(e){if(["POST","PATCH","PUT","DELETE"].indexOf(e.method)===-1)return{};try{let t=await e.text();return JSON.parse(t)}catch{}return{}}function or({allowedKeys:e}){return async(r,n)=>{if(!e)return r.status=501,!1;if(!Zi(r,e))return r.status=422,!1;let o=await Qi(r.request);if(!nr(o,e))return r.status=422,!1;await n(r)}}var uo=v(M());var E=crypto,D=e=>e instanceof CryptoKey;var x=new TextEncoder,W=new TextDecoder,wu=2**32;function X(...e){let t=e.reduce((o,{length:a})=>o+a,0),r=new Uint8Array(t),n=0;return e.forEach(o=>{r.set(o,n),n+=o.length}),r}var zn=e=>{let t=e;typeof t=="string"&&(t=x.encode(t));let r=32768,n=[];for(let o=0;o<t.length;o+=r)n.push(String.fromCharCode.apply(null,t.subarray(o,o+r)));return btoa(n.join(""))},J=e=>zn(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_");var le=class extends Error{static get code(){return"ERR_JOSE_GENERIC"}constructor(t){super(t),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}};var A=class extends le{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}static get code(){return"ERR_JOSE_NOT_SUPPORTED"}};var N=class extends le{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}static get code(){return"ERR_JWS_INVALID"}},j=class extends le{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}static get code(){return"ERR_JWT_INVALID"}};var et=E.getRandomValues.bind(E);function G(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function tt(e,t){return e.name===t}function ar(e){return parseInt(e.name.slice(4),10)}function rc(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function nc(e,t){if(t.length&&!t.some(r=>e.usages.includes(r))){let r="CryptoKey does not support this operation, its usages must include ";if(t.length>2){let n=t.pop();r+=`one of ${t.join(", ")}, or ${n}.`}else t.length===2?r+=`one of ${t[0]} or ${t[1]}.`:r+=`${t[0]}.`;throw new TypeError(r)}}function jn(e,t,...r){switch(t){case"HS256":case"HS384":case"HS512":{if(!tt(e.algorithm,"HMAC"))throw G("HMAC");let n=parseInt(t.slice(2),10);if(ar(e.algorithm.hash)!==n)throw G(`SHA-${n}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!tt(e.algorithm,"RSASSA-PKCS1-v1_5"))throw G("RSASSA-PKCS1-v1_5");let n=parseInt(t.slice(2),10);if(ar(e.algorithm.hash)!==n)throw G(`SHA-${n}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!tt(e.algorithm,"RSA-PSS"))throw G("RSA-PSS");let n=parseInt(t.slice(2),10);if(ar(e.algorithm.hash)!==n)throw G(`SHA-${n}`,"algorithm.hash");break}case"EdDSA":{if(e.algorithm.name!=="Ed25519"&&e.algorithm.name!=="Ed448")throw G("Ed25519 or Ed448");break}case"ES256":case"ES384":case"ES512":{if(!tt(e.algorithm,"ECDSA"))throw G("ECDSA");let n=rc(t);if(e.algorithm.namedCurve!==n)throw G(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}nc(e,r)}function Yn(e,t,...r){if(r.length>2){let n=r.pop();e+=`one of type ${r.join(", ")}, or ${n}.`}else r.length===2?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;return t==null?e+=` Received ${t}`:typeof t=="function"&&t.name?e+=` Received function ${t.name}`:typeof t=="object"&&t!=null&&t.constructor&&t.constructor.name&&(e+=` Received an instance of ${t.constructor.name}`),e}var $=(e,...t)=>Yn("Key must be ",e,...t);function sr(e,t,...r){return Yn(`Key for the ${e} algorithm must be `,t,...r)}var ir=e=>D(e),b=["CryptoKey"];var cc=(...e)=>{let t=e.filter(Boolean);if(t.length===0||t.length===1)return!0;let r;for(let n of t){let o=Object.keys(n);if(!r||r.size===0){r=new Set(o);continue}for(let a of o){if(r.has(a))return!1;r.add(a)}}return!0},me=cc;function dc(e){return typeof e=="object"&&e!==null}function R(e){if(!dc(e)||Object.prototype.toString.call(e)!=="[object Object]")return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}var rt=(e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){let{modulusLength:r}=t.algorithm;if(typeof r!="number"||r<2048)throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}};var Z=(e,t,r=0)=>{r===0&&(t.unshift(t.length),t.unshift(6));let n=e.indexOf(t[0],r);if(n===-1)return!1;let o=e.subarray(n,n+t.length);return o.length!==t.length?!1:o.every((a,s)=>a===t[s])||Z(e,t,n+1)},Qn=e=>{switch(!0){case Z(e,[42,134,72,206,61,3,1,7]):return"P-256";case Z(e,[43,129,4,0,34]):return"P-384";case Z(e,[43,129,4,0,35]):return"P-521";case Z(e,[43,101,110]):return"X25519";case Z(e,[43,101,111]):return"X448";case Z(e,[43,101,112]):return"Ed25519";case Z(e,[43,101,113]):return"Ed448";default:throw new A("Invalid or unsupported EC Key Curve or OKP Key Sub Type")}},fc=async(e,t,r,n,o)=>{let a,s,i=new Uint8Array(atob(r.replace(e,"")).split("").map(u=>u.charCodeAt(0))),c=t==="spki";switch(n){case"PS256":case"PS384":case"PS512":a={name:"RSA-PSS",hash:`SHA-${n.slice(-3)}`},s=c?["verify"]:["sign"];break;case"RS256":case"RS384":case"RS512":a={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${n.slice(-3)}`},s=c?["verify"]:["sign"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":a={name:"RSA-OAEP",hash:`SHA-${parseInt(n.slice(-3),10)||1}`},s=c?["encrypt","wrapKey"]:["decrypt","unwrapKey"];break;case"ES256":a={name:"ECDSA",namedCurve:"P-256"},s=c?["verify"]:["sign"];break;case"ES384":a={name:"ECDSA",namedCurve:"P-384"},s=c?["verify"]:["sign"];break;case"ES512":a={name:"ECDSA",namedCurve:"P-521"},s=c?["verify"]:["sign"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{let u=Qn(i);a=u.startsWith("P-")?{name:"ECDH",namedCurve:u}:{name:u},s=c?[]:["deriveBits"];break}case"EdDSA":a={name:Qn(i)},s=c?["verify"]:["sign"];break;default:throw new A('Invalid or unsupported "alg" (Algorithm) value')}return E.subtle.importKey(t,i,a,o?.extractable??!1,s)},eo=(e,t,r)=>fc(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g,"pkcs8",e,t,r);async function cr(e,t,r){if(typeof e!="string"||e.indexOf("-----BEGIN PRIVATE KEY-----")!==0)throw new TypeError('"pkcs8" must be PKCS#8 formatted string');return eo(e,t,r)}var lc=(e,t)=>{if(!(t instanceof Uint8Array)){if(!ir(t))throw new TypeError(sr(e,t,...b,"Uint8Array"));if(t.type!=="secret")throw new TypeError(`${b.join(" or ")} instances for symmetric algorithms must be of type "secret"`)}},mc=(e,t,r)=>{if(!ir(t))throw new TypeError(sr(e,t,...b));if(t.type==="secret")throw new TypeError(`${b.join(" or ")} instances for asymmetric algorithms must not be of type "secret"`);if(r==="sign"&&t.type==="public")throw new TypeError(`${b.join(" or ")} instances for asymmetric algorithm signing must be of type "private"`);if(r==="decrypt"&&t.type==="public")throw new TypeError(`${b.join(" or ")} instances for asymmetric algorithm decryption must be of type "private"`);if(t.algorithm&&r==="verify"&&t.type==="private")throw new TypeError(`${b.join(" or ")} instances for asymmetric algorithm verifying must be of type "public"`);if(t.algorithm&&r==="encrypt"&&t.type==="private")throw new TypeError(`${b.join(" or ")} instances for asymmetric algorithm encryption must be of type "public"`)},yc=(e,t,r)=>{e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?lc(e,t):mc(e,t,r)},Ie=yc;function Cc(e,t,r,n,o){if(o.crit!==void 0&&n.crit===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||n.crit===void 0)return new Set;if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some(s=>typeof s!="string"||s.length===0))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let a;r!==void 0?a=new Map([...Object.entries(r),...t.entries()]):a=t;for(let s of n.crit){if(!a.has(s))throw new A(`Extension Header Parameter "${s}" is not recognized`);if(o[s]===void 0)throw new e(`Extension Header Parameter "${s}" is missing`);if(a.get(s)&&n[s]===void 0)throw new e(`Extension Header Parameter "${s}" MUST be integrity protected`)}return new Set(n.crit)}var ye=Cc;var Kc=Symbol();function nt(e,t){let r=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:e.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:t.namedCurve};case"EdDSA":return{name:t.name};default:throw new A(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}function ot(e,t,r){if(D(t))return jn(t,e,r),t;if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw new TypeError($(t,...b));return E.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[r])}throw new TypeError($(t,...b,"Uint8Array"))}var Q=e=>Math.floor(e.getTime()/1e3);var Oc=/^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i,at=e=>{let t=Oc.exec(e);if(!t)throw new TypeError("Invalid time period format");let r=parseFloat(t[1]);switch(t[2].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":return Math.round(r);case"minute":case"minutes":case"min":case"mins":case"m":return Math.round(r*60);case"hour":case"hours":case"hr":case"hrs":case"h":return Math.round(r*3600);case"day":case"days":case"d":return Math.round(r*86400);case"week":case"weeks":case"w":return Math.round(r*604800);default:return Math.round(r*31557600)}};var Ic=async(e,t,r)=>{let n=await ot(e,t,"sign");rt(e,n);let o=await E.subtle.sign(nt(e,n.algorithm),n,r);return new Uint8Array(o)},so=Ic;var ge=class{constructor(t){if(!(t instanceof Uint8Array))throw new TypeError("payload must be an instance of Uint8Array");this._payload=t}setProtectedHeader(t){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=t,this}setUnprotectedHeader(t){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=t,this}async sign(t,r){if(!this._protectedHeader&&!this._unprotectedHeader)throw new N("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!me(this._protectedHeader,this._unprotectedHeader))throw new N("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let n={...this._protectedHeader,...this._unprotectedHeader},o=ye(N,new Map([["b64",!0]]),r?.crit,this._protectedHeader,n),a=!0;if(o.has("b64")&&(a=this._protectedHeader.b64,typeof a!="boolean"))throw new N('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:s}=n;if(typeof s!="string"||!s)throw new N('JWS "alg" (Algorithm) Header Parameter missing or invalid');Ie(s,t,"sign");let i=this._payload;a&&(i=x.encode(J(i)));let c;this._protectedHeader?c=x.encode(J(JSON.stringify(this._protectedHeader))):c=x.encode("");let u=X(c,x.encode("."),i),f=await so(s,t,u),d={signature:J(f),payload:""};return a&&(d.payload=W.decode(i)),this._unprotectedHeader&&(d.header=this._unprotectedHeader),this._protectedHeader&&(d.protected=W.decode(c)),d}};var We=class{constructor(t){this._flattened=new ge(t)}setProtectedHeader(t){return this._flattened.setProtectedHeader(t),this}async sign(t,r){let n=await this._flattened.sign(t,r);if(n.payload===void 0)throw new TypeError("use the flattened module for creating JWS with b64: false");return`${n.protected}.${n.payload}.${n.signature}`}};function we(e,t){if(!Number.isFinite(t))throw new TypeError(`Invalid ${e} input`);return t}var Ae=class{constructor(t={}){if(!R(t))throw new TypeError("JWT Claims Set MUST be an object");this._payload=t}setIssuer(t){return this._payload={...this._payload,iss:t},this}setSubject(t){return this._payload={...this._payload,sub:t},this}setAudience(t){return this._payload={...this._payload,aud:t},this}setJti(t){return this._payload={...this._payload,jti:t},this}setNotBefore(t){return typeof t=="number"?this._payload={...this._payload,nbf:we("setNotBefore",t)}:t instanceof Date?this._payload={...this._payload,nbf:we("setNotBefore",Q(t))}:this._payload={...this._payload,nbf:Q(new Date)+at(t)},this}setExpirationTime(t){return typeof t=="number"?this._payload={...this._payload,exp:we("setExpirationTime",t)}:t instanceof Date?this._payload={...this._payload,exp:we("setExpirationTime",Q(t))}:this._payload={...this._payload,exp:Q(new Date)+at(t)},this}setIssuedAt(t){return typeof t>"u"?this._payload={...this._payload,iat:Q(new Date)}:t instanceof Date?this._payload={...this._payload,iat:we("setIssuedAt",Q(t))}:this._payload={...this._payload,iat:we("setIssuedAt",t)},this}};var Je=class extends Ae{setProtectedHeader(t){return this._protectedHeader=t,this}async sign(t,r){let n=new We(x.encode(JSON.stringify(this._payload)));if(n.setProtectedHeader(this._protectedHeader),Array.isArray(this._protectedHeader?.crit)&&this._protectedHeader.crit.includes("b64")&&this._protectedHeader.b64===!1)throw new j("JWTs MUST NOT use unencoded payload");return n.sign(t,r)}};var kc;(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))&&(kc="jose/v5.1.0");var io=function e(t){function r(o,a,s){var i,c={};if(Array.isArray(o))return o.concat(a);for(i in o)c[s?i.toLowerCase():i]=o[i];for(i in a){var u=s?i.toLowerCase():i,f=a[i];c[u]=u in c&&typeof f=="object"?r(c[u],f,u=="headers"):f}return c}function n(o,a,s,i,c){var u=typeof o!="string"?(a=o).url:o,f={config:a},d=r(t,a),l={};i=i||d.data,(d.transformRequest||[]).map(function(h){i=h(i,d.headers)||i}),d.auth&&(l.authorization=d.auth),i&&typeof i=="object"&&typeof i.append!="function"&&typeof i.text!="function"&&(i=JSON.stringify(i),l["content-type"]="application/json");try{l[d.xsrfHeaderName]=decodeURIComponent(document.cookie.match(RegExp("(^|; )"+d.xsrfCookieName+"=([^;]*)"))[2])}catch{}return d.baseURL&&(u=u.replace(/^(?!.*\/\/)\/?/,d.baseURL+"/")),d.params&&(u+=(~u.indexOf("?")?"&":"?")+(d.paramsSerializer?d.paramsSerializer(d.params):new URLSearchParams(d.params))),(d.fetch||fetch)(u,{method:(s||d.method||"get").toUpperCase(),body:i,headers:r(d.headers,l,!0),credentials:d.withCredentials?"include":c}).then(function(h){for(var y in h)typeof h[y]!="function"&&(f[y]=h[y]);return d.responseType=="stream"?(f.data=h.body,f):h[d.responseType||"text"]().then(function(w){f.data=w,f.data=JSON.parse(w)}).catch(Object).then(function(){return(d.validateStatus?d.validateStatus(h.status):h.ok)?f:Promise.reject(f)})})}return t=t||{},n.request=n,n.get=function(o,a){return n(o,a,"get")},n.delete=function(o,a){return n(o,a,"delete")},n.head=function(o,a){return n(o,a,"head")},n.options=function(o,a){return n(o,a,"options")},n.post=function(o,a,s){return n(o,s,"post",a)},n.put=function(o,a,s){return n(o,s,"put",a)},n.patch=function(o,a,s){return n(o,s,"patch",a)},n.all=Promise.all.bind(Promise),n.spread=function(o){return o.apply.bind(o,o)},n.CancelToken=typeof AbortController=="function"?AbortController:Object,n.defaults=t,n.create=e,n}();var $c=e=>{if(!e)return!1;let t=JSON.parse(atob(e.split(".")[1])),r=Math.floor(Date.now()/1e3);return t.exp>r-600},st=async(e,t)=>{let r=await GCP_INVOKER_TOKEN.get(t);if($c(r))return r;let n=await cr(e.private_key,"RS256"),o=e.client_email,a={iss:o,sub:o,aud:"https://www.googleapis.com/oauth2/v4/token",target_audience:t,iat:Math.floor(Date.now()/1e3),exp:Math.floor(Date.now()/1e3)+3600},s=await new Je(a).setProtectedHeader({alg:"RS256",typ:"JWT"}).sign(n),i=await io.post("https://www.googleapis.com/oauth2/v4/token",{grant_type:"urn:ietf:params:oauth:grant-type:jwt-bearer",assertion:s});return await GCP_INVOKER_TOKEN.delete(t),await GCP_INVOKER_TOKEN.put(t,i.data.id_token),i.data.id_token};var co={get:uo.default};function ur({project_id:e,region:t,functionName:r,serviceAccount:n}){return async o=>{let a=co.get(o,"request.query",{}),s=new URLSearchParams(a).toString(),i=`https://${t}-${e}.cloudfunctions.net/${r}`,c=`https://${t}-${e}.cloudfunctions.net/${r}${s?`?${s}`:""}`;console.log("urlWithParms:",c);let u=await st(n,i);o.request.headers["X-Serverless-Authorization"]=`Bearer ${u}`;let f={headers:o.request.headers,method:o.request.method,redirect:"manual"};if(O.methodsMethodsWithBody.indexOf(o.request.method)!==-1&&co.get(o,"event.request.body")){let h=o.event.request.clone();f.body=h.body}let d=await fetch(c,f);o.body=d.body,o.status=d.status;let l=S.instanceToJson(d.headers);Object.keys(l).forEach(h=>{o.set(h,l[h])})}}var po=v(M());var qc={get:po.default};function pr({domain:e,serviceAccount:t}){return async r=>{let n=`${e}${r.request.path}`,o=await st(t,e);r.request.headers["X-Serverless-Authorization"]=`Bearer ${o}`;let a={headers:r.request.headers,method:r.request.method,redirect:"manual"};if(O.methodsMethodsWithBody.indexOf(r.request.method)!==-1&&qc.get(r,"event.request.body")){let c=r.event.request.clone();a.body=c.body}let s=await fetch(n,a);r.body=s.body,r.status=s.status;let i=S.instanceToJson(s.headers);Object.keys(i).forEach(c=>{r.set(c,i[c])})}}var ho={basicAuth:St,cache:Ct,cors:_t,geoDecorator:vt,jwt:Pt,kvStorage:Ht,kvStorageBinding:Tt,lambda:Ot,loadbalancer:Wt,logger:Nt,oauth2:Gt,origin:Vt,rateLimit:jt,response:zt,s3:Yt,signature:Qt,split:er,transform:tr,recaptcha:rr,userInputValidation:or,cloudfunction:ur,gcpCloudrun:pr};module.exports=class{constructor(t=[],r={}){this.router=new fo.default,t.forEach(n=>{let o=r[n.handlerName]||ho[n.handlerName];if(!o)throw new Error(`Handler ${n.handlerName} is not supported`);this.router.add(n,o(n.options))})}async resolve(t){return this.router.resolve(t)}};
|
|
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 s(d,l){let h=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",h,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 u(d){return d.replace(/[!'()*]/g,l=>"%"+l.charCodeAt(0).toString(16).toUpperCase())}function f(d,l){let{hostname:h,pathname:y}=d,w=h.replace("dualstack.","").match(/([^.]+)\.(?:([^.]*)\.)?amazonaws\.com(?:\.cn)?$/),[m,g]=(w||["",""]).slice(1,3);if(g==="us-gov")g="us-gov-west-1";else if(g==="s3"||g==="s3-accelerate")g="us-east-1",m="s3";else if(m==="iot")h.startsWith("iot.")?m="execute-api":h.startsWith("data.jobs.iot.")?m="iot-jobs-data":m=y==="/mqtt"?"iotdevicegateway":"iotdata";else if(m==="autoscaling"){let K=(l.get("X-Amz-Target")||"").split(".")[0];K==="AnyScaleFrontendService"?m="application-autoscaling":K==="AnyScaleScalingPlannerFrontendService"&&(m="autoscaling-plans")}else g==null&&m.startsWith("s3-")?(g=m.slice(3).replace(/^fips-|^external-1/,""),m="s3"):m.endsWith("-fips")?m=m.slice(0,-5):g&&/-\d$/.test(m)&&!/-\d$/.test(g)&&([m,g]=[g,m]);return[r[m]||m,g]}e.AwsClient=o,e.AwsV4Signer=a,Object.defineProperty(e,"__esModule",{value:!0})})});var ze=_((Sd,on)=>{var Za="Expected a function",jr="__lodash_hash_undefined__",Yr=1/0,Qa=9007199254740991,es="[object Function]",ts="[object GeneratorFunction]",rs="[object Symbol]",ns=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,os=/^\w*$/,as=/^\./,ss=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,is=/[\\^$.*+?()[\]{}|]/g,cs=/\\(\\)?/g,ds=/^\[object .+?Constructor\]$/,us=/^(?:0|[1-9]\d*)$/,ps=typeof global=="object"&&global&&global.Object===Object&&global,hs=typeof self=="object"&&self&&self.Object===Object&&self,Rt=ps||hs||Function("return this")();function fs(e,t){return e?.[t]}function ls(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var ms=Array.prototype,ys=Function.prototype,Zr=Object.prototype,xt=Rt["__core-js_shared__"],Gr=function(){var e=/[^.]+$/.exec(xt&&xt.keys&&xt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Qr=ys.toString,Be=Zr.hasOwnProperty,en=Zr.toString,gs=RegExp("^"+Qr.call(Be).replace(is,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Vr=Rt.Symbol,ws=ms.splice,As=tn(Rt,"Map"),Pe=tn(Object,"create"),zr=Vr?Vr.prototype:void 0,Xr=zr?zr.toString:void 0;function ae(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Ss(){this.__data__=Pe?Pe(null):{}}function Es(e){return this.has(e)&&delete this.__data__[e]}function bs(e){var t=this.__data__;if(Pe){var r=t[e];return r===jr?void 0:r}return Be.call(t,e)?t[e]:void 0}function Cs(e){var t=this.__data__;return Pe?t[e]!==void 0:Be.call(t,e)}function _s(e,t){var r=this.__data__;return r[e]=Pe&&t===void 0?jr:t,this}ae.prototype.clear=Ss;ae.prototype.delete=Es;ae.prototype.get=bs;ae.prototype.has=Cs;ae.prototype.set=_s;function he(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function vs(){this.__data__=[]}function Ps(e){var t=this.__data__,r=Ge(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():ws.call(t,r,1),!0}function Hs(e){var t=this.__data__,r=Ge(t,e);return r<0?void 0:t[r][1]}function Ks(e){return Ge(this.__data__,e)>-1}function Ts(e,t){var r=this.__data__,n=Ge(r,e);return n<0?r.push([e,t]):r[n][1]=t,this}he.prototype.clear=vs;he.prototype.delete=Ps;he.prototype.get=Hs;he.prototype.has=Ks;he.prototype.set=Ts;function se(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Os(){this.__data__={hash:new ae,map:new(As||he),string:new ae}}function xs(e){return Ve(this,e).delete(e)}function Rs(e){return Ve(this,e).get(e)}function Us(e){return Ve(this,e).has(e)}function Is(e,t){return Ve(this,e).set(e,t),this}se.prototype.clear=Os;se.prototype.delete=xs;se.prototype.get=Rs;se.prototype.has=Us;se.prototype.set=Is;function Ws(e,t,r){var n=e[t];(!(Be.call(e,t)&&rn(n,r))||r===void 0&&!(t in e))&&(e[t]=r)}function Ge(e,t){for(var r=e.length;r--;)if(rn(e[r][0],t))return r;return-1}function Js(e){if(!Le(e)||Fs(e))return!1;var t=Vs(e)||ls(e)?gs:ds;return t.test(Gs(e))}function Ns(e,t,r,n){if(!Le(e))return e;t=$s(t,e)?[t]:Ds(t);for(var o=-1,a=t.length,s=a-1,i=e;i!=null&&++o<a;){var c=Bs(t[o]),u=r;if(o!=s){var f=i[c];u=n?n(f,c,i):void 0,u===void 0&&(u=Le(f)?f:Ms(t[o+1])?[]:{})}Ws(i,c,u),i=i[c]}return e}function ks(e){if(typeof e=="string")return e;if(It(e))return Xr?Xr.call(e):"";var t=e+"";return t=="0"&&1/e==-Yr?"-0":t}function Ds(e){return nn(e)?e:Ls(e)}function Ve(e,t){var r=e.__data__;return qs(t)?r[typeof t=="string"?"string":"hash"]:r.map}function tn(e,t){var r=fs(e,t);return Js(r)?r:void 0}function Ms(e,t){return t=t??Qa,!!t&&(typeof e=="number"||us.test(e))&&e>-1&&e%1==0&&e<t}function $s(e,t){if(nn(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||It(e)?!0:os.test(e)||!ns.test(e)||t!=null&&e in Object(t)}function qs(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Fs(e){return!!Gr&&Gr in e}var Ls=Ut(function(e){e=Xs(e);var t=[];return as.test(e)&&t.push(""),e.replace(ss,function(r,n,o,a){t.push(o?a.replace(cs,"$1"):n||r)}),t});function Bs(e){if(typeof e=="string"||It(e))return e;var t=e+"";return t=="0"&&1/e==-Yr?"-0":t}function Gs(e){if(e!=null){try{return Qr.call(e)}catch{}try{return e+""}catch{}}return""}function Ut(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(Za);var r=function(){var n=arguments,o=t?t.apply(this,n):n[0],a=r.cache;if(a.has(o))return a.get(o);var s=e.apply(this,n);return r.cache=a.set(o,s),s};return r.cache=new(Ut.Cache||se),r}Ut.Cache=se;function rn(e,t){return e===t||e!==e&&t!==t}var nn=Array.isArray;function Vs(e){var t=Le(e)?en.call(e):"";return t==es||t==ts}function Le(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function zs(e){return!!e&&typeof e=="object"}function It(e){return typeof e=="symbol"||zs(e)&&en.call(e)==rs}function Xs(e){return e==null?"":ks(e)}function js(e,t,r){return e==null?e:Ns(e,t,r)}on.exports=js});var hn=_(kt=>{"use strict";kt.parse=oi;kt.serialize=ai;var ti=decodeURIComponent,ri=encodeURIComponent,ni=/; */,je=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function oi(e,t){if(typeof e!="string")throw new TypeError("argument str must be a string");for(var r={},n=t||{},o=e.split(ni),a=n.decode||ti,s=0;s<o.length;s++){var i=o[s],c=i.indexOf("=");if(!(c<0)){var u=i.substr(0,c).trim(),f=i.substr(++c,i.length).trim();f[0]=='"'&&(f=f.slice(1,-1)),r[u]==null&&(r[u]=si(f,a))}}return r}function ai(e,t,r){var n=r||{},o=n.encode||ri;if(typeof o!="function")throw new TypeError("option encode is invalid");if(!je.test(e))throw new TypeError("argument name is invalid");var a=o(t);if(a&&!je.test(a))throw new TypeError("argument val is invalid");var s=e+"="+a;if(n.maxAge!=null){var i=n.maxAge-0;if(isNaN(i)||!isFinite(i))throw new TypeError("option maxAge is invalid");s+="; Max-Age="+Math.floor(i)}if(n.domain){if(!je.test(n.domain))throw new TypeError("option domain is invalid");s+="; Domain="+n.domain}if(n.path){if(!je.test(n.path))throw new TypeError("option path is invalid");s+="; Path="+n.path}if(n.expires){if(typeof n.expires.toUTCString!="function")throw new TypeError("option expires is invalid");s+="; Expires="+n.expires.toUTCString()}if(n.httpOnly&&(s+="; HttpOnly"),n.secure&&(s+="; Secure"),n.sameSite){var c=typeof n.sameSite=="string"?n.sameSite.toLowerCase():n.sameSite;switch(c){case!0:s+="; SameSite=Strict";break;case"lax":s+="; SameSite=Lax";break;case"strict":s+="; SameSite=Strict";break;case"none":s+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return s}function si(e,t){try{return t(e)}catch{return e}}});var ln=_((kd,fn)=>{"use strict";var Ye=1;function ii(){return Ye=(Ye*9301+49297)%233280,Ye/233280}function ci(e){Ye=e}fn.exports={nextValue:ii,seed:ci}});var Oe=_((Dd,wn)=>{"use strict";var Dt=ln(),ce="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-",z,mn,Te;function Mt(){Te=!1}function yn(e){if(!e){z!==ce&&(z=ce,Mt());return}if(e!==z){if(e.length!==ce.length)throw new Error("Custom alphabet for shortid must be "+ce.length+" unique characters. You submitted "+e.length+" characters: "+e);var t=e.split("").filter(function(r,n,o){return n!==o.lastIndexOf(r)});if(t.length)throw new Error("Custom alphabet for shortid must be "+ce.length+" unique characters. These characters were not unique: "+t.join(", "));z=e,Mt()}}function di(e){return yn(e),z}function ui(e){Dt.seed(e),mn!==e&&(Mt(),mn=e)}function pi(){z||yn(ce);for(var e=z.split(""),t=[],r=Dt.nextValue(),n;e.length>0;)r=Dt.nextValue(),n=Math.floor(r*e.length),t.push(e.splice(n,1)[0]);return t.join("")}function gn(){return Te||(Te=pi(),Te)}function hi(e){var t=gn();return t[e]}function fi(){return z||ce}wn.exports={get:fi,characters:di,seed:ui,lookup:hi,shuffled:gn}});var Sn=_((Md,An)=>{"use strict";var $t=typeof window=="object"&&(window.crypto||window.msCrypto),qt;!$t||!$t.getRandomValues?qt=function(e){for(var t=[],r=0;r<e;r++)t.push(Math.floor(Math.random()*256));return t}:qt=function(e){return $t.getRandomValues(new Uint8Array(e))};An.exports=qt});var bn=_(($d,En)=>{En.exports=function(e,t,r){for(var n=(2<<Math.log(t.length-1)/Math.LN2)-1,o=-~(1.6*n*r/t.length),a="";;)for(var s=e(o),i=o;i--;)if(a+=t[s[i]&n]||"",a.length===+r)return a}});var _n=_((qd,Cn)=>{"use strict";var li=Oe(),mi=Sn(),yi=bn();function gi(e){for(var t=0,r,n="";!r;)n=n+yi(mi,li.get(),1),r=e<Math.pow(16,t+1),t++;return n}Cn.exports=gi});var Hn=_((Ld,Pn)=>{"use strict";var Ze=_n(),Fd=Oe(),wi=1567752802062,Ai=7,Qe,vn;function Si(e){var t="",r=Math.floor((Date.now()-wi)*.001);return r===vn?Qe++:(Qe=0,vn=r),t=t+Ze(Ai),t=t+Ze(e),Qe>0&&(t=t+Ze(Qe)),t=t+Ze(r),t}Pn.exports=Si});var Tn=_((Bd,Kn)=>{"use strict";var Ei=Oe();function bi(e){if(!e||typeof e!="string"||e.length<6)return!1;var t=new RegExp("[^"+Ei.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]");return!t.test(e)}Kn.exports=bi});var xn=_((Gd,On)=>{"use strict";On.exports=0});var In=_((Vd,B)=>{"use strict";var Ft=Oe(),Ci=Hn(),_i=Tn(),Rn=xn()||0;function vi(e){return Ft.seed(e),B.exports}function Pi(e){return Rn=e,B.exports}function Hi(e){return e!==void 0&&Ft.characters(e),Ft.shuffled()}function Un(){return Ci(Rn)}B.exports=Un;B.exports.generate=Un;B.exports.seed=vi;B.exports.worker=Pi;B.exports.characters=Hi;B.exports.isValid=_i});var Jn=_((zd,Wn)=>{"use strict";Wn.exports=In()});var lo=v(vr());var Dr=v(M()),Ra={get:Dr.default};function At(e){e.status=401,e.body="Unauthorized",e.set("WWW-Authenticate","Basic")}function St(e){return async(t,r)=>{if(t.request.path===e.logoutPath)return At(t);let n=Ra.get(t,"request.headers.authorization");if(!n||!n.startsWith("Basic "))return At(t);let o=e.users.map(i=>i.authToken),a=n.substring(6),s=o.indexOf(a);return s===-1?At(t):(t.state.user=e.users[s].username,r(t))}}var Mr=caches.default;async function Ua(e){return await Mr.match(e)}async function Ia(e,t){return Mr.put(e.href,t)}var Et={get:Ua,set:Ia};async function Wa(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 $r=Wa;function Ja(e,t={}){return Object.keys(t).reduce((r,n)=>r.replace(`{${n}}`,t[n]),e)}function bt(e){return[...e].reduce((t,r)=>{let n={};return n[r[0]]=r[1],{...t,...n}},{})}var S={resolveParams:Ja,instanceToJson:bt};var Na=["x-ratelimit-count","x-ratelimit-limit","x-ratelimit-reset","x-cache-hit"];async function ka(e){return["POST","PATCH","PUT","DELETE"].indexOf(e.method)===-1?null:e.text()}async function Da(e,t){if(!t)return e.event.request;let r=t.match(/{.*?}/gi).map(a=>a.slice(1,-1)),n={};for(let a=0;a<r.length;a+=1){let s=r[a],i=s.split(":");switch(i[0]){case"method":n[s]=e.request.method;break;case"path":n[s]=e.request.path;break;case"bodyHash":n[s]=await $r(await ka(e.request));break;case"header":n[s]=e.request.headers[i[1]]||"";break;default:n[s]=s}}let o=encodeURIComponent(t.replace(/({(.*?)})/gi,(a,s,i)=>n[i]));return new Request(`http://${e.request.hostname}/${o}`)}function Ct({cacheDuration:e,cacheKeyTemplate:t,headerBlacklist:r=Na}){return async(n,o)=>{let a=await Da(n,t),s=await Et.get(a);if(s){n.body=s.body,n.status=s.status;let i=bt(s.headers);Object.keys(i).forEach(c=>{n.set(c,i[c])}),n.set("X-Cache-Hit",!0)}else{await o(n);let i;n.body.tee?[n.body,i]=n.body.tee():i=n.body;let c=new Response(i,{status:n.status});Object.keys(n.response.headers).forEach(u=>{r.indexOf(u.toLowerCase())===-1&&c.headers.set(u,n.response.headers[u])}),e&&(c.headers.delete("Cache-Control"),c.headers.set("Cache-Control",`max-age=${e}`)),n.event.waitUntil(Et.set(a,c))}}}function _t({allowedOrigins:e=["*"],allowedMethods:t=["GET","PUT","POST","PATCH","DELETE","HEAD","OPTIONS"],allowCredentials:r=!0,allowedHeaders:n=["Content-Type"],allowedExposeHeaders:o=["WWW-Authenticate","Server-Authorization"],maxAge:a=600,optionsSuccessStatus:s=204,terminatePreflight:i=!1}){return async(c,u)=>{let{method:f}=c.request,{origin:d}=c.request.headers,l=c.request.headers["access-control-request-headers"];if(Ma(c,d,e),$a(c,r),Ba(c,o),f==="OPTIONS"&&(qa(c,t),Fa(c,l,n),La(c,a),i)){c.status=s,c.set("Content-Length","0"),c.body="";return}await u(c)}}function Ma(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 $a(e,t){t&&e.set("Access-Control-Allow-Credentials",t)}function qa(e,t){e.set("Access-Control-Allow-Methods",t.join(","))}function Fa(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 La(e,t){t&&e.set("Access-Control-Max-Age",t)}function Ba(e,t){t.length&&e.set("Access-Control-Expose-Headers",t.join(","))}var Ga={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 vt(){return async(e,t)=>{let r=e.request.headers["cf-ipcountry"]||"XX";e.request.headers["proxy-continent"]=Ga[r],await t(e)}}function Va(e){let t=e.split("."),r=JSON.parse(atob(t[0])),n=JSON.parse(atob(t[1])),o=atob(t[2].replace(/-/g,"+").replace(/_/g,"/"));return{header:r,payload:n,signature:o,raw:{header:t[0],payload:t[1],signature:t[2]}}}function Pt({jwksUri:e,iss:t,aud:r,allowPublicAccess:n=!1}){async function o(){return(await(await fetch(e)).json()).keys}function a(c){return c.status=403,c.body="Forbidden",c}async function s(c){let f=new TextEncoder().encode([c.raw.header,c.raw.payload].join(".")),d=new Uint8Array(Array.from(c.signature).map(y=>y.charCodeAt(0))),l=await o();return(await Promise.all(l.map(async y=>{let w=await crypto.subtle.importKey("jwk",y,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["verify"]);return crypto.subtle.verify("RSASSA-PKCS1-v1_5",w,d,f)}))).some(y=>y)}async function i(c,u){if(c.request.method==="OPTIONS"||n)return u(c);if((c.request.headers.authorization||"").toLowerCase().startsWith("bearer")){let d=Va(c.request.headers.authorization.slice(7)),l=new Date(d.payload.exp*1e3),h=new Date(Date.now());return l<=h||!t||d.payload.iss!==t||!r||d.payload.aud!==r||!await s(d)?a(c):(c.state.user=d.payload,u(c))}return a(c)}return i}var qr=v(M()),za={get:qr.default},oe=class{constructor({accountId:t,namespace:r,authEmail:n,authKey:o,ttl:a}){this.accountId=t,this.namespace=r,this.authEmail=n,this.authKey=o,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 n=`${this.getNamespaceUrl()}/keys?prefix=${t}&limit=${r}`,o=await fetch(n,{headers:{"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey}});return o.ok?o.json():null}async get(t,r){let n=this.getUrlForKey(t),o=await fetch(n,{headers:{"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey}});if(o.ok)switch(r){case"json":return o.json();case"stream":return o;case"arrayBuffer":return o.arrayBuffer();default:return o.text()}return null}async getWithMetadata(t,r){let[n,o]=await Promise.all([this.get(t,r),this.list(t)]),a=za.get(o,"result.0.metadata",{});return{value:n,metadata:a}}async put(t,r,n={}){let o=this.getUrlForKey(t),a=new URLSearchParams;this.ttl&&a.append("expiration_ttl",this.ttl.toString());let s={"X-Auth-Email":this.authEmail,"X-Auth-Key":this.authKey};o.search=a.toString();let i=new FormData;return i.append("value",r),i.append("metadata",JSON.stringify(n)),(await fetch(o.toString(),{method:"PUT",headers:s,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 O={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 Xa(e,t,r){if(e==="/"&&r)return r;let n=e.split("/").pop();return n.split(".").pop()!==n?e:`${e}.${t}`}function Ht({kvAccountId:e,kvNamespace:t,kvAuthEmail:r,kvAuthKey:n,kvBasePath:o="",kvKey:a="{file}",defaultExtension:s="html",defaultIndexDocument:i,defaultErrorDocument:c,mime:u={},mode:f="rest"}){let d=new oe({accountId:e,namespace:t,authEmail:r,authKey:n,mode:f}),l={...O.mime,...u};return async h=>{let y=S.resolveParams(a,h.params),w=y===""&&i?i:Xa(y,s),m=await d.get(o+w);!m&&c&&(m=await d.get(o+c)),m?(h.status=200,h.body=m,h.set("Content-Type",l[w.split(".").pop()]||"text/plain")):(h.status=404,h.body=O.http.statusMessages[404],h.set("Content-Type","text/plain"))}}var Fr=v(M());var Kt={get:Fr.default};function ja(e,t,r){if(e==="/"&&r)return r;let n=e.split("/").pop();return n.split(".").pop()!==n?e:`${e}.${t}`}function Ya(e,t){let r=Kt.get(e,"headers.if-none-match"),n=Kt.get(t,"metadata.headers.etag");return r?r===n:!1}function Tt({kvNamespaceBinding:e,kvBasePath:t="",kvKey:r="{file}",defaultExtension:n="html",defaultIndexDocument:o,defaultErrorDocument:a}){async function s(i){return await global[e].getWithMetadata(i)}return async i=>{let c=S.resolveParams(r,i.params),u=c===""&&o?o:ja(c,n),f=await s(t+u);if(!f&&a&&(f=await s(t+a)),f)if(Ya(i.request,f))i.status=304;else{i.status=f.status,i.body=f.value;let d=Kt.get(f,"metadata.headers",{});Object.keys(d).forEach(l=>{i.set(l,d[l])})}else i.status=404,i.body=O.http.statusMessages[404],i.set("Content-Type","text/plain")}}var Br=v(Fe());function Ot({accessKeyId:e,secretAccessKey:t,region:r,lambdaName:n}){let o=new Br.AwsClient({accessKeyId:e,secretAccessKey:t});return async a=>{let s=`https://lambda.${r}.amazonaws.com/2015-03-31/functions/${n}/invocations`,i={},c=await o.fetch(s,{body:JSON.stringify(i)});a.status=c.status,a.body=c.body;let u=S.instanceToJson(c.headers);Object.keys(u).forEach(f=>{a.set(f,u[f])})}}var sn=v(M()),cn=v(ze());var an={get:sn.default,set:cn.default};function Ys(e){let t={};return Object.keys(e).forEach(r=>{r.startsWith("cf")||(t[r]=e[r])}),t}function Zs(e){return e[Math.floor(Math.random()*e.length)]}function Wt({sources:e=[]}){return async t=>{let r=Zs(e),n={method:t.request.method,headers:Ys(t.request.headers),redirect:"manual",cf:t.request.cf};if(O.methodsMethodsWithBody.indexOf(t.request.method)!==-1&&an.get(t,"event.request.body")){let i=t.event.request.clone();n.body=i.body}let o=S.resolveParams(r.url,t.params);if(r.resolveOverride){let i=S.resolveParams(r.resolveOverride,t.request.params);an.set(n,"cf.resolveOverride",i)}let a=await fetch(o+t.request.search,n);t.body=a.body,t.status=a.status;let s=S.instanceToJson(a.headers);Object.keys(s).forEach(i=>{t.set(i,s[i])})}}var pn=v(M());var Jt={name:"@ahmadissa/cloudworker-proxy",version:"1.1.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",jose:"^5.1.0","lodash.get":"4.4.2","lodash.set":"4.3.2",redaxios:"^0.5.1",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 ie=class{constructor({maxSize:t=10,maxSeconds:r=10,sink:n}){this.maxSize=t,this.maxSeconds=r,this.queue=[],this.sink=n,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,n)=>{this.resolveTimer=r,this.rejectTimer=n,this.cancelationToken=setTimeout(async()=>{try{r(await this.flush())}catch(o){n(o)}},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(t);this.timer&&(clearTimeout(this.cancelationToken),this.resolveTimer(r))}catch(t){this.timer&&this.rejectTimer(t)}finally{this.timer=null,this.flushing=!1}}}};function dn(e,t=".",r=""){return e instanceof Object?Object.keys(e).reduce((n,o)=>e[o]==null?n:{...n,...dn(e[o],t,r+o+t)},{}):r.endsWith(t)?{[r.slice(0,r.length-1)]:e}:{[r]:e}}var Xe=dn;var He=class{constructor(t){this.url=t.url,this.contentType=t.contentType,this.delimiter=t.delimiter,this.chunker=new ie({sink:this.sendMessage.bind(this),...t})}async log(t){let r=Xe(t,this.delimiter);await this.chunker.push(JSON.stringify(r))}async sendMessage(t){return fetch(this.url,{body:t,method:"POST",headers:{"Content-Type":this.contentType}})}};var un=v(Fe());var Ke=class{constructor(t){this.delimiter=t.delimiter,this.chunker=new ie({sink:this.sendMessage.bind(this),...t}),this.awsClient=new un.AwsClient({accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey,region:t.region}),this.streamName=t.streamName,this.region=t.region}async log(t){let r=Xe(t,this.delimiter);await this.chunker.push(JSON.stringify(r))}async sendMessage(t){let r=btoa(`${JSON.stringify(t)}
|
|
7
|
+
`),n=JSON.stringify({DeliveryStreamName:this.streamName,Record:{Data:r}}),o=`https://firehose.${this.region}.amazonaws.com`,a=new Request(o,{method:"POST",body:n,headers:{"X-Amz-Target":"Firehose_20150804.PutRecord","Content-Type":" application/x-amz-json-1.1"}});return this.awsClient.fetch(a)}};var I={get:pn.default};async function ei(e){return["POST","PATCH","PUT","DELETE"].indexOf(e.method)===-1?null:e.text()}function Nt(e){let t;switch(e.type){case"http":t=new He(e);break;case"kinesis":t=new Ke(e);break;default:throw new Error(`Log service type not supported: ${e.type}`)}return async(r,n)=>{r.state["logger-startDate"]=new Date;let o=await ei(r.request);try{await n(r);let a={message:"START",requestIp:I.get(r,"request.headers.x-real-ip"),requestId:I.get(r,"request.requestId"),request:{headers:I.get(r,"request.headers"),method:I.get(r,"request.method"),url:I.get(r,"request.href"),protocol:I.get(r,"request.protocol"),body:o},response:{status:r.status,headers:I.get(r,"response.headers")},handlers:I.get(r,"state.handlers",[]).join(","),route:I.get(r,"route.name"),timestamp:new Date().toISOString(),ttfb:new Date-r.state["logger-startDate"],redirectUrl:r.userRedirect,severity:30,proxyVersion:Jt.version};r.event.waitUntil(t.log(a))}catch(a){let s={request:{headers:I.get(r,"request.headers"),method:I.get(r,"request.method"),handlers:I.get(r,"state.handlers",[]).join(","),url:I.get(r,"request.href"),body:o},message:"ERROR",stack:a.stack,error:a.message,severity:50,proxyVersion:Jt.version};r.event.waitUntil(t.log(s))}}}var xe=v(hn()),Mn=v(M()),$n=v(ze()),qn=v(Jn());async function Lt({refresh_token:e,authDomain:t,clientId:r,clientSecret:n}){let o=`${t}/oauth/token`,a=await fetch(o,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",client_id:r,client_secret:n,refresh_token:e})});if(!a.ok)throw new Error("Authentication failed");let s=await a.json();return{...s,expires:Date.now()+s.expires_in*1e3,refresh_token:e}}var Nn="PBKDF2",Bt="AES-GCM",Ki="SHA-256",Ti="raw";function Oi(e){let t=atob(e.replace(/_/g,"/").replace(/-/g,"+")),r=t.length,n=new Uint8Array(r);for(let o=0;o<r;o+=1)n[o]=t.charCodeAt(o);return n.buffer}function kn(e){let t="",r=new Uint8Array(e),n=r.byteLength;for(let o=0;o<n;o+=1)t+=String.fromCharCode(r[o]);return btoa(t).replace(/\//g,"_").replace(/\+/g,"-")}function xi(e){return String.fromCharCode.apply(null,new Uint16Array(e))}function Ri(e){let t=new ArrayBuffer(e.length*2),r=new Uint16Array(t);for(let n=0,o=e.length;n<o;n+=1)r[n]=e.charCodeAt(n);return t}async function Ui(e){let t=new TextEncoder;return crypto.subtle.importKey(Ti,t.encode(e),{name:Nn},!1,["deriveKey"])}async function Ii(e,t){let r=await Ui(e),o=new TextEncoder().encode(t.replace(/_/g,"/").replace(/-/g,"+"));return crypto.subtle.deriveKey({name:Nn,salt:o,iterations:1e3,hash:{name:Ki}},r,{name:Bt,length:256},!0,["encrypt","decrypt"])}async function Wi(){let e=crypto.getRandomValues(new Uint8Array(8));return kn(e)}async function Ji(e,t){let r=Oi(t),n=r.slice(0,16),o=r.slice(16),a=await crypto.subtle.decrypt({name:Bt,iv:n},e,o);return xi(a)}async function Ni(e,t){let r=crypto.getRandomValues(new Uint8Array(16)),n=await crypto.subtle.encrypt({name:Bt,iv:r},e,Ri(t)),o=new Uint8Array(n.byteLength+r.byteLength);return o.set(r,0),o.set(new Uint8Array(n),r.byteLength),kn(o)}var de={decrypt:Ji,deriveAesGcmKey:Ii,encrypt:Ni,getSalt:Wi};var fe={get:Mn.default,set:$n.default};function Dn({cookieHeader:e="",cookieName:t}){return xe.default.parse(e)[t]}function ki(e){return Object.keys(e).map(t=>`${t}=${encodeURIComponent(e[t])}`).join("&")}function Di(e=""){return e.split(",").indexOf("text/html")!==-1}function Gt({cookieName:e="proxy",cookieHttpOnly:t=!0,allowPublicAccess:r=!1,kvAccountId:n,kvNamespace:o,kvAuthEmail:a,kvAuthKey:s,kvTtl:i=2592e3,oauth2AuthDomain:c,oauth2ClientId:u,oauth2ClientSecret:f,oauth2Audience:d,oauth2Scopes:l=[],oauth2CallbackPath:h="/callback",oauth2CallbackType:y="cookie",oauth2LogoutPath:w="/logout",oauth2LoginPath:m="/login",oauth2ServerTokenPath:g="/oauth/token",oauth2ServerAuthorizePath:K="",oauth2ServerLogoutPath:k}){let U=new oe({accountId:n,namespace:o,authEmail:a,authKey:s,ttl:i}),ee=c,Se=h,it=y,ct=g,Ne=K,dt=k,V=u,Ee=f,q=d,ke=w,C=m,Ce=l.join("%20");async function De(p,H){let P=`${ee}${ct}`,T=await fetch(P,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:ki({code:p,grant_type:"authorization_code",client_id:V,client_secret:Ee,redirect_uri:H})});if(!T.ok)throw new Error("Authentication failed");let F=await T.json();return{...F,expires:Date.now()+F.expires_in*1e3}}async function mo(p){if(Dn({cookieHeader:p.request.headers.cookie,cookieName:e})){let T=p.request.hostname.match(/[^.]+\.[^.]+$/i)[0];p.set("Set-Cookie",xe.default.serialize(e,"",{domain:`.${T}`,path:"/",maxAge:0}))}let P=fr(p);if(k){let T=encodeURIComponent(`${p.request.protocol}://${p.request.host}${P}`);p.set("Location",`${ee}${dt}?client_id=${V}&returnTo=${T}`)}else p.set("Location",P);p.status=302}async function yo(p){let H=p.request.href.split("?")[0],P=await De(p.request.query.code,H),T=qn.default.generate(),F=await de.getSalt(),L=`${T}.${F}`,ut=await de.deriveAesGcmKey(T,F),te=await de.encrypt(ut,JSON.stringify(P));await U.put(T,te);let pt=p.request.hostname.match(/[^.]+\.[^.]+$/i)[0];p.status=302,it==="query"?p.set("Location",`${p.request.query.state}?auth=${L}`):(p.set("Set-Cookie",xe.default.serialize(e,L,{httpOnly:t,domain:`.${pt}`,path:"/",maxAge:60*60*24*365})),p.set("Location",p.request.query.state))}async function go(p,H){let[P,T]=H.split("."),F=await U.get(P);if(F){let L=await de.deriveAesGcmKey(P,T),ut=await de.decrypt(L,F),te=JSON.parse(ut);if(te.expires<Date.now()){te=await Lt({refresh_token:te.refresh_token,clientId:V,authDomain:ee,clientSecret:Ee});let pt=await de.encrypt(L,JSON.stringify(te));await U.put(P,pt)}p.state.accessToken=te.access_token,p.state.accessToken&&(p.request.headers.authorization=`bearer ${p.state.accessToken}`)}else{let L=p.request.hostname.match(/[^.]+\.[^.]+$/i)[0];p.set("Set-Cookie",xe.default.serialize(e,"",{domain:`.${L}`,maxAge:0}))}}function fr(p){let H=fe.get(p,"request.query.redirect-to");if(H)return H;let P=fe.get(p,"request.headers.referer");return P||"/"}async function wo(p){if(p.request.method==="OPTIONS")p.status=200;else{let H=fr(p),P=encodeURIComponent(H||"/"),T=encodeURIComponent(`${p.request.protocol}://${p.request.host}${Se}`);p.status=302,p.set("location",`${ee}${Ne}/authorize?state=${P}&client_id=${V}&response_type=code&scope=${Ce}&audience=${q}&redirect_uri=${T}`)}}async function Ao(p,H){if(p.request.method==="OPTIONS")await H(p);else if(fe.get(p,"request.headers.authorization","").toLowerCase().startsWith("bearer "))fe.set(p,"state.access_token",p.request.headers.authorization.slice(7)),await H(p);else{let P=fe.get(p,"request.query.auth")||Dn({cookieHeader:p.request.headers.cookie,cookieName:e});if(P&&await go(p,P),fe.get(p,"state.accessToken")||r)await H(p);else if(Di(p.request.headers.accept)){let F=encodeURIComponent(p.request.href),L=encodeURIComponent(`${p.request.protocol}://${p.request.host}${Se}`);p.status=302,p.set("location",`${ee}${Ne}/authorize?state=${F}&client_id=${V}&response_type=code&scope=${Ce}&audience=${q}&redirect_uri=${L}`)}else p.status=403,p.body="Forbidden"}}return async(p,H)=>{switch(p.request.path){case Se:await yo(p);break;case ke:await mo(p);break;case C:await wo(p);break;default:await Ao(p,H)}}}var Fn=v(M());var Mi={get:Fn.default};function $i(e){let t={};return Object.keys(e).forEach(r=>{r.startsWith("cf")||(t[r]=e[r])}),t}function Vt(e){let{localOriginOverride:t,backend:r}=e;return async n=>{let o=process.env.LOCAL?`${t||n.request.origin}${n.request.path}`:`${r}${n.request.path}`,a={headers:$i(n.request.headers),method:n.request.method,redirect:"manual"};if(O.methodsMethodsWithBody.indexOf(n.request.method)!==-1&&Mi.get(n,"event.request.body")){let c=n.event.request.clone();a.body=c.body}let s=await fetch(o,a);n.body=s.body,n.status=s.status;let i=S.instanceToJson(s.headers);Object.keys(i).forEach(c=>{n.set(c,i[c])})}}function zt({body:e="",headers:t={},status:r=200}){return async n=>{e instanceof Object?(n.body=JSON.stringify(e),n.set("Content-Type","application/json")):n.body=S.resolveParams(e,n.params),n.status=r,Object.keys(t).forEach(o=>{n.set(o,S.resolveParams(t[o],n.params))})}}var Ln=v(M()),Bn=v(ze()),Xt={get:Ln.default,set:Bn.default};function jt({type:e="IP",scope:t="default",limit:r=1e3}){let n={};function o(s,i){let c=i["x-real-ip"];return e==="IP"?`minute.${s}.${t}.${c}`:`minute.${s}.${t}.account`}function a(s){let i=Xt.get(n,"minutes",{});Object.keys(i).forEach(c=>{c!==s&&delete n.minutes.minute})}return async(s,i)=>{let c=Math.trunc(Date.now()/6e4),u=Math.trunc(c*60+60-Date.now()/1e3),f=o(c,s.request.headers),d=Xt.get(n,f,0);if(["HEAD","OPTIONS"].indexOf(s.request.method)===-1&&(d+=1),Xt.set(n,f,d),r<d){s.status=429;return}a(c),await i(s)}}var Gn=v(Fe());function qi(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:n,endpoint:o,forcePathStyle:a,enableBucketOperations:s=!1}){let i=new Gn.AwsClient({accessKeyId:e,region:n,secretAccessKey:t}),c=qi(o,{region:n,bucket:r,forcePathStyle:a});return async u=>{if(u.params.file===void 0&&!s){u.status=404,u.body=O.http.statusMessages[404],u.set("Content-Type","text/plain");return}let f=u.params.file?S.resolveParams(`${c}/{file}`,u.params):c,d={};u.request.headers.range&&(d.range=u.request.headers.range);let l=await i.fetch(f,{method:u.method||u.request.method,headers:d});u.status=l.status,u.body=l.body;let h=S.instanceToJson(l.headers);Object.keys(h).forEach(y=>{u.set(y,h[y])})}}var Zt;function Vn(e){return new Uint8Array(e.split("").map(r=>r.charCodeAt(0)))}async function Fi(e){return Zt||(Zt=await crypto.subtle.importKey("raw",Vn(e),{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign","verify"])),Zt}async function Li(e,t){let r=await Fi(t),n=await crypto.subtle.sign({name:"HMAC"},r,Vn(e));return btoa(String.fromCharCode.apply(null,new Uint8Array(n))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Qt({secret:e}){return async(t,r)=>{let n=(t.request.path+t.request.search).replace(/([?|&]sign=[\w|-]+)/,"");if(await Li(n,e)!==t.query.sign){t.status=403;return}await r(t)}}function er({host:e}){if(!e)throw new Error("Need to specify a host for the split middleware.");return async(t,r)=>{let n=t.clone();n.cloned=!0,n.request={...n.request,href:n.request.href.replace(n.request.href,e),host:e},t.event.waitUntil(r(n)),await r(t)}}async function Bi(e,t,r){let n=e.getReader(),o=t.getWriter(),a=new TextDecoder,s=new TextEncoder;for(;;){let{done:i,value:c}=await n.read();if(i)break;let u=a.decode(c),f=zn(u,r),d=s.encode(f);await o.write(d)}await o.close()}function Gi(e,t){return e.replace(/{{\$(\d)}}/g,(r,n)=>t[parseInt(n,10)])}function zn(e,t){return t.reduce((r,n)=>r.replace(n.regex,(...o)=>Gi(n.replace,o)),e)}function tr({transforms:e=[],statusCodes:t=[200]}){let r=e.map(n=>({regex:new RegExp(n.regex,"g"),replace:n.replace}));return async(n,o)=>{await o(n);let{body:a}=n;if(t.indexOf(n.status)!==-1)if(typeof a=="string")n.body=zn(a,r);else{let{readable:s,writable:i}=new TransformStream;Bi(a,i,r),n.body=s}}}async function Vi({projectID:e="your-project-id",API_KEY:t="GCP_API_KEY",token:r="action-token",siteKey:n="siteKey",expectedAction:o="action-name"}){let s=await(await fetch(`https://recaptchaenterprise.googleapis.com/v1/projects/${e}/assessments?key=${t}`,{body:JSON.stringify({event:{token:r,siteKey:n,expectedAction:o}}),headers:{"Content-Type":"application/json"},method:"POST"})).json();return s.tokenProperties.valid?s.tokenProperties.action===o?(s.riskAnalysis.reasons.forEach(i=>{console.log(i)}),s.riskAnalysis.score):(console.error("reCAPTCHA action error:"+o+":action:"+s.tokenProperties.action),null):(console.error("The CreateAssessment call failed because the token was: "+s.tokenProperties.invalidReason),0)}var zi=e=>(e=e.split("?")[0],e.replace(/\W/g,"").slice(0,100));function rr({projectID:e,API_KEY:t,siteKey:r}){function n(o){return{token:o["g-recaptcha-token"]}}return async(o,a)=>{let{token:s}=n(o.request.headers),i=zi(o.request.path);if((await Vi({projectID:e,API_KEY:t,token:s,siteKey:r,expectedAction:i})||0)<.5){o.status=409;return}await a(o)}}var Xi=e=>!new RegExp("(\b)(onS+)(s*)=|javascript|<(|/|[^/>][^>]+|/[^>][^>]+)>").test(e),ji=(e,t,r)=>!(!Xi(t)||!r[e](t)),Yi=e=>!(e===null||typeof e!="object"||Array.isArray(e)&&(!e[0]||typeof e[0]!="object")),nr=(e,t)=>{let r=Object.keys(e);for(let n of r){if(!t[n])return console.error("key not allowed",n),!1;if(e[n]===null&&(e[n]=""),Yi(e[n])){if(!nr(e[n],t))return console.error("error validating key+validateObject:",n),!1}else if(!ji(n,e[n],t))return console.error("error validating key+validateKeyValue:",n),!1}return!0},Zi=e=>!(e==null||typeof e!="object"),Qi=(e,t)=>{let r=e.query;return Zi(r)?nr(r,t):!1};async function ec(e){if(["POST","PATCH","PUT","DELETE"].indexOf(e.method)===-1)return{};try{let t=await e.text();return JSON.parse(t)}catch{}return{}}function or({allowedKeys:e}){return async(r,n)=>{if(!e)return r.status=501,!1;if(!Qi(r,e))return r.status=422,!1;let o=await ec(r.request);if(!nr(o,e))return r.status=422,!1;await n(r)}}var po=v(M());var E=crypto,D=e=>e instanceof CryptoKey;var x=new TextEncoder,W=new TextDecoder,Au=2**32;function X(...e){let t=e.reduce((o,{length:a})=>o+a,0),r=new Uint8Array(t),n=0;return e.forEach(o=>{r.set(o,n),n+=o.length}),r}var Xn=e=>{let t=e;typeof t=="string"&&(t=x.encode(t));let r=32768,n=[];for(let o=0;o<t.length;o+=r)n.push(String.fromCharCode.apply(null,t.subarray(o,o+r)));return btoa(n.join(""))},J=e=>Xn(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_");var le=class extends Error{static get code(){return"ERR_JOSE_GENERIC"}constructor(t){super(t),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}};var A=class extends le{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}static get code(){return"ERR_JOSE_NOT_SUPPORTED"}};var N=class extends le{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}static get code(){return"ERR_JWS_INVALID"}},j=class extends le{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}static get code(){return"ERR_JWT_INVALID"}};var et=E.getRandomValues.bind(E);function G(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function tt(e,t){return e.name===t}function ar(e){return parseInt(e.name.slice(4),10)}function nc(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function oc(e,t){if(t.length&&!t.some(r=>e.usages.includes(r))){let r="CryptoKey does not support this operation, its usages must include ";if(t.length>2){let n=t.pop();r+=`one of ${t.join(", ")}, or ${n}.`}else t.length===2?r+=`one of ${t[0]} or ${t[1]}.`:r+=`${t[0]}.`;throw new TypeError(r)}}function Yn(e,t,...r){switch(t){case"HS256":case"HS384":case"HS512":{if(!tt(e.algorithm,"HMAC"))throw G("HMAC");let n=parseInt(t.slice(2),10);if(ar(e.algorithm.hash)!==n)throw G(`SHA-${n}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!tt(e.algorithm,"RSASSA-PKCS1-v1_5"))throw G("RSASSA-PKCS1-v1_5");let n=parseInt(t.slice(2),10);if(ar(e.algorithm.hash)!==n)throw G(`SHA-${n}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!tt(e.algorithm,"RSA-PSS"))throw G("RSA-PSS");let n=parseInt(t.slice(2),10);if(ar(e.algorithm.hash)!==n)throw G(`SHA-${n}`,"algorithm.hash");break}case"EdDSA":{if(e.algorithm.name!=="Ed25519"&&e.algorithm.name!=="Ed448")throw G("Ed25519 or Ed448");break}case"ES256":case"ES384":case"ES512":{if(!tt(e.algorithm,"ECDSA"))throw G("ECDSA");let n=nc(t);if(e.algorithm.namedCurve!==n)throw G(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}oc(e,r)}function Zn(e,t,...r){if(r.length>2){let n=r.pop();e+=`one of type ${r.join(", ")}, or ${n}.`}else r.length===2?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;return t==null?e+=` Received ${t}`:typeof t=="function"&&t.name?e+=` Received function ${t.name}`:typeof t=="object"&&t!=null&&t.constructor&&t.constructor.name&&(e+=` Received an instance of ${t.constructor.name}`),e}var $=(e,...t)=>Zn("Key must be ",e,...t);function sr(e,t,...r){return Zn(`Key for the ${e} algorithm must be `,t,...r)}var ir=e=>D(e),b=["CryptoKey"];var dc=(...e)=>{let t=e.filter(Boolean);if(t.length===0||t.length===1)return!0;let r;for(let n of t){let o=Object.keys(n);if(!r||r.size===0){r=new Set(o);continue}for(let a of o){if(r.has(a))return!1;r.add(a)}}return!0},me=dc;function uc(e){return typeof e=="object"&&e!==null}function R(e){if(!uc(e)||Object.prototype.toString.call(e)!=="[object Object]")return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}var rt=(e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){let{modulusLength:r}=t.algorithm;if(typeof r!="number"||r<2048)throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}};var Z=(e,t,r=0)=>{r===0&&(t.unshift(t.length),t.unshift(6));let n=e.indexOf(t[0],r);if(n===-1)return!1;let o=e.subarray(n,n+t.length);return o.length!==t.length?!1:o.every((a,s)=>a===t[s])||Z(e,t,n+1)},eo=e=>{switch(!0){case Z(e,[42,134,72,206,61,3,1,7]):return"P-256";case Z(e,[43,129,4,0,34]):return"P-384";case Z(e,[43,129,4,0,35]):return"P-521";case Z(e,[43,101,110]):return"X25519";case Z(e,[43,101,111]):return"X448";case Z(e,[43,101,112]):return"Ed25519";case Z(e,[43,101,113]):return"Ed448";default:throw new A("Invalid or unsupported EC Key Curve or OKP Key Sub Type")}},lc=async(e,t,r,n,o)=>{let a,s,i=new Uint8Array(atob(r.replace(e,"")).split("").map(u=>u.charCodeAt(0))),c=t==="spki";switch(n){case"PS256":case"PS384":case"PS512":a={name:"RSA-PSS",hash:`SHA-${n.slice(-3)}`},s=c?["verify"]:["sign"];break;case"RS256":case"RS384":case"RS512":a={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${n.slice(-3)}`},s=c?["verify"]:["sign"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":a={name:"RSA-OAEP",hash:`SHA-${parseInt(n.slice(-3),10)||1}`},s=c?["encrypt","wrapKey"]:["decrypt","unwrapKey"];break;case"ES256":a={name:"ECDSA",namedCurve:"P-256"},s=c?["verify"]:["sign"];break;case"ES384":a={name:"ECDSA",namedCurve:"P-384"},s=c?["verify"]:["sign"];break;case"ES512":a={name:"ECDSA",namedCurve:"P-521"},s=c?["verify"]:["sign"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{let u=eo(i);a=u.startsWith("P-")?{name:"ECDH",namedCurve:u}:{name:u},s=c?[]:["deriveBits"];break}case"EdDSA":a={name:eo(i)},s=c?["verify"]:["sign"];break;default:throw new A('Invalid or unsupported "alg" (Algorithm) value')}return E.subtle.importKey(t,i,a,o?.extractable??!1,s)},to=(e,t,r)=>lc(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g,"pkcs8",e,t,r);async function cr(e,t,r){if(typeof e!="string"||e.indexOf("-----BEGIN PRIVATE KEY-----")!==0)throw new TypeError('"pkcs8" must be PKCS#8 formatted string');return to(e,t,r)}var mc=(e,t)=>{if(!(t instanceof Uint8Array)){if(!ir(t))throw new TypeError(sr(e,t,...b,"Uint8Array"));if(t.type!=="secret")throw new TypeError(`${b.join(" or ")} instances for symmetric algorithms must be of type "secret"`)}},yc=(e,t,r)=>{if(!ir(t))throw new TypeError(sr(e,t,...b));if(t.type==="secret")throw new TypeError(`${b.join(" or ")} instances for asymmetric algorithms must not be of type "secret"`);if(r==="sign"&&t.type==="public")throw new TypeError(`${b.join(" or ")} instances for asymmetric algorithm signing must be of type "private"`);if(r==="decrypt"&&t.type==="public")throw new TypeError(`${b.join(" or ")} instances for asymmetric algorithm decryption must be of type "private"`);if(t.algorithm&&r==="verify"&&t.type==="private")throw new TypeError(`${b.join(" or ")} instances for asymmetric algorithm verifying must be of type "public"`);if(t.algorithm&&r==="encrypt"&&t.type==="private")throw new TypeError(`${b.join(" or ")} instances for asymmetric algorithm encryption must be of type "public"`)},gc=(e,t,r)=>{e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?mc(e,t):yc(e,t,r)},Ie=gc;function _c(e,t,r,n,o){if(o.crit!==void 0&&n.crit===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||n.crit===void 0)return new Set;if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some(s=>typeof s!="string"||s.length===0))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let a;r!==void 0?a=new Map([...Object.entries(r),...t.entries()]):a=t;for(let s of n.crit){if(!a.has(s))throw new A(`Extension Header Parameter "${s}" is not recognized`);if(o[s]===void 0)throw new e(`Extension Header Parameter "${s}" is missing`);if(a.get(s)&&n[s]===void 0)throw new e(`Extension Header Parameter "${s}" MUST be integrity protected`)}return new Set(n.crit)}var ye=_c;var Tc=Symbol();function nt(e,t){let r=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:e.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:t.namedCurve};case"EdDSA":return{name:t.name};default:throw new A(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}function ot(e,t,r){if(D(t))return Yn(t,e,r),t;if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw new TypeError($(t,...b));return E.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[r])}throw new TypeError($(t,...b,"Uint8Array"))}var Q=e=>Math.floor(e.getTime()/1e3);var xc=/^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i,at=e=>{let t=xc.exec(e);if(!t)throw new TypeError("Invalid time period format");let r=parseFloat(t[1]);switch(t[2].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":return Math.round(r);case"minute":case"minutes":case"min":case"mins":case"m":return Math.round(r*60);case"hour":case"hours":case"hr":case"hrs":case"h":return Math.round(r*3600);case"day":case"days":case"d":return Math.round(r*86400);case"week":case"weeks":case"w":return Math.round(r*604800);default:return Math.round(r*31557600)}};var Wc=async(e,t,r)=>{let n=await ot(e,t,"sign");rt(e,n);let o=await E.subtle.sign(nt(e,n.algorithm),n,r);return new Uint8Array(o)},io=Wc;var ge=class{constructor(t){if(!(t instanceof Uint8Array))throw new TypeError("payload must be an instance of Uint8Array");this._payload=t}setProtectedHeader(t){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=t,this}setUnprotectedHeader(t){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=t,this}async sign(t,r){if(!this._protectedHeader&&!this._unprotectedHeader)throw new N("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!me(this._protectedHeader,this._unprotectedHeader))throw new N("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let n={...this._protectedHeader,...this._unprotectedHeader},o=ye(N,new Map([["b64",!0]]),r?.crit,this._protectedHeader,n),a=!0;if(o.has("b64")&&(a=this._protectedHeader.b64,typeof a!="boolean"))throw new N('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:s}=n;if(typeof s!="string"||!s)throw new N('JWS "alg" (Algorithm) Header Parameter missing or invalid');Ie(s,t,"sign");let i=this._payload;a&&(i=x.encode(J(i)));let c;this._protectedHeader?c=x.encode(J(JSON.stringify(this._protectedHeader))):c=x.encode("");let u=X(c,x.encode("."),i),f=await io(s,t,u),d={signature:J(f),payload:""};return a&&(d.payload=W.decode(i)),this._unprotectedHeader&&(d.header=this._unprotectedHeader),this._protectedHeader&&(d.protected=W.decode(c)),d}};var We=class{constructor(t){this._flattened=new ge(t)}setProtectedHeader(t){return this._flattened.setProtectedHeader(t),this}async sign(t,r){let n=await this._flattened.sign(t,r);if(n.payload===void 0)throw new TypeError("use the flattened module for creating JWS with b64: false");return`${n.protected}.${n.payload}.${n.signature}`}};function we(e,t){if(!Number.isFinite(t))throw new TypeError(`Invalid ${e} input`);return t}var Ae=class{constructor(t={}){if(!R(t))throw new TypeError("JWT Claims Set MUST be an object");this._payload=t}setIssuer(t){return this._payload={...this._payload,iss:t},this}setSubject(t){return this._payload={...this._payload,sub:t},this}setAudience(t){return this._payload={...this._payload,aud:t},this}setJti(t){return this._payload={...this._payload,jti:t},this}setNotBefore(t){return typeof t=="number"?this._payload={...this._payload,nbf:we("setNotBefore",t)}:t instanceof Date?this._payload={...this._payload,nbf:we("setNotBefore",Q(t))}:this._payload={...this._payload,nbf:Q(new Date)+at(t)},this}setExpirationTime(t){return typeof t=="number"?this._payload={...this._payload,exp:we("setExpirationTime",t)}:t instanceof Date?this._payload={...this._payload,exp:we("setExpirationTime",Q(t))}:this._payload={...this._payload,exp:Q(new Date)+at(t)},this}setIssuedAt(t){return typeof t>"u"?this._payload={...this._payload,iat:Q(new Date)}:t instanceof Date?this._payload={...this._payload,iat:we("setIssuedAt",Q(t))}:this._payload={...this._payload,iat:we("setIssuedAt",t)},this}};var Je=class extends Ae{setProtectedHeader(t){return this._protectedHeader=t,this}async sign(t,r){let n=new We(x.encode(JSON.stringify(this._payload)));if(n.setProtectedHeader(this._protectedHeader),Array.isArray(this._protectedHeader?.crit)&&this._protectedHeader.crit.includes("b64")&&this._protectedHeader.b64===!1)throw new j("JWTs MUST NOT use unencoded payload");return n.sign(t,r)}};var Dc;(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))&&(Dc="jose/v5.1.0");var co=function e(t){function r(o,a,s){var i,c={};if(Array.isArray(o))return o.concat(a);for(i in o)c[s?i.toLowerCase():i]=o[i];for(i in a){var u=s?i.toLowerCase():i,f=a[i];c[u]=u in c&&typeof f=="object"?r(c[u],f,u=="headers"):f}return c}function n(o,a,s,i,c){var u=typeof o!="string"?(a=o).url:o,f={config:a},d=r(t,a),l={};i=i||d.data,(d.transformRequest||[]).map(function(h){i=h(i,d.headers)||i}),d.auth&&(l.authorization=d.auth),i&&typeof i=="object"&&typeof i.append!="function"&&typeof i.text!="function"&&(i=JSON.stringify(i),l["content-type"]="application/json");try{l[d.xsrfHeaderName]=decodeURIComponent(document.cookie.match(RegExp("(^|; )"+d.xsrfCookieName+"=([^;]*)"))[2])}catch{}return d.baseURL&&(u=u.replace(/^(?!.*\/\/)\/?/,d.baseURL+"/")),d.params&&(u+=(~u.indexOf("?")?"&":"?")+(d.paramsSerializer?d.paramsSerializer(d.params):new URLSearchParams(d.params))),(d.fetch||fetch)(u,{method:(s||d.method||"get").toUpperCase(),body:i,headers:r(d.headers,l,!0),credentials:d.withCredentials?"include":c}).then(function(h){for(var y in h)typeof h[y]!="function"&&(f[y]=h[y]);return d.responseType=="stream"?(f.data=h.body,f):h[d.responseType||"text"]().then(function(w){f.data=w,f.data=JSON.parse(w)}).catch(Object).then(function(){return(d.validateStatus?d.validateStatus(h.status):h.ok)?f:Promise.reject(f)})})}return t=t||{},n.request=n,n.get=function(o,a){return n(o,a,"get")},n.delete=function(o,a){return n(o,a,"delete")},n.head=function(o,a){return n(o,a,"head")},n.options=function(o,a){return n(o,a,"options")},n.post=function(o,a,s){return n(o,s,"post",a)},n.put=function(o,a,s){return n(o,s,"put",a)},n.patch=function(o,a,s){return n(o,s,"patch",a)},n.all=Promise.all.bind(Promise),n.spread=function(o){return o.apply.bind(o,o)},n.CancelToken=typeof AbortController=="function"?AbortController:Object,n.defaults=t,n.create=e,n}();var qc=e=>{if(!e)return!1;let t=JSON.parse(atob(e.split(".")[1])),r=Math.floor(Date.now()/1e3);return t.exp>r-600},st=async(e,t)=>{let r=await GCP_INVOKER_TOKEN.get(t);if(qc(r))return r;let n=await cr(e.private_key,"RS256"),o=e.client_email,a={iss:o,sub:o,aud:"https://www.googleapis.com/oauth2/v4/token",target_audience:t,iat:Math.floor(Date.now()/1e3),exp:Math.floor(Date.now()/1e3)+3600},s=await new Je(a).setProtectedHeader({alg:"RS256",typ:"JWT"}).sign(n),i=await co.post("https://www.googleapis.com/oauth2/v4/token",{grant_type:"urn:ietf:params:oauth:grant-type:jwt-bearer",assertion:s});return await GCP_INVOKER_TOKEN.delete(t),await GCP_INVOKER_TOKEN.put(t,i.data.id_token),i.data.id_token};var uo={get:po.default};function ur({project_id:e,region:t,functionName:r,serviceAccount:n}){return async o=>{let a=uo.get(o,"request.query",{}),s=new URLSearchParams(a).toString(),i=`https://${t}-${e}.cloudfunctions.net/${r}`,c=`https://${t}-${e}.cloudfunctions.net/${r}${s?`?${s}`:""}`;console.log("urlWithParms:",c);let u=await st(n,i);o.request.headers["X-Serverless-Authorization"]=`Bearer ${u}`;let f={headers:o.request.headers,method:o.request.method,redirect:"manual"};if(O.methodsMethodsWithBody.indexOf(o.request.method)!==-1&&uo.get(o,"event.request.body")){let h=o.event.request.clone();f.body=h.body}let d=await fetch(c,f);o.body=d.body,o.status=d.status;let l=S.instanceToJson(d.headers);Object.keys(l).forEach(h=>{o.set(h,l[h])})}}var ho=v(M());var Fc={get:ho.default};function pr({domain:e,serviceAccount:t}){return async r=>{let n=`${e}${r.request.path}`,o=await st(t,e);r.request.headers["X-Serverless-Authorization"]=`Bearer ${o}`;let a={headers:r.request.headers,method:r.request.method,redirect:"manual"};if(O.methodsMethodsWithBody.indexOf(r.request.method)!==-1&&Fc.get(r,"event.request.body")){let c=r.event.request.clone();a.body=c.body}let s=await fetch(n,a);r.body=s.body,r.status=s.status;let i=S.instanceToJson(s.headers);Object.keys(i).forEach(c=>{r.set(c,i[c])})}}function hr({headers:e={}}){return async(t,r)=>{Object.keys(e).forEach(n=>{n.toLowerCase()==="set-cookie"?t.append(n,e[n]):t.set(n,e[n])}),await r()}}var fo={basicAuth:St,cache:Ct,cors:_t,geoDecorator:vt,jwt:Pt,kvStorage:Ht,kvStorageBinding:Tt,lambda:Ot,loadbalancer:Wt,logger:Nt,oauth2:Gt,origin:Vt,rateLimit:jt,response:zt,s3:Yt,signature:Qt,split:er,transform:tr,recaptcha:rr,userInputValidation:or,cloudfunction:ur,gcpCloudrun:pr,headers:hr};module.exports=class{constructor(t=[],r={}){this.router=new lo.default,t.forEach(n=>{let o=r[n.handlerName]||fo[n.handlerName];if(!o)throw new Error(`Handler ${n.handlerName} is not supported`);this.router.add(n,o(n.options))})}async resolve(t){return this.router.resolve(t)}};
|
|
8
8
|
/*! Bundled license information:
|
|
9
9
|
|
|
10
10
|
aws4fetch/dist/aws4fetch.umd.js:
|