Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
sailthru-client-8
Advanced tools
For installation instructions, documentation, and examples please visit: http://getstarted.sailthru.com/new-for-developers-overview/api-client-library/node-js-npm
A simple client library to remotely access the Sailthru REST API
as per http://getstarted.sailthru.com/new-for-developers-overview/api/api-overview/
By default, it will make request in JSON
format. XML
format is not supported.
npm install sailthru-client --save
var apiKey = '******',
apiSecret = '*****',
sailthru = require('sailthru-client').createSailthruClient(apiKey, apiSecret);
var version = require('sailthru-client').VERSION;
sailthru.enableLogging();
sailthru.disableLogging();
var data = {
email: 'foo@example.com',
lists: {
'list-a': 1
}
};
sailthru.apiPost('email', data, function(err, response) {
if (!err) {
console.log(response);
} else {
console.log('Error!');
console.log(err);
}
});
// Making import /job API POST call
// MUltipart call
var data = {
job: 'import',
list: 'test-list',
file: './emails.txt'
};
var multipart_params = ['file']; // this is required to mark file as a multipart upload item'
sailthru.apiPost('job', data, multipart_params, function(err, response) {
console.log(response);
});
// Making /send API GET call
var send_id = 'TE8EZ3-LmosnAgAA';
sailthru.apiGet('send', {send_id: send_id}, function(err, response) {
console.log(response);
});
// /send API DELETE call
var send_id = 'TE8EZ3-LmosnAgAA';
sailthru.apiDelete('send', {send_id: send_id}, function(err, response) {
console.log(response);
});
//send
var template = 'my-template',
email = 'foo@example.com',
options = {
'vars': {
'name': 'Foo Bar',
'address': 'Queens, NY'
},
'options': {
'test': 1,
'replyto': 'bar@example.com'
}
};
sailthru.send(template, email, options, function(err, response) {
if (err) {
console.log("Status Code: " + err.statusCode);
console.log("Error Code: " + err.error);
console.log("Error Message: " + err.errormsg);
} else {
//process output
}
});
//multi-send
var emails = ['blah@example.com', 'foo@example.com', 'bar@example.com'],
template = 'multi-template',
options = {
'options': {
'test': 1
}
};
sailthru.multiSend(template, emails, options, function(err, response) {
if (err) {
//Process error
} else {
//process JSON output
}
});
The library allows inspection of the 'X-Rate-Limit-*' headers returned by the Sailthru API. The getLastRateLimitInfo(action, method)
function allows you to retrieve the last known rate limit information for the given action / method combination. It must follow an API call. For example, if you do a /send POST
, you can follow up with a call to getLastRateLimitInfo('send', 'POST')
as shown below:
// make API call as normal
sailthru.apiPost('send', {'template': 'my template', 'email': 'foo@example.com'}, function(err, response) {
if (!err) {
console.log(response);
} else {
console.log('Error!');
console.log(err);
}
});
// check rate limit information
var rateLimitInfo = sailthru.getLastRateLimitInfo('send', 'POST');
The return type will be undefined
if there is no rate limit information for the given action / method combination (e.g. if you have not yet made a request to that endpoint). Otherwise, it will be an object in the following format:
{
limit: 1234, // <Number representing the limit of requests/minute for this action / method combination>
remaining: 1230, // <Number representing how many requests remain in the current minute>
reset: 1459381680 // <Number representing the UNIX epoch timestamp of when the next minute starts, and when the rate limit resets>
}
npm install -g grunt-cli
npm install # to install dependencies locally
grunt # for running tests
FAQs
Node.js client for Sailthru API
The npm package sailthru-client-8 receives a total of 0 weekly downloads. As such, sailthru-client-8 popularity was classified as not popular.
We found that sailthru-client-8 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.