notifications-node-client 6.0.0 → 7.0.1

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 CHANGED
@@ -1,3 +1,11 @@
1
+ ## 7.0.1 - 2023-07-13
2
+
3
+ * Fix a bug with default behaviour for `confirmEmailBeforeDownload`, which coalesced false to null.
4
+
5
+ ## 7.0.0 - 2023-01-12
6
+
7
+ * Remove support for node versions below v14.17.3.
8
+
1
9
  ## 6.0.0 - 2022-12-22
2
10
 
3
11
  * Bump jsonwebtokens from 8.5.1 to 9.0.0 to mitigate CVE-2022-23529. We don't believe this CVE affects any use-cases of notifications-node-client; this update is out of best-practice rather than any direct concern.
package/DOCUMENTATION.md CHANGED
@@ -291,15 +291,13 @@ To send a file by email, add a placeholder to the template then upload a file. T
291
291
 
292
292
  The links are unique and unguessable. GOV.UK Notify cannot access or decrypt your file.
293
293
 
294
- Your file will be available to download for a default period of 78 weeks (18 months). From 29 March 2023 we will reduce this to 26 weeks (6 months) for all new files. Files sent before 29 March will not be affected.
294
+ Your file will be available to download for a default period of 26 weeks (6 months).
295
295
 
296
296
  To help protect your files you can also:
297
297
 
298
298
  * ask recipients to confirm their email address before downloading
299
299
  * choose the length of time that a file is available to download
300
300
 
301
- To turn these features on or off, you will need version 5.2.0 of the Node.js client library or a more recent version.
302
-
303
301
  #### Add contact details to the file download page
304
302
 
305
303
  1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
@@ -344,7 +342,7 @@ The method returns a [promise](https://developer.mozilla.org/en-US/docs/Web/Java
344
342
 
345
343
  ##### CSV Files
346
344
 
347
- Uploads for CSV files should use the `isCsv` parameter on the `prepareUpload()` function. For example:
345
+ Uploads for CSV files should use the `isCsv` option on the `prepareUpload()` function. For example:
348
346
 
349
347
  ```javascript
350
348
  var fs = require('fs')
@@ -355,7 +353,7 @@ fs.readFile('path/to/document.csv', function (err, csvFile) {
355
353
  personalisation: {
356
354
  first_name: 'Amala',
357
355
  application_date: '2018-01-01',
358
- link_to_file: notifyClient.prepareUpload(csvFile, true)
356
+ link_to_file: notifyClient.prepareUpload(csvFile, { isCsv: true })
359
357
  }
360
358
  }).then(response => console.log(response)).catch(err => console.error(err))
361
359
  })
@@ -363,38 +361,13 @@ fs.readFile('path/to/document.csv', function (err, csvFile) {
363
361
 
364
362
  #### Ask recipients to confirm their email address before they can download the file
365
363
 
366
- This new security feature is optional. You should use it if you send files that are sensitive - for example, because they contain personal information about your users.
367
-
368
364
  When a recipient clicks the link in the email you’ve sent them, they have to enter their email address. Only someone who knows the recipient’s email address can download the file.
369
365
 
370
- From 29 March 2023, we will turn this feature on by default for every file you send. Files sent before 29 March will not be affected.
371
-
372
- ##### Turn on email address check
373
-
374
- To use this feature before 29 March 2023 you will need version 5.2.0 of the Node.js client library, or a more recent version.
375
-
376
- To make the recipient confirm their email address before downloading the file, set the `confirmEmailBeforeDownload` flag to `true`.
377
-
378
- You will not need to do this after 29 March.
379
-
380
- ```javascript
381
- var fs = require('fs')
382
-
383
- fs.readFile('path/to/document.pdf', function (err, pdfFile) {
384
- console.log(err)
385
- notifyClient.sendEmail(templateId, emailAddress, {
386
- personalisation: {
387
- first_name: 'Amala',
388
- application_date: '2018-01-01',
389
- link_to_file: notifyClient.prepareUpload(pdfFile, false, true, undefined)
390
- }
391
- }).then(response => console.log(response)).catch(err => console.error(err))
392
- })
393
- ```
366
+ This security feature is turned on by default.
394
367
 
395
368
  ##### Turn off email address check (not recommended)
396
369
 
397
- If you do not want to use this feature after 29 March 2023, you can turn it off on a file-by-file basis.
370
+ If you do not want to use this feature, you can turn it off on a file-by-file basis.
398
371
 
399
372
  To do this you will need version 5.2.0 of the Node.js client library, or a more recent version.
400
373
 
@@ -404,7 +377,7 @@ You should not turn this feature off if you send files that contain:
404
377
  * commercially sensitive information
405
378
  * information classified as ‘OFFICIAL’ or ‘OFFICIAL-SENSITIVE’ under the [Government Security Classifications](https://www.gov.uk/government/publications/government-security-classifications) policy
406
379
 
407
- To let the recipient download the file without confirming their email address, set the `confirmEmailBeforeDownload` flag to `false`.
380
+ To let the recipient download the file without confirming their email address, set the `confirmEmailBeforeDownload` option to `false`.
408
381
 
409
382
  ```javascript
410
383
  var fs = require('fs')
@@ -415,7 +388,7 @@ fs.readFile('path/to/document.pdf', function (err, pdfFile) {
415
388
  personalisation: {
416
389
  first_name: 'Amala',
417
390
  application_date: '2018-01-01',
418
- link_to_file: notifyClient.prepareUpload(pdfFile, false, false, undefined)
391
+ link_to_file: notifyClient.prepareUpload(pdfFile, { confirmEmailBeforeDownload: false })
419
392
  }
420
393
  }).then(response => console.log(response)).catch(err => console.error(err))
421
394
  })
@@ -423,13 +396,15 @@ fs.readFile('path/to/document.pdf', function (err, pdfFile) {
423
396
 
424
397
  #### Choose the length of time that a file is available to download
425
398
 
426
- Set the number of weeks you want the file to be available using the `retentionPeriod` parameter.
399
+ Set the number of weeks you want the file to be available using the `retentionPeriod` option.
427
400
 
428
401
  You can choose any value between 1 week and 78 weeks.
429
402
 
430
403
  To use this feature will need version 5.2.0 of the Node.js client library, or a more recent version.
431
404
 
432
- If you do not choose a value, the file will be available for the default period of 78 weeks (18 months).
405
+ If you do not choose a value, the file will be available for the default period of 26 weeks (6 months).
406
+
407
+ Files sent before 12 April 2023 had a longer default period of 78 weeks (18 months).
433
408
 
434
409
  ```javascript
435
410
  var fs = require('fs')
@@ -440,7 +415,7 @@ fs.readFile('path/to/document.pdf', function (err, pdfFile) {
440
415
  personalisation: {
441
416
  first_name: 'Amala',
442
417
  application_date: '2018-01-01',
443
- link_to_file: notifyClient.prepareUpload(pdfFile, false, undefined, '52 weeks')
418
+ link_to_file: notifyClient.prepareUpload(pdfFile, { retentionPeriod: '52 weeks' })
444
419
  }
445
420
  }).then(response => console.log(response)).catch(err => console.error(err))
446
421
  })
package/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM node:12.16.1-slim
1
+ FROM ghcr.io/alphagov/notify/node:18-slim
2
2
 
3
3
  ENV DEBIAN_FRONTEND=noninteractive
4
4
 
@@ -368,7 +368,7 @@ Object.assign(NotifyClient.prototype, {
368
368
  data.is_csv = options.isCsv;
369
369
  }
370
370
 
371
- data.confirm_email_before_download = options.confirmEmailBeforeDownload || null;
371
+ data.confirm_email_before_download = options.confirmEmailBeforeDownload !== undefined ? options.confirmEmailBeforeDownload : null;
372
372
  data.retention_period = options.retentionPeriod || null
373
373
  }
374
374
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notifications-node-client",
3
- "version": "6.0.0",
3
+ "version": "7.0.1",
4
4
  "homepage": "https://docs.notifications.service.gov.uk/node.html",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,8 +14,8 @@
14
14
  "integration": "mocha spec/integration/test.js"
15
15
  },
16
16
  "engines": {
17
- "npm": ">=6.12.0",
18
- "node": ">=12.13.0"
17
+ "npm": ">=6.14.13",
18
+ "node": ">=14.17.3"
19
19
  },
20
20
  "author": "GDS developers",
21
21
  "license": "MIT",
@@ -29,7 +29,7 @@
29
29
  "chai-json-schema": "1.5.0",
30
30
  "chai-bytes": "0.1.2",
31
31
  "jsonschema": "1.2.4",
32
- "mocha": "5.2.0",
32
+ "mocha": "10.1.0",
33
33
  "mockdate": "2.0.2",
34
34
  "nock": "9.2.6",
35
35
  "optimist": "0.6.1",
@@ -228,6 +228,13 @@ describe('notification api', () => {
228
228
  ).contains({is_csv: false, confirm_email_before_download: null, retention_period: null})
229
229
  });
230
230
 
231
+ it('should allow send a file email confirmation to be disabled', () => {
232
+ let file = Buffer.alloc(2*1024*1024)
233
+ expect(
234
+ notifyClient.prepareUpload(file, {confirmEmailBeforeDownload: false})
235
+ ).contains({is_csv: false, confirm_email_before_download: false, retention_period: null})
236
+ });
237
+
231
238
  it('should allow send a file email confirmation to be set', () => {
232
239
  let file = Buffer.alloc(2*1024*1024)
233
240
  expect(