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

sparkpost

Package Overview
Dependencies
Maintainers
4
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sparkpost - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

10

CHANGELOG.md

@@ -7,2 +7,7 @@ # Change Log

## [2.0.1] - 2016-11-10
### Added
- Node.js version is now tracked using the User-Agent header by @ewandennis.
- An optional "stack identifier" that can be set during [initialization](README.md#initialization) so we can track libraries that use node-sparkpost via the User-Agent header by @ewandennis.
## [2.0.0] - 2016-11-04 - *breaking*

@@ -139,4 +144,5 @@ - [#188](https://github.com/SparkPost/node-sparkpost/pull/188) Added setting debug in initialization (@aydrian)

[unreleased]: https://github.com/sparkpost/node-sparkpost/compare/2.0.0...HEAD
[2.0.0]: https://github.com/sparkpost/node-sparkpost/compare/1.3.8...2.0.0
[unreleased]: https://github.com/sparkpost/node-sparkpost/compare/v2.0.1...HEAD
[2.0.1]: https://github.com/sparkpost/node-sparkpost/compare/v2.0.0...v2.0.1
[2.0.0]: https://github.com/sparkpost/node-sparkpost/compare/1.3.8...v2.0.0
[1.3.8]: https://github.com/sparkpost/node-sparkpost/compare/1.3.7...1.3.8

@@ -143,0 +149,0 @@ [1.3.7]: https://github.com/sparkpost/node-sparkpost/compare/1.3.6...1.3.7

12

lib/sparkpost.js

@@ -8,3 +8,3 @@ 'use strict';

, _ = require('lodash')
, defaults, resolveUri, handleOptions, createSparkPostError, SparkPost;
, defaults, resolveUri, handleOptions, createSparkPostError, createVersionStr, SparkPost;

@@ -49,2 +49,10 @@ //REST API Config Defaults

createVersionStr = function(version, options) {
let versionStr = 'node-sparkpost/' + version + ' node.js/' + process.version;
if (options.stackIdentity) {
versionStr += options.stackIdentity + ' ' + versionStr;
}
return versionStr;
};
SparkPost = function(apiKey, options) {

@@ -65,3 +73,3 @@

this.defaultHeaders = _.merge({
'User-Agent': 'node-sparkpost/' + this.version
'User-Agent': createVersionStr(version, options)
, 'Content-Type': 'application/json'

@@ -68,0 +76,0 @@ }, options.headers);

{
"name": "sparkpost",
"version": "2.0.0",
"version": "2.0.1",
"description": "A Node.js wrapper for interfacing with your favorite SparkPost APIs",

@@ -5,0 +5,0 @@ "main": "./lib/sparkpost.js",

@@ -41,2 +41,6 @@ <a href="https://www.sparkpost.com"><img src="https://www.sparkpost.com/sites/default/files/attachments/SparkPost_Logo_2-Color_Gray-Orange_RGB.svg" width="200px"/></a>

* Default: `v1`
* `options.stackIdentity`
* Required: no
* Type: `String`
* An optional identifier to include in the User-Agent header. e.g. `product/1.0.0`
* `options.headers`

@@ -43,0 +47,0 @@ * Required: no

@@ -8,6 +8,8 @@ 'use strict';

, nock = require('nock')
, SparkPost = require('../../lib/sparkpost');
, SparkPost = require('../../lib/sparkpost')
, libVersion = require('../../package.json').version;
chai.use(require('sinon-chai'));
describe('SparkPost Library', function() {

@@ -85,2 +87,44 @@

function checkUserAgent(clientOptions, checkFn, done) {
let req = {
method: 'GET'
, uri: 'get/test'
, json: true
, debug: true
}
, client;
nock('https://api.sparkpost.com')
.get('/api/v1/get/test')
.reply(200, function() {
expect(this.req.headers).to.have.property('user-agent');
checkFn(this.req.headers['user-agent']);
return { ok: true };
});
client = new SparkPost('123456789', clientOptions);
client.request(req, done);
}
it('should allow users to self identify in user-agent', function(done) {
let options = {
stackIdentity: 'phantasmatron/1.1.3.8'
}
checkUserAgent(options, function(userAgent) {
expect(userAgent).to.include(options.stackIdentity);
}, done);
});
it('should include lib version in user-agent', function(done) {
checkUserAgent({}, function(userAgent) {
expect(userAgent).to.include('node-sparkpost/' + libVersion);
}, done);
});
it('should include Node.JS version in user-agent', function(done) {
checkUserAgent({}, function(userAgent) {
expect(userAgent).to.include('node.js/' + process.version);
}, done);
});
describe('request method', function() {

@@ -87,0 +131,0 @@ var client;

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