@ahmadissa/cloudworker-proxy 1.1.85 → 1.1.86
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 +5 -5
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";var Do=Object.create;var Pr=Object.defineProperty;var ko=Object.getOwnPropertyDescriptor;var $o=Object.getOwnPropertyNames;var qo=Object.getPrototypeOf,Fo=Object.prototype.hasOwnProperty;var S=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Lo=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $o(t))!Fo.call(e,o)&&o!==r&&Pr(e,o,{get:()=>t[o],enumerable:!(n=ko(t,o))||n.enumerable});return e};var x=(e,t,r)=>(r=e!=null?Do(qo(e)):{},Lo(t||!e||!e.__esModule?Pr(r,"default",{value:e,enumerable:!0}):r,e));var Hr=S(Tr=>{"use strict";Object.defineProperty(Tr,"__esModule",{value:!0})});var xr=S(Kr=>{"use strict";Object.defineProperty(Kr,"__esModule",{value:!0})});var Rr=S(Or=>{"use strict";Object.defineProperty(Or,"__esModule",{value:!0})});var Ir=S(Ur=>{"use strict";Object.defineProperty(Ur,"__esModule",{value:!0})});var Wr=S(Y=>{"use strict";var Bo=Y&&Y.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),Ve=Y&&Y.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Bo(t,e,r)};Object.defineProperty(Y,"__esModule",{value:!0});Ve(Hr(),Y);Ve(xr(),Y);Ve(Rr(),Y);Ve(Ir(),Y)});var Dr=S(I=>{"use strict";Object.defineProperty(I,"__esModule",{value:!0});I.pathToRegexp=I.tokensToRegexp=I.regexpToFunction=I.match=I.tokensToFunction=I.compile=I.parse=void 0;function Go(e){for(var t=[],r=0;r<e.length;){var n=e[r];if(n==="*"||n==="+"||n==="?"){t.push({type:"MODIFIER",index:r,value:e[r++]});continue}if(n==="\\"){t.push({type:"ESCAPED_CHAR",index:r++,value:e[r++]});continue}if(n==="{"){t.push({type:"OPEN",index:r,value:e[r++]});continue}if(n==="}"){t.push({type:"CLOSE",index:r,value:e[r++]});continue}if(n===":"){for(var o="",a=r+1;a<e.length;){var s=e.charCodeAt(a);if(s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122||s===95){o+=e[a++];continue}break}if(!o)throw new TypeError("Missing parameter name at ".concat(r));t.push({type:"NAME",index:r,value:o}),r=a;continue}if(n==="("){var i=1,c="",a=r+1;if(e[a]==="?")throw new TypeError('Pattern cannot start with "?" at '.concat(a));for(;a<e.length;){if(e[a]==="\\"){c+=e[a++]+e[a++];continue}if(e[a]===")"){if(i--,i===0){a++;break}}else if(e[a]==="("&&(i++,e[a+1]!=="?"))throw new TypeError("Capturing groups are not allowed at ".concat(a));c+=e[a++]}if(i)throw new TypeError("Unbalanced pattern at ".concat(r));if(!c)throw new TypeError("Missing pattern at ".concat(r));t.push({type:"PATTERN",index:r,value:c}),r=a;continue}t.push({type:"CHAR",index:r,value:e[r++]})}return t.push({type:"END",index:r,value:""}),t}function At(e,t){t===void 0&&(t={});for(var r=Go(e),n=t.prefixes,o=n===void 0?"./":n,a=t.delimiter,s=a===void 0?"/#?":a,i=[],c=0,p=0,d="",u=function(O){if(p<r.length&&r[p].type===O)return r[p++].value},f=function(O){var C=u(O);if(C!==void 0)return C;var H=r[p],Q=H.type,B=H.index;throw new TypeError("Unexpected ".concat(Q," at ").concat(B,", expected ").concat(O))},h=function(){for(var O="",C;C=u("CHAR")||u("ESCAPED_CHAR");)O+=C;return O},y=function(O){for(var C=0,H=s;C<H.length;C++){var Q=H[C];if(O.indexOf(Q)>-1)return!0}return!1},w=function(O){var C=i[i.length-1],H=O||(C&&typeof C=="string"?C:"");if(C&&!H)throw new TypeError('Must have text between two parameters, missing text after "'.concat(C.name,'"'));return!H||y(H)?"[^".concat(oe(s),"]+?"):"(?:(?!".concat(oe(H),")[^").concat(oe(s),"])+?")};p<r.length;){var m=u("CHAR"),g=u("NAME"),_=u("PATTERN");if(g||_){var v=m||"";o.indexOf(v)===-1&&(d+=v,v=""),d&&(i.push(d),d=""),i.push({name:g||c++,prefix:v,suffix:"",pattern:_||w(v),modifier:u("MODIFIER")||""});continue}var A=m||u("ESCAPED_CHAR");if(A){d+=A;continue}d&&(i.push(d),d="");var W=u("OPEN");if(W){var v=h(),k=u("NAME")||"",Z=u("PATTERN")||"",j=h();f("CLOSE"),i.push({name:k||(Z?c++:""),pattern:k&&!Z?w(v):Z,prefix:v,suffix:j,modifier:u("MODIFIER")||""});continue}f("END")}return i}I.parse=At;function Vo(e,t){return Jr(At(e,t),t)}I.compile=Vo;function Jr(e,t){t===void 0&&(t={});var r=St(t),n=t.encode,o=n===void 0?function(c){return c}:n,a=t.validate,s=a===void 0?!0:a,i=e.map(function(c){if(typeof c=="object")return new RegExp("^(?:".concat(c.pattern,")$"),r)});return function(c){for(var p="",d=0;d<e.length;d++){var u=e[d];if(typeof u=="string"){p+=u;continue}var f=c?c[u.name]:void 0,h=u.modifier==="?"||u.modifier==="*",y=u.modifier==="*"||u.modifier==="+";if(Array.isArray(f)){if(!y)throw new TypeError('Expected "'.concat(u.name,'" to not repeat, but got an array'));if(f.length===0){if(h)continue;throw new TypeError('Expected "'.concat(u.name,'" to not be empty'))}for(var w=0;w<f.length;w++){var m=o(f[w],u);if(s&&!i[d].test(m))throw new TypeError('Expected all "'.concat(u.name,'" to match "').concat(u.pattern,'", but got "').concat(m,'"'));p+=u.prefix+m+u.suffix}continue}if(typeof f=="string"||typeof f=="number"){var m=o(String(f),u);if(s&&!i[d].test(m))throw new TypeError('Expected "'.concat(u.name,'" to match "').concat(u.pattern,'", but got "').concat(m,'"'));p+=u.prefix+m+u.suffix;continue}if(!h){var g=y?"an array":"a string";throw new TypeError('Expected "'.concat(u.name,'" to be ').concat(g))}}return p}}I.tokensToFunction=Jr;function zo(e,t){var r=[],n=Et(e,r,t);return Nr(n,r,t)}I.match=zo;function Nr(e,t,r){r===void 0&&(r={});var n=r.decode,o=n===void 0?function(a){return a}:n;return function(a){var s=e.exec(a);if(!s)return!1;for(var i=s[0],c=s.index,p=Object.create(null),d=function(f){if(s[f]===void 0)return"continue";var h=t[f-1];h.modifier==="*"||h.modifier==="+"?p[h.name]=s[f].split(h.prefix+h.suffix).map(function(y){return o(y,h)}):p[h.name]=o(s[f],h)},u=1;u<s.length;u++)d(u);return{path:i,index:c,params:p}}}I.regexpToFunction=Nr;function oe(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function St(e){return e&&e.sensitive?"":"i"}function jo(e,t){if(!t)return e;for(var r=/\((?:\?<(.*?)>)?(?!\?)/g,n=0,o=r.exec(e.source);o;)t.push({name:o[1]||n++,prefix:"",suffix:"",modifier:"",pattern:""}),o=r.exec(e.source);return e}function Xo(e,t,r){var n=e.map(function(o){return Et(o,t,r).source});return new RegExp("(?:".concat(n.join("|"),")"),St(r))}function Yo(e,t,r){return Mr(At(e,r),t,r)}function Mr(e,t,r){r===void 0&&(r={});for(var n=r.strict,o=n===void 0?!1:n,a=r.start,s=a===void 0?!0:a,i=r.end,c=i===void 0?!0:i,p=r.encode,d=p===void 0?function(C){return C}:p,u=r.delimiter,f=u===void 0?"/#?":u,h=r.endsWith,y=h===void 0?"":h,w="[".concat(oe(y),"]|$"),m="[".concat(oe(f),"]"),g=s?"^":"",_=0,v=e;_<v.length;_++){var A=v[_];if(typeof A=="string")g+=oe(d(A));else{var W=oe(d(A.prefix)),k=oe(d(A.suffix));if(A.pattern)if(t&&t.push(A),W||k)if(A.modifier==="+"||A.modifier==="*"){var Z=A.modifier==="*"?"?":"";g+="(?:".concat(W,"((?:").concat(A.pattern,")(?:").concat(k).concat(W,"(?:").concat(A.pattern,"))*)").concat(k,")").concat(Z)}else g+="(?:".concat(W,"(").concat(A.pattern,")").concat(k,")").concat(A.modifier);else{if(A.modifier==="+"||A.modifier==="*")throw new TypeError('Can not repeat "'.concat(A.name,'" without a prefix and suffix'));g+="(".concat(A.pattern,")").concat(A.modifier)}else g+="(?:".concat(W).concat(k,")").concat(A.modifier)}}if(c)o||(g+="".concat(m,"?")),g+=r.endsWith?"(?=".concat(w,")"):"$";else{var j=e[e.length-1],O=typeof j=="string"?m.indexOf(j[j.length-1])>-1:j===void 0;o||(g+="(?:".concat(m,"(?=").concat(w,"))?")),O||(g+="(?=".concat(m,"|").concat(w,")"))}return new RegExp(g,St(r))}I.tokensToRegexp=Mr;function Et(e,t,r){return e instanceof RegExp?jo(e,t):Array.isArray(e)?Xo(e,t,r):Yo(e,t,r)}I.pathToRegexp=Et});var kr=S(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.Router=void 0;var Zo=Dr(),bt=class{constructor(){this.routes=[]}all(t,r){return this.push("ALL",t,r)}get(t,...r){return r.forEach(n=>{this.push("GET",t,n),this.push("HEAD",t,n)}),this}post(t,...r){return r.forEach(n=>{this.push("POST",t,n)}),this}put(t,...r){return r.forEach(n=>{this.push("PUT",t,n)}),this}patch(t,...r){return r.forEach(n=>{this.push("PATCH",t,n)}),this}delete(t,...r){return r.forEach(n=>{this.push("DELETE",t,n)}),this}head(t,...r){return r.forEach(n=>{this.push("HEAD",t,n)}),this}options(t,...r){return r.forEach(n=>{this.push("OPTIONS",t,n)}),this}use(t){return this.push("ALL","*",t)}allowedMethods(){return async t=>{let r=new URL(t.request.url),n={OPTIONS:!0};return this.routes.forEach(o=>{if(o.method==="ALL")return;let a=o.regexp.exec(r.pathname);!a||!a.length||(n[o.method]=!0)}),new Response(null,{status:204,headers:{"Access-Control-Allow-Methods":Object.keys(n).join(", "),"Access-Control-Allow-Origin":"*","Access-Control-Allow-Headers":"Content-Type"}})}}matches(t,r){let n=[];return this.routes.forEach(o=>{if(o.method!==t&&o.method!=="ALL")return;let a=o.regexp.exec(r);!a||!a.length||n.push({...o,matches:a,params:Qo(a,o.keys)})}),n}async handleMatches(t,...r){let n=r.shift();return n?(t.params=n.params,n.handler(t,()=>this.handleMatches(t,...r))):null}async handle(t,r,n){let{pathname:o,searchParams:a,protocol:s,host:i,hostname:c}=new URL(t.url),p=this.matches(t.method,o),d={request:t,query:a,headers:t.headers,ip:t.headers.get("x-real-ip"),protocol:s,host:i,hostname:c,params:{},state:{},env:r,event:n},u=await this.handleMatches(d,...p);return u?t.method==="HEAD"?new Response("",u):u:new Response("Not Found",{status:404})}push(t,r,n){let o=[];r==="*"&&(r="(.*)");let a=(0,Zo.pathToRegexp)(r,o);return this.routes.push({method:t,path:r.toString(),handler:n,keys:o,regexp:a}),this}};ze.Router=bt;var Qo=(e,t)=>{let r={};for(let n=1;n<e.length;n++){let a=t[n-1].name,s=e[n];s!==void 0&&(r[a]=s)}return r}});var $r=S(je=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.bodyparser=void 0;var ea=["POST","PUT","PATCH"];async function ta(e,t){let r=e.headers.get("content-type");if(!ea.includes(e.request.method))return t();try{return r?.startsWith("application/json")?e.body=await e.request.json():r?.startsWith("application/x-www-form-urlencoded")?e.body=Object.fromEntries(await e.request.formData()):r?.startsWith("text")&&(e.body=await e.request.text()),t()}catch{return new Response("Invalid body format",{status:400,headers:{"content-type":"text/plain"}})}}je.bodyparser=ta});var qr=S(fe=>{"use strict";var ra=fe&&fe.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),na=fe&&fe.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&ra(t,e,r)};Object.defineProperty(fe,"__esModule",{value:!0});na($r(),fe)});var Fr=S(te=>{"use strict";var oa=te&&te.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),vt=te&&te.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&oa(t,e,r)};Object.defineProperty(te,"__esModule",{value:!0});vt(Wr(),te);vt(kr(),te);vt(qr(),te)});var V=S((Pu,rn)=>{var aa="Expected a function",zr="__lodash_hash_undefined__",jr=1/0,sa="[object Function]",ia="[object GeneratorFunction]",ca="[object Symbol]",ua=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,da=/^\w*$/,pa=/^\./,fa=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ha=/[\\^$.*+?()[\]{}|]/g,la=/\\(\\)?/g,ma=/^\[object .+?Constructor\]$/,ya=typeof global=="object"&&global&&global.Object===Object&&global,ga=typeof self=="object"&&self&&self.Object===Object&&self,_t=ya||ga||Function("return this")();function wa(e,t){return e?.[t]}function Aa(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var Sa=Array.prototype,Ea=Function.prototype,Xr=Object.prototype,Ct=_t["__core-js_shared__"],Lr=function(){var e=/[^.]+$/.exec(Ct&&Ct.keys&&Ct.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Yr=Ea.toString,Pt=Xr.hasOwnProperty,Zr=Xr.toString,ba=RegExp("^"+Yr.call(Pt).replace(ha,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Br=_t.Symbol,va=Sa.splice,Ca=Qr(_t,"Map"),Re=Qr(Object,"create"),Gr=Br?Br.prototype:void 0,Vr=Gr?Gr.toString:void 0;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 _a(){this.__data__=Re?Re(null):{}}function Pa(e){return this.has(e)&&delete this.__data__[e]}function Ta(e){var t=this.__data__;if(Re){var r=t[e];return r===zr?void 0:r}return Pt.call(t,e)?t[e]:void 0}function Ha(e){var t=this.__data__;return Re?t[e]!==void 0:Pt.call(t,e)}function Ka(e,t){var r=this.__data__;return r[e]=Re&&t===void 0?zr:t,this}he.prototype.clear=_a;he.prototype.delete=Pa;he.prototype.get=Ta;he.prototype.has=Ha;he.prototype.set=Ka;function Ee(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 xa(){this.__data__=[]}function Oa(e){var t=this.__data__,r=Xe(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():va.call(t,r,1),!0}function Ra(e){var t=this.__data__,r=Xe(t,e);return r<0?void 0:t[r][1]}function Ua(e){return Xe(this.__data__,e)>-1}function Ia(e,t){var r=this.__data__,n=Xe(r,e);return n<0?r.push([e,t]):r[n][1]=t,this}Ee.prototype.clear=xa;Ee.prototype.delete=Oa;Ee.prototype.get=Ra;Ee.prototype.has=Ua;Ee.prototype.set=Ia;function le(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 Wa(){this.__data__={hash:new he,map:new(Ca||Ee),string:new he}}function Ja(e){return Ye(this,e).delete(e)}function Na(e){return Ye(this,e).get(e)}function Ma(e){return Ye(this,e).has(e)}function Da(e,t){return Ye(this,e).set(e,t),this}le.prototype.clear=Wa;le.prototype.delete=Ja;le.prototype.get=Na;le.prototype.has=Ma;le.prototype.set=Da;function Xe(e,t){for(var r=e.length;r--;)if(Xa(e[r][0],t))return r;return-1}function ka(e,t){t=La(t,e)?[t]:Fa(t);for(var r=0,n=t.length;e!=null&&r<n;)e=e[za(t[r++])];return r&&r==n?e:void 0}function $a(e){if(!tn(e)||Ga(e))return!1;var t=Ya(e)||Aa(e)?ba:ma;return t.test(ja(e))}function qa(e){if(typeof e=="string")return e;if(Ht(e))return Vr?Vr.call(e):"";var t=e+"";return t=="0"&&1/e==-jr?"-0":t}function Fa(e){return en(e)?e:Va(e)}function Ye(e,t){var r=e.__data__;return Ba(t)?r[typeof t=="string"?"string":"hash"]:r.map}function Qr(e,t){var r=wa(e,t);return $a(r)?r:void 0}function La(e,t){if(en(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||Ht(e)?!0:da.test(e)||!ua.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 Ga(e){return!!Lr&&Lr in e}var Va=Tt(function(e){e=Qa(e);var t=[];return pa.test(e)&&t.push(""),e.replace(fa,function(r,n,o,a){t.push(o?a.replace(la,"$1"):n||r)}),t});function za(e){if(typeof e=="string"||Ht(e))return e;var t=e+"";return t=="0"&&1/e==-jr?"-0":t}function ja(e){if(e!=null){try{return Yr.call(e)}catch{}try{return e+""}catch{}}return""}function Tt(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(aa);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(Tt.Cache||le),r}Tt.Cache=le;function Xa(e,t){return e===t||e!==e&&t!==t}var en=Array.isArray;function Ya(e){var t=tn(e)?Zr.call(e):"";return t==sa||t==ia}function tn(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function Za(e){return!!e&&typeof e=="object"}function Ht(e){return typeof e=="symbol"||Za(e)&&Zr.call(e)==ca}function Qa(e){return e==null?"":qa(e)}function es(e,t,r){var n=e==null?void 0:ka(e,t);return n===void 0?r:n}rn.exports=es});var Qe=S((Ze,dn)=>{(function(e,t){typeof Ze=="object"&&typeof dn<"u"?t(Ze):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.aws4fetch={}))})(Ze,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:f,secretAccessKey:h,sessionToken:y,service:w,region:m,cache:g,retries:_,initRetryMs:v}){if(f==null)throw new TypeError("accessKeyId is a required option");if(h==null)throw new TypeError("secretAccessKey is a required option");this.accessKeyId=f,this.secretAccessKey=h,this.sessionToken=y,this.service=w,this.region=m,this.cache=g||new Map,this.retries=_??10,this.initRetryMs=v||50}async sign(f,h){if(f instanceof Request){let{method:m,url:g,headers:_,body:v}=f;h=Object.assign({method:m,url:g,headers:_},h),h.body==null&&_.has("Content-Type")&&(h.body=v!=null&&_.has("X-Amz-Content-Sha256")?v:await f.clone().arrayBuffer()),f=g}let y=new a(Object.assign({url:f},h,this,h&&h.aws)),w=Object.assign({},h,await y.sign());return delete w.aws,new Request(w.url.toString(),w)}async fetch(f,h){for(let y=0;y<=this.retries;y++){let w=fetch(await this.sign(f,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:f,url:h,headers:y,body:w,accessKeyId:m,secretAccessKey:g,sessionToken:_,service:v,region:A,cache:W,datetime:k,signQuery:Z,appendSessionToken:j,allHeaders:O,singleEncode:C}){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=f||(w?"POST":"GET"),this.url=new URL(h),this.headers=new Headers(y||{}),this.body=w,this.accessKeyId=m,this.secretAccessKey=g,this.sessionToken=_;let H,Q;(!v||!A)&&([H,Q]=d(this.url,this.headers)),this.service=v||H||"",this.region=A||Q||"us-east-1",this.cache=W||new Map,this.datetime=k||new Date().toISOString().replace(/[:-]|\.\d{3}/g,""),this.signQuery=Z,this.appendSessionToken=j||this.service==="iotdevicegateway",this.headers.delete("Host");let B=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"),B.set("X-Amz-Date",this.datetime),this.sessionToken&&!this.appendSessionToken&&B.set("X-Amz-Security-Token",this.sessionToken),this.signableHeaders=["host",...this.headers.keys()].filter(K=>O||!n.includes(K)).sort(),this.signedHeaders=this.signableHeaders.join(";"),this.canonicalHeaders=this.signableHeaders.map(K=>K+":"+(K==="host"?this.url.host:(this.headers.get(K)||"").replace(/\s+/g," "))).join(`
|
|
2
|
-
`),this.credentialString=[this.datetime.slice(0,8),this.region,this.service,"aws4_request"].join("/"),this.signQuery&&(this.service==="s3"&&!B.has("X-Amz-Expires")&&B.set("X-Amz-Expires","86400"),B.set("X-Amz-Algorithm","AWS4-HMAC-SHA256"),B.set("X-Amz-Credential",this.accessKeyId+"/"+this.credentialString),B.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,"/");
|
|
1
|
+
"use strict";var Mo=Object.create;var Cr=Object.defineProperty;var Do=Object.getOwnPropertyDescriptor;var ko=Object.getOwnPropertyNames;var $o=Object.getPrototypeOf,qo=Object.prototype.hasOwnProperty;var S=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Fo=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ko(t))!qo.call(e,o)&&o!==r&&Cr(e,o,{get:()=>t[o],enumerable:!(n=Do(t,o))||n.enumerable});return e};var O=(e,t,r)=>(r=e!=null?Mo($o(e)):{},Fo(t||!e||!e.__esModule?Cr(r,"default",{value:e,enumerable:!0}):r,e));var Tr=S(Pr=>{"use strict";Object.defineProperty(Pr,"__esModule",{value:!0})});var Kr=S(Hr=>{"use strict";Object.defineProperty(Hr,"__esModule",{value:!0})});var xr=S(Or=>{"use strict";Object.defineProperty(Or,"__esModule",{value:!0})});var Ur=S(Rr=>{"use strict";Object.defineProperty(Rr,"__esModule",{value:!0})});var Ir=S(Y=>{"use strict";var Lo=Y&&Y.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),Ve=Y&&Y.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Lo(t,e,r)};Object.defineProperty(Y,"__esModule",{value:!0});Ve(Tr(),Y);Ve(Kr(),Y);Ve(xr(),Y);Ve(Ur(),Y)});var Mr=S(I=>{"use strict";Object.defineProperty(I,"__esModule",{value:!0});I.pathToRegexp=I.tokensToRegexp=I.regexpToFunction=I.match=I.tokensToFunction=I.compile=I.parse=void 0;function Bo(e){for(var t=[],r=0;r<e.length;){var n=e[r];if(n==="*"||n==="+"||n==="?"){t.push({type:"MODIFIER",index:r,value:e[r++]});continue}if(n==="\\"){t.push({type:"ESCAPED_CHAR",index:r++,value:e[r++]});continue}if(n==="{"){t.push({type:"OPEN",index:r,value:e[r++]});continue}if(n==="}"){t.push({type:"CLOSE",index:r,value:e[r++]});continue}if(n===":"){for(var o="",a=r+1;a<e.length;){var s=e.charCodeAt(a);if(s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122||s===95){o+=e[a++];continue}break}if(!o)throw new TypeError("Missing parameter name at ".concat(r));t.push({type:"NAME",index:r,value:o}),r=a;continue}if(n==="("){var i=1,c="",a=r+1;if(e[a]==="?")throw new TypeError('Pattern cannot start with "?" at '.concat(a));for(;a<e.length;){if(e[a]==="\\"){c+=e[a++]+e[a++];continue}if(e[a]===")"){if(i--,i===0){a++;break}}else if(e[a]==="("&&(i++,e[a+1]!=="?"))throw new TypeError("Capturing groups are not allowed at ".concat(a));c+=e[a++]}if(i)throw new TypeError("Unbalanced pattern at ".concat(r));if(!c)throw new TypeError("Missing pattern at ".concat(r));t.push({type:"PATTERN",index:r,value:c}),r=a;continue}t.push({type:"CHAR",index:r,value:e[r++]})}return t.push({type:"END",index:r,value:""}),t}function At(e,t){t===void 0&&(t={});for(var r=Bo(e),n=t.prefixes,o=n===void 0?"./":n,a=t.delimiter,s=a===void 0?"/#?":a,i=[],c=0,d=0,p="",u=function(x){if(d<r.length&&r[d].type===x)return r[d++].value},f=function(x){var _=u(x);if(_!==void 0)return _;var H=r[d],Q=H.type,B=H.index;throw new TypeError("Unexpected ".concat(Q," at ").concat(B,", expected ").concat(x))},h=function(){for(var x="",_;_=u("CHAR")||u("ESCAPED_CHAR");)x+=_;return x},y=function(x){for(var _=0,H=s;_<H.length;_++){var Q=H[_];if(x.indexOf(Q)>-1)return!0}return!1},w=function(x){var _=i[i.length-1],H=x||(_&&typeof _=="string"?_:"");if(_&&!H)throw new TypeError('Must have text between two parameters, missing text after "'.concat(_.name,'"'));return!H||y(H)?"[^".concat(oe(s),"]+?"):"(?:(?!".concat(oe(H),")[^").concat(oe(s),"])+?")};d<r.length;){var m=u("CHAR"),g=u("NAME"),C=u("PATTERN");if(g||C){var b=m||"";o.indexOf(b)===-1&&(p+=b,b=""),p&&(i.push(p),p=""),i.push({name:g||c++,prefix:b,suffix:"",pattern:C||w(b),modifier:u("MODIFIER")||""});continue}var A=m||u("ESCAPED_CHAR");if(A){p+=A;continue}p&&(i.push(p),p="");var W=u("OPEN");if(W){var b=h(),k=u("NAME")||"",Z=u("PATTERN")||"",j=h();f("CLOSE"),i.push({name:k||(Z?c++:""),pattern:k&&!Z?w(b):Z,prefix:b,suffix:j,modifier:u("MODIFIER")||""});continue}f("END")}return i}I.parse=At;function Go(e,t){return Wr(At(e,t),t)}I.compile=Go;function Wr(e,t){t===void 0&&(t={});var r=St(t),n=t.encode,o=n===void 0?function(c){return c}:n,a=t.validate,s=a===void 0?!0:a,i=e.map(function(c){if(typeof c=="object")return new RegExp("^(?:".concat(c.pattern,")$"),r)});return function(c){for(var d="",p=0;p<e.length;p++){var u=e[p];if(typeof u=="string"){d+=u;continue}var f=c?c[u.name]:void 0,h=u.modifier==="?"||u.modifier==="*",y=u.modifier==="*"||u.modifier==="+";if(Array.isArray(f)){if(!y)throw new TypeError('Expected "'.concat(u.name,'" to not repeat, but got an array'));if(f.length===0){if(h)continue;throw new TypeError('Expected "'.concat(u.name,'" to not be empty'))}for(var w=0;w<f.length;w++){var m=o(f[w],u);if(s&&!i[p].test(m))throw new TypeError('Expected all "'.concat(u.name,'" to match "').concat(u.pattern,'", but got "').concat(m,'"'));d+=u.prefix+m+u.suffix}continue}if(typeof f=="string"||typeof f=="number"){var m=o(String(f),u);if(s&&!i[p].test(m))throw new TypeError('Expected "'.concat(u.name,'" to match "').concat(u.pattern,'", but got "').concat(m,'"'));d+=u.prefix+m+u.suffix;continue}if(!h){var g=y?"an array":"a string";throw new TypeError('Expected "'.concat(u.name,'" to be ').concat(g))}}return d}}I.tokensToFunction=Wr;function Vo(e,t){var r=[],n=Et(e,r,t);return Jr(n,r,t)}I.match=Vo;function Jr(e,t,r){r===void 0&&(r={});var n=r.decode,o=n===void 0?function(a){return a}:n;return function(a){var s=e.exec(a);if(!s)return!1;for(var i=s[0],c=s.index,d=Object.create(null),p=function(f){if(s[f]===void 0)return"continue";var h=t[f-1];h.modifier==="*"||h.modifier==="+"?d[h.name]=s[f].split(h.prefix+h.suffix).map(function(y){return o(y,h)}):d[h.name]=o(s[f],h)},u=1;u<s.length;u++)p(u);return{path:i,index:c,params:d}}}I.regexpToFunction=Jr;function oe(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function St(e){return e&&e.sensitive?"":"i"}function zo(e,t){if(!t)return e;for(var r=/\((?:\?<(.*?)>)?(?!\?)/g,n=0,o=r.exec(e.source);o;)t.push({name:o[1]||n++,prefix:"",suffix:"",modifier:"",pattern:""}),o=r.exec(e.source);return e}function jo(e,t,r){var n=e.map(function(o){return Et(o,t,r).source});return new RegExp("(?:".concat(n.join("|"),")"),St(r))}function Xo(e,t,r){return Nr(At(e,r),t,r)}function Nr(e,t,r){r===void 0&&(r={});for(var n=r.strict,o=n===void 0?!1:n,a=r.start,s=a===void 0?!0:a,i=r.end,c=i===void 0?!0:i,d=r.encode,p=d===void 0?function(_){return _}:d,u=r.delimiter,f=u===void 0?"/#?":u,h=r.endsWith,y=h===void 0?"":h,w="[".concat(oe(y),"]|$"),m="[".concat(oe(f),"]"),g=s?"^":"",C=0,b=e;C<b.length;C++){var A=b[C];if(typeof A=="string")g+=oe(p(A));else{var W=oe(p(A.prefix)),k=oe(p(A.suffix));if(A.pattern)if(t&&t.push(A),W||k)if(A.modifier==="+"||A.modifier==="*"){var Z=A.modifier==="*"?"?":"";g+="(?:".concat(W,"((?:").concat(A.pattern,")(?:").concat(k).concat(W,"(?:").concat(A.pattern,"))*)").concat(k,")").concat(Z)}else g+="(?:".concat(W,"(").concat(A.pattern,")").concat(k,")").concat(A.modifier);else{if(A.modifier==="+"||A.modifier==="*")throw new TypeError('Can not repeat "'.concat(A.name,'" without a prefix and suffix'));g+="(".concat(A.pattern,")").concat(A.modifier)}else g+="(?:".concat(W).concat(k,")").concat(A.modifier)}}if(c)o||(g+="".concat(m,"?")),g+=r.endsWith?"(?=".concat(w,")"):"$";else{var j=e[e.length-1],x=typeof j=="string"?m.indexOf(j[j.length-1])>-1:j===void 0;o||(g+="(?:".concat(m,"(?=").concat(w,"))?")),x||(g+="(?=".concat(m,"|").concat(w,")"))}return new RegExp(g,St(r))}I.tokensToRegexp=Nr;function Et(e,t,r){return e instanceof RegExp?zo(e,t):Array.isArray(e)?jo(e,t,r):Xo(e,t,r)}I.pathToRegexp=Et});var Dr=S(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.Router=void 0;var Yo=Mr(),bt=class{constructor(){this.routes=[]}all(t,r){return this.push("ALL",t,r)}get(t,...r){return r.forEach(n=>{this.push("GET",t,n),this.push("HEAD",t,n)}),this}post(t,...r){return r.forEach(n=>{this.push("POST",t,n)}),this}put(t,...r){return r.forEach(n=>{this.push("PUT",t,n)}),this}patch(t,...r){return r.forEach(n=>{this.push("PATCH",t,n)}),this}delete(t,...r){return r.forEach(n=>{this.push("DELETE",t,n)}),this}head(t,...r){return r.forEach(n=>{this.push("HEAD",t,n)}),this}options(t,...r){return r.forEach(n=>{this.push("OPTIONS",t,n)}),this}use(t){return this.push("ALL","*",t)}allowedMethods(){return async t=>{let r=new URL(t.request.url),n={OPTIONS:!0};return this.routes.forEach(o=>{if(o.method==="ALL")return;let a=o.regexp.exec(r.pathname);!a||!a.length||(n[o.method]=!0)}),new Response(null,{status:204,headers:{"Access-Control-Allow-Methods":Object.keys(n).join(", "),"Access-Control-Allow-Origin":"*","Access-Control-Allow-Headers":"Content-Type"}})}}matches(t,r){let n=[];return this.routes.forEach(o=>{if(o.method!==t&&o.method!=="ALL")return;let a=o.regexp.exec(r);!a||!a.length||n.push({...o,matches:a,params:Zo(a,o.keys)})}),n}async handleMatches(t,...r){let n=r.shift();return n?(t.params=n.params,n.handler(t,()=>this.handleMatches(t,...r))):null}async handle(t,r,n){let{pathname:o,searchParams:a,protocol:s,host:i,hostname:c}=new URL(t.url),d=this.matches(t.method,o),p={request:t,query:a,headers:t.headers,ip:t.headers.get("x-real-ip"),protocol:s,host:i,hostname:c,params:{},state:{},env:r,event:n},u=await this.handleMatches(p,...d);return u?t.method==="HEAD"?new Response("",u):u:new Response("Not Found",{status:404})}push(t,r,n){let o=[];r==="*"&&(r="(.*)");let a=(0,Yo.pathToRegexp)(r,o);return this.routes.push({method:t,path:r.toString(),handler:n,keys:o,regexp:a}),this}};ze.Router=bt;var Zo=(e,t)=>{let r={};for(let n=1;n<e.length;n++){let a=t[n-1].name,s=e[n];s!==void 0&&(r[a]=s)}return r}});var kr=S(je=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.bodyparser=void 0;var Qo=["POST","PUT","PATCH"];async function ea(e,t){let r=e.headers.get("content-type");if(!Qo.includes(e.request.method))return t();try{return r?.startsWith("application/json")?e.body=await e.request.json():r?.startsWith("application/x-www-form-urlencoded")?e.body=Object.fromEntries(await e.request.formData()):r?.startsWith("text")&&(e.body=await e.request.text()),t()}catch{return new Response("Invalid body format",{status:400,headers:{"content-type":"text/plain"}})}}je.bodyparser=ea});var $r=S(fe=>{"use strict";var ta=fe&&fe.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),ra=fe&&fe.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&ta(t,e,r)};Object.defineProperty(fe,"__esModule",{value:!0});ra(kr(),fe)});var qr=S(te=>{"use strict";var na=te&&te.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),vt=te&&te.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&na(t,e,r)};Object.defineProperty(te,"__esModule",{value:!0});vt(Ir(),te);vt(Dr(),te);vt($r(),te)});var V=S((Cu,tn)=>{var oa="Expected a function",Vr="__lodash_hash_undefined__",zr=1/0,aa="[object Function]",sa="[object GeneratorFunction]",ia="[object Symbol]",ca=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ua=/^\w*$/,da=/^\./,pa=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,fa=/[\\^$.*+?()[\]{}|]/g,ha=/\\(\\)?/g,la=/^\[object .+?Constructor\]$/,ma=typeof global=="object"&&global&&global.Object===Object&&global,ya=typeof self=="object"&&self&&self.Object===Object&&self,Ct=ma||ya||Function("return this")();function ga(e,t){return e?.[t]}function wa(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var Aa=Array.prototype,Sa=Function.prototype,jr=Object.prototype,_t=Ct["__core-js_shared__"],Fr=function(){var e=/[^.]+$/.exec(_t&&_t.keys&&_t.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Xr=Sa.toString,Pt=jr.hasOwnProperty,Yr=jr.toString,Ea=RegExp("^"+Xr.call(Pt).replace(fa,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Lr=Ct.Symbol,ba=Aa.splice,va=Zr(Ct,"Map"),Re=Zr(Object,"create"),Br=Lr?Lr.prototype:void 0,Gr=Br?Br.toString:void 0;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 _a(){this.__data__=Re?Re(null):{}}function Ca(e){return this.has(e)&&delete this.__data__[e]}function Pa(e){var t=this.__data__;if(Re){var r=t[e];return r===Vr?void 0:r}return Pt.call(t,e)?t[e]:void 0}function Ta(e){var t=this.__data__;return Re?t[e]!==void 0:Pt.call(t,e)}function Ha(e,t){var r=this.__data__;return r[e]=Re&&t===void 0?Vr:t,this}he.prototype.clear=_a;he.prototype.delete=Ca;he.prototype.get=Pa;he.prototype.has=Ta;he.prototype.set=Ha;function Ee(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 Ka(){this.__data__=[]}function Oa(e){var t=this.__data__,r=Xe(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():ba.call(t,r,1),!0}function xa(e){var t=this.__data__,r=Xe(t,e);return r<0?void 0:t[r][1]}function Ra(e){return Xe(this.__data__,e)>-1}function Ua(e,t){var r=this.__data__,n=Xe(r,e);return n<0?r.push([e,t]):r[n][1]=t,this}Ee.prototype.clear=Ka;Ee.prototype.delete=Oa;Ee.prototype.get=xa;Ee.prototype.has=Ra;Ee.prototype.set=Ua;function le(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__={hash:new he,map:new(va||Ee),string:new he}}function Wa(e){return Ye(this,e).delete(e)}function Ja(e){return Ye(this,e).get(e)}function Na(e){return Ye(this,e).has(e)}function Ma(e,t){return Ye(this,e).set(e,t),this}le.prototype.clear=Ia;le.prototype.delete=Wa;le.prototype.get=Ja;le.prototype.has=Na;le.prototype.set=Ma;function Xe(e,t){for(var r=e.length;r--;)if(ja(e[r][0],t))return r;return-1}function Da(e,t){t=Fa(t,e)?[t]:qa(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 ka(e){if(!en(e)||Ba(e))return!1;var t=Xa(e)||wa(e)?Ea:la;return t.test(za(e))}function $a(e){if(typeof e=="string")return e;if(Ht(e))return Gr?Gr.call(e):"";var t=e+"";return t=="0"&&1/e==-zr?"-0":t}function qa(e){return Qr(e)?e:Ga(e)}function Ye(e,t){var r=e.__data__;return La(t)?r[typeof t=="string"?"string":"hash"]:r.map}function Zr(e,t){var r=ga(e,t);return ka(r)?r:void 0}function Fa(e,t){if(Qr(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||Ht(e)?!0:ua.test(e)||!ca.test(e)||t!=null&&e in Object(t)}function La(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Ba(e){return!!Fr&&Fr in e}var Ga=Tt(function(e){e=Za(e);var t=[];return da.test(e)&&t.push(""),e.replace(pa,function(r,n,o,a){t.push(o?a.replace(ha,"$1"):n||r)}),t});function Va(e){if(typeof e=="string"||Ht(e))return e;var t=e+"";return t=="0"&&1/e==-zr?"-0":t}function za(e){if(e!=null){try{return Xr.call(e)}catch{}try{return e+""}catch{}}return""}function Tt(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(oa);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(Tt.Cache||le),r}Tt.Cache=le;function ja(e,t){return e===t||e!==e&&t!==t}var Qr=Array.isArray;function Xa(e){var t=en(e)?Yr.call(e):"";return t==aa||t==sa}function en(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function Ya(e){return!!e&&typeof e=="object"}function Ht(e){return typeof e=="symbol"||Ya(e)&&Yr.call(e)==ia}function Za(e){return e==null?"":$a(e)}function Qa(e,t,r){var n=e==null?void 0:Da(e,t);return n===void 0?r:n}tn.exports=Qa});var Qe=S((Ze,un)=>{(function(e,t){typeof Ze=="object"&&typeof un<"u"?t(Ze):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.aws4fetch={}))})(Ze,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:f,secretAccessKey:h,sessionToken:y,service:w,region:m,cache:g,retries:C,initRetryMs:b}){if(f==null)throw new TypeError("accessKeyId is a required option");if(h==null)throw new TypeError("secretAccessKey is a required option");this.accessKeyId=f,this.secretAccessKey=h,this.sessionToken=y,this.service=w,this.region=m,this.cache=g||new Map,this.retries=C??10,this.initRetryMs=b||50}async sign(f,h){if(f instanceof Request){let{method:m,url:g,headers:C,body:b}=f;h=Object.assign({method:m,url:g,headers:C},h),h.body==null&&C.has("Content-Type")&&(h.body=b!=null&&C.has("X-Amz-Content-Sha256")?b:await f.clone().arrayBuffer()),f=g}let y=new a(Object.assign({url:f},h,this,h&&h.aws)),w=Object.assign({},h,await y.sign());return delete w.aws,new Request(w.url.toString(),w)}async fetch(f,h){for(let y=0;y<=this.retries;y++){let w=fetch(await this.sign(f,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:f,url:h,headers:y,body:w,accessKeyId:m,secretAccessKey:g,sessionToken:C,service:b,region:A,cache:W,datetime:k,signQuery:Z,appendSessionToken:j,allHeaders:x,singleEncode:_}){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=f||(w?"POST":"GET"),this.url=new URL(h),this.headers=new Headers(y||{}),this.body=w,this.accessKeyId=m,this.secretAccessKey=g,this.sessionToken=C;let H,Q;(!b||!A)&&([H,Q]=p(this.url,this.headers)),this.service=b||H||"",this.region=A||Q||"us-east-1",this.cache=W||new Map,this.datetime=k||new Date().toISOString().replace(/[:-]|\.\d{3}/g,""),this.signQuery=Z,this.appendSessionToken=j||this.service==="iotdevicegateway",this.headers.delete("Host");let B=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"),B.set("X-Amz-Date",this.datetime),this.sessionToken&&!this.appendSessionToken&&B.set("X-Amz-Security-Token",this.sessionToken),this.signableHeaders=["host",...this.headers.keys()].filter(K=>x||!n.includes(K)).sort(),this.signedHeaders=this.signableHeaders.join(";"),this.canonicalHeaders=this.signableHeaders.map(K=>K+":"+(K==="host"?this.url.host:(this.headers.get(K)||"").replace(/\s+/g," "))).join(`
|
|
2
|
+
`),this.credentialString=[this.datetime.slice(0,8),this.region,this.service,"aws4_request"].join("/"),this.signQuery&&(this.service==="s3"&&!B.has("X-Amz-Expires")&&B.set("X-Amz-Expires","86400"),B.set("X-Amz-Algorithm","AWS4-HMAC-SHA256"),B.set("X-Amz-Credential",this.accessKeyId+"/"+this.credentialString),B.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,"/");_||(this.encodedPath=encodeURIComponent(this.encodedPath).replace(/%2F/g,"/")),this.encodedPath=d(this.encodedPath);let Be=new Set;this.encodedSearch=[...this.url.searchParams].filter(([K])=>{if(!K)return!1;if(this.service==="s3"){if(Be.has(K))return!1;Be.add(K)}return!0}).map(K=>K.map(Oe=>d(encodeURIComponent(Oe)))).sort(([K,Oe],[xe,Ge])=>K<xe?-1:K>xe?1:Oe<Ge?-1:Oe>Ge?1:0).map(K=>K.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 f=this.datetime.slice(0,8),h=[this.secretAccessKey,f,this.region,this.service].join(),y=this.cache.get(h);if(!y){let w=await s("AWS4"+this.secretAccessKey,f),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 f=this.headers.get("X-Amz-Content-Sha256");if(f==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");f=c(await i(this.body||""))}return f}}async function s(u,f){let h=await crypto.subtle.importKey("raw",typeof u=="string"?t.encode(u):u,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return crypto.subtle.sign("HMAC",h,t.encode(f))}async function i(u){return crypto.subtle.digest("SHA-256",typeof u=="string"?t.encode(u):u)}function c(u){return Array.prototype.map.call(new Uint8Array(u),f=>("0"+f.toString(16)).slice(-2)).join("")}function p(u){return u.replace(/[!'()*]/g,f=>"%"+f.charCodeAt(0).toString(16).toUpperCase())}function d(u,f){let{hostname:h,pathname:y}=u,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 _=(f.get("X-Amz-Target")||"").split(".")[0];_==="AnyScaleFrontendService"?m="application-autoscaling":_==="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 ot=S((Xu,Cn)=>{var Es="Expected a function",yn="__lodash_hash_undefined__",gn=1/0,bs=9007199254740991,vs="[object Function]",Cs="[object GeneratorFunction]",_s="[object Symbol]",Ps=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ts=/^\w*$/,Hs=/^\./,Ks=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,xs=/[\\^$.*+?()[\]{}|]/g,Os=/\\(\\)?/g,Rs=/^\[object .+?Constructor\]$/,Us=/^(?:0|[1-9]\d*)$/,Is=typeof global=="object"&&global&&global.Object===Object&&global,Ws=typeof self=="object"&&self&&self.Object===Object&&self,Ft=Is||Ws||Function("return this")();function Js(e,t){return e?.[t]}function Ns(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var Ms=Array.prototype,Ds=Function.prototype,wn=Object.prototype,qt=Ft["__core-js_shared__"],fn=function(){var e=/[^.]+$/.exec(qt&&qt.keys&&qt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),An=Ds.toString,tt=wn.hasOwnProperty,Sn=wn.toString,ks=RegExp("^"+An.call(tt).replace(xs,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),hn=Ft.Symbol,$s=Ms.splice,qs=En(Ft,"Map"),Ue=En(Object,"create"),ln=hn?hn.prototype:void 0,mn=ln?ln.toString:void 0;function ye(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 Fs(){this.__data__=Ue?Ue(null):{}}function Ls(e){return this.has(e)&&delete this.__data__[e]}function Bs(e){var t=this.__data__;if(Ue){var r=t[e];return r===yn?void 0:r}return tt.call(t,e)?t[e]:void 0}function Gs(e){var t=this.__data__;return Ue?t[e]!==void 0:tt.call(t,e)}function Vs(e,t){var r=this.__data__;return r[e]=Ue&&t===void 0?yn:t,this}ye.prototype.clear=Fs;ye.prototype.delete=Ls;ye.prototype.get=Bs;ye.prototype.has=Gs;ye.prototype.set=Vs;function be(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 zs(){this.__data__=[]}function js(e){var t=this.__data__,r=rt(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():$s.call(t,r,1),!0}function Xs(e){var t=this.__data__,r=rt(t,e);return r<0?void 0:t[r][1]}function Ys(e){return rt(this.__data__,e)>-1}function Zs(e,t){var r=this.__data__,n=rt(r,e);return n<0?r.push([e,t]):r[n][1]=t,this}be.prototype.clear=zs;be.prototype.delete=js;be.prototype.get=Xs;be.prototype.has=Ys;be.prototype.set=Zs;function ge(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 Qs(){this.__data__={hash:new ye,map:new(qs||be),string:new ye}}function ei(e){return nt(this,e).delete(e)}function ti(e){return nt(this,e).get(e)}function ri(e){return nt(this,e).has(e)}function ni(e,t){return nt(this,e).set(e,t),this}ge.prototype.clear=Qs;ge.prototype.delete=ei;ge.prototype.get=ti;ge.prototype.has=ri;ge.prototype.set=ni;function oi(e,t,r){var n=e[t];(!(tt.call(e,t)&&bn(n,r))||r===void 0&&!(t in e))&&(e[t]=r)}function rt(e,t){for(var r=e.length;r--;)if(bn(e[r][0],t))return r;return-1}function ai(e){if(!et(e)||fi(e))return!1;var t=yi(e)||Ns(e)?ks:Rs;return t.test(mi(e))}function si(e,t,r,n){if(!et(e))return e;t=di(t,e)?[t]:ci(t);for(var o=-1,a=t.length,s=a-1,i=e;i!=null&&++o<a;){var c=li(t[o]),p=r;if(o!=s){var d=i[c];p=n?n(d,c,i):void 0,p===void 0&&(p=et(d)?d:ui(t[o+1])?[]:{})}oi(i,c,p),i=i[c]}return e}function ii(e){if(typeof e=="string")return e;if(Bt(e))return mn?mn.call(e):"";var t=e+"";return t=="0"&&1/e==-gn?"-0":t}function ci(e){return vn(e)?e:hi(e)}function nt(e,t){var r=e.__data__;return pi(t)?r[typeof t=="string"?"string":"hash"]:r.map}function En(e,t){var r=Js(e,t);return ai(r)?r:void 0}function ui(e,t){return t=t??bs,!!t&&(typeof e=="number"||Us.test(e))&&e>-1&&e%1==0&&e<t}function di(e,t){if(vn(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||Bt(e)?!0:Ts.test(e)||!Ps.test(e)||t!=null&&e in Object(t)}function pi(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function fi(e){return!!fn&&fn in e}var hi=Lt(function(e){e=wi(e);var t=[];return Hs.test(e)&&t.push(""),e.replace(Ks,function(r,n,o,a){t.push(o?a.replace(Os,"$1"):n||r)}),t});function li(e){if(typeof e=="string"||Bt(e))return e;var t=e+"";return t=="0"&&1/e==-gn?"-0":t}function mi(e){if(e!=null){try{return An.call(e)}catch{}try{return e+""}catch{}}return""}function Lt(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(Es);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(Lt.Cache||ge),r}Lt.Cache=ge;function bn(e,t){return e===t||e!==e&&t!==t}var vn=Array.isArray;function yi(e){var t=et(e)?Sn.call(e):"";return t==vs||t==Cs}function et(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function gi(e){return!!e&&typeof e=="object"}function Bt(e){return typeof e=="symbol"||gi(e)&&Sn.call(e)==_s}function wi(e){return e==null?"":ii(e)}function Ai(e,t,r){return e==null?e:si(e,t,r)}Cn.exports=Ai});var On=S(jt=>{"use strict";jt.parse=Ti;jt.serialize=Hi;var Ci=decodeURIComponent,_i=encodeURIComponent,Pi=/; */,st=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function Ti(e,t){if(typeof e!="string")throw new TypeError("argument str must be a string");for(var r={},n=t||{},o=e.split(Pi),a=n.decode||Ci,s=0;s<o.length;s++){var i=o[s],c=i.indexOf("=");if(!(c<0)){var p=i.substr(0,c).trim(),d=i.substr(++c,i.length).trim();d[0]=='"'&&(d=d.slice(1,-1)),r[p]==null&&(r[p]=Ki(d,a))}}return r}function Hi(e,t,r){var n=r||{},o=n.encode||_i;if(typeof o!="function")throw new TypeError("option encode is invalid");if(!st.test(e))throw new TypeError("argument name is invalid");var a=o(t);if(a&&!st.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(!st.test(n.domain))throw new TypeError("option domain is invalid");s+="; Domain="+n.domain}if(n.path){if(!st.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 Ki(e,t){try{return t(e)}catch{return e}}});var Un=S((ld,Rn)=>{"use strict";var it=1;function xi(){return it=(it*9301+49297)%233280,it/233280}function Oi(e){it=e}Rn.exports={nextValue:xi,seed:Oi}});var Ne=S((md,Nn)=>{"use strict";var Xt=Un(),Ae="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-",ae,In,Je;function Yt(){Je=!1}function Wn(e){if(!e){ae!==Ae&&(ae=Ae,Yt());return}if(e!==ae){if(e.length!==Ae.length)throw new Error("Custom alphabet for shortid must be "+Ae.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 "+Ae.length+" unique characters. These characters were not unique: "+t.join(", "));ae=e,Yt()}}function Ri(e){return Wn(e),ae}function Ui(e){Xt.seed(e),In!==e&&(Yt(),In=e)}function Ii(){ae||Wn(Ae);for(var e=ae.split(""),t=[],r=Xt.nextValue(),n;e.length>0;)r=Xt.nextValue(),n=Math.floor(r*e.length),t.push(e.splice(n,1)[0]);return t.join("")}function Jn(){return Je||(Je=Ii(),Je)}function Wi(e){var t=Jn();return t[e]}function Ji(){return ae||Ae}Nn.exports={get:Ji,characters:Ri,seed:Ui,lookup:Wi,shuffled:Jn}});var Dn=S((yd,Mn)=>{"use strict";var Zt=typeof window=="object"&&(window.crypto||window.msCrypto),Qt;!Zt||!Zt.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 Zt.getRandomValues(new Uint8Array(e))};Mn.exports=Qt});var $n=S((gd,kn)=>{kn.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 Fn=S((wd,qn)=>{"use strict";var Ni=Ne(),Mi=Dn(),Di=$n();function ki(e){for(var t=0,r,n="";!r;)n=n+Di(Mi,Ni.get(),1),r=e<Math.pow(16,t+1),t++;return n}qn.exports=ki});var Gn=S((Sd,Bn)=>{"use strict";var ct=Fn(),Ad=Ne(),$i=1567752802062,qi=7,ut,Ln;function Fi(e){var t="",r=Math.floor((Date.now()-$i)*.001);return r===Ln?ut++:(ut=0,Ln=r),t=t+ct(qi),t=t+ct(e),ut>0&&(t=t+ct(ut)),t=t+ct(r),t}Bn.exports=Fi});var zn=S((Ed,Vn)=>{"use strict";var Li=Ne();function Bi(e){if(!e||typeof e!="string"||e.length<6)return!1;var t=new RegExp("[^"+Li.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]");return!t.test(e)}Vn.exports=Bi});var Xn=S((bd,jn)=>{"use strict";jn.exports=0});var Qn=S((vd,re)=>{"use strict";var er=Ne(),Gi=Gn(),Vi=zn(),Yn=Xn()||0;function zi(e){return er.seed(e),re.exports}function ji(e){return Yn=e,re.exports}function Xi(e){return e!==void 0&&er.characters(e),er.shuffled()}function Zn(){return Gi(Yn)}re.exports=Zn;re.exports.generate=Zn;re.exports.seed=zi;re.exports.worker=ji;re.exports.characters=Xi;re.exports.isValid=Vi});var to=S((Cd,eo)=>{"use strict";eo.exports=Qn()});var Uo=x(Fr());var nn=x(V()),ts={get:nn.default};function Kt(e){e.status=401,e.body="Unauthorized",e.set("WWW-Authenticate","Basic")}function xt(e){return async(t,r)=>{if(t.request.path===e.logoutPath)return Kt(t);let n=ts.get(t,"request.headers.authorization");if(!n||!n.startsWith("Basic "))return Kt(t);let o=e.users.map(i=>i.authToken),a=n.substring(6),s=o.indexOf(a);return s===-1?Kt(t):(t.state.user=e.users[s].username,r(t))}}var on=caches.default;async function rs(e){return await on.match(e)}async function ns(e,t){return on.put(e.href,t)}var Ot={get:rs,set:ns};async function os(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 an=os;function as(e,t={}){return Object.keys(t).reduce((r,n)=>r.replace(`{${n}}`,t[n]),e)}function Rt(e){return[...e].reduce((t,r)=>{let n={};return n[r[0]]=r[1],{...t,...n}},{})}function Ut(e){return e.set=function(t,r){return this.response.headers.set(t.toLowerCase(),r)},e.header=function(t){return this.response.headers.get(t.toLowerCase())},e}var b={resolveParams:as,instanceToJson:Rt,CTXHelper:Ut};var ss=["x-ratelimit-count","x-ratelimit-limit","x-ratelimit-reset","x-cache-hit"];async function is(e){return["POST","PATCH","PUT","DELETE"].indexOf(e.method)===-1?null:e.text()}async function cs(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 an(await is(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 It({cacheDuration:e,cacheKeyTemplate:t,headerBlacklist:r=ss}){return async(n,o)=>{let a=await cs(n,t),s=await Ot.get(a);if(s){n.body=s.body,n.status=s.status;let i=Rt(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(p=>{r.indexOf(p.toLowerCase())===-1&&c.headers.set(p,n.response.headers[p])}),e&&(c.headers.delete("Cache-Control"),c.headers.set("Cache-Control",`max-age=${e}`)),n.event.waitUntil(Ot.set(a,c))}}}function Wt({allowedOrigins:e=["*"],allowedMethods:t=["GET","PUT","POST","PATCH","DELETE","HEAD","OPTIONS"],allowCredentials:r=!0,allowedHeaders:n=["Content-Type"],allowedExposeHeaders:o=[],maxAge:a=600,optionsSuccessStatus:s=204,terminatePreflight:i=!1}){return async(c,p)=>{let d=Ut(c),{method:u}=d.request,{origin:f}=d.request.headers,h=d.request.headers["access-control-request-headers"];if(console.log("---------------------1"+JSON.stringify(d.response.headers)),us(d,f,e),console.log("---------------------2"+JSON.stringify(d.response.headers)),ds(d,r),console.log("---------------------3"+JSON.stringify(d.response.headers)),ls(d,o),console.log("---------------------4"+JSON.stringify(d.response.headers)),u==="OPTIONS"&&(ps(d,t),fs(d,h,n),hs(d,a),i)){d.status=s,d.set("Content-Length","0"),d.body="";return}await p(d)}}function us(e,t,r){Array.isArray(r)&&(r[0]==="*"?(e.set("Access-Control-Allow-Origin","*"),setCTXHeader()):r.indexOf(t)!==-1&&(e.set("Access-Control-Allow-Origin",t),e.set("Vary","Origin")))}function ds(e,t){t&&e.set("Access-Control-Allow-Credentials",t)}function ps(e,t){e.set("Access-Control-Allow-Methods",t.join(","))}function fs(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 hs(e,t){t&&e.set("Access-Control-Max-Age",t)}function ls(e,t){t.length&&e.set("Access-Control-Expose-Headers",t.join(","))}var ms={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 Jt(){return async(e,t)=>{let r=e.request.headers["cf-ipcountry"]||"XX";e.request.headers["proxy-continent"]=ms[r],await t(e)}}function sn(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=atob(t),n=Uint8Array.from(r,o=>o.charCodeAt(0));return new TextDecoder().decode(n)}function ys(e){let t=e.split("."),r=JSON.parse(sn(t[0])),n=JSON.parse(sn(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 Nt({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 d=new TextEncoder().encode([c.raw.header,c.raw.payload].join(".")),u=new Uint8Array(Array.from(c.signature).map(y=>y.charCodeAt(0))),f=await o();return(await Promise.all(f.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,u,d)}))).some(y=>y)}async function i(c,p){if(c.request.method==="OPTIONS"||n)return p(c);if((c.request.headers.authorization||"").toLowerCase().startsWith("bearer")){let u=ys(c.request.headers.authorization.slice(7)),f=new Date(u.payload.exp*1e3),h=new Date(Date.now());return f<=h||!t||u.payload.iss!==t||!r||u.payload.aud!==r||!await s(u)?a(c):(c.state.user=u.payload,p(c))}return a(c)}return i}var cn=x(V()),gs={get:cn.default},me=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=gs.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 N={methodsMethodsWithBody:["POST","PUT","PATCH"],http:{statusMessages:{404:"Not Found"}},mime:{css:"text/css",csv:"text/csv",html:"text/html",ico:"image/microsoft.vnd.icon",jpeg:"image/jpeg",js:"application/javascript",json:"application/json",png:"image/png",svg:"image/svg+xml",xml:"application/xml"}};function ws(e,t,r){if(e==="/"&&r)return r;let n=e.split("/").pop();return n.split(".").pop()!==n?e:`${e}.${t}`}function Mt({kvAccountId:e,kvNamespace:t,kvAuthEmail:r,kvAuthKey:n,kvBasePath:o="",kvKey:a="{file}",defaultExtension:s="html",defaultIndexDocument:i,defaultErrorDocument:c,mime:p={},mode:d="rest"}){let u=new me({accountId:e,namespace:t,authEmail:r,authKey:n,mode:d}),f={...N.mime,...p};return async h=>{let y=b.resolveParams(a,h.params),w=y===""&&i?i:ws(y,s),m=await u.get(o+w);!m&&c&&(m=await u.get(o+c)),m?(h.status=200,h.body=m,h.set("Content-Type",f[w.split(".").pop()]||"text/plain")):(h.status=404,h.body=N.http.statusMessages[404],h.set("Content-Type","text/plain"))}}var un=x(V());var Dt={get:un.default};function As(e,t,r){if(e==="/"&&r)return r;let n=e.split("/").pop();return n.split(".").pop()!==n?e:`${e}.${t}`}function Ss(e,t){let r=Dt.get(e,"headers.if-none-match"),n=Dt.get(t,"metadata.headers.etag");return r?r===n:!1}function kt({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=b.resolveParams(r,i.params),p=c===""&&o?o:As(c,n),d=await s(t+p);if(!d&&a&&(d=await s(t+a)),d)if(Ss(i.request,d))i.status=304;else{i.status=d.status,i.body=d.value;let u=Dt.get(d,"metadata.headers",{});Object.keys(u).forEach(f=>{i.set(f,u[f])})}else i.status=404,i.body=N.http.statusMessages[404],i.set("Content-Type","text/plain")}}var pn=x(Qe());function $t({accessKeyId:e,secretAccessKey:t,region:r,lambdaName:n}){let o=new pn.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 p=b.instanceToJson(c.headers);Object.keys(p).forEach(d=>{a.set(d,p[d])})}}var Pn=x(V()),Tn=x(ot());var _n={get:Pn.default,set:Tn.default};function Si(e){let t={};return Object.keys(e).forEach(r=>{r.startsWith("cf")||(t[r]=e[r])}),t}function Ei(e){return e[Math.floor(Math.random()*e.length)]}function Gt({sources:e=[]}){return async t=>{let r=Ei(e),n={method:t.request.method,headers:Si(t.request.headers),redirect:"manual",cf:t.request.cf};if(N.methodsMethodsWithBody.indexOf(t.request.method)!==-1&&_n.get(t,"event.request.body")){let i=t.event.request.clone();n.body=i.body}let o=b.resolveParams(r.url,t.params);if(r.resolveOverride){let i=b.resolveParams(r.resolveOverride,t.request.params);_n.set(n,"cf.resolveOverride",i)}let a=await fetch(o+t.request.search,n);t.body=a.body,t.status=a.status;let s=b.instanceToJson(a.headers);Object.keys(s).forEach(i=>{t.set(i,s[i])})}}var xn=x(V());var Vt={name:"@ahmadissa/cloudworker-proxy",version:"1.1.85",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:"Ahmad Issa",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",build:"^0.1.4","cloudworker-router":"^4.1.5",cookie:"0.4.1",jose:"^5.1.0","lodash.get":"4.4.2","lodash.set":"4.3.2",package:"^1.0.1",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 we=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 $={get:xn.default};async function vi(e){return["POST","PATCH","PUT","DELETE"].indexOf(e.method)===-1?null:e.text()}function zt(e){let t;switch(e.type){case"http":t=new Ie(e);break;case"kinesis":t=new We(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 vi(r.request);try{await n(r);let a={message:"START",requestIp:$.get(r,"request.headers.x-real-ip"),requestId:$.get(r,"request.requestId"),request:{headers:$.get(r,"request.headers"),method:$.get(r,"request.method"),url:$.get(r,"request.href"),protocol:$.get(r,"request.protocol"),body:o},response:{status:r.status,headers:$.get(r,"response.headers")},handlers:$.get(r,"state.handlers",[]).join(","),route:$.get(r,"route.name"),timestamp:new Date().toISOString(),ttfb:new Date-r.state["logger-startDate"],redirectUrl:r.userRedirect,severity:30,proxyVersion:Vt.version};r.event.waitUntil(t.log(a))}catch(a){let s={request:{headers:$.get(r,"request.headers"),method:$.get(r,"request.method"),handlers:$.get(r,"state.handlers",[]).join(","),url:$.get(r,"request.href"),body:o},message:"ERROR",stack:a.stack,error:a.message,severity:50,proxyVersion:Vt.version};r.event.waitUntil(t.log(s))}}}var Me=x(On()),ao=x(V()),so=x(ot()),io=x(to());async function tr({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 ro="PBKDF2",rr="AES-GCM",Yi="SHA-256",Zi="raw";function Qi(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 no(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 ec(e){return new TextEncoder().encode(e).buffer}function tc(e){return new TextDecoder().decode(e)}async function rc(e){let t=new TextEncoder;return crypto.subtle.importKey(Zi,t.encode(e),{name:ro},!1,["deriveKey"])}async function nc(e,t){let r=await rc(e),o=new TextEncoder().encode(t.replace(/_/g,"/").replace(/-/g,"+"));return crypto.subtle.deriveKey({name:ro,salt:o,iterations:1e3,hash:{name:Yi}},r,{name:rr,length:256},!0,["encrypt","decrypt"])}async function oc(){let e=crypto.getRandomValues(new Uint8Array(8));return no(e)}async function ac(e,t){let r=Qi(t),n=r.slice(0,16),o=r.slice(16),a=await crypto.subtle.decrypt({name:rr,iv:n},e,o);return tc(a)}async function sc(e,t){let r=crypto.getRandomValues(new Uint8Array(16)),n=await crypto.subtle.encrypt({name:rr,iv:r},e,ec(t)),o=new Uint8Array(n.byteLength+r.byteLength);return o.set(r,0),o.set(new Uint8Array(n),r.byteLength),no(o)}var Se={decrypt:ac,deriveAesGcmKey:nc,encrypt:sc,getSalt:oc};var ve={get:ao.default,set:so.default};function oo({cookieHeader:e="",cookieName:t}){return Me.default.parse(e)[t]}function ic(e){return Object.keys(e).map(t=>`${t}=${encodeURIComponent(e[t])}`).join("&")}function cc(e=""){return e.split(",").indexOf("text/html")!==-1}function nr({cookieName:e="proxy",cookieHttpOnly:t=!0,allowPublicAccess:r=!1,kvAccountId:n,kvNamespace:o,kvAuthEmail:a,kvAuthKey:s,kvTtl:i=2592e3,oauth2AuthDomain:c,oauth2ClientId:p,oauth2ClientSecret:d,oauth2Audience:u,oauth2Scopes:f=[],oauth2CallbackPath:h="/callback",oauth2CallbackType:y="cookie",oauth2LogoutPath:w="/logout",oauth2LoginPath:m="/login",oauth2ServerTokenPath:g="/oauth/token",oauth2ServerAuthorizePath:_="",oauth2ServerLogoutPath:v}){let A=new me({accountId:n,namespace:o,authEmail:a,authKey:s,ttl:i}),W=c,k=h,Z=y,j=g,O=_,C=v,H=p,Q=d,B=u,Be=w,K=m,Oe=f.join("%20");async function Ge(l,U){let R=`${W}${j}`,J=await fetch(R,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:ic({code:l,grant_type:"authorization_code",client_id:H,client_secret:Q,redirect_uri:U})});if(!J.ok)throw new Error("Authentication failed");let X=await J.json();return{...X,expires:Date.now()+X.expires_in*1e3}}async function Io(l){if(oo({cookieHeader:l.request.headers.cookie,cookieName:e})){let J=l.request.hostname.match(/[^.]+\.[^.]+$/i)[0];l.set("Set-Cookie",Me.default.serialize(e,"",{domain:`.${J}`,path:"/",maxAge:0}))}let R=_r(l);if(v){let J=encodeURIComponent(`${l.request.protocol}://${l.request.host}${R}`);l.set("Location",`${W}${C}?client_id=${H}&returnTo=${J}`)}else l.set("Location",R);l.status=302}async function Wo(l){let U=l.request.href.split("?")[0],R=await Ge(l.request.query.code,U),J=io.default.generate(),X=await Se.getSalt(),ee=`${J}.${X}`,gt=await Se.deriveAesGcmKey(J,X),pe=await Se.encrypt(gt,JSON.stringify(R));await A.put(J,pe);let wt=l.request.hostname.match(/[^.]+\.[^.]+$/i)[0];l.status=302,Z==="query"?l.set("Location",`${l.request.query.state}?auth=${ee}`):(l.set("Set-Cookie",Me.default.serialize(e,ee,{httpOnly:t,domain:`.${wt}`,path:"/",maxAge:60*60*24*365})),l.set("Location",l.request.query.state))}async function Jo(l,U){let[R,J]=U.split("."),X=await A.get(R);if(X){let ee=await Se.deriveAesGcmKey(R,J),gt=await Se.decrypt(ee,X),pe=JSON.parse(gt);if(pe.expires<Date.now()){pe=await tr({refresh_token:pe.refresh_token,clientId:H,authDomain:W,clientSecret:Q});let wt=await Se.encrypt(ee,JSON.stringify(pe));await A.put(R,wt)}l.state.accessToken=pe.access_token,l.state.accessToken&&(l.request.headers.authorization=`bearer ${l.state.accessToken}`)}else{let ee=l.request.hostname.match(/[^.]+\.[^.]+$/i)[0];l.set("Set-Cookie",Me.default.serialize(e,"",{domain:`.${ee}`,maxAge:0}))}}function _r(l){let U=ve.get(l,"request.query.redirect-to");if(U)return U;let R=ve.get(l,"request.headers.referer");return R||"/"}async function No(l){if(l.request.method==="OPTIONS")l.status=200;else{let U=_r(l),R=encodeURIComponent(U||"/"),J=encodeURIComponent(`${l.request.protocol}://${l.request.host}${k}`);l.status=302,l.set("location",`${W}${O}/authorize?state=${R}&client_id=${H}&response_type=code&scope=${Oe}&audience=${B}&redirect_uri=${J}`)}}async function Mo(l,U){if(l.request.method==="OPTIONS")await U(l);else if(ve.get(l,"request.headers.authorization","").toLowerCase().startsWith("bearer "))ve.set(l,"state.access_token",l.request.headers.authorization.slice(7)),await U(l);else{let R=ve.get(l,"request.query.auth")||oo({cookieHeader:l.request.headers.cookie,cookieName:e});if(R&&await Jo(l,R),ve.get(l,"state.accessToken")||r)await U(l);else if(cc(l.request.headers.accept)){let X=encodeURIComponent(l.request.href),ee=encodeURIComponent(`${l.request.protocol}://${l.request.host}${k}`);l.status=302,l.set("location",`${W}${O}/authorize?state=${X}&client_id=${H}&response_type=code&scope=${Oe}&audience=${B}&redirect_uri=${ee}`)}else l.status=403,l.body="Forbidden"}}return async(l,U)=>{switch(l.request.path){case k:await Wo(l);break;case Be:await Io(l);break;case K:await No(l);break;default:await Mo(l,U)}}}var co=x(V());var uc={get:co.default};function dc(e){let t={};return Object.keys(e).forEach(r=>{r.startsWith("cf")||(t[r]=e[r])}),t}function or(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:dc(n.request.headers),method:n.request.method,redirect:"manual"};if(N.methodsMethodsWithBody.indexOf(n.request.method)!==-1&&uc.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=b.instanceToJson(s.headers);Object.keys(i).forEach(c=>{n.set(c,i[c])})}}function ar({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=b.resolveParams(e,n.params),n.status=r,Object.keys(t).forEach(o=>{n.set(o,b.resolveParams(t[o],n.params))})}}var uo=x(V()),po=x(ot()),sr={get:uo.default,set:po.default};function ir({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=sr.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),p=Math.trunc(c*60+60-Date.now()/1e3),d=o(c,s.request.headers),u=sr.get(n,d,0);if(["HEAD","OPTIONS"].indexOf(s.request.method)===-1&&(u+=1),sr.set(n,d,u),r<u){s.status=429;return}a(c),await i(s)}}var fo=x(Qe());function pc(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 cr({accessKeyId:e,secretAccessKey:t,bucket:r,region:n,endpoint:o,forcePathStyle:a,enableBucketOperations:s=!1}){let i=new fo.AwsClient({accessKeyId:e,region:n,secretAccessKey:t}),c=pc(o,{region:n,bucket:r,forcePathStyle:a});return async p=>{if(p.params.file===void 0&&!s){p.status=404,p.body=N.http.statusMessages[404],p.set("Content-Type","text/plain");return}let d=p.params.file?b.resolveParams(`${c}/{file}`,p.params):c,u={};p.request.headers.range&&(u.range=p.request.headers.range);let f=await i.fetch(d,{method:p.method||p.request.method,headers:u});p.status=f.status,p.body=f.body;let h=b.instanceToJson(f.headers);Object.keys(h).forEach(y=>{p.set(y,h[y])})}}var ur;function ho(e){return new Uint8Array(e.split("").map(r=>r.charCodeAt(0)))}async function fc(e){return ur||(ur=await crypto.subtle.importKey("raw",ho(e),{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign","verify"])),ur}async function hc(e,t){let r=await fc(t),n=await crypto.subtle.sign({name:"HMAC"},r,ho(e));return btoa(String.fromCharCode.apply(null,new Uint8Array(n))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function dr({secret:e}){return async(t,r)=>{let n=(t.request.path+t.request.search).replace(/([?|&]sign=[\w|-]+)/,"");if(await hc(n,e)!==t.query.sign){t.status=403;return}await r(t)}}function pr({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 lc(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 p=a.decode(c),d=lo(p,r),u=s.encode(d);await o.write(u)}await o.close()}function mc(e,t){return e.replace(/{{\$(\d)}}/g,(r,n)=>t[parseInt(n,10)])}function lo(e,t){return t.reduce((r,n)=>r.replace(n.regex,(...o)=>mc(n.replace,o)),e)}function fr({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=lo(a,r);else{let{readable:s,writable:i}=new TransformStream;lc(a,i,r),n.body=s}}}async function yc({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 gc=e=>(e=e.split("?")[0],e.replace(/\W/g,"").slice(0,100));function hr({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=gc(o.request.path);if((await yc({projectID:e,API_KEY:t,token:s,siteKey:r,expectedAction:i})||0)<.5){o.status=409;return}await a(o)}}async function wc({secret:e,token:t,expectedAction:r,remoteip:n}){if(!t)return{ok:!1,score:0,errorCodes:["missing-input-response"]};let o=new URLSearchParams({secret:e,response:t,...n?{remoteip:n}:{}}),s=await(await fetch("https://www.google.com/recaptcha/api/siteverify",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:o})).json(),i=!!s.success,c=s.action===r,p=typeof s.score=="number"?s.score:0;return{ok:i&&c,score:p,action:s.action,errorCodes:s["error-codes"]}}var Ac=e=>{let t=e;try{t=new URL(e,"http://dummy").pathname}catch{}return t=t.split("?")[0]||"/",t.replace(/\W/g,"").slice(0,100)},De=(e,t)=>{if(e instanceof Headers)return e.get(t);let r=e[t]??e[t.toLowerCase()];return Array.isArray(r)?r[0]??null:r??null};function lr({secret:e,headerName:t="x-recaptcha-token",minScore:r=.5,requireActionMatch:n=!0}){return async(o,a)=>{let s=o.request?.req||o.request||o,i=s.headers??o.request?.headers??{},c=De(i,t)||De(i,"g-recaptcha-token")||null,d=De(i,"x-recaptcha-action")||Ac(o.request?.path||o.request?.url||s.url||"/"),u=De(i,"cf-connecting-ip")||De(i,"x-forwarded-for")||void 0,f=await wc({secret:e,token:c,expectedAction:d,remoteip:u});if(!(f.score>=r&&f.ok)){let y={action:f.action,expectedAction:d,score:f.score??0,errors:f.errorCodes??[]};console.warn("[reCAPTCHA] failed:"+JSON.stringify(y)),o.status=409,o.set?.("Content-Type","application/json"),o.body=JSON.stringify({error:"reCAPTCHA verification failed"});return}await a(o)}}var Sc=e=>!new RegExp("(\b)(onS+)(s*)=|javascript|<(|/|[^/>][^>]+|/[^>][^>]+)>").test(e),Ec=(e,t,r)=>!(!Sc(t)||!r[e](t)),bc=e=>!(e===null||typeof e!="object"||Array.isArray(e)&&(!e[0]||typeof e[0]!="object")),mr=(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]=""),bc(e[n])){if(!mr(e[n],t))return console.error("error validating key+validateObject:",n),!1}else if(!Ec(n,e[n],t))return console.error("error validating key+validateKeyValue:",n),!1}return!0},vc=e=>!(e==null||typeof e!="object"),Cc=(e,t)=>{let r=e.query;return vc(r)?mr(r,t):!1};async function _c(e){if(["POST","PATCH","PUT","DELETE"].indexOf(e.method)===-1)return{};try{let t=await e.text();return JSON.parse(t)}catch{}return{}}function yr({allowedKeys:e}){return async(r,n)=>{if(!e)return r.status=501,!1;if(!Cc(r,e))return r.status=422,!1;let o=await _c(r.request);if(!mr(o,e))return r.status=422,!1;await n(r)}}var xo=x(V());var P=crypto,G=e=>e instanceof CryptoKey;var M=new TextEncoder,q=new TextDecoder,Xd=2**32;function se(...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 mo=e=>{let t=e;typeof t=="string"&&(t=M.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(""))},F=e=>mo(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_");var Ce=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 E=class extends Ce{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}static get code(){return"ERR_JOSE_NOT_SUPPORTED"}};var L=class extends Ce{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}static get code(){return"ERR_JWS_INVALID"}},ie=class extends Ce{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}static get code(){return"ERR_JWT_INVALID"}};var dt=P.getRandomValues.bind(P);function ne(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function pt(e,t){return e.name===t}function gr(e){return parseInt(e.name.slice(4),10)}function Hc(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function Kc(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 go(e,t,...r){switch(t){case"HS256":case"HS384":case"HS512":{if(!pt(e.algorithm,"HMAC"))throw ne("HMAC");let n=parseInt(t.slice(2),10);if(gr(e.algorithm.hash)!==n)throw ne(`SHA-${n}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!pt(e.algorithm,"RSASSA-PKCS1-v1_5"))throw ne("RSASSA-PKCS1-v1_5");let n=parseInt(t.slice(2),10);if(gr(e.algorithm.hash)!==n)throw ne(`SHA-${n}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!pt(e.algorithm,"RSA-PSS"))throw ne("RSA-PSS");let n=parseInt(t.slice(2),10);if(gr(e.algorithm.hash)!==n)throw ne(`SHA-${n}`,"algorithm.hash");break}case"EdDSA":{if(e.algorithm.name!=="Ed25519"&&e.algorithm.name!=="Ed448")throw ne("Ed25519 or Ed448");break}case"ES256":case"ES384":case"ES512":{if(!pt(e.algorithm,"ECDSA"))throw ne("ECDSA");let n=Hc(t);if(e.algorithm.namedCurve!==n)throw ne(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}Kc(e,r)}function wo(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 z=(e,...t)=>wo("Key must be ",e,...t);function wr(e,t,...r){return wo(`Key for the ${e} algorithm must be `,t,...r)}var Ar=e=>G(e),T=["CryptoKey"];var Ic=(...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},_e=Ic;function Wc(e){return typeof e=="object"&&e!==null}function D(e){if(!Wc(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 ft=(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 ue=(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])||ue(e,t,n+1)},So=e=>{switch(!0){case ue(e,[42,134,72,206,61,3,1,7]):return"P-256";case ue(e,[43,129,4,0,34]):return"P-384";case ue(e,[43,129,4,0,35]):return"P-521";case ue(e,[43,101,110]):return"X25519";case ue(e,[43,101,111]):return"X448";case ue(e,[43,101,112]):return"Ed25519";case ue(e,[43,101,113]):return"Ed448";default:throw new E("Invalid or unsupported EC Key Curve or OKP Key Sub Type")}},Dc=async(e,t,r,n,o)=>{let a,s,i=new Uint8Array(atob(r.replace(e,"")).split("").map(p=>p.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 p=So(i);a=p.startsWith("P-")?{name:"ECDH",namedCurve:p}:{name:p},s=c?[]:["deriveBits"];break}case"EdDSA":a={name:So(i)},s=c?["verify"]:["sign"];break;default:throw new E('Invalid or unsupported "alg" (Algorithm) value')}return P.subtle.importKey(t,i,a,o?.extractable??!1,s)},Eo=(e,t,r)=>Dc(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g,"pkcs8",e,t,r);async function Sr(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 kc=(e,t)=>{if(!(t instanceof Uint8Array)){if(!Ar(t))throw new TypeError(wr(e,t,...T,"Uint8Array"));if(t.type!=="secret")throw new TypeError(`${T.join(" or ")} instances for symmetric algorithms must be of type "secret"`)}},$c=(e,t,r)=>{if(!Ar(t))throw new TypeError(wr(e,t,...T));if(t.type==="secret")throw new TypeError(`${T.join(" or ")} instances for asymmetric algorithms must not be of type "secret"`);if(r==="sign"&&t.type==="public")throw new TypeError(`${T.join(" or ")} instances for asymmetric algorithm signing must be of type "private"`);if(r==="decrypt"&&t.type==="public")throw new TypeError(`${T.join(" or ")} instances for asymmetric algorithm decryption must be of type "private"`);if(t.algorithm&&r==="verify"&&t.type==="private")throw new TypeError(`${T.join(" or ")} instances for asymmetric algorithm verifying must be of type "public"`);if(t.algorithm&&r==="encrypt"&&t.type==="private")throw new TypeError(`${T.join(" or ")} instances for asymmetric algorithm encryption must be of type "public"`)},qc=(e,t,r)=>{e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?kc(e,t):$c(e,t,r)},qe=qc;function jc(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 E(`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 Pe=jc;var eu=Symbol();function ht(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 E(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}function lt(e,t,r){if(G(t))return go(t,e,r),t;if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw new TypeError(z(t,...T));return P.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[r])}throw new TypeError(z(t,...T,"Uint8Array"))}var de=e=>Math.floor(e.getTime()/1e3);var ru=/^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i,mt=e=>{let t=ru.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 su=async(e,t,r)=>{let n=await lt(e,t,"sign");ft(e,n);let o=await P.subtle.sign(ht(e,n.algorithm),n,r);return new Uint8Array(o)},To=su;var Te=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 L("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!_e(this._protectedHeader,this._unprotectedHeader))throw new L("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let n={...this._protectedHeader,...this._unprotectedHeader},o=Pe(L,new Map([["b64",!0]]),r?.crit,this._protectedHeader,n),a=!0;if(o.has("b64")&&(a=this._protectedHeader.b64,typeof a!="boolean"))throw new L('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:s}=n;if(typeof s!="string"||!s)throw new L('JWS "alg" (Algorithm) Header Parameter missing or invalid');qe(s,t,"sign");let i=this._payload;a&&(i=M.encode(F(i)));let c;this._protectedHeader?c=M.encode(F(JSON.stringify(this._protectedHeader))):c=M.encode("");let p=se(c,M.encode("."),i),d=await To(s,t,p),u={signature:F(d),payload:""};return a&&(u.payload=q.decode(i)),this._unprotectedHeader&&(u.header=this._unprotectedHeader),this._protectedHeader&&(u.protected=q.decode(c)),u}};var Fe=class{constructor(t){this._flattened=new Te(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 He(e,t){if(!Number.isFinite(t))throw new TypeError(`Invalid ${e} input`);return t}var Ke=class{constructor(t={}){if(!D(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:He("setNotBefore",t)}:t instanceof Date?this._payload={...this._payload,nbf:He("setNotBefore",de(t))}:this._payload={...this._payload,nbf:de(new Date)+mt(t)},this}setExpirationTime(t){return typeof t=="number"?this._payload={...this._payload,exp:He("setExpirationTime",t)}:t instanceof Date?this._payload={...this._payload,exp:He("setExpirationTime",de(t))}:this._payload={...this._payload,exp:de(new Date)+mt(t)},this}setIssuedAt(t){return typeof t>"u"?this._payload={...this._payload,iat:de(new Date)}:t instanceof Date?this._payload={...this._payload,iat:He("setIssuedAt",de(t))}:this._payload={...this._payload,iat:He("setIssuedAt",t)},this}};var Le=class extends Ke{setProtectedHeader(t){return this._protectedHeader=t,this}async sign(t,r){let n=new Fe(M.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 ie("JWTs MUST NOT use unencoded payload");return n.sign(t,r)}};var du;(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))&&(du="jose/v5.1.0");var Ho=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 p=s?i.toLowerCase():i,d=a[i];c[p]=p in c&&typeof d=="object"?r(c[p],d,p=="headers"):d}return c}function n(o,a,s,i,c){var p=typeof o!="string"?(a=o).url:o,d={config:a},u=r(t,a),f={};i=i||u.data,(u.transformRequest||[]).map(function(h){i=h(i,u.headers)||i}),u.auth&&(f.authorization=u.auth),i&&typeof i=="object"&&typeof i.append!="function"&&typeof i.text!="function"&&(i=JSON.stringify(i),f["content-type"]="application/json");try{f[u.xsrfHeaderName]=decodeURIComponent(document.cookie.match(RegExp("(^|; )"+u.xsrfCookieName+"=([^;]*)"))[2])}catch{}return u.baseURL&&(p=p.replace(/^(?!.*\/\/)\/?/,u.baseURL+"/")),u.params&&(p+=(~p.indexOf("?")?"&":"?")+(u.paramsSerializer?u.paramsSerializer(u.params):new URLSearchParams(u.params))),(u.fetch||fetch)(p,{method:(s||u.method||"get").toUpperCase(),body:i,headers:r(u.headers,f,!0),credentials:u.withCredentials?"include":c}).then(function(h){for(var y in h)typeof h[y]!="function"&&(d[y]=h[y]);return u.responseType=="stream"?(d.data=h.body,d):h[u.responseType||"text"]().then(function(w){d.data=w,d.data=JSON.parse(w)}).catch(Object).then(function(){return(u.validateStatus?u.validateStatus(h.status):h.ok)?d:Promise.reject(d)})})}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 hu=e=>{if(!e)return!1;let t=JSON.parse(atob(e.split(".")[1])),r=Math.floor(Date.now()/1e3);return t.exp>r-600},yt=async(e,t)=>{let r=await GCP_INVOKER_TOKEN.get(t);if(hu(r))return r;let n=await Sr(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 Le(a).setProtectedHeader({alg:"RS256",typ:"JWT"}).sign(n),i=await Ho.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 Ko={get:xo.default};function br({project_id:e,region:t,functionName:r,serviceAccount:n}){return async o=>{let a=Ko.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 p=await yt(n,i);o.request.headers["X-Serverless-Authorization"]=`Bearer ${p}`;let d={headers:o.request.headers,method:o.request.method,redirect:"manual"};if(N.methodsMethodsWithBody.indexOf(o.request.method)!==-1&&Ko.get(o,"event.request.body")){let h=o.event.request.clone();d.body=h.body}let u=await fetch(c,d);o.body=u.body,o.status=u.status;let f=b.instanceToJson(u.headers);Object.keys(f).forEach(h=>{o.set(h,f[h])})}}var Oo=x(V());var lu={get:Oo.default};function vr({domain:e,serviceAccount:t}){return async r=>{let n=b.CTXHelper(r),o=`${e}${n.request.path}`,a=await yt(t,e),s=new Headers(n.request.headers);s.set("X-Serverless-Authorization",`Bearer ${a}`),s.set("X-Token",s.get("authorization")||"N/A"),s.set("authorization","");let i=n.event.cf||{},c={"X-Geo-Country":i.country,"X-Geo-City":i.city,"X-Geo-Latitude":i.latitude,"X-Geo-Longitude":i.longitude,"X-Geo-Timezone":i.timezone,"X-Geo-Region":i.region,"X-Geo-PostalCode":i.postalCode,"X-Geo-RegionCode":i.regionCode,"X-Geo-EU-Country":i.isEUCountry?"1":"0"};for(let[f,h]of Object.entries(c))h!==void 0&&s.set(f,h);let p={method:n.request.method,headers:s,redirect:"manual"};if(N.methodsMethodsWithBody.includes(n.request.method)&&lu.get(n,"event.request.body")){let f=n.event.request.clone();p.body=f.body}let d=await fetch(o,p),u=b.instanceToJson(d.headers);n.status=d.status,n.body=await d.text(),console.log("**************11"+JSON.stringify(n.response.headers)),Object.entries(u).forEach(([f,h])=>{let y=n.header(f);y||(console.log("-----"+JSON.stringify({existing:y,key:f,value:h})),n.set(f,h))}),console.log("**************22"+JSON.stringify(n.response.headers))}}function Cr({headers:e={},headersFN:t}){return async(r,n)=>{if(e)for(let o of Object.keys(e))r.set(o,e[o]);if(t){let o=await t();for(let a of Object.keys(o))r.set(a,o[a])}await n(r)}}var Ro={basicAuth:xt,cache:It,cors:Wt,geoDecorator:Jt,jwt:Nt,kvStorage:Mt,kvStorageBinding:kt,lambda:$t,loadbalancer:Gt,logger:zt,oauth2:nr,origin:or,rateLimit:ir,response:ar,s3:cr,signature:dr,split:pr,transform:fr,recaptcha:hr,recaptchaV3:lr,userInputValidation:yr,cloudfunction:br,gcpCloudrun:vr,headers:Cr};module.exports=class{constructor(t=[],r={}){this.router=new Uo.default,t.forEach(n=>{let o=r[n.handlerName]||Ro[n.handlerName];if(!o)throw new Error(`Handler ${n.handlerName} is not supported`);this.router.add(n,o(n.options))})}async resolve(t){return t.cf=t?.request?.cf||{},this.router.resolve(t)}};
|
|
5
|
+
`)}async hexBodyHash(){let f=this.headers.get("X-Amz-Content-Sha256");if(f==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");f=c(await i(this.body||""))}return f}}async function s(u,f){let h=await crypto.subtle.importKey("raw",typeof u=="string"?t.encode(u):u,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return crypto.subtle.sign("HMAC",h,t.encode(f))}async function i(u){return crypto.subtle.digest("SHA-256",typeof u=="string"?t.encode(u):u)}function c(u){return Array.prototype.map.call(new Uint8Array(u),f=>("0"+f.toString(16)).slice(-2)).join("")}function d(u){return u.replace(/[!'()*]/g,f=>"%"+f.charCodeAt(0).toString(16).toUpperCase())}function p(u,f){let{hostname:h,pathname:y}=u,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 C=(f.get("X-Amz-Target")||"").split(".")[0];C==="AnyScaleFrontendService"?m="application-autoscaling":C==="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 ot=S((zu,vn)=>{var Ss="Expected a function",mn="__lodash_hash_undefined__",yn=1/0,Es=9007199254740991,bs="[object Function]",vs="[object GeneratorFunction]",_s="[object Symbol]",Cs=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ps=/^\w*$/,Ts=/^\./,Hs=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ks=/[\\^$.*+?()[\]{}|]/g,Os=/\\(\\)?/g,xs=/^\[object .+?Constructor\]$/,Rs=/^(?:0|[1-9]\d*)$/,Us=typeof global=="object"&&global&&global.Object===Object&&global,Is=typeof self=="object"&&self&&self.Object===Object&&self,qt=Us||Is||Function("return this")();function Ws(e,t){return e?.[t]}function Js(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var Ns=Array.prototype,Ms=Function.prototype,gn=Object.prototype,$t=qt["__core-js_shared__"],pn=function(){var e=/[^.]+$/.exec($t&&$t.keys&&$t.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),wn=Ms.toString,tt=gn.hasOwnProperty,An=gn.toString,Ds=RegExp("^"+wn.call(tt).replace(Ks,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),fn=qt.Symbol,ks=Ns.splice,$s=Sn(qt,"Map"),Ue=Sn(Object,"create"),hn=fn?fn.prototype:void 0,ln=hn?hn.toString:void 0;function ye(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 qs(){this.__data__=Ue?Ue(null):{}}function Fs(e){return this.has(e)&&delete this.__data__[e]}function Ls(e){var t=this.__data__;if(Ue){var r=t[e];return r===mn?void 0:r}return tt.call(t,e)?t[e]:void 0}function Bs(e){var t=this.__data__;return Ue?t[e]!==void 0:tt.call(t,e)}function Gs(e,t){var r=this.__data__;return r[e]=Ue&&t===void 0?mn:t,this}ye.prototype.clear=qs;ye.prototype.delete=Fs;ye.prototype.get=Ls;ye.prototype.has=Bs;ye.prototype.set=Gs;function be(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 zs(e){var t=this.__data__,r=rt(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():ks.call(t,r,1),!0}function js(e){var t=this.__data__,r=rt(t,e);return r<0?void 0:t[r][1]}function Xs(e){return rt(this.__data__,e)>-1}function Ys(e,t){var r=this.__data__,n=rt(r,e);return n<0?r.push([e,t]):r[n][1]=t,this}be.prototype.clear=Vs;be.prototype.delete=zs;be.prototype.get=js;be.prototype.has=Xs;be.prototype.set=Ys;function ge(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 Zs(){this.__data__={hash:new ye,map:new($s||be),string:new ye}}function Qs(e){return nt(this,e).delete(e)}function ei(e){return nt(this,e).get(e)}function ti(e){return nt(this,e).has(e)}function ri(e,t){return nt(this,e).set(e,t),this}ge.prototype.clear=Zs;ge.prototype.delete=Qs;ge.prototype.get=ei;ge.prototype.has=ti;ge.prototype.set=ri;function ni(e,t,r){var n=e[t];(!(tt.call(e,t)&&En(n,r))||r===void 0&&!(t in e))&&(e[t]=r)}function rt(e,t){for(var r=e.length;r--;)if(En(e[r][0],t))return r;return-1}function oi(e){if(!et(e)||pi(e))return!1;var t=mi(e)||Js(e)?Ds:xs;return t.test(li(e))}function ai(e,t,r,n){if(!et(e))return e;t=ui(t,e)?[t]:ii(t);for(var o=-1,a=t.length,s=a-1,i=e;i!=null&&++o<a;){var c=hi(t[o]),d=r;if(o!=s){var p=i[c];d=n?n(p,c,i):void 0,d===void 0&&(d=et(p)?p:ci(t[o+1])?[]:{})}ni(i,c,d),i=i[c]}return e}function si(e){if(typeof e=="string")return e;if(Lt(e))return ln?ln.call(e):"";var t=e+"";return t=="0"&&1/e==-yn?"-0":t}function ii(e){return bn(e)?e:fi(e)}function nt(e,t){var r=e.__data__;return di(t)?r[typeof t=="string"?"string":"hash"]:r.map}function Sn(e,t){var r=Ws(e,t);return oi(r)?r:void 0}function ci(e,t){return t=t??Es,!!t&&(typeof e=="number"||Rs.test(e))&&e>-1&&e%1==0&&e<t}function ui(e,t){if(bn(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||Lt(e)?!0:Ps.test(e)||!Cs.test(e)||t!=null&&e in Object(t)}function di(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function pi(e){return!!pn&&pn in e}var fi=Ft(function(e){e=gi(e);var t=[];return Ts.test(e)&&t.push(""),e.replace(Hs,function(r,n,o,a){t.push(o?a.replace(Os,"$1"):n||r)}),t});function hi(e){if(typeof e=="string"||Lt(e))return e;var t=e+"";return t=="0"&&1/e==-yn?"-0":t}function li(e){if(e!=null){try{return wn.call(e)}catch{}try{return e+""}catch{}}return""}function Ft(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(Ss);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(Ft.Cache||ge),r}Ft.Cache=ge;function En(e,t){return e===t||e!==e&&t!==t}var bn=Array.isArray;function mi(e){var t=et(e)?An.call(e):"";return t==bs||t==vs}function et(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function yi(e){return!!e&&typeof e=="object"}function Lt(e){return typeof e=="symbol"||yi(e)&&An.call(e)==_s}function gi(e){return e==null?"":si(e)}function wi(e,t,r){return e==null?e:ai(e,t,r)}vn.exports=wi});var On=S(zt=>{"use strict";zt.parse=Pi;zt.serialize=Ti;var vi=decodeURIComponent,_i=encodeURIComponent,Ci=/; */,st=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function Pi(e,t){if(typeof e!="string")throw new TypeError("argument str must be a string");for(var r={},n=t||{},o=e.split(Ci),a=n.decode||vi,s=0;s<o.length;s++){var i=o[s],c=i.indexOf("=");if(!(c<0)){var d=i.substr(0,c).trim(),p=i.substr(++c,i.length).trim();p[0]=='"'&&(p=p.slice(1,-1)),r[d]==null&&(r[d]=Hi(p,a))}}return r}function Ti(e,t,r){var n=r||{},o=n.encode||_i;if(typeof o!="function")throw new TypeError("option encode is invalid");if(!st.test(e))throw new TypeError("argument name is invalid");var a=o(t);if(a&&!st.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(!st.test(n.domain))throw new TypeError("option domain is invalid");s+="; Domain="+n.domain}if(n.path){if(!st.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 Hi(e,t){try{return t(e)}catch{return e}}});var Rn=S((fd,xn)=>{"use strict";var it=1;function Ki(){return it=(it*9301+49297)%233280,it/233280}function Oi(e){it=e}xn.exports={nextValue:Ki,seed:Oi}});var Ne=S((hd,Jn)=>{"use strict";var jt=Rn(),Ae="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-",ae,Un,Je;function Xt(){Je=!1}function In(e){if(!e){ae!==Ae&&(ae=Ae,Xt());return}if(e!==ae){if(e.length!==Ae.length)throw new Error("Custom alphabet for shortid must be "+Ae.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 "+Ae.length+" unique characters. These characters were not unique: "+t.join(", "));ae=e,Xt()}}function xi(e){return In(e),ae}function Ri(e){jt.seed(e),Un!==e&&(Xt(),Un=e)}function Ui(){ae||In(Ae);for(var e=ae.split(""),t=[],r=jt.nextValue(),n;e.length>0;)r=jt.nextValue(),n=Math.floor(r*e.length),t.push(e.splice(n,1)[0]);return t.join("")}function Wn(){return Je||(Je=Ui(),Je)}function Ii(e){var t=Wn();return t[e]}function Wi(){return ae||Ae}Jn.exports={get:Wi,characters:xi,seed:Ri,lookup:Ii,shuffled:Wn}});var Mn=S((ld,Nn)=>{"use strict";var Yt=typeof window=="object"&&(window.crypto||window.msCrypto),Zt;!Yt||!Yt.getRandomValues?Zt=function(e){for(var t=[],r=0;r<e;r++)t.push(Math.floor(Math.random()*256));return t}:Zt=function(e){return Yt.getRandomValues(new Uint8Array(e))};Nn.exports=Zt});var kn=S((md,Dn)=>{Dn.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 qn=S((yd,$n)=>{"use strict";var Ji=Ne(),Ni=Mn(),Mi=kn();function Di(e){for(var t=0,r,n="";!r;)n=n+Mi(Ni,Ji.get(),1),r=e<Math.pow(16,t+1),t++;return n}$n.exports=Di});var Bn=S((wd,Ln)=>{"use strict";var ct=qn(),gd=Ne(),ki=1567752802062,$i=7,ut,Fn;function qi(e){var t="",r=Math.floor((Date.now()-ki)*.001);return r===Fn?ut++:(ut=0,Fn=r),t=t+ct($i),t=t+ct(e),ut>0&&(t=t+ct(ut)),t=t+ct(r),t}Ln.exports=qi});var Vn=S((Ad,Gn)=>{"use strict";var Fi=Ne();function Li(e){if(!e||typeof e!="string"||e.length<6)return!1;var t=new RegExp("[^"+Fi.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]");return!t.test(e)}Gn.exports=Li});var jn=S((Sd,zn)=>{"use strict";zn.exports=0});var Zn=S((Ed,re)=>{"use strict";var Qt=Ne(),Bi=Bn(),Gi=Vn(),Xn=jn()||0;function Vi(e){return Qt.seed(e),re.exports}function zi(e){return Xn=e,re.exports}function ji(e){return e!==void 0&&Qt.characters(e),Qt.shuffled()}function Yn(){return Bi(Xn)}re.exports=Yn;re.exports.generate=Yn;re.exports.seed=Vi;re.exports.worker=zi;re.exports.characters=ji;re.exports.isValid=Gi});var eo=S((bd,Qn)=>{"use strict";Qn.exports=Zn()});var Ro=O(qr());var rn=O(V()),es={get:rn.default};function Kt(e){e.status=401,e.body="Unauthorized",e.set("WWW-Authenticate","Basic")}function Ot(e){return async(t,r)=>{if(t.request.path===e.logoutPath)return Kt(t);let n=es.get(t,"request.headers.authorization");if(!n||!n.startsWith("Basic "))return Kt(t);let o=e.users.map(i=>i.authToken),a=n.substring(6),s=o.indexOf(a);return s===-1?Kt(t):(t.state.user=e.users[s].username,r(t))}}var nn=caches.default;async function ts(e){return await nn.match(e)}async function rs(e,t){return nn.put(e.href,t)}var xt={get:ts,set:rs};async function ns(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 on=ns;function os(e,t={}){return Object.keys(t).reduce((r,n)=>r.replace(`{${n}}`,t[n]),e)}function Rt(e){return[...e].reduce((t,r)=>{let n={};return n[r[0]]=r[1],{...t,...n}},{})}var v={resolveParams:os,instanceToJson:Rt};var as=["x-ratelimit-count","x-ratelimit-limit","x-ratelimit-reset","x-cache-hit"];async function ss(e){return["POST","PATCH","PUT","DELETE"].indexOf(e.method)===-1?null:e.text()}async function is(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 on(await ss(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 Ut({cacheDuration:e,cacheKeyTemplate:t,headerBlacklist:r=as}){return async(n,o)=>{let a=await is(n,t),s=await xt.get(a);if(s){n.body=s.body,n.status=s.status;let i=Rt(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(d=>{r.indexOf(d.toLowerCase())===-1&&c.headers.set(d,n.response.headers[d])}),e&&(c.headers.delete("Cache-Control"),c.headers.set("Cache-Control",`max-age=${e}`)),n.event.waitUntil(xt.set(a,c))}}}function It({allowedOrigins:e=["*"],allowedMethods:t=["GET","PUT","POST","PATCH","DELETE","HEAD","OPTIONS"],allowCredentials:r=!0,allowedHeaders:n=["Content-Type"],allowedExposeHeaders:o=[],maxAge:a=600,optionsSuccessStatus:s=204,terminatePreflight:i=!1}){return async(c,d)=>{let{method:p}=c.request,{origin:u}=c.request.headers,f=c.request.headers["access-control-request-headers"];if(console.log("---------------------1"+JSON.stringify(c.response.headers)),cs(c,u,e),console.log("---------------------2"+JSON.stringify(c.response.headers)),us(c,r),console.log("---------------------3"+JSON.stringify(c.response.headers)),hs(c,o),console.log("---------------------4"+JSON.stringify(c.response.headers)),p==="OPTIONS"&&(ds(c,t),ps(c,f,n),fs(c,a),i)){c.status=s,c.set("content-length","0"),c.body="";return}await d(c)}}function cs(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 us(e,t){t&&e.set("access-control-allow-credentials",t)}function ds(e,t){e.set("access-control-allow-methods",t.join(","))}function ps(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 fs(e,t){t&&e.set("access-aontrol-max-age",t)}function hs(e,t){t.length&&e.set("access-control-expose-headers",t.join(","))}var ls={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 Wt(){return async(e,t)=>{let r=e.request.headers["cf-ipcountry"]||"XX";e.request.headers["proxy-continent"]=ls[r],await t(e)}}function an(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=atob(t),n=Uint8Array.from(r,o=>o.charCodeAt(0));return new TextDecoder().decode(n)}function ms(e){let t=e.split("."),r=JSON.parse(an(t[0])),n=JSON.parse(an(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 Jt({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 p=new TextEncoder().encode([c.raw.header,c.raw.payload].join(".")),u=new Uint8Array(Array.from(c.signature).map(y=>y.charCodeAt(0))),f=await o();return(await Promise.all(f.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,u,p)}))).some(y=>y)}async function i(c,d){if(c.request.method==="OPTIONS"||n)return d(c);if((c.request.headers.authorization||"").toLowerCase().startsWith("bearer")){let u=ms(c.request.headers.authorization.slice(7)),f=new Date(u.payload.exp*1e3),h=new Date(Date.now());return f<=h||!t||u.payload.iss!==t||!r||u.payload.aud!==r||!await s(u)?a(c):(c.state.user=u.payload,d(c))}return a(c)}return i}var sn=O(V()),ys={get:sn.default},me=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=ys.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 N={methodsMethodsWithBody:["POST","PUT","PATCH"],http:{statusMessages:{404:"Not Found"}},mime:{css:"text/css",csv:"text/csv",html:"text/html",ico:"image/microsoft.vnd.icon",jpeg:"image/jpeg",js:"application/javascript",json:"application/json",png:"image/png",svg:"image/svg+xml",xml:"application/xml"}};function gs(e,t,r){if(e==="/"&&r)return r;let n=e.split("/").pop();return n.split(".").pop()!==n?e:`${e}.${t}`}function Nt({kvAccountId:e,kvNamespace:t,kvAuthEmail:r,kvAuthKey:n,kvBasePath:o="",kvKey:a="{file}",defaultExtension:s="html",defaultIndexDocument:i,defaultErrorDocument:c,mime:d={},mode:p="rest"}){let u=new me({accountId:e,namespace:t,authEmail:r,authKey:n,mode:p}),f={...N.mime,...d};return async h=>{let y=v.resolveParams(a,h.params),w=y===""&&i?i:gs(y,s),m=await u.get(o+w);!m&&c&&(m=await u.get(o+c)),m?(h.status=200,h.body=m,h.set("Content-Type",f[w.split(".").pop()]||"text/plain")):(h.status=404,h.body=N.http.statusMessages[404],h.set("Content-Type","text/plain"))}}var cn=O(V());var Mt={get:cn.default};function ws(e,t,r){if(e==="/"&&r)return r;let n=e.split("/").pop();return n.split(".").pop()!==n?e:`${e}.${t}`}function As(e,t){let r=Mt.get(e,"headers.if-none-match"),n=Mt.get(t,"metadata.headers.etag");return r?r===n:!1}function Dt({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=v.resolveParams(r,i.params),d=c===""&&o?o:ws(c,n),p=await s(t+d);if(!p&&a&&(p=await s(t+a)),p)if(As(i.request,p))i.status=304;else{i.status=p.status,i.body=p.value;let u=Mt.get(p,"metadata.headers",{});Object.keys(u).forEach(f=>{i.set(f,u[f])})}else i.status=404,i.body=N.http.statusMessages[404],i.set("Content-Type","text/plain")}}var dn=O(Qe());function kt({accessKeyId:e,secretAccessKey:t,region:r,lambdaName:n}){let o=new dn.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 d=v.instanceToJson(c.headers);Object.keys(d).forEach(p=>{a.set(p,d[p])})}}var Cn=O(V()),Pn=O(ot());var _n={get:Cn.default,set:Pn.default};function Ai(e){let t={};return Object.keys(e).forEach(r=>{r.startsWith("cf")||(t[r]=e[r])}),t}function Si(e){return e[Math.floor(Math.random()*e.length)]}function Bt({sources:e=[]}){return async t=>{let r=Si(e),n={method:t.request.method,headers:Ai(t.request.headers),redirect:"manual",cf:t.request.cf};if(N.methodsMethodsWithBody.indexOf(t.request.method)!==-1&&_n.get(t,"event.request.body")){let i=t.event.request.clone();n.body=i.body}let o=v.resolveParams(r.url,t.params);if(r.resolveOverride){let i=v.resolveParams(r.resolveOverride,t.request.params);_n.set(n,"cf.resolveOverride",i)}let a=await fetch(o+t.request.search,n);t.body=a.body,t.status=a.status;let s=v.instanceToJson(a.headers);Object.keys(s).forEach(i=>{t.set(i,s[i])})}}var Kn=O(V());var Gt={name:"@ahmadissa/cloudworker-proxy",version:"1.1.86",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:"Ahmad Issa",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",build:"^0.1.4","cloudworker-router":"^4.1.5",cookie:"0.4.1",jose:"^5.1.0","lodash.get":"4.4.2","lodash.set":"4.3.2",package:"^1.0.1",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 we=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 Tn(e,t=".",r=""){return e instanceof Object?Object.keys(e).reduce((n,o)=>e[o]==null?n:{...n,...Tn(e[o],t,r+o+t)},{}):r.endsWith(t)?{[r.slice(0,r.length-1)]:e}:{[r]:e}}var at=Tn;var Ie=class{constructor(t){this.url=t.url,this.contentType=t.contentType,this.delimiter=t.delimiter,this.chunker=new we({sink:this.sendMessage.bind(this),...t})}async log(t){let r=at(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 Hn=O(Qe());var We=class{constructor(t){this.delimiter=t.delimiter,this.chunker=new we({sink:this.sendMessage.bind(this),...t}),this.awsClient=new Hn.AwsClient({accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey,region:t.region}),this.streamName=t.streamName,this.region=t.region}async log(t){let r=at(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 $={get:Kn.default};async function bi(e){return["POST","PATCH","PUT","DELETE"].indexOf(e.method)===-1?null:e.text()}function Vt(e){let t;switch(e.type){case"http":t=new Ie(e);break;case"kinesis":t=new We(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 bi(r.request);try{await n(r);let a={message:"START",requestIp:$.get(r,"request.headers.x-real-ip"),requestId:$.get(r,"request.requestId"),request:{headers:$.get(r,"request.headers"),method:$.get(r,"request.method"),url:$.get(r,"request.href"),protocol:$.get(r,"request.protocol"),body:o},response:{status:r.status,headers:$.get(r,"response.headers")},handlers:$.get(r,"state.handlers",[]).join(","),route:$.get(r,"route.name"),timestamp:new Date().toISOString(),ttfb:new Date-r.state["logger-startDate"],redirectUrl:r.userRedirect,severity:30,proxyVersion:Gt.version};r.event.waitUntil(t.log(a))}catch(a){let s={request:{headers:$.get(r,"request.headers"),method:$.get(r,"request.method"),handlers:$.get(r,"state.handlers",[]).join(","),url:$.get(r,"request.href"),body:o},message:"ERROR",stack:a.stack,error:a.message,severity:50,proxyVersion:Gt.version};r.event.waitUntil(t.log(s))}}}var Me=O(On()),oo=O(V()),ao=O(ot()),so=O(eo());async function er({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 to="PBKDF2",tr="AES-GCM",Xi="SHA-256",Yi="raw";function Zi(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 ro(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 Qi(e){return new TextEncoder().encode(e).buffer}function ec(e){return new TextDecoder().decode(e)}async function tc(e){let t=new TextEncoder;return crypto.subtle.importKey(Yi,t.encode(e),{name:to},!1,["deriveKey"])}async function rc(e,t){let r=await tc(e),o=new TextEncoder().encode(t.replace(/_/g,"/").replace(/-/g,"+"));return crypto.subtle.deriveKey({name:to,salt:o,iterations:1e3,hash:{name:Xi}},r,{name:tr,length:256},!0,["encrypt","decrypt"])}async function nc(){let e=crypto.getRandomValues(new Uint8Array(8));return ro(e)}async function oc(e,t){let r=Zi(t),n=r.slice(0,16),o=r.slice(16),a=await crypto.subtle.decrypt({name:tr,iv:n},e,o);return ec(a)}async function ac(e,t){let r=crypto.getRandomValues(new Uint8Array(16)),n=await crypto.subtle.encrypt({name:tr,iv:r},e,Qi(t)),o=new Uint8Array(n.byteLength+r.byteLength);return o.set(r,0),o.set(new Uint8Array(n),r.byteLength),ro(o)}var Se={decrypt:oc,deriveAesGcmKey:rc,encrypt:ac,getSalt:nc};var ve={get:oo.default,set:ao.default};function no({cookieHeader:e="",cookieName:t}){return Me.default.parse(e)[t]}function sc(e){return Object.keys(e).map(t=>`${t}=${encodeURIComponent(e[t])}`).join("&")}function ic(e=""){return e.split(",").indexOf("text/html")!==-1}function rr({cookieName:e="proxy",cookieHttpOnly:t=!0,allowPublicAccess:r=!1,kvAccountId:n,kvNamespace:o,kvAuthEmail:a,kvAuthKey:s,kvTtl:i=2592e3,oauth2AuthDomain:c,oauth2ClientId:d,oauth2ClientSecret:p,oauth2Audience:u,oauth2Scopes:f=[],oauth2CallbackPath:h="/callback",oauth2CallbackType:y="cookie",oauth2LogoutPath:w="/logout",oauth2LoginPath:m="/login",oauth2ServerTokenPath:g="/oauth/token",oauth2ServerAuthorizePath:C="",oauth2ServerLogoutPath:b}){let A=new me({accountId:n,namespace:o,authEmail:a,authKey:s,ttl:i}),W=c,k=h,Z=y,j=g,x=C,_=b,H=d,Q=p,B=u,Be=w,K=m,xe=f.join("%20");async function Ge(l,U){let R=`${W}${j}`,J=await fetch(R,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:sc({code:l,grant_type:"authorization_code",client_id:H,client_secret:Q,redirect_uri:U})});if(!J.ok)throw new Error("Authentication failed");let X=await J.json();return{...X,expires:Date.now()+X.expires_in*1e3}}async function Uo(l){if(no({cookieHeader:l.request.headers.cookie,cookieName:e})){let J=l.request.hostname.match(/[^.]+\.[^.]+$/i)[0];l.set("Set-Cookie",Me.default.serialize(e,"",{domain:`.${J}`,path:"/",maxAge:0}))}let R=_r(l);if(b){let J=encodeURIComponent(`${l.request.protocol}://${l.request.host}${R}`);l.set("Location",`${W}${_}?client_id=${H}&returnTo=${J}`)}else l.set("Location",R);l.status=302}async function Io(l){let U=l.request.href.split("?")[0],R=await Ge(l.request.query.code,U),J=so.default.generate(),X=await Se.getSalt(),ee=`${J}.${X}`,gt=await Se.deriveAesGcmKey(J,X),pe=await Se.encrypt(gt,JSON.stringify(R));await A.put(J,pe);let wt=l.request.hostname.match(/[^.]+\.[^.]+$/i)[0];l.status=302,Z==="query"?l.set("Location",`${l.request.query.state}?auth=${ee}`):(l.set("Set-Cookie",Me.default.serialize(e,ee,{httpOnly:t,domain:`.${wt}`,path:"/",maxAge:60*60*24*365})),l.set("Location",l.request.query.state))}async function Wo(l,U){let[R,J]=U.split("."),X=await A.get(R);if(X){let ee=await Se.deriveAesGcmKey(R,J),gt=await Se.decrypt(ee,X),pe=JSON.parse(gt);if(pe.expires<Date.now()){pe=await er({refresh_token:pe.refresh_token,clientId:H,authDomain:W,clientSecret:Q});let wt=await Se.encrypt(ee,JSON.stringify(pe));await A.put(R,wt)}l.state.accessToken=pe.access_token,l.state.accessToken&&(l.request.headers.authorization=`bearer ${l.state.accessToken}`)}else{let ee=l.request.hostname.match(/[^.]+\.[^.]+$/i)[0];l.set("Set-Cookie",Me.default.serialize(e,"",{domain:`.${ee}`,maxAge:0}))}}function _r(l){let U=ve.get(l,"request.query.redirect-to");if(U)return U;let R=ve.get(l,"request.headers.referer");return R||"/"}async function Jo(l){if(l.request.method==="OPTIONS")l.status=200;else{let U=_r(l),R=encodeURIComponent(U||"/"),J=encodeURIComponent(`${l.request.protocol}://${l.request.host}${k}`);l.status=302,l.set("location",`${W}${x}/authorize?state=${R}&client_id=${H}&response_type=code&scope=${xe}&audience=${B}&redirect_uri=${J}`)}}async function No(l,U){if(l.request.method==="OPTIONS")await U(l);else if(ve.get(l,"request.headers.authorization","").toLowerCase().startsWith("bearer "))ve.set(l,"state.access_token",l.request.headers.authorization.slice(7)),await U(l);else{let R=ve.get(l,"request.query.auth")||no({cookieHeader:l.request.headers.cookie,cookieName:e});if(R&&await Wo(l,R),ve.get(l,"state.accessToken")||r)await U(l);else if(ic(l.request.headers.accept)){let X=encodeURIComponent(l.request.href),ee=encodeURIComponent(`${l.request.protocol}://${l.request.host}${k}`);l.status=302,l.set("location",`${W}${x}/authorize?state=${X}&client_id=${H}&response_type=code&scope=${xe}&audience=${B}&redirect_uri=${ee}`)}else l.status=403,l.body="Forbidden"}}return async(l,U)=>{switch(l.request.path){case k:await Io(l);break;case Be:await Uo(l);break;case K:await Jo(l);break;default:await No(l,U)}}}var io=O(V());var cc={get:io.default};function uc(e){let t={};return Object.keys(e).forEach(r=>{r.startsWith("cf")||(t[r]=e[r])}),t}function nr(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:uc(n.request.headers),method:n.request.method,redirect:"manual"};if(N.methodsMethodsWithBody.indexOf(n.request.method)!==-1&&cc.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=v.instanceToJson(s.headers);Object.keys(i).forEach(c=>{n.set(c,i[c])})}}function or({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=v.resolveParams(e,n.params),n.status=r,Object.keys(t).forEach(o=>{n.set(o,v.resolveParams(t[o],n.params))})}}var co=O(V()),uo=O(ot()),ar={get:co.default,set:uo.default};function sr({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=ar.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),d=Math.trunc(c*60+60-Date.now()/1e3),p=o(c,s.request.headers),u=ar.get(n,p,0);if(["HEAD","OPTIONS"].indexOf(s.request.method)===-1&&(u+=1),ar.set(n,p,u),r<u){s.status=429;return}a(c),await i(s)}}var po=O(Qe());function dc(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 ir({accessKeyId:e,secretAccessKey:t,bucket:r,region:n,endpoint:o,forcePathStyle:a,enableBucketOperations:s=!1}){let i=new po.AwsClient({accessKeyId:e,region:n,secretAccessKey:t}),c=dc(o,{region:n,bucket:r,forcePathStyle:a});return async d=>{if(d.params.file===void 0&&!s){d.status=404,d.body=N.http.statusMessages[404],d.set("Content-Type","text/plain");return}let p=d.params.file?v.resolveParams(`${c}/{file}`,d.params):c,u={};d.request.headers.range&&(u.range=d.request.headers.range);let f=await i.fetch(p,{method:d.method||d.request.method,headers:u});d.status=f.status,d.body=f.body;let h=v.instanceToJson(f.headers);Object.keys(h).forEach(y=>{d.set(y,h[y])})}}var cr;function fo(e){return new Uint8Array(e.split("").map(r=>r.charCodeAt(0)))}async function pc(e){return cr||(cr=await crypto.subtle.importKey("raw",fo(e),{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign","verify"])),cr}async function fc(e,t){let r=await pc(t),n=await crypto.subtle.sign({name:"HMAC"},r,fo(e));return btoa(String.fromCharCode.apply(null,new Uint8Array(n))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function ur({secret:e}){return async(t,r)=>{let n=(t.request.path+t.request.search).replace(/([?|&]sign=[\w|-]+)/,"");if(await fc(n,e)!==t.query.sign){t.status=403;return}await r(t)}}function dr({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 hc(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 d=a.decode(c),p=ho(d,r),u=s.encode(p);await o.write(u)}await o.close()}function lc(e,t){return e.replace(/{{\$(\d)}}/g,(r,n)=>t[parseInt(n,10)])}function ho(e,t){return t.reduce((r,n)=>r.replace(n.regex,(...o)=>lc(n.replace,o)),e)}function pr({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=ho(a,r);else{let{readable:s,writable:i}=new TransformStream;hc(a,i,r),n.body=s}}}async function mc({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 yc=e=>(e=e.split("?")[0],e.replace(/\W/g,"").slice(0,100));function fr({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=yc(o.request.path);if((await mc({projectID:e,API_KEY:t,token:s,siteKey:r,expectedAction:i})||0)<.5){o.status=409;return}await a(o)}}async function gc({secret:e,token:t,expectedAction:r,remoteip:n}){if(!t)return{ok:!1,score:0,errorCodes:["missing-input-response"]};let o=new URLSearchParams({secret:e,response:t,...n?{remoteip:n}:{}}),s=await(await fetch("https://www.google.com/recaptcha/api/siteverify",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:o})).json(),i=!!s.success,c=s.action===r,d=typeof s.score=="number"?s.score:0;return{ok:i&&c,score:d,action:s.action,errorCodes:s["error-codes"]}}var wc=e=>{let t=e;try{t=new URL(e,"http://dummy").pathname}catch{}return t=t.split("?")[0]||"/",t.replace(/\W/g,"").slice(0,100)},De=(e,t)=>{if(e instanceof Headers)return e.get(t);let r=e[t]??e[t.toLowerCase()];return Array.isArray(r)?r[0]??null:r??null};function hr({secret:e,headerName:t="x-recaptcha-token",minScore:r=.5,requireActionMatch:n=!0}){return async(o,a)=>{let s=o.request?.req||o.request||o,i=s.headers??o.request?.headers??{},c=De(i,t)||De(i,"g-recaptcha-token")||null,p=De(i,"x-recaptcha-action")||wc(o.request?.path||o.request?.url||s.url||"/"),u=De(i,"cf-connecting-ip")||De(i,"x-forwarded-for")||void 0,f=await gc({secret:e,token:c,expectedAction:p,remoteip:u});if(!(f.score>=r&&f.ok)){let y={action:f.action,expectedAction:p,score:f.score??0,errors:f.errorCodes??[]};console.warn("[reCAPTCHA] failed:"+JSON.stringify(y)),o.status=409,o.set?.("Content-Type","application/json"),o.body=JSON.stringify({error:"reCAPTCHA verification failed"});return}await a(o)}}var Ac=e=>!new RegExp("(\b)(onS+)(s*)=|javascript|<(|/|[^/>][^>]+|/[^>][^>]+)>").test(e),Sc=(e,t,r)=>!(!Ac(t)||!r[e](t)),Ec=e=>!(e===null||typeof e!="object"||Array.isArray(e)&&(!e[0]||typeof e[0]!="object")),lr=(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]=""),Ec(e[n])){if(!lr(e[n],t))return console.error("error validating key+validateObject:",n),!1}else if(!Sc(n,e[n],t))return console.error("error validating key+validateKeyValue:",n),!1}return!0},bc=e=>!(e==null||typeof e!="object"),vc=(e,t)=>{let r=e.query;return bc(r)?lr(r,t):!1};async function _c(e){if(["POST","PATCH","PUT","DELETE"].indexOf(e.method)===-1)return{};try{let t=await e.text();return JSON.parse(t)}catch{}return{}}function mr({allowedKeys:e}){return async(r,n)=>{if(!e)return r.status=501,!1;if(!vc(r,e))return r.status=422,!1;let o=await _c(r.request);if(!lr(o,e))return r.status=422,!1;await n(r)}}var Ko=O(V());var P=crypto,G=e=>e instanceof CryptoKey;var M=new TextEncoder,q=new TextDecoder,zd=2**32;function se(...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 lo=e=>{let t=e;typeof t=="string"&&(t=M.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(""))},F=e=>lo(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_");var _e=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 E=class extends _e{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}static get code(){return"ERR_JOSE_NOT_SUPPORTED"}};var L=class extends _e{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}static get code(){return"ERR_JWS_INVALID"}},ie=class extends _e{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}static get code(){return"ERR_JWT_INVALID"}};var dt=P.getRandomValues.bind(P);function ne(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function pt(e,t){return e.name===t}function yr(e){return parseInt(e.name.slice(4),10)}function Tc(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function Hc(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 yo(e,t,...r){switch(t){case"HS256":case"HS384":case"HS512":{if(!pt(e.algorithm,"HMAC"))throw ne("HMAC");let n=parseInt(t.slice(2),10);if(yr(e.algorithm.hash)!==n)throw ne(`SHA-${n}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!pt(e.algorithm,"RSASSA-PKCS1-v1_5"))throw ne("RSASSA-PKCS1-v1_5");let n=parseInt(t.slice(2),10);if(yr(e.algorithm.hash)!==n)throw ne(`SHA-${n}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!pt(e.algorithm,"RSA-PSS"))throw ne("RSA-PSS");let n=parseInt(t.slice(2),10);if(yr(e.algorithm.hash)!==n)throw ne(`SHA-${n}`,"algorithm.hash");break}case"EdDSA":{if(e.algorithm.name!=="Ed25519"&&e.algorithm.name!=="Ed448")throw ne("Ed25519 or Ed448");break}case"ES256":case"ES384":case"ES512":{if(!pt(e.algorithm,"ECDSA"))throw ne("ECDSA");let n=Tc(t);if(e.algorithm.namedCurve!==n)throw ne(n,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}Hc(e,r)}function go(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 z=(e,...t)=>go("Key must be ",e,...t);function gr(e,t,...r){return go(`Key for the ${e} algorithm must be `,t,...r)}var wr=e=>G(e),T=["CryptoKey"];var Uc=(...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},Ce=Uc;function Ic(e){return typeof e=="object"&&e!==null}function D(e){if(!Ic(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 ft=(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 ue=(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])||ue(e,t,n+1)},Ao=e=>{switch(!0){case ue(e,[42,134,72,206,61,3,1,7]):return"P-256";case ue(e,[43,129,4,0,34]):return"P-384";case ue(e,[43,129,4,0,35]):return"P-521";case ue(e,[43,101,110]):return"X25519";case ue(e,[43,101,111]):return"X448";case ue(e,[43,101,112]):return"Ed25519";case ue(e,[43,101,113]):return"Ed448";default:throw new E("Invalid or unsupported EC Key Curve or OKP Key Sub Type")}},Mc=async(e,t,r,n,o)=>{let a,s,i=new Uint8Array(atob(r.replace(e,"")).split("").map(d=>d.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 d=Ao(i);a=d.startsWith("P-")?{name:"ECDH",namedCurve:d}:{name:d},s=c?[]:["deriveBits"];break}case"EdDSA":a={name:Ao(i)},s=c?["verify"]:["sign"];break;default:throw new E('Invalid or unsupported "alg" (Algorithm) value')}return P.subtle.importKey(t,i,a,o?.extractable??!1,s)},So=(e,t,r)=>Mc(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g,"pkcs8",e,t,r);async function Ar(e,t,r){if(typeof e!="string"||e.indexOf("-----BEGIN PRIVATE KEY-----")!==0)throw new TypeError('"pkcs8" must be PKCS#8 formatted string');return So(e,t,r)}var Dc=(e,t)=>{if(!(t instanceof Uint8Array)){if(!wr(t))throw new TypeError(gr(e,t,...T,"Uint8Array"));if(t.type!=="secret")throw new TypeError(`${T.join(" or ")} instances for symmetric algorithms must be of type "secret"`)}},kc=(e,t,r)=>{if(!wr(t))throw new TypeError(gr(e,t,...T));if(t.type==="secret")throw new TypeError(`${T.join(" or ")} instances for asymmetric algorithms must not be of type "secret"`);if(r==="sign"&&t.type==="public")throw new TypeError(`${T.join(" or ")} instances for asymmetric algorithm signing must be of type "private"`);if(r==="decrypt"&&t.type==="public")throw new TypeError(`${T.join(" or ")} instances for asymmetric algorithm decryption must be of type "private"`);if(t.algorithm&&r==="verify"&&t.type==="private")throw new TypeError(`${T.join(" or ")} instances for asymmetric algorithm verifying must be of type "public"`);if(t.algorithm&&r==="encrypt"&&t.type==="private")throw new TypeError(`${T.join(" or ")} instances for asymmetric algorithm encryption must be of type "public"`)},$c=(e,t,r)=>{e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?Dc(e,t):kc(e,t,r)},qe=$c;function zc(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 E(`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 Pe=zc;var Qc=Symbol();function ht(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 E(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}function lt(e,t,r){if(G(t))return yo(t,e,r),t;if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw new TypeError(z(t,...T));return P.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[r])}throw new TypeError(z(t,...T,"Uint8Array"))}var de=e=>Math.floor(e.getTime()/1e3);var tu=/^(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)$/i,mt=e=>{let t=tu.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 au=async(e,t,r)=>{let n=await lt(e,t,"sign");ft(e,n);let o=await P.subtle.sign(ht(e,n.algorithm),n,r);return new Uint8Array(o)},Po=au;var Te=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 L("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!Ce(this._protectedHeader,this._unprotectedHeader))throw new L("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");let n={...this._protectedHeader,...this._unprotectedHeader},o=Pe(L,new Map([["b64",!0]]),r?.crit,this._protectedHeader,n),a=!0;if(o.has("b64")&&(a=this._protectedHeader.b64,typeof a!="boolean"))throw new L('The "b64" (base64url-encode payload) Header Parameter must be a boolean');let{alg:s}=n;if(typeof s!="string"||!s)throw new L('JWS "alg" (Algorithm) Header Parameter missing or invalid');qe(s,t,"sign");let i=this._payload;a&&(i=M.encode(F(i)));let c;this._protectedHeader?c=M.encode(F(JSON.stringify(this._protectedHeader))):c=M.encode("");let d=se(c,M.encode("."),i),p=await Po(s,t,d),u={signature:F(p),payload:""};return a&&(u.payload=q.decode(i)),this._unprotectedHeader&&(u.header=this._unprotectedHeader),this._protectedHeader&&(u.protected=q.decode(c)),u}};var Fe=class{constructor(t){this._flattened=new Te(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 He(e,t){if(!Number.isFinite(t))throw new TypeError(`Invalid ${e} input`);return t}var Ke=class{constructor(t={}){if(!D(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:He("setNotBefore",t)}:t instanceof Date?this._payload={...this._payload,nbf:He("setNotBefore",de(t))}:this._payload={...this._payload,nbf:de(new Date)+mt(t)},this}setExpirationTime(t){return typeof t=="number"?this._payload={...this._payload,exp:He("setExpirationTime",t)}:t instanceof Date?this._payload={...this._payload,exp:He("setExpirationTime",de(t))}:this._payload={...this._payload,exp:de(new Date)+mt(t)},this}setIssuedAt(t){return typeof t>"u"?this._payload={...this._payload,iat:de(new Date)}:t instanceof Date?this._payload={...this._payload,iat:He("setIssuedAt",de(t))}:this._payload={...this._payload,iat:He("setIssuedAt",t)},this}};var Le=class extends Ke{setProtectedHeader(t){return this._protectedHeader=t,this}async sign(t,r){let n=new Fe(M.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 ie("JWTs MUST NOT use unencoded payload");return n.sign(t,r)}};var uu;(typeof navigator>"u"||!navigator.userAgent?.startsWith?.("Mozilla/5.0 "))&&(uu="jose/v5.1.0");var To=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 d=s?i.toLowerCase():i,p=a[i];c[d]=d in c&&typeof p=="object"?r(c[d],p,d=="headers"):p}return c}function n(o,a,s,i,c){var d=typeof o!="string"?(a=o).url:o,p={config:a},u=r(t,a),f={};i=i||u.data,(u.transformRequest||[]).map(function(h){i=h(i,u.headers)||i}),u.auth&&(f.authorization=u.auth),i&&typeof i=="object"&&typeof i.append!="function"&&typeof i.text!="function"&&(i=JSON.stringify(i),f["content-type"]="application/json");try{f[u.xsrfHeaderName]=decodeURIComponent(document.cookie.match(RegExp("(^|; )"+u.xsrfCookieName+"=([^;]*)"))[2])}catch{}return u.baseURL&&(d=d.replace(/^(?!.*\/\/)\/?/,u.baseURL+"/")),u.params&&(d+=(~d.indexOf("?")?"&":"?")+(u.paramsSerializer?u.paramsSerializer(u.params):new URLSearchParams(u.params))),(u.fetch||fetch)(d,{method:(s||u.method||"get").toUpperCase(),body:i,headers:r(u.headers,f,!0),credentials:u.withCredentials?"include":c}).then(function(h){for(var y in h)typeof h[y]!="function"&&(p[y]=h[y]);return u.responseType=="stream"?(p.data=h.body,p):h[u.responseType||"text"]().then(function(w){p.data=w,p.data=JSON.parse(w)}).catch(Object).then(function(){return(u.validateStatus?u.validateStatus(h.status):h.ok)?p:Promise.reject(p)})})}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 fu=e=>{if(!e)return!1;let t=JSON.parse(atob(e.split(".")[1])),r=Math.floor(Date.now()/1e3);return t.exp>r-600},yt=async(e,t)=>{let r=await GCP_INVOKER_TOKEN.get(t);if(fu(r))return r;let n=await Ar(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 Le(a).setProtectedHeader({alg:"RS256",typ:"JWT"}).sign(n),i=await To.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 Ho={get:Ko.default};function Er({project_id:e,region:t,functionName:r,serviceAccount:n}){return async o=>{let a=Ho.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 d=await yt(n,i);o.request.headers["X-Serverless-Authorization"]=`Bearer ${d}`;let p={headers:o.request.headers,method:o.request.method,redirect:"manual"};if(N.methodsMethodsWithBody.indexOf(o.request.method)!==-1&&Ho.get(o,"event.request.body")){let h=o.event.request.clone();p.body=h.body}let u=await fetch(c,p);o.body=u.body,o.status=u.status;let f=v.instanceToJson(u.headers);Object.keys(f).forEach(h=>{o.set(h,f[h])})}}var Oo=O(V());var hu={get:Oo.default};function br({domain:e,serviceAccount:t}){return async r=>{let n=`${e}${r.request.path}`,o=await yt(t,e),a=new Headers(r.request.headers);a.set("X-Serverless-Authorization",`Bearer ${o}`),a.set("X-Token",a.get("authorization")||"N/A"),a.set("authorization","");let s=r.event.cf||{},i={"X-Geo-Country":s.country,"X-Geo-City":s.city,"X-Geo-Latitude":s.latitude,"X-Geo-Longitude":s.longitude,"X-Geo-Timezone":s.timezone,"X-Geo-Region":s.region,"X-Geo-PostalCode":s.postalCode,"X-Geo-RegionCode":s.regionCode,"X-Geo-EU-Country":s.isEUCountry?"1":"0"};for(let[u,f]of Object.entries(i))f!==void 0&&a.set(u,f);let c={method:r.request.method,headers:a,redirect:"manual"};if(N.methodsMethodsWithBody.includes(r.request.method)&&hu.get(r,"event.request.body")){let u=r.event.request.clone();c.body=u.body}let d=await fetch(n,c),p=v.instanceToJson(d.headers);r.status=d.status,r.body=await d.text(),console.log("**************11"+JSON.stringify(r.response.headers)),Object.entries(p).forEach(([u,f])=>{u=u.toLowerCase();let h=r.header(u);h||(console.log("-----"+JSON.stringify({existing:h,key:u,value:f})),r.set(u,f))}),console.log("**************22"+JSON.stringify(r.response.headers))}}function vr({headers:e={},headersFN:t}){return async(r,n)=>{if(e)for(let o of Object.keys(e))r.set(o,e[o]);if(t){let o=await t();for(let a of Object.keys(o))r.set(a,o[a])}await n(r)}}var xo={basicAuth:Ot,cache:Ut,cors:It,geoDecorator:Wt,jwt:Jt,kvStorage:Nt,kvStorageBinding:Dt,lambda:kt,loadbalancer:Bt,logger:Vt,oauth2:rr,origin:nr,rateLimit:sr,response:or,s3:ir,signature:ur,split:dr,transform:pr,recaptcha:fr,recaptchaV3:hr,userInputValidation:mr,cloudfunction:Er,gcpCloudrun:br,headers:vr};module.exports=class{constructor(t=[],r={}){this.router=new Ro.default,t.forEach(n=>{let o=r[n.handlerName]||xo[n.handlerName];if(!o)throw new Error(`Handler ${n.handlerName} is not supported`);this.router.add(n,o(n.options))})}async resolve(t){return t.cf=t?.request?.cf||{},this.router.resolve(t)}};
|
|
8
8
|
/*! Bundled license information:
|
|
9
9
|
|
|
10
10
|
aws4fetch/dist/aws4fetch.umd.js:
|