Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@ahmedayob/email-toolkit
Advanced tools
A powerful and flexible toolkit for building, validating, and processing emails with TypeScript. This library offers utilities for handling email headers, attachments, and encoding, making it easier to compose and manage emails programmatically.
@ahmedayob/email-toolkit
A powerful and flexible toolkit for building, validating, and processing emails with TypeScript. This library offers utilities for handling email headers, attachments, and encoding, making it easier to compose and manage emails programmatically.
EmailError
class.To install the toolkit, use npm or yarn:
npm install @ahmedayob/email-toolkit
# or
yarn add @ahmedayob/email-toolkit
Here's a quick guide on how to use the library:
Create and configure email headers:
import { EmailBuilderHeader } from "@ahmedayob/email-toolkit";
const header = new EmailBuilderHeader();
header
.setFrom("ahmed <ahmed@gmail.com>")
.setTo("ahmed <ahmed@gmail.com>")
.setCc("ahmed <ahmed@gmail.com>")
.setBcc("ahmed <ahmed@gmail.com>")
.setSubject("This is a test email subject")
.setInReplyTo("ahmed@gmail.com")
.setMIMEVersion("1.0")
.setContentTransferEncoding("quoted-printable")
.setContentType("text/html")
.setCharset("utf-8");
Add attachments to your email:
import { EmailBuilderAttachment, Base64 } from "@ahmedayob/email-toolkit";
const attachment = new EmailBuilderAttachment();
attachment.addAttachment({
headers: {
"Content-Type": 'text/plain; charset="utf-8"',
"Content-Transfer-Encoding": "base64",
"Content-Disposition": 'attachment; filename="test.txt"',
},
size: 1234,
filename: "test.txt",
mimeType: "text/plain",
attachmentId: "1234",
attachmentContent: Base64.encodeToBase64(
"This is the content of the attachment."
),
});
Combine headers and attachments to create the final email:
import { EmailBuilder } from "@ahmedayob/email-toolkit";
const email = new EmailBuilder();
email.messagebody = "<p>This is the message body</p>";
const finalEmail = email.getRawMessage(header.headers, attachment.attachments);
console.log(finalEmail);
Generate base64-encoded messages and email signatures:
import { EmailBuilder } from "@ahmedayob/email-toolkit";
const email = new EmailBuilder();
email.messagebody = "<p>This is the message body</p>";
const encodedMessage = email.getEncodedMessage(
header.headers,
attachment.attachments
);
console.log(encodedMessage);
email.setSignature({
url: "https://github.com/wildduck2",
name: "Ahmed Ayob",
});
const signature = email.getSignature({
from: "ahmed@example.com",
url: "https://github.com/wildduck2",
name: "Ahmed Ayob",
});
console.log(signature.join("\n"));
EmailBuilderHeader
EmailBuilderAttachment
EmailBuilder
Base64
EmailError
EmailError
.Validation schemas are available to ensure data correctness:
Contributions are welcome! Please open issues and pull requests on the GitHub repository.
This project is licensed under the MIT License. See the LICENSE file for details.
FAQs
A powerful and flexible toolkit for building, validating, and processing emails with TypeScript. This library offers utilities for handling email headers, attachments, and encoding, making it easier to compose and manage emails programmatically.
The npm package @ahmedayob/email-toolkit receives a total of 1 weekly downloads. As such, @ahmedayob/email-toolkit popularity was classified as not popular.
We found that @ahmedayob/email-toolkit demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.