Socket
Socket
Sign inDemoInstall

@sendgrid/helpers

Package Overview
Dependencies
Maintainers
4
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sendgrid/helpers - npm Package Compare versions

Comparing version 7.2.0 to 7.2.3

helpers/validate-settings.js

48

classes/mail.js

@@ -13,2 +13,3 @@ 'use strict';

const { DYNAMIC_TEMPLATE_CHAR_WARNING } = require('../constants');
const {validateMailSettings, validateTrackingSettings} = require('../helpers/validate-settings');

@@ -124,2 +125,5 @@ /**

}
if (typeof from !== 'string' && typeof from.email !== 'string') {
throw new Error('String or address object expected for `from`');
}
this.from = EmailAddress.create(from);

@@ -135,2 +139,5 @@ }

}
if (typeof replyTo !== 'string' && typeof replyTo.email !== 'string') {
throw new Error('String or address object expected for `replyTo`');
}
this.replyTo = EmailAddress.create(replyTo);

@@ -219,2 +226,9 @@ }

}
if (typeof asm.groupId !== 'number') {
throw new Error('Expected `asm` to include an integer in its `groupId` field');
}
if (asm.groupsToDisplay &&
(!Array.isArray(asm.groupsToDisplay) || !asm.groupsToDisplay.every(group => typeof group === 'number'))) {
throw new Error('Array of integers expected for `asm.groupsToDisplay`');
}
this.asm = asm;

@@ -230,4 +244,5 @@ }

}
if (!Array.isArray(personalizations)) {
throw new Error('Array expected for `personalizations`');
if (!Array.isArray(personalizations) ||
!personalizations.every(personalization => typeof personalization === 'object')) {
throw new Error('Array of objects expected for `personalizations`');
}

@@ -364,2 +379,11 @@

}
if (!content.every(contentField => typeof contentField === 'object')) {
throw new Error('Expected each entry in `content` to be an object');
}
if (!content.every(contentField => typeof contentField.type === 'string')) {
throw new Error('Expected each `content` entry to contain a `type` string');
}
if (!content.every(contentField => typeof contentField.value === 'string')) {
throw new Error('Expected each `content` entry to contain a `value` string');
}
this.content = content;

@@ -420,2 +444,14 @@ }

}
if (!attachments.every(attachment => typeof attachment.content === 'string')) {
throw new Error('Expected each attachment to contain a `content` string');
}
if (!attachments.every(attachment => typeof attachment.filename === 'string')) {
throw new Error('Expected each attachment to contain a `filename` string');
}
if (!attachments.every(attachment => attachment.type && typeof attachment.type === 'string')) {
throw new Error('Expected the attachment\'s `type` field to be a string');
}
if (!attachments.every(attachment => attachment.disposition && typeof attachment.disposition === 'string')) {
throw new Error('Expected the attachment\'s `disposition` field to be a string');
}
this.attachments = attachments;

@@ -520,5 +556,3 @@ }

}
if (typeof settings !== 'object') {
throw new Error('Object expected for `trackingSettings`');
}
validateTrackingSettings(settings);
this.trackingSettings = settings;

@@ -534,5 +568,3 @@ }

}
if (typeof settings !== 'object') {
throw new Error('Object expected for `mailSettings`');
}
validateMailSettings(settings);
this.mailSettings = settings;

@@ -539,0 +571,0 @@ }

4

package.json
{
"name": "@sendgrid/helpers",
"description": "Twilio SendGrid NodeJS internal helpers",
"version": "7.2.0",
"version": "7.2.3",
"author": "Twilio SendGrid <help@twilio.com> (sendgrid.com)",

@@ -36,3 +36,3 @@ "contributors": [

},
"gitHead": "31e48a85d5f03a63ae4616ed8c31708aa6761311"
"gitHead": "b5eb9f3a10af2a9291c54a34d55a1e54409819e8"
}
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