@dwp/govuk-casa 9.6.6 → 10.0.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.
Files changed (287) hide show
  1. package/dist/assets/css/casa.css +1 -1
  2. package/dist/assets/css/casa.css.map +1 -1
  3. package/dist/casa.d.ts +81 -41
  4. package/dist/casa.d.ts.map +1 -0
  5. package/dist/casa.js +72 -99
  6. package/dist/core-plugins/edit-snapshot/src/configure.d.ts +1 -0
  7. package/dist/core-plugins/edit-snapshot/src/configure.d.ts.map +1 -0
  8. package/dist/core-plugins/edit-snapshot/src/configure.js +7 -14
  9. package/dist/core-plugins/edit-snapshot/src/index.d.ts +1 -0
  10. package/dist/core-plugins/edit-snapshot/src/index.d.ts.map +1 -0
  11. package/dist/core-plugins/edit-snapshot/src/index.js +3 -9
  12. package/dist/core-plugins/edit-snapshot/src/post-steer-hook.d.ts +2 -1
  13. package/dist/core-plugins/edit-snapshot/src/post-steer-hook.d.ts.map +1 -0
  14. package/dist/core-plugins/edit-snapshot/src/post-steer-hook.js +8 -13
  15. package/dist/core-plugins/edit-snapshot/src/pre-steer-hook.d.ts +2 -1
  16. package/dist/core-plugins/edit-snapshot/src/pre-steer-hook.d.ts.map +1 -0
  17. package/dist/core-plugins/edit-snapshot/src/pre-steer-hook.js +13 -18
  18. package/dist/core-plugins/edit-snapshot/src/utils.d.ts +8 -5
  19. package/dist/core-plugins/edit-snapshot/src/utils.d.ts.map +1 -0
  20. package/dist/core-plugins/edit-snapshot/src/utils.js +37 -19
  21. package/dist/core-plugins/index.d.ts +1 -0
  22. package/dist/core-plugins/index.d.ts.map +1 -0
  23. package/dist/core-plugins/index.js +1 -9
  24. package/dist/lib/CasaTemplateLoader.d.ts +1 -0
  25. package/dist/lib/CasaTemplateLoader.d.ts.map +1 -0
  26. package/dist/lib/CasaTemplateLoader.js +2 -6
  27. package/dist/lib/JourneyContext.d.ts +22 -11
  28. package/dist/lib/JourneyContext.d.ts.map +1 -0
  29. package/dist/lib/JourneyContext.js +40 -45
  30. package/dist/lib/MutableRouter.d.ts +74 -55
  31. package/dist/lib/MutableRouter.d.ts.map +1 -0
  32. package/dist/lib/MutableRouter.js +48 -45
  33. package/dist/lib/NullObject.d.ts +3 -0
  34. package/dist/lib/NullObject.d.ts.map +1 -0
  35. package/dist/lib/NullObject.js +3 -0
  36. package/dist/lib/Plan.d.ts +2 -1
  37. package/dist/lib/Plan.d.ts.map +1 -0
  38. package/dist/lib/Plan.js +44 -62
  39. package/dist/lib/ValidationError.d.ts +2 -1
  40. package/dist/lib/ValidationError.d.ts.map +1 -0
  41. package/dist/lib/ValidationError.js +3 -11
  42. package/dist/lib/ValidatorFactory.d.ts +5 -6
  43. package/dist/lib/ValidatorFactory.d.ts.map +1 -0
  44. package/dist/lib/ValidatorFactory.js +4 -12
  45. package/dist/lib/configuration-ingestor.d.ts +10 -22
  46. package/dist/lib/configuration-ingestor.d.ts.map +1 -0
  47. package/dist/lib/configuration-ingestor.js +61 -143
  48. package/dist/lib/configure.d.ts +2 -1
  49. package/dist/lib/configure.d.ts.map +1 -0
  50. package/dist/lib/configure.js +40 -52
  51. package/dist/lib/constants.d.ts +1 -0
  52. package/dist/lib/constants.d.ts.map +1 -0
  53. package/dist/lib/constants.js +8 -12
  54. package/dist/lib/context-id-generators.d.ts +1 -0
  55. package/dist/lib/context-id-generators.d.ts.map +1 -0
  56. package/dist/lib/context-id-generators.js +4 -9
  57. package/dist/lib/end-session.d.ts +2 -1
  58. package/dist/lib/end-session.d.ts.map +1 -0
  59. package/dist/lib/end-session.js +4 -11
  60. package/dist/lib/field.d.ts +2 -1
  61. package/dist/lib/field.d.ts.map +1 -0
  62. package/dist/lib/field.js +11 -21
  63. package/dist/lib/index.d.ts +1 -0
  64. package/dist/lib/index.d.ts.map +1 -0
  65. package/dist/lib/index.js +13 -65
  66. package/dist/lib/logger.d.ts +25 -2
  67. package/dist/lib/logger.d.ts.map +1 -0
  68. package/dist/lib/logger.js +18 -9
  69. package/dist/lib/mount.d.ts +1 -0
  70. package/dist/lib/mount.d.ts.map +1 -0
  71. package/dist/lib/mount.js +10 -16
  72. package/dist/lib/nunjucks-filters.d.ts +7 -3
  73. package/dist/lib/nunjucks-filters.d.ts.map +1 -0
  74. package/dist/lib/nunjucks-filters.js +58 -71
  75. package/dist/lib/nunjucks.d.ts +2 -2
  76. package/dist/lib/nunjucks.d.ts.map +1 -0
  77. package/dist/lib/nunjucks.js +12 -25
  78. package/dist/lib/utils.d.ts +4 -2
  79. package/dist/lib/utils.d.ts.map +1 -0
  80. package/dist/lib/utils.js +14 -28
  81. package/dist/lib/validators/dateObject.d.ts +1 -0
  82. package/dist/lib/validators/dateObject.d.ts.map +1 -0
  83. package/dist/lib/validators/dateObject.js +14 -21
  84. package/dist/lib/validators/email.d.ts +1 -0
  85. package/dist/lib/validators/email.d.ts.map +1 -0
  86. package/dist/lib/validators/email.js +8 -15
  87. package/dist/lib/validators/inArray.d.ts +1 -0
  88. package/dist/lib/validators/inArray.d.ts.map +1 -0
  89. package/dist/lib/validators/inArray.js +8 -15
  90. package/dist/lib/validators/index.d.ts +1 -0
  91. package/dist/lib/validators/index.d.ts.map +1 -0
  92. package/dist/lib/validators/index.js +21 -27
  93. package/dist/lib/validators/nino.d.ts +1 -0
  94. package/dist/lib/validators/nino.d.ts.map +1 -0
  95. package/dist/lib/validators/nino.js +6 -13
  96. package/dist/lib/validators/postalAddressObject.d.ts +1 -0
  97. package/dist/lib/validators/postalAddressObject.d.ts.map +1 -0
  98. package/dist/lib/validators/postalAddressObject.js +12 -19
  99. package/dist/lib/validators/range.d.ts +1 -0
  100. package/dist/lib/validators/range.d.ts.map +1 -0
  101. package/dist/lib/validators/range.js +6 -13
  102. package/dist/lib/validators/regex.d.ts +1 -0
  103. package/dist/lib/validators/regex.d.ts.map +1 -0
  104. package/dist/lib/validators/regex.js +6 -13
  105. package/dist/lib/validators/required.d.ts +1 -0
  106. package/dist/lib/validators/required.d.ts.map +1 -0
  107. package/dist/lib/validators/required.js +9 -17
  108. package/dist/lib/validators/strlen.d.ts +1 -0
  109. package/dist/lib/validators/strlen.d.ts.map +1 -0
  110. package/dist/lib/validators/strlen.js +6 -13
  111. package/dist/lib/validators/wordCount.d.ts +1 -0
  112. package/dist/lib/validators/wordCount.d.ts.map +1 -0
  113. package/dist/lib/validators/wordCount.js +6 -13
  114. package/dist/lib/waypoint-url.d.ts +3 -2
  115. package/dist/lib/waypoint-url.d.ts.map +1 -0
  116. package/dist/lib/waypoint-url.js +12 -19
  117. package/dist/middleware/body-parser.d.ts +1 -0
  118. package/dist/middleware/body-parser.d.ts.map +1 -0
  119. package/dist/middleware/body-parser.js +4 -9
  120. package/dist/middleware/csrf.d.ts +1 -0
  121. package/dist/middleware/csrf.d.ts.map +1 -0
  122. package/dist/middleware/csrf.js +4 -8
  123. package/dist/middleware/data.d.ts +2 -3
  124. package/dist/middleware/data.d.ts.map +1 -0
  125. package/dist/middleware/data.js +23 -25
  126. package/dist/middleware/gather-fields.d.ts +3 -1
  127. package/dist/middleware/gather-fields.d.ts.map +1 -0
  128. package/dist/middleware/gather-fields.js +13 -14
  129. package/dist/middleware/i18n.d.ts +1 -0
  130. package/dist/middleware/i18n.d.ts.map +1 -0
  131. package/dist/middleware/i18n.js +26 -31
  132. package/dist/middleware/post.d.ts +1 -0
  133. package/dist/middleware/post.d.ts.map +1 -0
  134. package/dist/middleware/post.js +3 -10
  135. package/dist/middleware/pre.d.ts +2 -1
  136. package/dist/middleware/pre.d.ts.map +1 -0
  137. package/dist/middleware/pre.js +6 -12
  138. package/dist/middleware/progress-journey.d.ts +5 -3
  139. package/dist/middleware/progress-journey.d.ts.map +1 -0
  140. package/dist/middleware/progress-journey.js +20 -18
  141. package/dist/middleware/sanitise-fields.d.ts +5 -3
  142. package/dist/middleware/sanitise-fields.d.ts.map +1 -0
  143. package/dist/middleware/sanitise-fields.js +25 -17
  144. package/dist/middleware/serve-first-waypoint.d.ts +1 -0
  145. package/dist/middleware/serve-first-waypoint.d.ts.map +1 -0
  146. package/dist/middleware/serve-first-waypoint.js +3 -6
  147. package/dist/middleware/session.d.ts +15 -0
  148. package/dist/middleware/session.d.ts.map +1 -0
  149. package/dist/middleware/session.js +53 -57
  150. package/dist/middleware/skip-waypoint.d.ts +3 -2
  151. package/dist/middleware/skip-waypoint.d.ts.map +1 -0
  152. package/dist/middleware/skip-waypoint.js +15 -14
  153. package/dist/middleware/steer-journey.d.ts +2 -1
  154. package/dist/middleware/steer-journey.d.ts.map +1 -0
  155. package/dist/middleware/steer-journey.js +7 -13
  156. package/dist/middleware/strip-proxy-path.d.ts +3 -2
  157. package/dist/middleware/strip-proxy-path.d.ts.map +1 -0
  158. package/dist/middleware/strip-proxy-path.js +24 -24
  159. package/dist/middleware/validate-fields.d.ts +7 -4
  160. package/dist/middleware/validate-fields.d.ts.map +1 -0
  161. package/dist/middleware/validate-fields.js +22 -11
  162. package/dist/routes/ancillary.d.ts +1 -0
  163. package/dist/routes/ancillary.d.ts.map +1 -0
  164. package/dist/routes/ancillary.js +3 -10
  165. package/dist/routes/journey.d.ts +7 -2
  166. package/dist/routes/journey.d.ts.map +1 -0
  167. package/dist/routes/journey.js +56 -55
  168. package/dist/routes/static.d.ts +1 -0
  169. package/dist/routes/static.d.ts.map +1 -0
  170. package/dist/routes/static.js +15 -23
  171. package/locales/cy/error.json +1 -0
  172. package/locales/en/error.json +1 -0
  173. package/package.json +32 -38
  174. package/src/casa.js +49 -29
  175. package/src/core-plugins/edit-snapshot/src/post-steer-hook.js +1 -0
  176. package/src/core-plugins/edit-snapshot/src/pre-steer-hook.js +2 -1
  177. package/src/core-plugins/edit-snapshot/src/utils.js +29 -1
  178. package/src/lib/JourneyContext.js +31 -28
  179. package/src/lib/MutableRouter.js +47 -38
  180. package/src/lib/NullObject.js +4 -0
  181. package/src/lib/Plan.js +41 -55
  182. package/src/lib/ValidationError.js +2 -4
  183. package/src/lib/ValidatorFactory.js +3 -5
  184. package/src/lib/configuration-ingestor.js +18 -38
  185. package/src/lib/configure.js +7 -10
  186. package/src/lib/end-session.js +1 -1
  187. package/src/lib/field.js +7 -12
  188. package/src/lib/logger.js +16 -0
  189. package/src/lib/mount.js +1 -1
  190. package/src/lib/nunjucks-filters.js +51 -61
  191. package/src/lib/nunjucks.js +3 -12
  192. package/src/lib/utils.js +2 -1
  193. package/src/lib/validators/dateObject.js +3 -4
  194. package/src/lib/validators/postalAddressObject.js +6 -7
  195. package/src/lib/validators/required.js +1 -3
  196. package/src/lib/waypoint-url.js +15 -19
  197. package/src/middleware/csrf.js +1 -1
  198. package/src/middleware/data.js +13 -13
  199. package/src/middleware/gather-fields.js +8 -2
  200. package/src/middleware/i18n.js +9 -6
  201. package/src/middleware/pre.js +1 -1
  202. package/src/middleware/progress-journey.js +8 -0
  203. package/src/middleware/sanitise-fields.js +17 -2
  204. package/src/middleware/session.js +53 -12
  205. package/src/middleware/skip-waypoint.js +8 -1
  206. package/src/middleware/steer-journey.js +1 -1
  207. package/src/middleware/strip-proxy-path.js +21 -16
  208. package/src/middleware/validate-fields.js +19 -0
  209. package/src/routes/journey.js +18 -8
  210. package/src/routes/static.js +5 -4
  211. package/views/casa/components/character-count/template.njk +1 -0
  212. package/views/casa/components/checkboxes/template.njk +1 -0
  213. package/views/casa/components/date-input/template.njk +1 -0
  214. package/views/casa/components/input/template.njk +1 -0
  215. package/views/casa/components/postal-address-object/template.njk +5 -0
  216. package/views/casa/components/radios/template.njk +1 -0
  217. package/views/casa/components/select/template.njk +1 -0
  218. package/views/casa/components/textarea/template.njk +1 -0
  219. package/views/casa/layouts/journey.njk +1 -1
  220. package/views/casa/layouts/main.njk +11 -21
  221. package/dist/casa.js.map +0 -1
  222. package/dist/core-plugins/edit-snapshot/src/configure.js.map +0 -1
  223. package/dist/core-plugins/edit-snapshot/src/index.js.map +0 -1
  224. package/dist/core-plugins/edit-snapshot/src/post-steer-hook.js.map +0 -1
  225. package/dist/core-plugins/edit-snapshot/src/pre-steer-hook.js.map +0 -1
  226. package/dist/core-plugins/edit-snapshot/src/utils.js.map +0 -1
  227. package/dist/core-plugins/index.js.map +0 -1
  228. package/dist/lib/CasaTemplateLoader.js.map +0 -1
  229. package/dist/lib/JourneyContext.js.map +0 -1
  230. package/dist/lib/MutableRouter.js.map +0 -1
  231. package/dist/lib/Plan.js.map +0 -1
  232. package/dist/lib/ValidationError.js.map +0 -1
  233. package/dist/lib/ValidatorFactory.js.map +0 -1
  234. package/dist/lib/configuration-ingestor.js.map +0 -1
  235. package/dist/lib/configure.js.map +0 -1
  236. package/dist/lib/constants.js.map +0 -1
  237. package/dist/lib/context-id-generators.js.map +0 -1
  238. package/dist/lib/dirname.cjs +0 -1
  239. package/dist/lib/dirname.d.cts +0 -2
  240. package/dist/lib/end-session.js.map +0 -1
  241. package/dist/lib/field.js.map +0 -1
  242. package/dist/lib/index.js.map +0 -1
  243. package/dist/lib/logger.js.map +0 -1
  244. package/dist/lib/mount.js.map +0 -1
  245. package/dist/lib/nunjucks-filters.js.map +0 -1
  246. package/dist/lib/nunjucks.js.map +0 -1
  247. package/dist/lib/utils.js.map +0 -1
  248. package/dist/lib/validators/dateObject.js.map +0 -1
  249. package/dist/lib/validators/email.js.map +0 -1
  250. package/dist/lib/validators/inArray.js.map +0 -1
  251. package/dist/lib/validators/index.js.map +0 -1
  252. package/dist/lib/validators/nino.js.map +0 -1
  253. package/dist/lib/validators/postalAddressObject.js.map +0 -1
  254. package/dist/lib/validators/range.js.map +0 -1
  255. package/dist/lib/validators/regex.js.map +0 -1
  256. package/dist/lib/validators/required.js.map +0 -1
  257. package/dist/lib/validators/strlen.js.map +0 -1
  258. package/dist/lib/validators/wordCount.js.map +0 -1
  259. package/dist/lib/waypoint-url.js.map +0 -1
  260. package/dist/middleware/body-parser.js.map +0 -1
  261. package/dist/middleware/csrf.js.map +0 -1
  262. package/dist/middleware/data.js.map +0 -1
  263. package/dist/middleware/dirname.cjs +0 -1
  264. package/dist/middleware/dirname.d.cts +0 -2
  265. package/dist/middleware/gather-fields.js.map +0 -1
  266. package/dist/middleware/i18n.js.map +0 -1
  267. package/dist/middleware/post.js.map +0 -1
  268. package/dist/middleware/pre.js.map +0 -1
  269. package/dist/middleware/progress-journey.js.map +0 -1
  270. package/dist/middleware/sanitise-fields.js.map +0 -1
  271. package/dist/middleware/serve-first-waypoint.js.map +0 -1
  272. package/dist/middleware/session.js.map +0 -1
  273. package/dist/middleware/skip-waypoint.js.map +0 -1
  274. package/dist/middleware/steer-journey.js.map +0 -1
  275. package/dist/middleware/strip-proxy-path.js.map +0 -1
  276. package/dist/middleware/validate-fields.js.map +0 -1
  277. package/dist/mjs/esm-wrapper.js +0 -20
  278. package/dist/mjs/package.json +0 -3
  279. package/dist/package.json +0 -3
  280. package/dist/routes/ancillary.js.map +0 -1
  281. package/dist/routes/dirname.cjs +0 -1
  282. package/dist/routes/dirname.d.cts +0 -2
  283. package/dist/routes/journey.js.map +0 -1
  284. package/dist/routes/static.js.map +0 -1
  285. package/src/lib/dirname.cjs +0 -1
  286. package/src/middleware/dirname.cjs +0 -1
  287. package/src/routes/dirname.cjs +0 -1
@@ -1,19 +1,23 @@
1
- "use strict";
2
1
  // Sanitise the fields submitted from a form
3
2
  // - Coerce each field to its correct type
4
3
  // - Remove an extraneous fields that are not know to the application
5
- var __importDefault = (this && this.__importDefault) || function (mod) {
6
- return (mod && mod.__esModule) ? mod : { "default": mod };
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- const field_js_1 = __importDefault(require("../lib/field.js"));
10
- const JourneyContext_js_1 = __importDefault(require("../lib/JourneyContext.js"));
11
- exports.default = ({ waypoint, fields = [] }) => {
4
+ import fieldFactory from "../lib/field.js";
5
+ import JourneyContext from "../lib/JourneyContext.js";
6
+ import NullObject from "../lib/NullObject.js";
7
+ /**
8
+ * Get "sanitise fields" middleware for a given waypoint
9
+ *
10
+ * @param {object} opts Options
11
+ * @param {string} opts.waypoint Waypoint
12
+ * @param {PageField[]} opts.fields Fields to sanitise
13
+ * @returns {import("express").RequestHandler[]} Middleware functions
14
+ */
15
+ export default ({ waypoint, fields = [] }) => {
12
16
  // Add some common, transient fields to ensure they survive beyond this sanitisation process
13
- fields.push((0, field_js_1.default)("_csrf", { persist: false }).processor((value) => String(value)));
14
- fields.push((0, field_js_1.default)("contextid", { persist: false }).processor((value) => String(value)));
15
- fields.push((0, field_js_1.default)("edit", { persist: false }).processor((value) => String(value)));
16
- fields.push((0, field_js_1.default)("editorigin", { persist: false }).processor((value) => String(value)));
17
+ fields.push(fieldFactory("_csrf", { persist: false }).processor((value) => String(value)));
18
+ fields.push(fieldFactory("contextid", { persist: false }).processor((value) => String(value)));
19
+ fields.push(fieldFactory("edit", { persist: false }).processor((value) => String(value)));
20
+ fields.push(fieldFactory("editorigin", { persist: false }).processor((value) => String(value)));
17
21
  // Middleware
18
22
  return [
19
23
  (req, res, next) => {
@@ -21,19 +25,20 @@ exports.default = ({ waypoint, fields = [] }) => {
21
25
  // those that do not have an entry in `fields`)
22
26
  // EsLint disabled as `fields`, `i` & `name` are only controlled by dev
23
27
  /* eslint-disable security/detect-object-injection */
24
- const prunedBody = Object.create(null);
28
+ const prunedBody = new NullObject();
25
29
  for (let i = 0, l = fields.length; i < l; i++) {
26
- if (Object.hasOwn(req.body, fields[i].name) &&
30
+ if (req.body &&
31
+ Object.hasOwn(req.body, fields[i].name) &&
27
32
  req.body[fields[i].name] !== undefined) {
28
33
  prunedBody[fields[i].name] = req.body[fields[i].name];
29
34
  }
30
35
  }
31
36
  /* eslint-enable security/detect-object-injection */
32
- const journeyContext = JourneyContext_js_1.default.fromContext(req.casa.journeyContext, req);
37
+ const journeyContext = JourneyContext.fromContext(req.casa.journeyContext, req);
33
38
  journeyContext.setDataForPage(waypoint, prunedBody);
34
39
  // Second, prune any fields that do not pass the validation conditional,
35
40
  // and process those that do.
36
- const sanitisedBody = Object.create(null);
41
+ const sanitisedBody = new NullObject();
37
42
  for (let i = 0, l = fields.length; i < l; i++) {
38
43
  const field = fields[i]; /* eslint-disable-line security/detect-object-injection */
39
44
  const fieldValue = field.getValue(prunedBody);
@@ -52,4 +57,7 @@ exports.default = ({ waypoint, fields = [] }) => {
52
57
  },
53
58
  ];
54
59
  };
55
- //# sourceMappingURL=sanitise-fields.js.map
60
+ /**
61
+ * @typedef {import("../casa").PageField} PageField
62
+ * @access private
63
+ */
@@ -2,3 +2,4 @@ declare function _default({ plan }: Plan): ExpressRequestHandler[];
2
2
  export default _default;
3
3
  export type ExpressRequestHandler = import("express").RequestHandler;
4
4
  export type Plan = import("../casa").Plan;
5
+ //# sourceMappingURL=serve-first-waypoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serve-first-waypoint.d.ts","sourceRoot":"","sources":["../../src/middleware/serve-first-waypoint.js"],"names":[],"mappings":"AAmBe,oCAHJ,IAAI,GACF,qBAAqB,EAAE,CAYnC;;oCA1BY,OAAO,SAAS,EAAE,cAAc;mBAKhC,OAAO,SAAS,EAAE,IAAI"}
@@ -1,6 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_js_1 = require("../lib/utils.js");
1
+ import { validateUrlPath } from "../lib/utils.js";
4
2
  /**
5
3
  * @typedef {import("express").RequestHandler} ExpressRequestHandler
6
4
  * @access private
@@ -16,13 +14,12 @@ const utils_js_1 = require("../lib/utils.js");
16
14
  * @param {Plan} plan CASA Plan
17
15
  * @returns {ExpressRequestHandler[]} Array of middleware
18
16
  */
19
- exports.default = ({ plan }) => [
17
+ export default ({ plan }) => [
20
18
  (req, res) => {
21
19
  const reqUrl = new URL(req.url, "https://placeholder.test/");
22
- const reqPath = (0, utils_js_1.validateUrlPath)(`${req.baseUrl}${reqUrl.pathname}${plan.getWaypoints()[0]}`);
20
+ const reqPath = validateUrlPath(`${req.baseUrl}${reqUrl.pathname}${plan.getWaypoints()[0]}`);
23
21
  let reqParams = reqUrl.searchParams.toString();
24
22
  reqParams = reqParams ? `?${reqParams}` : "";
25
23
  res.redirect(302, `${reqPath}${reqParams}`);
26
24
  },
27
25
  ];
28
- //# sourceMappingURL=serve-first-waypoint.js.map
@@ -26,4 +26,19 @@ export default function sessionMiddleware({ cookieParserMiddleware, secret, name
26
26
  cookiePath?: string | undefined;
27
27
  store?: object | undefined;
28
28
  }): RequestHandler[];
29
+ /**
30
+ * Get the last modified time of the touch cookie
31
+ */
32
+ export type touchModified = (req: ExpressRequest) => any;
33
+ /**
34
+ * Set the touch cookie on the response
35
+ */
36
+ export type touchCookie = (res: ExpressResponse) => any;
37
+ /**
38
+ * Remove the touch cookie on the response
39
+ */
40
+ export type removeTouchCookie = (res: ExpressResponse) => any;
29
41
  export type RequestHandler = import("express").RequestHandler;
42
+ export type ExpressRequest = import("express").Request;
43
+ export type ExpressResponse = import("express").Response;
44
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/middleware/session.js"],"names":[],"mappings":"AA8EA;;;;;;;;;;;;;;;;;GAiBG;AACH,qIAVG;IAA6B,sBAAsB,EAA3C,cAAc;IACD,MAAM,EAAnB,MAAM;IACO,IAAI,EAAjB,MAAM;IACQ,MAAM,EAApB,OAAO;IACM,GAAG,EAAhB,MAAM;IACkB,cAAc;IACxB,UAAU;IACV,KAAK;CAC3B,GAAU,cAAc,EAAE,CA0E5B;;;;kCAIU,cAAc;;;;gCAMd,eAAe;;;;sCAMf,eAAe;6BAKb,OAAO,SAAS,EAAE,cAAc;6BAKhC,OAAO,SAAS,EAAE,OAAO;8BAKzB,OAAO,SAAS,EAAE,QAAQ"}
@@ -1,55 +1,22 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.default = sessionMiddleware;
40
1
  // A last-modified cookie is used to control whether the end user sees a
41
2
  // session-timeout page, or they are simply given a new session without
42
3
  // interrupting their journey.
43
- const express_session_1 = __importStar(require("express-session"));
44
- const logger_js_1 = __importDefault(require("../lib/logger.js"));
45
- const utils_js_1 = require("../lib/utils.js");
4
+ import expressSession, { MemoryStore } from "express-session";
5
+ import logger from "../lib/logger.js";
6
+ import { validateUrlPath } from "../lib/utils.js";
7
+ const log = logger("middleware:session");
46
8
  /**
47
- * @typedef {import("express").RequestHandler} RequestHandler
48
- * @access private
9
+ * Session expiry middleware
10
+ *
11
+ * @param {number} ttl Session data time-to-live
12
+ * @param {lastTouched} lastTouched Function to get last modified time of touch
13
+ * cookie
14
+ * @param {touchCookie} touchCookie Function to reset the touch cookie
15
+ * @param {removeTouchCookie} removeTouchCookie Function to remove touch cookie
16
+ * @returns {RequestHandler} Middleware functions
49
17
  */
50
- const log = (0, logger_js_1.default)("middleware:session");
51
- const sessionExpiryMiddleware = (ttl, getCookie, touchCookie, removeCookie) => (req, res, next) => {
52
- const lastModified = getCookie(req);
18
+ const sessionExpiryMiddleware = (ttl, lastTouched, touchCookie, removeTouchCookie) => (req, res, next) => {
19
+ const lastModified = lastTouched(req);
53
20
  const age = Math.floor(Date.now() * 0.001) - lastModified;
54
21
  if (lastModified === 0) {
55
22
  // New session, or grace period cookie no longer available after
@@ -63,9 +30,9 @@ const sessionExpiryMiddleware = (ttl, getCookie, touchCookie, removeCookie) => (
63
30
  }
64
31
  else {
65
32
  touchCookie(res);
66
- if (req.method === "POST") {
33
+ if (req.method === "POST" && req.body._csrf) {
67
34
  log.info("The CSRF token for this POST request will now be invalid for this regenerated session. Redirecting to app mount point.");
68
- res.redirect(302, (0, utils_js_1.validateUrlPath)(`${req.baseUrl}/`));
35
+ res.redirect(302, validateUrlPath(`${req.baseUrl}/`));
69
36
  }
70
37
  else {
71
38
  next();
@@ -83,12 +50,12 @@ const sessionExpiryMiddleware = (ttl, getCookie, touchCookie, removeCookie) => (
83
50
  next(err);
84
51
  }
85
52
  else {
86
- removeCookie(res);
53
+ removeTouchCookie(res);
87
54
  const params = new URLSearchParams({
88
55
  referrer: req.originalUrl,
89
56
  lang: language,
90
57
  });
91
- res.redirect(302, (0, utils_js_1.validateUrlPath)(`${req.baseUrl}/session-timeout`) +
58
+ res.redirect(302, validateUrlPath(`${req.baseUrl}/session-timeout`) +
92
59
  `?${params.toString()}`);
93
60
  }
94
61
  });
@@ -117,7 +84,7 @@ const sessionExpiryMiddleware = (ttl, getCookie, touchCookie, removeCookie) => (
117
84
  * @param {object} [opts.store] Storage instance
118
85
  * @returns {RequestHandler[]} Middleware functions
119
86
  */
120
- function sessionMiddleware({ cookieParserMiddleware, secret, name, secure, ttl, cookieSameSite = true, cookiePath = "/", store = new express_session_1.MemoryStore(), }) {
87
+ export default function sessionMiddleware({ cookieParserMiddleware, secret, name, secure, ttl, cookieSameSite = true, cookiePath = "/", store = new MemoryStore(), }) {
121
88
  const commonCookieOptions = {
122
89
  httpOnly: true,
123
90
  path: cookiePath,
@@ -134,13 +101,15 @@ function sessionMiddleware({ cookieParserMiddleware, secret, name, secure, ttl,
134
101
  maxAge: (ttl + ttlGrace) * 1000,
135
102
  signed: true,
136
103
  };
137
- const getCookie = (req) => {
104
+ /** @type {lastTouched} */
105
+ const lastTouched = (req) => {
138
106
  // Disabled eslint as `touchCookieName` is a constant, known value
139
107
  const lastModified = Date.parse(
140
108
  /* eslint-disable-next-line security/detect-object-injection */
141
109
  String(req.signedCookies[touchCookieName] ?? "1970-01-01T00:00:00+0000"));
142
110
  return Number.isNaN(lastModified) ? 0 : Math.floor(lastModified * 0.001);
143
111
  };
112
+ /** @type {touchCookie} */
144
113
  const touchCookie = (res) => {
145
114
  // Touch cookie expiry is a short period after the session ttl. This gives
146
115
  // a small period of time where a user will see the session-timeout message,
@@ -148,11 +117,12 @@ function sessionMiddleware({ cookieParserMiddleware, secret, name, secure, ttl,
148
117
  // to the start of their journey.
149
118
  res.cookie(touchCookieName, new Date(Date.now()).toUTCString(), touchCookieOptions);
150
119
  };
151
- const removeCookie = (res) => {
120
+ /** @type {removeTouchCookie} */
121
+ const removeTouchCookie = (res) => {
152
122
  res.clearCookie(touchCookieName, touchCookieOptions);
153
123
  };
154
124
  return [
155
- (0, express_session_1.default)({
125
+ expressSession({
156
126
  secret,
157
127
  name,
158
128
  saveUninitialized: false,
@@ -164,7 +134,33 @@ function sessionMiddleware({ cookieParserMiddleware, secret, name, secure, ttl,
164
134
  store,
165
135
  }),
166
136
  cookieParserMiddleware,
167
- sessionExpiryMiddleware(ttl, getCookie, touchCookie, removeCookie),
137
+ sessionExpiryMiddleware(ttl, lastTouched, touchCookie, removeTouchCookie),
168
138
  ];
169
139
  }
170
- //# sourceMappingURL=session.js.map
140
+ /**
141
+ * @callback touchModified Get the last modified time of the touch cookie
142
+ * @param {ExpressRequest} req Express request
143
+ * @access private
144
+ */
145
+ /**
146
+ * @callback touchCookie Set the touch cookie on the response
147
+ * @param {ExpressResponse} res Express response
148
+ * @access private
149
+ */
150
+ /**
151
+ * @callback removeTouchCookie Remove the touch cookie on the response
152
+ * @param {ExpressResponse} res Express response
153
+ * @access private
154
+ */
155
+ /**
156
+ * @typedef {import("express").RequestHandler} RequestHandler
157
+ * @access private
158
+ */
159
+ /**
160
+ * @typedef {import("express").Request} ExpressRequest
161
+ * @access private
162
+ */
163
+ /**
164
+ * @typedef {import("express").Response} ExpressResponse
165
+ * @access private
166
+ */
@@ -1,4 +1,5 @@
1
1
  declare function _default({ waypoint }: {
2
- waypoint: any;
3
- }): ((req: any, res: any, next: any) => any)[];
2
+ waypoint: string;
3
+ }): import("express").RequestHandler[];
4
4
  export default _default;
5
+ //# sourceMappingURL=skip-waypoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skip-waypoint.d.ts","sourceRoot":"","sources":["../../src/middleware/skip-waypoint.js"],"names":[],"mappings":"AAee,wCAHZ;IAAqB,QAAQ,EAArB,MAAM;CACd,GAAU,OAAO,SAAS,EAAE,cAAc,EAAE,CAgC9C"}
@@ -1,16 +1,18 @@
1
- "use strict";
2
1
  // Mark a waypoint as skipped
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const JourneyContext_js_1 = __importDefault(require("../lib/JourneyContext.js"));
8
- const waypoint_url_js_1 = __importDefault(require("../lib/waypoint-url.js"));
9
- const logger_js_1 = __importDefault(require("../lib/logger.js"));
10
- const log = (0, logger_js_1.default)("middleware:skip-waypoint");
11
- exports.default = ({ waypoint }) => [
2
+ import JourneyContext from "../lib/JourneyContext.js";
3
+ import waypointUrl from "../lib/waypoint-url.js";
4
+ import logger from "../lib/logger.js";
5
+ const log = logger("middleware:skip-waypoint");
6
+ /**
7
+ * Get "skip waypoint" middleware for a given waypoint
8
+ *
9
+ * @param {object} opts Options
10
+ * @param {string} opts.waypoint Waypoint
11
+ * @returns {import("express").RequestHandler[]} Middleware functions
12
+ */
13
+ export default ({ waypoint }) => [
12
14
  (req, res, next) => {
13
- if (!Object.hasOwn(req.query, "skipto")) {
15
+ if (!req.query || !Object.hasOwn(req.query, "skipto")) {
14
16
  return next();
15
17
  }
16
18
  const skipTo = String(req.query.skipto);
@@ -18,8 +20,8 @@ exports.default = ({ waypoint }) => [
18
20
  log.info(`Marking waypoint "${waypoint}" as skipped`);
19
21
  req.casa.journeyContext.clearValidationErrorsForPage(waypoint);
20
22
  req.casa.journeyContext.setSkipped(waypoint, { to: skipTo });
21
- JourneyContext_js_1.default.putContext(req.session, req.casa.journeyContext);
22
- const redirectUrl = (0, waypoint_url_js_1.default)({
23
+ JourneyContext.putContext(req.session, req.casa.journeyContext);
24
+ const redirectUrl = waypointUrl({
23
25
  mountUrl: `${req.baseUrl}/`,
24
26
  waypoint: skipTo,
25
27
  edit: req.casa.editMode,
@@ -37,4 +39,3 @@ exports.default = ({ waypoint }) => [
37
39
  });
38
40
  },
39
41
  ];
40
- //# sourceMappingURL=skip-waypoint.js.map
@@ -1,6 +1,7 @@
1
1
  declare function _default({ waypoint, plan }: {
2
2
  waypoint: string;
3
3
  plan: Plan;
4
- }): void;
4
+ }): import("express").RequestHandler[];
5
5
  export default _default;
6
6
  export type Plan = typeof import("../lib/Plan");
7
+ //# sourceMappingURL=steer-journey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"steer-journey.d.ts","sourceRoot":"","sources":["../../src/middleware/steer-journey.js"],"names":[],"mappings":"AAsBe,8CAJZ;IAAoB,QAAQ,EAApB,MAAM;IACI,IAAI,EAAd,IAAI;CACZ,GAAU,OAAO,SAAS,EAAE,cAAc,EAAE,CAuE9C"}
@@ -1,13 +1,8 @@
1
- "use strict";
2
1
  // This sits in front of all other middleware and prevents the user from
3
2
  // "jumping ahead" in the Plan.
4
- var __importDefault = (this && this.__importDefault) || function (mod) {
5
- return (mod && mod.__esModule) ? mod : { "default": mod };
6
- };
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- const waypoint_url_js_1 = __importDefault(require("../lib/waypoint-url.js"));
9
- const logger_js_1 = __importDefault(require("../lib/logger.js"));
10
- const log = (0, logger_js_1.default)("middleware:steer-journey");
3
+ import waypointUrl from "../lib/waypoint-url.js";
4
+ import logger from "../lib/logger.js";
5
+ const log = logger("middleware:steer-journey");
11
6
  /**
12
7
  * @typedef {import("../lib/Plan")} Plan
13
8
  * @access private
@@ -19,9 +14,9 @@ const log = (0, logger_js_1.default)("middleware:steer-journey");
19
14
  * @param {object} obj Options
20
15
  * @param {string} obj.waypoint Current waypoint
21
16
  * @param {Plan} obj.plan CASA Plan
22
- * @returns {void}
17
+ * @returns {import("express").RequestHandler[]} Middleware functions
23
18
  */
24
- exports.default = ({ waypoint, plan }) => [
19
+ export default ({ waypoint, plan }) => [
25
20
  (req, res, next) => {
26
21
  const mountUrl = `${req.baseUrl}/`;
27
22
  // If the requested waypoint doesn't exist in the traversed journey, send
@@ -30,7 +25,7 @@ exports.default = ({ waypoint, plan }) => [
30
25
  if (traversed.indexOf(waypoint) === -1) {
31
26
  const redirectTo = traversed[traversed.length - 1];
32
27
  log.trace(`Attempted to access "${waypoint}" when not in the journey; redirecting to "${redirectTo}"`);
33
- return res.redirect(302, (0, waypoint_url_js_1.default)({
28
+ return res.redirect(302, waypointUrl({
34
29
  waypoint: redirectTo,
35
30
  mountUrl,
36
31
  journeyContext: req.casa.journeyContext,
@@ -59,7 +54,7 @@ exports.default = ({ waypoint, plan }) => [
59
54
  stopCondition: () => true, // stop at the first one
60
55
  });
61
56
  res.locals.casa.journeyPreviousUrl = prevRoute.target
62
- ? (0, waypoint_url_js_1.default)({
57
+ ? waypointUrl({
63
58
  mountUrl,
64
59
  journeyContext: req.casa.journeyContext,
65
60
  waypoint: prevRoute.target,
@@ -71,4 +66,3 @@ exports.default = ({ waypoint, plan }) => [
71
66
  return next();
72
67
  },
73
68
  ];
74
- //# sourceMappingURL=steer-journey.js.map
@@ -1,4 +1,5 @@
1
1
  declare function _default({ mountUrl }: {
2
- mountUrl?: string | undefined;
3
- }): ((req: any, res: any, next: any) => void)[];
2
+ mountUrl: string;
3
+ }): import("express").RequestHandler[];
4
4
  export default _default;
5
+ //# sourceMappingURL=strip-proxy-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strip-proxy-path.d.ts","sourceRoot":"","sources":["../../src/middleware/strip-proxy-path.js"],"names":[],"mappings":"AAyBe,wCAHZ;IAAqB,QAAQ,EAArB,MAAM;CACd,GAAU,OAAO,SAAS,EAAE,cAAc,EAAE,CAsC9C"}
@@ -1,26 +1,27 @@
1
- "use strict";
2
- // Strip any "proxy path" prefix present on the request URL
3
- //
4
- // The default "mountUrl" will be match whatever path that the CASA app
5
- // instance will be mounted onto. So if you mount on `/a/b/c` then all
6
- // URLs generated for the browser will be prefixed with `/a/b/c`.
7
- //
8
- // Defining a `mountUrl` will change that behaviour into a "proxy mode".
9
- // This mode assumes you have a forwarding proxy that will alter
10
- // the incoming request paths from `mountUrl` to the original path you
11
- // have mounted this CASA app instance onto.
12
- //
13
- // For example, if you mount the app on `/a/b/c/x`, but want the browser
14
- // URLs to just use the `/x` prefix, then pass a `mountUrl` of `/x`.
15
- //
16
- // See docs in `docs/guides/setup-behind-a-proxy.md`
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- const logger_js_1 = __importDefault(require("../lib/logger.js"));
22
- const log = (0, logger_js_1.default)("casa:middleware:strip-proxy-path");
23
- exports.default = ({ mountUrl = "/" }) => [
1
+ import logger from "../lib/logger.js";
2
+ const log = logger("casa:middleware:strip-proxy-path");
3
+ /**
4
+ * Strip any "proxy path" prefix present on the request URL
5
+ *
6
+ * The default "mountUrl" will be match whatever path that the CASA app instance
7
+ * will be mounted onto. So if you mount on `/a/b/c` then all URLs generated for
8
+ * the browser will be prefixed with `/a/b/c`.
9
+ *
10
+ * Defining a `mountUrl` will change that behaviour into a "proxy mode". This
11
+ * mode assumes you have a forwarding proxy that will alter the incoming request
12
+ * paths from `mountUrl` to the original path you have mounted this CASA app
13
+ * instance onto.
14
+ *
15
+ * For example, if you mount the app on `/a/b/c/x`, but want the browser URLs to
16
+ * just use the `/x` prefix, then pass a `mountUrl` of `/x`.
17
+ *
18
+ * See docs in `docs/guides/setup-behind-a-proxy.md`
19
+ *
20
+ * @param {object} opts Options
21
+ * @param {string} opts.mountUrl CASA mount URL
22
+ * @returns {import("express").RequestHandler[]} Middleware functions
23
+ */
24
+ export default ({ mountUrl = "/" }) => [
24
25
  (req, res, next) => {
25
26
  // TODO:
26
27
  // We _may_ have to start tracking the various prefix in order to differentiate
@@ -53,4 +54,3 @@ exports.default = ({ mountUrl = "/" }) => [
53
54
  }
54
55
  },
55
56
  ];
56
- //# sourceMappingURL=strip-proxy-path.js.map
@@ -1,6 +1,9 @@
1
1
  declare function _default({ waypoint, fields, plan }: {
2
- waypoint: any;
3
- fields?: never[] | undefined;
4
- plan: any;
5
- }): ((req: any, res: any, next: any) => any)[];
2
+ waypoint: string;
3
+ fields: PageField[];
4
+ plan: Plan;
5
+ }): import("express").RequestHandler[];
6
6
  export default _default;
7
+ export type Plan = import("../casa").Plan;
8
+ export type PageField = import("../casa").PageField;
9
+ //# sourceMappingURL=validate-fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-fields.d.ts","sourceRoot":"","sources":["../../src/middleware/validate-fields.js"],"names":[],"mappings":"AAkCe,sDALZ;IAAqB,QAAQ,EAArB,MAAM;IACY,MAAM,EAAxB,SAAS,EAAE;IACA,IAAI,EAAf,IAAI;CACZ,GAAU,OAAO,SAAS,EAAE,cAAc,EAAE,CA0D9C;;mBAGY,OAAO,SAAS,EAAE,IAAI;wBAKtB,OAAO,SAAS,EAAE,SAAS"}
@@ -1,11 +1,6 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
1
  // Validate the data captured in the journey context
7
- const JourneyContext_js_1 = __importDefault(require("../lib/JourneyContext.js"));
8
- const constants_js_1 = require("../lib/constants.js");
2
+ import JourneyContext from "../lib/JourneyContext.js";
3
+ import { REQUEST_PHASE_VALIDATE } from "../lib/constants.js";
9
4
  const updateContext = ({ waypoint, errors = null, journeyContext, session, }) => {
10
5
  // Set validation state
11
6
  if (errors === null) {
@@ -15,13 +10,22 @@ const updateContext = ({ waypoint, errors = null, journeyContext, session, }) =>
15
10
  journeyContext.setValidationErrorsForPage(waypoint, errors);
16
11
  }
17
12
  // Save to session
18
- JourneyContext_js_1.default.putContext(session, journeyContext, {
13
+ JourneyContext.putContext(session, journeyContext, {
19
14
  userInfo: {
20
- casaRequestPhase: constants_js_1.REQUEST_PHASE_VALIDATE,
15
+ casaRequestPhase: REQUEST_PHASE_VALIDATE,
21
16
  },
22
17
  });
23
18
  };
24
- exports.default = ({ waypoint, fields = [], plan }) => [
19
+ /**
20
+ * Get "sanitise fields" middleware for a given waypoint
21
+ *
22
+ * @param {object} opts Options
23
+ * @param {string} opts.waypoint Waypoint
24
+ * @param {PageField[]} opts.fields Fields to validate
25
+ * @param {Plan} opts.plan CASA Plan
26
+ * @returns {import("express").RequestHandler[]} Middleware functions
27
+ */
28
+ export default ({ waypoint, fields = [], plan }) => [
25
29
  (req, res, next) => {
26
30
  const mountUrl = `${req.baseUrl}/`;
27
31
  // Run validators for every field to build up a complete list of errors
@@ -71,4 +75,11 @@ exports.default = ({ waypoint, fields = [], plan }) => [
71
75
  return next();
72
76
  },
73
77
  ];
74
- //# sourceMappingURL=validate-fields.js.map
78
+ /**
79
+ * @typedef {import("../casa").Plan} Plan
80
+ * @access private
81
+ */
82
+ /**
83
+ * @typedef {import("../casa").PageField} PageField
84
+ * @access private
85
+ */
@@ -20,3 +20,4 @@ export type AncillaryRouterOptions = {
20
20
  sessionTtl: number;
21
21
  };
22
22
  import MutableRouter from "../lib/MutableRouter.js";
23
+ //# sourceMappingURL=ancillary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ancillary.d.ts","sourceRoot":"","sources":["../../src/routes/ancillary.js"],"names":[],"mappings":"AAEA;;;GAGG;AAEH;;;;;;GAMG;AACH,wDAJW,sBAAsB,GACpB,aAAa,CAezB;;;;;;;;gBAtBa,MAAM;;0BAJM,yBAAyB"}
@@ -1,10 +1,4 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = ancillaryRouter;
7
- const MutableRouter_js_1 = __importDefault(require("../lib/MutableRouter.js"));
1
+ import MutableRouter from "../lib/MutableRouter.js";
8
2
  /**
9
3
  * @typedef {object} AncillaryRouterOptions Options to configure static router
10
4
  * @property {number} sessionTtl Session timeout (seconds)
@@ -16,9 +10,9 @@ const MutableRouter_js_1 = __importDefault(require("../lib/MutableRouter.js"));
16
10
  * @returns {MutableRouter} ExpressJS Router instance
17
11
  * @access private
18
12
  */
19
- function ancillaryRouter({ sessionTtl }) {
13
+ export default function ancillaryRouter({ sessionTtl }) {
20
14
  // Router
21
- const router = new MutableRouter_js_1.default({ mergeParams: true });
15
+ const router = new MutableRouter({ mergeParams: true });
22
16
  // Session timeout
23
17
  router.all("/session-timeout", (req, res) => {
24
18
  res.render("casa/session-timeout.njk", {
@@ -27,4 +21,3 @@ function ancillaryRouter({ sessionTtl }) {
27
21
  });
28
22
  return router;
29
23
  }
30
- //# sourceMappingURL=ancillary.js.map
@@ -8,6 +8,9 @@
8
8
  */
9
9
  export default function journeyRouter({ globalHooks, pages, plan, csrfMiddleware, globalErrorVisibility, }: JourneyRouterOptions): MutableRouter;
10
10
  export function generateGovukErrors(errors: Record<string, ValidationError>, req: import("express").Request): GovUkErrorObject[];
11
+ export type GlobalHook = import("../casa.js").GlobalHook;
12
+ export type Page = import("../casa.js").Page;
13
+ export type Plan = import("../casa.js").Plan;
11
14
  export type ValidationError = import("../casa.js").ValidationError;
12
15
  export type GovUkErrorObject = {
13
16
  /**
@@ -36,8 +39,10 @@ export type JourneyRouterOptions = {
36
39
  */
37
40
  plan: Plan;
38
41
  /**
39
- * Middleware for providing CSRF controls
42
+ * Middleware for
43
+ * providing CSRF controls
40
44
  */
41
- csrfMiddleware: Function[];
45
+ csrfMiddleware: import("express").RequestHandler[];
42
46
  };
43
47
  import MutableRouter from "../lib/MutableRouter.js";
48
+ //# sourceMappingURL=journey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journey.d.ts","sourceRoot":"","sources":["../../src/routes/journey.js"],"names":[],"mappings":"AAkHA;;;;;;;GAOG;AACH,4GAJW,oBAAoB,GAClB,aAAa,CAqPzB;AA3RM,4CALI,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,OAE/B,OAAO,SAAS,EAAE,OAAO,GACvB,gBAAgB,EAAE,CAM1B;yBArEQ,OAAO,YAAY,EAAE,UAAU;mBAK/B,OAAO,YAAY,EAAE,IAAI;mBAKzB,OAAO,YAAY,EAAE,IAAI;8BAIxB,OAAO,YAAY,EAAE,eAAe;;;;;UAIpC,MAAM;;;;UACN,MAAM;;;;;;;;;iBAKN,UAAU,EAAE;;;;WACZ,IAAI,EAAE;;;;UACN,IAAI;;;;;oBACJ,OAAO,SAAS,EAAE,cAAc,EAAE;;0BA3CtB,yBAAyB"}