2 lines
356 KiB
JavaScript
2 lines
356 KiB
JavaScript
|
|
(()=>{var __webpack_modules__={1900:(A,e,t)=>{"use strict";const{parseContentType:s}=t(4318);function getInstance(A){const e=A.headers;const t=s(e["content-type"]);if(!t)throw new Error("Malformed content type");for(const s of o){const o=s.detect(t);if(!o)continue;const r={limits:A.limits,headers:e,conType:t,highWaterMark:undefined,fileHwm:undefined,defCharset:undefined,defParamCharset:undefined,preservePath:false};if(A.highWaterMark)r.highWaterMark=A.highWaterMark;if(A.fileHwm)r.fileHwm=A.fileHwm;r.defCharset=A.defCharset;r.defParamCharset=A.defParamCharset;r.preservePath=A.preservePath;return new s(r)}throw new Error(`Unsupported content type: ${e["content-type"]}`)}const o=[t(6104),t(8506)].filter((function(A){return typeof A.detect==="function"}));A.exports=A=>{if(typeof A!=="object"||A===null)A={};if(typeof A.headers!=="object"||A.headers===null||typeof A.headers["content-type"]!=="string"){throw new Error("Missing Content-Type")}return getInstance(A)}},6104:(A,e,t)=>{"use strict";const{Readable:s,Writable:o}=t(2781);const r=t(6542);const{basename:i,convertToUTF8:g,getDecoder:n,parseContentType:Q,parseDisposition:C}=t(4318);const E=Buffer.from("\r\n");const I=Buffer.from("\r");const B=Buffer.from("-");function noop(){}const a=2e3;const c=16*1024;const h=0;const l=1;const u=2;class HeaderParser{constructor(A){this.header=Object.create(null);this.pairCount=0;this.byteCount=0;this.state=h;this.name="";this.value="";this.crlf=0;this.cb=A}reset(){this.header=Object.create(null);this.pairCount=0;this.byteCount=0;this.state=h;this.name="";this.value="";this.crlf=0}push(A,e,t){let s=e;while(e<t){switch(this.state){case h:{let o=false;for(;e<t;++e){if(this.byteCount===c)return-1;++this.byteCount;const t=A[e];if(f[t]!==1){if(t!==58)return-1;this.name+=A.latin1Slice(s,e);if(this.name.length===0)return-1;++e;o=true;this.state=l;break}}if(!o){this.name+=A.latin1Slice(s,e);break}}case l:{let o=false;for(;e<t;++e){if(this.byteCount===c)return-1;++this.byteCount;const t=A[e];if(t!==32&&t!==9){s=e;o=true;this.state=u;break}}if(!o)break}case u:switch(this.crlf){case 0:for(;e<t;++e){if(this.byteCount===c)return-1;++this.byteCount;const t=A[e];if(D[t]!==1){if(t!==13)return-1;++this.crlf;break}}this.value+=A.latin1Slice(s,e++);break;case 1:if(this.byteCount===c)return-1;++this.byteCount;if(A[e++]!==10)return-1;++this.crlf;break;case 2:{if(this.byteCount===c)return-1;++this.byteCount;const t=A[e];if(t===32||t===9){s=e;this.crlf=0}else{if(++this.pairCount<a){this.name=this.name.toLowerCase();if(this.header[this.name]===undefined)this.header[this.name]=[this.value];else this.header[this.name].push(this.value)}if(t===13){++this.crlf;++e}else{s=e;this.crlf=0;this.state=h;this.name="";this.value=""}}break}case 3:{if(this.byteCount===c)return-1;++this.byteCount;if(A[e++]!==10)return-1;const t=this.header;this.reset();this.cb(t);return e}}break}}return e}}class FileStream extends s{constructor(A,e){super(A);this.truncated=false;this._readcb=null;this.once("end",(()=>{this._read();if(--e._fileEndsLeft===0&&e._finalcb){const A=e._finalcb;e._finalcb=null;process.nextTick(A)}}))}_read(A){const e=this._readcb;if(e){this._readcb=null;e()}}}const d={push:(A,e)=>{},destroy:()=>{}};function callAndUnsetCb(A,e){const t=A._writecb;A._writecb=null;if(e)A.destroy(e);else if(t)t()}function nullDecoder(A,e){return A}class Multipart extends o{constructor(A){const e={autoDestroy:true,emitClose:true,highWaterMark:typeof A.highWaterMark==="number"?A.highWaterMark:undefined};super(e);if(!A.conType.params||typeof A.conType.params.boundary!=="string")throw new Error("Multipart: Boundary not found");const t=A.conType.params.boundary;const s=typeof A.defParamCharset==="string"&&A.defParamCharset?n(A.defParamCharset):nullDecoder;const o=A.defCharset||"utf8";const a=A.preservePath;const c={autoDestroy:true,emitClose:true,highWaterMark:typeof A.fileHwm==="number"?A.fileHwm:undefined};const h=A.limits;const l=h&&typeof h.fieldSize==="number"?h.fieldSize:1*1024*1024;const u=h&&typeof h.fileSize==="number"?h.fileSize:Infinity;const f=h&&typeof h.files==="number"?h.files:In
|
||
|
|
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */;const escape=A=>A.replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/"/g,"%22");const normalizeLinefeeds=A=>A.replace(/\r?\n|\r/g,"\r\n");Q=async function*(A){const s=new TextEncoder;for(const[e,o]of A){if(typeof o==="string"){yield s.encode(t+`; name="${escape(normalizeLinefeeds(e))}"`+`\r\n\r\n${normalizeLinefeeds(o)}\r\n`)}else{yield s.encode(t+`; name="${escape(normalizeLinefeeds(e))}"`+(o.name?`; filename="${escape(o.name)}"`:"")+"\r\n"+`Content-Type: ${o.type||"application/octet-stream"}\r\n\r\n`);yield*o.stream();yield new Uint8Array([13,10])}}yield s.encode(`--${e}--`)};C=A;E=(()=>{const s=t.length;const o=e.length;let r=0;for(const[e,t]of A){if(typeof t==="string"){r+=s+Buffer.byteLength(`; name="${escape(normalizeLinefeeds(e))}"\r\n\r\n${normalizeLinefeeds(t)}\r\n`)}else{r+=s+Buffer.byteLength(`; name="${escape(normalizeLinefeeds(e))}"`+(t.name?`; filename="${escape(t.name)}"`:""))+2+`Content-Type: ${t.type||"application/octet-stream"}\r\n\r\n`.length;r+=t.size+2}}r+=o+4;return r})();I="multipart/form-data; boundary="+e}else if(i(A)){C=A;E=A.size;if(A.type){I=A.type}}else if(A instanceof Uint8Array){C=A}else if(typeof A[Symbol.asyncIterator]==="function"){if(e){throw new TypeError("keepalive")}if(o.isDisturbed(A)||A.locked){throw new TypeError("Response body object should not be disturbed or locked")}s=A instanceof S?A:r(A)}if(typeof C==="string"||o.isBuffer(C)){E=Buffer.byteLength(C)}if(Q!=null){let e;s=new S({async start(){e=Q(A)[Symbol.asyncIterator]()},async pull(A){const{value:t,done:o}=await e.next();if(o){queueMicrotask((()=>{A.close()}))}else{if(!u(s)){A.enqueue(new Uint8Array(t))}}return A.desiredSize>0},async cancel(A){await e.return()},type:undefined})}const B={stream:s,source:C,length:E};return[B,I]}function safelyExtractBody(A,e=false){if(!S){S=t(5356).ReadableStream}if(A instanceof S){l(!o.isDisturbed(A),"The body has already been consumed.");l(!A.locked,"The stream is locked.")}return extractBody(A,e)}function cloneBody(A){const[e,t]=A.stream.tee();const s=B(t,{transfer:[t]});const[,o]=s.tee();A.stream=e;return{stream:o,length:A.length,source:A.source}}async function*consumeBody(A){if(A){if(d(A)){yield A}else{const e=A.stream;if(o.isDisturbed(e)){throw new TypeError("The body has already been consumed.")}if(e.locked){throw new TypeError("The stream is locked.")}e[h]=true;yield*e}}}function throwIfAborted(A){if(A.aborted){throw new I("The operation was aborted.","AbortError")}}function bodyMixinMethods(A){const e={blob(){return specConsumeBody(this,"Blob",A)},arrayBuffer(){return specConsumeBody(this,"ArrayBuffer",A)},text(){return specConsumeBody(this,"text",A)},json(){return specConsumeBody(this,"JSON",A)},async formData(){E.brandCheck(this,A);throwIfAborted(this[C]);const e=this.headers.get("Content-Type");if(/multipart\/form-data/.test(e)){const A={};for(const[e,t]of this.headers)A[e.toLowerCase()]=t;const e=new Q;let t;try{t=s({headers:A,defParamCharset:"utf8"})}catch(A){throw Object.assign(new TypeError,{cause:A})}t.on("field",((A,t)=>{e.append(A,t)}));t.on("file",((A,t,s)=>{const{filename:o,encoding:r,mimeType:i}=s;const g=[];if(r==="base64"||r.toLowerCase()==="base64"){let s="";t.on("data",(A=>{s+=A.toString().replace(/[\r\n]/gm,"");const e=s.length-s.length%4;g.push(Buffer.from(s.slice(0,e),"base64"));s=s.slice(e)}));t.on("end",(()=>{g.push(Buffer.from(s,"base64"));e.append(A,new p(g,o,{type:i}))}))}else{t.on("data",(A=>{g.push(A)}));t.on("end",(()=>{e.append(A,new p(g,o,{type:i}))}))}}));const o=new Promise(((A,e)=>{t.on("finish",A);t.on("error",(A=>e(new TypeError(A))))}));if(this.body!==null)for await(const A of consumeBody(this[C].body))t.write(A);t.end();await o;return e}else if(/application\/x-www-form-urlencoded/.test(e)){let A;try{let e="";const t=new TextDecoder("utf-8",{ignoreBOM:true});for await(const A of consumeBody(this[C].body)){if(!d(A)){throw new TypeError("Expected Uint8Array chunk")}e+=t.decode(A,{stream:true})}e+=t.decode();A=new URLSearchParams(e)}catch(A){throw Object.assign(
|