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.esm.js CHANGED
@@ -393,8 +393,8 @@ function getKeyFromS3Uri(s3Uri) {
393
393
  return match ? match[1] : null;
394
394
  }
395
395
  /**
396
- * Fetch profile picture: (1) GET path API for JSON with filePath/s3Uri, (2) GET download API with key to get image, return blob URL.
397
- * Path API returns JSON: { statusResponse, filePath, s3Uri, errors }. Download API: GET /v1/objectStore/download?key=<key>.
396
+ * Fetch profile picture: (1) GET path API for JSON with filePath/s3Uri, (2) GET download API with key; download returns JSON with base64 fileContent.
397
+ * Path API: { statusResponse, filePath, s3Uri, errors }. Download API: { statusResponse, fileName, contentType, fileContent (base64), errors }.
398
398
  * @param baseUrl - Base URL for the object store API (default: http://objectstore.impact0mics.local:9012)
399
399
  * @returns Promise that resolves to blob URL string or null if fetch fails
400
400
  */
@@ -565,7 +565,7 @@ const fetchProfilePictureAsBlobUrl = async (baseUrl = "http://objectstore.impact
565
565
  console.warn("Profile picture response has no key/s3Uri/filePath for download");
566
566
  return null;
567
567
  }
568
- // Step 2: GET download API → image bytes
568
+ // Step 2: GET download API → JSON with fileContent (base64) and contentType
569
569
  const cleanBase = baseUrl.replace(/\/$/, "");
570
570
  const downloadUrl = `${cleanBase}/v1/objectStore/download?key=${encodeURIComponent(downloadKey)}`;
571
571
  const imageResponse = await fetch(downloadUrl, { method: "GET", headers });
@@ -573,12 +573,28 @@ const fetchProfilePictureAsBlobUrl = async (baseUrl = "http://objectstore.impact
573
573
  console.warn(`Failed to fetch profile picture image: ${imageResponse.status} ${imageResponse.statusText}`);
574
574
  return null;
575
575
  }
576
- const contentType = imageResponse.headers.get("content-type");
577
- if (!contentType || !contentType.startsWith("image/")) {
578
- console.warn(`Profile picture download is not an image: ${contentType}`);
576
+ const downloadData = (await imageResponse.json());
577
+ const downloadStatus = downloadData?.statusResponse?.status;
578
+ if (downloadStatus !== "SUCCESS") {
579
+ console.warn("Profile picture download API did not return SUCCESS:", downloadStatus, downloadData?.errors);
579
580
  return null;
580
581
  }
581
- const blob = await imageResponse.blob();
582
+ const fileContent = downloadData?.fileContent;
583
+ const contentType = (downloadData?.contentType || "").trim() || "image/png";
584
+ if (!fileContent || typeof fileContent !== "string") {
585
+ console.warn("Profile picture download response has no fileContent");
586
+ return null;
587
+ }
588
+ if (!contentType.startsWith("image/")) {
589
+ console.warn(`Profile picture download contentType is not an image: ${contentType}`);
590
+ return null;
591
+ }
592
+ // Decode base64 fileContent → Blob → object URL
593
+ const binary = atob(fileContent);
594
+ const bytes = new Uint8Array(binary.length);
595
+ for (let i = 0; i < binary.length; i++)
596
+ bytes[i] = binary.charCodeAt(i);
597
+ const blob = new Blob([bytes], { type: contentType });
582
598
  return URL.createObjectURL(blob);
583
599
  }
584
600
  catch (err) {