
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Sign up for a SparkPost account and visit our Developer Hub for even more content.
The official Node.js binding for your favorite SparkPost APIs!
Before using this library, you must have:
npm install sparkpost
new SparkPost(apiKey, options) - Initialization
apiKey
SPARKPOST_API_KEY
environment variable)String
options.origin
or options.endpoint
String
https://api.sparkpost.com:443
options.apiVersion
String
v1
options.headers
Object
options
- see request modules optionsoptions.uri
- can either be a full url or a path that is appended to options.origin
used at initialization (url.resolve)callback
- executed after task is completed. required
callback(err, data)
err
- any error that occurreddata.res
- full response from request clientdata.body
- payload from responseoptions
- see request optionscallback
- see request optionsPassing in an API key
var SparkPost = require('sparkpost');
var client = new SparkPost('YOUR_API_KEY');
Using an API key stored in an environment variable
//Create an env var as SPARKPOST_API_KEY
var SparkPost = require('sparkpost');
var client = new SparkPost();
Specifying non-default options
var SparkPost = require('sparkpost');
var options = {
endpoint: 'https://dev.sparkpost.com:443'
};
var client = new SparkPost('YOUR_API_KEY', options);
We may not wrap every resource available in the SparkPost Client Library, for example the Node Client Library does not wrap the Metrics resource, but you can use the Node Client Library Base Object to form requests to these unwrapped resources. Here is an example request using the base object to make requests to the Metrics resource. Here is an example request using the base object to make requests to the Metrics resource.
// Get a list of domains that the Metrics API contains data on.
var options = {
uri: 'metrics/domains'
};
client.get(options, function(err, data) {
if(err) {
console.log(err);
return;
}
console.log(data.body);
});
Below is an example of how to send a simple email. Sending an email is known as a transmission. By using the send method on the transmissions service that's available from the SparkPost object you instatiate you can pass in a transmissionBody object with all the information relevant to the email being sent. The send method also takes a callback method that will let you know if the email was sent successful and if not information about the error that ocurred.
var SparkPost = require('sparkpost');
var sp = new SparkPost('<YOUR API KEY>');
sp.transmissions.send({
transmissionBody: {
content: {
from: 'testing@sparkpostbox.com',
subject: 'Hello, World!',
html:'<html><body><p>Testing SparkPost - the world\'s most awesomest email service!</p></body></html>'
},
recipients: [
{address: '<YOUR EMAIL ADDRESS>'}
]
}
}, function(err, res) {
if (err) {
console.log('Whoops! Something went wrong');
console.log(err);
} else {
console.log('Woohoo! You just sent your first mailing!');
}
});
Click on the desired API to see usage and more information
client.inboundDomains
(examples)client.messageEvents
(examples)client.recipientLists
(examples)client.relayWebhooks
(examples)client.sendingDomains
(examples)client.subaccounts
(examples)client.suppressionList
(examples)client.templates
(examples)client.transmissions
(examples)client.webhooks
(examples)We use Grunt for our task runner, so you will also have to install Grunt globally npm install -g grunt-cli
Run npm install
inside the repository to install all the dev dependencies.
Once all the dependencies are installed, you can execute the unit tests using grunt test
FAQs
A Node.js wrapper for interfacing with your favorite SparkPost APIs
We found that sparkpost demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.