node_modules: update (#360)

Co-authored-by: dawidd6 <9713907+dawidd6@users.noreply.github.com>
This commit is contained in:
Dawid Dziurlaanddawidd6 authored and GitHub committed 2026-10-31 22:36:14 +01:00
1 parent a9703ed892
commit 27bf7a883d
17 files changed
+126 -137

No files matched your search

+1 -1
View File
@@ -124,7 +124,7 @@ export interface MailComposerOptions {
headers?: MimeNodeHeaders | undefined;
/** List-* headers, read by the mailer */
list?: MailComposerListHeaders | undefined;
/** One-time passcode for the OTP-Token header, read by the mailer */
/** One-time passcode for the OTP-Token header. An invalid value makes compile() throw an EOTP error */
otp?: MailComposerOtp | undefined;
/** SMTP envelope to use instead of the one generated from the headers */
envelope?: MimeNodeEnvelopeInput | undefined;
+53
View File
@@ -39,6 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true });
const index_js_1 = __importDefault(require("../mime-node/index.js"));
const mimeFuncs = __importStar(require("../mime-funcs/index.js"));
const errors = __importStar(require("../errors.js"));
const index_js_2 = require("../shared/index.js");
/**
* Creates the object for composing a MimeNode instance out from the mail options
@@ -133,6 +134,10 @@ class MailComposer {
if (this.mail.headers) {
this.message.addHeader(this.mail.headers);
}
// after the custom headers, so it replaces an OTP-Token from them, the field may appear only once
if (this.mail.otp) {
this.message.setHeader('OTP-Token', formatOtpToken(this.mail.otp));
}
// Add headers to the root node, always overrides custom headers
['from', 'sender', 'to', 'cc', 'bcc', 'reply-to', 'in-reply-to', 'references', 'subject', 'message-id', 'date'].forEach(header => {
const key = header.replace(/-(\w)/g, (o, c) => c.toUpperCase());
@@ -641,6 +646,54 @@ class MailComposer {
return element;
}
}
/**
* Returns the value of the OTP-Token header for the otp option. The header is defined by
* draft-goto-otp-token-01, an Internet-Draft that expires on 25 March 2027. By then check
* for a newer revision of the draft or a published RFC, the header name and its
* parameters are still open questions in the draft.
*/
function formatOtpToken(otp) {
// a structured field String can only hold printable ascii. The code is a secret the recipient
// compares against the one in the message body, so it is rejected rather than cleaned up
if (typeof otp.code !== 'string' || !/^[\x20-\x7e]+$/.test(otp.code)) {
throw otpError('The otp code must be a non-empty string of printable ASCII characters');
}
// a structured field String escapes the same two characters as a quoted-string
return mimeFuncs.quoteString(otp.code) + '; origin=' + mimeFuncs.quoteString(getOtpOrigin(otp.origin));
}
/**
* Returns the canonical ascii serialization of the origin the code is bound to. The draft
* requires a potentially trustworthy origin, so only https is accepted, plus http on a
* loopback host for local development
*/
function getOtpOrigin(origin) {
let url;
try {
url = new URL(String(origin));
}
catch {
// handled below
}
// the WHATWG parser lets characters such as a quote or a brace into a host, which the
// origin grammar the draft requires (RFC 6454) does not allow, so a receiver would discard
// the header. Only a DNS name, an IPv4 address or a bracketed IPv6 address is accepted.
// Userinfo is refused as well, an origin never has it and it turns a value built as
// 'https://example.com' + input into the origin of whatever host follows an "@"
if (!url || url.username || url.password || !/^([a-z0-9_-]+\.)*[a-z0-9_-]+$|^\[[0-9a-f:.]+\]$/.test(url.hostname)) {
throw otpError('The otp origin must be an absolute https URL');
}
const isLoopback = /^(localhost|.+\.localhost|127(\.\d+){3}|\[::1\])$/.test(url.hostname);
if (url.protocol !== 'https:' && !(url.protocol === 'http:' && isLoopback)) {
throw otpError('The otp origin must be an https URL, or an http URL on a loopback host');
}
// the URL parser already lowercases the host, converts it to punycode and drops the default port
return url.origin;
}
function otpError(message) {
const err = new Error(message);
err.code = errors.EOTP;
return err;
}
exports.default = MailComposer;
module.exports = exports.default;
Object.defineProperty(module.exports, 'default', { value: exports.default, enumerable: false, writable: true, configurable: true });