varminer-app-header 2.2.8 → 2.2.9

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/index.js CHANGED
@@ -413,8 +413,8 @@ function getKeyFromS3Uri(s3Uri) {
413
413
  return match ? match[1] : null;
414
414
  }
415
415
  /**
416
- * Fetch profile picture: (1) GET path API for JSON with filePath/s3Uri, (2) GET download API with key to get image, return blob URL.
417
- * Path API returns JSON: { statusResponse, filePath, s3Uri, errors }. Download API: GET /v1/objectStore/download?key=<key>.
416
+ * Fetch profile picture: (1) GET path API for JSON with filePath/s3Uri, (2) GET download API with key; download returns JSON with base64 fileContent.
417
+ * Path API: { statusResponse, filePath, s3Uri, errors }. Download API: { statusResponse, fileName, contentType, fileContent (base64), errors }.
418
418
  * @param baseUrl - Base URL for the object store API (default: http://objectstore.impact0mics.local:9012)
419
419
  * @returns Promise that resolves to blob URL string or null if fetch fails
420
420
  */
@@ -585,7 +585,7 @@ const fetchProfilePictureAsBlobUrl = async (baseUrl = "http://objectstore.impact
585
585
  console.warn("Profile picture response has no key/s3Uri/filePath for download");
586
586
  return null;
587
587
  }
588
- // Step 2: GET download API → image bytes
588
+ // Step 2: GET download API → JSON with fileContent (base64) and contentType
589
589
  const cleanBase = baseUrl.replace(/\/$/, "");
590
590
  const downloadUrl = `${cleanBase}/v1/objectStore/download?key=${encodeURIComponent(downloadKey)}`;
591
591
  const imageResponse = await fetch(downloadUrl, { method: "GET", headers });
@@ -593,12 +593,28 @@ const fetchProfilePictureAsBlobUrl = async (baseUrl = "http://objectstore.impact
593
593
  console.warn(`Failed to fetch profile picture image: ${imageResponse.status} ${imageResponse.statusText}`);
594
594
  return null;
595
595
  }
596
- const contentType = imageResponse.headers.get("content-type");
597
- if (!contentType || !contentType.startsWith("image/")) {
598
- console.warn(`Profile picture download is not an image: ${contentType}`);
596
+ const downloadData = (await imageResponse.json());
597
+ const downloadStatus = downloadData?.statusResponse?.status;
598
+ if (downloadStatus !== "SUCCESS") {
599
+ console.warn("Profile picture download API did not return SUCCESS:", downloadStatus, downloadData?.errors);
599
600
  return null;
600
601
  }
601
- const blob = await imageResponse.blob();
602
+ const fileContent = downloadData?.fileContent;
603
+ const contentType = (downloadData?.contentType || "").trim() || "image/png";
604
+ if (!fileContent || typeof fileContent !== "string") {
605
+ console.warn("Profile picture download response has no fileContent");
606
+ return null;
607
+ }
608
+ if (!contentType.startsWith("image/")) {
609
+ console.warn(`Profile picture download contentType is not an image: ${contentType}`);
610
+ return null;
611
+ }
612
+ // Decode base64 fileContent → Blob → object URL
613
+ const binary = atob(fileContent);
614
+ const bytes = new Uint8Array(binary.length);
615
+ for (let i = 0; i < binary.length; i++)
616
+ bytes[i] = binary.charCodeAt(i);
617
+ const blob = new Blob([bytes], { type: contentType });
602
618
  return URL.createObjectURL(blob);
603
619
  }
604
620
  catch (err) {