notifications-node-client
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -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 @@ }); |
@@ -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, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
64161
5
1341
744
0
32
+ Addedhoek@2.16.3(transitive)
+ Addedisemail@1.2.0(transitive)
+ Addedjoi@6.10.1(transitive)
+ Addedjsonwebtoken@7.4.1(transitive)
+ Addedlodash.once@4.1.1(transitive)
+ Addedmoment@2.30.1(transitive)
+ Addedms@2.1.3(transitive)
+ Addedtopo@1.1.0(transitive)
- Removedrestler@3.4.0
- Removediconv-lite@0.2.11(transitive)
- Removedjsonwebtoken@5.5.4(transitive)
- Removedms@0.7.3(transitive)
- Removedqs@1.2.0(transitive)
- Removedrestler@3.4.0(transitive)
- Removedsax@0.5.8(transitive)
- Removedxml2js@0.4.0(transitive)
- Removedxmlbuilder@15.1.1(transitive)
- Removedyaml@0.2.3(transitive)
Updatedjsonwebtoken@7.4.1