hof 22.11.0-frontend-v4-beta.2 → 22.11.0

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.
@@ -1,22 +1,22 @@
1
- /* eslint-disable max-len, no-undef */
1
+ /* eslint-disable max-len, no-var, vars-on-top, no-undef */
2
2
  'use strict';
3
3
 
4
4
  // TODO: update package.json(s)
5
5
 
6
6
  function hideFallbackContent(containerId) {
7
- const container = document.getElementById(containerId);
7
+ var container = document.getElementById(containerId);
8
8
  if (container === null) return;
9
- const fallbackContent = container.getElementsByClassName('js-disabled');
10
- for (let i = 0; i < fallbackContent.length; i++) {
9
+ var fallbackContent = container.getElementsByClassName('js-disabled');
10
+ for (var i = 0; i < fallbackContent.length; i++) {
11
11
  fallbackContent[i].style.display = 'none';
12
12
  }
13
13
  }
14
14
 
15
15
  function showInteractiveContent(containerId) {
16
- const container = document.getElementById(containerId);
16
+ var container = document.getElementById(containerId);
17
17
  if (container === null) return;
18
- const interactiveContent = container.getElementsByClassName('js-enabled');
19
- for (let i = 0; i < interactiveContent.length; i++) {
18
+ var interactiveContent = container.getElementsByClassName('js-enabled');
19
+ for (var i = 0; i < interactiveContent.length; i++) {
20
20
  interactiveContent[i].style.display = 'block';
21
21
  }
22
22
  }
@@ -34,53 +34,41 @@ function setCookiePreferences(preferences) {
34
34
  function showCookieBannerSubmitted() {
35
35
  document.getElementById('cookie-banner-info').style.display = 'none';
36
36
  document.getElementById('cookie-banner-actions').style.display = 'none';
37
- let cookieBannerSubmitted;
38
- const cookieBannerDiv = document.getElementById('cookie-banner-submitted-accepted');
39
- if (cookieBannerDiv.dataset.acceptCookies === 'true') {
40
- cookieBannerSubmitted = document.getElementById('cookie-banner-submitted-accepted');
41
- } else {
42
- cookieBannerSubmitted = document.getElementById('cookie-banner-submitted-rejected');
43
- }
37
+ var cookieBannerSubmitted = document.getElementById('cookie-banner-submitted');
44
38
  cookieBannerSubmitted.style.display = 'block';
45
39
  cookieBannerSubmitted.focus();
46
40
  }
47
41
 
48
- function hideCookieBanner() {
49
- document.getElementById('cookie-banner').style.display = 'none';
50
- }
51
-
52
42
  function initialiseBannerButtons() {
53
- const acceptedCookieBannerDiv = document.getElementById('cookie-banner-submitted-accepted');
54
43
  document.getElementById('accept-cookies-button').addEventListener('click', function () {
55
- setCookiePreferences({ essential: true, usage: true });
44
+ setCookiePreferences({essential: true, usage: true});
56
45
  showCookieBannerSubmitted();
57
46
  sessionStorage.setItem('reloading', 'true');
58
47
  window.location = document.URL;
59
48
  });
60
49
 
61
50
  document.getElementById('reject-cookies-button').addEventListener('click', function () {
62
- setCookiePreferences({ essential: true, usage: false });
63
- acceptedCookieBannerDiv.dataset.acceptCookies = 'false';
51
+ setCookiePreferences({essential: true, usage: false});
64
52
  showCookieBannerSubmitted();
65
53
  });
66
54
 
67
- document.getElementById('hide-accept-cookie-banner').addEventListener('click', hideCookieBanner);
68
-
69
- document.getElementById('hide-reject-cookie-banner').addEventListener('click', hideCookieBanner);
55
+ document.getElementById('hide-cookie-banner').addEventListener('click', function () {
56
+ document.getElementById('cookie-banner').style.display = 'none';
57
+ });
70
58
  }
71
59
 
72
60
  function initialiseCookieBanner() {
73
- const preferences = GOVUK.cookie('cookie_preferences');
61
+ var preferences = GOVUK.cookie('cookie_preferences');
74
62
 
75
63
  if (preferences !== null) {
76
64
  return;
77
65
  }
78
66
 
79
67
  // the default cookie message container from hof-govuk-template
80
- const bannerContainer = document.getElementById('global-cookie-message');
68
+ var bannerContainer = document.getElementById('global-cookie-message');
81
69
 
82
70
  // the cookie banner that will replace the container's default content if using google analytics
83
- const cookieBanner = document.getElementById('cookie-banner');
71
+ var cookieBanner = document.getElementById('cookie-banner');
84
72
 
85
73
  if (bannerContainer !== null && cookieBanner !== null) {
86
74
  hideFallbackContent('global-cookie-message');
@@ -94,8 +82,8 @@ function handleSaveSettings(e) {
94
82
  e.preventDefault();
95
83
  setCookiePreferences({ essential: true, usage: document.getElementById('radio-1').checked });
96
84
 
97
- const cookieNotification = document.getElementById('cookie-notification');
98
- const cookieBanner = document.getElementById('cookie-banner');
85
+ var cookieNotification = document.getElementById('cookie-notification');
86
+ var cookieBanner = document.getElementById('cookie-banner');
99
87
 
100
88
  if (cookieBanner !== null) {
101
89
  cookieBanner.style.display = 'none';
@@ -108,8 +96,8 @@ function handleSaveSettings(e) {
108
96
  }
109
97
 
110
98
  function initialiseFormControls() {
111
- const preferences = JSON.parse(GOVUK.cookie('cookie_preferences'));
112
- let usage;
99
+ var preferences = JSON.parse(GOVUK.cookie('cookie_preferences'));
100
+ var usage;
113
101
 
114
102
  if (preferences !== null && preferences.usage !== undefined && typeof preferences.usage === 'boolean') {
115
103
  usage = preferences.usage;
@@ -123,7 +111,7 @@ function initialiseFormControls() {
123
111
  }
124
112
 
125
113
  function initialiseCookiePage() {
126
- const shouldDisplayCookieControls = document.getElementById('cookie-settings') !== null;
114
+ var shouldDisplayCookieControls = document.getElementById('cookie-settings') !== null;
127
115
 
128
116
  if (shouldDisplayCookieControls) {
129
117
  hideFallbackContent('cookie-settings');
@@ -134,12 +122,12 @@ function initialiseCookiePage() {
134
122
 
135
123
  function onLoad() {
136
124
  window.onload = function () {
137
- const reloading = sessionStorage.getItem('reloading');
125
+ var reloading = sessionStorage.getItem('reloading');
138
126
  if (reloading) {
139
127
  sessionStorage.removeItem('reloading');
140
128
 
141
- const bannerContainer = document.getElementById('global-cookie-message');
142
- const cookieBanner = document.getElementById('cookie-banner');
129
+ var bannerContainer = document.getElementById('global-cookie-message');
130
+ var cookieBanner = document.getElementById('cookie-banner');
143
131
 
144
132
  if (bannerContainer !== null && cookieBanner !== null) {
145
133
  bannerContainer.style.display = 'block';
package/index.js CHANGED
@@ -156,7 +156,7 @@ function bootstrap(options) {
156
156
  res.locals.htmlLang = config.htmlLang;
157
157
  res.locals.cookieName = config.session.name;
158
158
  // session timeout warning configs
159
- res.locals.sessionTimeOut = config.session.ttl;
159
+ res.locals.sessionTimeOut = process.env.CUSTOM_SESSION_EXPIRY || config.session.ttl;
160
160
  res.locals.sessionTimeOutWarning = config.sessionTimeOutWarning;
161
161
  res.locals.sessionTimeoutWarningContent = config.sessionTimeoutWarningContent;
162
162
  res.locals.exitFormContent = config.exitFormContent;
@@ -252,26 +252,32 @@ function bootstrap(options) {
252
252
 
253
253
  /**
254
254
  * Handles requests to the session timeout page.
255
+ * For custom session timeout handling that is not linked to the redis session ttl,
256
+ * set `CUSTOM_SESSION_EXPIRY` variables to the relevant time and `USE_CUSTOM_SESSION_TIMEOUT`variables to true.
257
+ * If `CUSTOM_SESSION_EXPIRY` and `USE_CUSTOM_SESSION_TIMEOUT` envs are set,
258
+ * include '/session-timeout' step in the project's index.js.
255
259
  * - If the user has a session cookie but their session is missing or inactive,
256
260
  * this triggers a session timeout error handled by error middleware.
257
261
  * - Otherwise, responds with a 404 "Page Not Found" error.
258
262
  * This route ensures the timeout page only appears after an actual session expiry.
259
263
  */
260
- app.get('/session-timeout', (req, res, next) => {
261
- if ((req.cookies['hof-wizard-sc']) && (!req.session || req.session.exists !== true)) {
262
- const err = new Error('Session expired');
263
- err.code = 'SESSION_TIMEOUT';
264
- return next(err);
265
- }
266
- const err = new Error('Not Found');
267
- err.status = 404;
268
- const locals = Object.assign({}, req.translate('errors'));
269
- if (locals && locals['404']) {
270
- return res.status(404).render('404', locals['404']);
271
- }
272
- // Fallback: render a basic 404 page if translation is missing
273
- return res.status(404).send('Page Not Found');
274
- });
264
+ if (!config.useCustomSessionTimeout) {
265
+ app.get('/session-timeout', (req, res, next) => {
266
+ if ((req.cookies['hof-wizard-sc']) && (!req.session || req.session.exists !== true)) {
267
+ const err = new Error('Session expired');
268
+ err.code = 'SESSION_TIMEOUT';
269
+ return next(err);
270
+ }
271
+ const err = new Error('Not Found');
272
+ err.status = 404;
273
+ const locals = Object.assign({}, req.translate('errors'));
274
+ if (locals && locals['404']) {
275
+ return res.status(404).render('404', locals['404']);
276
+ }
277
+ // Fallback: render a basic 404 page if translation is missing
278
+ return res.status(404).send('Page Not Found');
279
+ });
280
+ }
275
281
 
276
282
  if (config.getAccessibility === true) {
277
283
  deprecate(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hof",
3
3
  "description": "A bootstrap for HOF projects",
4
- "version": "22.11.0-frontend-v4-beta.2",
4
+ "version": "22.11.0",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
7
7
  "author": "HomeOffice",
@@ -36,99 +36,99 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "aliasify": "^2.1.0",
39
- "axios": "^1.11.0",
39
+ "axios": "^1.12.2",
40
40
  "bluebird": "^3.7.2",
41
- "body-parser": "^1.15.1",
42
- "browserify": "^17.0.0",
41
+ "body-parser": "^1.20.3",
42
+ "browserify": "^17.0.1",
43
43
  "callsite": "^1.0.0",
44
- "chalk": "^2.0.0",
45
- "chokidar": "^3.4.0",
44
+ "chalk": "^2.4.2",
45
+ "chokidar": "^3.6.0",
46
46
  "connect-redis": "^5.2.0",
47
- "cookie-parser": "^1.4.6",
47
+ "cookie-parser": "^1.4.7",
48
48
  "cp": "^0.2.0",
49
49
  "csrf": "^3.1.0",
50
- "debug": "^4.3.1",
51
- "deprecate": "^1.0.0",
50
+ "debug": "^4.4.3",
51
+ "deprecate": "^1.1.1",
52
52
  "dialog-polyfill": "^0.5.6",
53
53
  "dotenv": "^4.0.0",
54
- "duplexify": "^3.5.0",
54
+ "duplexify": "^3.7.1",
55
55
  "exorcist": "^2.0.0",
56
- "express": "^4.17.1",
56
+ "express": "^4.21.2",
57
57
  "express-healthcheck": "^0.1.0",
58
58
  "express-partial-templates": "^0.2.1",
59
- "express-session": "^1.13.0",
59
+ "express-session": "^1.18.2",
60
60
  "findup": "^0.1.5",
61
- "glob": "^7.2.0",
61
+ "glob": "^7.2.3",
62
62
  "govuk-elements-sass": "^3.1.3",
63
- "govuk-frontend": "4.10.1",
63
+ "govuk-frontend": "3.15.0",
64
64
  "govuk_template_mustache": "^0.26.0",
65
- "helmet": "^3.22.0",
65
+ "helmet": "^3.23.3",
66
66
  "hogan-express-strict": "^0.5.4",
67
67
  "hogan.js": "^3.0.2",
68
68
  "homeoffice-countries": "^0.2.0",
69
- "i18n-future": "^2.0.0",
69
+ "i18n-future": "^2.0.1",
70
70
  "i18n-lookup": "^0.1.0",
71
71
  "is-pdf": "^1.0.0",
72
- "jquery": "^3.6.0",
73
- "libphonenumber-js": "^1.9.44",
72
+ "jquery": "^3.7.1",
73
+ "libphonenumber-js": "^1.12.23",
74
74
  "lodash": "^4.17.21",
75
75
  "markdown-it": "^12.3.2",
76
- "minimatch": "^3.0.7",
77
- "minimist": "^1.2.6",
76
+ "minimatch": "^3.1.2",
77
+ "minimist": "^1.2.8",
78
78
  "mixwith": "^0.1.1",
79
- "moment": "^2.29.4",
80
- "morgan": "^1.10.0",
79
+ "moment": "^2.30.1",
80
+ "morgan": "^1.10.1",
81
81
  "mustache": "^4.2.0",
82
- "nodemailer": "^6.6.3",
82
+ "nodemailer": "^6.10.1",
83
83
  "nodemailer-ses-transport": "^1.5.1",
84
84
  "nodemailer-stub-transport": "^1.1.0",
85
85
  "notifications-node-client": "^8.2.1",
86
86
  "redis": "^3.1.2",
87
87
  "reqres": "^3.0.1",
88
88
  "rimraf": "^3.0.2",
89
- "sass": "^1.56.2",
90
- "serve-static": "^1.14.1",
91
- "uglify-js": "^3.14.3",
89
+ "sass": "^1.93.2",
90
+ "serve-static": "^1.16.2",
91
+ "uglify-js": "^3.19.3",
92
92
  "underscore": "^1.13.7",
93
93
  "urijs": "^1.19.11",
94
94
  "uuid": "^8.3.2",
95
- "winston": "^3.7.2"
95
+ "winston": "^3.18.3"
96
96
  },
97
97
  "devDependencies": {
98
- "@cucumber/cucumber": "^7.3.0",
99
- "@cucumber/pretty-formatter": "^1.0.0-alpha.1",
100
- "@types/jest": "^26.0.14",
101
- "@xmldom/xmldom": "~0.8.4",
98
+ "@cucumber/cucumber": "^7.3.2",
99
+ "@cucumber/pretty-formatter": "^1.0.1",
100
+ "@types/jest": "^26.0.24",
101
+ "@xmldom/xmldom": "~0.8.11",
102
102
  "chai": "^3.5.0",
103
- "chai-as-promised": "^7.1.1",
103
+ "chai-as-promised": "^7.1.2",
104
104
  "chai-subset": "^1.6.0",
105
- "concat-stream": "^1.4.7",
106
- "csv": "^5.3.2",
107
- "eslint": "^8.57.0",
105
+ "concat-stream": "^1.6.2",
106
+ "csv": "^5.5.3",
107
+ "eslint": "^8.57.1",
108
108
  "eslint-config-hof": "^1.3.4",
109
109
  "funkie": "0.0.5",
110
110
  "funkie-phantom": "0.0.1",
111
- "istanbul": "^0.4.3",
112
- "jest": "^26.5.0",
113
- "jquery": "^3.6.0",
114
- "karma": "^6.3.4",
115
- "karma-browserify": "^8.0.0",
111
+ "istanbul": "^0.4.5",
112
+ "jest": "^26.6.3",
113
+ "jquery": "^3.7.1",
114
+ "karma": "^6.4.4",
115
+ "karma-browserify": "^8.1.0",
116
116
  "karma-chai": "^0.1.0",
117
117
  "karma-cli": "^2.0.0",
118
118
  "karma-mocha": "^2.0.1",
119
119
  "karma-phantomjs-launcher": "^1.0.4",
120
120
  "mocha": "^8.4.0",
121
121
  "mocha-sandbox": "^1.0.0",
122
- "node-mocks-http": "^1.6.2",
123
- "npm-run-all": "^3.1.1",
122
+ "node-mocks-http": "^1.17.2",
123
+ "npm-run-all": "^3.1.2",
124
124
  "nyc": "^15.1.0",
125
- "playwright": "^1.16.3",
125
+ "playwright": "^1.56.0",
126
126
  "postcode": "0.2.2",
127
- "proxyquire": "^1.7.11",
128
- "release-it": "^16.2.1",
129
- "sinon": "^11.1.1",
127
+ "proxyquire": "^1.8.0",
128
+ "release-it": "^16.3.0",
129
+ "sinon": "^11.1.2",
130
130
  "sinon-chai": "^3.7.0",
131
- "supertest": "^3.0.0",
131
+ "supertest": "^3.4.2",
132
132
  "travis-conditions": "0.0.0",
133
133
  "watchify": "^4.0.0",
134
134
  "webdriverio": "^4.14.4"
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "author": "",
17
17
  "dependencies": {
18
- "govuk-frontend": "4.10.1",
18
+ "govuk-frontend": "3.14",
19
19
  "jquery": "^3.7.1",
20
20
  "sass": "^1.53.0",
21
21
  "typeahead-aria": "^1.0.4"