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.
- package/CHANGELOG.md +19 -0
- package/README.md +20 -2
- package/components/date/templates/date.html +1 -1
- package/config/hof-defaults.js +1 -0
- package/frontend/govuk-template/build/govuk_template.html +22 -66
- package/frontend/govuk-template/govuk_template_generated.html +22 -66
- package/frontend/template-mixins/mixins/template-mixins.js +4 -5
- package/frontend/template-mixins/partials/forms/checkbox.html +1 -5
- package/frontend/template-mixins/partials/forms/input-text-date.html +1 -2
- package/frontend/template-mixins/partials/forms/input-text-group.html +1 -1
- package/frontend/template-mixins/partials/forms/textarea-group.html +1 -1
- package/frontend/template-partials/views/layout.html +1 -1
- package/frontend/template-partials/views/partials/cookie-banner.html +32 -50
- package/frontend/template-partials/views/partials/navigation.html +2 -2
- package/frontend/themes/gov-uk/client-js/cookieSettings.js +24 -36
- package/index.js +22 -16
- package/package.json +47 -47
- package/sandbox/package.json +1 -1
- package/sandbox/public/js/bundle.js +2216 -4754
- package/sandbox/yarn.lock +59 -166
- package/sandbox/public/css/app.css +0 -11196
- package/sandbox/public/images/icons/icon-caret-left.png +0 -0
- package/sandbox/public/images/icons/icon-complete.png +0 -0
- package/sandbox/public/images/icons/icon-cross-remove-sign.png +0 -0
|
@@ -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
|
-
|
|
7
|
+
var container = document.getElementById(containerId);
|
|
8
8
|
if (container === null) return;
|
|
9
|
-
|
|
10
|
-
for (
|
|
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
|
-
|
|
16
|
+
var container = document.getElementById(containerId);
|
|
17
17
|
if (container === null) return;
|
|
18
|
-
|
|
19
|
-
for (
|
|
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
|
-
|
|
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({
|
|
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({
|
|
63
|
-
acceptedCookieBannerDiv.dataset.acceptCookies = 'false';
|
|
51
|
+
setCookiePreferences({essential: true, usage: false});
|
|
64
52
|
showCookieBannerSubmitted();
|
|
65
53
|
});
|
|
66
54
|
|
|
67
|
-
document.getElementById('hide-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
98
|
-
|
|
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
|
-
|
|
112
|
-
|
|
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
|
-
|
|
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
|
-
|
|
125
|
+
var reloading = sessionStorage.getItem('reloading');
|
|
138
126
|
if (reloading) {
|
|
139
127
|
sessionStorage.removeItem('reloading');
|
|
140
128
|
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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
|
|
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.
|
|
39
|
+
"axios": "^1.12.2",
|
|
40
40
|
"bluebird": "^3.7.2",
|
|
41
|
-
"body-parser": "^1.
|
|
42
|
-
"browserify": "^17.0.
|
|
41
|
+
"body-parser": "^1.20.3",
|
|
42
|
+
"browserify": "^17.0.1",
|
|
43
43
|
"callsite": "^1.0.0",
|
|
44
|
-
"chalk": "^2.
|
|
45
|
-
"chokidar": "^3.
|
|
44
|
+
"chalk": "^2.4.2",
|
|
45
|
+
"chokidar": "^3.6.0",
|
|
46
46
|
"connect-redis": "^5.2.0",
|
|
47
|
-
"cookie-parser": "^1.4.
|
|
47
|
+
"cookie-parser": "^1.4.7",
|
|
48
48
|
"cp": "^0.2.0",
|
|
49
49
|
"csrf": "^3.1.0",
|
|
50
|
-
"debug": "^4.3
|
|
51
|
-
"deprecate": "^1.
|
|
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.
|
|
54
|
+
"duplexify": "^3.7.1",
|
|
55
55
|
"exorcist": "^2.0.0",
|
|
56
|
-
"express": "^4.
|
|
56
|
+
"express": "^4.21.2",
|
|
57
57
|
"express-healthcheck": "^0.1.0",
|
|
58
58
|
"express-partial-templates": "^0.2.1",
|
|
59
|
-
"express-session": "^1.
|
|
59
|
+
"express-session": "^1.18.2",
|
|
60
60
|
"findup": "^0.1.5",
|
|
61
|
-
"glob": "^7.2.
|
|
61
|
+
"glob": "^7.2.3",
|
|
62
62
|
"govuk-elements-sass": "^3.1.3",
|
|
63
|
-
"govuk-frontend": "
|
|
63
|
+
"govuk-frontend": "3.15.0",
|
|
64
64
|
"govuk_template_mustache": "^0.26.0",
|
|
65
|
-
"helmet": "^3.
|
|
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.
|
|
69
|
+
"i18n-future": "^2.0.1",
|
|
70
70
|
"i18n-lookup": "^0.1.0",
|
|
71
71
|
"is-pdf": "^1.0.0",
|
|
72
|
-
"jquery": "^3.
|
|
73
|
-
"libphonenumber-js": "^1.
|
|
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.
|
|
77
|
-
"minimist": "^1.2.
|
|
76
|
+
"minimatch": "^3.1.2",
|
|
77
|
+
"minimist": "^1.2.8",
|
|
78
78
|
"mixwith": "^0.1.1",
|
|
79
|
-
"moment": "^2.
|
|
80
|
-
"morgan": "^1.10.
|
|
79
|
+
"moment": "^2.30.1",
|
|
80
|
+
"morgan": "^1.10.1",
|
|
81
81
|
"mustache": "^4.2.0",
|
|
82
|
-
"nodemailer": "^6.
|
|
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.
|
|
90
|
-
"serve-static": "^1.
|
|
91
|
-
"uglify-js": "^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.
|
|
95
|
+
"winston": "^3.18.3"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
|
-
"@cucumber/cucumber": "^7.3.
|
|
99
|
-
"@cucumber/pretty-formatter": "^1.0.
|
|
100
|
-
"@types/jest": "^26.0.
|
|
101
|
-
"@xmldom/xmldom": "~0.8.
|
|
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.
|
|
103
|
+
"chai-as-promised": "^7.1.2",
|
|
104
104
|
"chai-subset": "^1.6.0",
|
|
105
|
-
"concat-stream": "^1.
|
|
106
|
-
"csv": "^5.3
|
|
107
|
-
"eslint": "^8.57.
|
|
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.
|
|
112
|
-
"jest": "^26.
|
|
113
|
-
"jquery": "^3.
|
|
114
|
-
"karma": "^6.
|
|
115
|
-
"karma-browserify": "^8.
|
|
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.
|
|
123
|
-
"npm-run-all": "^3.1.
|
|
122
|
+
"node-mocks-http": "^1.17.2",
|
|
123
|
+
"npm-run-all": "^3.1.2",
|
|
124
124
|
"nyc": "^15.1.0",
|
|
125
|
-
"playwright": "^1.
|
|
125
|
+
"playwright": "^1.56.0",
|
|
126
126
|
"postcode": "0.2.2",
|
|
127
|
-
"proxyquire": "^1.
|
|
128
|
-
"release-it": "^16.
|
|
129
|
-
"sinon": "^11.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.
|
|
131
|
+
"supertest": "^3.4.2",
|
|
132
132
|
"travis-conditions": "0.0.0",
|
|
133
133
|
"watchify": "^4.0.0",
|
|
134
134
|
"webdriverio": "^4.14.4"
|