notifications-node-client 5.2.0 → 5.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +2 -2
- package/client/notification.js +3 -0
- package/package.json +1 -1
- package/spec/notification.js +18 -0
- package/spec/test_files/simple.csv +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 5.2.2 - 2022-11-16
|
|
2
|
+
|
|
3
|
+
* Upgrade ansi-regex dependencies to mitigate CVE-2021-3807.
|
|
4
|
+
|
|
5
|
+
## 5.2.1 - 2022-10-19
|
|
6
|
+
|
|
7
|
+
* Support strings in calls to `prepareUpload`. `fs.readFile` can return strings if an encoding is provided, and the client didn't handle these correctly.
|
|
8
|
+
|
|
1
9
|
## 5.2.0 - 2022-09-27
|
|
2
10
|
|
|
3
11
|
* Add support for new security features when sending a file by email:
|
package/README.md
CHANGED
|
@@ -6,5 +6,5 @@ Useful links:
|
|
|
6
6
|
|
|
7
7
|
- [Documentation](https://docs.notifications.service.gov.uk/node.html)
|
|
8
8
|
- [NPM package](https://www.npmjs.com/package/notifications-node-client)
|
|
9
|
-
- [Changelog](https://github.com/alphagov/notifications-node-client/blob/
|
|
10
|
-
- [Contributing to this client](https://github.com/alphagov/notifications-node-client/blob/
|
|
9
|
+
- [Changelog](https://github.com/alphagov/notifications-node-client/blob/main/CHANGELOG.md)
|
|
10
|
+
- [Contributing to this client](https://github.com/alphagov/notifications-node-client/blob/main/CONTRIBUTING.md)
|
package/client/notification.js
CHANGED
|
@@ -115,6 +115,9 @@ function _check_and_encode_file(file, size_limit) {
|
|
|
115
115
|
if (file.length > size_limit * 1024 * 1024) {
|
|
116
116
|
throw "File is larger than " + String(size_limit) + "MB.";
|
|
117
117
|
}
|
|
118
|
+
if (typeof(file) === 'string') {
|
|
119
|
+
file = Buffer.from(file);
|
|
120
|
+
}
|
|
118
121
|
return file.toString('base64')
|
|
119
122
|
}
|
|
120
123
|
|
package/package.json
CHANGED
package/spec/notification.js
CHANGED
|
@@ -188,6 +188,24 @@ describe('notification api', () => {
|
|
|
188
188
|
notifyClient.prepareUpload(file);
|
|
189
189
|
}).to.throw("File is larger than 2MB.")
|
|
190
190
|
});
|
|
191
|
+
it('should accept files as buffers (from fs.readFile with no encoding)', () => {
|
|
192
|
+
let fs = require('fs');
|
|
193
|
+
let file = fs.readFileSync('./spec/test_files/simple.csv');
|
|
194
|
+
expect(typeof(file)).to.equal('object')
|
|
195
|
+
expect(Buffer.isBuffer(file)).to.equal(true);
|
|
196
|
+
expect(
|
|
197
|
+
notifyClient.prepareUpload(file, true)
|
|
198
|
+
).contains({file: 'MSwyLDMKYSxiLGMK', is_csv: true})
|
|
199
|
+
});
|
|
200
|
+
it('should accept files as strings (from fs.readFile with an encoding)', () => {
|
|
201
|
+
let fs = require('fs');
|
|
202
|
+
let file = fs.readFileSync('./spec/test_files/simple.csv', 'binary');
|
|
203
|
+
expect(typeof(file)).to.equal('string')
|
|
204
|
+
expect(Buffer.isBuffer(file)).to.equal(false);
|
|
205
|
+
expect(
|
|
206
|
+
notifyClient.prepareUpload(file, true)
|
|
207
|
+
).contains({file: 'MSwyLDMKYSxiLGMK', is_csv: true})
|
|
208
|
+
});
|
|
191
209
|
|
|
192
210
|
it('should allow isCsv to be set with the old method (directly into options)', () => {
|
|
193
211
|
let file = Buffer.alloc(2*1024*1024)
|