@shipstatic/ship 0.5.5 → 0.6.1

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 CHANGED
@@ -536,11 +536,27 @@ declare function getENV(): ExecutionEnvironment;
536
536
  * Format file size to human-readable string
537
537
  */
538
538
  declare function formatFileSize(bytes: number, decimals?: number): string;
539
+ /**
540
+ * Validate filename for deployment safety
541
+ * Rejects filenames that would cause issues in URLs, filesystems, or shells
542
+ *
543
+ * Rejected patterns:
544
+ * - URL-unsafe: ?, &, #, %, <, >, [, ], {, }, |, \, ^, ~, `
545
+ * - Path traversal: .. (already checked separately)
546
+ * - Shell dangerous: ; $ ( ) ' " *
547
+ * - Control characters: \0, \r, \n, \t
548
+ * - Reserved names: CON, PRN, AUX, NUL, COM1-9, LPT1-9 (Windows)
549
+ * - Leading/trailing dots or spaces
550
+ */
551
+ declare function validateFileName(filename: string): {
552
+ valid: boolean;
553
+ reason?: string;
554
+ };
539
555
  /**
540
556
  * Validate files against configuration limits with severity-based reporting
541
557
  *
542
558
  * Validation categorizes issues by severity:
543
- * - **Errors**: Block deployment (file too large, invalid type, etc.)
559
+ * - **Errors**: Block deployment (file too large, blocked extension, etc.)
544
560
  * - **Warnings**: Exclude files but allow deployment (empty files, etc.)
545
561
  *
546
562
  * @param files - Array of files to validate
@@ -593,11 +609,16 @@ declare function allValidFilesReady<T extends ValidatableFile>(files: T[]): bool
593
609
  * @throws {ShipError} If the path contains unsafe patterns
594
610
  */
595
611
  declare function validateDeployPath(deployPath: string, sourceIdentifier: string): void;
596
-
597
612
  /**
598
- * Get MIME type from file path (browser-compatible, no Node.js dependencies)
613
+ * Validate a deploy file's name and extension.
614
+ * Rejects unsafe filenames (shell/URL-dangerous chars, reserved names)
615
+ * and blocked file extensions (.exe, .msi, .dll, etc.).
616
+ *
617
+ * @param deployPath - The deployment path to validate
618
+ * @param sourceIdentifier - Human-readable identifier for error messages
619
+ * @throws {ShipError} If the filename is unsafe or extension is blocked
599
620
  */
600
- declare function getMimeType(path: string): string;
621
+ declare function validateDeployFile(deployPath: string, sourceIdentifier: string): void;
601
622
 
602
623
  /**
603
624
  * @file Platform configuration management for the Ship SDK.
@@ -620,8 +641,8 @@ declare function getCurrentConfig(): ConfigResponse;
620
641
  *
621
642
  * Pipeline order matches Node.js (node-files.ts) for consistency:
622
643
  * 1. Extract paths → 2. Filter junk → 3. Optimize paths →
623
- * 4. Security validate → 5. Skip empties → 6. Size validate →
624
- * 7. Calculate MD5 → 8. Count validate
644
+ * 4. Security validate → 5. Skip empties → 6. Name & extension validate →
645
+ * 7. Size validate → 8. Calculate MD5 → 9. Count validate
625
646
  */
626
647
 
627
648
  /**
@@ -668,4 +689,4 @@ declare class Ship extends Ship$1 {
668
689
  protected getDeployBodyCreator(): DeployBodyCreator;
669
690
  }
670
691
 
671
- 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, getMimeType, getValidFiles, mergeDeployOptions, optimizeDeployPaths, pluralize, processFilesForBrowser, resolveConfig, setConfig as setPlatformConfig, validateDeployPath, validateFiles };
692
+ 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 };