Socket
Socket
Sign inDemoInstall

notifications-node-client

Package Overview
Dependencies
Maintainers
3
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

notifications-node-client - npm Package Compare versions

Comparing version 3.1.0 to 3.2.0

14

client/api_client.js

@@ -16,2 +16,4 @@ var restClient = require('request-promise'),

this.proxy = null;
if (arguments.length === 1) {

@@ -78,2 +80,4 @@ this.urlBase = notifyProductionAPI;

if(this.proxy !== null) options.proxy = this.proxy;
return restClient(options);

@@ -101,4 +105,14 @@ },

};
if(this.proxy !== null) options.proxy = this.proxy;
return restClient(options);
},
/**
*
* @param {String} url
*/
setProxy: function(url){
this.proxy = url;
}

@@ -105,0 +119,0 @@ });

2

client/authentication.js

@@ -14,3 +14,3 @@ var jwt = require('jsonwebtoken');

{
headers: {typ: "JWT", alg: "HS256"}
header: {typ: "JWT", alg: "HS256"}
}

@@ -17,0 +17,0 @@ );

@@ -215,5 +215,11 @@ var ApiClient = require('./api_client'),

return this.apiClient.post('/v2/template/' + templateId + '/preview', payload);
},
/**
*
* @param {String} url
*/
setProxy: function(url) {
this.apiClient.setProxy(url);
}
});

@@ -220,0 +226,0 @@

{
"name": "notifications-node-client",
"version": "3.1.0",
"version": "3.2.0",
"description": "GOV.UK Notify Node.js client ",

@@ -14,6 +14,5 @@ "main": "index.js",

"crypto": "0.0.3",
"jsonwebtoken": "5.5.4",
"jsonwebtoken": "7.4.1",
"request": "^2.73.0",
"request-promise": "^4.0.1",
"restler": "3.4.0",
"underscore": "^1.8.3"

@@ -20,0 +19,0 @@ },

@@ -7,3 +7,3 @@ [![Dependency Status](https://david-dm.org/alphagov/notifications-node-client.svg)](https://david-dm.org/alphagov/notifications-node-client)

```shell
npm install notifications-node-client
npm install --save notifications-node-client
```

@@ -21,2 +21,7 @@

### Connect through a proxy (optional)
```
notifyClient.setProxy(proxyUrl);
```
## Send messages

@@ -29,4 +34,4 @@

.sendSms(templateId, phoneNumber, personalisation, reference)
.then((response) => { })
.catch((err) => {})
.then(response => console.log(response))
.catch(err => console.error(err))
;

@@ -129,5 +134,5 @@ ```

notifyClient
.sendEmail(templateId, emailAddress, personalisation, reference);
.then((response) => { })
.catch((err) => {})
.sendEmail(templateId, emailAddress, personalisation, reference)
.then(response => console.log(response))
.catch(err => console.error(err))
;

@@ -134,0 +139,0 @@ ```

@@ -74,2 +74,39 @@ var expect = require('chai').expect,

it('should direct get requests through the proxy when set', function (done) {
var urlBase = 'https://api.notifications.service.gov.uk',
proxyUrl = 'http://proxy.service.gov.uk:3030/',
path = '/email',
apiClient = new ApiClient(urlBase, 'apiKey');
nock(urlBase)
.get(path)
.reply(200, 'test');
apiClient.setProxy(proxyUrl);
apiClient.get(path)
.then(function (response) {
expect(response.statusCode).to.equal(200);
expect(response.request.proxy.href).to.equal(proxyUrl);
done();
});
});
it('should direct post requests through the proxy when set', function (done) {
var urlBase = 'https://api.notifications.service.gov.uk',
proxyUrl = 'http://proxy.service.gov.uk:3030/',
path = '/email',
apiClient = new ApiClient(urlBase, 'apiKey');
nock(urlBase)
.post(path)
.reply(200, 'test');
apiClient.setProxy(proxyUrl);
apiClient.post(path)
.then(function (response) {
expect(response.statusCode).to.equal(200);
expect(response.request.proxy.href).to.equal(proxyUrl);
done();
});
});
});

@@ -24,3 +24,3 @@ var expect = require('chai').expect,

expect(token).to.equal('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOjEyMywiaWF0IjoxMjM0NTY3ODkwfQ.R9-H_oV7d56Dal9jUAKThrZlo1_LNVqc3LCtY62WQd4');
expect(token).to.equal('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOjEyMywiaWF0IjoxMjM0NTY3ODkwfQ.18aBKSLffjbX_TLmosB_qYgW9EkWIQpBgWy7GpiKg6o');
expect(decoded.iss).to.equal(123);

@@ -27,0 +27,0 @@ expect(decoded.iat).to.equal(1234567890);

@@ -25,3 +25,7 @@ {

"sent_at": {"type": ["string", "null"]},
"completed_at": {"type": ["string", "null"]}
"completed_at": {"type": ["string", "null"]},
"scheduled_for": {"oneOf":[
{"$ref": "definitions.json#/datetime"},
{"type": "null"}
]}
},

@@ -28,0 +32,0 @@ "required": [

@@ -10,3 +10,7 @@ {

"uri": {"type": "string"},
"template": {"$ref": "definitions.json#/template"}
"template": {"$ref": "definitions.json#/template"},
"scheduled_for": {"oneOf":[
{"$ref": "definitions.json#/datetime"},
{"type": "null"}
]}
},

@@ -13,0 +17,0 @@ "additionalProperties": false,

@@ -10,3 +10,7 @@ {

"uri": {"type": "string"},
"template": {"$ref": "definitions.json#/template"}
"template": {"$ref": "definitions.json#/template"},
"scheduled_for": {"oneOf":[
{"$ref": "definitions.json#/datetime"},
{"type": "null"}
]}
},

@@ -13,0 +17,0 @@ "additionalProperties": false,

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