New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

emailjs

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

emailjs - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

README.md

2

email.ts

@@ -0,1 +1,2 @@

export * from './smtp/address';
export * from './smtp/client';

@@ -6,2 +7,3 @@ export * from './smtp/connection';

export * from './smtp/message';
export * from './smtp/mime';
export * from './smtp/response';

25

package.json
{
"name": "emailjs",
"description": "send text/html emails and attachments (files, streams and strings) from node.js to any smtp server",
"version": "3.0.0",
"version": "3.1.0",
"author": "eleith",

@@ -20,22 +20,20 @@ "contributors": [

"@ledge/configs": "23.0.0",
"@rollup/plugin-commonjs": "12.0.0",
"@rollup/plugin-node-resolve": "8.0.0",
"@rollup/plugin-commonjs": "13.0.0",
"@rollup/plugin-node-resolve": "8.0.1",
"@rollup/plugin-typescript": "4.1.2",
"@types/mailparser": "2.7.3",
"@types/smtp-server": "3.5.4",
"@typescript-eslint/eslint-plugin": "3.0.1",
"@typescript-eslint/parser": "3.0.1",
"addressparser": "1.0.1",
"ava": "3.8.2",
"emailjs-mime-codec": "2.0.9",
"eslint": "7.1.0",
"@typescript-eslint/eslint-plugin": "3.3.0",
"@typescript-eslint/parser": "3.3.0",
"ava": "3.9.0",
"eslint": "7.2.0",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-prettier": "3.1.3",
"eslint-plugin-prettier": "3.1.4",
"mailparser": "2.7.7",
"prettier": "2.0.5",
"rollup": "2.10.9",
"rollup": "2.17.0",
"smtp-server": "3.6.0",
"ts-node": "8.10.1",
"ts-node": "8.10.2",
"tslib": "2.0.0",
"typescript": "3.9.3"
"typescript": "3.9.5"
},

@@ -59,2 +57,3 @@ "engine": [

"lint": "eslint *.ts \"+(smtp|test)/*.ts\"",
"tsc": "tsc",
"test": "ava --serial",

@@ -61,0 +60,0 @@ "test-cjs": "npm run build && npm run test -- --node-arguments='--title=cjs'"

@@ -1,2 +0,2 @@

import addressparser from 'addressparser';
import { addressparser } from './address';
import { Message } from './message';

@@ -95,9 +95,13 @@ import type { MessageAttachment, MessageHeaders } from './message';

if (typeof message.header.to === 'string') {
stack.to = addressparser(message.header.to);
const {
header: { to, cc, bcc, 'return-path': returnPath },
} = message;
if ((typeof to === 'string' || Array.isArray(to)) && to.length > 0) {
stack.to = addressparser(to);
}
if (typeof message.header.cc === 'string') {
if ((typeof cc === 'string' || Array.isArray(cc)) && cc.length > 0) {
stack.to = stack.to.concat(
addressparser(message.header.cc).filter(
addressparser(cc).filter(
(x) => stack.to.some((y) => y.address === x.address) === false

@@ -108,5 +112,5 @@ )

if (typeof message.header.bcc === 'string') {
if ((typeof bcc === 'string' || Array.isArray(bcc)) && bcc.length > 0) {
stack.to = stack.to.concat(
addressparser(message.header.bcc).filter(
addressparser(bcc).filter(
(x) => stack.to.some((y) => y.address === x.address) === false

@@ -117,10 +121,7 @@ )

if (
typeof message.header['return-path'] === 'string' &&
message.header['return-path'].length > 0
) {
const parsedReturnPath = addressparser(message.header['return-path']);
if (typeof returnPath === 'string' && returnPath.length > 0) {
const parsedReturnPath = addressparser(returnPath);
if (parsedReturnPath.length > 0) {
const [{ address: returnPathAddress }] = parsedReturnPath;
stack.returnPath = returnPathAddress;
stack.returnPath = returnPathAddress as string;
}

@@ -127,0 +128,0 @@ }

@@ -0,6 +1,7 @@

import { createHmac } from 'crypto';
import { EventEmitter } from 'events';
import { Socket } from 'net';
import { createHmac } from 'crypto';
import { hostname } from 'os';
import { connect, createSecureContext, TLSSocket } from 'tls';
import { EventEmitter } from 'events';
import type { ConnectionOptions } from 'tls';

@@ -69,7 +70,6 @@ import { SMTPError, SMTPErrorStates } from './error';

export interface SMTPSocketOptions {
key: string;
ca: string;
cert: string;
}
export type SMTPSocketOptions = Omit<
ConnectionOptions,
'port' | 'host' | 'path' | 'socket' | 'timeout' | 'secureContext'
>;

@@ -76,0 +76,0 @@ export interface SMTPConnectionOptions {

import fs from 'fs';
import type { PathLike } from 'fs';
import type { PathLike, ReadStream } from 'fs';
import { hostname } from 'os';
import { Stream } from 'stream';
import type { Duplex } from 'stream';
import addressparser from 'addressparser';
import { mimeWordEncode } from 'emailjs-mime-codec';
import { addressparser } from './address';
import { getRFC2822Date } from './date';
import { mimeWordEncode } from './mime';

@@ -35,3 +34,3 @@ const CRLF = '\r\n' as const;

export interface AlternateMessageAttachment {
export interface MessageAttachment {
[index: string]:

@@ -43,3 +42,3 @@ | string

| MessageAttachmentHeaders
| Duplex
| ReadStream
| PathLike

@@ -49,19 +48,22 @@ | undefined;

headers?: MessageAttachmentHeaders;
inline: boolean;
inline?: boolean;
alternative?: MessageAttachment | boolean;
related?: MessageAttachment[];
data: string;
data?: string;
encoded?: boolean;
stream?: Duplex;
stream?: ReadStream;
path?: PathLike;
type?: string;
charset?: string;
method?: string;
}
export interface MessageAttachment extends AlternateMessageAttachment {
type: string;
charset: string;
method: string;
}
export interface MessageHeaders {
[index: string]: string | null | MessageAttachment | MessageAttachment[];
[index: string]:
| boolean
| string
| string[]
| null
| MessageAttachment
| MessageAttachment[];
'content-type': string;

@@ -71,6 +73,6 @@ 'message-id': string;

date: string;
from: string;
to: string;
cc: string;
bcc: string;
from: string | string[];
to: string | string[];
cc: string | string[];
bcc: string | string[];
subject: string;

@@ -95,3 +97,3 @@ text: string | null;

function convertPersonToAddress(person: string) {
function convertPersonToAddress(person: string | string[]) {
return addressparser(person)

@@ -122,3 +124,3 @@ .map(({ name, address }) => {

public readonly text?: string;
public alternative: AlternateMessageAttachment | null = null;
public alternative: MessageAttachment | null = null;

@@ -156,6 +158,6 @@ /**

} else if (header === 'subject') {
this.header.subject = mimeWordEncode(headers.subject);
this.header.subject = mimeWordEncode(headers.subject as string);
} else if (/^(cc|bcc|to|from)/i.test(header)) {
this.header[header.toLowerCase()] = convertPersonToAddress(
headers[header] as string
headers[header] as string | string[]
);

@@ -198,8 +200,14 @@ } else {

public valid(callback: (isValid: boolean, invalidReason?: string) => void) {
if (typeof this.header.from !== 'string') {
if (
typeof this.header.from !== 'string' &&
Array.isArray(this.header.from) === false
) {
callback(false, 'Message must have a `from` header');
} else if (
typeof this.header.to !== 'string' &&
Array.isArray(this.header.to) === false &&
typeof this.header.cc !== 'string' &&
typeof this.header.bcc !== 'string'
Array.isArray(this.header.cc) === false &&
typeof this.header.bcc !== 'string' &&
Array.isArray(this.header.bcc) === false
) {

@@ -323,8 +331,6 @@ callback(

/**
* @param {MessageAttachment | AlternateMessageAttachment} [attachment] the attachment whose headers you would like to output
* @param {MessageAttachment} [attachment] the attachment whose headers you would like to output
* @returns {void}
*/
const output_attachment_headers = (
attachment: MessageAttachment | AlternateMessageAttachment
) => {
const output_attachment_headers = (attachment: MessageAttachment) => {
let data: string[] = [];

@@ -381,3 +387,3 @@ const headers: Partial<MessageHeaders> = {

const output_file = (
attachment: MessageAttachment | AlternateMessageAttachment,
attachment: MessageAttachment,
next: (err: NodeJS.ErrnoException | null) => void

@@ -444,3 +450,3 @@ ) => {

const output_stream = (
attachment: MessageAttachment | AlternateMessageAttachment,
attachment: MessageAttachment,
callback: () => void

@@ -491,3 +497,3 @@ ) => {

const output_attachment = (
attachment: MessageAttachment | AlternateMessageAttachment,
attachment: MessageAttachment,
callback: () => void

@@ -545,3 +551,3 @@ ) => {

output_alternative(
// typescript bug; should narrow to { alternative: AlternateMessageAttachment }
// typescript bug; should narrow to { alternative: MessageAttachment }
this.message as Parameters<typeof output_alternative>[0],

@@ -559,3 +565,3 @@ () => output_message(boundary, this.message.attachments, 0, close)

const output_data = (
attachment: MessageAttachment | AlternateMessageAttachment,
attachment: MessageAttachment,
callback: () => void

@@ -565,4 +571,4 @@ ) => {

attachment.encoded
? attachment.data
: Buffer.from(attachment.data).toString('base64'),
? attachment.data ?? ''
: Buffer.from(attachment.data ?? '').toString('base64'),
callback

@@ -598,3 +604,3 @@ );

const output_related = (
message: AlternateMessageAttachment,
message: MessageAttachment,
callback: () => void

@@ -620,3 +626,3 @@ ) => {

const output_alternative = (
message: Message & { alternative: AlternateMessageAttachment },
message: Message & { alternative: MessageAttachment },
callback: () => void

@@ -623,0 +629,0 @@ ) => {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc