hof 22.11.0-custom-session-timeout-beta.1 → 22.11.0-custom-session-timeout-beta.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
@@ -1,14 +1,14 @@
1
- ## 2025-11-11, Version 22.11.0 , @Rhodine-orleans-lindsay
1
+ ## 2025-11-15, Version 22.11.0 (Stable), @Rhodine-orleans-lindsay
2
2
 
3
3
  ### Changed
4
4
  - Updated custom session-timeout handling so that custom behaviours are not blocked by a `404` middleware error.
5
5
 
6
6
  ### Added
7
7
  - Added a `CUSTOM_SESSION_EXPIRY` environment variable so that a time other than the redis session ttl can be used for the session timeout. **IMPORTANT**: The `CUSTOM_SESSION_EXPIRY` variable must always a time before the redis session ttl would expire so that behaviours can run before the `SESSION_TIMEOUT` middleware is triggered.
8
- - Added a `CUSTOM_SESSION_TIMEOUT` that is `false` by default. When set to `true` the the '/session-timeout' page can run before the session expires without triggering a `404` middleware error.
8
+ - Added a `USE_CUSTOM_SESSION_TIMEOUT` that is `false` by default. When set to `true` the the '/session-timeout' page can run before the session expires without triggering a `404` middleware error.
9
9
 
10
10
  - 🎬 Action:
11
- - For custom session timeout handling that is not linked to the redis session ttl, The following variables must be set: `CUSTOM_SESSION_EXPIRY` to the relevant expiry time e.g.600 and `CUSTOM_SESSION_TIMEOUT` to true.
11
+ - For custom session timeout handling that is not linked to the redis session ttl, The following variables must be set: `CUSTOM_SESSION_EXPIRY` to the relevant expiry time e.g.600 and `USE_CUSTOM_SESSION_TIMEOUT` to true.
12
12
  - If a behaviour is required on the '/session-timeout` step, the '/session-timeout' step must be set in the project's index.js, along with any relevant behaviours.
13
13
 
14
14
 
package/README.md CHANGED
@@ -1329,8 +1329,8 @@ This feature allows you to customise the content related to the session timeout
1329
1329
  ### Usage
1330
1330
 
1331
1331
  By default, the session timeout is set to the redis session ttl. To bypass this and display the session timeout message before the redis session ttl the following evironment variables must be set:
1332
- `CUSTOM_SESSION_EXPIRY` - e.g. `600`. Configured to expire before thte project's redis session ttl.
1333
- `CUSTOM_SESSION_TIMEOUT` - `False` by default. When set to `true` the the '/session-timeout' page can run before the session expires without triggering a `404` middleware error.
1332
+ `CUSTOM_SESSION_EXPIRY` - e.g. `600`. Configure to expire before thte project's redis session ttl.
1333
+ `USE_CUSTOM_SESSION_TIMEOUT` - `false` by default. When set to `true` the the '/session-timeout' page can run before the session expires without triggering a `404` middleware error.
1334
1334
 
1335
1335
  To enable and customise the session timeout behaviour, you need to set the component and translations in your project's `hof.settings.json` file:
1336
1336
  ```json
@@ -59,7 +59,7 @@ const defaults = {
59
59
  pdfConverter: process.env.PDF_CONVERTER_URL
60
60
  },
61
61
  serveStatic: process.env.SERVE_STATIC_FILES !== 'false',
62
- customSessionTimeout: parseBoolean(process.env.CUSTOM_SESSION_TIMEOUT, false, 'CUSTOM_SESSION_TIMEOUT'),
62
+ useCustomSessionTimeout: parseBoolean(process.env.USE_CUSTOM_SESSION_TIMEOUT, false, 'USE_CUSTOM_SESSION_TIMEOUT'),
63
63
  sessionTimeOutWarning: process.env.SESSION_TIMEOUT_WARNING || 300,
64
64
  serviceUnavailable: parseBoolean(process.env.SERVICE_UNAVAILABLE, false, 'SERVICE_UNAVAILABLE')
65
65
  };
package/index.js CHANGED
@@ -253,15 +253,15 @@ function bootstrap(options) {
253
253
  /**
254
254
  * Handles requests to the session timeout page.
255
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 `CUSTOM_SESSION_TIMEOUT`variables to true.
257
- * If `CUSTOM_SESSION_EXPIRY` and `CUSTOM_SESSION_TIMEOUT` envs are set,
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
258
  * include '/session-timeout' step in the project's index.js.
259
259
  * - If the user has a session cookie but their session is missing or inactive,
260
260
  * this triggers a session timeout error handled by error middleware.
261
261
  * - Otherwise, responds with a 404 "Page Not Found" error.
262
262
  * This route ensures the timeout page only appears after an actual session expiry.
263
263
  */
264
- if (!config.customSessionTimeout) {
264
+ if (!config.useCustomSessionTimeout) {
265
265
  app.get('/session-timeout', (req, res, next) => {
266
266
  if ((req.cookies['hof-wizard-sc']) && (!req.session || req.session.exists !== true)) {
267
267
  const err = new Error('Session expired');
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-custom-session-timeout-beta.1",
4
+ "version": "22.11.0-custom-session-timeout-beta.2",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
7
7
  "author": "HomeOffice",
@@ -4,7 +4,6 @@
4
4
  const CountrySelect = require('./behaviours/country-select')
5
5
  const SummaryPageBehaviour = require('../../../').components.summary;
6
6
  const InternationalPhoneNumber = require('./behaviours/international-number');
7
- const TestConsoleLog = require('./behaviours/test-console-log');
8
7
 
9
8
  module.exports = {
10
9
  name: 'sandbox',
@@ -93,9 +92,6 @@ module.exports = {
93
92
  ],
94
93
  next: '/confirm'
95
94
  },
96
- '/session-timeout': {
97
- behaviours: TestConsoleLog
98
- },
99
95
  '/exit': {},
100
96
  '/save-and-exit': {}
101
97
  }
@@ -2,10 +2,6 @@
2
2
  "errors": {
3
3
  "service-unavailable": {
4
4
  "contact": "You can email for more information"
5
- },
6
- "session": {
7
- "title": "Custom title translation - Your session has timed out",
8
- "message": "Custom message translation - For your security, we have timed you out due to inactivity."
9
5
  }
10
6
  },
11
7
  "exit": {
@@ -1,9 +1,5 @@
1
1
  {
2
2
  "service-unavailable": {
3
3
  "contact": "You can email for more information"
4
- },
5
- "session": {
6
- "title": "Custom title translation - Your session has timed out",
7
- "message": "Custom message translation - For your security, we have timed you out due to inactivity."
8
4
  }
9
5
  }
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "scripts": {
10
10
  "start": "node server.js",
11
- "start:dev": "HOF_SANDBOX=true ../bin/hof-build watch --env",
11
+ "start:dev": "HOF_SANDBOX=true ../bin/hof-build watch",
12
12
  "dev": "yarn && GA_TAG=test nodemon server",
13
13
  "build": "HOF_SANDBOX=true ../bin/hof-build",
14
14
  "postinstall": "yarn run build"
package/sandbox/server.js CHANGED
@@ -8,7 +8,6 @@ bootstrap({
8
8
  routes: [
9
9
  require('./apps/sandbox')
10
10
  ],
11
- views: './apps/sandbox/views',
12
11
  behaviours: [
13
12
  require('../').components.sessionTimeoutWarning
14
13
  ],
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = SuperClass => class extends SuperClass {
4
- configure(req, res, next) {
5
- // Simple behaviour to log to console when run
6
- console.log('***************** console log behaviour executed************************');
7
- return super.configure(req, res, next);
8
- }
9
- };
@@ -1,7 +0,0 @@
1
- {{<error}}
2
- {{$content}}
3
- <h1 class="govuk-heading-l">{{#t}}errors.session.title{{/t}}</h1>
4
- <h2 class="govuk-heading-m">{{#t}}errors.session.message{{/t}}</h2>
5
- <a href="/" class="govuk-button" role="button">{{#t}}buttons.start-again{{/t}}</a>
6
- {{/content}}
7
- {{/error}}