@trops/dash-core 0.1.241 → 0.1.243

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.
@@ -33354,8 +33354,68 @@ async function installDashboardFromRegistry$1(
33354
33354
  };
33355
33355
  }
33356
33356
 
33357
- const buffer = await response.arrayBuffer();
33358
- const zip = new AdmZip(Buffer.from(buffer));
33357
+ const contentType = response.headers.get("content-type") || "";
33358
+ const arrayBuffer = await response.arrayBuffer();
33359
+ let zipBuffer = Buffer.from(arrayBuffer);
33360
+
33361
+ if (zipBuffer.length === 0) {
33362
+ return {
33363
+ success: false,
33364
+ error: "Download failed: registry returned an empty response.",
33365
+ };
33366
+ }
33367
+
33368
+ if (contentType.includes("text/html")) {
33369
+ return {
33370
+ success: false,
33371
+ error:
33372
+ "Download failed: registry returned an HTML page instead of package data.",
33373
+ };
33374
+ }
33375
+
33376
+ if (contentType.includes("application/json")) {
33377
+ let jsonData;
33378
+ try {
33379
+ jsonData = JSON.parse(zipBuffer.toString("utf-8"));
33380
+ } catch (parseErr) {
33381
+ return {
33382
+ success: false,
33383
+ error: `Download failed: invalid JSON (${parseErr.message}).`,
33384
+ };
33385
+ }
33386
+ if (jsonData.error) {
33387
+ return {
33388
+ success: false,
33389
+ error: `Download failed: ${jsonData.error}`,
33390
+ };
33391
+ }
33392
+ if (jsonData.downloadUrl) {
33393
+ let zipResponse;
33394
+ try {
33395
+ zipResponse = await fetch(jsonData.downloadUrl);
33396
+ } catch (fetchErr) {
33397
+ return {
33398
+ success: false,
33399
+ error: `Download failed: could not fetch ZIP from storage (${fetchErr.message}).`,
33400
+ };
33401
+ }
33402
+ if (!zipResponse.ok) {
33403
+ return {
33404
+ success: false,
33405
+ error: `Download failed: storage returned ${zipResponse.status} ${zipResponse.statusText}`,
33406
+ };
33407
+ }
33408
+ zipBuffer = Buffer.from(await zipResponse.arrayBuffer());
33409
+ if (zipBuffer.length === 0) {
33410
+ return {
33411
+ success: false,
33412
+ error: "Download failed: storage returned an empty ZIP file.",
33413
+ };
33414
+ }
33415
+ }
33416
+ }
33417
+
33418
+ const zip = new AdmZip(zipBuffer);
33359
33419
 
33360
33420
  // 3. Validate ZIP entries
33361
33421
  const tempDir = path$1.join(app$1.getPath("temp"), "dash-registry-import");