@tapi-dev/sdk 0.1.26 → 0.1.27

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/cli.d.ts CHANGED
@@ -126,6 +126,7 @@ export declare function chooseStudioPort(preferred?: number, options?: {
126
126
  portAvailable?: StudioPortAvailable;
127
127
  reapBlockedPorts?: StudioPortReaper;
128
128
  }): Promise<number>;
129
+ export declare function downloadAndVerify(url: string, destination: string, expectedSha256: string, label?: string): Promise<void>;
129
130
  export declare function studioInstanceRecordPathForOptions(options: StudioCliOptions): string;
130
131
  export declare function findPortableStudioServerExe(releaseDir: string, manifest: StudioReleaseManifest): string | undefined;
131
132
  export declare function estimateRequiredExtractionBytes(zipBytes: number): number;
package/dist/cli.js CHANGED
@@ -2590,16 +2590,22 @@ async function requestStudioInstallToken(apiBaseUrl, channel, firebaseIdToken, f
2590
2590
  expiresAt: typeof payload?.expiresAt === "string" ? payload.expiresAt : undefined,
2591
2591
  };
2592
2592
  }
2593
- async function downloadAndVerify(url, destination, expectedSha256, label = "Studio installer") {
2593
+ export async function downloadAndVerify(url, destination, expectedSha256, label = "Studio installer") {
2594
2594
  const partialPath = `${destination}.partial`;
2595
- await downloadFile(url, partialPath, label);
2596
- const actualSha256 = await sha256File(partialPath);
2597
- if (actualSha256 !== expectedSha256.toLowerCase()) {
2595
+ await unlinkIfExists(partialPath);
2596
+ try {
2597
+ await downloadFile(url, partialPath, label);
2598
+ const actualSha256 = await sha256File(partialPath);
2599
+ if (actualSha256 !== expectedSha256.toLowerCase()) {
2600
+ throw new Error(`${label} checksum mismatch. Expected ${expectedSha256}, got ${actualSha256}.`);
2601
+ }
2602
+ await rename(partialPath, destination);
2603
+ console.log(`Verified SHA256: ${actualSha256}`);
2604
+ }
2605
+ catch (error) {
2598
2606
  await unlinkIfExists(partialPath);
2599
- throw new Error(`${label} checksum mismatch. Expected ${expectedSha256}, got ${actualSha256}.`);
2607
+ throw error;
2600
2608
  }
2601
- await rename(partialPath, destination);
2602
- console.log(`Verified SHA256: ${actualSha256}`);
2603
2609
  }
2604
2610
  async function downloadFile(url, destination, label = "download") {
2605
2611
  const response = await fetch(url);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapi-dev/sdk",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",