resend 6.36.0 → 6.37.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.
- package/dist/index.cjs +29 -4
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +29 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -57,7 +57,7 @@ const MOVE_THREAD_FOLDERS = [
|
|
|
57
57
|
];
|
|
58
58
|
//#endregion
|
|
59
59
|
//#region package.json
|
|
60
|
-
var version = "6.
|
|
60
|
+
var version = "6.37.0";
|
|
61
61
|
//#endregion
|
|
62
62
|
//#region src/common/utils/build-pagination-query.ts
|
|
63
63
|
function buildPaginationUrl(base, options) {
|
|
@@ -240,9 +240,24 @@ var Automations = class {
|
|
|
240
240
|
};
|
|
241
241
|
//#endregion
|
|
242
242
|
//#region src/common/utils/parse-email-to-api-options.ts
|
|
243
|
+
function encodeBase64(bytes) {
|
|
244
|
+
if (typeof Buffer !== "undefined") return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64");
|
|
245
|
+
let binary = "";
|
|
246
|
+
for (let i = 0; i < bytes.length; i += 32768) binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
|
|
247
|
+
return btoa(binary);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* JSON.stringify turns a Uint8Array into an object of indexes and an
|
|
251
|
+
* ArrayBuffer into `{}`, so binary content is sent as base64 instead.
|
|
252
|
+
*/
|
|
253
|
+
function parseAttachmentContent(content) {
|
|
254
|
+
if (ArrayBuffer.isView(content)) return encodeBase64(new Uint8Array(content.buffer, content.byteOffset, content.byteLength));
|
|
255
|
+
if (content instanceof ArrayBuffer) return encodeBase64(new Uint8Array(content));
|
|
256
|
+
return content;
|
|
257
|
+
}
|
|
243
258
|
function parseAttachments(attachments) {
|
|
244
259
|
return attachments?.map((attachment) => ({
|
|
245
|
-
content: attachment.content,
|
|
260
|
+
content: parseAttachmentContent(attachment.content),
|
|
246
261
|
filename: attachment.filename,
|
|
247
262
|
path: attachment.path,
|
|
248
263
|
content_type: attachment.contentType,
|
|
@@ -386,12 +401,22 @@ function buildRecipientsQuery(options) {
|
|
|
386
401
|
//#region src/common/utils/has-dot-segment.ts
|
|
387
402
|
const DOT_SEGMENT = /^(?:\.|%2e){1,2}$/i;
|
|
388
403
|
/**
|
|
404
|
+
* Drops what URL parsing drops before it resolves dot segments: tabs and
|
|
405
|
+
* newlines anywhere, and control characters or spaces at the end.
|
|
406
|
+
*/
|
|
407
|
+
function stripIgnoredCharacters(requestPath) {
|
|
408
|
+
let path = requestPath.replace(/[\t\n\r]/g, "");
|
|
409
|
+
while (path.length > 0 && path.charCodeAt(path.length - 1) <= 32) path = path.slice(0, -1);
|
|
410
|
+
return path;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
389
413
|
* Whether a request path contains a `.` or `..` segment. URL parsing resolves
|
|
390
414
|
* these (even when percent-encoded), so the request would reach another path.
|
|
415
|
+
* In http(s) URLs a `\` separates segments the same way `/` does.
|
|
391
416
|
*/
|
|
392
417
|
function hasDotSegment(requestPath) {
|
|
393
|
-
const [pathname] = requestPath.split(/[?#]/);
|
|
394
|
-
return pathname.split(
|
|
418
|
+
const [pathname] = stripIgnoredCharacters(requestPath).split(/[?#]/);
|
|
419
|
+
return pathname.split(/[\\/]/).some((segment) => DOT_SEGMENT.test(segment));
|
|
395
420
|
}
|
|
396
421
|
//#endregion
|
|
397
422
|
//#region src/common/utils/parse-contact-properties-to-api-options.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -618,8 +618,8 @@ export interface CreateEmailResponseSuccess {
|
|
|
618
618
|
}
|
|
619
619
|
export type CreateEmailResponse = Response<CreateEmailResponseSuccess>;
|
|
620
620
|
export interface Attachment {
|
|
621
|
-
/** Content of an attached file. */
|
|
622
|
-
content?: string | Buffer;
|
|
621
|
+
/** Content of an attached file, as a base64 string or binary data, which is sent as base64. */
|
|
622
|
+
content?: string | Buffer | Uint8Array | ArrayBuffer;
|
|
623
623
|
/** Name of attached file. */
|
|
624
624
|
filename?: string | false | undefined;
|
|
625
625
|
/** Path where the attachment file is hosted */
|
|
@@ -1829,8 +1829,8 @@ interface InboxDraftAttachment {
|
|
|
1829
1829
|
size: number;
|
|
1830
1830
|
}
|
|
1831
1831
|
interface InboxDraftContentAttachmentOptions {
|
|
1832
|
-
/** Content of the file, as a base64 string or
|
|
1833
|
-
content: string | Buffer;
|
|
1832
|
+
/** Content of the file, as a base64 string or binary data, which is sent as base64. */
|
|
1833
|
+
content: string | Buffer | Uint8Array | ArrayBuffer;
|
|
1834
1834
|
path?: never;
|
|
1835
1835
|
filename: string;
|
|
1836
1836
|
contentType: string;
|
package/dist/index.d.mts
CHANGED
|
@@ -618,8 +618,8 @@ export interface CreateEmailResponseSuccess {
|
|
|
618
618
|
}
|
|
619
619
|
export type CreateEmailResponse = Response<CreateEmailResponseSuccess>;
|
|
620
620
|
export interface Attachment {
|
|
621
|
-
/** Content of an attached file. */
|
|
622
|
-
content?: string | Buffer;
|
|
621
|
+
/** Content of an attached file, as a base64 string or binary data, which is sent as base64. */
|
|
622
|
+
content?: string | Buffer | Uint8Array | ArrayBuffer;
|
|
623
623
|
/** Name of attached file. */
|
|
624
624
|
filename?: string | false | undefined;
|
|
625
625
|
/** Path where the attachment file is hosted */
|
|
@@ -1829,8 +1829,8 @@ interface InboxDraftAttachment {
|
|
|
1829
1829
|
size: number;
|
|
1830
1830
|
}
|
|
1831
1831
|
interface InboxDraftContentAttachmentOptions {
|
|
1832
|
-
/** Content of the file, as a base64 string or
|
|
1833
|
-
content: string | Buffer;
|
|
1832
|
+
/** Content of the file, as a base64 string or binary data, which is sent as base64. */
|
|
1833
|
+
content: string | Buffer | Uint8Array | ArrayBuffer;
|
|
1834
1834
|
path?: never;
|
|
1835
1835
|
filename: string;
|
|
1836
1836
|
contentType: string;
|
package/dist/index.mjs
CHANGED
|
@@ -33,7 +33,7 @@ const MOVE_THREAD_FOLDERS = [
|
|
|
33
33
|
];
|
|
34
34
|
//#endregion
|
|
35
35
|
//#region package.json
|
|
36
|
-
var version = "6.
|
|
36
|
+
var version = "6.37.0";
|
|
37
37
|
//#endregion
|
|
38
38
|
//#region src/common/utils/build-pagination-query.ts
|
|
39
39
|
function buildPaginationUrl(base, options) {
|
|
@@ -216,9 +216,24 @@ var Automations = class {
|
|
|
216
216
|
};
|
|
217
217
|
//#endregion
|
|
218
218
|
//#region src/common/utils/parse-email-to-api-options.ts
|
|
219
|
+
function encodeBase64(bytes) {
|
|
220
|
+
if (typeof Buffer !== "undefined") return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64");
|
|
221
|
+
let binary = "";
|
|
222
|
+
for (let i = 0; i < bytes.length; i += 32768) binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
|
|
223
|
+
return btoa(binary);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* JSON.stringify turns a Uint8Array into an object of indexes and an
|
|
227
|
+
* ArrayBuffer into `{}`, so binary content is sent as base64 instead.
|
|
228
|
+
*/
|
|
229
|
+
function parseAttachmentContent(content) {
|
|
230
|
+
if (ArrayBuffer.isView(content)) return encodeBase64(new Uint8Array(content.buffer, content.byteOffset, content.byteLength));
|
|
231
|
+
if (content instanceof ArrayBuffer) return encodeBase64(new Uint8Array(content));
|
|
232
|
+
return content;
|
|
233
|
+
}
|
|
219
234
|
function parseAttachments(attachments) {
|
|
220
235
|
return attachments?.map((attachment) => ({
|
|
221
|
-
content: attachment.content,
|
|
236
|
+
content: parseAttachmentContent(attachment.content),
|
|
222
237
|
filename: attachment.filename,
|
|
223
238
|
path: attachment.path,
|
|
224
239
|
content_type: attachment.contentType,
|
|
@@ -362,12 +377,22 @@ function buildRecipientsQuery(options) {
|
|
|
362
377
|
//#region src/common/utils/has-dot-segment.ts
|
|
363
378
|
const DOT_SEGMENT = /^(?:\.|%2e){1,2}$/i;
|
|
364
379
|
/**
|
|
380
|
+
* Drops what URL parsing drops before it resolves dot segments: tabs and
|
|
381
|
+
* newlines anywhere, and control characters or spaces at the end.
|
|
382
|
+
*/
|
|
383
|
+
function stripIgnoredCharacters(requestPath) {
|
|
384
|
+
let path = requestPath.replace(/[\t\n\r]/g, "");
|
|
385
|
+
while (path.length > 0 && path.charCodeAt(path.length - 1) <= 32) path = path.slice(0, -1);
|
|
386
|
+
return path;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
365
389
|
* Whether a request path contains a `.` or `..` segment. URL parsing resolves
|
|
366
390
|
* these (even when percent-encoded), so the request would reach another path.
|
|
391
|
+
* In http(s) URLs a `\` separates segments the same way `/` does.
|
|
367
392
|
*/
|
|
368
393
|
function hasDotSegment(requestPath) {
|
|
369
|
-
const [pathname] = requestPath.split(/[?#]/);
|
|
370
|
-
return pathname.split(
|
|
394
|
+
const [pathname] = stripIgnoredCharacters(requestPath).split(/[?#]/);
|
|
395
|
+
return pathname.split(/[\\/]/).some((segment) => DOT_SEGMENT.test(segment));
|
|
371
396
|
}
|
|
372
397
|
//#endregion
|
|
373
398
|
//#region src/common/utils/parse-contact-properties-to-api-options.ts
|