Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

emailemail

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

emailemail - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

lib/emailemail.js.map

8

lib/emailemail.d.ts
import { Provider } from "./providers/provider";
import { EmailInstance, ProviderOpts } from "./types";
import { EmailInstance } from "./types";
export * from "./types";

@@ -7,6 +7,6 @@ export declare type EmailProvider = "aws";

provider_name: EmailProvider;
provider_opts?: ProviderOpts;
provider_opts?: any;
template_directory?: string;
sender_email_address?: string;
reply_to_address?: string;
sender_email_address: string;
reply_to_address: string;
};

@@ -13,0 +13,0 @@ export declare class EmailEmail {

@@ -1,12 +0,31 @@

var _a;
import { readFileSync } from "fs";
import glob from "glob";
import Handlebars from "handlebars";
import juice from "juice";
import { join } from "path";
import { EmailEmailAWSProvider } from "./providers/aws";
export * from "./types";
const debug = require("debug")("emailemail:EmailEmail");
require("env2")(".env");
const DEFAULT_TEMPLATE_DIRECTORY = join(__dirname, "..", "templates");
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmailEmail = void 0;
const debug_1 = require("debug");
const fs_1 = require("fs");
const glob_1 = __importDefault(require("glob"));
const handlebars_1 = __importDefault(require("handlebars"));
const juice_1 = __importDefault(require("juice"));
const path_1 = require("path");
const aws_1 = require("./providers/aws");
__exportStar(require("./types"), exports);
const debug = (0, debug_1.debug)("emailemail:EmailEmail");
const DEFAULT_TEMPLATE_DIRECTORY = (0, path_1.join)(__dirname, "..", "templates");
const defaults = {

@@ -16,8 +35,12 @@ provider_name: "aws",

template_directory: DEFAULT_TEMPLATE_DIRECTORY,
sender_email_address: process.env.SENDER_EMAIL_ADDRESS,
reply_to_address: (_a = process.env.REPLY_TO_ADDRESS) !== null && _a !== void 0 ? _a : process.env.SENDER_EMAIL_ADDRESS,
sender_email_address: process.env.SENDER_EMAIL_ADDRESS ?? "no-reply@ari.io",
reply_to_address: process.env.REPLY_TO_ADDRESS ??
process.env.SENDER_EMAIL_ADDRESS ??
"unknown@ari.io",
};
export class EmailEmail {
class EmailEmail {
opts;
provider;
compiled_templates = {};
constructor(opts) {
this.compiled_templates = {};
this.opts = opts = { ...defaults, ...opts };

@@ -28,3 +51,3 @@ switch (this.opts.provider_name) {

debug(`Using aws as email provider`);
this.provider = new EmailEmailAWSProvider(this.opts.provider_opts);
this.provider = new aws_1.EmailEmailAWSProvider(this.opts.provider_opts);
break;

@@ -35,3 +58,3 @@ }

const context = { email: emailOpts, ...rawContext };
const { toAddresses, subject, name, ccAddresses, bccAddresses } = emailOpts;
const { toAddresses, subject, ccAddresses, bccAddresses } = emailOpts;
const compiled_html_template = await this.compile_html_template(template_name, template_content, context);

@@ -45,4 +68,4 @@ const compiled_text_template = await this.compile_template(template_name, "txt", template_content, context);

toAddresses: Array.isArray(toAddresses) ? toAddresses : [toAddresses],
ccAddresses: ccAddresses !== null && ccAddresses !== void 0 ? ccAddresses : null,
bccAddresses: bccAddresses !== null && bccAddresses !== void 0 ? bccAddresses : null,
ccAddresses: ccAddresses ?? null,
bccAddresses: bccAddresses ?? null,
},

@@ -59,13 +82,13 @@ replyToAddress: this.opts.reply_to_address,

if (content) {
const template = Handlebars.compile(content);
const template = handlebars_1.default.compile(content);
this.compiled_templates[template_name] = template;
}
else {
let files = this.opts.template_directory
? glob.sync(join(this.opts.template_directory, "**/*.{hbs,html,txt}"), { ignore: ["**/*.css"] })
const files = this.opts.template_directory
? glob_1.default.sync((0, path_1.join)(this.opts.template_directory, "**/*.{hbs,html,txt}"), { ignore: ["**/*.css"] })
: [];
const templateFile = files.find((filename) => filename.indexOf(template_name) >= 0);
if (templateFile) {
const template = readFileSync(templateFile, "utf-8");
this.compiled_templates[template_name] = Handlebars.compile(template);
const template = (0, fs_1.readFileSync)(templateFile, "utf-8");
this.compiled_templates[template_name] = handlebars_1.default.compile(template);
}

@@ -81,14 +104,15 @@ else {

async compile_html_template(name, content, context = {}) {
return new Promise(async (resolve, reject) => {
const template = await this.compile_template(name, "html", content);
if (!template) {
return reject(`Template could not be created`);
}
juice.juiceResources(template, {
// return new Promise(async (resolve, reject) => {
const template = await this.compile_template(name, "html", content, context);
if (!template) {
throw new Error(`Template could not be created`);
}
return new Promise((resolve, reject) => {
juice_1.default.juiceResources(template, {
webResources: {
relativeTo: this.opts.template_directory,
relativeTo: this.opts.template_directory ?? process.cwd(),
},
}, (err, html) => {
if (err) {
return reject(err);
reject(err);
}

@@ -100,1 +124,3 @@ resolve(html);

}
exports.EmailEmail = EmailEmail;
//# sourceMappingURL=emailemail.js.map

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

export * from "./emailemail";
export * from "./types";
export { EmailEmail } from "./emailemail";
export type { EmailEmailAWSOpts, EmailEmailAWSProvider } from "./providers/aws";
export type { Provider } from "./providers/provider";
export type { EmailInstance, EmailOpts } from "./types";

@@ -1,3 +0,6 @@

require("env2")(".env");
export * from "./emailemail";
export * from "./types";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmailEmail = void 0;
var emailemail_1 = require("./emailemail");
Object.defineProperty(exports, "EmailEmail", { enumerable: true, get: function () { return emailemail_1.EmailEmail; } });
//# sourceMappingURL=index.js.map
import AWS from "aws-sdk";
import { EmailOpts, ProviderOpts } from "../types";
import { EmailOpts } from "../types";
import { Provider } from "./provider";
export declare type EmailEmailAWSOpts = ProviderOpts & {
export declare type EmailEmailAWSOpts = {
region?: string;

@@ -6,0 +6,0 @@ profile?: string;

@@ -1,19 +0,28 @@

import AWS from "aws-sdk";
import { defaultCharset } from "../types";
const debug = require("debug")(`emailemail:provider:aws`);
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmailEmailAWSProvider = void 0;
const aws_sdk_1 = __importDefault(require("aws-sdk"));
const debug_1 = require("debug");
const types_1 = require("../types");
const debug = (0, debug_1.debug)(`emailemail:provider:aws`);
const defaults = {
region: "us-east-1",
};
export class EmailEmailAWSProvider {
class EmailEmailAWSProvider {
opts;
region;
ses;
constructor(opts = {}) {
var _a;
this.opts = opts = { ...defaults, ...opts };
this.region = (_a = this.opts.region) !== null && _a !== void 0 ? _a : defaults.region;
this.ses = new AWS.SES();
AWS.config.region = this.region;
this.region = this.opts.region ?? defaults.region ?? "us-east-1";
this.ses = new aws_sdk_1.default.SES();
aws_sdk_1.default.config.region = this.region;
if (opts.profile) {
const credentials = new AWS.SharedIniFileCredentials({
const credentials = new aws_sdk_1.default.SharedIniFileCredentials({
profile: opts.profile,
});
AWS.config.credentials = credentials;
aws_sdk_1.default.config.credentials = credentials;
}

@@ -23,3 +32,2 @@ }

return new Promise((resolve, reject) => {
var _a, _b, _c, _d, _e;
const Message = {

@@ -29,7 +37,7 @@ Body: {

Data: opts.compiled_html_template,
Charset: (_a = opts.htmlCharset) !== null && _a !== void 0 ? _a : defaultCharset,
Charset: opts.htmlCharset ?? types_1.defaultCharset,
},
Text: {
Data: opts.compiled_text_template,
Charset: (_b = opts.textCharset) !== null && _b !== void 0 ? _b : defaultCharset,
Charset: opts.textCharset ?? types_1.defaultCharset,
},

@@ -39,3 +47,3 @@ },

Data: opts.subject,
Charset: (_c = opts.subjectCharset) !== null && _c !== void 0 ? _c : defaultCharset,
Charset: opts.subjectCharset ?? types_1.defaultCharset,
},

@@ -45,4 +53,4 @@ };

ToAddresses: opts.destination.toAddresses,
CcAddresses: (_d = opts.destination.ccAddresses) !== null && _d !== void 0 ? _d : [],
BccAddresses: (_e = opts.destination.bccAddresses) !== null && _e !== void 0 ? _e : [],
CcAddresses: opts.destination.ccAddresses ?? [],
BccAddresses: opts.destination.bccAddresses ?? [],
};

@@ -74,1 +82,3 @@ const params = {

}
exports.EmailEmailAWSProvider = EmailEmailAWSProvider;
//# sourceMappingURL=aws.js.map

@@ -1,1 +0,3 @@

export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=provider.js.map

@@ -8,3 +8,2 @@ export declare type EmailInstance = {

};
export declare type ProviderOpts = {};
export declare type DestinationOpts = {

@@ -11,0 +10,0 @@ toAddresses: string[];

@@ -1,1 +0,5 @@

export const defaultCharset = "utf-8";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultCharset = void 0;
exports.defaultCharset = "utf-8";
//# sourceMappingURL=types.js.map
{
"name": "emailemail",
"version": "1.0.8",
"version": "1.0.9",
"description": "",

@@ -8,8 +8,7 @@ "main": "lib/index.js",

"files": [
"/lib",
"/templates"
"/lib"
],
"scripts": {
"lint": "eslint \"src/**/*.ts\"",
"build": "tsc -p ./tsconfig.json",
"postbuild": "cp -r ./templates ./lib",
"postpublish": "git push && git push --tags",

@@ -35,3 +34,6 @@ "prepublishOnly": "npm test",

"@types/node": "^18.11.2",
"@typescript-eslint/eslint-plugin": "^5.40.1",
"@typescript-eslint/parser": "^5.40.1",
"decache": "^4.6.1",
"eslint": "^8.25.0",
"goodparts": "^1.3.0",

@@ -42,4 +44,5 @@ "nyc": "^15.1.0",

"ts-jest": "^29.0.3",
"ts-node": "^10.9.1"
"ts-node": "^10.9.1",
"typescript": "^4.8.4"
}
}
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