resend 6.35.0 → 6.36.1

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 CHANGED
@@ -57,7 +57,7 @@ const MOVE_THREAD_FOLDERS = [
57
57
  ];
58
58
  //#endregion
59
59
  //#region package.json
60
- var version = "6.35.0";
60
+ var version = "6.36.1";
61
61
  //#endregion
62
62
  //#region src/common/utils/build-pagination-query.ts
63
63
  function buildPaginationUrl(base, options) {
@@ -386,12 +386,22 @@ function buildRecipientsQuery(options) {
386
386
  //#region src/common/utils/has-dot-segment.ts
387
387
  const DOT_SEGMENT = /^(?:\.|%2e){1,2}$/i;
388
388
  /**
389
+ * Drops what URL parsing drops before it resolves dot segments: tabs and
390
+ * newlines anywhere, and control characters or spaces at the end.
391
+ */
392
+ function stripIgnoredCharacters(requestPath) {
393
+ let path = requestPath.replace(/[\t\n\r]/g, "");
394
+ while (path.length > 0 && path.charCodeAt(path.length - 1) <= 32) path = path.slice(0, -1);
395
+ return path;
396
+ }
397
+ /**
389
398
  * Whether a request path contains a `.` or `..` segment. URL parsing resolves
390
399
  * these (even when percent-encoded), so the request would reach another path.
400
+ * In http(s) URLs a `\` separates segments the same way `/` does.
391
401
  */
392
402
  function hasDotSegment(requestPath) {
393
- const [pathname] = requestPath.split(/[?#]/);
394
- return pathname.split("/").some((segment) => DOT_SEGMENT.test(segment));
403
+ const [pathname] = stripIgnoredCharacters(requestPath).split(/[?#]/);
404
+ return pathname.split(/[\\/]/).some((segment) => DOT_SEGMENT.test(segment));
395
405
  }
396
406
  //#endregion
397
407
  //#region src/common/utils/parse-contact-properties-to-api-options.ts
package/dist/index.d.cts CHANGED
@@ -1828,12 +1828,22 @@ interface InboxDraftAttachment {
1828
1828
  content_type: string;
1829
1829
  size: number;
1830
1830
  }
1831
- interface InboxDraftAttachmentOptions {
1831
+ interface InboxDraftContentAttachmentOptions {
1832
1832
  /** Content of the file, as a base64 string or a Buffer. */
1833
1833
  content: string | Buffer;
1834
+ path?: never;
1834
1835
  filename: string;
1835
1836
  contentType: string;
1836
1837
  }
1838
+ interface InboxDraftPathAttachmentOptions {
1839
+ content?: never;
1840
+ /** URL of the file, downloaded when the request is made and stored on the draft. */
1841
+ path: string;
1842
+ filename: string;
1843
+ /** Defaults to the content type of the downloaded file. */
1844
+ contentType?: string;
1845
+ }
1846
+ type InboxDraftAttachmentOptions = InboxDraftContentAttachmentOptions | InboxDraftPathAttachmentOptions;
1837
1847
  interface InboxDraft {
1838
1848
  object: 'inbox_draft';
1839
1849
  id: string;
@@ -1874,8 +1884,10 @@ type CreateInboxDraftContent = RequireAtLeastOne<{
1874
1884
  text?: string | null;
1875
1885
  html?: string | null;
1876
1886
  /**
1877
- * Files to store on the draft. Each one needs `content`, `filename` and `contentType`.
1878
- * The files on a draft can total at most 25 MB. An empty file or a blocked file type returns a 422.
1887
+ * Files to store on the draft. Each one needs a `filename` and either `content` with a `contentType`,
1888
+ * or a `path` URL that is downloaded when the request is made.
1889
+ * The files on a draft, downloaded ones included, can total at most 25 MB. An empty file, a blocked file type,
1890
+ * or a `path` that cannot be downloaded returns a 422.
1879
1891
  */
1880
1892
  attachments?: InboxDraftAttachmentOptions[];
1881
1893
  }>;
@@ -1949,8 +1961,10 @@ type UpdateInboxDraftOptions = InboxSelector & {
1949
1961
  text?: string | null;
1950
1962
  html?: string | null;
1951
1963
  /**
1952
- * Files to store on the draft. Each one needs `content`, `filename` and `contentType`.
1953
- * The files on a draft can total at most 25 MB. An empty file or a blocked file type returns a 422.
1964
+ * Files to store on the draft. Each one needs a `filename` and either `content` with a `contentType`,
1965
+ * or a `path` URL that is downloaded when the request is made.
1966
+ * The files on a draft, downloaded ones included, can total at most 25 MB. An empty file, a blocked file type,
1967
+ * or a `path` that cannot be downloaded returns a 422.
1954
1968
  * Sending the field replaces every attachment on the draft. Send `[]` or `null` to remove them all.
1955
1969
  */
1956
1970
  attachments?: InboxDraftAttachmentOptions[] | null;
package/dist/index.d.mts CHANGED
@@ -1828,12 +1828,22 @@ interface InboxDraftAttachment {
1828
1828
  content_type: string;
1829
1829
  size: number;
1830
1830
  }
1831
- interface InboxDraftAttachmentOptions {
1831
+ interface InboxDraftContentAttachmentOptions {
1832
1832
  /** Content of the file, as a base64 string or a Buffer. */
1833
1833
  content: string | Buffer;
1834
+ path?: never;
1834
1835
  filename: string;
1835
1836
  contentType: string;
1836
1837
  }
1838
+ interface InboxDraftPathAttachmentOptions {
1839
+ content?: never;
1840
+ /** URL of the file, downloaded when the request is made and stored on the draft. */
1841
+ path: string;
1842
+ filename: string;
1843
+ /** Defaults to the content type of the downloaded file. */
1844
+ contentType?: string;
1845
+ }
1846
+ type InboxDraftAttachmentOptions = InboxDraftContentAttachmentOptions | InboxDraftPathAttachmentOptions;
1837
1847
  interface InboxDraft {
1838
1848
  object: 'inbox_draft';
1839
1849
  id: string;
@@ -1874,8 +1884,10 @@ type CreateInboxDraftContent = RequireAtLeastOne<{
1874
1884
  text?: string | null;
1875
1885
  html?: string | null;
1876
1886
  /**
1877
- * Files to store on the draft. Each one needs `content`, `filename` and `contentType`.
1878
- * The files on a draft can total at most 25 MB. An empty file or a blocked file type returns a 422.
1887
+ * Files to store on the draft. Each one needs a `filename` and either `content` with a `contentType`,
1888
+ * or a `path` URL that is downloaded when the request is made.
1889
+ * The files on a draft, downloaded ones included, can total at most 25 MB. An empty file, a blocked file type,
1890
+ * or a `path` that cannot be downloaded returns a 422.
1879
1891
  */
1880
1892
  attachments?: InboxDraftAttachmentOptions[];
1881
1893
  }>;
@@ -1949,8 +1961,10 @@ type UpdateInboxDraftOptions = InboxSelector & {
1949
1961
  text?: string | null;
1950
1962
  html?: string | null;
1951
1963
  /**
1952
- * Files to store on the draft. Each one needs `content`, `filename` and `contentType`.
1953
- * The files on a draft can total at most 25 MB. An empty file or a blocked file type returns a 422.
1964
+ * Files to store on the draft. Each one needs a `filename` and either `content` with a `contentType`,
1965
+ * or a `path` URL that is downloaded when the request is made.
1966
+ * The files on a draft, downloaded ones included, can total at most 25 MB. An empty file, a blocked file type,
1967
+ * or a `path` that cannot be downloaded returns a 422.
1954
1968
  * Sending the field replaces every attachment on the draft. Send `[]` or `null` to remove them all.
1955
1969
  */
1956
1970
  attachments?: InboxDraftAttachmentOptions[] | null;
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.35.0";
36
+ var version = "6.36.1";
37
37
  //#endregion
38
38
  //#region src/common/utils/build-pagination-query.ts
39
39
  function buildPaginationUrl(base, options) {
@@ -362,12 +362,22 @@ function buildRecipientsQuery(options) {
362
362
  //#region src/common/utils/has-dot-segment.ts
363
363
  const DOT_SEGMENT = /^(?:\.|%2e){1,2}$/i;
364
364
  /**
365
+ * Drops what URL parsing drops before it resolves dot segments: tabs and
366
+ * newlines anywhere, and control characters or spaces at the end.
367
+ */
368
+ function stripIgnoredCharacters(requestPath) {
369
+ let path = requestPath.replace(/[\t\n\r]/g, "");
370
+ while (path.length > 0 && path.charCodeAt(path.length - 1) <= 32) path = path.slice(0, -1);
371
+ return path;
372
+ }
373
+ /**
365
374
  * Whether a request path contains a `.` or `..` segment. URL parsing resolves
366
375
  * these (even when percent-encoded), so the request would reach another path.
376
+ * In http(s) URLs a `\` separates segments the same way `/` does.
367
377
  */
368
378
  function hasDotSegment(requestPath) {
369
- const [pathname] = requestPath.split(/[?#]/);
370
- return pathname.split("/").some((segment) => DOT_SEGMENT.test(segment));
379
+ const [pathname] = stripIgnoredCharacters(requestPath).split(/[?#]/);
380
+ return pathname.split(/[\\/]/).some((segment) => DOT_SEGMENT.test(segment));
371
381
  }
372
382
  //#endregion
373
383
  //#region src/common/utils/parse-contact-properties-to-api-options.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resend",
3
- "version": "6.35.0",
3
+ "version": "6.36.1",
4
4
  "description": "Node.js library for the Resend API",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",