@doist/comms-sdk 3.1.0 → 3.2.0

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.
@@ -18,14 +18,17 @@ function resolveAttachmentId(attachmentId) {
18
18
  return resolveCreateId(attachmentId);
19
19
  }
20
20
  export const IMAGE_READ_MIME_TYPES = ['image/jpeg', 'image/png', 'image/webp'];
21
+ const IMAGE_READ_MAX_BYTES = 5 * 1024 * 1024;
21
22
  export const ImageReadResultSchema = z.object({
22
23
  mimeType: z.enum(IMAGE_READ_MIME_TYPES),
23
- dataBase64: z.string().min(1).max(5592408).base64(),
24
- byteLength: z
25
- .number()
26
- .int()
27
- .positive()
28
- .max(4 * 1024 * 1024),
24
+ // The API allows 5 MiB of image bytes. Base64 encodes each three-byte group
25
+ // as four characters, including padding for the last group.
26
+ dataBase64: z
27
+ .string()
28
+ .min(1)
29
+ .max(4 * Math.ceil(IMAGE_READ_MAX_BYTES / 3))
30
+ .base64(),
31
+ byteLength: z.number().int().positive().max(IMAGE_READ_MAX_BYTES),
29
32
  });
30
33
  /**
31
34
  * Client for uploading attachments and reading thread images.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doist/comms-sdk",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "A TypeScript wrapper for the Comms REST API.",
5
5
  "author": "Doist developers",
6
6
  "homepage": "https://doist.github.io/comms-sdk-typescript/",