From 292bbc28217f6ad271edbcea8416d2bab719726f Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Thu, 12 Oct 2023 15:23:11 +0300 Subject: [PATCH] fix(attachments): Added contentDisposition property for attachments --- docs/api/openapi.yml | 8 +++ lib/api/messages.js | 9 ++- lib/api/submit.js | 9 ++- package-lock.json | 136 +++++++++++++++++++++++-------------------- package.json | 6 +- 5 files changed, 96 insertions(+), 72 deletions(-) diff --git a/docs/api/openapi.yml b/docs/api/openapi.yml index 546553e5..11cf6240 100644 --- a/docs/api/openapi.yml +++ b/docs/api/openapi.yml @@ -3452,6 +3452,14 @@ components: contentType: type: string description: MIME type for the attachment file + contentDisposition: + type: string + description: Which Content-Disposition value to use + enum: + - inline + - attachment + example: attachment + default: null cid: type: string description: Content-ID value if you want to reference to this attachment from HTML formatted message diff --git a/lib/api/messages.js b/lib/api/messages.js index 0543f477..8ab79e13 100644 --- a/lib/api/messages.js +++ b/lib/api/messages.js @@ -1598,11 +1598,14 @@ module.exports = (db, server, messageHandler, userHandler, storageHandler, setti attachments: Joi.array().items( Joi.object().keys({ filename: Joi.string().empty('').max(255), + contentType: Joi.string().empty('').max(255), - encoding: Joi.string().empty('').default('base64'), contentTransferEncoding: Joi.string().empty(''), - content: Joi.string().required(), - cid: Joi.string().empty('').max(255) + contentDisposition: Joi.string().empty('').trim().lowercase().valid('inline', 'attachment'), + cid: Joi.string().empty('').max(255), + + encoding: Joi.string().empty('').default('base64'), + content: Joi.string().required() }) ), diff --git a/lib/api/submit.js b/lib/api/submit.js index 9a148fdb..86561551 100644 --- a/lib/api/submit.js +++ b/lib/api/submit.js @@ -714,11 +714,14 @@ module.exports = (db, server, messageHandler, userHandler, settingsHandler) => { attachments: Joi.array().items( Joi.object().keys({ filename: Joi.string().empty('').max(255), + contentType: Joi.string().empty('').max(255), + contentTransferEncoding: Joi.string().empty('').trim().lowercase(), + contentDisposition: Joi.string().empty('').trim().lowercase().valid('inline', 'attachment'), + cid: Joi.string().empty('').max(255), + encoding: Joi.string().empty('').default('base64'), - contentTransferEncoding: Joi.string().empty(''), - content: Joi.string().required(), - cid: Joi.string().empty('').max(255) + content: Joi.string().required() }) ), meta: Joi.object().unknown(true), diff --git a/package-lock.json b/package-lock.json index bea083ef..48e5cece 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "base32.js": "0.1.0", "bcryptjs": "2.4.3", "bson": "6.1.0", - "bullmq": "4.12.2", + "bullmq": "4.12.3", "fido2-lib": "3.4.1", "gelf": "2.0.1", "generate-password": "1.7.0", @@ -64,13 +64,13 @@ "seq-index": "1.1.0", "smtp-server": "3.13.0", "speakeasy": "2.0.0", - "undici": "5.25.4", + "undici": "5.26.3", "unix-crypt-td-js": "1.1.4", "unixcrypt": "1.2.0", "uuid": "9.0.1", "wild-config": "1.7.1", "yargs": "17.7.2", - "zone-mta": "3.6.11" + "zone-mta": "3.6.13" }, "devDependencies": { "ajv": "8.12.0", @@ -1169,6 +1169,14 @@ "yarn": "^1.22.10" } }, + "node_modules/@opentelemetry/api": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.6.0.tgz", + "integrity": "sha512-OWlrQAnWn9577PhVgqjUvMr1pg57Bc4jv0iL4w0PRuOSRvq67rvHW9Ie/dZVMvCzhSCB+UxhcY/PmCmFj33Q+g==", + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/@peculiar/asn1-schema": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-2.3.0.tgz", @@ -1435,9 +1443,9 @@ } }, "node_modules/@smithy/fetch-http-handler": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-2.2.2.tgz", - "integrity": "sha512-K7aRtRuaBjzlk+jWWeyfDTLAmRRvmA4fU8eHUXtjsuEDgi3f356ZE32VD2ssxIH13RCLVZbXMt5h7wHzYiSuVA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-2.2.3.tgz", + "integrity": "sha512-0G9sePU+0R+8d7cie+OXzNbbkjnD4RfBlVCs46ZEuQAMcxK8OniemYXSSkOc80CCk8Il4DnlYZcUSvsIs2OB2w==", "optional": true, "dependencies": { "@smithy/protocol-http": "^3.0.7", @@ -1499,12 +1507,13 @@ } }, "node_modules/@smithy/middleware-endpoint": { - "version": "2.0.11", - "resolved": "https://registry.npmjs.org/@smithy/middleware-endpoint/-/middleware-endpoint-2.0.11.tgz", - "integrity": "sha512-mCugsvB15up6fqpzUEpMT4CuJmFkEI+KcozA7QMzYguXCaIilyMKsyxgamwmr+o7lo3QdjN0//XLQ9bWFL129g==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@smithy/middleware-endpoint/-/middleware-endpoint-2.1.0.tgz", + "integrity": "sha512-e6HZbfrp9CNTJqIPSgkydB9mNQXiq5pkHF3ZB6rOzPPR9PkJBoGFo9TcM7FaaKFUaH4Kc20AX6WwwVyIlNhXTA==", "optional": true, "dependencies": { "@smithy/middleware-serde": "^2.0.11", + "@smithy/node-config-provider": "^2.1.1", "@smithy/types": "^2.3.5", "@smithy/url-parser": "^2.0.11", "@smithy/util-middleware": "^2.0.4", @@ -1697,14 +1706,14 @@ } }, "node_modules/@smithy/smithy-client": { - "version": "2.1.10", - "resolved": "https://registry.npmjs.org/@smithy/smithy-client/-/smithy-client-2.1.10.tgz", - "integrity": "sha512-2OEmZDiW1Z196QHuQZ5M6cBE8FCSG0H2HADP1G+DY8P3agsvb0YJyfhyKuJbxIQy15tr3eDAK6FOrlbxgKOOew==", + "version": "2.1.11", + "resolved": "https://registry.npmjs.org/@smithy/smithy-client/-/smithy-client-2.1.11.tgz", + "integrity": "sha512-okjMbuBBCTiieK665OFN/ap6u9+Z9z55PMphS5FYCsS6Zfp137Q3qlnt0OgBAnUVnH/mNGyoJV0LBX9gkTWptg==", "optional": true, "dependencies": { "@smithy/middleware-stack": "^2.0.5", "@smithy/types": "^2.3.5", - "@smithy/util-stream": "^2.0.15", + "@smithy/util-stream": "^2.0.16", "tslib": "^2.5.0" }, "engines": { @@ -1794,13 +1803,13 @@ } }, "node_modules/@smithy/util-defaults-mode-browser": { - "version": "2.0.14", - "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-browser/-/util-defaults-mode-browser-2.0.14.tgz", - "integrity": "sha512-NupG7SWUucm3vJrvlpt9jG1XeoPJphjcivgcUUXhDJbUPy4F04LhlTiAhWSzwlCNcF8OJsMvZ/DWbpYD3pselw==", + "version": "2.0.15", + "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-browser/-/util-defaults-mode-browser-2.0.15.tgz", + "integrity": "sha512-2raMZOYKSuke7QlDg/HDcxQdrp0zteJ8z+S0B9Rn23J55ZFNK1+IjG4HkN6vo/0u3Xy/JOdJ93ibiBSB8F7kOw==", "optional": true, "dependencies": { "@smithy/property-provider": "^2.0.12", - "@smithy/smithy-client": "^2.1.10", + "@smithy/smithy-client": "^2.1.11", "@smithy/types": "^2.3.5", "bowser": "^2.11.0", "tslib": "^2.5.0" @@ -1810,16 +1819,16 @@ } }, "node_modules/@smithy/util-defaults-mode-node": { - "version": "2.0.18", - "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-node/-/util-defaults-mode-node-2.0.18.tgz", - "integrity": "sha512-+3jMom/b/Cdp21tDnY4vKu249Al+G/P0HbRbct7/aSZDlROzv1tksaYukon6UUv7uoHn+/McqnsvqZHLlqvQ0g==", + "version": "2.0.19", + "resolved": "https://registry.npmjs.org/@smithy/util-defaults-mode-node/-/util-defaults-mode-node-2.0.19.tgz", + "integrity": "sha512-7pScU4jBFADB2MBYKM3zb5onMh6Nn0X3IfaFVLYPyCarTIZDLUtUl1GtruzEUJPmDzP+uGeqOtU589HDY0Ni6g==", "optional": true, "dependencies": { "@smithy/config-resolver": "^2.0.14", "@smithy/credential-provider-imds": "^2.0.16", "@smithy/node-config-provider": "^2.1.1", "@smithy/property-provider": "^2.0.12", - "@smithy/smithy-client": "^2.1.10", + "@smithy/smithy-client": "^2.1.11", "@smithy/types": "^2.3.5", "tslib": "^2.5.0" }, @@ -1867,12 +1876,12 @@ } }, "node_modules/@smithy/util-stream": { - "version": "2.0.15", - "resolved": "https://registry.npmjs.org/@smithy/util-stream/-/util-stream-2.0.15.tgz", - "integrity": "sha512-A/hkYJPH2N5MCWYvky4tTpQihpYAEzqnUfxDyG3L/yMndy/2sLvxnyQal9Opuj1e9FiKSTeMyjnU9xxZGs0mRw==", + "version": "2.0.16", + "resolved": "https://registry.npmjs.org/@smithy/util-stream/-/util-stream-2.0.16.tgz", + "integrity": "sha512-b5ZSRh1KzUzC7LoJcpfk7+iXGoRr3WylEfmPd4FnBLm90OwxSB9VgK1fDZwicfYxSEvWHdYXgvvjPtenEYBBhw==", "optional": true, "dependencies": { - "@smithy/fetch-http-handler": "^2.2.2", + "@smithy/fetch-http-handler": "^2.2.3", "@smithy/node-http-handler": "^2.1.7", "@smithy/types": "^2.3.5", "@smithy/util-base64": "^2.0.0", @@ -1923,9 +1932,12 @@ } }, "node_modules/@types/node": { - "version": "20.8.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.3.tgz", - "integrity": "sha512-jxiZQFpb+NlH5kjW49vXxvxTjeeqlbsnTAdBTKpzEdPs9itay7MscYXz3Fo9VYFEsfQ6LJFitHad3faerLAjCw==" + "version": "20.8.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.4.tgz", + "integrity": "sha512-ZVPnqU58giiCjSxjVUESDtdPk4QR5WQhhINbc9UBrKLU68MX5BF6kbQzTrkwbolyr0X8ChBpXfavr5mZFKZQ5A==", + "dependencies": { + "undici-types": "~5.25.1" + } }, "node_modules/@types/webidl-conversions": { "version": "7.0.1", @@ -2496,9 +2508,9 @@ } }, "node_modules/bullmq": { - "version": "4.12.2", - "resolved": "https://registry.npmjs.org/bullmq/-/bullmq-4.12.2.tgz", - "integrity": "sha512-0YhOtg1lvdqBtYQgh7NNKisFckbxKaHSDqifXvx90OAa5qa6sqNoFbvOgaUitRsAiJgg2fDdT1DnMdQHsQiCeQ==", + "version": "4.12.3", + "resolved": "https://registry.npmjs.org/bullmq/-/bullmq-4.12.3.tgz", + "integrity": "sha512-4uPp4NQTALFF+eFK7g8VJM+rt0aiduQdzBomgiEO1OK4OE+TdgC6cjGXooKI/asuB8iDhSZ+pSnGYy5Xyr6qRA==", "dependencies": { "cron-parser": "^4.6.0", "glob": "^8.0.3", @@ -4175,9 +4187,9 @@ "dev": true }, "node_modules/find-my-way": { - "version": "7.6.2", - "resolved": "https://registry.npmjs.org/find-my-way/-/find-my-way-7.6.2.tgz", - "integrity": "sha512-0OjHn1b1nCX3eVbm9ByeEHiscPYiHLfhei1wOUU9qffQkk98wE0Lo8VrVYfSGMgnSnDh86DxedduAnBf4nwUEw==", + "version": "7.7.0", + "resolved": "https://registry.npmjs.org/find-my-way/-/find-my-way-7.7.0.tgz", + "integrity": "sha512-+SrHpvQ52Q6W9f3wJoJBbAQULJuNEEQwBvlvYwACDhBTLOTMiQ0HYWh4+vC3OivGP2ENcTI1oKlFA2OepJNjhQ==", "dependencies": { "fast-deep-equal": "^3.1.3", "fast-querystring": "^1.0.0", @@ -5823,9 +5835,9 @@ } }, "node_modules/jose": { - "version": "4.15.2", - "resolved": "https://registry.npmjs.org/jose/-/jose-4.15.2.tgz", - "integrity": "sha512-IY73F228OXRl9ar3jJagh7Vnuhj/GzBunPiZP13K0lOl7Am9SoWW3kEzq3MCllJMTtZqHTiDXQvoRd4U95aU6A==", + "version": "4.15.3", + "resolved": "https://registry.npmjs.org/jose/-/jose-4.15.3.tgz", + "integrity": "sha512-RZJdL9Qjd1sqNdyiVteRGV/bnWtik/+PJh1JP4kT6+x1QQMn+7ryueRys5BEueuayvSVY8CWGCisCDazeRLTuw==", "funding": { "url": "https://github.com/sponsors/panva" } @@ -7865,14 +7877,15 @@ "integrity": "sha512-SyAjKYd83c9rcBfb4Xpawq0dnPbgOzva2vEaKvdd5rC+6a1MzLyNieqRfT0pas7FBJRyI4JLeuCENpz/Va8mMw==" }, "node_modules/prom-client": { - "version": "14.2.0", - "resolved": "https://registry.npmjs.org/prom-client/-/prom-client-14.2.0.tgz", - "integrity": "sha512-sF308EhTenb/pDRPakm+WgiN+VdM/T1RaHj1x+MvAuT8UiQP8JmOEbxVqtkbfR4LrvOg5n7ic01kRBDGXjYikA==", + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/prom-client/-/prom-client-15.0.0.tgz", + "integrity": "sha512-UocpgIrKyA2TKLVZDSfm8rGkL13C19YrQBAiG3xo3aDFWcHedxRxI3z+cIcucoxpSO0h5lff5iv/SXoxyeopeA==", "dependencies": { + "@opentelemetry/api": "^1.4.0", "tdigest": "^0.1.1" }, "engines": { - "node": ">=10" + "node": "^16 || ^18 || >=20" } }, "node_modules/proxy-from-env": { @@ -8349,9 +8362,9 @@ "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==" }, "node_modules/resolve": { - "version": "1.22.6", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.6.tgz", - "integrity": "sha512-njhxM7mV12JfufShqGy3Rz8j11RPdLy4xi15UurGJeoHLfJpVXKdh3ueuOqbYUcDZnffr6X739JBo5LzyahEsw==", + "version": "1.22.8", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", "dev": true, "dependencies": { "is-core-module": "^2.13.0", @@ -8916,9 +8929,9 @@ } }, "node_modules/sonic-boom": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-3.6.1.tgz", - "integrity": "sha512-QV+p5nXPiUiSMxn/k5bOL+hzCpafdj1voL+hywPZhheRSYyYp7CF15rNdz1evOXCUn/tFb7R62PDX1yJmtoTgg==", + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-3.7.0.tgz", + "integrity": "sha512-IudtNvSqA/ObjN97tfgNmOKyDOs4dNcg4cUUsHDebqsgb8wGBBwb31LIgShNO8fye0dFI52X1+tFoKKI6Rq1Gg==", "dependencies": { "atomic-sleep": "^1.0.0" } @@ -9501,9 +9514,9 @@ } }, "node_modules/undici": { - "version": "5.25.4", - "resolved": "https://registry.npmjs.org/undici/-/undici-5.25.4.tgz", - "integrity": "sha512-450yJxT29qKMf3aoudzFpIciqpx6Pji3hEWaXqXmanbXF58LTAGCKxcJjxMXWu3iG+Mudgo3ZUfDB6YDFd/dAw==", + "version": "5.26.3", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.26.3.tgz", + "integrity": "sha512-H7n2zmKEWgOllKkIUkLvFmsJQj062lSm3uA4EYApG8gLuiOM0/go9bIoC3HVaSnfg4xunowDE2i9p8drkXuvDw==", "dependencies": { "@fastify/busboy": "^2.0.0" }, @@ -9511,6 +9524,11 @@ "node": ">=14.0" } }, + "node_modules/undici-types": { + "version": "5.25.3", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.25.3.tgz", + "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==" + }, "node_modules/unique-string": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-2.0.0.tgz", @@ -10153,9 +10171,9 @@ } }, "node_modules/zone-mta": { - "version": "3.6.11", - "resolved": "https://registry.npmjs.org/zone-mta/-/zone-mta-3.6.11.tgz", - "integrity": "sha512-qcJriWtJwRyBk+Dr8DIi9Bl9p4uWrfLSmXR0fqltcKlMt2zIKZjpBMDC994iY4twRfAWb7HVmRiQ1fFG8yc8zA==", + "version": "3.6.13", + "resolved": "https://registry.npmjs.org/zone-mta/-/zone-mta-3.6.13.tgz", + "integrity": "sha512-we+vhQeXw1S7CzerErqHy9nj8XxTzV08/KCvFeORabe74wGRdQSZs7Y0RmQBpuyODQSO2nbeCY4uVyCKvJSYaQ==", "dependencies": { "base32.js": "0.1.0", "crc-32": "1.2.2", @@ -10170,9 +10188,9 @@ "mongodb": "4.17.0", "msgpack-js": "0.3.0", "mx-connect": "1.4.4", - "nodemailer": "6.9.5", + "nodemailer": "6.9.6", "npmlog": "7.0.1", - "prom-client": "14.2.0", + "prom-client": "15.0.0", "punycode": "2.3.0", "request": "2.88.2", "restify": "11.1.0", @@ -10188,14 +10206,6 @@ "engines": { "node": ">=16.0.0" } - }, - "node_modules/zone-mta/node_modules/nodemailer": { - "version": "6.9.5", - "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.5.tgz", - "integrity": "sha512-/dmdWo62XjumuLc5+AYQZeiRj+PRR8y8qKtFCOyuOl1k/hckZd8durUUHs/ucKx6/8kN+wFxqKJlQ/LK/qR5FA==", - "engines": { - "node": ">=6.0.0" - } } } } diff --git a/package.json b/package.json index 93083bd8..7729a177 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "base32.js": "0.1.0", "bcryptjs": "2.4.3", "bson": "6.1.0", - "bullmq": "4.12.2", + "bullmq": "4.12.3", "fido2-lib": "3.4.1", "gelf": "2.0.1", "generate-password": "1.7.0", @@ -97,13 +97,13 @@ "seq-index": "1.1.0", "smtp-server": "3.13.0", "speakeasy": "2.0.0", - "undici": "5.25.4", + "undici": "5.26.3", "unix-crypt-td-js": "1.1.4", "unixcrypt": "1.2.0", "uuid": "9.0.1", "wild-config": "1.7.1", "yargs": "17.7.2", - "zone-mta": "3.6.11" + "zone-mta": "3.6.13" }, "repository": { "type": "git",