@shipstatic/ship 0.8.12 → 0.8.14
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/README.md +16 -0
- package/dist/browser.d.ts +27 -6
- package/dist/browser.js +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/cli.cjs +22 -21
- package/dist/cli.cjs.map +1 -1
- package/dist/completions/ship.bash +1 -1
- package/dist/completions/ship.fish +1 -0
- package/dist/completions/ship.zsh +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -6
- package/dist/index.d.ts +27 -6
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -158,6 +158,7 @@ ship completion uninstall
|
|
|
158
158
|
| `--deploy-token <token>` | Deploy token for single-use deployments |
|
|
159
159
|
| `--config <file>` | Custom config file path |
|
|
160
160
|
| `--label <label>` | Add label (repeatable) |
|
|
161
|
+
| `--password <password>` | Password-protect this deployment |
|
|
161
162
|
| `--no-path-detect` | Disable automatic path optimization |
|
|
162
163
|
| `--no-spa-detect` | Disable automatic SPA detection |
|
|
163
164
|
| `--no-color` | Disable colored output |
|
|
@@ -189,6 +190,7 @@ ship.setDeployToken('token-...');
|
|
|
189
190
|
```typescript
|
|
190
191
|
ship.deploy(input, {
|
|
191
192
|
labels?: string[],
|
|
193
|
+
password?: string, // Password-protect the deployment (6–128 chars)
|
|
192
194
|
onProgress?: ({ percent }) => void,
|
|
193
195
|
signal?: AbortSignal,
|
|
194
196
|
pathDetect?: boolean, // Auto-optimize paths (default: true)
|
|
@@ -201,6 +203,20 @@ ship.deploy(input, {
|
|
|
201
203
|
});
|
|
202
204
|
```
|
|
203
205
|
|
|
206
|
+
#### Password protection
|
|
207
|
+
|
|
208
|
+
Pass `password` (6–128 characters; whitespace significant) to gate the deployment behind a prompt. Visitors are asked for the password before they can view the site, including on any custom domains pointing at it. To remove protection, redeploy without a password.
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
ship --password 'your-passphrase' ./dist
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
```javascript
|
|
215
|
+
await ship.deploy('./dist', { password: 'your-passphrase' });
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
The CLI also reads `SHIP_PASSWORD` from the environment when `--password` is not given.
|
|
219
|
+
|
|
204
220
|
### Browser Usage
|
|
205
221
|
|
|
206
222
|
```javascript
|
package/dist/browser.d.ts
CHANGED
|
@@ -54,15 +54,36 @@ interface DeployBody {
|
|
|
54
54
|
body: FormData | ArrayBuffer;
|
|
55
55
|
headers: Record<string, string>;
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Context passed to the deploy body creator — everything that becomes a
|
|
59
|
+
* form field alongside the files themselves.
|
|
60
|
+
*/
|
|
61
|
+
interface DeployBodyContext {
|
|
62
|
+
/**
|
|
63
|
+
* Deployment labels for categorization. Each label must satisfy
|
|
64
|
+
* `LABEL_CONSTRAINTS` (length and pattern, lowercased+trimmed).
|
|
65
|
+
*/
|
|
66
|
+
labels?: string[];
|
|
67
|
+
/** Client identifier (`cli`, `sdk`, `web`). */
|
|
68
|
+
via?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Optional plaintext password to protect the deployment.
|
|
71
|
+
* Length: `PASSWORD_CONSTRAINTS.MIN_LENGTH` to `PASSWORD_CONSTRAINTS.MAX_LENGTH`
|
|
72
|
+
* characters. Whitespace is preserved verbatim — significant.
|
|
73
|
+
*/
|
|
74
|
+
password?: string;
|
|
75
|
+
/** @internal Server-side processing flags. */
|
|
76
|
+
flags?: {
|
|
77
|
+
build?: boolean;
|
|
78
|
+
prerender?: boolean;
|
|
79
|
+
spa?: boolean;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
57
82
|
/**
|
|
58
83
|
* Function that creates a deploy request body from files.
|
|
59
84
|
* Implemented differently for Node.js and Browser.
|
|
60
85
|
*/
|
|
61
|
-
type DeployBodyCreator = (files: StaticFile[],
|
|
62
|
-
build?: boolean;
|
|
63
|
-
prerender?: boolean;
|
|
64
|
-
spa?: boolean;
|
|
65
|
-
}) => Promise<DeployBody>;
|
|
86
|
+
type DeployBodyCreator = (files: StaticFile[], context?: DeployBodyContext) => Promise<DeployBody>;
|
|
66
87
|
/**
|
|
67
88
|
* Options for configuring a `Ship` instance.
|
|
68
89
|
* Sets default API host, authentication credentials, progress callbacks, concurrency, and timeouts for the client.
|
|
@@ -728,4 +749,4 @@ declare class Ship extends Ship$1 {
|
|
|
728
749
|
protected getDeployBodyCreator(): DeployBodyCreator;
|
|
729
750
|
}
|
|
730
751
|
|
|
731
|
-
export { type ApiDeployOptions, ApiHttp, type ApiHttpOptions, type DeployBody, type DeployBodyCreator, type DeployFile, type DeploymentOptions, type DeploymentResourceContext, type DomainSetResult, type ExecutionEnvironment, JUNK_DIRECTORIES, type MD5Result, type ResourceContext, Ship, type ShipClientOptions, type ShipEvents, __setTestEnvironment, allValidFilesReady, calculateMD5, createAccountResource, createDeploymentResource, createDomainResource, createTokenResource, Ship as default, filterJunk, formatFileSize, getCurrentConfig, getENV, getValidFiles, mergeDeployOptions, optimizeDeployPaths, pluralize, processFilesForBrowser, resolveConfig, setConfig as setPlatformConfig, validateDeployFile, validateDeployPath, validateFileName, validateFiles };
|
|
752
|
+
export { type ApiDeployOptions, ApiHttp, type ApiHttpOptions, type DeployBody, type DeployBodyContext, type DeployBodyCreator, type DeployFile, type DeploymentOptions, type DeploymentResourceContext, type DomainSetResult, type ExecutionEnvironment, JUNK_DIRECTORIES, type MD5Result, type ResourceContext, Ship, type ShipClientOptions, type ShipEvents, __setTestEnvironment, allValidFilesReady, calculateMD5, createAccountResource, createDeploymentResource, createDomainResource, createTokenResource, Ship as default, filterJunk, formatFileSize, getCurrentConfig, getENV, getValidFiles, mergeDeployOptions, optimizeDeployPaths, pluralize, processFilesForBrowser, resolveConfig, setConfig as setPlatformConfig, validateDeployFile, validateDeployPath, validateFileName, validateFiles };
|
package/dist/browser.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var Ke=Object.create;var L=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,je=Object.prototype.hasOwnProperty;var qe=(i,r,e)=>r in i?L(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e;var C=(i,r)=>()=>(i&&(r=i(i=0)),r);var me=(i,r)=>()=>(r||i((r={exports:{}}).exports,r),r.exports),Ye=(i,r)=>{for(var e in r)L(i,e,{get:r[e],enumerable:!0})},Je=(i,r,e,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let u of Ge(r))!je.call(i,u)&&u!==e&&L(i,u,{get:()=>r[u],enumerable:!(s=He(r,u))||s.enumerable});return i};var J=(i,r,e)=>(e=i!=null?Ke(Ve(i)):{},Je(r||!i||!i.__esModule?L(e,"default",{value:i,enumerable:!0}):e,i));var B=(i,r,e)=>qe(i,typeof r!="symbol"?r+"":r,e);function Z(i){return i!==null&&typeof i=="object"&&"name"in i&&i.name==="ShipError"&&"status"in i}function k(i){let r=i.lastIndexOf(".");if(r===-1||r===i.length-1)return!1;let e=i.slice(r+1).toLowerCase();return We.has(e)}function Ae(i){return Xe.test(i)}function M(i){return i.replace(/\\/g,"/").split("/").filter(Boolean).some(e=>Qe.has(e))}function mt(i){if(!i.startsWith(P))throw d.validation(`API key must start with "${P}"`);if(i.length!==ye)throw d.validation(`API key must be ${ye} characters total (${P} + ${X} hex chars)`);let r=i.slice(P.length);if(!/^[a-f0-9]{64}$/i.test(r))throw d.validation(`API key must contain ${X} hexadecimal characters after "${P}" prefix`)}function yt(i){if(!i.startsWith(O))throw d.validation(`Deploy token must start with "${O}"`);if(i.length!==ge)throw d.validation(`Deploy token must be ${ge} characters total (${O} + ${Q} hex chars)`);let r=i.slice(O.length);if(!/^[a-f0-9]{64}$/i.test(r))throw d.validation(`Deploy token must contain ${Q} hexadecimal characters after "${O}" prefix`)}function gt(i){try{let r=new URL(i);if(!["http:","https:"].includes(r.protocol))throw d.validation("API URL must use http:// or https:// protocol");if(r.pathname!=="/"&&r.pathname!=="")throw d.validation("API URL must not contain a path");if(r.search||r.hash)throw d.validation("API URL must not contain query parameters or fragments")}catch(r){throw Z(r)?r:d.validation("API URL must be a valid URL")}}function At(i){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(i)}function Se(i,r){return i.endsWith(`.${r}`)}function Dt(i,r){return!Se(i,r)}function St(i,r){return Se(i,r)?i.slice(0,-(r.length+1)):null}function Et(i){return`https://${i}`}function bt(i){return`https://${i}`}function Rt(i){return!i||i.length===0?null:JSON.stringify(i)}function Ct(i){if(!i)return[];try{let r=JSON.parse(i);return Array.isArray(r)?r:[]}catch{return[]}}var ut,ct,ft,S,W,d,We,Xe,Qe,P,X,ye,ht,O,Q,ge,dt,ee,De,z,b,vt,wt,R=C(()=>{"use strict";ut={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},ct={PENDING:"pending",PARTIAL:"partial",SUCCESS:"success",PAUSED:"paused"},ft={FREE:"free",STANDARD:"standard",SPONSORED:"sponsored",ENTERPRISE:"enterprise",SUSPENDED:"suspended",TERMINATING:"terminating",TERMINATED:"terminated"};(function(i){i.Validation="validation_failed",i.NotFound="not_found",i.RateLimit="rate_limit_exceeded",i.Authentication="authentication_failed",i.Business="business_logic_error",i.Api="internal_server_error",i.Network="network_error",i.Cancelled="operation_cancelled",i.File="file_error",i.Config="config_error"})(S||(S={}));W={client:new Set([S.Business,S.Config,S.File,S.Validation]),network:new Set([S.Network]),auth:new Set([S.Authentication])},d=class i extends Error{constructor(e,s,u,f){super(s);B(this,"type");B(this,"status");B(this,"details");this.type=e,this.status=u,this.details=f,this.name="ShipError"}toResponse(){let e=this.type===S.Authentication&&this.details?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:e}}static fromResponse(e){return new i(e.error,e.message,e.status,e.details)}static validation(e,s){return new i(S.Validation,e,400,s)}static notFound(e,s){let u=s?`${e} ${s} not found`:`${e} not found`;return new i(S.NotFound,u,404)}static rateLimit(e="Too many requests"){return new i(S.RateLimit,e,429)}static authentication(e="Authentication required",s){return new i(S.Authentication,e,401,s)}static business(e,s=400){return new i(S.Business,e,s)}static network(e,s){return new i(S.Network,e,void 0,{cause:s})}static cancelled(e){return new i(S.Cancelled,e)}static file(e,s){return new i(S.File,e,void 0,{filePath:s})}static config(e,s){return new i(S.Config,e,void 0,s)}static api(e,s=500){return new i(S.Api,e,s)}static database(e,s=500){return new i(S.Api,e,s)}static storage(e,s=500){return new i(S.Api,e,s)}get filePath(){return this.details?.filePath}isClientError(){return W.client.has(this.type)}isNetworkError(){return W.network.has(this.type)}isAuthError(){return W.auth.has(this.type)}isValidationError(){return this.type===S.Validation}isFileError(){return this.type===S.File}isConfigError(){return this.type===S.Config}isType(e){return this.type===e}};We=new Set(["exe","msi","dll","scr","bat","cmd","com","pif","app","deb","rpm","pkg","mpkg","dmg","iso","img","cab","cpl","chm","ps1","vbs","vbe","ws","wsf","wsc","wsh","reg","jar","jnlp","apk","crx","lnk","inf","hta"]);Xe=/[\x00-\x1f\x7f#?%\\<>"]/;Qe=new Set(["node_modules","package.json"]);P="ship-",X=64,ye=P.length+X,ht=4,O="token-",Q=64,ge=O.length+Q,dt={JWT:"jwt",API_KEY:"apiKey",TOKEN:"token",WEBHOOK:"webhook",SYSTEM:"system"},ee="ship.json",De={rewrites:[{source:"/(.*)",destination:"/index.html"}]};z="https://api.shipstatic.com",b={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};vt={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},wt=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/});function ne(i){te=i}function $(){if(te===null)throw d.config("Platform configuration not initialized. The SDK must fetch configuration from the API before performing operations.");return te}var te,N=C(()=>{"use strict";R();te=null});function Lt(i){re=i}function et(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function G(){return re||et()}var re,V=C(()=>{"use strict";re=null});var Re=me((ve,we)=>{"use strict";(function(i){if(typeof ve=="object")we.exports=i();else if(typeof define=="function"&&define.amd)define(i);else{var r;try{r=window}catch{r=self}r.SparkMD5=i()}})(function(i){"use strict";var r=function(p,l){return p+l&4294967295},e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function s(p,l,n,t,a,o){return l=r(r(l,p),r(t,o)),r(l<<a|l>>>32-a,n)}function u(p,l){var n=p[0],t=p[1],a=p[2],o=p[3];n+=(t&a|~t&o)+l[0]-680876936|0,n=(n<<7|n>>>25)+t|0,o+=(n&t|~n&a)+l[1]-389564586|0,o=(o<<12|o>>>20)+n|0,a+=(o&n|~o&t)+l[2]+606105819|0,a=(a<<17|a>>>15)+o|0,t+=(a&o|~a&n)+l[3]-1044525330|0,t=(t<<22|t>>>10)+a|0,n+=(t&a|~t&o)+l[4]-176418897|0,n=(n<<7|n>>>25)+t|0,o+=(n&t|~n&a)+l[5]+1200080426|0,o=(o<<12|o>>>20)+n|0,a+=(o&n|~o&t)+l[6]-1473231341|0,a=(a<<17|a>>>15)+o|0,t+=(a&o|~a&n)+l[7]-45705983|0,t=(t<<22|t>>>10)+a|0,n+=(t&a|~t&o)+l[8]+1770035416|0,n=(n<<7|n>>>25)+t|0,o+=(n&t|~n&a)+l[9]-1958414417|0,o=(o<<12|o>>>20)+n|0,a+=(o&n|~o&t)+l[10]-42063|0,a=(a<<17|a>>>15)+o|0,t+=(a&o|~a&n)+l[11]-1990404162|0,t=(t<<22|t>>>10)+a|0,n+=(t&a|~t&o)+l[12]+1804603682|0,n=(n<<7|n>>>25)+t|0,o+=(n&t|~n&a)+l[13]-40341101|0,o=(o<<12|o>>>20)+n|0,a+=(o&n|~o&t)+l[14]-1502002290|0,a=(a<<17|a>>>15)+o|0,t+=(a&o|~a&n)+l[15]+1236535329|0,t=(t<<22|t>>>10)+a|0,n+=(t&o|a&~o)+l[1]-165796510|0,n=(n<<5|n>>>27)+t|0,o+=(n&a|t&~a)+l[6]-1069501632|0,o=(o<<9|o>>>23)+n|0,a+=(o&t|n&~t)+l[11]+643717713|0,a=(a<<14|a>>>18)+o|0,t+=(a&n|o&~n)+l[0]-373897302|0,t=(t<<20|t>>>12)+a|0,n+=(t&o|a&~o)+l[5]-701558691|0,n=(n<<5|n>>>27)+t|0,o+=(n&a|t&~a)+l[10]+38016083|0,o=(o<<9|o>>>23)+n|0,a+=(o&t|n&~t)+l[15]-660478335|0,a=(a<<14|a>>>18)+o|0,t+=(a&n|o&~n)+l[4]-405537848|0,t=(t<<20|t>>>12)+a|0,n+=(t&o|a&~o)+l[9]+568446438|0,n=(n<<5|n>>>27)+t|0,o+=(n&a|t&~a)+l[14]-1019803690|0,o=(o<<9|o>>>23)+n|0,a+=(o&t|n&~t)+l[3]-187363961|0,a=(a<<14|a>>>18)+o|0,t+=(a&n|o&~n)+l[8]+1163531501|0,t=(t<<20|t>>>12)+a|0,n+=(t&o|a&~o)+l[13]-1444681467|0,n=(n<<5|n>>>27)+t|0,o+=(n&a|t&~a)+l[2]-51403784|0,o=(o<<9|o>>>23)+n|0,a+=(o&t|n&~t)+l[7]+1735328473|0,a=(a<<14|a>>>18)+o|0,t+=(a&n|o&~n)+l[12]-1926607734|0,t=(t<<20|t>>>12)+a|0,n+=(t^a^o)+l[5]-378558|0,n=(n<<4|n>>>28)+t|0,o+=(n^t^a)+l[8]-2022574463|0,o=(o<<11|o>>>21)+n|0,a+=(o^n^t)+l[11]+1839030562|0,a=(a<<16|a>>>16)+o|0,t+=(a^o^n)+l[14]-35309556|0,t=(t<<23|t>>>9)+a|0,n+=(t^a^o)+l[1]-1530992060|0,n=(n<<4|n>>>28)+t|0,o+=(n^t^a)+l[4]+1272893353|0,o=(o<<11|o>>>21)+n|0,a+=(o^n^t)+l[7]-155497632|0,a=(a<<16|a>>>16)+o|0,t+=(a^o^n)+l[10]-1094730640|0,t=(t<<23|t>>>9)+a|0,n+=(t^a^o)+l[13]+681279174|0,n=(n<<4|n>>>28)+t|0,o+=(n^t^a)+l[0]-358537222|0,o=(o<<11|o>>>21)+n|0,a+=(o^n^t)+l[3]-722521979|0,a=(a<<16|a>>>16)+o|0,t+=(a^o^n)+l[6]+76029189|0,t=(t<<23|t>>>9)+a|0,n+=(t^a^o)+l[9]-640364487|0,n=(n<<4|n>>>28)+t|0,o+=(n^t^a)+l[12]-421815835|0,o=(o<<11|o>>>21)+n|0,a+=(o^n^t)+l[15]+530742520|0,a=(a<<16|a>>>16)+o|0,t+=(a^o^n)+l[2]-995338651|0,t=(t<<23|t>>>9)+a|0,n+=(a^(t|~o))+l[0]-198630844|0,n=(n<<6|n>>>26)+t|0,o+=(t^(n|~a))+l[7]+1126891415|0,o=(o<<10|o>>>22)+n|0,a+=(n^(o|~t))+l[14]-1416354905|0,a=(a<<15|a>>>17)+o|0,t+=(o^(a|~n))+l[5]-57434055|0,t=(t<<21|t>>>11)+a|0,n+=(a^(t|~o))+l[12]+1700485571|0,n=(n<<6|n>>>26)+t|0,o+=(t^(n|~a))+l[3]-1894986606|0,o=(o<<10|o>>>22)+n|0,a+=(n^(o|~t))+l[10]-1051523|0,a=(a<<15|a>>>17)+o|0,t+=(o^(a|~n))+l[1]-2054922799|0,t=(t<<21|t>>>11)+a|0,n+=(a^(t|~o))+l[8]+1873313359|0,n=(n<<6|n>>>26)+t|0,o+=(t^(n|~a))+l[15]-30611744|0,o=(o<<10|o>>>22)+n|0,a+=(n^(o|~t))+l[6]-1560198380|0,a=(a<<15|a>>>17)+o|0,t+=(o^(a|~n))+l[13]+1309151649|0,t=(t<<21|t>>>11)+a|0,n+=(a^(t|~o))+l[4]-145523070|0,n=(n<<6|n>>>26)+t|0,o+=(t^(n|~a))+l[11]-1120210379|0,o=(o<<10|o>>>22)+n|0,a+=(n^(o|~t))+l[2]+718787259|0,a=(a<<15|a>>>17)+o|0,t+=(o^(a|~n))+l[9]-343485551|0,t=(t<<21|t>>>11)+a|0,p[0]=n+p[0]|0,p[1]=t+p[1]|0,p[2]=a+p[2]|0,p[3]=o+p[3]|0}function f(p){var l=[],n;for(n=0;n<64;n+=4)l[n>>2]=p.charCodeAt(n)+(p.charCodeAt(n+1)<<8)+(p.charCodeAt(n+2)<<16)+(p.charCodeAt(n+3)<<24);return l}function h(p){var l=[],n;for(n=0;n<64;n+=4)l[n>>2]=p[n]+(p[n+1]<<8)+(p[n+2]<<16)+(p[n+3]<<24);return l}function m(p){var l=p.length,n=[1732584193,-271733879,-1732584194,271733878],t,a,o,w,T,F;for(t=64;t<=l;t+=64)u(n,f(p.substring(t-64,t)));for(p=p.substring(t-64),a=p.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<a;t+=1)o[t>>2]|=p.charCodeAt(t)<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(u(n,o),t=0;t<16;t+=1)o[t]=0;return w=l*8,w=w.toString(16).match(/(.*?)(.{0,8})$/),T=parseInt(w[2],16),F=parseInt(w[1],16)||0,o[14]=T,o[15]=F,u(n,o),n}function c(p){var l=p.length,n=[1732584193,-271733879,-1732584194,271733878],t,a,o,w,T,F;for(t=64;t<=l;t+=64)u(n,h(p.subarray(t-64,t)));for(p=t-64<l?p.subarray(t-64):new Uint8Array(0),a=p.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<a;t+=1)o[t>>2]|=p[t]<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(u(n,o),t=0;t<16;t+=1)o[t]=0;return w=l*8,w=w.toString(16).match(/(.*?)(.{0,8})$/),T=parseInt(w[2],16),F=parseInt(w[1],16)||0,o[14]=T,o[15]=F,u(n,o),n}function y(p){var l="",n;for(n=0;n<4;n+=1)l+=e[p>>n*8+4&15]+e[p>>n*8&15];return l}function g(p){var l;for(l=0;l<p.length;l+=1)p[l]=y(p[l]);return p.join("")}g(m("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(r=function(p,l){var n=(p&65535)+(l&65535),t=(p>>16)+(l>>16)+(n>>16);return t<<16|n&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function p(l,n){return l=l|0||0,l<0?Math.max(l+n,0):Math.min(l,n)}ArrayBuffer.prototype.slice=function(l,n){var t=this.byteLength,a=p(l,t),o=t,w,T,F,de;return n!==i&&(o=p(n,t)),a>o?new ArrayBuffer(0):(w=o-a,T=new ArrayBuffer(w),F=new Uint8Array(T),de=new Uint8Array(this,a,w),F.set(de),T)}})();function A(p){return/[\u0080-\uFFFF]/.test(p)&&(p=unescape(encodeURIComponent(p))),p}function v(p,l){var n=p.length,t=new ArrayBuffer(n),a=new Uint8Array(t),o;for(o=0;o<n;o+=1)a[o]=p.charCodeAt(o);return l?a:t}function x(p){return String.fromCharCode.apply(null,new Uint8Array(p))}function _(p,l,n){var t=new Uint8Array(p.byteLength+l.byteLength);return t.set(new Uint8Array(p)),t.set(new Uint8Array(l),p.byteLength),n?t:t.buffer}function I(p){var l=[],n=p.length,t;for(t=0;t<n-1;t+=2)l.push(parseInt(p.substr(t,2),16));return String.fromCharCode.apply(String,l)}function D(){this.reset()}return D.prototype.append=function(p){return this.appendBinary(A(p)),this},D.prototype.appendBinary=function(p){this._buff+=p,this._length+=p.length;var l=this._buff.length,n;for(n=64;n<=l;n+=64)u(this._hash,f(this._buff.substring(n-64,n)));return this._buff=this._buff.substring(n-64),this},D.prototype.end=function(p){var l=this._buff,n=l.length,t,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o;for(t=0;t<n;t+=1)a[t>>2]|=l.charCodeAt(t)<<(t%4<<3);return this._finish(a,n),o=g(this._hash),p&&(o=I(o)),this.reset(),o},D.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},D.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},D.prototype.setState=function(p){return this._buff=p.buff,this._length=p.length,this._hash=p.hash,this},D.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},D.prototype._finish=function(p,l){var n=l,t,a,o;if(p[n>>2]|=128<<(n%4<<3),n>55)for(u(this._hash,p),n=0;n<16;n+=1)p[n]=0;t=this._length*8,t=t.toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(t[2],16),o=parseInt(t[1],16)||0,p[14]=a,p[15]=o,u(this._hash,p)},D.hash=function(p,l){return D.hashBinary(A(p),l)},D.hashBinary=function(p,l){var n=m(p),t=g(n);return l?I(t):t},D.ArrayBuffer=function(){this.reset()},D.ArrayBuffer.prototype.append=function(p){var l=_(this._buff.buffer,p,!0),n=l.length,t;for(this._length+=p.byteLength,t=64;t<=n;t+=64)u(this._hash,h(l.subarray(t-64,t)));return this._buff=t-64<n?new Uint8Array(l.buffer.slice(t-64)):new Uint8Array(0),this},D.ArrayBuffer.prototype.end=function(p){var l=this._buff,n=l.length,t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],a,o;for(a=0;a<n;a+=1)t[a>>2]|=l[a]<<(a%4<<3);return this._finish(t,n),o=g(this._hash),p&&(o=I(o)),this.reset(),o},D.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},D.ArrayBuffer.prototype.getState=function(){var p=D.prototype.getState.call(this);return p.buff=x(p.buff),p},D.ArrayBuffer.prototype.setState=function(p){return p.buff=v(p.buff,!0),D.prototype.setState.call(this,p)},D.ArrayBuffer.prototype.destroy=D.prototype.destroy,D.ArrayBuffer.prototype._finish=D.prototype._finish,D.ArrayBuffer.hash=function(p,l){var n=c(new Uint8Array(p)),t=g(n);return l?I(t):t},D})});var ie=me((kt,Ce)=>{"use strict";Ce.exports={}});async function tt(i){let r=(await Promise.resolve().then(()=>J(Re(),1))).default;return new Promise((e,s)=>{let f=Math.ceil(i.size/2097152),h=0,m=new r.ArrayBuffer,c=new FileReader,y=()=>{let g=h*2097152,A=Math.min(g+2097152,i.size);c.readAsArrayBuffer(i.slice(g,A))};c.onload=g=>{let A=g.target?.result;if(!A){s(d.business("Failed to read file chunk"));return}m.append(A),h++,h<f?y():e({md5:m.end()})},c.onerror=()=>{s(d.business("Failed to calculate MD5: FileReader error"))},y()})}async function nt(i){let r=await Promise.resolve().then(()=>J(ie(),1));if(Buffer.isBuffer(i)){let s=r.createHash("md5");return s.update(i),{md5:s.digest("hex")}}let e=await Promise.resolve().then(()=>J(ie(),1));return new Promise((s,u)=>{let f=r.createHash("md5"),h=e.createReadStream(i);h.on("error",m=>u(d.business(`Failed to read file for MD5: ${m.message}`))),h.on("data",m=>f.update(m)),h.on("end",()=>s({md5:f.digest("hex")}))})}async function U(i){let r=G();if(r==="browser"){if(!(i instanceof Blob))throw d.business("Invalid input for browser MD5 calculation: Expected Blob or File.");return tt(i)}if(r==="node"){if(!(Buffer.isBuffer(i)||typeof i=="string"))throw d.business("Invalid input for Node.js MD5 calculation: Expected Buffer or file path string.");return nt(i)}throw d.business("Unknown or unsupported execution environment for MD5 calculation.")}var j=C(()=>{"use strict";V();R()});function _e(i){return ot.test(i)}var it,ot,$e=C(()=>{"use strict";it=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],ot=new RegExp(it.join("|"))});function Ne(i,r){if(!i||i.length===0)return[];if(!r?.allowUnbuilt&&i.find(s=>s&&M(s)))throw d.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return i.filter(e=>{if(!e)return!1;let s=e.replace(/\\/g,"/").split("/").filter(Boolean);if(s.length===0)return!0;let u=s[s.length-1];if(_e(u))return!1;for(let h of s)if(h!==".well-known"&&(h.startsWith(".")||h.length>255))return!1;let f=s.slice(0,-1);for(let h of f)if(st.some(m=>h.toLowerCase()===m.toLowerCase()))return!1;return!0})}var st,oe=C(()=>{"use strict";$e();R();st=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function Y(i){return i.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var Ue=C(()=>{"use strict"});function Le(i,r={}){if(r.flatten===!1)return i.map(s=>({path:Y(s),name:se(s)}));let e=at(i);return i.map(s=>{let u=Y(s);if(e){let f=e.endsWith("/")?e:`${e}/`;u.startsWith(f)&&(u=u.substring(f.length))}return u||(u=se(s)),{path:u,name:se(s)}})}function at(i){if(!i.length)return"";let e=i.map(f=>Y(f)).map(f=>f.split("/")),s=[],u=Math.min(...e.map(f=>f.length));for(let f=0;f<u-1;f++){let h=e[0][f];if(e.every(m=>m[f]===h))s.push(h);else break}return s.join("/")}function se(i){return i.split(/[/\\]/).pop()||i}var ae=C(()=>{"use strict";Ue()});function le(i,r=1){if(i===0)return"0 Bytes";let e=1024,s=["Bytes","KB","MB","GB"],u=Math.floor(Math.log(i)/Math.log(e));return parseFloat((i/Math.pow(e,u)).toFixed(r))+" "+s[u]}function pe(i){if(Ae(i))return{valid:!1,reason:"File name contains unsafe characters"};if(i.startsWith(" ")||i.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(i.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let r=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,e=i.split("/").pop()||i;return r.test(e)?{valid:!1,reason:"File name uses a reserved system name"}:i.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function dn(i,r){let e=[],s=[],u=[];if(i.length===0){let c={file:"(no files)",message:"At least one file must be provided"};return e.push(c),{files:[],validFiles:[],errors:e,warnings:[],canDeploy:!1}}for(let c of i)if(M(c.name))return e.push({file:c.name,message:"Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:i.map(y=>({...y,status:b.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:e,warnings:[],canDeploy:!1};if(i.length>r.maxFilesCount){let c={file:`(${i.length} files)`,message:`File count (${i.length}) exceeds limit of ${r.maxFilesCount}`};return e.push(c),{files:i.map(y=>({...y,status:b.VALIDATION_FAILED,statusMessage:c.message})),validFiles:[],errors:e,warnings:[],canDeploy:!1}}let f=0;for(let c of i){let y=b.READY,g="Ready for upload",A=c.name?pe(c.name):{valid:!1,reason:"File name cannot be empty"};if(c.status===b.PROCESSING_ERROR)y=b.VALIDATION_FAILED,g=c.statusMessage||"File failed during processing",e.push({file:c.name,message:g});else if(c.size===0){y=b.EXCLUDED,g="File is empty (0 bytes) and cannot be deployed due to storage limitations",s.push({file:c.name,message:g}),u.push({...c,status:y,statusMessage:g});continue}else c.size<0?(y=b.VALIDATION_FAILED,g="File size must be positive",e.push({file:c.name,message:g})):!c.name||c.name.trim().length===0?(y=b.VALIDATION_FAILED,g="File name cannot be empty",e.push({file:c.name||"(empty)",message:g})):c.name.includes("\0")?(y=b.VALIDATION_FAILED,g="File name contains invalid characters (null byte)",e.push({file:c.name,message:g})):A.valid?k(c.name)?(y=b.VALIDATION_FAILED,g=`File extension not allowed: "${c.name}"`,e.push({file:c.name,message:g})):c.size>r.maxFileSize?(y=b.VALIDATION_FAILED,g=`File size (${le(c.size)}) exceeds limit of ${le(r.maxFileSize)}`,e.push({file:c.name,message:g})):(f+=c.size,f>r.maxTotalSize&&(y=b.VALIDATION_FAILED,g=`Total size would exceed limit of ${le(r.maxTotalSize)}`,e.push({file:c.name,message:g}))):(y=b.VALIDATION_FAILED,g=A.reason||"Invalid file name",e.push({file:c.name,message:g}));u.push({...c,status:y,statusMessage:g})}e.length>0&&(u=u.map(c=>c.status===b.EXCLUDED?c:{...c,status:b.VALIDATION_FAILED,statusMessage:c.status===b.VALIDATION_FAILED?c.statusMessage:"Deployment failed due to validation errors in bundle"}));let h=e.length===0?u.filter(c=>c.status===b.READY):[],m=e.length===0;return{files:u,validFiles:h,errors:e,warnings:s,canDeploy:m}}function lt(i){return i.filter(r=>r.status===b.READY)}function mn(i){return lt(i).length>0}var ue=C(()=>{"use strict";R()});function Be(i,r){if(i.includes("\0")||i.includes("/../")||i.startsWith("../")||i.endsWith("/.."))throw d.business(`Security error: Unsafe file path "${i}" for file: ${r}`)}function ke(i,r){let e=pe(i);if(!e.valid)throw d.business(e.reason||"Invalid file name");if(k(i))throw d.business(`File extension not allowed: "${r}"`)}var ce=C(()=>{"use strict";R();ue()});var ze={};Ye(ze,{processFilesForBrowser:()=>Me});async function Me(i,r={}){if(G()!=="browser")throw d.business("processFilesForBrowser can only be called in a browser environment.");let e=i.map(A=>A.webkitRelativePath||A.name),s=r.build||r.prerender,u=Le(e,{flatten:r.pathDetect!==!1}),f=u.map(A=>A.path),h=new Set(Ne(f,{allowUnbuilt:s})),m=[];for(let A=0;A<i.length;A++)h.has(f[A])&&m.push({file:i[A],deployPath:u[A].path});if(m.length===0)return[];if(s){let A=[];for(let v=0;v<m.length;v++){let{file:x,deployPath:_}=m[v];if(x.size===0)continue;let{md5:I}=await U(x);A.push({path:_,content:x,size:x.size,md5:I})}return A}let c=$(),y=[],g=0;for(let A=0;A<m.length;A++){let{file:v,deployPath:x}=m[A];if(Be(x,v.name),v.size===0)continue;if(ke(x,v.name),v.size>c.maxFileSize)throw d.business(`File ${v.name} is too large. Maximum allowed size is ${c.maxFileSize/(1024*1024)}MB.`);if(g+=v.size,g>c.maxTotalSize)throw d.business(`Total deploy size is too large. Maximum allowed is ${c.maxTotalSize/(1024*1024)}MB.`);let{md5:_}=await U(v);y.push({path:x,content:v,size:v.size,md5:_})}if(y.length>c.maxFilesCount)throw d.business(`Too many files to deploy. Maximum allowed is ${c.maxFilesCount} files.`);return y}var fe=C(()=>{"use strict";j();R();V();oe();ae();ce();N()});R();var K=class{constructor(){this.handlers=new Map}on(r,e){this.handlers.has(r)||this.handlers.set(r,new Set),this.handlers.get(r).add(e)}off(r,e){let s=this.handlers.get(r);s&&(s.delete(e),s.size===0&&this.handlers.delete(r))}emit(r,...e){let s=this.handlers.get(r);if(!s)return;let u=Array.from(s);for(let f of u)try{f(...e)}catch(h){s.delete(f),r!=="error"&&setTimeout(()=>{h instanceof Error?this.emit("error",h,String(r)):this.emit("error",new Error(String(h)),String(r))},0)}}transfer(r){this.handlers.forEach((e,s)=>{e.forEach(u=>{r.on(s,u)})})}clear(){this.handlers.clear()}};var E={DEPLOYMENTS:"/deployments",DOMAINS:"/domains",TOKENS:"/tokens",ACCOUNT:"/account",CONFIG:"/config",PING:"/ping",SPA_CHECK:"/spa-check"},Ze=3e4,H=class extends K{constructor(e){super();this.globalHeaders={};this.apiUrl=e.apiUrl||z,this.getAuthHeadersCallback=e.getAuthHeaders,this.useCredentials=e.useCredentials??!1,this.timeout=e.timeout??Ze,this.createDeployBody=e.createDeployBody,this.deployEndpoint=e.deployEndpoint||E.DEPLOYMENTS}setGlobalHeaders(e){this.globalHeaders=e}transferEventsTo(e){this.transfer(e)}async executeRequest(e,s,u){let f=this.mergeHeaders(s.headers),{signal:h,cleanup:m}=this.createTimeoutSignal(s.signal),c={...s,headers:f,credentials:this.useCredentials&&!f.Authorization?"include":void 0,signal:h};this.emit("request",e,c);try{let y=await fetch(e,c);return m(),y.ok||await this.handleResponseError(y,u),this.emit("response",this.safeClone(y),e),{data:await this.parseResponse(this.safeClone(y)),status:y.status}}catch(y){m();let g=y instanceof Error?y:new Error(String(y));this.emit("error",g,e),this.handleFetchError(y,u)}}async request(e,s,u){let{data:f}=await this.executeRequest(e,s,u);return f}async requestWithStatus(e,s,u){return this.executeRequest(e,s,u)}mergeHeaders(e={}){return{...this.globalHeaders,...this.getAuthHeadersCallback(),...e}}createTimeoutSignal(e){let s=new AbortController,u=setTimeout(()=>s.abort(),this.timeout);if(e){let f=()=>s.abort();e.addEventListener("abort",f),e.aborted&&s.abort()}return{signal:s.signal,cleanup:()=>clearTimeout(u)}}safeClone(e){try{return e.clone()}catch{return e}}async parseResponse(e){if(!(e.headers.get("Content-Length")==="0"||e.status===204))return e.json()}async handleResponseError(e,s){let u={};try{if(e.headers.get("content-type")?.includes("application/json")){let m=await e.json();if(m&&typeof m=="object"){let c=m;typeof c.message=="string"&&(u.message=c.message),typeof c.error=="string"&&(u.error=c.error)}}else u={message:await e.text()}}catch{u={message:"Failed to parse error response"}}let f=u.message||u.error||`${s} failed`;throw e.status===401?d.authentication(f):d.api(f,e.status)}handleFetchError(e,s){throw Z(e)?e:e instanceof Error&&e.name==="AbortError"?d.cancelled(`${s} was cancelled`):e instanceof TypeError&&e.message.includes("fetch")?d.network(`${s} failed: ${e.message}`,e):e instanceof Error?d.business(`${s} failed: ${e.message}`):d.business(`${s} failed: Unknown error`)}async deploy(e,s={}){if(!e.length)throw d.business("No files to deploy");for(let c of e)if(!c.md5)throw d.file(`MD5 checksum missing for file: ${c.path}`,c.path);let u=s.build||s.prerender||s.spa?{build:s.build,prerender:s.prerender,spa:s.spa}:void 0,{body:f,headers:h}=await this.createDeployBody(e,s.labels,s.via,u),m={};return s.deployToken?m.Authorization=`Bearer ${s.deployToken}`:s.apiKey&&(m.Authorization=`Bearer ${s.apiKey}`),s.caller&&(m["X-Caller"]=s.caller),this.request(`${s.apiUrl||this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:f,headers:{...h,...m},signal:s.signal||null},"Deploy")}async listDeployments(){return this.request(`${this.apiUrl}${E.DEPLOYMENTS}`,{method:"GET"},"List deployments")}async getDeployment(e){return this.request(`${this.apiUrl}${E.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(e,s){return this.request(`${this.apiUrl}${E.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:s})},"Update deployment labels")}async removeDeployment(e){await this.request(`${this.apiUrl}${E.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove deployment")}async setDomain(e,s,u){let f={};s&&(f.deployment=s),u!==void 0&&(f.labels=u);let{data:h,status:m}=await this.requestWithStatus(`${this.apiUrl}${E.DOMAINS}/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)},"Set domain");return{...h,isCreate:m===201}}async listDomains(){return this.request(`${this.apiUrl}${E.DOMAINS}`,{method:"GET"},"List domains")}async getDomain(e){return this.request(`${this.apiUrl}${E.DOMAINS}/${encodeURIComponent(e)}`,{method:"GET"},"Get domain")}async removeDomain(e){await this.request(`${this.apiUrl}${E.DOMAINS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove domain")}async verifyDomain(e){return this.request(`${this.apiUrl}${E.DOMAINS}/${encodeURIComponent(e)}/verify`,{method:"POST"},"Verify domain")}async getDomainDns(e){return this.request(`${this.apiUrl}${E.DOMAINS}/${encodeURIComponent(e)}/dns`,{method:"GET"},"Get domain DNS")}async getDomainRecords(e){return this.request(`${this.apiUrl}${E.DOMAINS}/${encodeURIComponent(e)}/records`,{method:"GET"},"Get domain records")}async getDomainShare(e){return this.request(`${this.apiUrl}${E.DOMAINS}/${encodeURIComponent(e)}/share`,{method:"GET"},"Get domain share")}async validateDomain(e){return this.request(`${this.apiUrl}${E.DOMAINS}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:e})},"Validate domain")}async createToken(e,s){let u={};return e!==void 0&&(u.ttl=e),s!==void 0&&(u.labels=s),this.request(`${this.apiUrl}${E.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)},"Create token")}async listTokens(){return this.request(`${this.apiUrl}${E.TOKENS}`,{method:"GET"},"List tokens")}async removeToken(e){await this.request(`${this.apiUrl}${E.TOKENS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove token")}async fetchAgentToken(){return this.request(`${this.apiUrl}${E.TOKENS}/agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})},"Fetch agent token")}async getAccount(){return this.request(`${this.apiUrl}${E.ACCOUNT}`,{method:"GET"},"Get account")}async getConfig(){return this.request(`${this.apiUrl}${E.CONFIG}`,{method:"GET"},"Get config")}async ping(){return(await this.request(`${this.apiUrl}${E.PING}`,{method:"GET"},"Ping"))?.success||!1}async checkSPA(e,s={}){let u=e.find(y=>y.path==="index.html"||y.path==="/index.html");if(!u||u.size>100*1024)return!1;let f;if(typeof Buffer<"u"&&Buffer.isBuffer(u.content))f=u.content.toString("utf-8");else if(typeof Blob<"u"&&u.content instanceof Blob)f=await u.content.text();else if(typeof File<"u"&&u.content instanceof File)f=await u.content.text();else return!1;let h={"Content-Type":"application/json"};s.deployToken?h.Authorization=`Bearer ${s.deployToken}`:s.apiKey&&(h.Authorization=`Bearer ${s.apiKey}`);let m={files:e.map(y=>y.path),index:f};return(await this.request(`${this.apiUrl}${E.SPA_CHECK}`,{method:"POST",headers:h,body:JSON.stringify(m)},"SPA check")).isSPA}};R();N();R();R();function Ee(i={},r={}){let e={apiUrl:i.apiUrl||r.apiUrl||z,apiKey:i.apiKey!==void 0?i.apiKey:r.apiKey,deployToken:i.deployToken!==void 0?i.deployToken:r.deployToken},s={apiUrl:e.apiUrl};return e.apiKey!==void 0&&(s.apiKey=e.apiKey),e.deployToken!==void 0&&(s.deployToken=e.deployToken),s}function be(i,r){let e={...i};return e.apiUrl===void 0&&r.apiUrl!==void 0&&(e.apiUrl=r.apiUrl),e.apiKey===void 0&&r.apiKey!==void 0&&(e.apiKey=r.apiKey),e.deployToken===void 0&&r.deployToken!==void 0&&(e.deployToken=r.deployToken),e.timeout===void 0&&r.timeout!==void 0&&(e.timeout=r.timeout),e.maxConcurrency===void 0&&r.maxConcurrency!==void 0&&(e.maxConcurrency=r.maxConcurrency),e.onProgress===void 0&&r.onProgress!==void 0&&(e.onProgress=r.onProgress),e.caller===void 0&&r.caller!==void 0&&(e.caller=r.caller),e}R();j();async function rt(){let i=JSON.stringify(De,null,2),r;typeof Buffer<"u"?r=Buffer.from(i,"utf-8"):r=new Blob([i],{type:"application/json"});let{md5:e}=await U(r);return{path:ee,content:r,size:i.length,md5:e}}async function xe(i,r,e){if(e.spaDetect===!1||e.spa||e.build||e.prerender||i.some(s=>s.path===ee))return i;try{if(await r.checkSPA(i,e)){let u=await rt();return[...i,u]}}catch{}return i}function Te(i){let{getApi:r,ensureInit:e,processInput:s,clientDefaults:u,hasAuth:f}=i;return{upload:async(h,m={})=>{await e();let c=u?be(m,u):m;if(f&&!f()&&!c.deployToken&&!c.apiKey)try{let A=r(),{secret:v}=await A.fetchAgentToken();c.deployToken=v}catch{throw d.authentication("Too many requests; try again later or configure a free API key with 'ship config'")}if(!s)throw d.config("processInput function is not provided.");let y=r(),g=await s(h,c);return g=await xe(g,y,c),y.deploy(g,c)},list:async()=>(await e(),r().listDeployments()),get:async h=>(await e(),r().getDeployment(h)),set:async(h,m)=>(await e(),r().updateDeploymentLabels(h,m.labels)),remove:async h=>{await e(),await r().removeDeployment(h)}}}function Fe(i){let{getApi:r,ensureInit:e}=i;return{set:async(s,u={})=>(await e(),r().setDomain(s,u.deployment,u.labels)),list:async()=>(await e(),r().listDomains()),get:async s=>(await e(),r().getDomain(s)),remove:async s=>{await e(),await r().removeDomain(s)},verify:async s=>(await e(),r().verifyDomain(s)),validate:async s=>(await e(),r().validateDomain(s)),dns:async s=>(await e(),r().getDomainDns(s)),records:async s=>(await e(),r().getDomainRecords(s)),share:async s=>(await e(),r().getDomainShare(s))}}function Ie(i){let{getApi:r,ensureInit:e}=i;return{get:async()=>(await e(),r().getAccount())}}function Pe(i){let{getApi:r,ensureInit:e}=i;return{create:async(s={})=>(await e(),r().createToken(s.ttl,s.labels)),list:async()=>(await e(),r().listTokens()),remove:async s=>{await e(),await r().removeToken(s)}}}var q=class{constructor(r={}){this.initPromise=null;this._config=null;this.auth=null;this.customHeaders={};this.clientOptions=r,r.deployToken?this.auth={type:"token",value:r.deployToken}:r.apiKey&&(this.auth={type:"apiKey",value:r.apiKey}),this.authHeadersCallback=()=>this.getAuthHeaders();let e=this.resolveInitialConfig(r);this.http=new H({...r,...e,getAuthHeaders:this.authHeadersCallback,createDeployBody:this.getDeployBodyCreator()});let s={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this._deployments=Te({...s,processInput:(u,f)=>this.processInput(u,f),clientDefaults:this.clientOptions,hasAuth:()=>this.hasAuth()}),this._domains=Fe(s),this._account=Ie(s),this._tokens=Pe(s)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.loadFullConfig()),this.initPromise}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(r,e){return this.deployments.upload(r,e)}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=$(),this._config)}on(r,e){this.http.on(r,e)}off(r,e){this.http.off(r,e)}setHeaders(r){this.customHeaders=r,this.http.setGlobalHeaders(r)}clearHeaders(){this.customHeaders={},this.http.setGlobalHeaders({})}replaceHttpClient(r){if(this.http?.transferEventsTo)try{this.http.transferEventsTo(r)}catch(e){console.warn("Event transfer failed during client replacement:",e)}this.http=r,Object.keys(this.customHeaders).length>0&&this.http.setGlobalHeaders(this.customHeaders)}setDeployToken(r){if(!r||typeof r!="string")throw d.business("Invalid deploy token provided. Deploy token must be a non-empty string.");this.auth={type:"token",value:r}}setApiKey(r){if(!r||typeof r!="string")throw d.business("Invalid API key provided. API key must be a non-empty string.");this.auth={type:"apiKey",value:r}}getAuthHeaders(){return this.auth?{Authorization:`Bearer ${this.auth.value}`}:{}}hasAuth(){return this.clientOptions.useCredentials?!0:this.auth!==null}};N();R();R();async function Oe(i,r,e,s){let u=new FormData,f=[];for(let h of i){if(!(h.content instanceof File||h.content instanceof Blob))throw d.file(`Unsupported file.content type for browser: ${h.path}`,h.path);if(!h.md5)throw d.file(`File missing md5 checksum: ${h.path}`,h.path);let m=new File([h.content],h.path,{type:"application/octet-stream"});u.append("files[]",m),f.push(h.md5)}return u.append("checksums",JSON.stringify(f)),r&&r.length>0&&u.append("labels",JSON.stringify(r)),e&&u.append("via",e),s?.build&&u.append("build","true"),s?.prerender&&u.append("prerender","true"),s?.spa&&u.append("spa","true"),{body:u,headers:{}}}j();function rn(i,r,e,s=!0){let u=i===1?r:e;return s?`${i} ${u}`:u}oe();ae();V();ue();ce();R();N();fe();var he=class extends q{constructor(r={}){super(r)}resolveInitialConfig(r){return Ee(r,{})}async loadFullConfig(){try{let r=await this.http.getConfig();ne(r)}catch(r){throw this.initPromise=null,r}}async processInput(r,e){if(!this.isFileArray(r))throw d.business("Invalid input type for browser environment. Expected File[].");if(r.length===0)throw d.business("No files to deploy.");let{processFilesForBrowser:s}=await Promise.resolve().then(()=>(fe(),ze));return s(r,e)}isFileArray(r){return Array.isArray(r)&&r.every(e=>e instanceof File)}getDeployBodyCreator(){return Oe}},jn=he;export{X as API_KEY_HEX_LENGTH,ht as API_KEY_HINT_LENGTH,P as API_KEY_PREFIX,ye as API_KEY_TOTAL_LENGTH,ft as AccountPlan,H as ApiHttp,dt as AuthMethod,We as BLOCKED_EXTENSIONS,z as DEFAULT_API,ee as DEPLOYMENT_CONFIG_FILENAME,Q as DEPLOY_TOKEN_HEX_LENGTH,O as DEPLOY_TOKEN_PREFIX,ge as DEPLOY_TOKEN_TOTAL_LENGTH,ut as DeploymentStatus,ct as DomainStatus,S as ErrorType,b as FILE_VALIDATION_STATUS,b as FileValidationStatus,st as JUNK_DIRECTORIES,vt as LABEL_CONSTRAINTS,wt as LABEL_PATTERN,De as SPA_DEFAULT_CONFIG,he as Ship,d as ShipError,Qe as UNBUILT_PROJECT_MARKERS,Xe as UNSAFE_FILENAME_CHARS,Lt as __setTestEnvironment,mn as allValidFilesReady,U as calculateMD5,Ie as createAccountResource,Te as createDeploymentResource,Fe as createDomainResource,Pe as createTokenResource,jn as default,Ct as deserializeLabels,St as extractSubdomain,Ne as filterJunk,le as formatFileSize,Et as generateDeploymentUrl,bt as generateDomainUrl,$ as getCurrentConfig,G as getENV,lt as getValidFiles,M as hasUnbuiltMarker,Ae as hasUnsafeChars,k as isBlockedExtension,Dt as isCustomDomain,At as isDeployment,Se as isPlatformDomain,Z as isShipError,be as mergeDeployOptions,Le as optimizeDeployPaths,rn as pluralize,Me as processFilesForBrowser,Ee as resolveConfig,Rt as serializeLabels,ne as setPlatformConfig,mt as validateApiKey,gt as validateApiUrl,ke as validateDeployFile,Be as validateDeployPath,yt as validateDeployToken,pe as validateFileName,dn as validateFiles};
|
|
1
|
+
var qe=Object.create;var z=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var We=Object.getPrototypeOf,Je=Object.prototype.hasOwnProperty;var Qe=(n,i,e)=>i in n?z(n,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[i]=e;var R=(n,i)=>()=>(n&&(i=n(n=0)),i);var Ae=(n,i)=>()=>(i||n((i={exports:{}}).exports,i),i.exports),Ze=(n,i)=>{for(var e in i)z(n,e,{get:i[e],enumerable:!0})},et=(n,i,e,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let u of Ye(i))!Je.call(n,u)&&u!==e&&z(n,u,{get:()=>i[u],enumerable:!(s=Xe(i,u))||s.enumerable});return n};var Z=(n,i,e)=>(e=n!=null?qe(We(n)):{},et(i||!n||!n.__esModule?z(e,"default",{value:n,enumerable:!0}):e,n));var H=(n,i,e)=>Qe(n,typeof i!="symbol"?i+"":i,e);function L(n){return n!==null&&typeof n=="object"&&"name"in n&&n.name==="ShipError"&&"status"in n}function K(n){let i=n.lastIndexOf(".");if(i===-1||i===n.length-1)return!1;let e=n.slice(i+1).toLowerCase();return tt.has(e)}function Ee(n){return nt.test(n)}function G(n){return n.replace(/\\/g,"/").split("/").filter(Boolean).some(e=>rt.has(e))}function St(n){if(!n.startsWith(_))throw d.validation(`API key must start with "${_}"`);if(n.length!==De)throw d.validation(`API key must be ${De} characters total (${_} + ${te} hex chars)`);let i=n.slice(_.length);if(!/^[a-f0-9]{64}$/i.test(i))throw d.validation(`API key must contain ${te} hexadecimal characters after "${_}" prefix`)}function Et(n){if(!n.startsWith(O))throw d.validation(`Deploy token must start with "${O}"`);if(n.length!==Se)throw d.validation(`Deploy token must be ${Se} characters total (${O} + ${ne} hex chars)`);let i=n.slice(O.length);if(!/^[a-f0-9]{64}$/i.test(i))throw d.validation(`Deploy token must contain ${ne} hexadecimal characters after "${O}" prefix`)}function bt(n){try{let i=new URL(n);if(!["http:","https:"].includes(i.protocol))throw d.validation("API URL must use http:// or https:// protocol");if(i.pathname!=="/"&&i.pathname!=="")throw d.validation("API URL must not contain a path");if(i.search||i.hash)throw d.validation("API URL must not contain query parameters or fragments")}catch(i){throw L(i)?i:d.validation("API URL must be a valid URL")}}function wt(n){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(n)}function we(n,i){return n.endsWith(`.${i}`)}function vt(n,i){return!we(n,i)}function Tt(n,i){return we(n,i)?n.slice(0,-(i.length+1)):null}function Rt(n){return`https://${n}`}function Ct(n){return`https://${n}`}function xt(n){return!n||n.length===0?null:JSON.stringify(n)}function It(n){if(!n)return[];try{let i=JSON.parse(n);return Array.isArray(i)?i:[]}catch{return[]}}var mt,yt,gt,D,ee,d,tt,nt,rt,_,te,De,At,O,ne,Se,Dt,re,be,V,b,F,ve,$,v=R(()=>{"use strict";mt={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},yt={PENDING:"pending",PARTIAL:"partial",SUCCESS:"success",PAUSED:"paused"},gt={FREE:"free",STANDARD:"standard",SPONSORED:"sponsored",ENTERPRISE:"enterprise",SUSPENDED:"suspended",TERMINATING:"terminating",TERMINATED:"terminated"};(function(n){n.Validation="validation_failed",n.NotFound="not_found",n.RateLimit="rate_limit_exceeded",n.Authentication="authentication_failed",n.Business="business_logic_error",n.Api="internal_server_error",n.Network="network_error",n.Cancelled="operation_cancelled",n.File="file_error",n.Config="config_error"})(D||(D={}));ee={client:new Set([D.Business,D.Config,D.File,D.Validation]),network:new Set([D.Network]),auth:new Set([D.Authentication])},d=class n extends Error{constructor(e,s,u,f){super(s);H(this,"type");H(this,"status");H(this,"details");this.type=e,this.status=u,this.details=f,this.name="ShipError"}toResponse(){let e=this.type===D.Authentication&&this.details?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:e}}static fromResponse(e){return new n(e.error,e.message,e.status,e.details)}static validation(e,s){return new n(D.Validation,e,400,s)}static notFound(e,s){let u=s?`${e} ${s} not found`:`${e} not found`;return new n(D.NotFound,u,404)}static rateLimit(e="Too many requests"){return new n(D.RateLimit,e,429)}static authentication(e="Authentication required",s){return new n(D.Authentication,e,401,s)}static business(e,s=400){return new n(D.Business,e,s)}static network(e,s){return new n(D.Network,e,void 0,{cause:s})}static cancelled(e){return new n(D.Cancelled,e)}static file(e,s){return new n(D.File,e,void 0,{filePath:s})}static config(e,s){return new n(D.Config,e,void 0,s)}static api(e,s=500){return new n(D.Api,e,s)}static database(e,s=500){return new n(D.Api,e,s)}static storage(e,s=500){return new n(D.Api,e,s)}get filePath(){return this.details?.filePath}isClientError(){return ee.client.has(this.type)}isNetworkError(){return ee.network.has(this.type)}isAuthError(){return ee.auth.has(this.type)}isValidationError(){return this.type===D.Validation}isFileError(){return this.type===D.File}isConfigError(){return this.type===D.Config}isType(e){return this.type===e}};tt=new Set(["exe","msi","dll","scr","bat","cmd","com","pif","app","deb","rpm","pkg","mpkg","dmg","iso","img","cab","cpl","chm","ps1","vbs","vbe","ws","wsf","wsc","wsh","reg","jar","jnlp","apk","crx","lnk","inf","hta"]);nt=/[\x00-\x1f\x7f#?%\\<>"]/;rt=new Set(["node_modules","package.json"]);_="ship-",te=64,De=_.length+te,At=4,O="token-",ne=64,Se=O.length+ne,Dt={JWT:"jwt",API_KEY:"apiKey",TOKEN:"token",WEBHOOK:"webhook",SYSTEM:"system"},re="ship.json",be={rewrites:[{source:"/(.*)",destination:"/index.html"}]};V="https://api.shipstatic.com",b={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};F={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},ve=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;$={MIN_LENGTH:6,MAX_LENGTH:128}});function oe(n){ie=n}function B(){if(ie===null)throw d.config("Platform configuration not initialized. The SDK must fetch configuration from the API before performing operations.");return ie}var ie,M=R(()=>{"use strict";v();ie=null});function Kt(n){se=n}function ot(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function X(){return se||ot()}var se,Y=R(()=>{"use strict";se=null});var Fe=Ae((xe,Ie)=>{"use strict";(function(n){if(typeof xe=="object")Ie.exports=n();else if(typeof define=="function"&&define.amd)define(n);else{var i;try{i=window}catch{i=self}i.SparkMD5=n()}})(function(n){"use strict";var i=function(p,l){return p+l&4294967295},e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function s(p,l,r,t,a,o){return l=i(i(l,p),i(t,o)),i(l<<a|l>>>32-a,r)}function u(p,l){var r=p[0],t=p[1],a=p[2],o=p[3];r+=(t&a|~t&o)+l[0]-680876936|0,r=(r<<7|r>>>25)+t|0,o+=(r&t|~r&a)+l[1]-389564586|0,o=(o<<12|o>>>20)+r|0,a+=(o&r|~o&t)+l[2]+606105819|0,a=(a<<17|a>>>15)+o|0,t+=(a&o|~a&r)+l[3]-1044525330|0,t=(t<<22|t>>>10)+a|0,r+=(t&a|~t&o)+l[4]-176418897|0,r=(r<<7|r>>>25)+t|0,o+=(r&t|~r&a)+l[5]+1200080426|0,o=(o<<12|o>>>20)+r|0,a+=(o&r|~o&t)+l[6]-1473231341|0,a=(a<<17|a>>>15)+o|0,t+=(a&o|~a&r)+l[7]-45705983|0,t=(t<<22|t>>>10)+a|0,r+=(t&a|~t&o)+l[8]+1770035416|0,r=(r<<7|r>>>25)+t|0,o+=(r&t|~r&a)+l[9]-1958414417|0,o=(o<<12|o>>>20)+r|0,a+=(o&r|~o&t)+l[10]-42063|0,a=(a<<17|a>>>15)+o|0,t+=(a&o|~a&r)+l[11]-1990404162|0,t=(t<<22|t>>>10)+a|0,r+=(t&a|~t&o)+l[12]+1804603682|0,r=(r<<7|r>>>25)+t|0,o+=(r&t|~r&a)+l[13]-40341101|0,o=(o<<12|o>>>20)+r|0,a+=(o&r|~o&t)+l[14]-1502002290|0,a=(a<<17|a>>>15)+o|0,t+=(a&o|~a&r)+l[15]+1236535329|0,t=(t<<22|t>>>10)+a|0,r+=(t&o|a&~o)+l[1]-165796510|0,r=(r<<5|r>>>27)+t|0,o+=(r&a|t&~a)+l[6]-1069501632|0,o=(o<<9|o>>>23)+r|0,a+=(o&t|r&~t)+l[11]+643717713|0,a=(a<<14|a>>>18)+o|0,t+=(a&r|o&~r)+l[0]-373897302|0,t=(t<<20|t>>>12)+a|0,r+=(t&o|a&~o)+l[5]-701558691|0,r=(r<<5|r>>>27)+t|0,o+=(r&a|t&~a)+l[10]+38016083|0,o=(o<<9|o>>>23)+r|0,a+=(o&t|r&~t)+l[15]-660478335|0,a=(a<<14|a>>>18)+o|0,t+=(a&r|o&~r)+l[4]-405537848|0,t=(t<<20|t>>>12)+a|0,r+=(t&o|a&~o)+l[9]+568446438|0,r=(r<<5|r>>>27)+t|0,o+=(r&a|t&~a)+l[14]-1019803690|0,o=(o<<9|o>>>23)+r|0,a+=(o&t|r&~t)+l[3]-187363961|0,a=(a<<14|a>>>18)+o|0,t+=(a&r|o&~r)+l[8]+1163531501|0,t=(t<<20|t>>>12)+a|0,r+=(t&o|a&~o)+l[13]-1444681467|0,r=(r<<5|r>>>27)+t|0,o+=(r&a|t&~a)+l[2]-51403784|0,o=(o<<9|o>>>23)+r|0,a+=(o&t|r&~t)+l[7]+1735328473|0,a=(a<<14|a>>>18)+o|0,t+=(a&r|o&~r)+l[12]-1926607734|0,t=(t<<20|t>>>12)+a|0,r+=(t^a^o)+l[5]-378558|0,r=(r<<4|r>>>28)+t|0,o+=(r^t^a)+l[8]-2022574463|0,o=(o<<11|o>>>21)+r|0,a+=(o^r^t)+l[11]+1839030562|0,a=(a<<16|a>>>16)+o|0,t+=(a^o^r)+l[14]-35309556|0,t=(t<<23|t>>>9)+a|0,r+=(t^a^o)+l[1]-1530992060|0,r=(r<<4|r>>>28)+t|0,o+=(r^t^a)+l[4]+1272893353|0,o=(o<<11|o>>>21)+r|0,a+=(o^r^t)+l[7]-155497632|0,a=(a<<16|a>>>16)+o|0,t+=(a^o^r)+l[10]-1094730640|0,t=(t<<23|t>>>9)+a|0,r+=(t^a^o)+l[13]+681279174|0,r=(r<<4|r>>>28)+t|0,o+=(r^t^a)+l[0]-358537222|0,o=(o<<11|o>>>21)+r|0,a+=(o^r^t)+l[3]-722521979|0,a=(a<<16|a>>>16)+o|0,t+=(a^o^r)+l[6]+76029189|0,t=(t<<23|t>>>9)+a|0,r+=(t^a^o)+l[9]-640364487|0,r=(r<<4|r>>>28)+t|0,o+=(r^t^a)+l[12]-421815835|0,o=(o<<11|o>>>21)+r|0,a+=(o^r^t)+l[15]+530742520|0,a=(a<<16|a>>>16)+o|0,t+=(a^o^r)+l[2]-995338651|0,t=(t<<23|t>>>9)+a|0,r+=(a^(t|~o))+l[0]-198630844|0,r=(r<<6|r>>>26)+t|0,o+=(t^(r|~a))+l[7]+1126891415|0,o=(o<<10|o>>>22)+r|0,a+=(r^(o|~t))+l[14]-1416354905|0,a=(a<<15|a>>>17)+o|0,t+=(o^(a|~r))+l[5]-57434055|0,t=(t<<21|t>>>11)+a|0,r+=(a^(t|~o))+l[12]+1700485571|0,r=(r<<6|r>>>26)+t|0,o+=(t^(r|~a))+l[3]-1894986606|0,o=(o<<10|o>>>22)+r|0,a+=(r^(o|~t))+l[10]-1051523|0,a=(a<<15|a>>>17)+o|0,t+=(o^(a|~r))+l[1]-2054922799|0,t=(t<<21|t>>>11)+a|0,r+=(a^(t|~o))+l[8]+1873313359|0,r=(r<<6|r>>>26)+t|0,o+=(t^(r|~a))+l[15]-30611744|0,o=(o<<10|o>>>22)+r|0,a+=(r^(o|~t))+l[6]-1560198380|0,a=(a<<15|a>>>17)+o|0,t+=(o^(a|~r))+l[13]+1309151649|0,t=(t<<21|t>>>11)+a|0,r+=(a^(t|~o))+l[4]-145523070|0,r=(r<<6|r>>>26)+t|0,o+=(t^(r|~a))+l[11]-1120210379|0,o=(o<<10|o>>>22)+r|0,a+=(r^(o|~t))+l[2]+718787259|0,a=(a<<15|a>>>17)+o|0,t+=(o^(a|~r))+l[9]-343485551|0,t=(t<<21|t>>>11)+a|0,p[0]=r+p[0]|0,p[1]=t+p[1]|0,p[2]=a+p[2]|0,p[3]=o+p[3]|0}function f(p){var l=[],r;for(r=0;r<64;r+=4)l[r>>2]=p.charCodeAt(r)+(p.charCodeAt(r+1)<<8)+(p.charCodeAt(r+2)<<16)+(p.charCodeAt(r+3)<<24);return l}function h(p){var l=[],r;for(r=0;r<64;r+=4)l[r>>2]=p[r]+(p[r+1]<<8)+(p[r+2]<<16)+(p[r+3]<<24);return l}function y(p){var l=p.length,r=[1732584193,-271733879,-1732584194,271733878],t,a,o,T,x,I;for(t=64;t<=l;t+=64)u(r,f(p.substring(t-64,t)));for(p=p.substring(t-64),a=p.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<a;t+=1)o[t>>2]|=p.charCodeAt(t)<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(u(r,o),t=0;t<16;t+=1)o[t]=0;return T=l*8,T=T.toString(16).match(/(.*?)(.{0,8})$/),x=parseInt(T[2],16),I=parseInt(T[1],16)||0,o[14]=x,o[15]=I,u(r,o),r}function c(p){var l=p.length,r=[1732584193,-271733879,-1732584194,271733878],t,a,o,T,x,I;for(t=64;t<=l;t+=64)u(r,h(p.subarray(t-64,t)));for(p=t-64<l?p.subarray(t-64):new Uint8Array(0),a=p.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<a;t+=1)o[t>>2]|=p[t]<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(u(r,o),t=0;t<16;t+=1)o[t]=0;return T=l*8,T=T.toString(16).match(/(.*?)(.{0,8})$/),x=parseInt(T[2],16),I=parseInt(T[1],16)||0,o[14]=x,o[15]=I,u(r,o),r}function m(p){var l="",r;for(r=0;r<4;r+=1)l+=e[p>>r*8+4&15]+e[p>>r*8&15];return l}function g(p){var l;for(l=0;l<p.length;l+=1)p[l]=m(p[l]);return p.join("")}g(y("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(i=function(p,l){var r=(p&65535)+(l&65535),t=(p>>16)+(l>>16)+(r>>16);return t<<16|r&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function p(l,r){return l=l|0||0,l<0?Math.max(l+r,0):Math.min(l,r)}ArrayBuffer.prototype.slice=function(l,r){var t=this.byteLength,a=p(l,t),o=t,T,x,I,ge;return r!==n&&(o=p(r,t)),a>o?new ArrayBuffer(0):(T=o-a,x=new ArrayBuffer(T),I=new Uint8Array(x),ge=new Uint8Array(this,a,T),I.set(ge),x)}})();function A(p){return/[\u0080-\uFFFF]/.test(p)&&(p=unescape(encodeURIComponent(p))),p}function w(p,l){var r=p.length,t=new ArrayBuffer(r),a=new Uint8Array(t),o;for(o=0;o<r;o+=1)a[o]=p.charCodeAt(o);return l?a:t}function C(p){return String.fromCharCode.apply(null,new Uint8Array(p))}function N(p,l,r){var t=new Uint8Array(p.byteLength+l.byteLength);return t.set(new Uint8Array(p)),t.set(new Uint8Array(l),p.byteLength),r?t:t.buffer}function P(p){var l=[],r=p.length,t;for(t=0;t<r-1;t+=2)l.push(parseInt(p.substr(t,2),16));return String.fromCharCode.apply(String,l)}function S(){this.reset()}return S.prototype.append=function(p){return this.appendBinary(A(p)),this},S.prototype.appendBinary=function(p){this._buff+=p,this._length+=p.length;var l=this._buff.length,r;for(r=64;r<=l;r+=64)u(this._hash,f(this._buff.substring(r-64,r)));return this._buff=this._buff.substring(r-64),this},S.prototype.end=function(p){var l=this._buff,r=l.length,t,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o;for(t=0;t<r;t+=1)a[t>>2]|=l.charCodeAt(t)<<(t%4<<3);return this._finish(a,r),o=g(this._hash),p&&(o=P(o)),this.reset(),o},S.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},S.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},S.prototype.setState=function(p){return this._buff=p.buff,this._length=p.length,this._hash=p.hash,this},S.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},S.prototype._finish=function(p,l){var r=l,t,a,o;if(p[r>>2]|=128<<(r%4<<3),r>55)for(u(this._hash,p),r=0;r<16;r+=1)p[r]=0;t=this._length*8,t=t.toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(t[2],16),o=parseInt(t[1],16)||0,p[14]=a,p[15]=o,u(this._hash,p)},S.hash=function(p,l){return S.hashBinary(A(p),l)},S.hashBinary=function(p,l){var r=y(p),t=g(r);return l?P(t):t},S.ArrayBuffer=function(){this.reset()},S.ArrayBuffer.prototype.append=function(p){var l=N(this._buff.buffer,p,!0),r=l.length,t;for(this._length+=p.byteLength,t=64;t<=r;t+=64)u(this._hash,h(l.subarray(t-64,t)));return this._buff=t-64<r?new Uint8Array(l.buffer.slice(t-64)):new Uint8Array(0),this},S.ArrayBuffer.prototype.end=function(p){var l=this._buff,r=l.length,t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],a,o;for(a=0;a<r;a+=1)t[a>>2]|=l[a]<<(a%4<<3);return this._finish(t,r),o=g(this._hash),p&&(o=P(o)),this.reset(),o},S.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},S.ArrayBuffer.prototype.getState=function(){var p=S.prototype.getState.call(this);return p.buff=C(p.buff),p},S.ArrayBuffer.prototype.setState=function(p){return p.buff=w(p.buff,!0),S.prototype.setState.call(this,p)},S.ArrayBuffer.prototype.destroy=S.prototype.destroy,S.ArrayBuffer.prototype._finish=S.prototype._finish,S.ArrayBuffer.hash=function(p,l){var r=c(new Uint8Array(p)),t=g(r);return l?P(t):t},S})});var ae=Ae((Vt,Pe)=>{"use strict";Pe.exports={}});async function st(n){let i=(await Promise.resolve().then(()=>Z(Fe(),1))).default;return new Promise((e,s)=>{let f=Math.ceil(n.size/2097152),h=0,y=new i.ArrayBuffer,c=new FileReader,m=()=>{let g=h*2097152,A=Math.min(g+2097152,n.size);c.readAsArrayBuffer(n.slice(g,A))};c.onload=g=>{let A=g.target?.result;if(!A){s(d.business("Failed to read file chunk"));return}y.append(A),h++,h<f?m():e({md5:y.end()})},c.onerror=()=>{s(d.business("Failed to calculate MD5: FileReader error"))},m()})}async function at(n){let i=await Promise.resolve().then(()=>Z(ae(),1));if(Buffer.isBuffer(n)){let s=i.createHash("md5");return s.update(n),{md5:s.digest("hex")}}let e=await Promise.resolve().then(()=>Z(ae(),1));return new Promise((s,u)=>{let f=i.createHash("md5"),h=e.createReadStream(n);h.on("error",y=>u(d.business(`Failed to read file for MD5: ${y.message}`))),h.on("data",y=>f.update(y)),h.on("end",()=>s({md5:f.digest("hex")}))})}async function k(n){let i=X();if(i==="browser"){if(!(n instanceof Blob))throw d.business("Invalid input for browser MD5 calculation: Expected Blob or File.");return st(n)}if(i==="node"){if(!(Buffer.isBuffer(n)||typeof n=="string"))throw d.business("Invalid input for Node.js MD5 calculation: Expected Buffer or file path string.");return at(n)}throw d.business("Unknown or unsupported execution environment for MD5 calculation.")}var W=R(()=>{"use strict";Y();v()});function Be(n){return ut.test(n)}var pt,ut,Me=R(()=>{"use strict";pt=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],ut=new RegExp(pt.join("|"))});function ke(n,i){if(!n||n.length===0)return[];if(!i?.allowUnbuilt&&n.find(s=>s&&G(s)))throw d.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return n.filter(e=>{if(!e)return!1;let s=e.replace(/\\/g,"/").split("/").filter(Boolean);if(s.length===0)return!0;let u=s[s.length-1];if(Be(u))return!1;for(let h of s)if(h!==".well-known"&&(h.startsWith(".")||h.length>255))return!1;let f=s.slice(0,-1);for(let h of f)if(ct.some(y=>h.toLowerCase()===y.toLowerCase()))return!1;return!0})}var ct,le=R(()=>{"use strict";Me();v();ct=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function Q(n){return n.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var ze=R(()=>{"use strict"});function He(n,i={}){if(i.flatten===!1)return n.map(s=>({path:Q(s),name:pe(s)}));let e=ft(n);return n.map(s=>{let u=Q(s);if(e){let f=e.endsWith("/")?e:`${e}/`;u.startsWith(f)&&(u=u.substring(f.length))}return u||(u=pe(s)),{path:u,name:pe(s)}})}function ft(n){if(!n.length)return"";let e=n.map(f=>Q(f)).map(f=>f.split("/")),s=[],u=Math.min(...e.map(f=>f.length));for(let f=0;f<u-1;f++){let h=e[0][f];if(e.every(y=>y[f]===h))s.push(h);else break}return s.join("/")}function pe(n){return n.split(/[/\\]/).pop()||n}var ue=R(()=>{"use strict";ze()});function ce(n,i=1){if(n===0)return"0 Bytes";let e=1024,s=["Bytes","KB","MB","GB"],u=Math.floor(Math.log(n)/Math.log(e));return parseFloat((n/Math.pow(e,u)).toFixed(i))+" "+s[u]}function fe(n){if(Ee(n))return{valid:!1,reason:"File name contains unsafe characters"};if(n.startsWith(" ")||n.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(n.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let i=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,e=n.split("/").pop()||n;return i.test(e)?{valid:!1,reason:"File name uses a reserved system name"}:n.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function Sn(n,i){let e=[],s=[],u=[];if(n.length===0){let c={file:"(no files)",message:"At least one file must be provided"};return e.push(c),{files:[],validFiles:[],errors:e,warnings:[],canDeploy:!1}}for(let c of n)if(G(c.name))return e.push({file:c.name,message:"Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:n.map(m=>({...m,status:b.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:e,warnings:[],canDeploy:!1};if(n.length>i.maxFilesCount){let c={file:`(${n.length} files)`,message:`File count (${n.length}) exceeds limit of ${i.maxFilesCount}`};return e.push(c),{files:n.map(m=>({...m,status:b.VALIDATION_FAILED,statusMessage:c.message})),validFiles:[],errors:e,warnings:[],canDeploy:!1}}let f=0;for(let c of n){let m=b.READY,g="Ready for upload",A=c.name?fe(c.name):{valid:!1,reason:"File name cannot be empty"};if(c.status===b.PROCESSING_ERROR)m=b.VALIDATION_FAILED,g=c.statusMessage||"File failed during processing",e.push({file:c.name,message:g});else if(c.size===0){m=b.EXCLUDED,g="File is empty (0 bytes) and cannot be deployed due to storage limitations",s.push({file:c.name,message:g}),u.push({...c,status:m,statusMessage:g});continue}else c.size<0?(m=b.VALIDATION_FAILED,g="File size must be positive",e.push({file:c.name,message:g})):!c.name||c.name.trim().length===0?(m=b.VALIDATION_FAILED,g="File name cannot be empty",e.push({file:c.name||"(empty)",message:g})):c.name.includes("\0")?(m=b.VALIDATION_FAILED,g="File name contains invalid characters (null byte)",e.push({file:c.name,message:g})):A.valid?K(c.name)?(m=b.VALIDATION_FAILED,g=`File extension not allowed: "${c.name}"`,e.push({file:c.name,message:g})):c.size>i.maxFileSize?(m=b.VALIDATION_FAILED,g=`File size (${ce(c.size)}) exceeds limit of ${ce(i.maxFileSize)}`,e.push({file:c.name,message:g})):(f+=c.size,f>i.maxTotalSize&&(m=b.VALIDATION_FAILED,g=`Total size would exceed limit of ${ce(i.maxTotalSize)}`,e.push({file:c.name,message:g}))):(m=b.VALIDATION_FAILED,g=A.reason||"Invalid file name",e.push({file:c.name,message:g}));u.push({...c,status:m,statusMessage:g})}e.length>0&&(u=u.map(c=>c.status===b.EXCLUDED?c:{...c,status:b.VALIDATION_FAILED,statusMessage:c.status===b.VALIDATION_FAILED?c.statusMessage:"Deployment failed due to validation errors in bundle"}));let h=e.length===0?u.filter(c=>c.status===b.READY):[],y=e.length===0;return{files:u,validFiles:h,errors:e,warnings:s,canDeploy:y}}function dt(n){return n.filter(i=>i.status===b.READY)}function En(n){return dt(n).length>0}var de=R(()=>{"use strict";v()});function Ke(n,i){if(n.includes("\0")||n.includes("/../")||n.startsWith("../")||n.endsWith("/.."))throw d.business(`Security error: Unsafe file path "${n}" for file: ${i}`)}function Ge(n,i){let e=fe(n);if(!e.valid)throw d.business(e.reason||"Invalid file name");if(K(n))throw d.business(`File extension not allowed: "${i}"`)}var he=R(()=>{"use strict";v();de()});var je={};Ze(je,{processFilesForBrowser:()=>Ve});async function Ve(n,i={}){if(X()!=="browser")throw d.business("processFilesForBrowser can only be called in a browser environment.");let e=n.map(A=>A.webkitRelativePath||A.name),s=i.build||i.prerender,u=He(e,{flatten:i.pathDetect!==!1}),f=u.map(A=>A.path),h=new Set(ke(f,{allowUnbuilt:s})),y=[];for(let A=0;A<n.length;A++)h.has(f[A])&&y.push({file:n[A],deployPath:u[A].path});if(y.length===0)return[];if(s){let A=[];for(let w=0;w<y.length;w++){let{file:C,deployPath:N}=y[w];if(C.size===0)continue;let{md5:P}=await k(C);A.push({path:N,content:C,size:C.size,md5:P})}return A}let c=B(),m=[],g=0;for(let A=0;A<y.length;A++){let{file:w,deployPath:C}=y[A];if(Ke(C,w.name),w.size===0)continue;if(Ge(C,w.name),w.size>c.maxFileSize)throw d.business(`File ${w.name} is too large. Maximum allowed size is ${c.maxFileSize/(1024*1024)}MB.`);if(g+=w.size,g>c.maxTotalSize)throw d.business(`Total deploy size is too large. Maximum allowed is ${c.maxTotalSize/(1024*1024)}MB.`);let{md5:N}=await k(w);m.push({path:C,content:w,size:w.size,md5:N})}if(m.length>c.maxFilesCount)throw d.business(`Too many files to deploy. Maximum allowed is ${c.maxFilesCount} files.`);return m}var me=R(()=>{"use strict";W();v();Y();le();ue();he();M()});v();var j=class{constructor(){this.handlers=new Map}on(i,e){this.handlers.has(i)||this.handlers.set(i,new Set),this.handlers.get(i).add(e)}off(i,e){let s=this.handlers.get(i);s&&(s.delete(e),s.size===0&&this.handlers.delete(i))}emit(i,...e){let s=this.handlers.get(i);if(!s)return;let u=Array.from(s);for(let f of u)try{f(...e)}catch(h){s.delete(f),i!=="error"&&setTimeout(()=>{h instanceof Error?this.emit("error",h,String(i)):this.emit("error",new Error(String(h)),String(i))},0)}}transfer(i){this.handlers.forEach((e,s)=>{e.forEach(u=>{i.on(s,u)})})}clear(){this.handlers.clear()}};v();function Te(n){if(n!=null){if(typeof n!="string")throw d.validation("Password must be a string");if(n.length<$.MIN_LENGTH||n.length>$.MAX_LENGTH)throw d.validation(`Password must be between ${$.MIN_LENGTH} and ${$.MAX_LENGTH} characters`)}}function U(n){if(n==null)return;if(n.length===0)return n;if(n.length>F.MAX_COUNT)throw d.validation(`Maximum ${F.MAX_COUNT} labels allowed`);let i=n.map((s,u)=>{if(typeof s!="string")throw d.validation(`Label at index ${u} must be a string`);let f=s.trim().toLowerCase();if(f.length<F.MIN_LENGTH)throw d.validation(`Labels must be at least ${F.MIN_LENGTH} characters long`);if(f.length>F.MAX_LENGTH)throw d.validation(`Labels must be no more than ${F.MAX_LENGTH} characters long`);if(!ve.test(f))throw d.validation(`Labels must start and end with alphanumeric characters, with optional separators (${F.SEPARATORS}) between segments`);return f}),e=[...new Set(i)];if(e.length!==i.length)throw d.validation("Duplicate labels are not allowed");return e}var E={DEPLOYMENTS:"/deployments",DOMAINS:"/domains",TOKENS:"/tokens",ACCOUNT:"/account",CONFIG:"/config",PING:"/ping",SPA_CHECK:"/spa-check"},it=3e4,q=class extends j{constructor(e){super();this.globalHeaders={};this.apiUrl=e.apiUrl||V,this.getAuthHeadersCallback=e.getAuthHeaders,this.useCredentials=e.useCredentials??!1,this.timeout=e.timeout??it,this.createDeployBody=e.createDeployBody,this.deployEndpoint=e.deployEndpoint||E.DEPLOYMENTS}setGlobalHeaders(e){this.globalHeaders=e}transferEventsTo(e){this.transfer(e)}async executeRequest(e,s,u){let f=this.mergeHeaders(s.headers),{signal:h,cleanup:y}=this.createTimeoutSignal(s.signal),c={...s,headers:f,credentials:this.useCredentials&&!f.Authorization?"include":void 0,signal:h};this.emit("request",e,c);try{let m=await fetch(e,c);return y(),m.ok||await this.handleResponseError(m,u),this.emit("response",this.safeClone(m),e),{data:await this.parseResponse(this.safeClone(m)),status:m.status}}catch(m){y();let g=m instanceof Error?m:new Error(String(m));this.emit("error",g,e),this.handleFetchError(m,u)}}async request(e,s,u){let{data:f}=await this.executeRequest(e,s,u);return f}async requestWithStatus(e,s,u){return this.executeRequest(e,s,u)}mergeHeaders(e={}){return{...this.globalHeaders,...this.getAuthHeadersCallback(),...e}}createTimeoutSignal(e){let s=new AbortController,u=setTimeout(()=>s.abort(),this.timeout);if(e){let f=()=>s.abort();e.addEventListener("abort",f),e.aborted&&s.abort()}return{signal:s.signal,cleanup:()=>clearTimeout(u)}}safeClone(e){try{return e.clone()}catch{return e}}async parseResponse(e){if(!(e.headers.get("Content-Length")==="0"||e.status===204))return e.json()}async handleResponseError(e,s){let u={};try{if(e.headers.get("content-type")?.includes("application/json")){let y=await e.json();if(y&&typeof y=="object"){let c=y;typeof c.message=="string"&&(u.message=c.message),typeof c.error=="string"&&(u.error=c.error)}}else u={message:await e.text()}}catch{u={message:"Failed to parse error response"}}let f=u.message||u.error||`${s} failed`;throw e.status===401?d.authentication(f):e.status===429?d.rateLimit(f):d.api(f,e.status)}handleFetchError(e,s){throw L(e)?e:e instanceof Error&&e.name==="AbortError"?d.cancelled(`${s} was cancelled`):e instanceof TypeError&&e.message.includes("fetch")?d.network(`${s} failed: ${e.message}`,e):e instanceof Error?d.business(`${s} failed: ${e.message}`):d.business(`${s} failed: Unknown error`)}async deploy(e,s={}){if(!e.length)throw d.business("No files to deploy");for(let m of e)if(!m.md5)throw d.file(`MD5 checksum missing for file: ${m.path}`,m.path);Te(s.password);let u=U(s.labels),f=s.build||s.prerender||s.spa?{build:s.build,prerender:s.prerender,spa:s.spa}:void 0,{body:h,headers:y}=await this.createDeployBody(e,{labels:u,via:s.via,password:s.password,flags:f}),c={};return s.deployToken?c.Authorization=`Bearer ${s.deployToken}`:s.apiKey&&(c.Authorization=`Bearer ${s.apiKey}`),s.caller&&(c["X-Caller"]=s.caller),this.request(`${s.apiUrl||this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:h,headers:{...y,...c},signal:s.signal||null},"Deploy")}async listDeployments(){return this.request(`${this.apiUrl}${E.DEPLOYMENTS}`,{method:"GET"},"List deployments")}async getDeployment(e){return this.request(`${this.apiUrl}${E.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(e,s){let u=U(s);return this.request(`${this.apiUrl}${E.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:u})},"Update deployment labels")}async removeDeployment(e){await this.request(`${this.apiUrl}${E.DEPLOYMENTS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove deployment")}async setDomain(e,s,u){let f=U(u),h={};s&&(h.deployment=s),f!==void 0&&(h.labels=f);let{data:y,status:c}=await this.requestWithStatus(`${this.apiUrl}${E.DOMAINS}/${encodeURIComponent(e)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)},"Set domain");return{...y,isCreate:c===201}}async listDomains(){return this.request(`${this.apiUrl}${E.DOMAINS}`,{method:"GET"},"List domains")}async getDomain(e){return this.request(`${this.apiUrl}${E.DOMAINS}/${encodeURIComponent(e)}`,{method:"GET"},"Get domain")}async removeDomain(e){await this.request(`${this.apiUrl}${E.DOMAINS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove domain")}async verifyDomain(e){return this.request(`${this.apiUrl}${E.DOMAINS}/${encodeURIComponent(e)}/verify`,{method:"POST"},"Verify domain")}async getDomainDns(e){return this.request(`${this.apiUrl}${E.DOMAINS}/${encodeURIComponent(e)}/dns`,{method:"GET"},"Get domain DNS")}async getDomainRecords(e){return this.request(`${this.apiUrl}${E.DOMAINS}/${encodeURIComponent(e)}/records`,{method:"GET"},"Get domain records")}async getDomainShare(e){return this.request(`${this.apiUrl}${E.DOMAINS}/${encodeURIComponent(e)}/share`,{method:"GET"},"Get domain share")}async validateDomain(e){return this.request(`${this.apiUrl}${E.DOMAINS}/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:e})},"Validate domain")}async createToken(e,s){let u=U(s),f={};return e!==void 0&&(f.ttl=e),u!==void 0&&(f.labels=u),this.request(`${this.apiUrl}${E.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)},"Create token")}async listTokens(){return this.request(`${this.apiUrl}${E.TOKENS}`,{method:"GET"},"List tokens")}async removeToken(e){await this.request(`${this.apiUrl}${E.TOKENS}/${encodeURIComponent(e)}`,{method:"DELETE"},"Remove token")}async fetchAgentToken(){return this.request(`${this.apiUrl}${E.TOKENS}/agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})},"Fetch agent token")}async getAccount(){return this.request(`${this.apiUrl}${E.ACCOUNT}`,{method:"GET"},"Get account")}async getConfig(){return this.request(`${this.apiUrl}${E.CONFIG}`,{method:"GET"},"Get config")}async ping(){return(await this.request(`${this.apiUrl}${E.PING}`,{method:"GET"},"Ping"))?.success||!1}async checkSPA(e,s={}){let u=e.find(m=>m.path==="index.html"||m.path==="/index.html");if(!u||u.size>100*1024)return!1;let f;if(typeof Buffer<"u"&&Buffer.isBuffer(u.content))f=u.content.toString("utf-8");else if(typeof Blob<"u"&&u.content instanceof Blob)f=await u.content.text();else if(typeof File<"u"&&u.content instanceof File)f=await u.content.text();else return!1;let h={"Content-Type":"application/json"};s.deployToken?h.Authorization=`Bearer ${s.deployToken}`:s.apiKey&&(h.Authorization=`Bearer ${s.apiKey}`);let y={files:e.map(m=>m.path),index:f};return(await this.request(`${this.apiUrl}${E.SPA_CHECK}`,{method:"POST",headers:h,body:JSON.stringify(y)},"SPA check")).isSPA}};v();M();v();v();function Re(n={},i={}){let e={apiUrl:n.apiUrl||i.apiUrl||V,apiKey:n.apiKey!==void 0?n.apiKey:i.apiKey,deployToken:n.deployToken!==void 0?n.deployToken:i.deployToken},s={apiUrl:e.apiUrl};return e.apiKey!==void 0&&(s.apiKey=e.apiKey),e.deployToken!==void 0&&(s.deployToken=e.deployToken),s}function Ce(n,i){let e={...n};return e.apiUrl===void 0&&i.apiUrl!==void 0&&(e.apiUrl=i.apiUrl),e.apiKey===void 0&&i.apiKey!==void 0&&(e.apiKey=i.apiKey),e.deployToken===void 0&&i.deployToken!==void 0&&(e.deployToken=i.deployToken),e.timeout===void 0&&i.timeout!==void 0&&(e.timeout=i.timeout),e.maxConcurrency===void 0&&i.maxConcurrency!==void 0&&(e.maxConcurrency=i.maxConcurrency),e.onProgress===void 0&&i.onProgress!==void 0&&(e.onProgress=i.onProgress),e.caller===void 0&&i.caller!==void 0&&(e.caller=i.caller),e}v();W();async function lt(){let n=JSON.stringify(be,null,2),i;typeof Buffer<"u"?i=Buffer.from(n,"utf-8"):i=new Blob([n],{type:"application/json"});let{md5:e}=await k(i);return{path:re,content:i,size:n.length,md5:e}}async function _e(n,i,e){if(e.spaDetect===!1||e.spa||e.build||e.prerender||n.some(s=>s.path===re))return n;try{if(await i.checkSPA(n,e)){let u=await lt();return[...n,u]}}catch{}return n}function Oe(n){let{getApi:i,ensureInit:e,processInput:s,clientDefaults:u,hasAuth:f}=n;return{upload:async(h,y={})=>{await e();let c=u?Ce(y,u):y;if(f&&!f()&&!c.deployToken&&!c.apiKey)try{let A=i(),{secret:w}=await A.fetchAgentToken();c.deployToken=w}catch(A){throw L(A)&&A.type===D.RateLimit?d.rateLimit("public deploy rate limit exceeded, try again later or run 'ship config' for a free account with higher limits"):A}if(!s)throw d.config("processInput function is not provided.");let m=i(),g=await s(h,c);return g=await _e(g,m,c),m.deploy(g,c)},list:async()=>(await e(),i().listDeployments()),get:async h=>(await e(),i().getDeployment(h)),set:async(h,y)=>(await e(),i().updateDeploymentLabels(h,y.labels)),remove:async h=>{await e(),await i().removeDeployment(h)}}}function Ne(n){let{getApi:i,ensureInit:e}=n;return{set:async(s,u={})=>(await e(),i().setDomain(s,u.deployment,u.labels)),list:async()=>(await e(),i().listDomains()),get:async s=>(await e(),i().getDomain(s)),remove:async s=>{await e(),await i().removeDomain(s)},verify:async s=>(await e(),i().verifyDomain(s)),validate:async s=>(await e(),i().validateDomain(s)),dns:async s=>(await e(),i().getDomainDns(s)),records:async s=>(await e(),i().getDomainRecords(s)),share:async s=>(await e(),i().getDomainShare(s))}}function Le(n){let{getApi:i,ensureInit:e}=n;return{get:async()=>(await e(),i().getAccount())}}function $e(n){let{getApi:i,ensureInit:e}=n;return{create:async(s={})=>(await e(),i().createToken(s.ttl,s.labels)),list:async()=>(await e(),i().listTokens()),remove:async s=>{await e(),await i().removeToken(s)}}}var J=class{constructor(i={}){this.initPromise=null;this._config=null;this.auth=null;this.customHeaders={};this.clientOptions=i,i.deployToken?this.auth={type:"token",value:i.deployToken}:i.apiKey&&(this.auth={type:"apiKey",value:i.apiKey}),this.authHeadersCallback=()=>this.getAuthHeaders();let e=this.resolveInitialConfig(i);this.http=new q({...i,...e,getAuthHeaders:this.authHeadersCallback,createDeployBody:this.getDeployBodyCreator()});let s={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this._deployments=Oe({...s,processInput:(u,f)=>this.processInput(u,f),clientDefaults:this.clientOptions,hasAuth:()=>this.hasAuth()}),this._domains=Ne(s),this._account=Le(s),this._tokens=$e(s)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.loadFullConfig()),this.initPromise}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(i,e){return this.deployments.upload(i,e)}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=B(),this._config)}on(i,e){this.http.on(i,e)}off(i,e){this.http.off(i,e)}setHeaders(i){this.customHeaders=i,this.http.setGlobalHeaders(i)}clearHeaders(){this.customHeaders={},this.http.setGlobalHeaders({})}replaceHttpClient(i){if(this.http?.transferEventsTo)try{this.http.transferEventsTo(i)}catch(e){console.warn("Event transfer failed during client replacement:",e)}this.http=i,Object.keys(this.customHeaders).length>0&&this.http.setGlobalHeaders(this.customHeaders)}setDeployToken(i){if(!i||typeof i!="string")throw d.business("Invalid deploy token provided. Deploy token must be a non-empty string.");this.auth={type:"token",value:i}}setApiKey(i){if(!i||typeof i!="string")throw d.business("Invalid API key provided. API key must be a non-empty string.");this.auth={type:"apiKey",value:i}}getAuthHeaders(){return this.auth?{Authorization:`Bearer ${this.auth.value}`}:{}}hasAuth(){return this.clientOptions.useCredentials?!0:this.auth!==null}};M();v();v();async function Ue(n,i={}){let{labels:e,via:s,password:u,flags:f}=i,h=new FormData,y=[];for(let c of n){if(!(c.content instanceof File||c.content instanceof Blob))throw d.file(`Unsupported file.content type for browser: ${c.path}`,c.path);if(!c.md5)throw d.file(`File missing md5 checksum: ${c.path}`,c.path);let m=new File([c.content],c.path,{type:"application/octet-stream"});h.append("files[]",m),y.push(c.md5)}return h.append("checksums",JSON.stringify(y)),e&&e.length>0&&h.append("labels",JSON.stringify(e)),s&&h.append("via",s),u&&h.append("password",u),f?.build&&h.append("build","true"),f?.prerender&&h.append("prerender","true"),f?.spa&&h.append("spa","true"),{body:h,headers:{}}}W();function un(n,i,e,s=!0){let u=n===1?i:e;return s?`${n} ${u}`:u}le();ue();Y();de();he();v();M();me();var ye=class extends J{constructor(i={}){super(i)}resolveInitialConfig(i){return Re(i,{})}async loadFullConfig(){try{let i=await this.http.getConfig();oe(i)}catch(i){throw this.initPromise=null,i}}async processInput(i,e){if(!this.isFileArray(i))throw d.business("Invalid input type for browser environment. Expected File[].");if(i.length===0)throw d.business("No files to deploy.");let{processFilesForBrowser:s}=await Promise.resolve().then(()=>(me(),je));return s(i,e)}isFileArray(i){return Array.isArray(i)&&i.every(e=>e instanceof File)}getDeployBodyCreator(){return Ue}},Qn=ye;export{te as API_KEY_HEX_LENGTH,At as API_KEY_HINT_LENGTH,_ as API_KEY_PREFIX,De as API_KEY_TOTAL_LENGTH,gt as AccountPlan,q as ApiHttp,Dt as AuthMethod,tt as BLOCKED_EXTENSIONS,V as DEFAULT_API,re as DEPLOYMENT_CONFIG_FILENAME,ne as DEPLOY_TOKEN_HEX_LENGTH,O as DEPLOY_TOKEN_PREFIX,Se as DEPLOY_TOKEN_TOTAL_LENGTH,mt as DeploymentStatus,yt as DomainStatus,D as ErrorType,b as FILE_VALIDATION_STATUS,b as FileValidationStatus,ct as JUNK_DIRECTORIES,F as LABEL_CONSTRAINTS,ve as LABEL_PATTERN,$ as PASSWORD_CONSTRAINTS,be as SPA_DEFAULT_CONFIG,ye as Ship,d as ShipError,rt as UNBUILT_PROJECT_MARKERS,nt as UNSAFE_FILENAME_CHARS,Kt as __setTestEnvironment,En as allValidFilesReady,k as calculateMD5,Le as createAccountResource,Oe as createDeploymentResource,Ne as createDomainResource,$e as createTokenResource,Qn as default,It as deserializeLabels,Tt as extractSubdomain,ke as filterJunk,ce as formatFileSize,Rt as generateDeploymentUrl,Ct as generateDomainUrl,B as getCurrentConfig,X as getENV,dt as getValidFiles,G as hasUnbuiltMarker,Ee as hasUnsafeChars,K as isBlockedExtension,vt as isCustomDomain,wt as isDeployment,we as isPlatformDomain,L as isShipError,Ce as mergeDeployOptions,He as optimizeDeployPaths,un as pluralize,Ve as processFilesForBrowser,Re as resolveConfig,xt as serializeLabels,oe as setPlatformConfig,St as validateApiKey,bt as validateApiUrl,Ge as validateDeployFile,Ke as validateDeployPath,Et as validateDeployToken,fe as validateFileName,Sn as validateFiles};
|
|
2
2
|
//# sourceMappingURL=browser.js.map
|