@dwp/govuk-casa 8.5.1 → 8.5.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 CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [8.5.2](https://github.com/dwp/govuk-casa/compare/8.5.1...8.5.2) (2022-10-31)
6
+
5
7
  ### [8.5.1](https://github.com/dwp/govuk-casa/compare/8.5.0...8.5.1) (2022-10-13)
6
8
 
7
9
  ## [8.5.0](https://github.com/dwp/govuk-casa/compare/8.4.0...8.5.0) (2022-09-22)
@@ -100,6 +100,7 @@ export class PageField {
100
100
  * @param {any} value Value to validate
101
101
  * @param {ValidateContext} context Contextual validation information
102
102
  * @returns {ValidationError[]} Errors, or an empty array if all valid
103
+ * @throws {TypeError} If validator does not return an array
103
104
  */
104
105
  runValidators(value: any, context?: ValidateContext): ValidationError[];
105
106
  /**
package/dist/lib/field.js CHANGED
@@ -18,9 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.PageField = void 0;
19
19
  const lodash_1 = __importDefault(require("lodash"));
20
20
  const utils_js_1 = require("./utils.js");
21
- const logger_js_1 = __importDefault(require("./logger.js"));
22
21
  const { isFunction } = lodash_1.default;
23
- const log = (0, logger_js_1.default)('lib:field');
24
22
  /**
25
23
  * @access private
26
24
  * @typedef {import('./index').JourneyContext} JourneyContext
@@ -246,6 +244,7 @@ class PageField {
246
244
  * @param {any} value Value to validate
247
245
  * @param {ValidateContext} context Contextual validation information
248
246
  * @returns {ValidationError[]} Errors, or an empty array if all valid
247
+ * @throws {TypeError} If validator does not return an array
249
248
  */
250
249
  runValidators(value, context = Object.create(null)) {
251
250
  var _a;
@@ -5,14 +5,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const crypto_1 = require("crypto");
7
7
  const helmet_1 = __importDefault(require("helmet"));
8
+ /**
9
+ * @access private
10
+ * @typedef {import('../casa').HelmetConfigurator} HelmetConfigurator
11
+ */
8
12
  const GA_DOMAIN = '*.google-analytics.com';
9
13
  const GA_ANALYTICS_DOMAIN = '*.analytics.google.com';
10
14
  const GTM_DOMAIN = '*.googletagmanager.com';
11
15
  const GTM_PREVIEW_DOMAIN = 'https://tagmanager.google.com';
12
16
  /**
13
- * @access private
14
- * @typedef {import('../casa').HelmetConfigurator} HelmetConfigurator
17
+ * Extracts the CSP nonce used in every template, and makes it available as a
18
+ * nonce value in the CSP header.
19
+ *
20
+ * IMPORTANT: Do not rename this function as it _might_ be used in consumer code
21
+ * to identify this function specifically, most likely to remove it from CSP
22
+ * headers for custom purposes.
23
+ *
24
+ * @param {import('express').Request} req Request
25
+ * @param {import('express').Response} res Response
26
+ * @returns {string} nonce value suitable for use in CSP header
15
27
  */
28
+ function casaCspNonce(req, res) {
29
+ return `'nonce-${res.locals.cspNonce}'`;
30
+ }
16
31
  /**
17
32
  * Pre middleware.
18
33
  *
@@ -56,13 +71,13 @@ exports.default = ({ helmetConfigurator = (config) => (config), } = {}) => [
56
71
  useDefaults: true,
57
72
  directives: {
58
73
  'default-src': ["'none'"],
59
- 'script-src': ["'self'", GA_DOMAIN, GTM_DOMAIN, GTM_PREVIEW_DOMAIN, (req, res) => `'nonce-${res.locals.cspNonce}'`],
74
+ 'script-src': ["'self'", GA_DOMAIN, GTM_DOMAIN, GTM_PREVIEW_DOMAIN, casaCspNonce],
60
75
  'img-src': ["'self'", GA_DOMAIN, GA_ANALYTICS_DOMAIN, GTM_DOMAIN, 'https://ssl.gstatic.com', 'https://www.gstatic.com'],
61
76
  'connect-src': ["'self'", GA_DOMAIN, GA_ANALYTICS_DOMAIN, GTM_DOMAIN],
62
77
  'frame-src': ["'self'", GTM_DOMAIN],
63
78
  'frame-ancestors': ["'self'"],
64
79
  'form-action': ["'self'"],
65
- 'style-src': ["'self'", 'https://fonts.googleapis.com', GTM_PREVIEW_DOMAIN, (req, res) => `'nonce-${res.locals.cspNonce}'`],
80
+ 'style-src': ["'self'", 'https://fonts.googleapis.com', GTM_PREVIEW_DOMAIN, casaCspNonce],
66
81
  'font-src': ["'self'", 'data:', 'https://fonts.gstatic.com'],
67
82
  },
68
83
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dwp/govuk-casa",
3
- "version": "8.5.1",
3
+ "version": "8.5.2",
4
4
  "description": "A framework for building GOVUK Collect-And-Submit-Applications",
5
5
  "repository": {
6
6
  "type": "git",
@@ -62,7 +62,7 @@
62
62
  "validator": "13.7.0"
63
63
  },
64
64
  "devDependencies": {
65
- "@babel/core": "7.19.3",
65
+ "@babel/core": "7.19.6",
66
66
  "@babel/eslint-parser": "7.19.1",
67
67
  "@babel/preset-env": "7.19.4",
68
68
  "@ckeditor/jsdoc-plugins": "30.5.0",
@@ -72,7 +72,7 @@
72
72
  "@dwp/casa-spiderplan-zap-plugin": "0.1.1",
73
73
  "@dwp/eslint-config-base": "6.0.0",
74
74
  "@types/express": "4.17.14",
75
- "@types/node": "18.0.0",
75
+ "@types/node": "18.11.8",
76
76
  "@types/nunjucks": "3.2.1",
77
77
  "babel-eslint": "10.1.0",
78
78
  "c8": "7.12.0",
@@ -80,20 +80,20 @@
80
80
  "cheerio": "1.0.0-rc.12",
81
81
  "commitlint": "17.1.2",
82
82
  "docdash": "1.2.0",
83
- "eslint": "8.25.0",
83
+ "eslint": "8.26.0",
84
84
  "eslint-plugin-no-unsafe-regex": "1.0.0",
85
85
  "eslint-plugin-security": "1.5.0",
86
86
  "eslint-plugin-sonarjs": "0.16.0",
87
- "fast-check": "3.2.0",
87
+ "fast-check": "3.3.0",
88
88
  "husky": "8.0.1",
89
89
  "jsdoc": "3.6.11",
90
90
  "jsdoc-tsimport-plugin": "1.0.5",
91
- "mocha": "10.0.0",
91
+ "mocha": "10.1.0",
92
92
  "sass": "1.55.0",
93
93
  "sinon": "14.0.1",
94
94
  "sinon-chai": "3.7.0",
95
95
  "standard-version": "9.5.0",
96
- "supertest": "6.3.0",
96
+ "supertest": "6.3.1",
97
97
  "typescript": "4.8.4"
98
98
  }
99
99
  }