@shipstatic/ship 0.3.11 → 0.3.12
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/browser.d.ts +1 -1
- package/dist/browser.js +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/browser.d.ts
CHANGED
|
@@ -201,7 +201,7 @@ declare class ApiHttp extends SimpleEvents {
|
|
|
201
201
|
listDeployments(): Promise<DeploymentListResponse>;
|
|
202
202
|
getDeployment(id: string): Promise<Deployment>;
|
|
203
203
|
removeDeployment(id: string): Promise<void>;
|
|
204
|
-
setDomain(name: string, deployment
|
|
204
|
+
setDomain(name: string, deployment?: string, tags?: string[]): Promise<Domain>;
|
|
205
205
|
getDomain(name: string): Promise<Domain>;
|
|
206
206
|
listDomains(): Promise<DomainListResponse>;
|
|
207
207
|
removeDomain(name: string): Promise<void>;
|
package/dist/browser.js
CHANGED
|
@@ -2,7 +2,7 @@ var ja=Object.create;var W=Object.defineProperty;var Fa=Object.getOwnPropertyDes
|
|
|
2
2
|
`||e===`
|
|
3
3
|
`&&t[a-1]!=="\r"?`\r
|
|
4
4
|
`:e);Na=i=>new Proxy(i,{get:(e,a)=>Ye(e,a),has:(e,a)=>Ye(e,a)!==void 0}),Ba={enableAdditionalHeaders:!1},ee={writable:!1,configurable:!1},Ma=class{constructor(i,e,a){if(z(this,V),z(this,P,`\r
|
|
5
|
-
`),z(this,B),z(this,ae),z(this,M,"-".repeat(2)),z(this,_,new TextEncoder),z(this,K),z(this,H),z(this,ie),!Ze(i))throw new TypeError("Expected first argument to be a FormData instance.");let t;if(We(e)?a=e:t=e,t||(t=`form-data-encoder-${$a()}`),typeof t!="string")throw new TypeError("Expected boundary argument to be a string.");if(a&&!We(a))throw new TypeError("Expected options argument to be an object.");N(this,H,Array.from(i.entries())),N(this,ie,{...Ba,...a}),N(this,B,g(this,_).encode(g(this,P))),N(this,ae,g(this,B).byteLength),this.boundary=t,this.contentType=`multipart/form-data; boundary=${this.boundary}`,N(this,K,g(this,_).encode(`${g(this,M)}${this.boundary}${g(this,M)}${g(this,P).repeat(2)}`));let u={"Content-Type":this.contentType},p=ye(this,V,ea).call(this);p&&(this.contentLength=p,u["Content-Length"]=p),this.headers=Na(Object.freeze(u)),Object.defineProperties(this,{boundary:ee,contentType:ee,contentLength:ee,headers:ee})}*values(){for(let[i,e]of g(this,H)){let a=$(e)?e:g(this,_).encode(Qe(e));yield ye(this,V,ke).call(this,i,a),yield a,yield g(this,B)}yield g(this,K)}async*encode(){for(let i of this.values())$(i)?yield*La(i.stream()):yield*Xe(i)}[Symbol.iterator](){return this.values()}[Symbol.asyncIterator](){return this.encode()}};P=new WeakMap;B=new WeakMap;ae=new WeakMap;M=new WeakMap;_=new WeakMap;K=new WeakMap;H=new WeakMap;ie=new WeakMap;V=new WeakSet;ke=function(i,e){let a="";if(a+=`${g(this,M)}${this.boundary}${g(this,P)}`,a+=`Content-Disposition: form-data; name="${Ve(i)}"`,$(e)&&(a+=`; filename="${Ve(e.name)}"${g(this,P)}`,a+=`Content-Type: ${e.type||"application/octet-stream"}`),g(this,ie).enableAdditionalHeaders===!0){let t=$(e)?e.size:e.byteLength;t!=null&&!isNaN(t)&&(a+=`${g(this,P)}Content-Length: ${t}`)}return g(this,_).encode(`${a}${g(this,P).repeat(2)}`)};ea=function(){let i=0;for(let[e,a]of g(this,H)){let t=$(a)?a:g(this,_).encode(Qe(a)),u=$(t)?t.size:t.byteLength;if(u==null||isNaN(u))return;i+=ye(this,V,ke).call(this,e,t).byteLength,i+=u,i+=g(this,ae)}return String(i+g(this,K).byteLength)}});var ra=Y((ta,ca)=>{"use strict";(function(i){if(typeof ta=="object")ca.exports=i();else if(typeof define=="function"&&define.amd)define(i);else{var e;try{e=window}catch{e=self}e.SparkMD5=i()}})(function(i){"use strict";var e=function(l,r){return l+r&4294967295},a=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function t(l,r,o,n,c,s){return r=e(e(r,l),e(n,s)),e(r<<c|r>>>32-c,o)}function u(l,r){var o=l[0],n=l[1],c=l[2],s=l[3];o+=(n&c|~n&s)+r[0]-680876936|0,o=(o<<7|o>>>25)+n|0,s+=(o&n|~o&c)+r[1]-389564586|0,s=(s<<12|s>>>20)+o|0,c+=(s&o|~s&n)+r[2]+606105819|0,c=(c<<17|c>>>15)+s|0,n+=(c&s|~c&o)+r[3]-1044525330|0,n=(n<<22|n>>>10)+c|0,o+=(n&c|~n&s)+r[4]-176418897|0,o=(o<<7|o>>>25)+n|0,s+=(o&n|~o&c)+r[5]+1200080426|0,s=(s<<12|s>>>20)+o|0,c+=(s&o|~s&n)+r[6]-1473231341|0,c=(c<<17|c>>>15)+s|0,n+=(c&s|~c&o)+r[7]-45705983|0,n=(n<<22|n>>>10)+c|0,o+=(n&c|~n&s)+r[8]+1770035416|0,o=(o<<7|o>>>25)+n|0,s+=(o&n|~o&c)+r[9]-1958414417|0,s=(s<<12|s>>>20)+o|0,c+=(s&o|~s&n)+r[10]-42063|0,c=(c<<17|c>>>15)+s|0,n+=(c&s|~c&o)+r[11]-1990404162|0,n=(n<<22|n>>>10)+c|0,o+=(n&c|~n&s)+r[12]+1804603682|0,o=(o<<7|o>>>25)+n|0,s+=(o&n|~o&c)+r[13]-40341101|0,s=(s<<12|s>>>20)+o|0,c+=(s&o|~s&n)+r[14]-1502002290|0,c=(c<<17|c>>>15)+s|0,n+=(c&s|~c&o)+r[15]+1236535329|0,n=(n<<22|n>>>10)+c|0,o+=(n&s|c&~s)+r[1]-165796510|0,o=(o<<5|o>>>27)+n|0,s+=(o&c|n&~c)+r[6]-1069501632|0,s=(s<<9|s>>>23)+o|0,c+=(s&n|o&~n)+r[11]+643717713|0,c=(c<<14|c>>>18)+s|0,n+=(c&o|s&~o)+r[0]-373897302|0,n=(n<<20|n>>>12)+c|0,o+=(n&s|c&~s)+r[5]-701558691|0,o=(o<<5|o>>>27)+n|0,s+=(o&c|n&~c)+r[10]+38016083|0,s=(s<<9|s>>>23)+o|0,c+=(s&n|o&~n)+r[15]-660478335|0,c=(c<<14|c>>>18)+s|0,n+=(c&o|s&~o)+r[4]-405537848|0,n=(n<<20|n>>>12)+c|0,o+=(n&s|c&~s)+r[9]+568446438|0,o=(o<<5|o>>>27)+n|0,s+=(o&c|n&~c)+r[14]-1019803690|0,s=(s<<9|s>>>23)+o|0,c+=(s&n|o&~n)+r[3]-187363961|0,c=(c<<14|c>>>18)+s|0,n+=(c&o|s&~o)+r[8]+1163531501|0,n=(n<<20|n>>>12)+c|0,o+=(n&s|c&~s)+r[13]-1444681467|0,o=(o<<5|o>>>27)+n|0,s+=(o&c|n&~c)+r[2]-51403784|0,s=(s<<9|s>>>23)+o|0,c+=(s&n|o&~n)+r[7]+1735328473|0,c=(c<<14|c>>>18)+s|0,n+=(c&o|s&~o)+r[12]-1926607734|0,n=(n<<20|n>>>12)+c|0,o+=(n^c^s)+r[5]-378558|0,o=(o<<4|o>>>28)+n|0,s+=(o^n^c)+r[8]-2022574463|0,s=(s<<11|s>>>21)+o|0,c+=(s^o^n)+r[11]+1839030562|0,c=(c<<16|c>>>16)+s|0,n+=(c^s^o)+r[14]-35309556|0,n=(n<<23|n>>>9)+c|0,o+=(n^c^s)+r[1]-1530992060|0,o=(o<<4|o>>>28)+n|0,s+=(o^n^c)+r[4]+1272893353|0,s=(s<<11|s>>>21)+o|0,c+=(s^o^n)+r[7]-155497632|0,c=(c<<16|c>>>16)+s|0,n+=(c^s^o)+r[10]-1094730640|0,n=(n<<23|n>>>9)+c|0,o+=(n^c^s)+r[13]+681279174|0,o=(o<<4|o>>>28)+n|0,s+=(o^n^c)+r[0]-358537222|0,s=(s<<11|s>>>21)+o|0,c+=(s^o^n)+r[3]-722521979|0,c=(c<<16|c>>>16)+s|0,n+=(c^s^o)+r[6]+76029189|0,n=(n<<23|n>>>9)+c|0,o+=(n^c^s)+r[9]-640364487|0,o=(o<<4|o>>>28)+n|0,s+=(o^n^c)+r[12]-421815835|0,s=(s<<11|s>>>21)+o|0,c+=(s^o^n)+r[15]+530742520|0,c=(c<<16|c>>>16)+s|0,n+=(c^s^o)+r[2]-995338651|0,n=(n<<23|n>>>9)+c|0,o+=(c^(n|~s))+r[0]-198630844|0,o=(o<<6|o>>>26)+n|0,s+=(n^(o|~c))+r[7]+1126891415|0,s=(s<<10|s>>>22)+o|0,c+=(o^(s|~n))+r[14]-1416354905|0,c=(c<<15|c>>>17)+s|0,n+=(s^(c|~o))+r[5]-57434055|0,n=(n<<21|n>>>11)+c|0,o+=(c^(n|~s))+r[12]+1700485571|0,o=(o<<6|o>>>26)+n|0,s+=(n^(o|~c))+r[3]-1894986606|0,s=(s<<10|s>>>22)+o|0,c+=(o^(s|~n))+r[10]-1051523|0,c=(c<<15|c>>>17)+s|0,n+=(s^(c|~o))+r[1]-2054922799|0,n=(n<<21|n>>>11)+c|0,o+=(c^(n|~s))+r[8]+1873313359|0,o=(o<<6|o>>>26)+n|0,s+=(n^(o|~c))+r[15]-30611744|0,s=(s<<10|s>>>22)+o|0,c+=(o^(s|~n))+r[6]-1560198380|0,c=(c<<15|c>>>17)+s|0,n+=(s^(c|~o))+r[13]+1309151649|0,n=(n<<21|n>>>11)+c|0,o+=(c^(n|~s))+r[4]-145523070|0,o=(o<<6|o>>>26)+n|0,s+=(n^(o|~c))+r[11]-1120210379|0,s=(s<<10|s>>>22)+o|0,c+=(o^(s|~n))+r[2]+718787259|0,c=(c<<15|c>>>17)+s|0,n+=(s^(c|~o))+r[9]-343485551|0,n=(n<<21|n>>>11)+c|0,l[0]=o+l[0]|0,l[1]=n+l[1]|0,l[2]=c+l[2]|0,l[3]=s+l[3]|0}function p(l){var r=[],o;for(o=0;o<64;o+=4)r[o>>2]=l.charCodeAt(o)+(l.charCodeAt(o+1)<<8)+(l.charCodeAt(o+2)<<16)+(l.charCodeAt(o+3)<<24);return r}function m(l){var r=[],o;for(o=0;o<64;o+=4)r[o>>2]=l[o]+(l[o+1]<<8)+(l[o+2]<<16)+(l[o+3]<<24);return r}function d(l){var r=l.length,o=[1732584193,-271733879,-1732584194,271733878],n,c,s,j,S,R;for(n=64;n<=r;n+=64)u(o,p(l.substring(n-64,n)));for(l=l.substring(n-64),c=l.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<c;n+=1)s[n>>2]|=l.charCodeAt(n)<<(n%4<<3);if(s[n>>2]|=128<<(n%4<<3),n>55)for(u(o,s),n=0;n<16;n+=1)s[n]=0;return j=r*8,j=j.toString(16).match(/(.*?)(.{0,8})$/),S=parseInt(j[2],16),R=parseInt(j[1],16)||0,s[14]=S,s[15]=R,u(o,s),o}function f(l){var r=l.length,o=[1732584193,-271733879,-1732584194,271733878],n,c,s,j,S,R;for(n=64;n<=r;n+=64)u(o,m(l.subarray(n-64,n)));for(l=n-64<r?l.subarray(n-64):new Uint8Array(0),c=l.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<c;n+=1)s[n>>2]|=l[n]<<(n%4<<3);if(s[n>>2]|=128<<(n%4<<3),n>55)for(u(o,s),n=0;n<16;n+=1)s[n]=0;return j=r*8,j=j.toString(16).match(/(.*?)(.{0,8})$/),S=parseInt(j[2],16),R=parseInt(j[1],16)||0,s[14]=S,s[15]=R,u(o,s),o}function k(l){var r="",o;for(o=0;o<4;o+=1)r+=a[l>>o*8+4&15]+a[l>>o*8&15];return r}function w(l){var r;for(r=0;r<l.length;r+=1)l[r]=k(l[r]);return l.join("")}w(d("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(e=function(l,r){var o=(l&65535)+(r&65535),n=(l>>16)+(r>>16)+(o>>16);return n<<16|o&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function l(r,o){return r=r|0||0,r<0?Math.max(r+o,0):Math.min(r,o)}ArrayBuffer.prototype.slice=function(r,o){var n=this.byteLength,c=l(r,n),s=n,j,S,R,$e;return o!==i&&(s=l(o,n)),c>s?new ArrayBuffer(0):(j=s-c,S=new ArrayBuffer(j),R=new Uint8Array(S),$e=new Uint8Array(this,c,j),R.set($e),S)}})();function v(l){return/[\u0080-\uFFFF]/.test(l)&&(l=unescape(encodeURIComponent(l))),l}function D(l,r){var o=l.length,n=new ArrayBuffer(o),c=new Uint8Array(n),s;for(s=0;s<o;s+=1)c[s]=l.charCodeAt(s);return r?c:n}function T(l){return String.fromCharCode.apply(null,new Uint8Array(l))}function le(l,r,o){var n=new Uint8Array(l.byteLength+r.byteLength);return n.set(new Uint8Array(l)),n.set(new Uint8Array(r),l.byteLength),o?n:n.buffer}function G(l){var r=[],o=l.length,n;for(n=0;n<o-1;n+=2)r.push(parseInt(l.substr(n,2),16));return String.fromCharCode.apply(String,r)}function b(){this.reset()}return b.prototype.append=function(l){return this.appendBinary(v(l)),this},b.prototype.appendBinary=function(l){this._buff+=l,this._length+=l.length;var r=this._buff.length,o;for(o=64;o<=r;o+=64)u(this._hash,p(this._buff.substring(o-64,o)));return this._buff=this._buff.substring(o-64),this},b.prototype.end=function(l){var r=this._buff,o=r.length,n,c=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s;for(n=0;n<o;n+=1)c[n>>2]|=r.charCodeAt(n)<<(n%4<<3);return this._finish(c,o),s=w(this._hash),l&&(s=G(s)),this.reset(),s},b.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},b.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},b.prototype.setState=function(l){return this._buff=l.buff,this._length=l.length,this._hash=l.hash,this},b.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},b.prototype._finish=function(l,r){var o=r,n,c,s;if(l[o>>2]|=128<<(o%4<<3),o>55)for(u(this._hash,l),o=0;o<16;o+=1)l[o]=0;n=this._length*8,n=n.toString(16).match(/(.*?)(.{0,8})$/),c=parseInt(n[2],16),s=parseInt(n[1],16)||0,l[14]=c,l[15]=s,u(this._hash,l)},b.hash=function(l,r){return b.hashBinary(v(l),r)},b.hashBinary=function(l,r){var o=d(l),n=w(o);return r?G(n):n},b.ArrayBuffer=function(){this.reset()},b.ArrayBuffer.prototype.append=function(l){var r=le(this._buff.buffer,l,!0),o=r.length,n;for(this._length+=l.byteLength,n=64;n<=o;n+=64)u(this._hash,m(r.subarray(n-64,n)));return this._buff=n-64<o?new Uint8Array(r.buffer.slice(n-64)):new Uint8Array(0),this},b.ArrayBuffer.prototype.end=function(l){var r=this._buff,o=r.length,n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c,s;for(c=0;c<o;c+=1)n[c>>2]|=r[c]<<(c%4<<3);return this._finish(n,o),s=w(this._hash),l&&(s=G(s)),this.reset(),s},b.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},b.ArrayBuffer.prototype.getState=function(){var l=b.prototype.getState.call(this);return l.buff=T(l.buff),l},b.ArrayBuffer.prototype.setState=function(l){return l.buff=D(l.buff,!0),b.prototype.setState.call(this,l)},b.ArrayBuffer.prototype.destroy=b.prototype.destroy,b.ArrayBuffer.prototype._finish=b.prototype._finish,b.ArrayBuffer.hash=function(l,r){var o=f(new Uint8Array(l)),n=w(o);return r?G(n):n},b})});var De=Y((Pi,pa)=>{"use strict";pa.exports={}});async function Ga(i){let e=(await Promise.resolve().then(()=>L(ra(),1))).default;return new Promise((a,t)=>{let p=Math.ceil(i.size/2097152),m=0,d=new e.ArrayBuffer,f=new FileReader,k=()=>{let w=m*2097152,v=Math.min(w+2097152,i.size);f.readAsArrayBuffer(i.slice(w,v))};f.onload=w=>{let v=w.target?.result;if(!v){t(x.business("Failed to read file chunk"));return}d.append(v),m++,m<p?k():a({md5:d.end()})},f.onerror=()=>{t(x.business("Failed to calculate MD5: FileReader error"))},k()})}async function Wa(i){let e=await Promise.resolve().then(()=>L(De(),1));if(Buffer.isBuffer(i)){let t=e.createHash("md5");return t.update(i),{md5:t.digest("hex")}}let a=await Promise.resolve().then(()=>L(De(),1));return new Promise((t,u)=>{let p=e.createHash("md5"),m=a.createReadStream(i);m.on("error",d=>u(x.business(`Failed to read file for MD5: ${d.message}`))),m.on("data",d=>p.update(d)),m.on("end",()=>t({md5:p.digest("hex")}))})}async function se(i){let e=U();if(e==="browser"){if(!(i instanceof Blob))throw x.business("Invalid input for browser MD5 calculation: Expected Blob or File.");return Ga(i)}if(e==="node"){if(!(Buffer.isBuffer(i)||typeof i=="string"))throw x.business("Invalid input for Node.js MD5 calculation: Expected Buffer or file path string.");return Wa(i)}throw x.business("Unknown or unsupported execution environment for MD5 calculation.")}var te=A(()=>{"use strict";O();F()});function va(i){return Xa.test(i)}var Ja,Xa,fa=A(()=>{"use strict";Ja=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],Xa=new RegExp(Ja.join("|"))});function ba(i){return!i||i.length===0?[]:i.filter(e=>{if(!e)return!1;let a=e.replace(/\\/g,"/").split("/").filter(Boolean);if(a.length===0)return!0;let t=a[a.length-1];if(va(t))return!1;let u=a.slice(0,-1);for(let p of u)if(Za.some(m=>p.toLowerCase()===m.toLowerCase()))return!1;return!0})}var Za,Se=A(()=>{"use strict";fa();Za=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function re(i){return i.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var ha=A(()=>{"use strict"});function ga(i,e={}){if(e.flatten===!1)return i.map(t=>({path:re(t),name:Ae(t)}));let a=Qa(i);return i.map(t=>{let u=re(t);if(a){let p=a.endsWith("/")?a:`${a}/`;u.startsWith(p)&&(u=u.substring(p.length))}return u||(u=Ae(t)),{path:u,name:Ae(t)}})}function Qa(i){if(!i.length)return"";let a=i.map(p=>re(p)).map(p=>p.split("/")),t=[],u=Math.min(...a.map(p=>p.length));for(let p=0;p<u-1;p++){let m=a[0][p];if(a.every(d=>d[p]===m))t.push(m);else break}return t.join("/")}function Ae(i){return i.split(/[/\\]/).pop()||i}var ze=A(()=>{"use strict";ha()});var wa={};ue(wa,{processFilesForBrowser:()=>ya});async function ya(i,e={}){let{getENV:a}=await Promise.resolve().then(()=>(O(),Me));if(a()!=="browser")throw x.business("processFilesForBrowser can only be called in a browser environment.");let t=i,u=t.map(v=>v.webkitRelativePath||v.name),p=ga(u,{flatten:e.pathDetect!==!1}),m=[];for(let v=0;v<t.length;v++){let D=t[v],T=p[v].path;if(T.includes("..")||T.includes("\0"))throw x.business(`Security error: Unsafe file path "${T}" for file: ${D.name}`);m.push({file:D,relativePath:T})}let d=m.map(v=>v.relativePath),f=ba(d),k=new Set(f),w=[];for(let v of m){if(!k.has(v.relativePath))continue;let{md5:D}=await se(v.file);w.push({content:v.file,path:v.relativePath,size:v.file.size,md5:D})}return w}var Pe=A(()=>{"use strict";te();F();Se();ze()});var de=L(me(),1),xe={};for(let i in de.default){let e=de.default[i];e&&e.extensions&&e.extensions.forEach(a=>{xe[a]||(xe[a]=i)})}function X(i){let e=i.includes(".")?i.substring(i.lastIndexOf(".")+1).toLowerCase():"";return xe[e]||"application/octet-stream"}F();var Q=class{constructor(){this.handlers=new Map}on(e,a){this.handlers.has(e)||this.handlers.set(e,new Set),this.handlers.get(e).add(a)}off(e,a){let t=this.handlers.get(e);t&&(t.delete(a),t.size===0&&this.handlers.delete(e))}emit(e,...a){let t=this.handlers.get(e);if(!t)return;let u=Array.from(t);for(let p of u)try{p(...a)}catch(m){t.delete(p),e!=="error"&&setTimeout(()=>{m instanceof Error?this.emit("error",m,String(e)):this.emit("error",new Error(String(m)),String(e))},0)}}transfer(e){this.handlers.forEach((a,t)=>{a.forEach(u=>{e.on(t,u)})})}clear(){this.handlers.clear()}};O();var ne="/deployments",na="/ping",E="/domains",Ka="/config",Ha="/account",je="/tokens",Va="/spa-check",oe=class extends Q{constructor(e){super(),this.apiUrl=e.apiUrl||Z,this.getAuthHeadersCallback=e.getAuthHeaders}transferEventsTo(e){this.transfer(e)}async request(e,a={},t){let u=this.getAuthHeaders(a.headers),p={...a,headers:u,credentials:u.Authorization?void 0:"include"};this.emit("request",e,p);try{let m=await fetch(e,p);m.ok||await this.handleResponseError(m,t);let d=this.safeClone(m),f=this.safeClone(m);return this.emit("response",d,e),await this.parseResponse(f)}catch(m){throw this.emit("error",m,e),this.handleFetchError(m,t),m}}getAuthHeaders(e={}){let a=this.getAuthHeadersCallback();return{...e,...a}}safeClone(e){try{return e.clone()}catch{return e}}async parseResponse(e){if(!(e.headers.get("Content-Length")==="0"||e.status===204))return await e.json()}async handleResponseError(e,a){let t={};try{e.headers.get("content-type")?.includes("application/json")?t=await e.json():t={message:await e.text()}}catch{t={message:"Failed to parse error response"}}let u=t.message||t.error||`${a} failed due to API error`;throw e.status===401?x.authentication(u):x.api(u,e.status,t.code,t)}handleFetchError(e,a){throw e.name==="AbortError"?x.cancelled(`${a} operation was cancelled.`):e instanceof TypeError&&e.message.includes("fetch")?x.network(`${a} failed due to network error: ${e.message}`,e):e instanceof x?e:x.business(`An unexpected error occurred during ${a}: ${e.message||"Unknown error"}`)}async ping(){return(await this.request(`${this.apiUrl}${na}`,{method:"GET"},"Ping"))?.success||!1}async getPingResponse(){return await this.request(`${this.apiUrl}${na}`,{method:"GET"},"Ping")}async getConfig(){return await this.request(`${this.apiUrl}${Ka}`,{method:"GET"},"Config")}async deploy(e,a={}){this.validateFiles(e);let{requestBody:t,requestHeaders:u}=await this.prepareRequestPayload(e,a.tags),p={};a.deployToken?p={Authorization:`Bearer ${a.deployToken}`}:a.apiKey&&(p={Authorization:`Bearer ${a.apiKey}`});let m={method:"POST",body:t,headers:{...u,...p},signal:a.signal||null};return await this.request(`${a.apiUrl||this.apiUrl}${ne}`,m,"Deploy")}async listDeployments(){return await this.request(`${this.apiUrl}${ne}`,{method:"GET"},"List Deployments")}async getDeployment(e){return await this.request(`${this.apiUrl}${ne}/${e}`,{method:"GET"},"Get Deployment")}async removeDeployment(e){await this.request(`${this.apiUrl}${ne}/${e}`,{method:"DELETE"},"Remove Deployment")}async setDomain(e,a,t){let u={deployment:a};t&&t.length>0&&(u.tags=t);let p={method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)},m=this.getAuthHeaders(p.headers),d={...p,headers:m,credentials:m.Authorization?void 0:"include"};this.emit("request",`${this.apiUrl}${E}/${encodeURIComponent(e)}`,d);try{let f=await fetch(`${this.apiUrl}${E}/${encodeURIComponent(e)}`,d);f.ok||await this.handleResponseError(f,"Set Domain");let k=this.safeClone(f),w=this.safeClone(f);return this.emit("response",k,`${this.apiUrl}${E}/${encodeURIComponent(e)}`),{...await this.parseResponse(w),isCreate:f.status===201}}catch(f){throw this.emit("error",f,`${this.apiUrl}${E}/${encodeURIComponent(e)}`),this.handleFetchError(f,"Set Domain"),f}}async getDomain(e){return await this.request(`${this.apiUrl}${E}/${encodeURIComponent(e)}`,{method:"GET"},"Get Domain")}async listDomains(){return await this.request(`${this.apiUrl}${E}`,{method:"GET"},"List Domains")}async removeDomain(e){await this.request(`${this.apiUrl}${E}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove Domain")}async confirmDomain(e){return await this.request(`${this.apiUrl}${E}/${encodeURIComponent(e)}/confirm`,{method:"POST"},"Confirm Domain")}async getDomainDns(e){return await this.request(`${this.apiUrl}${E}/${encodeURIComponent(e)}/dns`,{method:"GET"},"Get Domain DNS")}async getDomainRecords(e){return await this.request(`${this.apiUrl}${E}/${encodeURIComponent(e)}/records`,{method:"GET"},"Get Domain Records")}async getDomainShare(e){return await this.request(`${this.apiUrl}${E}/${encodeURIComponent(e)}/share`,{method:"GET"},"Get Domain Share")}async getAccount(){return await this.request(`${this.apiUrl}${Ha}`,{method:"GET"},"Get Account")}async createToken(e,a){let t={};return e!==void 0&&(t.ttl=e),a&&a.length>0&&(t.tags=a),await this.request(`${this.apiUrl}${je}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},"Create Token")}async listTokens(){return await this.request(`${this.apiUrl}${je}`,{method:"GET"},"List Tokens")}async removeToken(e){await this.request(`${this.apiUrl}${je}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove Token")}async checkSPA(e){let a=e.find(m=>m.path==="index.html"||m.path==="/index.html");if(!a||a.size>100*1024)return!1;let t;if(typeof Buffer<"u"&&Buffer.isBuffer(a.content))t=a.content.toString("utf-8");else if(typeof Blob<"u"&&a.content instanceof Blob)t=await a.content.text();else if(typeof File<"u"&&a.content instanceof File)t=await a.content.text();else return!1;let u={files:e.map(m=>m.path),index:t};return(await this.request(`${this.apiUrl}${Va}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)},"SPA Check")).isSPA}validateFiles(e){if(!e.length)throw x.business("No files to deploy.");for(let a of e)if(!a.md5)throw x.file(`MD5 checksum missing for file: ${a.path}`,a.path)}async prepareRequestPayload(e,a){if(U()==="browser")return{requestBody:this.createBrowserBody(e,a),requestHeaders:{}};if(U()==="node"){let{body:t,headers:u}=await this.createNodeBody(e,a);return{requestBody:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),requestHeaders:u}}else throw x.business("Unknown or unsupported execution environment")}createBrowserBody(e,a){let t=new FormData,u=[];for(let p of e){if(!(p.content instanceof File||p.content instanceof Blob))throw x.file(`Unsupported file.content type for browser FormData: ${p.path}`,p.path);let m=this.getBrowserContentType(p.content instanceof File?p.content:p.path),d=new File([p.content],p.path,{type:m});t.append("files[]",d),u.push(p.md5)}return t.append("checksums",JSON.stringify(u)),a&&a.length>0&&t.append("tags",JSON.stringify(a)),t}async createNodeBody(e,a){let{FormData:t,File:u}=await import("formdata-node"),{FormDataEncoder:p}=await Promise.resolve().then(()=>(ia(),aa)),m=new t,d=[];for(let v of e){let D=X(v.path),T;if(Buffer.isBuffer(v.content))T=new u([v.content],v.path,{type:D});else if(typeof Blob<"u"&&v.content instanceof Blob)T=new u([v.content],v.path,{type:D});else throw x.file(`Unsupported file.content type for Node.js FormData: ${v.path}`,v.path);let le=v.path.startsWith("/")?v.path:"/"+v.path;m.append("files[]",T,le),d.push(v.md5)}m.append("checksums",JSON.stringify(d)),a&&a.length>0&&m.append("tags",JSON.stringify(a));let f=new p(m),k=[];for await(let v of f.encode())k.push(Buffer.from(v));let w=Buffer.concat(k);return{body:w,headers:{"Content-Type":f.contentType,"Content-Length":Buffer.byteLength(w).toString()}}}getBrowserContentType(e){return typeof e=="string"?X(e):e.type||X(e.name)}};F();F();var Fe=null;function Ee(i){Fe=i}function Te(){if(Fe===null)throw x.config("Platform configuration not initialized. The SDK must fetch configuration from the API before performing operations.");return Fe}F();function oa(i={},e={}){let a={apiUrl:i.apiUrl||e.apiUrl||Z,apiKey:i.apiKey!==void 0?i.apiKey:e.apiKey,deployToken:i.deployToken!==void 0?i.deployToken:e.deployToken},t={apiUrl:a.apiUrl};return a.apiKey!==void 0&&(t.apiKey=a.apiKey),a.deployToken!==void 0&&(t.deployToken=a.deployToken),t}function sa(i,e){let a={...i};return a.apiUrl===void 0&&e.apiUrl!==void 0&&(a.apiUrl=e.apiUrl),a.apiKey===void 0&&e.apiKey!==void 0&&(a.apiKey=e.apiKey),a.deployToken===void 0&&e.deployToken!==void 0&&(a.deployToken=e.deployToken),a.timeout===void 0&&e.timeout!==void 0&&(a.timeout=e.timeout),a.maxConcurrency===void 0&&e.maxConcurrency!==void 0&&(a.maxConcurrency=e.maxConcurrency),a.onProgress===void 0&&e.onProgress!==void 0&&(a.onProgress=e.onProgress),a}F();te();async function Ya(){let e=JSON.stringify({rewrites:[{source:"/(.*)",destination:"/index.html"}]},null,2),a;typeof Buffer<"u"?a=Buffer.from(e,"utf-8"):a=new Blob([e],{type:"application/json"});let{md5:t}=await se(a);return{path:he,content:a,size:e.length,md5:t}}async function la(i,e,a){if(a.spaDetect===!1||i.some(t=>t.path===he))return i;try{if(await e.checkSPA(i)){let u=await Ya();return[...i,u]}}catch{}return i}function ua(i,e,a,t,u){return{create:async(p,m={})=>{if(u&&!u()&&!m.deployToken&&!m.apiKey)throw new Error("Authentication credentials are required for deployment. Please call setDeployToken() or setApiKey() first, or pass credentials in the deployment options.");a&&await a();let d=e?sa(m,e):m,f=i();if(!t)throw new Error("processInput function is not provided.");let k=await t(p,d);return k=await la(k,f,d),await f.deploy(k,d)},list:async()=>(a&&await a(),i().listDeployments()),remove:async p=>{a&&await a(),await i().removeDeployment(p)},get:async p=>(a&&await a(),i().getDeployment(p))}}function ma(i,e){return{set:async(a,t,u)=>(e&&await e(),i().setDomain(a,t,u)),get:async a=>(e&&await e(),i().getDomain(a)),list:async()=>(e&&await e(),i().listDomains()),remove:async a=>{e&&await e(),await i().removeDomain(a)},confirm:async a=>(e&&await e(),i().confirmDomain(a)),dns:async a=>(e&&await e(),i().getDomainDns(a)),records:async a=>(e&&await e(),i().getDomainRecords(a)),share:async a=>(e&&await e(),i().getDomainShare(a))}}function da(i,e){return{get:async()=>(e&&await e(),i().getAccount())}}function xa(i,e){return{create:async(a,t)=>(e&&await e(),i().createToken(a,t)),list:async()=>(e&&await e(),i().listTokens()),remove:async a=>{e&&await e(),await i().removeToken(a)}}}var ce=class{constructor(e={}){this.initPromise=null;this._config=null;this.auth=null;this.clientOptions=e,e.deployToken?this.auth={type:"token",value:e.deployToken}:e.apiKey&&(this.auth={type:"apiKey",value:e.apiKey}),this.authHeadersCallback=()=>this.getAuthHeaders();let a=this.resolveInitialConfig(e);this.http=new oe({...e,...a,getAuthHeaders:this.authHeadersCallback});let t=()=>this.ensureInitialized(),u=()=>this.http;this._deployments=ua(u,this.clientOptions,t,(p,m)=>this.processInput(p,m),()=>this.hasAuth()),this._domains=ma(u,t),this._account=da(u,t),this._tokens=xa(u,t)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.loadFullConfig()),this.initPromise}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(e,a){return this.deployments.create(e,a)}async whoami(){return this.account.get()}get deployments(){return this._deployments}get domains(){return this._domains}get account(){return this._account}get tokens(){return this._tokens}async getConfig(){return this._config?this._config:(await this.ensureInitialized(),this._config=Te(),this._config)}on(e,a){this.http.on(e,a)}off(e,a){this.http.off(e,a)}replaceHttpClient(e){if(this.http?.transferEventsTo)try{this.http.transferEventsTo(e)}catch(a){console.warn("Event transfer failed during client replacement:",a)}this.http=e}setDeployToken(e){if(!e||typeof e!="string")throw x.business("Invalid deploy token provided. Deploy token must be a non-empty string.");this.auth={type:"token",value:e}}setApiKey(e){if(!e||typeof e!="string")throw x.business("Invalid API key provided. API key must be a non-empty string.");this.auth={type:"apiKey",value:e}}getAuthHeaders(){if(!this.auth)return{};switch(this.auth.type){case"token":return{Authorization:`Bearer ${this.auth.value}`};case"apiKey":return{Authorization:`Bearer ${this.auth.value}`};default:return{}}}hasAuth(){return this.clientOptions.useCredentials?!0:this.auth!==null}};F();te();function Wi(i,e,a,t=!0){let u=i===1?e:a;return t?`${i} ${u}`:u}Se();ze();O();F();var Re=L(me(),1),ei=new Set(Object.keys(Re.default)),ai=new Map(Object.entries(Re.default).filter(([i,e])=>e.extensions).map(([i,e])=>[i,new Set(e.extensions)]));function Ce(i,e=1){if(i===0)return"0 Bytes";let a=1024,t=["Bytes","KB","MB","GB"],u=Math.floor(Math.log(i)/Math.log(a));return parseFloat((i/Math.pow(a,u)).toFixed(e))+" "+t[u]}function ii(i){if(/[?&#%<>\[\]{}|\\^~`;$()'"*\r\n\t]/.test(i))return{valid:!1,reason:"File name contains unsafe characters"};if(i.startsWith(".")===!1&&(i.startsWith(" ")||i.endsWith(" ")||i.endsWith(".")))return{valid:!1,reason:"File name cannot start/end with spaces or end with dots"};let a=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,t=i.split("/").pop()||i;return a.test(t)?{valid:!1,reason:"File name uses a reserved system name"}:i.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function ni(i,e){if(i.startsWith("."))return!0;let a=i.toLowerCase().split(".");if(a.length>1&&a[a.length-1]){let t=a[a.length-1],u=ai.get(e);if(u&&!u.has(t))return!1}return!0}function on(i,e){let a=[],t=[];if(i.length===0){let p="At least one file must be provided";return{files:[],validFiles:[],error:{error:"No Files Provided",details:p,errors:[p],isClientError:!0}}}if(i.length>e.maxFilesCount){let p=`Number of files (${i.length}) exceeds the limit of ${e.maxFilesCount}.`;return{files:i.map(m=>({...m,status:y.VALIDATION_FAILED,statusMessage:p})),validFiles:[],error:{error:"File Count Exceeded",details:p,errors:[p],isClientError:!0}}}let u=0;for(let p of i){let m=y.READY,d="Ready for upload",f=p.name?ii(p.name):{valid:!1,reason:"File name cannot be empty"};p.status===y.PROCESSING_ERROR?(m=y.PROCESSING_ERROR,d=p.statusMessage||"A file failed during processing.",a.push(`${p.name}: ${d}`)):!p.name||p.name.trim().length===0?(m=y.VALIDATION_FAILED,d="File name cannot be empty",a.push(`${p.name||"(empty)"}: ${d}`)):p.name.includes("\0")?(m=y.VALIDATION_FAILED,d="File name contains invalid characters (null byte)",a.push(`${p.name}: ${d}`)):f.valid?p.size<=0?(m=y.EMPTY_FILE,d=p.size===0?"File is empty (0 bytes)":"File size must be positive",a.push(`${p.name}: ${d}`)):!p.type||p.type.trim().length===0?(m=y.VALIDATION_FAILED,d="File MIME type is required",a.push(`${p.name}: ${d}`)):e.allowedMimeTypes.some(k=>p.type.startsWith(k))?ei.has(p.type)?ni(p.name,p.type)?p.size>e.maxFileSize?(m=y.VALIDATION_FAILED,d=`File size (${Ce(p.size)}) exceeds limit of ${Ce(e.maxFileSize)}`,a.push(`${p.name}: ${d}`)):(u+=p.size,u>e.maxTotalSize&&(m=y.VALIDATION_FAILED,d=`Total size would exceed limit of ${Ce(e.maxTotalSize)}`,a.push(`${p.name}: ${d}`))):(m=y.VALIDATION_FAILED,d="File extension does not match MIME type",a.push(`${p.name}: ${d}`)):(m=y.VALIDATION_FAILED,d=`Invalid MIME type "${p.type}"`,a.push(`${p.name}: ${d}`)):(m=y.VALIDATION_FAILED,d=`File type "${p.type}" is not allowed`,a.push(`${p.name}: ${d}`)):(m=y.VALIDATION_FAILED,d=f.reason||"Invalid file name",a.push(`${p.name}: ${d}`)),t.push({...p,status:m,statusMessage:d})}if(a.length>0){let p=t.find(d=>d.status!==y.READY&&d.status!==y.PENDING),m="Validation Failed";return p?.status===y.PROCESSING_ERROR?m="Processing Error":p?.status===y.EMPTY_FILE?m="Empty File":p?.statusMessage?.includes("File name cannot be empty")||p?.statusMessage?.includes("Invalid file name")||p?.statusMessage?.includes("File name contains")||p?.statusMessage?.includes("File name uses")||p?.statusMessage?.includes("File name cannot start")||p?.statusMessage?.includes("traversal")?m="Invalid File Name":p?.statusMessage?.includes("File size must be positive")?m="Invalid File Size":p?.statusMessage?.includes("MIME type is required")?m="Missing MIME Type":p?.statusMessage?.includes("Invalid MIME type")?m="Invalid MIME Type":p?.statusMessage?.includes("not allowed")?m="Invalid File Type":p?.statusMessage?.includes("extension does not match")?m="Extension Mismatch":p?.statusMessage?.includes("Total size")?m="Total Size Exceeded":p?.statusMessage?.includes("exceeds limit")&&(m="File Too Large"),{files:t.map(d=>({...d,status:y.VALIDATION_FAILED})),validFiles:[],error:{error:m,details:a.length===1?a[0]:`${a.length} file(s) failed validation`,errors:a,isClientError:!0}}}return{files:t,validFiles:t,error:null}}function oi(i){return i.filter(e=>e.status===y.READY)}function sn(i){return oi(i).length>0}F();async function si(i){return{}}Pe();var pe,ka,_e=class extends ce{constructor(a={}){super(a);qe(this,pe)}resolveInitialConfig(a){return oa(a,{})}async loadFullConfig(){try{let a=await this.http.getConfig();Ee(a)}catch(a){throw this.initPromise=null,a}}async processInput(a,t){if(!Ue(this,pe,ka).call(this,a))throw x.business("Invalid input type for browser environment. Expected File[].");let{processFilesForBrowser:u}=await Promise.resolve().then(()=>(Pe(),wa));return u(a,t)}};pe=new WeakSet,ka=function(a){return Array.isArray(a)?a.length===0||a.every(t=>t instanceof File):!1};var An=_e;export{fe as API_KEY_HEX_LENGTH,I as API_KEY_PREFIX,Ne as API_KEY_TOTAL_LENGTH,mi as AccountPlan,oe as ApiHttp,di as AuthMethod,Z as DEFAULT_API,he as DEPLOYMENT_CONFIG_FILENAME,be as DEPLOY_TOKEN_HEX_LENGTH,q as DEPLOY_TOKEN_PREFIX,Be as DEPLOY_TOKEN_TOTAL_LENGTH,li as DeploymentStatus,ui as DomainStatus,h as ErrorType,y as FILE_VALIDATION_STATUS,y as FileValidationStatus,Za as JUNK_DIRECTORIES,_e as Ship,x as ShipError,Ra as ShipErrorType,Pa as __setTestEnvironment,sn as allValidFilesReady,se as calculateMD5,da as createAccountResource,ua as createDeploymentResource,ma as createDomainResource,xa as createTokenResource,An as default,ba as filterJunk,Ce as formatFileSize,hi as generateDeploymentUrl,gi as generateDomainUrl,Te as getCurrentConfig,U as getENV,oi as getValidFiles,si as loadConfig,sa as mergeDeployOptions,ga as optimizeDeployPaths,Wi as pluralize,ya as processFilesForBrowser,oa as resolveConfig,Ee as setPlatformConfig,xi as validateApiKey,fi as validateApiUrl,vi as validateDeployToken,on as validateFiles,bi as validateSubdomain};
|
|
5
|
+
`),z(this,B),z(this,ae),z(this,M,"-".repeat(2)),z(this,_,new TextEncoder),z(this,K),z(this,H),z(this,ie),!Ze(i))throw new TypeError("Expected first argument to be a FormData instance.");let t;if(We(e)?a=e:t=e,t||(t=`form-data-encoder-${$a()}`),typeof t!="string")throw new TypeError("Expected boundary argument to be a string.");if(a&&!We(a))throw new TypeError("Expected options argument to be an object.");N(this,H,Array.from(i.entries())),N(this,ie,{...Ba,...a}),N(this,B,g(this,_).encode(g(this,P))),N(this,ae,g(this,B).byteLength),this.boundary=t,this.contentType=`multipart/form-data; boundary=${this.boundary}`,N(this,K,g(this,_).encode(`${g(this,M)}${this.boundary}${g(this,M)}${g(this,P).repeat(2)}`));let u={"Content-Type":this.contentType},p=ye(this,V,ea).call(this);p&&(this.contentLength=p,u["Content-Length"]=p),this.headers=Na(Object.freeze(u)),Object.defineProperties(this,{boundary:ee,contentType:ee,contentLength:ee,headers:ee})}*values(){for(let[i,e]of g(this,H)){let a=$(e)?e:g(this,_).encode(Qe(e));yield ye(this,V,ke).call(this,i,a),yield a,yield g(this,B)}yield g(this,K)}async*encode(){for(let i of this.values())$(i)?yield*La(i.stream()):yield*Xe(i)}[Symbol.iterator](){return this.values()}[Symbol.asyncIterator](){return this.encode()}};P=new WeakMap;B=new WeakMap;ae=new WeakMap;M=new WeakMap;_=new WeakMap;K=new WeakMap;H=new WeakMap;ie=new WeakMap;V=new WeakSet;ke=function(i,e){let a="";if(a+=`${g(this,M)}${this.boundary}${g(this,P)}`,a+=`Content-Disposition: form-data; name="${Ve(i)}"`,$(e)&&(a+=`; filename="${Ve(e.name)}"${g(this,P)}`,a+=`Content-Type: ${e.type||"application/octet-stream"}`),g(this,ie).enableAdditionalHeaders===!0){let t=$(e)?e.size:e.byteLength;t!=null&&!isNaN(t)&&(a+=`${g(this,P)}Content-Length: ${t}`)}return g(this,_).encode(`${a}${g(this,P).repeat(2)}`)};ea=function(){let i=0;for(let[e,a]of g(this,H)){let t=$(a)?a:g(this,_).encode(Qe(a)),u=$(t)?t.size:t.byteLength;if(u==null||isNaN(u))return;i+=ye(this,V,ke).call(this,e,t).byteLength,i+=u,i+=g(this,ae)}return String(i+g(this,K).byteLength)}});var ra=Y((ta,ca)=>{"use strict";(function(i){if(typeof ta=="object")ca.exports=i();else if(typeof define=="function"&&define.amd)define(i);else{var e;try{e=window}catch{e=self}e.SparkMD5=i()}})(function(i){"use strict";var e=function(l,r){return l+r&4294967295},a=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function t(l,r,o,n,c,s){return r=e(e(r,l),e(n,s)),e(r<<c|r>>>32-c,o)}function u(l,r){var o=l[0],n=l[1],c=l[2],s=l[3];o+=(n&c|~n&s)+r[0]-680876936|0,o=(o<<7|o>>>25)+n|0,s+=(o&n|~o&c)+r[1]-389564586|0,s=(s<<12|s>>>20)+o|0,c+=(s&o|~s&n)+r[2]+606105819|0,c=(c<<17|c>>>15)+s|0,n+=(c&s|~c&o)+r[3]-1044525330|0,n=(n<<22|n>>>10)+c|0,o+=(n&c|~n&s)+r[4]-176418897|0,o=(o<<7|o>>>25)+n|0,s+=(o&n|~o&c)+r[5]+1200080426|0,s=(s<<12|s>>>20)+o|0,c+=(s&o|~s&n)+r[6]-1473231341|0,c=(c<<17|c>>>15)+s|0,n+=(c&s|~c&o)+r[7]-45705983|0,n=(n<<22|n>>>10)+c|0,o+=(n&c|~n&s)+r[8]+1770035416|0,o=(o<<7|o>>>25)+n|0,s+=(o&n|~o&c)+r[9]-1958414417|0,s=(s<<12|s>>>20)+o|0,c+=(s&o|~s&n)+r[10]-42063|0,c=(c<<17|c>>>15)+s|0,n+=(c&s|~c&o)+r[11]-1990404162|0,n=(n<<22|n>>>10)+c|0,o+=(n&c|~n&s)+r[12]+1804603682|0,o=(o<<7|o>>>25)+n|0,s+=(o&n|~o&c)+r[13]-40341101|0,s=(s<<12|s>>>20)+o|0,c+=(s&o|~s&n)+r[14]-1502002290|0,c=(c<<17|c>>>15)+s|0,n+=(c&s|~c&o)+r[15]+1236535329|0,n=(n<<22|n>>>10)+c|0,o+=(n&s|c&~s)+r[1]-165796510|0,o=(o<<5|o>>>27)+n|0,s+=(o&c|n&~c)+r[6]-1069501632|0,s=(s<<9|s>>>23)+o|0,c+=(s&n|o&~n)+r[11]+643717713|0,c=(c<<14|c>>>18)+s|0,n+=(c&o|s&~o)+r[0]-373897302|0,n=(n<<20|n>>>12)+c|0,o+=(n&s|c&~s)+r[5]-701558691|0,o=(o<<5|o>>>27)+n|0,s+=(o&c|n&~c)+r[10]+38016083|0,s=(s<<9|s>>>23)+o|0,c+=(s&n|o&~n)+r[15]-660478335|0,c=(c<<14|c>>>18)+s|0,n+=(c&o|s&~o)+r[4]-405537848|0,n=(n<<20|n>>>12)+c|0,o+=(n&s|c&~s)+r[9]+568446438|0,o=(o<<5|o>>>27)+n|0,s+=(o&c|n&~c)+r[14]-1019803690|0,s=(s<<9|s>>>23)+o|0,c+=(s&n|o&~n)+r[3]-187363961|0,c=(c<<14|c>>>18)+s|0,n+=(c&o|s&~o)+r[8]+1163531501|0,n=(n<<20|n>>>12)+c|0,o+=(n&s|c&~s)+r[13]-1444681467|0,o=(o<<5|o>>>27)+n|0,s+=(o&c|n&~c)+r[2]-51403784|0,s=(s<<9|s>>>23)+o|0,c+=(s&n|o&~n)+r[7]+1735328473|0,c=(c<<14|c>>>18)+s|0,n+=(c&o|s&~o)+r[12]-1926607734|0,n=(n<<20|n>>>12)+c|0,o+=(n^c^s)+r[5]-378558|0,o=(o<<4|o>>>28)+n|0,s+=(o^n^c)+r[8]-2022574463|0,s=(s<<11|s>>>21)+o|0,c+=(s^o^n)+r[11]+1839030562|0,c=(c<<16|c>>>16)+s|0,n+=(c^s^o)+r[14]-35309556|0,n=(n<<23|n>>>9)+c|0,o+=(n^c^s)+r[1]-1530992060|0,o=(o<<4|o>>>28)+n|0,s+=(o^n^c)+r[4]+1272893353|0,s=(s<<11|s>>>21)+o|0,c+=(s^o^n)+r[7]-155497632|0,c=(c<<16|c>>>16)+s|0,n+=(c^s^o)+r[10]-1094730640|0,n=(n<<23|n>>>9)+c|0,o+=(n^c^s)+r[13]+681279174|0,o=(o<<4|o>>>28)+n|0,s+=(o^n^c)+r[0]-358537222|0,s=(s<<11|s>>>21)+o|0,c+=(s^o^n)+r[3]-722521979|0,c=(c<<16|c>>>16)+s|0,n+=(c^s^o)+r[6]+76029189|0,n=(n<<23|n>>>9)+c|0,o+=(n^c^s)+r[9]-640364487|0,o=(o<<4|o>>>28)+n|0,s+=(o^n^c)+r[12]-421815835|0,s=(s<<11|s>>>21)+o|0,c+=(s^o^n)+r[15]+530742520|0,c=(c<<16|c>>>16)+s|0,n+=(c^s^o)+r[2]-995338651|0,n=(n<<23|n>>>9)+c|0,o+=(c^(n|~s))+r[0]-198630844|0,o=(o<<6|o>>>26)+n|0,s+=(n^(o|~c))+r[7]+1126891415|0,s=(s<<10|s>>>22)+o|0,c+=(o^(s|~n))+r[14]-1416354905|0,c=(c<<15|c>>>17)+s|0,n+=(s^(c|~o))+r[5]-57434055|0,n=(n<<21|n>>>11)+c|0,o+=(c^(n|~s))+r[12]+1700485571|0,o=(o<<6|o>>>26)+n|0,s+=(n^(o|~c))+r[3]-1894986606|0,s=(s<<10|s>>>22)+o|0,c+=(o^(s|~n))+r[10]-1051523|0,c=(c<<15|c>>>17)+s|0,n+=(s^(c|~o))+r[1]-2054922799|0,n=(n<<21|n>>>11)+c|0,o+=(c^(n|~s))+r[8]+1873313359|0,o=(o<<6|o>>>26)+n|0,s+=(n^(o|~c))+r[15]-30611744|0,s=(s<<10|s>>>22)+o|0,c+=(o^(s|~n))+r[6]-1560198380|0,c=(c<<15|c>>>17)+s|0,n+=(s^(c|~o))+r[13]+1309151649|0,n=(n<<21|n>>>11)+c|0,o+=(c^(n|~s))+r[4]-145523070|0,o=(o<<6|o>>>26)+n|0,s+=(n^(o|~c))+r[11]-1120210379|0,s=(s<<10|s>>>22)+o|0,c+=(o^(s|~n))+r[2]+718787259|0,c=(c<<15|c>>>17)+s|0,n+=(s^(c|~o))+r[9]-343485551|0,n=(n<<21|n>>>11)+c|0,l[0]=o+l[0]|0,l[1]=n+l[1]|0,l[2]=c+l[2]|0,l[3]=s+l[3]|0}function p(l){var r=[],o;for(o=0;o<64;o+=4)r[o>>2]=l.charCodeAt(o)+(l.charCodeAt(o+1)<<8)+(l.charCodeAt(o+2)<<16)+(l.charCodeAt(o+3)<<24);return r}function m(l){var r=[],o;for(o=0;o<64;o+=4)r[o>>2]=l[o]+(l[o+1]<<8)+(l[o+2]<<16)+(l[o+3]<<24);return r}function d(l){var r=l.length,o=[1732584193,-271733879,-1732584194,271733878],n,c,s,j,S,R;for(n=64;n<=r;n+=64)u(o,p(l.substring(n-64,n)));for(l=l.substring(n-64),c=l.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<c;n+=1)s[n>>2]|=l.charCodeAt(n)<<(n%4<<3);if(s[n>>2]|=128<<(n%4<<3),n>55)for(u(o,s),n=0;n<16;n+=1)s[n]=0;return j=r*8,j=j.toString(16).match(/(.*?)(.{0,8})$/),S=parseInt(j[2],16),R=parseInt(j[1],16)||0,s[14]=S,s[15]=R,u(o,s),o}function f(l){var r=l.length,o=[1732584193,-271733879,-1732584194,271733878],n,c,s,j,S,R;for(n=64;n<=r;n+=64)u(o,m(l.subarray(n-64,n)));for(l=n-64<r?l.subarray(n-64):new Uint8Array(0),c=l.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<c;n+=1)s[n>>2]|=l[n]<<(n%4<<3);if(s[n>>2]|=128<<(n%4<<3),n>55)for(u(o,s),n=0;n<16;n+=1)s[n]=0;return j=r*8,j=j.toString(16).match(/(.*?)(.{0,8})$/),S=parseInt(j[2],16),R=parseInt(j[1],16)||0,s[14]=S,s[15]=R,u(o,s),o}function k(l){var r="",o;for(o=0;o<4;o+=1)r+=a[l>>o*8+4&15]+a[l>>o*8&15];return r}function w(l){var r;for(r=0;r<l.length;r+=1)l[r]=k(l[r]);return l.join("")}w(d("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(e=function(l,r){var o=(l&65535)+(r&65535),n=(l>>16)+(r>>16)+(o>>16);return n<<16|o&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function l(r,o){return r=r|0||0,r<0?Math.max(r+o,0):Math.min(r,o)}ArrayBuffer.prototype.slice=function(r,o){var n=this.byteLength,c=l(r,n),s=n,j,S,R,$e;return o!==i&&(s=l(o,n)),c>s?new ArrayBuffer(0):(j=s-c,S=new ArrayBuffer(j),R=new Uint8Array(S),$e=new Uint8Array(this,c,j),R.set($e),S)}})();function v(l){return/[\u0080-\uFFFF]/.test(l)&&(l=unescape(encodeURIComponent(l))),l}function D(l,r){var o=l.length,n=new ArrayBuffer(o),c=new Uint8Array(n),s;for(s=0;s<o;s+=1)c[s]=l.charCodeAt(s);return r?c:n}function T(l){return String.fromCharCode.apply(null,new Uint8Array(l))}function le(l,r,o){var n=new Uint8Array(l.byteLength+r.byteLength);return n.set(new Uint8Array(l)),n.set(new Uint8Array(r),l.byteLength),o?n:n.buffer}function G(l){var r=[],o=l.length,n;for(n=0;n<o-1;n+=2)r.push(parseInt(l.substr(n,2),16));return String.fromCharCode.apply(String,r)}function b(){this.reset()}return b.prototype.append=function(l){return this.appendBinary(v(l)),this},b.prototype.appendBinary=function(l){this._buff+=l,this._length+=l.length;var r=this._buff.length,o;for(o=64;o<=r;o+=64)u(this._hash,p(this._buff.substring(o-64,o)));return this._buff=this._buff.substring(o-64),this},b.prototype.end=function(l){var r=this._buff,o=r.length,n,c=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s;for(n=0;n<o;n+=1)c[n>>2]|=r.charCodeAt(n)<<(n%4<<3);return this._finish(c,o),s=w(this._hash),l&&(s=G(s)),this.reset(),s},b.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},b.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},b.prototype.setState=function(l){return this._buff=l.buff,this._length=l.length,this._hash=l.hash,this},b.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},b.prototype._finish=function(l,r){var o=r,n,c,s;if(l[o>>2]|=128<<(o%4<<3),o>55)for(u(this._hash,l),o=0;o<16;o+=1)l[o]=0;n=this._length*8,n=n.toString(16).match(/(.*?)(.{0,8})$/),c=parseInt(n[2],16),s=parseInt(n[1],16)||0,l[14]=c,l[15]=s,u(this._hash,l)},b.hash=function(l,r){return b.hashBinary(v(l),r)},b.hashBinary=function(l,r){var o=d(l),n=w(o);return r?G(n):n},b.ArrayBuffer=function(){this.reset()},b.ArrayBuffer.prototype.append=function(l){var r=le(this._buff.buffer,l,!0),o=r.length,n;for(this._length+=l.byteLength,n=64;n<=o;n+=64)u(this._hash,m(r.subarray(n-64,n)));return this._buff=n-64<o?new Uint8Array(r.buffer.slice(n-64)):new Uint8Array(0),this},b.ArrayBuffer.prototype.end=function(l){var r=this._buff,o=r.length,n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c,s;for(c=0;c<o;c+=1)n[c>>2]|=r[c]<<(c%4<<3);return this._finish(n,o),s=w(this._hash),l&&(s=G(s)),this.reset(),s},b.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},b.ArrayBuffer.prototype.getState=function(){var l=b.prototype.getState.call(this);return l.buff=T(l.buff),l},b.ArrayBuffer.prototype.setState=function(l){return l.buff=D(l.buff,!0),b.prototype.setState.call(this,l)},b.ArrayBuffer.prototype.destroy=b.prototype.destroy,b.ArrayBuffer.prototype._finish=b.prototype._finish,b.ArrayBuffer.hash=function(l,r){var o=f(new Uint8Array(l)),n=w(o);return r?G(n):n},b})});var De=Y((Pi,pa)=>{"use strict";pa.exports={}});async function Ga(i){let e=(await Promise.resolve().then(()=>L(ra(),1))).default;return new Promise((a,t)=>{let p=Math.ceil(i.size/2097152),m=0,d=new e.ArrayBuffer,f=new FileReader,k=()=>{let w=m*2097152,v=Math.min(w+2097152,i.size);f.readAsArrayBuffer(i.slice(w,v))};f.onload=w=>{let v=w.target?.result;if(!v){t(x.business("Failed to read file chunk"));return}d.append(v),m++,m<p?k():a({md5:d.end()})},f.onerror=()=>{t(x.business("Failed to calculate MD5: FileReader error"))},k()})}async function Wa(i){let e=await Promise.resolve().then(()=>L(De(),1));if(Buffer.isBuffer(i)){let t=e.createHash("md5");return t.update(i),{md5:t.digest("hex")}}let a=await Promise.resolve().then(()=>L(De(),1));return new Promise((t,u)=>{let p=e.createHash("md5"),m=a.createReadStream(i);m.on("error",d=>u(x.business(`Failed to read file for MD5: ${d.message}`))),m.on("data",d=>p.update(d)),m.on("end",()=>t({md5:p.digest("hex")}))})}async function se(i){let e=U();if(e==="browser"){if(!(i instanceof Blob))throw x.business("Invalid input for browser MD5 calculation: Expected Blob or File.");return Ga(i)}if(e==="node"){if(!(Buffer.isBuffer(i)||typeof i=="string"))throw x.business("Invalid input for Node.js MD5 calculation: Expected Buffer or file path string.");return Wa(i)}throw x.business("Unknown or unsupported execution environment for MD5 calculation.")}var te=A(()=>{"use strict";O();F()});function va(i){return Xa.test(i)}var Ja,Xa,fa=A(()=>{"use strict";Ja=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],Xa=new RegExp(Ja.join("|"))});function ba(i){return!i||i.length===0?[]:i.filter(e=>{if(!e)return!1;let a=e.replace(/\\/g,"/").split("/").filter(Boolean);if(a.length===0)return!0;let t=a[a.length-1];if(va(t))return!1;let u=a.slice(0,-1);for(let p of u)if(Za.some(m=>p.toLowerCase()===m.toLowerCase()))return!1;return!0})}var Za,Se=A(()=>{"use strict";fa();Za=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function re(i){return i.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var ha=A(()=>{"use strict"});function ga(i,e={}){if(e.flatten===!1)return i.map(t=>({path:re(t),name:Ae(t)}));let a=Qa(i);return i.map(t=>{let u=re(t);if(a){let p=a.endsWith("/")?a:`${a}/`;u.startsWith(p)&&(u=u.substring(p.length))}return u||(u=Ae(t)),{path:u,name:Ae(t)}})}function Qa(i){if(!i.length)return"";let a=i.map(p=>re(p)).map(p=>p.split("/")),t=[],u=Math.min(...a.map(p=>p.length));for(let p=0;p<u-1;p++){let m=a[0][p];if(a.every(d=>d[p]===m))t.push(m);else break}return t.join("/")}function Ae(i){return i.split(/[/\\]/).pop()||i}var ze=A(()=>{"use strict";ha()});var wa={};ue(wa,{processFilesForBrowser:()=>ya});async function ya(i,e={}){let{getENV:a}=await Promise.resolve().then(()=>(O(),Me));if(a()!=="browser")throw x.business("processFilesForBrowser can only be called in a browser environment.");let t=i,u=t.map(v=>v.webkitRelativePath||v.name),p=ga(u,{flatten:e.pathDetect!==!1}),m=[];for(let v=0;v<t.length;v++){let D=t[v],T=p[v].path;if(T.includes("..")||T.includes("\0"))throw x.business(`Security error: Unsafe file path "${T}" for file: ${D.name}`);m.push({file:D,relativePath:T})}let d=m.map(v=>v.relativePath),f=ba(d),k=new Set(f),w=[];for(let v of m){if(!k.has(v.relativePath))continue;let{md5:D}=await se(v.file);w.push({content:v.file,path:v.relativePath,size:v.file.size,md5:D})}return w}var Pe=A(()=>{"use strict";te();F();Se();ze()});var de=L(me(),1),xe={};for(let i in de.default){let e=de.default[i];e&&e.extensions&&e.extensions.forEach(a=>{xe[a]||(xe[a]=i)})}function X(i){let e=i.includes(".")?i.substring(i.lastIndexOf(".")+1).toLowerCase():"";return xe[e]||"application/octet-stream"}F();var Q=class{constructor(){this.handlers=new Map}on(e,a){this.handlers.has(e)||this.handlers.set(e,new Set),this.handlers.get(e).add(a)}off(e,a){let t=this.handlers.get(e);t&&(t.delete(a),t.size===0&&this.handlers.delete(e))}emit(e,...a){let t=this.handlers.get(e);if(!t)return;let u=Array.from(t);for(let p of u)try{p(...a)}catch(m){t.delete(p),e!=="error"&&setTimeout(()=>{m instanceof Error?this.emit("error",m,String(e)):this.emit("error",new Error(String(m)),String(e))},0)}}transfer(e){this.handlers.forEach((a,t)=>{a.forEach(u=>{e.on(t,u)})})}clear(){this.handlers.clear()}};O();var ne="/deployments",na="/ping",E="/domains",Ka="/config",Ha="/account",je="/tokens",Va="/spa-check",oe=class extends Q{constructor(e){super(),this.apiUrl=e.apiUrl||Z,this.getAuthHeadersCallback=e.getAuthHeaders}transferEventsTo(e){this.transfer(e)}async request(e,a={},t){let u=this.getAuthHeaders(a.headers),p={...a,headers:u,credentials:u.Authorization?void 0:"include"};this.emit("request",e,p);try{let m=await fetch(e,p);m.ok||await this.handleResponseError(m,t);let d=this.safeClone(m),f=this.safeClone(m);return this.emit("response",d,e),await this.parseResponse(f)}catch(m){throw this.emit("error",m,e),this.handleFetchError(m,t),m}}getAuthHeaders(e={}){let a=this.getAuthHeadersCallback();return{...e,...a}}safeClone(e){try{return e.clone()}catch{return e}}async parseResponse(e){if(!(e.headers.get("Content-Length")==="0"||e.status===204))return await e.json()}async handleResponseError(e,a){let t={};try{e.headers.get("content-type")?.includes("application/json")?t=await e.json():t={message:await e.text()}}catch{t={message:"Failed to parse error response"}}let u=t.message||t.error||`${a} failed due to API error`;throw e.status===401?x.authentication(u):x.api(u,e.status,t.code,t)}handleFetchError(e,a){throw e.name==="AbortError"?x.cancelled(`${a} operation was cancelled.`):e instanceof TypeError&&e.message.includes("fetch")?x.network(`${a} failed due to network error: ${e.message}`,e):e instanceof x?e:x.business(`An unexpected error occurred during ${a}: ${e.message||"Unknown error"}`)}async ping(){return(await this.request(`${this.apiUrl}${na}`,{method:"GET"},"Ping"))?.success||!1}async getPingResponse(){return await this.request(`${this.apiUrl}${na}`,{method:"GET"},"Ping")}async getConfig(){return await this.request(`${this.apiUrl}${Ka}`,{method:"GET"},"Config")}async deploy(e,a={}){this.validateFiles(e);let{requestBody:t,requestHeaders:u}=await this.prepareRequestPayload(e,a.tags),p={};a.deployToken?p={Authorization:`Bearer ${a.deployToken}`}:a.apiKey&&(p={Authorization:`Bearer ${a.apiKey}`});let m={method:"POST",body:t,headers:{...u,...p},signal:a.signal||null};return await this.request(`${a.apiUrl||this.apiUrl}${ne}`,m,"Deploy")}async listDeployments(){return await this.request(`${this.apiUrl}${ne}`,{method:"GET"},"List Deployments")}async getDeployment(e){return await this.request(`${this.apiUrl}${ne}/${e}`,{method:"GET"},"Get Deployment")}async removeDeployment(e){await this.request(`${this.apiUrl}${ne}/${e}`,{method:"DELETE"},"Remove Deployment")}async setDomain(e,a,t){let u={};a&&(u.deployment=a),t&&t.length>0&&(u.tags=t);let p={method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)},m=this.getAuthHeaders(p.headers),d={...p,headers:m,credentials:m.Authorization?void 0:"include"};this.emit("request",`${this.apiUrl}${E}/${encodeURIComponent(e)}`,d);try{let f=await fetch(`${this.apiUrl}${E}/${encodeURIComponent(e)}`,d);f.ok||await this.handleResponseError(f,"Set Domain");let k=this.safeClone(f),w=this.safeClone(f);return this.emit("response",k,`${this.apiUrl}${E}/${encodeURIComponent(e)}`),{...await this.parseResponse(w),isCreate:f.status===201}}catch(f){throw this.emit("error",f,`${this.apiUrl}${E}/${encodeURIComponent(e)}`),this.handleFetchError(f,"Set Domain"),f}}async getDomain(e){return await this.request(`${this.apiUrl}${E}/${encodeURIComponent(e)}`,{method:"GET"},"Get Domain")}async listDomains(){return await this.request(`${this.apiUrl}${E}`,{method:"GET"},"List Domains")}async removeDomain(e){await this.request(`${this.apiUrl}${E}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove Domain")}async confirmDomain(e){return await this.request(`${this.apiUrl}${E}/${encodeURIComponent(e)}/confirm`,{method:"POST"},"Confirm Domain")}async getDomainDns(e){return await this.request(`${this.apiUrl}${E}/${encodeURIComponent(e)}/dns`,{method:"GET"},"Get Domain DNS")}async getDomainRecords(e){return await this.request(`${this.apiUrl}${E}/${encodeURIComponent(e)}/records`,{method:"GET"},"Get Domain Records")}async getDomainShare(e){return await this.request(`${this.apiUrl}${E}/${encodeURIComponent(e)}/share`,{method:"GET"},"Get Domain Share")}async getAccount(){return await this.request(`${this.apiUrl}${Ha}`,{method:"GET"},"Get Account")}async createToken(e,a){let t={};return e!==void 0&&(t.ttl=e),a&&a.length>0&&(t.tags=a),await this.request(`${this.apiUrl}${je}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},"Create Token")}async listTokens(){return await this.request(`${this.apiUrl}${je}`,{method:"GET"},"List Tokens")}async removeToken(e){await this.request(`${this.apiUrl}${je}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove Token")}async checkSPA(e){let a=e.find(m=>m.path==="index.html"||m.path==="/index.html");if(!a||a.size>100*1024)return!1;let t;if(typeof Buffer<"u"&&Buffer.isBuffer(a.content))t=a.content.toString("utf-8");else if(typeof Blob<"u"&&a.content instanceof Blob)t=await a.content.text();else if(typeof File<"u"&&a.content instanceof File)t=await a.content.text();else return!1;let u={files:e.map(m=>m.path),index:t};return(await this.request(`${this.apiUrl}${Va}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)},"SPA Check")).isSPA}validateFiles(e){if(!e.length)throw x.business("No files to deploy.");for(let a of e)if(!a.md5)throw x.file(`MD5 checksum missing for file: ${a.path}`,a.path)}async prepareRequestPayload(e,a){if(U()==="browser")return{requestBody:this.createBrowserBody(e,a),requestHeaders:{}};if(U()==="node"){let{body:t,headers:u}=await this.createNodeBody(e,a);return{requestBody:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),requestHeaders:u}}else throw x.business("Unknown or unsupported execution environment")}createBrowserBody(e,a){let t=new FormData,u=[];for(let p of e){if(!(p.content instanceof File||p.content instanceof Blob))throw x.file(`Unsupported file.content type for browser FormData: ${p.path}`,p.path);let m=this.getBrowserContentType(p.content instanceof File?p.content:p.path),d=new File([p.content],p.path,{type:m});t.append("files[]",d),u.push(p.md5)}return t.append("checksums",JSON.stringify(u)),a&&a.length>0&&t.append("tags",JSON.stringify(a)),t}async createNodeBody(e,a){let{FormData:t,File:u}=await import("formdata-node"),{FormDataEncoder:p}=await Promise.resolve().then(()=>(ia(),aa)),m=new t,d=[];for(let v of e){let D=X(v.path),T;if(Buffer.isBuffer(v.content))T=new u([v.content],v.path,{type:D});else if(typeof Blob<"u"&&v.content instanceof Blob)T=new u([v.content],v.path,{type:D});else throw x.file(`Unsupported file.content type for Node.js FormData: ${v.path}`,v.path);let le=v.path.startsWith("/")?v.path:"/"+v.path;m.append("files[]",T,le),d.push(v.md5)}m.append("checksums",JSON.stringify(d)),a&&a.length>0&&m.append("tags",JSON.stringify(a));let f=new p(m),k=[];for await(let v of f.encode())k.push(Buffer.from(v));let w=Buffer.concat(k);return{body:w,headers:{"Content-Type":f.contentType,"Content-Length":Buffer.byteLength(w).toString()}}}getBrowserContentType(e){return typeof e=="string"?X(e):e.type||X(e.name)}};F();F();var Fe=null;function Ee(i){Fe=i}function Te(){if(Fe===null)throw x.config("Platform configuration not initialized. The SDK must fetch configuration from the API before performing operations.");return Fe}F();function oa(i={},e={}){let a={apiUrl:i.apiUrl||e.apiUrl||Z,apiKey:i.apiKey!==void 0?i.apiKey:e.apiKey,deployToken:i.deployToken!==void 0?i.deployToken:e.deployToken},t={apiUrl:a.apiUrl};return a.apiKey!==void 0&&(t.apiKey=a.apiKey),a.deployToken!==void 0&&(t.deployToken=a.deployToken),t}function sa(i,e){let a={...i};return a.apiUrl===void 0&&e.apiUrl!==void 0&&(a.apiUrl=e.apiUrl),a.apiKey===void 0&&e.apiKey!==void 0&&(a.apiKey=e.apiKey),a.deployToken===void 0&&e.deployToken!==void 0&&(a.deployToken=e.deployToken),a.timeout===void 0&&e.timeout!==void 0&&(a.timeout=e.timeout),a.maxConcurrency===void 0&&e.maxConcurrency!==void 0&&(a.maxConcurrency=e.maxConcurrency),a.onProgress===void 0&&e.onProgress!==void 0&&(a.onProgress=e.onProgress),a}F();te();async function Ya(){let e=JSON.stringify({rewrites:[{source:"/(.*)",destination:"/index.html"}]},null,2),a;typeof Buffer<"u"?a=Buffer.from(e,"utf-8"):a=new Blob([e],{type:"application/json"});let{md5:t}=await se(a);return{path:he,content:a,size:e.length,md5:t}}async function la(i,e,a){if(a.spaDetect===!1||i.some(t=>t.path===he))return i;try{if(await e.checkSPA(i)){let u=await Ya();return[...i,u]}}catch{}return i}function ua(i,e,a,t,u){return{create:async(p,m={})=>{if(u&&!u()&&!m.deployToken&&!m.apiKey)throw new Error("Authentication credentials are required for deployment. Please call setDeployToken() or setApiKey() first, or pass credentials in the deployment options.");a&&await a();let d=e?sa(m,e):m,f=i();if(!t)throw new Error("processInput function is not provided.");let k=await t(p,d);return k=await la(k,f,d),await f.deploy(k,d)},list:async()=>(a&&await a(),i().listDeployments()),remove:async p=>{a&&await a(),await i().removeDeployment(p)},get:async p=>(a&&await a(),i().getDeployment(p))}}function ma(i,e){return{set:async(a,t,u)=>(e&&await e(),i().setDomain(a,t,u)),get:async a=>(e&&await e(),i().getDomain(a)),list:async()=>(e&&await e(),i().listDomains()),remove:async a=>{e&&await e(),await i().removeDomain(a)},confirm:async a=>(e&&await e(),i().confirmDomain(a)),dns:async a=>(e&&await e(),i().getDomainDns(a)),records:async a=>(e&&await e(),i().getDomainRecords(a)),share:async a=>(e&&await e(),i().getDomainShare(a))}}function da(i,e){return{get:async()=>(e&&await e(),i().getAccount())}}function xa(i,e){return{create:async(a,t)=>(e&&await e(),i().createToken(a,t)),list:async()=>(e&&await e(),i().listTokens()),remove:async a=>{e&&await e(),await i().removeToken(a)}}}var ce=class{constructor(e={}){this.initPromise=null;this._config=null;this.auth=null;this.clientOptions=e,e.deployToken?this.auth={type:"token",value:e.deployToken}:e.apiKey&&(this.auth={type:"apiKey",value:e.apiKey}),this.authHeadersCallback=()=>this.getAuthHeaders();let a=this.resolveInitialConfig(e);this.http=new oe({...e,...a,getAuthHeaders:this.authHeadersCallback});let t=()=>this.ensureInitialized(),u=()=>this.http;this._deployments=ua(u,this.clientOptions,t,(p,m)=>this.processInput(p,m),()=>this.hasAuth()),this._domains=ma(u,t),this._account=da(u,t),this._tokens=xa(u,t)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.loadFullConfig()),this.initPromise}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(e,a){return this.deployments.create(e,a)}async whoami(){return this.account.get()}get deployments(){return this._deployments}get domains(){return this._domains}get account(){return this._account}get tokens(){return this._tokens}async getConfig(){return this._config?this._config:(await this.ensureInitialized(),this._config=Te(),this._config)}on(e,a){this.http.on(e,a)}off(e,a){this.http.off(e,a)}replaceHttpClient(e){if(this.http?.transferEventsTo)try{this.http.transferEventsTo(e)}catch(a){console.warn("Event transfer failed during client replacement:",a)}this.http=e}setDeployToken(e){if(!e||typeof e!="string")throw x.business("Invalid deploy token provided. Deploy token must be a non-empty string.");this.auth={type:"token",value:e}}setApiKey(e){if(!e||typeof e!="string")throw x.business("Invalid API key provided. API key must be a non-empty string.");this.auth={type:"apiKey",value:e}}getAuthHeaders(){if(!this.auth)return{};switch(this.auth.type){case"token":return{Authorization:`Bearer ${this.auth.value}`};case"apiKey":return{Authorization:`Bearer ${this.auth.value}`};default:return{}}}hasAuth(){return this.clientOptions.useCredentials?!0:this.auth!==null}};F();te();function Wi(i,e,a,t=!0){let u=i===1?e:a;return t?`${i} ${u}`:u}Se();ze();O();F();var Re=L(me(),1),ei=new Set(Object.keys(Re.default)),ai=new Map(Object.entries(Re.default).filter(([i,e])=>e.extensions).map(([i,e])=>[i,new Set(e.extensions)]));function Ce(i,e=1){if(i===0)return"0 Bytes";let a=1024,t=["Bytes","KB","MB","GB"],u=Math.floor(Math.log(i)/Math.log(a));return parseFloat((i/Math.pow(a,u)).toFixed(e))+" "+t[u]}function ii(i){if(/[?&#%<>\[\]{}|\\^~`;$()'"*\r\n\t]/.test(i))return{valid:!1,reason:"File name contains unsafe characters"};if(i.startsWith(".")===!1&&(i.startsWith(" ")||i.endsWith(" ")||i.endsWith(".")))return{valid:!1,reason:"File name cannot start/end with spaces or end with dots"};let a=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,t=i.split("/").pop()||i;return a.test(t)?{valid:!1,reason:"File name uses a reserved system name"}:i.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function ni(i,e){if(i.startsWith("."))return!0;let a=i.toLowerCase().split(".");if(a.length>1&&a[a.length-1]){let t=a[a.length-1],u=ai.get(e);if(u&&!u.has(t))return!1}return!0}function on(i,e){let a=[],t=[];if(i.length===0){let p="At least one file must be provided";return{files:[],validFiles:[],error:{error:"No Files Provided",details:p,errors:[p],isClientError:!0}}}if(i.length>e.maxFilesCount){let p=`Number of files (${i.length}) exceeds the limit of ${e.maxFilesCount}.`;return{files:i.map(m=>({...m,status:y.VALIDATION_FAILED,statusMessage:p})),validFiles:[],error:{error:"File Count Exceeded",details:p,errors:[p],isClientError:!0}}}let u=0;for(let p of i){let m=y.READY,d="Ready for upload",f=p.name?ii(p.name):{valid:!1,reason:"File name cannot be empty"};p.status===y.PROCESSING_ERROR?(m=y.PROCESSING_ERROR,d=p.statusMessage||"A file failed during processing.",a.push(`${p.name}: ${d}`)):!p.name||p.name.trim().length===0?(m=y.VALIDATION_FAILED,d="File name cannot be empty",a.push(`${p.name||"(empty)"}: ${d}`)):p.name.includes("\0")?(m=y.VALIDATION_FAILED,d="File name contains invalid characters (null byte)",a.push(`${p.name}: ${d}`)):f.valid?p.size<=0?(m=y.EMPTY_FILE,d=p.size===0?"File is empty (0 bytes)":"File size must be positive",a.push(`${p.name}: ${d}`)):!p.type||p.type.trim().length===0?(m=y.VALIDATION_FAILED,d="File MIME type is required",a.push(`${p.name}: ${d}`)):e.allowedMimeTypes.some(k=>p.type.startsWith(k))?ei.has(p.type)?ni(p.name,p.type)?p.size>e.maxFileSize?(m=y.VALIDATION_FAILED,d=`File size (${Ce(p.size)}) exceeds limit of ${Ce(e.maxFileSize)}`,a.push(`${p.name}: ${d}`)):(u+=p.size,u>e.maxTotalSize&&(m=y.VALIDATION_FAILED,d=`Total size would exceed limit of ${Ce(e.maxTotalSize)}`,a.push(`${p.name}: ${d}`))):(m=y.VALIDATION_FAILED,d="File extension does not match MIME type",a.push(`${p.name}: ${d}`)):(m=y.VALIDATION_FAILED,d=`Invalid MIME type "${p.type}"`,a.push(`${p.name}: ${d}`)):(m=y.VALIDATION_FAILED,d=`File type "${p.type}" is not allowed`,a.push(`${p.name}: ${d}`)):(m=y.VALIDATION_FAILED,d=f.reason||"Invalid file name",a.push(`${p.name}: ${d}`)),t.push({...p,status:m,statusMessage:d})}if(a.length>0){let p=t.find(d=>d.status!==y.READY&&d.status!==y.PENDING),m="Validation Failed";return p?.status===y.PROCESSING_ERROR?m="Processing Error":p?.status===y.EMPTY_FILE?m="Empty File":p?.statusMessage?.includes("File name cannot be empty")||p?.statusMessage?.includes("Invalid file name")||p?.statusMessage?.includes("File name contains")||p?.statusMessage?.includes("File name uses")||p?.statusMessage?.includes("File name cannot start")||p?.statusMessage?.includes("traversal")?m="Invalid File Name":p?.statusMessage?.includes("File size must be positive")?m="Invalid File Size":p?.statusMessage?.includes("MIME type is required")?m="Missing MIME Type":p?.statusMessage?.includes("Invalid MIME type")?m="Invalid MIME Type":p?.statusMessage?.includes("not allowed")?m="Invalid File Type":p?.statusMessage?.includes("extension does not match")?m="Extension Mismatch":p?.statusMessage?.includes("Total size")?m="Total Size Exceeded":p?.statusMessage?.includes("exceeds limit")&&(m="File Too Large"),{files:t.map(d=>({...d,status:y.VALIDATION_FAILED})),validFiles:[],error:{error:m,details:a.length===1?a[0]:`${a.length} file(s) failed validation`,errors:a,isClientError:!0}}}return{files:t,validFiles:t,error:null}}function oi(i){return i.filter(e=>e.status===y.READY)}function sn(i){return oi(i).length>0}F();async function si(i){return{}}Pe();var pe,ka,_e=class extends ce{constructor(a={}){super(a);qe(this,pe)}resolveInitialConfig(a){return oa(a,{})}async loadFullConfig(){try{let a=await this.http.getConfig();Ee(a)}catch(a){throw this.initPromise=null,a}}async processInput(a,t){if(!Ue(this,pe,ka).call(this,a))throw x.business("Invalid input type for browser environment. Expected File[].");let{processFilesForBrowser:u}=await Promise.resolve().then(()=>(Pe(),wa));return u(a,t)}};pe=new WeakSet,ka=function(a){return Array.isArray(a)?a.length===0||a.every(t=>t instanceof File):!1};var An=_e;export{fe as API_KEY_HEX_LENGTH,I as API_KEY_PREFIX,Ne as API_KEY_TOTAL_LENGTH,mi as AccountPlan,oe as ApiHttp,di as AuthMethod,Z as DEFAULT_API,he as DEPLOYMENT_CONFIG_FILENAME,be as DEPLOY_TOKEN_HEX_LENGTH,q as DEPLOY_TOKEN_PREFIX,Be as DEPLOY_TOKEN_TOTAL_LENGTH,li as DeploymentStatus,ui as DomainStatus,h as ErrorType,y as FILE_VALIDATION_STATUS,y as FileValidationStatus,Za as JUNK_DIRECTORIES,_e as Ship,x as ShipError,Ra as ShipErrorType,Pa as __setTestEnvironment,sn as allValidFilesReady,se as calculateMD5,da as createAccountResource,ua as createDeploymentResource,ma as createDomainResource,xa as createTokenResource,An as default,ba as filterJunk,Ce as formatFileSize,hi as generateDeploymentUrl,gi as generateDomainUrl,Te as getCurrentConfig,U as getENV,oi as getValidFiles,si as loadConfig,sa as mergeDeployOptions,ga as optimizeDeployPaths,Wi as pluralize,ya as processFilesForBrowser,oa as resolveConfig,Ee as setPlatformConfig,xi as validateApiKey,fi as validateApiUrl,vi as validateDeployToken,on as validateFiles,bi as validateSubdomain};
|
|
6
6
|
/*! Bundled license information:
|
|
7
7
|
|
|
8
8
|
mime-db/index.js:
|