You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@netlify/serverless-functions-api

Package Overview
Dependencies
Maintainers
23
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@netlify/serverless-functions-api - npm Package Compare versions

Comparing version

to
1.19.1

4

dist/index.js

@@ -1,2 +0,2 @@

import { createRequire } from 'module'; const require = createRequire(import.meta.url);
import{fileURLToPath as Je}from"url";import{Buffer as He}from"node:buffer";import{version as je}from"node:process";import{pipeline as Pe,Readable as Be}from"node:stream";import{promisify as Ue}from"node:util";var _=e=>({id:e??""});var T="x-nf-client-connection-ip",H="x-nf-geo",j="x-nf-account-id",y="x-nf-deploy-id",P="x-nf-deploy-context",B="x-nf-deploy-published",U="x-nf-site-id",A="x-nf-request-flags",w="x-nf-invocation-metadata",G="x-nf-request-id",V="x-nf-function-timing",M=e=>{let t=new Headers;return Object.entries(e).forEach(([o,r])=>{r!==void 0&&t.set(o.toLowerCase(),r)}),t},J=e=>{let t={};for(let[o,r]of e.entries())o in t?t[o].push(r):t[o]=[r];return t};var W=e=>({context:e.get(P)??"",id:e.get(y)??"",published:e.get(B)==="1"});import{Buffer as xe}from"buffer";var R=Symbol("Request flags"),f=Symbol("Request route"),Re=typeof Request>"u"?class{}:Request,Y,x=class extends(Y=Re,R,f,Y){},z=(e,t)=>{if(!(e==null||e===""))return t?xe.from(e,"base64"):e};var b=class{#e;#t;constructor(t){this.#e=new Set,this.#t=t}get(t){let o=this.#t[t];return o!==void 0&&this.#e.add(t),o}get evaluations(){return this.#e}},S=e=>e[R]??new b({}),K=(e,t)=>{let{flags:o={}}=e;t[R]=new b(o)};import{Buffer as be}from"node:buffer";var X=e=>{if(e===null)return{};try{return JSON.parse(be.from(e,"base64").toString("utf-8"))}catch{return{}}};var $=e=>e??"";import{URLPattern as Se}from"urlpattern-polyfill";var Q=(e,t)=>{var c;if(e===void 0)return{};let o=t.endsWith("/")?t.slice(0,-1):t,n=(c=new Se({pathname:e,baseURL:o}).exec(o))==null?void 0:c.pathname.groups;return n?Object.entries(n).reduce((i,[a,u])=>u===void 0?i:{...i,[a]:u},{}):{}};var Z=e=>e??"";import{env as ve}from"process";var ee=()=>({region:ve.AWS_REGION});import{env as k}from"process";var te=()=>({id:k.SITE_ID,name:k.SITE_NAME,url:k.URL});var Ne=e=>{let t=JSON.stringify(e);return new Response(t,{headers:{"content-type":"application/json"}})},oe=(e,t)=>{let o={};try{o=Q(e[f],e.url)}catch{console.log(`Could not parse function route ${e[f]}.`)}return{account:_(e.headers.get(j)),cookies:t.getPublicInterface(),deploy:W(e.headers),flags:S(e),geo:X(e.headers.get(H)),ip:$(e.headers.get(T)),json:Ne,log:console.log,next:()=>{throw new Error("`context.next` is not implemented for serverless functions")},params:o,requestId:Z(e.headers.get(G)),rewrite:n=>{let s=Fe(n,e.url);return Ce(s)},server:ee(),site:te()}},Fe=(e,t)=>{if(e instanceof URL)return e;if(e.startsWith("/")){let o=new URL(t);return o.pathname=e,o}return new URL(e)},Ce=async e=>await fetch(e);import{deleteCookie as Le,getCookies as qe,setCookie as we}from"@netlify/node-cookies";var v=class{constructor(t){this.ops=[],this.request=t}apply(t){this.ops.forEach(o=>{switch(o.type){case"delete":Le(t.headers,o.options.name,{domain:o.options.domain,path:o.options.path});break;case"set":we(t.headers,o.cookie);break;default:}})}delete(t){let o={path:"/"},r=typeof t=="string"?{name:t}:t;this.ops.push({options:{...o,...r},type:"delete"})}get(t){return qe(this.request.headers)[t]}getPublicInterface(){return{delete:this.delete.bind(this),get:this.get.bind(this),set:this.set.bind(this)}}set(t,o){let r;if(typeof t=="string"){if(typeof o!="string")throw new TypeError("You must provide the cookie value as a string to 'cookies.set'");r={name:t,value:o}}else r=t;this.ops.push({cookie:r,type:"set"})}};import{Buffer as re}from"node:buffer";import ne from"node:process";var ke="NETLIFY_PURGE_API_TOKEN",Ie="NETLIFY_BLOBS_CONTEXT",se=(e,t,o)=>{var s,c;let{blobs:r}=t,n=(c=(s=o==null?void 0:o.clientContext)==null?void 0:s.custom)==null?void 0:c.purge_api_token;if(typeof r=="string"&&r!=="")try{let i=re.from(r,"base64").toString("utf8"),a=JSON.parse(i),u=e.get(U),F=e.get(y);ne.env[Ie]=re.from(JSON.stringify({edgeURL:a.url,uncachedEdgeURL:a.url_uncached,token:a.token,siteID:u,deployID:F,primaryRegion:a.primary_region})).toString("base64")}catch(i){console.error("An internal error occurred while setting up Netlify Blobs:",i)}typeof n=="string"&&n!==""&&(ne.env[ke]=n)};var N=class e extends Error{constructor(t){super(t),this.name="NetlifyUserError",Object.setPrototypeOf(this,e.prototype)}};import De from"node:http";import _e from"node:https";import{AsyncLocalStorage as Ee}from"node:async_hooks";var m=new Ee;import{env as Oe}from"node:process";var ie=(e,t)=>{Oe.NETLIFY_DEV||console.log("__nfSystemLog",{msg:e,fields:t})};var Te=globalThis.fetch,ae=!1,ce=e=>{let t=m.getStore();if(t!=null&&t.cdnLoopHeader){if(e.headersSent){ie("Headers already sent, cannot add CDN-Loop header");return}e.setHeader("CDN-Loop",t==null?void 0:t.cdnLoopHeader)}},pe=()=>{if(!ae){ae=!0,globalThis.fetch=function(t,o){let r=new Request(t,o),n=m.getStore();return n!=null&&n.cdnLoopHeader&&r.headers.set("CDN-Loop",n.cdnLoopHeader),Te(r)};for(let e of[De,_e]){let t=e.request;e.get=function(...r){let n=t(...r);return ce(n),n.end(),n},e.request=function(...r){let n=t(...r);return ce(n),n}}}};var Ae=Ue(Pe),ue=0,Ge=e=>awslambda.streamifyResponse(async(t,o,r)=>{let n=Date.now(),s;t.initStartTimestamp!==void 0&&(s=ue===0?n-t.initStartTimestamp:0),ue=n;let{body:c,httpMethod:i,isBase64Encoded:a,headers:u,rawUrl:F,route:I}=t,C=M(u),fe=z(c,a),d=new x(F,{body:fe,headers:C,method:i});se(C,t,r),K(t,d),I&&(d[f]=I);let h=S(d);h.get("serverless_functions_request_interceptor_v2")===!0&&pe(),h.get("serverless_functions_wait_event_loop")===!0&&(r.callbackWaitsForEmptyEventLoop=!1);let E=new v(d),le=oe(d,E),l=await m.run({cdnLoopHeader:C.get("cdn-loop")},()=>e.default(d,le)),me={version:je},O=He.from(JSON.stringify(me)).toString("base64");if(l instanceof Response){E.apply(l);let p=new Headers(l.headers),{body:L,status:ge}=l,D=h.evaluations;D.size!==0&&p.set(A,[...D].join(",")),p.set(w,O),s!==void 0&&p.set(V,`init;dur=${s}`);let he={multiValueHeaders:J(p),statusCode:ge},q=awslambda.HttpResponseStream.from(o,he);if((h.get("serverless_functions_fix_empty_body")===!0||L===null)&&q.write(""),L===null){q.end();return}let ye=Be.fromWeb(L);await Ae(ye,q);return}if(l===void 0){let p=awslambda.HttpResponseStream.from(o,{statusCode:204,headers:{[w]:O}});p.write(""),p.end();return}throw new N("Function returned an unsupported value. Accepted types are 'Response' or 'undefined'")});import g from"process";var Ve={delete:e=>{delete g.env[e]},get:e=>g.env[e],has:e=>!!g.env[e],set:(e,t)=>{g.env[e]=t},toObject:()=>Object.entries(g.env).reduce((e,[t,o])=>o===void 0?e:{...e,[t]:o},{})},de={env:Ve};globalThis.Netlify=de;var Me=()=>de;var io=()=>Je(import.meta.url);export{Ge as getLambdaHandler,Me as getNetlifyGlobal,io as getPath};
import{createRequire}from"module";const require=createRequire(import.meta.url);
import{fileURLToPath as Kt}from"url";import{Buffer as qt}from"node:buffer";import{version as jt}from"node:process";import{pipeline as Mt,Readable as Bt}from"node:stream";import{promisify as Gt}from"node:util";var Q=e=>({id:e??""});var ee="x-nf-client-connection-ip",te="x-nf-geo",re="x-nf-account-id",U="x-nf-deploy-id",ne="x-nf-deploy-context",se="x-nf-deploy-published",ie="x-nf-site-id",oe="x-nf-request-flags",z="x-nf-invocation-metadata",ae="x-nf-request-id",ce="x-nf-function-timing",ue=e=>{let t=new Headers;return Object.entries(e).forEach(([r,n])=>{n!==void 0&&t.set(r.toLowerCase(),n)}),t},he=e=>{let t={};for(let[r,n]of e.entries())r in t?t[r].push(n):t[r]=[n];return t};var fe=e=>({context:e.get(ne)??"",id:e.get(U)??"",published:e.get(se)==="1"});import{Buffer as Ke}from"buffer";var q=Symbol("Request flags"),L=Symbol("Request route"),Xe=typeof Request>"u"?class{}:Request,le,H=class extends(le=Xe,q,L,le){},pe=(e,t)=>{if(!(e==null||e===""))return t?Ke.from(e,"base64"):e};var j=class{#e;#t;constructor(t){this.#e=new Set,this.#t=t}get(t){let r=this.#t[t];return r!==void 0&&this.#e.add(t),r}get evaluations(){return this.#e}},M=e=>e[q]??new j({}),me=(e,t)=>{let{flags:r={}}=e;t[q]=new j(r)};import{Buffer as Ye}from"node:buffer";var de=e=>{if(e===null)return{};try{return JSON.parse(Ye.from(e,"base64").toString("utf-8"))}catch{return{}}};var ge=e=>e??"";var _=class{constructor(e,t,r,n,i,u){this.type=3,this.name="",this.prefix="",this.value="",this.suffix="",this.modifier=3,this.type=e,this.name=t,this.prefix=r,this.value=n,this.suffix=i,this.modifier=u}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Ze=/[$_\p{ID_Start}]/u,Qe=/[$_\u200C\u200D\p{ID_Continue}]/u,K=".*";function et(e,t){return(t?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(e)}function ye(e,t=!1){let r=[],n=0;for(;n<e.length;){let i=e[n],u=function(o){if(!t)throw new TypeError(o);r.push({type:"INVALID_CHAR",index:n,value:e[n++]})};if(i==="*"){r.push({type:"ASTERISK",index:n,value:e[n++]});continue}if(i==="+"||i==="?"){r.push({type:"OTHER_MODIFIER",index:n,value:e[n++]});continue}if(i==="\\"){r.push({type:"ESCAPED_CHAR",index:n++,value:e[n++]});continue}if(i==="{"){r.push({type:"OPEN",index:n,value:e[n++]});continue}if(i==="}"){r.push({type:"CLOSE",index:n,value:e[n++]});continue}if(i===":"){let o="",s=n+1;for(;s<e.length;){let c=e.substr(s,1);if(s===n+1&&Ze.test(c)||s!==n+1&&Qe.test(c)){o+=e[s++];continue}break}if(!o){u(`Missing parameter name at ${n}`);continue}r.push({type:"NAME",index:n,value:o}),n=s;continue}if(i==="("){let o=1,s="",c=n+1,a=!1;if(e[c]==="?"){u(`Pattern cannot start with "?" at ${c}`);continue}for(;c<e.length;){if(!et(e[c],!1)){u(`Invalid character '${e[c]}' at ${c}.`),a=!0;break}if(e[c]==="\\"){s+=e[c++]+e[c++];continue}if(e[c]===")"){if(o--,o===0){c++;break}}else if(e[c]==="("&&(o++,e[c+1]!=="?")){u(`Capturing groups are not allowed at ${c}`),a=!0;break}s+=e[c++]}if(a)continue;if(o){u(`Unbalanced pattern at ${n}`);continue}if(!s){u(`Missing pattern at ${n}`);continue}r.push({type:"REGEX",index:n,value:s}),n=c;continue}r.push({type:"CHAR",index:n,value:e[n++]})}return r.push({type:"END",index:n,value:""}),r}function we(e,t={}){let r=ye(e);t.delimiter??(t.delimiter="/#?"),t.prefixes??(t.prefixes="./");let n=`[^${x(t.delimiter)}]+?`,i=[],u=0,o=0,s="",c=new Set,a=h=>{if(o<r.length&&r[o].type===h)return r[o++].value},l=()=>a("OTHER_MODIFIER")??a("ASTERISK"),g=h=>{let p=a(h);if(p!==void 0)return p;let{type:f,index:b}=r[o];throw new TypeError(`Unexpected ${f} at ${b}, expected ${h}`)},w=()=>{let h="",p;for(;p=a("CHAR")??a("ESCAPED_CHAR");)h+=p;return h},W=h=>h,S=t.encodePart||W,k="",P=h=>{k+=h},N=()=>{k.length&&(i.push(new _(3,"","",S(k),"",3)),k="")},v=(h,p,f,b,D)=>{let m=3;switch(D){case"?":m=1;break;case"*":m=0;break;case"+":m=2;break}if(!p&&!f&&m===3){P(h);return}if(N(),!p&&!f){if(!h)return;i.push(new _(3,"","",S(h),"",m));return}let d;f?f==="*"?d=K:d=f:d=n;let y=2;d===n?(y=1,d=""):d===K&&(y=0,d="");let C;if(p?C=p:f&&(C=u++),c.has(C))throw new TypeError(`Duplicate name '${C}'.`);c.add(C),i.push(new _(y,C,S(h),d,S(b),m))};for(;o<r.length;){let h=a("CHAR"),p=a("NAME"),f=a("REGEX");if(!p&&!f&&(f=a("ASTERISK")),p||f){let m=h??"";t.prefixes.indexOf(m)===-1&&(P(m),m=""),N();let d=l();v(m,p,f,"",d);continue}let b=h??a("ESCAPED_CHAR");if(b){P(b);continue}if(a("OPEN")){let m=w(),d=a("NAME"),y=a("REGEX");!d&&!y&&(y=a("ASTERISK"));let C=w();g("CLOSE");let Je=l();v(m,d,y,C,Je);continue}N(),g("END")}return i}function x(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function xe(e){return e&&e.ignoreCase?"ui":"u"}function tt(e,t,r){return be(we(e,r),t,r)}function T(e){switch(e){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}function be(e,t,r={}){r.delimiter??(r.delimiter="/#?"),r.prefixes??(r.prefixes="./"),r.sensitive??(r.sensitive=!1),r.strict??(r.strict=!1),r.end??(r.end=!0),r.start??(r.start=!0),r.endsWith="";let n=r.start?"^":"";for(let s of e){if(s.type===3){s.modifier===3?n+=x(s.value):n+=`(?:${x(s.value)})${T(s.modifier)}`;continue}t&&t.push(s.name);let c=`[^${x(r.delimiter)}]+?`,a=s.value;if(s.type===1?a=c:s.type===0&&(a=K),!s.prefix.length&&!s.suffix.length){s.modifier===3||s.modifier===1?n+=`(${a})${T(s.modifier)}`:n+=`((?:${a})${T(s.modifier)})`;continue}if(s.modifier===3||s.modifier===1){n+=`(?:${x(s.prefix)}(${a})${x(s.suffix)})`,n+=T(s.modifier);continue}n+=`(?:${x(s.prefix)}`,n+=`((?:${a})(?:`,n+=x(s.suffix),n+=x(s.prefix),n+=`(?:${a}))*)${x(s.suffix)})`,s.modifier===0&&(n+="?")}let i=`[${x(r.endsWith)}]|$`,u=`[${x(r.delimiter)}]`;if(r.end)return r.strict||(n+=`${u}?`),r.endsWith.length?n+=`(?=${i})`:n+="$",new RegExp(n,xe(r));r.strict||(n+=`(?:${u}(?=${i}))?`);let o=!1;if(e.length){let s=e[e.length-1];s.type===3&&s.modifier===3&&(o=r.delimiter.indexOf(s)>-1)}return o||(n+=`(?=${u}|${i})`),new RegExp(n,xe(r))}var E={delimiter:"",prefixes:"",sensitive:!0,strict:!0},rt={delimiter:".",prefixes:"",sensitive:!0,strict:!0},nt={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function st(e,t){return e.length?e[0]==="/"?!0:!t||e.length<2?!1:(e[0]=="\\"||e[0]=="{")&&e[1]=="/":!1}function Ce(e,t){return e.startsWith(t)?e.substring(t.length,e.length):e}function it(e,t){return e.endsWith(t)?e.substr(0,e.length-t.length):e}function ke(e){return!e||e.length<2?!1:e[0]==="["||(e[0]==="\\"||e[0]==="{")&&e[1]==="["}var Re=["ftp","file","http","https","ws","wss"];function ve(e){if(!e)return!0;for(let t of Re)if(e.test(t))return!0;return!1}function ot(e,t){if(e=Ce(e,"#"),t||e==="")return e;let r=new URL("https://example.com");return r.hash=e,r.hash?r.hash.substring(1,r.hash.length):""}function at(e,t){if(e=Ce(e,"?"),t||e==="")return e;let r=new URL("https://example.com");return r.search=e,r.search?r.search.substring(1,r.search.length):""}function ct(e,t){return t||e===""?e:ke(e)?Pe(e):Ee(e)}function ut(e,t){if(t||e==="")return e;let r=new URL("https://example.com");return r.password=e,r.password}function ht(e,t){if(t||e==="")return e;let r=new URL("https://example.com");return r.username=e,r.username}function ft(e,t,r){if(r||e==="")return e;if(t&&!Re.includes(t))return new URL(`${t}:${e}`).pathname;let n=e[0]=="/";return e=new URL(n?e:"/-"+e,"https://example.com").pathname,n||(e=e.substring(2,e.length)),e}function lt(e,t,r){return Ie(t)===e&&(e=""),r||e===""?e:Le(e)}function pt(e,t){return e=it(e,":"),t||e===""?e:X(e)}function Ie(e){switch(e){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}function X(e){if(e==="")return e;if(/^[-+.A-Za-z0-9]*$/.test(e))return e.toLowerCase();throw new TypeError(`Invalid protocol '${e}'.`)}function mt(e){if(e==="")return e;let t=new URL("https://example.com");return t.username=e,t.username}function dt(e){if(e==="")return e;let t=new URL("https://example.com");return t.password=e,t.password}function Ee(e){if(e==="")return e;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(e))throw new TypeError(`Invalid hostname '${e}'`);let t=new URL("https://example.com");return t.hostname=e,t.hostname}function Pe(e){if(e==="")return e;if(/[^0-9a-fA-F[\]:]/g.test(e))throw new TypeError(`Invalid IPv6 hostname '${e}'`);return e.toLowerCase()}function Le(e){if(e===""||/^[0-9]*$/.test(e)&&parseInt(e)<=65535)return e;throw new TypeError(`Invalid port '${e}'.`)}function gt(e){if(e==="")return e;let t=new URL("https://example.com");return t.pathname=e[0]!=="/"?"/-"+e:e,e[0]!=="/"?t.pathname.substring(2,t.pathname.length):t.pathname}function xt(e){return e===""?e:new URL(`data:${e}`).pathname}function St(e){if(e==="")return e;let t=new URL("https://example.com");return t.search=e,t.search.substring(1,t.search.length)}function yt(e){if(e==="")return e;let t=new URL("https://example.com");return t.hash=e,t.hash.substring(1,t.hash.length)}var wt=class{constructor(e){this.tokenList=[],this.internalResult={},this.tokenIndex=0,this.tokenIncrement=1,this.componentStart=0,this.state=0,this.groupDepth=0,this.hostnameIPv6BracketDepth=0,this.shouldTreatAsStandardURL=!1,this.input=e}get result(){return this.internalResult}parse(){for(this.tokenList=ye(this.input,!0);this.tokenIndex<this.tokenList.length;this.tokenIndex+=this.tokenIncrement){if(this.tokenIncrement=1,this.tokenList[this.tokenIndex].type==="END"){if(this.state===0){this.rewind(),this.isHashPrefix()?this.changeState(9,1):this.isSearchPrefix()?(this.changeState(8,1),this.internalResult.hash=""):(this.changeState(7,0),this.internalResult.search="",this.internalResult.hash="");continue}else if(this.state===2){this.rewindAndSetState(5);continue}this.changeState(10,0);break}if(this.groupDepth>0)if(this.isGroupClose())this.groupDepth-=1;else continue;if(this.isGroupOpen()){this.groupDepth+=1;continue}switch(this.state){case 0:this.isProtocolSuffix()&&(this.internalResult.username="",this.internalResult.password="",this.internalResult.hostname="",this.internalResult.port="",this.internalResult.pathname="",this.internalResult.search="",this.internalResult.hash="",this.rewindAndSetState(1));break;case 1:if(this.isProtocolSuffix()){this.computeShouldTreatAsStandardURL();let e=7,t=1;this.shouldTreatAsStandardURL&&(this.internalResult.pathname="/"),this.nextIsAuthoritySlashes()?(e=2,t=3):this.shouldTreatAsStandardURL&&(e=2),this.changeState(e,t)}break;case 2:this.isIdentityTerminator()?this.rewindAndSetState(3):(this.isPathnameStart()||this.isSearchPrefix()||this.isHashPrefix())&&this.rewindAndSetState(5);break;case 3:this.isPasswordPrefix()?this.changeState(4,1):this.isIdentityTerminator()&&this.changeState(5,1);break;case 4:this.isIdentityTerminator()&&this.changeState(5,1);break;case 5:this.isIPv6Open()?this.hostnameIPv6BracketDepth+=1:this.isIPv6Close()&&(this.hostnameIPv6BracketDepth-=1),this.isPortPrefix()&&!this.hostnameIPv6BracketDepth?this.changeState(6,1):this.isPathnameStart()?this.changeState(7,0):this.isSearchPrefix()?this.changeState(8,1):this.isHashPrefix()&&this.changeState(9,1);break;case 6:this.isPathnameStart()?this.changeState(7,0):this.isSearchPrefix()?this.changeState(8,1):this.isHashPrefix()&&this.changeState(9,1);break;case 7:this.isSearchPrefix()?this.changeState(8,1):this.isHashPrefix()&&this.changeState(9,1);break;case 8:this.isHashPrefix()&&this.changeState(9,1);break;case 9:break;case 10:break}}}changeState(e,t){switch(this.state){case 0:break;case 1:this.internalResult.protocol=this.makeComponentString();break;case 2:break;case 3:this.internalResult.username=this.makeComponentString();break;case 4:this.internalResult.password=this.makeComponentString();break;case 5:this.internalResult.hostname=this.makeComponentString();break;case 6:this.internalResult.port=this.makeComponentString();break;case 7:this.internalResult.pathname=this.makeComponentString();break;case 8:this.internalResult.search=this.makeComponentString();break;case 9:this.internalResult.hash=this.makeComponentString();break;case 10:break}this.changeStateWithoutSettingComponent(e,t)}changeStateWithoutSettingComponent(e,t){this.state=e,this.componentStart=this.tokenIndex+t,this.tokenIndex+=t,this.tokenIncrement=0}rewind(){this.tokenIndex=this.componentStart,this.tokenIncrement=0}rewindAndSetState(e){this.rewind(),this.state=e}safeToken(e){return e<0&&(e=this.tokenList.length-e),e<this.tokenList.length?this.tokenList[e]:this.tokenList[this.tokenList.length-1]}isNonSpecialPatternChar(e,t){let r=this.safeToken(e);return r.value===t&&(r.type==="CHAR"||r.type==="ESCAPED_CHAR"||r.type==="INVALID_CHAR")}isProtocolSuffix(){return this.isNonSpecialPatternChar(this.tokenIndex,":")}nextIsAuthoritySlashes(){return this.isNonSpecialPatternChar(this.tokenIndex+1,"/")&&this.isNonSpecialPatternChar(this.tokenIndex+2,"/")}isIdentityTerminator(){return this.isNonSpecialPatternChar(this.tokenIndex,"@")}isPasswordPrefix(){return this.isNonSpecialPatternChar(this.tokenIndex,":")}isPortPrefix(){return this.isNonSpecialPatternChar(this.tokenIndex,":")}isPathnameStart(){return this.isNonSpecialPatternChar(this.tokenIndex,"/")}isSearchPrefix(){if(this.isNonSpecialPatternChar(this.tokenIndex,"?"))return!0;if(this.tokenList[this.tokenIndex].value!=="?")return!1;let e=this.safeToken(this.tokenIndex-1);return e.type!=="NAME"&&e.type!=="REGEX"&&e.type!=="CLOSE"&&e.type!=="ASTERISK"}isHashPrefix(){return this.isNonSpecialPatternChar(this.tokenIndex,"#")}isGroupOpen(){return this.tokenList[this.tokenIndex].type=="OPEN"}isGroupClose(){return this.tokenList[this.tokenIndex].type=="CLOSE"}isIPv6Open(){return this.isNonSpecialPatternChar(this.tokenIndex,"[")}isIPv6Close(){return this.isNonSpecialPatternChar(this.tokenIndex,"]")}makeComponentString(){let e=this.tokenList[this.tokenIndex],t=this.safeToken(this.componentStart).index;return this.input.substring(t,e.index)}computeShouldTreatAsStandardURL(){let e={};Object.assign(e,E),e.encodePart=X;let t=tt(this.makeComponentString(),void 0,e);this.shouldTreatAsStandardURL=ve(t)}},J=["protocol","username","password","hostname","port","pathname","search","hash"],I="*";function Se(e,t){if(typeof e!="string")throw new TypeError("parameter 1 is not of type 'string'.");let r=new URL(e,t);return{protocol:r.protocol.substring(0,r.protocol.length-1),username:r.username,password:r.password,hostname:r.hostname,port:r.port,pathname:r.pathname,search:r.search!==""?r.search.substring(1,r.search.length):void 0,hash:r.hash!==""?r.hash.substring(1,r.hash.length):void 0}}function R(e,t){return t?A(e):e}function $(e,t,r){let n;if(typeof t.baseURL=="string")try{n=new URL(t.baseURL),e.protocol=R(n.protocol.substring(0,n.protocol.length-1),r),e.username=R(n.username,r),e.password=R(n.password,r),e.hostname=R(n.hostname,r),e.port=R(n.port,r),e.pathname=R(n.pathname,r),e.search=R(n.search.substring(1,n.search.length),r),e.hash=R(n.hash.substring(1,n.hash.length),r)}catch{throw new TypeError(`invalid baseURL '${t.baseURL}'.`)}if(typeof t.protocol=="string"&&(e.protocol=pt(t.protocol,r)),typeof t.username=="string"&&(e.username=ht(t.username,r)),typeof t.password=="string"&&(e.password=ut(t.password,r)),typeof t.hostname=="string"&&(e.hostname=ct(t.hostname,r)),typeof t.port=="string"&&(e.port=lt(t.port,e.protocol,r)),typeof t.pathname=="string"){if(e.pathname=t.pathname,n&&!st(e.pathname,r)){let i=n.pathname.lastIndexOf("/");i>=0&&(e.pathname=R(n.pathname.substring(0,i+1),r)+e.pathname)}e.pathname=ft(e.pathname,e.protocol,r)}return typeof t.search=="string"&&(e.search=at(t.search,r)),typeof t.hash=="string"&&(e.hash=ot(t.hash,r)),e}function A(e){return e.replace(/([+*?:{}()\\])/g,"\\$1")}function bt(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function Ct(e,t){t.delimiter??(t.delimiter="/#?"),t.prefixes??(t.prefixes="./"),t.sensitive??(t.sensitive=!1),t.strict??(t.strict=!1),t.end??(t.end=!0),t.start??(t.start=!0),t.endsWith="";let r=".*",n=`[^${bt(t.delimiter)}]+?`,i=/[$_\u200C\u200D\p{ID_Continue}]/u,u="";for(let o=0;o<e.length;++o){let s=e[o];if(s.type===3){if(s.modifier===3){u+=A(s.value);continue}u+=`{${A(s.value)}}${T(s.modifier)}`;continue}let c=s.hasCustomName(),a=!!s.suffix.length||!!s.prefix.length&&(s.prefix.length!==1||!t.prefixes.includes(s.prefix)),l=o>0?e[o-1]:null,g=o<e.length-1?e[o+1]:null;if(!a&&c&&s.type===1&&s.modifier===3&&g&&!g.prefix.length&&!g.suffix.length)if(g.type===3){let w=g.value.length>0?g.value[0]:"";a=i.test(w)}else a=!g.hasCustomName();if(!a&&!s.prefix.length&&l&&l.type===3){let w=l.value[l.value.length-1];a=t.prefixes.includes(w)}a&&(u+="{"),u+=A(s.prefix),c&&(u+=`:${s.name}`),s.type===2?u+=`(${s.value})`:s.type===1?c||(u+=`(${n})`):s.type===0&&(!c&&(!l||l.type===3||l.modifier!==3||a||s.prefix!=="")?u+="*":u+=`(${r})`),s.type===1&&c&&s.suffix.length&&i.test(s.suffix[0])&&(u+="\\"),u+=A(s.suffix),a&&(u+="}"),s.modifier!==3&&(u+=T(s.modifier))}return u}var B=class{constructor(e={},t,r){this.regexp={},this.names={},this.component_pattern={},this.parts={};try{let n;if(typeof t=="string"?n=t:r=t,typeof e=="string"){let s=new wt(e);if(s.parse(),e=s.result,n===void 0&&typeof e.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");e.baseURL=n}else{if(!e||typeof e!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(n)throw new TypeError("parameter 1 is not of type 'string'.")}typeof r>"u"&&(r={ignoreCase:!1});let i={ignoreCase:r.ignoreCase===!0},u={pathname:I,protocol:I,username:I,password:I,hostname:I,port:I,search:I,hash:I};this.pattern=$(u,e,!0),Ie(this.pattern.protocol)===this.pattern.port&&(this.pattern.port="");let o;for(o of J){if(!(o in this.pattern))continue;let s={},c=this.pattern[o];switch(this.names[o]=[],o){case"protocol":Object.assign(s,E),s.encodePart=X;break;case"username":Object.assign(s,E),s.encodePart=mt;break;case"password":Object.assign(s,E),s.encodePart=dt;break;case"hostname":Object.assign(s,rt),ke(c)?s.encodePart=Pe:s.encodePart=Ee;break;case"port":Object.assign(s,E),s.encodePart=Le;break;case"pathname":ve(this.regexp.protocol)?(Object.assign(s,nt,i),s.encodePart=gt):(Object.assign(s,E,i),s.encodePart=xt);break;case"search":Object.assign(s,E,i),s.encodePart=St;break;case"hash":Object.assign(s,E,i),s.encodePart=yt;break}try{this.parts[o]=we(c,s),this.regexp[o]=be(this.parts[o],this.names[o],s),this.component_pattern[o]=Ct(this.parts[o],s)}catch{throw new TypeError(`invalid ${o} pattern '${this.pattern[o]}'.`)}}}catch(n){throw new TypeError(`Failed to construct 'URLPattern': ${n.message}`)}}test(e={},t){let r={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof e!="string"&&t)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof e>"u")return!1;try{typeof e=="object"?r=$(r,e,!1):r=$(r,Se(e,t),!1)}catch{return!1}let n;for(n of J)if(!this.regexp[n].exec(r[n]))return!1;return!0}exec(e={},t){let r={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof e!="string"&&t)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof e>"u")return;try{typeof e=="object"?r=$(r,e,!1):r=$(r,Se(e,t),!1)}catch{return null}let n={};t?n.inputs=[e,t]:n.inputs=[e];let i;for(i of J){let u=this.regexp[i].exec(r[i]);if(!u)return null;let o={};for(let[s,c]of this.names[i].entries())if(typeof c=="string"||typeof c=="number"){let a=u[s+1];o[c]=a}n[i]={input:r[i]??"",groups:o}}return n}static compareComponent(e,t,r){let n=(s,c)=>{for(let a of["type","modifier","prefix","value","suffix"]){if(s[a]<c[a])return-1;if(s[a]===c[a])continue;return 1}return 0},i=new _(3,"","","","",3),u=new _(0,"","","","",3),o=(s,c)=>{let a=0;for(;a<Math.min(s.length,c.length);++a){let l=n(s[a],c[a]);if(l)return l}return s.length===c.length?0:n(s[a]??i,c[a]??i)};return!t.component_pattern[e]&&!r.component_pattern[e]?0:t.component_pattern[e]&&!r.component_pattern[e]?o(t.parts[e],[u]):!t.component_pattern[e]&&r.component_pattern[e]?o([u],r.parts[e]):o(t.parts[e],r.parts[e])}get protocol(){return this.component_pattern.protocol}get username(){return this.component_pattern.username}get password(){return this.component_pattern.password}get hostname(){return this.component_pattern.hostname}get port(){return this.component_pattern.port}get pathname(){return this.component_pattern.pathname}get search(){return this.component_pattern.search}get hash(){return this.component_pattern.hash}};globalThis.URLPattern||(globalThis.URLPattern=B);var Te=(e,t)=>{var o;if(e===void 0)return{};let r=t.endsWith("/")?t.slice(0,-1):t,i=(o=new B({pathname:e,baseURL:r}).exec(r))==null?void 0:o.pathname.groups;return i?Object.entries(i).reduce((s,[c,a])=>a===void 0?s:{...s,[c]:a},{}):{}};var Ne=e=>e??"";import{env as kt}from"process";var $e=()=>({region:kt.AWS_REGION});import{env as Y}from"process";var Ae=()=>({id:Y.SITE_ID,name:Y.SITE_NAME,url:Y.URL});var Rt=e=>{let t=JSON.stringify(e);return new Response(t,{headers:{"content-type":"application/json"}})},_e=(e,t)=>{let r={};try{r=Te(e[L],e.url)}catch{console.log(`Could not parse function route ${e[L]}.`)}return{account:Q(e.headers.get(re)),cookies:t.getPublicInterface(),deploy:fe(e.headers),flags:M(e),geo:de(e.headers.get(te)),ip:ge(e.headers.get(ee)),json:Rt,log:console.log,next:()=>{throw new Error("`context.next` is not implemented for serverless functions")},params:r,requestId:Ne(e.headers.get(ae)),rewrite:i=>{let u=vt(i,e.url);return It(u)},server:$e(),site:Ae()}},vt=(e,t)=>{if(e instanceof URL)return e;if(e.startsWith("/")){let r=new URL(t);return r.pathname=e,r}return new URL(e)},It=async e=>await fetch(e);import Oe from"node:assert";function Fe(e){function t(a,l=2){return a.padStart(l,"0")}let r=t(e.getUTCDate().toString()),n=t(e.getUTCHours().toString()),i=t(e.getUTCMinutes().toString()),u=t(e.getUTCSeconds().toString()),o=e.getUTCFullYear(),s=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],c=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return`${s[e.getUTCDay()]}, ${r} ${c[e.getUTCMonth()]} ${o} ${n}:${i}:${u} GMT`}var Et=/^(?=[\u0020-\u007E]*$)[^()@<>,;:\\"[\]?={}\s]+$/;function Pt(e){if(!e.name)return"";let t=[];if(Lt(e.name),Nt(e.name,e.value),t.push(`${e.name}=${e.value}`),e.name.startsWith("__Secure")&&(e.secure=!0),e.name.startsWith("__Host")&&(e.path="/",e.secure=!0,delete e.domain),e.secure&&t.push("Secure"),e.httpOnly&&t.push("HttpOnly"),typeof e.maxAge=="number"&&Number.isInteger(e.maxAge)&&(Oe(e.maxAge>=0,"Max-Age must be an integer superior or equal to 0"),t.push(`Max-Age=${e.maxAge}`)),e.domain&&($t(e.domain),t.push(`Domain=${e.domain}`)),e.sameSite&&t.push(`SameSite=${e.sameSite}`),e.path&&(Tt(e.path),t.push(`Path=${e.path}`)),e.expires){let{expires:r}=e,n=Fe(typeof r=="number"?new Date(r):r);t.push(`Expires=${n}`)}return e.unparsed&&t.push(e.unparsed.join("; ")),t.join("; ")}function Lt(e){if(e&&!Et.test(e))throw new TypeError(`Invalid cookie name: "${e}".`)}function Tt(e){if(e!=null)for(let t=0;t<e.length;t++){let r=e.charAt(t);if(r<" "||r>"~"||r==";")throw new Error(`${e}: Invalid cookie path char '${r}'`)}}function Nt(e,t){if(!(t==null||e==null))for(let r=0;r<t.length;r++){let n=t.charAt(r);if(n<"!"||n=='"'||n==","||n==";"||n=="\\"||n=="\x7F")throw new Error(`RFC2616 cookie '${e}' cannot contain character '${n}'`);if(n>"\x80")throw new Error(`RFC2616 cookie '${e}' can only have US-ASCII chars as value${n.charCodeAt(0).toString(16)}`)}}function $t(e){if(e==null)return;let t=e.charAt(0),r=e.charAt(e.length-1);if(t=="-"||r=="."||r=="-")throw new Error(`Invalid first/last char in cookie domain: ${e}`)}function De(e){let t=e.get("Cookie");if(t!=null){let r={},n=t.split(";");for(let i of n){let[u,...o]=i.split("=");Oe(u!=null);let s=u.trim();r[s]=o.join("=")}return r}return{}}function Z(e,t){let r=Pt(t);r&&e.append("Set-Cookie",r)}function Ue(e,t,r){Z(e,Object.assign({name:t,value:"",expires:new Date(0)},r))}var G=class{constructor(t){this.ops=[],this.request=t}apply(t){this.ops.forEach(r=>{switch(r.type){case"delete":Ue(t.headers,r.options.name,{domain:r.options.domain,path:r.options.path});break;case"set":Z(t.headers,r.cookie);break;default:}})}delete(t){let r={path:"/"},n=typeof t=="string"?{name:t}:t;this.ops.push({options:{...r,...n},type:"delete"})}get(t){return De(this.request.headers)[t]}getPublicInterface(){return{delete:this.delete.bind(this),get:this.get.bind(this),set:this.set.bind(this)}}set(t,r){let n;if(typeof t=="string"){if(typeof r!="string")throw new TypeError("You must provide the cookie value as a string to 'cookies.set'");n={name:t,value:r}}else n=t;this.ops.push({cookie:n,type:"set"})}};import{Buffer as He}from"node:buffer";import qe from"node:process";var At="NETLIFY_PURGE_API_TOKEN",_t="NETLIFY_BLOBS_CONTEXT",je=(e,t,r)=>{var u,o;let{blobs:n}=t,i=(o=(u=r==null?void 0:r.clientContext)==null?void 0:u.custom)==null?void 0:o.purge_api_token;if(typeof n=="string"&&n!=="")try{let s=He.from(n,"base64").toString("utf8"),c=JSON.parse(s),a=e.get(ie),l=e.get(U);qe.env[_t]=He.from(JSON.stringify({edgeURL:c.url,uncachedEdgeURL:c.url_uncached,token:c.token,siteID:a,deployID:l,primaryRegion:c.primary_region})).toString("base64")}catch(s){console.error("An internal error occurred while setting up Netlify Blobs:",s)}typeof i=="string"&&i!==""&&(qe.env[At]=i)};var V=class e extends Error{constructor(t){super(t),this.name="NetlifyUserError",Object.setPrototypeOf(this,e.prototype)}};import Dt from"node:http";import Ut from"node:https";import{AsyncLocalStorage as Ft}from"node:async_hooks";var F=new Ft;import{env as Ot}from"node:process";var Me=(e,t)=>{Ot.NETLIFY_DEV||console.log("__nfSystemLog",{msg:e,fields:t})};var Ht=globalThis.fetch,Be=!1,Ge=e=>{let t=F.getStore();if(t!=null&&t.cdnLoopHeader){if(e.headersSent){Me("Headers already sent, cannot add CDN-Loop header");return}e.setHeader("CDN-Loop",t==null?void 0:t.cdnLoopHeader)}},Ve=()=>{if(!Be){Be=!0,globalThis.fetch=function(t,r){let n=new Request(t,r),i=F.getStore();return i!=null&&i.cdnLoopHeader&&n.headers.set("CDN-Loop",i.cdnLoopHeader),Ht(n)};for(let e of[Dt,Ut]){let t=e.request;e.get=function(...n){let i=t(...n);return Ge(i),i.end(),i},e.request=function(...n){let i=t(...n);return Ge(i),i}}}};var Vt=Gt(Mt),We=0,Wt=e=>awslambda.streamifyResponse(async(t,r,n)=>{let i=Date.now(),u;t.initStartTimestamp!==void 0&&(u=We===0?i-t.initStartTimestamp:0),We=i;let{body:o,httpMethod:s,isBase64Encoded:c,headers:a,rawUrl:l,route:g}=t,w=ue(a),W=pe(o,c),S=new H(l,{body:W,headers:w,method:s});je(w,t,n),me(t,S),g&&(S[L]=g);let k=M(S);k.get("serverless_functions_request_interceptor_v2")===!0&&Ve(),k.get("serverless_functions_wait_event_loop")===!0&&(n.callbackWaitsForEmptyEventLoop=!1);let P=new G(S),N=_e(S,P),v=await F.run({cdnLoopHeader:w.get("cdn-loop")},()=>e.default(S,N)),h={version:jt},p=qt.from(JSON.stringify(h)).toString("base64");if(v instanceof Response){P.apply(v);let f=new Headers(v.headers),{body:b,status:D}=v,m=k.evaluations;m.size!==0&&f.set(oe,[...m].join(",")),f.set(z,p),u!==void 0&&f.set(ce,`init;dur=${u}`);let d={multiValueHeaders:he(f),statusCode:D},y=awslambda.HttpResponseStream.from(r,d);if((k.get("serverless_functions_fix_empty_body")===!0||b===null)&&y.write(""),b===null){y.end();return}let C=Bt.fromWeb(b);await Vt(C,y);return}if(v===void 0){let f=awslambda.HttpResponseStream.from(r,{statusCode:204,headers:{[z]:p}});f.write(""),f.end();return}throw new V("Function returned an unsupported value. Accepted types are 'Response' or 'undefined'")});import O from"process";var zt={delete:e=>{delete O.env[e]},get:e=>O.env[e],has:e=>!!O.env[e],set:(e,t)=>{O.env[e]=t},toObject:()=>Object.entries(O.env).reduce((e,[t,r])=>r===void 0?e:{...e,[t]:r},{})},ze={env:zt};globalThis.Netlify=ze;var Jt=()=>ze;var kn=()=>Kt(import.meta.url);export{Wt as getLambdaHandler,Jt as getNetlifyGlobal,kn as getPath};
{
"name": "@netlify/serverless-functions-api",
"type": "module",
"version": "1.19.0",
"version": "1.19.1",
"files": [

@@ -76,3 +76,3 @@ "dist/**/*.d.ts",

"@vitest/coverage-v8": "^1.0.0",
"esbuild": "^0.22.0",
"esbuild": "0.23.0",
"husky": "^9.0.0",

@@ -79,0 +79,0 @@ "lambda-local": "^2.0.2",

Sorry, the diff of this file is too big to display