@peopl-health/nexus 5.57.8 → 5.57.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.
@@ -115,9 +115,13 @@ function officeDocumentUrl(fileUrl) {
115
115
  } catch {
116
116
  url = null;
117
117
  }
118
- // The approved document template pins the bucket host and takes the rest of the URL as a variable.
119
- const bucketHost = new RegExp(`^${escapeRegExp(bucketName ?? '')}\\.s3(\\.[a-z0-9-]+)?\\.amazonaws\\.com$`);
120
- if (!bucketName || url?.protocol !== 'https:' || !bucketHost.test(url.hostname)) {
118
+ // The approved document template pins the S3 host and takes the rest of the URL as a variable. A bucket name
119
+ // with dots (whatsapp.prod) is presigned path-style, so the bucket is then the first path segment.
120
+ const bucket = escapeRegExp(bucketName ?? '');
121
+ const isVirtualHosted = new RegExp(`^${bucket}\\.s3(\\.[a-z0-9-]+)?\\.amazonaws\\.com$`).test(url?.hostname ?? '');
122
+ const isPathStyle = /^s3(\.[a-z0-9-]+)?\.amazonaws\.com$/.test(url?.hostname ?? '')
123
+ && url.pathname.startsWith(`/${bucketName}/`);
124
+ if (!bucketName || url?.protocol !== 'https:' || !(isVirtualHosted || isPathStyle)) {
121
125
  throw httpError(400, 'The document must be uploaded before it is sent');
122
126
  }
123
127
  return url;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "5.57.8",
3
+ "version": "5.57.9",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",