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

@composer-js/core

Package Overview
Dependencies
Maintainers
0
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@composer-js/core - npm Package Compare versions

Comparing version 6.0.0-rc.20 to 6.0.0-rc.23

18

dist/lib/ApiError.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApiError = void 0;
const StringUtils_1 = require("./StringUtils");
/**

@@ -10,6 +11,21 @@ * Describes an error that originates from a API service. This class extends the standard `Error` class to include

class ApiError extends Error {
constructor(code, status, message) {
ApiMessageTemplate(message, templateVariables) {
if (!message) {
return "";
}
if (message && templateVariables) {
return StringUtils_1.StringUtils.findAndReplace(message, templateVariables);
}
return message;
}
constructor(code, status, message, templateVariables) {
super(message);
this.code = code;
this.status = status;
try {
this.message = this.ApiMessageTemplate(message, templateVariables);
}
catch (error) {
// NO-OP
}
Object.setPrototypeOf(this, ApiError.prototype);

@@ -16,0 +32,0 @@ }

72

dist/lib/MessagingUtils.js

@@ -30,35 +30,53 @@ "use strict";

if (this.slackConfigs.length > 0) {
const { App } = await Promise.resolve().then(() => require("@slack/bolt"));
if (!App) {
throw new Error("Failed to import @slack/bolt. Did you add it to your project?");
}
for (const slackConfig of this.slackConfigs) {
if (!slackConfig.token || !slackConfig.signingSecret) {
throw new Error("Slack token or signingSecret is not set.");
try {
const { App } = await Promise.resolve().then(() => require("@slack/bolt"));
if (!App) {
throw new Error("Failed to import @slack/bolt. Did you add it to your project?");
}
const app = new App({
token: slackConfig.token,
signingSecret: slackConfig.signingSecret,
});
this.slackApps?.push(app);
for (const slackConfig of this.slackConfigs) {
if (!slackConfig.token || !slackConfig.signingSecret) {
throw new Error("Slack token or signingSecret is not set.");
}
const app = new App({
token: slackConfig.token,
signingSecret: slackConfig.signingSecret,
});
this.slackApps.push(app);
}
}
catch (error) {
this.logger?.error("Unable to setup slack notifications");
this.logger?.debug(error);
}
}
if (this.smtpConfig) {
const nodemailer = await Promise.resolve().then(() => require("nodemailer"));
if (!nodemailer) {
throw new Error("Failed to import nodemailer. Did you add it to your project?");
try {
const nodemailer = await Promise.resolve().then(() => require("nodemailer"));
if (!nodemailer) {
throw new Error("Failed to import nodemailer. Did you add it to your project?");
}
if (!this.smtpConfig.host) {
throw new Error("No host specified in SMTP configuration.");
}
}
if (!this.smtpConfig.host) {
throw new Error("No host specified in SMTP configuration.");
catch (error) {
this.logger?.error("Unable to setup email notifications");
this.logger?.debug(error);
}
}
if (this.twilioConfig) {
if (!this.twilioConfig.accountSid || !this.twilioConfig.token) {
throw new Error("Twilio accountSid or token is not set.");
try {
if (!this.twilioConfig.accountSid || !this.twilioConfig.token) {
throw new Error("Twilio accountSid or token is not set.");
}
const twilio = await Promise.resolve().then(() => require("twilio"));
if (!twilio) {
throw new Error("Failed to import twilio. Did you add it to your project?");
}
this.twilio = twilio(this.twilioConfig.accountSid, this.twilioConfig.token, this.twilioConfig.options);
}
const twilio = await Promise.resolve().then(() => require("twilio"));
if (!twilio) {
throw new Error("Failed to import twilio. Did you add it to your project?");
catch (error) {
this.logger?.error("Unable to setup twilio notifications");
this.logger?.debug(error);
}
this.twilio = twilio(this.twilioConfig.accountSid, this.twilioConfig.token, this.twilioConfig.options);
}

@@ -101,2 +119,6 @@ }

const transporter = nodemailer.createTransport(this.smtpConfig);
if (!this.templates?.from?.email) {
this.logger?.warn("Unable to send email missing from.email in message template");
return undefined;
}
const result = await transporter.sendMail({

@@ -192,2 +214,6 @@ from: this.templates.from.email,

__decorate([
ObjectDecorators_1.Logger,
__metadata("design:type", Object)
], MessagingUtils.prototype, "logger", void 0);
__decorate([
ObjectDecorators_1.Init,

@@ -194,0 +220,0 @@ __metadata("design:type", Function),

@@ -45,2 +45,11 @@ "use strict";

/**
* Validates that the provided array is not empty.
*/
static checkEmpty(val) {
if (val && val.length === 0) {
throw new Error("Value cannot be empty.");
}
return val;
}
/**
* Validates that the provided string is a valid IP address.

@@ -73,2 +82,11 @@ */

/**
* Validates that the provided object is not null or empty.
*/
static checkNull(val) {
if (typeof val !== "boolean" && !val) {
throw new Error("Value cannot be null.");
}
return val;
}
/**
* Validates that the provided string represents a valid phone number.

@@ -75,0 +93,0 @@ */

@@ -11,3 +11,4 @@ /**

status: number;
constructor(code: string, status: number, message?: string);
ApiMessageTemplate(message: string | undefined, templateVariables?: any): string;
constructor(code: string, status: number, message?: string, templateVariables?: any);
}

@@ -52,2 +52,3 @@ export interface OriginSettings {

private templates;
private logger?;
init(): Promise<void>;

@@ -54,0 +55,0 @@ /**

@@ -27,2 +27,6 @@ /**

/**
* Validates that the provided array is not empty.
*/
static checkEmpty(val: Array<any>): Array<any>;
/**
* Validates that the provided string is a valid IP address.

@@ -40,2 +44,6 @@ */

/**
* Validates that the provided object is not null or empty.
*/
static checkNull(val: any): any;
/**
* Validates that the provided string represents a valid phone number.

@@ -42,0 +50,0 @@ */

{
"name": "@composer-js/core",
"version": "6.0.0-rc.20",
"version": "6.0.0-rc.23",
"description": "A collection of common utilities and core functionality for composerjs applications.",

@@ -23,3 +23,3 @@ "repository": "https://gitlab.acceleratxr.com/composerjs/composer-core.git",

"dependencies": {
"form-data": "^4.0.0",
"form-data": "^4.0.1",
"handlebars": "^4.7.8",

@@ -32,3 +32,3 @@ "js-yaml": "^4.1.0",

"triple-beam": "^1.4.1",
"uuid": "^10.0.0",
"uuid": "^11.0.3",
"validator": "^13.12.0"

@@ -43,24 +43,24 @@ },

"devDependencies": {
"@slack/bolt": "^3.21.4",
"@slack/web-api": "^7.4.0",
"@slack/bolt": "^4.1.1",
"@slack/web-api": "^7.8.0",
"@types/eslint": "^9.6.1",
"@types/jest": "^29.5.13",
"@types/jest": "^29.5.14",
"@types/js-yaml": "^4.0.9",
"@types/jsonwebtoken": "^9.0.6",
"@types/node": "^20.16.5",
"@types/nodemailer": "^6.4.15",
"@types/jsonwebtoken": "^9.0.7",
"@types/node": "^22.10.2",
"@types/nodemailer": "^6.4.17",
"@types/triple-beam": "^1.3.5",
"@types/uuid": "^10.0.0",
"@types/validator": "^13",
"@typescript-eslint/eslint-plugin": "^8.5.0",
"@typescript-eslint/parser": "^8.5.0",
"axios": "^1.7.7",
"@typescript-eslint/eslint-plugin": "^8.18.0",
"@typescript-eslint/parser": "^8.18.0",
"axios": "^1.7.9",
"colors": "^1.4.0",
"commitizen": "^4.3.0",
"commitizen": "^4.3.1",
"coveralls": "^3.1.1",
"cross-env": "^7.0.3",
"eslint": "^9.10.0",
"eslint": "^9.16.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-jsdoc": "^50.2.3",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsdoc": "^50.6.1",
"jest": "^29.7.0",

@@ -70,5 +70,5 @@ "jest-config": "^29.7.0",

"nconf": "^0.12.1",
"nock": "^13.5.5",
"nodemailer": "^6.9.15",
"prettier": "^3.3.3",
"nock": "^13.5.6",
"nodemailer": "^6.9.16",
"prettier": "^3.4.2",
"reflect-metadata": "^0.2.2",

@@ -78,8 +78,8 @@ "rimraf": "^6.0.1",

"ts-node": "^10.9.2",
"twilio": "^5.3.0",
"typedoc": "^0.26.7",
"typedoc-plugin-markdown": "^4.2.7",
"typescript": "^5.6.2",
"winston": "^3.14.2",
"winston-transport": "^4.7.1"
"twilio": "^5.4.0",
"typedoc": "^0.27.4",
"typedoc-plugin-markdown": "^4.3.2",
"typescript": "^5.7.2",
"winston": "^3.17.0",
"winston-transport": "^4.9.0"
},

@@ -86,0 +86,0 @@ "resolutions": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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