@pooflabs/core 0.0.24 → 0.0.26

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.
@@ -25,6 +25,7 @@ export interface ClientConfig {
25
25
  theme?: 'light' | 'dark';
26
26
  appName?: string;
27
27
  appIcon?: string;
28
+ enablePrivyFallback?: boolean;
28
29
  };
29
30
  mockAuth?: boolean;
30
31
  }
package/dist/index.js CHANGED
@@ -3633,23 +3633,31 @@ async function getFiles(path) {
3633
3633
  async function setFile(path, file) {
3634
3634
  var _a;
3635
3635
  // 1) Get the presigned URL from your backend
3636
- // (It looks like you already have this working.)
3637
- const response = await makeApiRequest('POST', 'storage/url', {
3636
+ const requestBody = {
3638
3637
  destinationPath: path,
3639
- operation: file ? 'upload' : 'delete'
3640
- }, undefined);
3638
+ operation: file ? 'upload' : 'delete',
3639
+ };
3640
+ // Send file size so the server can enforce upload limits before issuing a presigned URL
3641
+ if (file) {
3642
+ requestBody.contentLength = file.size;
3643
+ }
3644
+ const response = await makeApiRequest('POST', 'storage/url', requestBody, undefined);
3641
3645
  if (file == null) {
3642
3646
  return true;
3643
3647
  }
3644
3648
  if (!((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.s3Url)) {
3645
3649
  throw new Error("No s3Url in response");
3646
3650
  }
3647
- const presignedUrl = response.data.s3Url; // The PUT URL you showed in the example
3651
+ // Client-side size guard using the limit returned by the server
3652
+ const maxFileSize = response.data.maxFileSize;
3653
+ if (maxFileSize && file.size > maxFileSize) {
3654
+ throw new Error(`File size ${(file.size / (1024 * 1024)).toFixed(2)} MB exceeds the maximum upload size of ${(maxFileSize / (1024 * 1024)).toFixed(0)} MB.`);
3655
+ }
3656
+ const presignedUrl = response.data.s3Url;
3648
3657
  // 2) Upload the file directly to S3 with a PUT request
3649
3658
  const uploadResponse = await fetch(presignedUrl, {
3650
3659
  method: 'PUT',
3651
3660
  headers: {
3652
- // Use the file's actual content type so S3 knows how to serve it
3653
3661
  'Content-Type': file.type,
3654
3662
  },
3655
3663
  body: file
@@ -3659,7 +3667,6 @@ async function setFile(path, file) {
3659
3667
  await uploadResponse.text();
3660
3668
  throw new Error(`Upload failed with status: ${uploadResponse.status}`);
3661
3669
  }
3662
- // Optionally return the file's public URL or some confirmation
3663
3670
  return true;
3664
3671
  }
3665
3672
  async function signMessage(message) {