hof 22.9.0-beta.v1 → 22.9.0-beta.v3

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 (316) hide show
  1. package/config/hof-defaults.js +1 -0
  2. package/frontend/template-partials/views/cookies.html +6 -6
  3. package/frontend/template-partials/views/partials/cookie-banner.html +11 -6
  4. package/lib/settings.js +1 -0
  5. package/package.json +1 -1
  6. package/package/.eslintignore +0 -1
  7. package/package/CHANGELOG.md +0 -232
  8. package/package/LICENSE +0 -21
  9. package/package/README.md +0 -1887
  10. package/package/bin/hof-build +0 -10
  11. package/package/bin/hof-transpiler +0 -12
  12. package/package/build/helpers/importer.js +0 -29
  13. package/package/build/helpers/local.js +0 -35
  14. package/package/build/helpers/resolver/import.js +0 -32
  15. package/package/build/helpers/resolver/nearest-package-root.js +0 -33
  16. package/package/build/helpers/resolver/package.js +0 -29
  17. package/package/build/helpers/resolver.js +0 -16
  18. package/package/build/index.js +0 -49
  19. package/package/build/lib/env.js +0 -36
  20. package/package/build/lib/mkdir.js +0 -9
  21. package/package/build/lib/run.js +0 -17
  22. package/package/build/lib/spawn.js +0 -18
  23. package/package/build/tasks/browserify/compress.js +0 -15
  24. package/package/build/tasks/browserify/index.js +0 -48
  25. package/package/build/tasks/build/index.js +0 -6
  26. package/package/build/tasks/images/index.js +0 -27
  27. package/package/build/tasks/index.js +0 -8
  28. package/package/build/tasks/sass/index.js +0 -67
  29. package/package/build/tasks/translate/index.js +0 -20
  30. package/package/build/tasks/watch/index.js +0 -161
  31. package/package/components/address-lookup/default-model.js +0 -76
  32. package/package/components/address-lookup/defaults.js +0 -25
  33. package/package/components/address-lookup/index.js +0 -251
  34. package/package/components/address-lookup/templates/address-lookup.html +0 -14
  35. package/package/components/address-lookup/templates/address.html +0 -22
  36. package/package/components/address-lookup/templates/postcode.html +0 -9
  37. package/package/components/clear-session/Readme.md +0 -46
  38. package/package/components/clear-session/index.js +0 -26
  39. package/package/components/combine-and-loop-fields/Readme.md +0 -42
  40. package/package/components/combine-and-loop-fields/index.js +0 -156
  41. package/package/components/date/fields.js +0 -16
  42. package/package/components/date/index.js +0 -172
  43. package/package/components/date/templates/date.html +0 -20
  44. package/package/components/emailer/assets/images/govuk_logotype_email.png +0 -0
  45. package/package/components/emailer/assets/images/ho_crest_27px.png +0 -0
  46. package/package/components/emailer/assets/images/spacer.gif +0 -0
  47. package/package/components/emailer/email-service.js +0 -51
  48. package/package/components/emailer/emailer.js +0 -53
  49. package/package/components/emailer/index.js +0 -74
  50. package/package/components/emailer/transports/debug.js +0 -74
  51. package/package/components/emailer/transports/index.js +0 -8
  52. package/package/components/emailer/transports/ses.js +0 -36
  53. package/package/components/emailer/transports/smtp.js +0 -26
  54. package/package/components/emailer/transports/stub.js +0 -5
  55. package/package/components/emailer/views/layout.html +0 -63
  56. package/package/components/homeoffice-countries/index.js +0 -22
  57. package/package/components/index.js +0 -13
  58. package/package/components/notify/index.js +0 -62
  59. package/package/components/notify/notify.js +0 -51
  60. package/package/components/session-timeout-warning/index.js +0 -67
  61. package/package/components/summary/index.js +0 -237
  62. package/package/config/builder-defaults.js +0 -45
  63. package/package/config/component-defaults.js +0 -13
  64. package/package/config/hof-defaults.js +0 -65
  65. package/package/config/rate-limits.js +0 -20
  66. package/package/config/sanitisation-rules.js +0 -32
  67. package/package/controller/base-controller.js +0 -296
  68. package/package/controller/behaviour-hooks.js +0 -51
  69. package/package/controller/behaviour-session.js +0 -64
  70. package/package/controller/controller.js +0 -258
  71. package/package/controller/deprecate-error.js +0 -10
  72. package/package/controller/formatting/formatters.js +0 -70
  73. package/package/controller/formatting/index.js +0 -32
  74. package/package/controller/index.js +0 -17
  75. package/package/controller/validation/email.js +0 -30
  76. package/package/controller/validation/index.js +0 -101
  77. package/package/controller/validation/validators.js +0 -181
  78. package/package/controller/validation-error.js +0 -14
  79. package/package/frontend/govuk-template/build/config.js +0 -24
  80. package/package/frontend/govuk-template/build/govuk_template.html +0 -102
  81. package/package/frontend/govuk-template/build/index.js +0 -23
  82. package/package/frontend/govuk-template/govuk_template_generated.html +0 -102
  83. package/package/frontend/govuk-template/index.js +0 -29
  84. package/package/frontend/index.js +0 -9
  85. package/package/frontend/template-mixins/mixins/helpers.js +0 -103
  86. package/package/frontend/template-mixins/mixins/index.js +0 -37
  87. package/package/frontend/template-mixins/mixins/render.js +0 -12
  88. package/package/frontend/template-mixins/mixins/template-mixins.js +0 -520
  89. package/package/frontend/template-mixins/partials/forms/checkbox-group.html +0 -47
  90. package/package/frontend/template-mixins/partials/forms/checkbox.html +0 -16
  91. package/package/frontend/template-mixins/partials/forms/input-submit.html +0 -1
  92. package/package/frontend/template-mixins/partials/forms/input-text-date.html +0 -37
  93. package/package/frontend/template-mixins/partials/forms/input-text-group.html +0 -45
  94. package/package/frontend/template-mixins/partials/forms/option-group.html +0 -43
  95. package/package/frontend/template-mixins/partials/forms/select.html +0 -17
  96. package/package/frontend/template-mixins/partials/forms/textarea-group.html +0 -37
  97. package/package/frontend/template-mixins/partials/mixins/panel.html +0 -4
  98. package/package/frontend/template-partials/index.js +0 -9
  99. package/package/frontend/template-partials/translations/index.js +0 -26
  100. package/package/frontend/template-partials/translations/src/cy/base.json +0 -4
  101. package/package/frontend/template-partials/translations/src/cy/buttons.json +0 -6
  102. package/package/frontend/template-partials/translations/src/cy/cookies.json +0 -104
  103. package/package/frontend/template-partials/translations/src/cy/errorlist.json +0 -6
  104. package/package/frontend/template-partials/translations/src/cy/errors.json +0 -18
  105. package/package/frontend/template-partials/translations/src/cy/terms.json +0 -28
  106. package/package/frontend/template-partials/translations/src/en/accessibility.json +0 -43
  107. package/package/frontend/template-partials/translations/src/en/base.json +0 -5
  108. package/package/frontend/template-partials/translations/src/en/buttons.json +0 -10
  109. package/package/frontend/template-partials/translations/src/en/cookies.json +0 -116
  110. package/package/frontend/template-partials/translations/src/en/errorlist.json +0 -7
  111. package/package/frontend/template-partials/translations/src/en/errors.json +0 -35
  112. package/package/frontend/template-partials/translations/src/en/exit.json +0 -5
  113. package/package/frontend/template-partials/translations/src/en/fields.json +0 -5
  114. package/package/frontend/template-partials/translations/src/en/journey.json +0 -6
  115. package/package/frontend/template-partials/translations/src/en/save-and-exit.json +0 -4
  116. package/package/frontend/template-partials/translations/src/en/terms.json +0 -28
  117. package/package/frontend/template-partials/views/404.html +0 -9
  118. package/package/frontend/template-partials/views/accessibility.html +0 -55
  119. package/package/frontend/template-partials/views/confirm.html +0 -8
  120. package/package/frontend/template-partials/views/confirmation.html +0 -19
  121. package/package/frontend/template-partials/views/content/en/what-happens-next.md +0 -0
  122. package/package/frontend/template-partials/views/cookie-error.html +0 -1
  123. package/package/frontend/template-partials/views/cookies.html +0 -84
  124. package/package/frontend/template-partials/views/email/data-row.html +0 -4
  125. package/package/frontend/template-partials/views/email/formatted.html +0 -12
  126. package/package/frontend/template-partials/views/email/layout.html +0 -63
  127. package/package/frontend/template-partials/views/email/raw.html +0 -11
  128. package/package/frontend/template-partials/views/email/section-row.html +0 -3
  129. package/package/frontend/template-partials/views/error.html +0 -20
  130. package/package/frontend/template-partials/views/exit.html +0 -9
  131. package/package/frontend/template-partials/views/feedback-submitted.html +0 -11
  132. package/package/frontend/template-partials/views/layout.html +0 -55
  133. package/package/frontend/template-partials/views/partials/analytics-table.html +0 -25
  134. package/package/frontend/template-partials/views/partials/back.html +0 -5
  135. package/package/frontend/template-partials/views/partials/bullet-list.html +0 -7
  136. package/package/frontend/template-partials/views/partials/confirmation-alert.html +0 -6
  137. package/package/frontend/template-partials/views/partials/continue.html +0 -5
  138. package/package/frontend/template-partials/views/partials/cookie-banner.html +0 -29
  139. package/package/frontend/template-partials/views/partials/cookie-notification.html +0 -4
  140. package/package/frontend/template-partials/views/partials/cookie-settings-button.html +0 -1
  141. package/package/frontend/template-partials/views/partials/cookie-settings-radio.html +0 -8
  142. package/package/frontend/template-partials/views/partials/details-summary.html +0 -8
  143. package/package/frontend/template-partials/views/partials/external-link.html +0 -1
  144. package/package/frontend/template-partials/views/partials/form.html +0 -10
  145. package/package/frontend/template-partials/views/partials/gatag.html +0 -60
  146. package/package/frontend/template-partials/views/partials/head.html +0 -31
  147. package/package/frontend/template-partials/views/partials/heading.html +0 -11
  148. package/package/frontend/template-partials/views/partials/items-table.html +0 -32
  149. package/package/frontend/template-partials/views/partials/maincontent-left.html +0 -10
  150. package/package/frontend/template-partials/views/partials/navigation.html +0 -8
  151. package/package/frontend/template-partials/views/partials/page.html +0 -23
  152. package/package/frontend/template-partials/views/partials/panel-indent.html +0 -3
  153. package/package/frontend/template-partials/views/partials/session-cookies-table.html +0 -28
  154. package/package/frontend/template-partials/views/partials/session-timeout-warning.html +0 -38
  155. package/package/frontend/template-partials/views/partials/summary-table-row.html +0 -14
  156. package/package/frontend/template-partials/views/partials/summary-table.html +0 -8
  157. package/package/frontend/template-partials/views/partials/table.html +0 -18
  158. package/package/frontend/template-partials/views/partials/validation-list.html +0 -3
  159. package/package/frontend/template-partials/views/partials/validation-summary.html +0 -25
  160. package/package/frontend/template-partials/views/partials/warn.html +0 -7
  161. package/package/frontend/template-partials/views/rate-limit-error.html +0 -10
  162. package/package/frontend/template-partials/views/save-and-exit.html +0 -17
  163. package/package/frontend/template-partials/views/service-unavailable.html +0 -13
  164. package/package/frontend/template-partials/views/session-timeout.html +0 -7
  165. package/package/frontend/template-partials/views/step.html +0 -14
  166. package/package/frontend/template-partials/views/terms.html +0 -26
  167. package/package/frontend/themes/gov-uk/client-js/cookieSettings.js +0 -145
  168. package/package/frontend/themes/gov-uk/client-js/govuk-cookies.js +0 -121
  169. package/package/frontend/themes/gov-uk/client-js/index.js +0 -27
  170. package/package/frontend/themes/gov-uk/client-js/session-timeout-dialog.js +0 -348
  171. package/package/frontend/themes/gov-uk/client-js/skip-to-main.js +0 -19
  172. package/package/frontend/themes/gov-uk/index.js +0 -9
  173. package/package/frontend/themes/gov-uk/styles/_base.scss +0 -17
  174. package/package/frontend/themes/gov-uk/styles/_check_your_answers.scss +0 -155
  175. package/package/frontend/themes/gov-uk/styles/_cookie-banner.scss +0 -111
  176. package/package/frontend/themes/gov-uk/styles/_cookie-settings.scss +0 -33
  177. package/package/frontend/themes/gov-uk/styles/_govuk_frontend_toolkit.scss +0 -23
  178. package/package/frontend/themes/gov-uk/styles/_helpers.scss +0 -5
  179. package/package/frontend/themes/gov-uk/styles/_layout.scss +0 -125
  180. package/package/frontend/themes/gov-uk/styles/_panel-indent.scss +0 -27
  181. package/package/frontend/themes/gov-uk/styles/_pdf.scss +0 -42
  182. package/package/frontend/themes/gov-uk/styles/_session-timeout-dialog.scss +0 -121
  183. package/package/frontend/themes/gov-uk/styles/_typography.scss +0 -27
  184. package/package/frontend/themes/gov-uk/styles/_variables.scss +0 -11
  185. package/package/frontend/themes/gov-uk/styles/govuk.scss +0 -43
  186. package/package/frontend/themes/gov-uk/styles/mixins.scss +0 -16
  187. package/package/frontend/themes/gov-uk/styles/modules/_alerts.scss +0 -73
  188. package/package/frontend/themes/gov-uk/styles/modules/_buttons.scss +0 -5
  189. package/package/frontend/themes/gov-uk/styles/modules/_character-count.scss +0 -8
  190. package/package/frontend/themes/gov-uk/styles/modules/_confirm-page.scss +0 -20
  191. package/package/frontend/themes/gov-uk/styles/modules/_lists.scss +0 -5
  192. package/package/frontend/themes/gov-uk/styles/modules/_progressive-reveal.scss +0 -17
  193. package/package/frontend/themes/gov-uk/styles/modules/_validation.scss +0 -51
  194. package/package/frontend/themes/index.js +0 -5
  195. package/package/frontend/toolkit/assets/images/passports/new-window-link-blue.png +0 -0
  196. package/package/frontend/toolkit/assets/images/passports/new-window-link.png +0 -0
  197. package/package/frontend/toolkit/assets/images/spinner.gif +0 -0
  198. package/package/frontend/toolkit/assets/javascript/character-count.js +0 -99
  199. package/package/frontend/toolkit/assets/javascript/form-focus.js +0 -101
  200. package/package/frontend/toolkit/assets/javascript/helpers.js +0 -177
  201. package/package/frontend/toolkit/assets/javascript/progressive-reveal.js +0 -72
  202. package/package/frontend/toolkit/assets/javascript/validation.js +0 -71
  203. package/package/frontend/toolkit/assets/javascript/vendor/details.polyfill.js +0 -189
  204. package/package/frontend/toolkit/assets/javascript/vendor/indexof.polyfill.js +0 -39
  205. package/package/frontend/toolkit/assets/javascript/vendor/safari-cachebuster.js +0 -6
  206. package/package/frontend/toolkit/assets/stylesheets/_base.scss +0 -17
  207. package/package/frontend/toolkit/assets/stylesheets/_helpers.scss +0 -5
  208. package/package/frontend/toolkit/assets/stylesheets/_layout.scss +0 -118
  209. package/package/frontend/toolkit/assets/stylesheets/_typography.scss +0 -27
  210. package/package/frontend/toolkit/assets/stylesheets/_variables.scss +0 -11
  211. package/package/frontend/toolkit/assets/stylesheets/app.scss +0 -30
  212. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_buttons.scss +0 -47
  213. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_details.scss +0 -38
  214. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_elements-typography.scss +0 -175
  215. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_forms.scss +0 -167
  216. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_helpers.scss +0 -39
  217. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_layout.scss +0 -67
  218. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_lists.scss +0 -40
  219. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_panels.scss +0 -29
  220. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_reset.scss +0 -33
  221. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_tables.scss +0 -33
  222. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/forms/_form-block-labels.scss +0 -63
  223. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/forms/_form-date.scss +0 -39
  224. package/package/frontend/toolkit/assets/stylesheets/govuk-elements/forms/_form-validation.scss +0 -63
  225. package/package/frontend/toolkit/assets/stylesheets/mixins.scss +0 -16
  226. package/package/frontend/toolkit/assets/stylesheets/modules/_alerts.scss +0 -73
  227. package/package/frontend/toolkit/assets/stylesheets/modules/_buttons.scss +0 -5
  228. package/package/frontend/toolkit/assets/stylesheets/modules/_confirm-page.scss +0 -20
  229. package/package/frontend/toolkit/assets/stylesheets/modules/_lists.scss +0 -5
  230. package/package/frontend/toolkit/assets/stylesheets/modules/_progressive-reveal.scss +0 -17
  231. package/package/frontend/toolkit/assets/stylesheets/modules/_validation.scss +0 -51
  232. package/package/frontend/toolkit/index.js +0 -10
  233. package/package/index.js +0 -351
  234. package/package/lib/deindex.js +0 -18
  235. package/package/lib/encryption.js +0 -23
  236. package/package/lib/ga-tag.js +0 -89
  237. package/package/lib/health.js +0 -26
  238. package/package/lib/helpers.js +0 -66
  239. package/package/lib/logger.js +0 -65
  240. package/package/lib/markdown.js +0 -46
  241. package/package/lib/router.js +0 -111
  242. package/package/lib/serve-static.js +0 -12
  243. package/package/lib/sessions.js +0 -82
  244. package/package/lib/settings.js +0 -74
  245. package/package/lib/which.js +0 -28
  246. package/package/middleware/cookies.js +0 -43
  247. package/package/middleware/deep-translate.js +0 -32
  248. package/package/middleware/errors.js +0 -119
  249. package/package/middleware/index.js +0 -10
  250. package/package/middleware/not-found.js +0 -38
  251. package/package/middleware/rate-limiter.js +0 -98
  252. package/package/middleware/service-unavailable.js +0 -64
  253. package/package/model/apis/axios-settings.js +0 -21
  254. package/package/model/apis/html-to-pdf-converter.js +0 -35
  255. package/package/model/apis/index.js +0 -5
  256. package/package/model/index.js +0 -348
  257. package/package/package.json +0 -147
  258. package/package/sandbox/README.md +0 -66
  259. package/package/sandbox/apps/sandbox/behaviours/clear-session.js +0 -8
  260. package/package/sandbox/apps/sandbox/behaviours/country-select.js +0 -10
  261. package/package/sandbox/apps/sandbox/behaviours/international-number.js +0 -22
  262. package/package/sandbox/apps/sandbox/fields.js +0 -128
  263. package/package/sandbox/apps/sandbox/index.js +0 -99
  264. package/package/sandbox/apps/sandbox/lib/staticAppealStages.js +0 -189
  265. package/package/sandbox/apps/sandbox/sections/summary-data-sections.js +0 -43
  266. package/package/sandbox/apps/sandbox/translations/src/en/errors.json +0 -5
  267. package/package/sandbox/apps/sandbox/translations/src/en/exit.json +0 -4
  268. package/package/sandbox/apps/sandbox/translations/src/en/fields.json +0 -101
  269. package/package/sandbox/apps/sandbox/translations/src/en/journey.json +0 -7
  270. package/package/sandbox/apps/sandbox/translations/src/en/pages.json +0 -72
  271. package/package/sandbox/apps/sandbox/translations/src/en/validation.json +0 -54
  272. package/package/sandbox/apps/sandbox/views/form-guidance-link.html +0 -8
  273. package/package/sandbox/apps/sandbox/views/save-and-exit.html +0 -19
  274. package/package/sandbox/assets/images/icons/icon-caret-left.png +0 -0
  275. package/package/sandbox/assets/images/icons/icon-complete.png +0 -0
  276. package/package/sandbox/assets/images/icons/icon-cross-remove-sign.png +0 -0
  277. package/package/sandbox/assets/js/index.js +0 -70
  278. package/package/sandbox/assets/scss/app.scss +0 -27
  279. package/package/sandbox/codecept.conf.js +0 -15
  280. package/package/sandbox/config.js +0 -17
  281. package/package/sandbox/package.json +0 -26
  282. package/package/sandbox/server.js +0 -23
  283. package/package/sandbox/yarn.lock +0 -262
  284. package/package/transpiler/index.js +0 -2
  285. package/package/transpiler/lib/aggregate.js +0 -32
  286. package/package/transpiler/lib/build.js +0 -15
  287. package/package/transpiler/lib/compile.js +0 -12
  288. package/package/transpiler/lib/expand-dirs.js +0 -14
  289. package/package/transpiler/lib/write-files.js +0 -24
  290. package/package/utilities/autofill/index.js +0 -189
  291. package/package/utilities/autofill/inputs.js +0 -60
  292. package/package/utilities/countries.js +0 -12
  293. package/package/utilities/helpers/index.js +0 -189
  294. package/package/utilities/index.js +0 -9
  295. package/package/utilities/reqres/index.js +0 -18
  296. package/package/utilities/test-data/data/domain.json +0 -7
  297. package/package/utilities/test-data/data/firstname.json +0 -16
  298. package/package/utilities/test-data/data/lastname.json +0 -10
  299. package/package/utilities/test-data/data/postcode.json +0 -12
  300. package/package/utilities/test-data/data/streetname.json +0 -8
  301. package/package/utilities/test-data/data/streetsuffix.json +0 -7
  302. package/package/utilities/test-data/data/town.json +0 -9
  303. package/package/utilities/test-data/index.js +0 -67
  304. package/package/wizard/behaviours/complete.js +0 -20
  305. package/package/wizard/behaviours/index.js +0 -5
  306. package/package/wizard/index.js +0 -124
  307. package/package/wizard/middleware/back-links.js +0 -68
  308. package/package/wizard/middleware/check-complete.js +0 -13
  309. package/package/wizard/middleware/check-progress.js +0 -139
  310. package/package/wizard/middleware/check-session.js +0 -17
  311. package/package/wizard/middleware/csrf.js +0 -47
  312. package/package/wizard/middleware/session-model.js +0 -11
  313. package/package/wizard/middleware/session.js +0 -9
  314. package/package/wizard/model.js +0 -29
  315. package/package/wizard/util/constants.js +0 -5
  316. package/package/wizard/util/helpers.js +0 -19
@@ -1,65 +0,0 @@
1
- 'use strict';
2
-
3
- const winston = require('winston');
4
- const { createLogger, format, transports } = winston;
5
- const { combine, timestamp, colorize, simple, json } = format;
6
- const util = require('util');
7
-
8
- module.exports = config => {
9
- const loggingTransports = [];
10
- const exceptionTransports = [];
11
- const notProd = config.env !== 'production';
12
- const isLocal = notProd && config.env !== 'development';
13
-
14
- loggingTransports.push(
15
- new transports.Console({
16
- format: isLocal ? combine(
17
- colorize(),
18
- simple()
19
- ) : json(),
20
- silent: config.loglevel === 'silent' || config.env === 'test',
21
- level: config.loglevel || 'info'
22
- })
23
- );
24
-
25
- exceptionTransports.push(
26
- new transports.Console({
27
- format: isLocal ? combine(
28
- colorize(),
29
- simple()
30
- ) : json()
31
- })
32
- );
33
-
34
- const loggerConfig = {
35
- format: combine(
36
- timestamp()
37
- ),
38
- exitOnError: false,
39
- transports: loggingTransports,
40
- exceptionHandlers: exceptionTransports
41
- };
42
-
43
- if (notProd) {
44
- delete loggerConfig.exceptionHandlers;
45
- }
46
-
47
- const logger = createLogger(loggerConfig);
48
-
49
- logger.stream = {
50
- write: message => {
51
- if (config.loglevel === 'debug') {
52
- logger.debug(message);
53
- } else {
54
- logger.info(message);
55
- }
56
- }
57
- };
58
-
59
- logger.logSession = id => (level, ...args) => {
60
- const msg = util.format(...args);
61
- return logger.log(level, `sessionId=${id} ${msg}`);
62
- };
63
-
64
- return logger;
65
- };
@@ -1,46 +0,0 @@
1
- 'use strict';
2
-
3
- const MarkdownIt = require('markdown-it');
4
- const converter = new MarkdownIt({html: true});
5
-
6
- const path = require('path');
7
- const fs = require('fs');
8
- const _ = require('lodash');
9
-
10
- const cache = {};
11
-
12
- module.exports = conf => {
13
- const config = conf || {};
14
- config.dir = config.dir || 'content';
15
- config.method = config.method || 'markdown';
16
- config.fallbackLang = config.fallbackLang || ['en', ''];
17
- config.ext = config.ext || 'md';
18
- return (req, res, next) => {
19
- const View = req.app.get('view');
20
- res.locals[config.method] = () => file => {
21
- if (!file) {
22
- throw new Error('markdown: filename must be specified');
23
- }
24
- const views = req.app.get('views');
25
- const languages = _.uniq([].concat(req.lang).concat(config.fallbackLang)).filter(a => typeof a === 'string');
26
- const paths = views.map(dir => languages.map(lang => path.resolve(dir, config.dir, lang.toLowerCase())));
27
-
28
- // use express' `View` class to shortcut looking up files
29
- const view = new View(file, {
30
- defaultEngine: config.ext,
31
- root: _.flatten(paths),
32
- engines: { [`.${config.ext}`]: {} }
33
- });
34
-
35
- if (!view.path) {
36
- throw new Error(`Could not find content: ${file}`);
37
- }
38
-
39
- const md = cache[view.path] || fs.readFileSync(view.path).toString('utf8');
40
- cache[view.path] = md;
41
-
42
- return converter.render(md);
43
- };
44
- next();
45
- };
46
- };
@@ -1,111 +0,0 @@
1
- 'use strict';
2
-
3
- const _ = require('lodash');
4
- const express = require('express');
5
- const wizard = require('../wizard');
6
- const translate = require('i18n-future').middleware;
7
- const deepTranslate = require('../middleware').deepTranslate;
8
- const expressPartialTemplates = require('express-partial-templates');
9
- const helpers = require('./helpers');
10
- const deprecate = require('deprecate');
11
-
12
- function applyBehaviours(steps, behaviours) {
13
- _.each(steps, step => {
14
- step.behaviours = [].concat(behaviours).concat(step.behaviours).filter(a => a);
15
- });
16
- }
17
-
18
- function getWizardConfig(config) {
19
- const wizardConfig = {
20
- name: config.route.name || (config.route.baseUrl || '').replace('/', ''),
21
- protocol: config.protocol,
22
- env: config.env,
23
- sanitiseInputs: config.sanitiseInputs
24
- };
25
-
26
- if (config.appConfig) {
27
- wizardConfig.appConfig = config.appConfig;
28
- }
29
-
30
- // whitelist properties from the route's config that should be passed into the form wizard
31
- const props = [
32
- 'confirmStep',
33
- 'exitStep',
34
- 'saveAndExitStep',
35
- 'params'
36
- ];
37
- Object.assign(wizardConfig, _.pick(config.route, props));
38
-
39
- return wizardConfig;
40
- }
41
-
42
- const returnBaseUrl = (url = '') => {
43
- const splitUrl = url.split('/');
44
-
45
- return splitUrl.length > 2 ? `/${splitUrl[1]}` : '/';
46
- };
47
-
48
- module.exports = config => {
49
- const app = express();
50
- const paths = helpers.getPaths(config);
51
- const fields = helpers.getFields(paths.fields);
52
- const routeViews = helpers.getViews(paths.views, config.route.views);
53
- const sharedViews = config.sharedViews;
54
-
55
- const views = routeViews ? [routeViews].concat(sharedViews) : sharedViews;
56
-
57
- app.set('x-powered-by', false);
58
- app.set('view engine', config.viewEngine);
59
- app.set('views', views);
60
-
61
- app.use(expressPartialTemplates(app));
62
-
63
- app.use(translate({
64
- resources: config.theme.translations,
65
- path: paths.translations + '/__lng__/__ns__.json'
66
- }));
67
- app.use(deepTranslate());
68
-
69
- const wizardConfig = getWizardConfig(config);
70
-
71
- if (config.baseController) {
72
- deprecate(
73
- '`baseController` option is deprecated and may be removed in future versions.',
74
- 'Use `behaviours` option to define global behaviours.'
75
- );
76
- wizardConfig.controller = config.baseController;
77
- }
78
-
79
- if (config.route.behaviours) {
80
- applyBehaviours(config.route.steps, config.route.behaviours);
81
- }
82
-
83
- if (config.behaviours) {
84
- applyBehaviours(config.route.steps, config.behaviours);
85
- }
86
-
87
- Object.keys(config.route.pages || {}).forEach(path => {
88
- app.get(path, (req, res) => {
89
- let objPath = config.route.pages[path];
90
-
91
- if (typeof objPath === 'string') {
92
- objPath = {
93
- template: objPath,
94
- title: objPath
95
- };
96
- }
97
- res.locals = Object.assign(res.locals, {
98
- baseUrl: returnBaseUrl(req.originalUrl),
99
- refererUrl: req.headers.referer,
100
- title: objPath.title
101
- });
102
- return res.render(objPath.template);
103
- });
104
- });
105
-
106
- if (config.route.steps) {
107
- app.use(wizard(config.route.steps, fields, wizardConfig));
108
- }
109
-
110
- return app;
111
- };
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- const express = require('express');
4
- const path = require('path');
5
-
6
- module.exports = (app, config) => {
7
- if (config.serveStatic !== false) {
8
- app.use('/public', express.static(path.resolve(config.root, 'public')));
9
- }
10
-
11
- return app;
12
- };
@@ -1,82 +0,0 @@
1
- 'use strict';
2
-
3
- const redis = require('redis');
4
- const session = require('express-session');
5
- const connectRedis = require('connect-redis');
6
- const cookieParser = require('cookie-parser');
7
-
8
- const secureHttps = config => config.protocol === 'https' || config.env === 'production';
9
-
10
- module.exports = (app, config) => {
11
- const logger = config.logger || console;
12
-
13
- if (config.env === 'production' && config.session.secret === 'changethis') {
14
- throw new Error('Session secret must be set to a unique random string for production environments');
15
- }
16
-
17
- app.use(cookieParser(config.session.secret, {
18
- path: '/',
19
- httpOnly: true,
20
- secure: secureHttps(config)
21
- }));
22
-
23
- if (config.sessionStore) {
24
- return app.use(session({
25
- store: config.sessionStore,
26
- genid: () => 'fakeId',
27
- saveUninitialized: true,
28
- resave: false
29
- }));
30
- }
31
-
32
- const encryption = require('./encryption')(config.session.secret);
33
- const RedisStore = connectRedis(session);
34
- const client = redis.createClient(config.redis);
35
-
36
- if (config.env !== 'test') {
37
- client.on('connecting', () => {
38
- logger.info('Connecting to redis');
39
- });
40
-
41
- client.on('connect', () => {
42
- logger.info('Connected to redis');
43
- });
44
-
45
- client.on('reconnecting', () => {
46
- logger.info('Reconnecting to redis');
47
- });
48
-
49
- client.on('error', e => {
50
- logger.error(e);
51
- });
52
- }
53
-
54
- const store = new RedisStore({
55
- client: client,
56
- ttl: config.session.ttl,
57
- secret: config.session.secret,
58
- serializer: {
59
- parse: data => JSON.parse(encryption.decrypt(data)),
60
- stringify: data => encryption.encrypt(JSON.stringify(data))
61
- }
62
- });
63
-
64
- app.set('trust proxy', true);
65
-
66
- const sessionOpts = Object.assign({
67
- store,
68
- name: config.session.name,
69
- cookie: {
70
- secure: secureHttps(config),
71
- sameSite: config.cookie?.sameSite === 'lax' ? config.cookie?.sameSite : 'strict',
72
- httpOnly: true
73
- },
74
- secret: config.session.secret,
75
- saveUninitialized: true,
76
- resave: true
77
- }, config.session);
78
-
79
- app.use(session(sessionOpts));
80
-
81
- return client;
82
- };
@@ -1,74 +0,0 @@
1
- 'use strict';
2
-
3
- const _ = require('lodash');
4
- const fs = require('fs');
5
- const path = require('path');
6
- const hoganExpressStrict = require('hogan-express-strict');
7
- const expressPartialTemplates = require('express-partial-templates');
8
- const bodyParser = require('body-parser');
9
-
10
- const dirExists = dir => {
11
- try {
12
- if (fs.existsSync(dir)) {
13
- return true;
14
- }
15
- return false;
16
- } catch(err) {
17
- throw new Error(`${err}: Cannot check if the directory path exists`);
18
- }
19
- };
20
-
21
- const filterEmptyViews = views => {
22
- return views.filter(view => dirExists(view));
23
- };
24
-
25
- module.exports = async (app, config) => {
26
- const viewEngine = config.viewEngine || 'html';
27
-
28
- app.use((req, res, next) => {
29
- res.locals.assetPath = '/public';
30
- next();
31
- });
32
-
33
- app.use(config.theme());
34
-
35
- const filteredViews = filterEmptyViews(config.theme.views);
36
- const viewPaths = [].concat(filteredViews);
37
- app.set('view engine', viewEngine);
38
- app.enable('view cache');
39
-
40
- if (config.views) {
41
- const viewsArray = _.castArray(config.views);
42
- viewsArray.slice().reverse().forEach(view => {
43
- const customViewPath = path.resolve(config.root, view);
44
- try {
45
- fs.accessSync(customViewPath, fs.F_OK);
46
- } catch (err) {
47
- throw new Error(`Cannot find views at ${customViewPath}`);
48
- }
49
- viewPaths.unshift(customViewPath);
50
- });
51
- }
52
-
53
- app.set('views', viewPaths);
54
- app.use(expressPartialTemplates(app));
55
-
56
- app.engine(viewEngine, hoganExpressStrict);
57
-
58
- app.use(bodyParser.urlencoded({
59
- extended: true
60
- }));
61
-
62
- app.use(bodyParser.json());
63
-
64
- app.use((req, res, next) => {
65
- res.locals.baseUrl = req.baseUrl;
66
- res.locals.showCookiesBanner = config.showCookiesBanner;
67
- next();
68
- });
69
-
70
- // Trust proxy for secure cookies
71
- app.set('trust proxy', 1);
72
-
73
- return app;
74
- };
@@ -1,28 +0,0 @@
1
- 'use strict';
2
-
3
- const path = require('path');
4
- const stack = require('callsite');
5
- const findup = require('findup');
6
-
7
- function which(name, scpt) {
8
- if (!name) { throw new Error('package name must be provided'); }
9
- const script = scpt || name;
10
-
11
- const pkgPath = `node_modules/${name}/package.json`;
12
- const callsite = stack()[1].getFileName();
13
- const dir = findup.sync(callsite, pkgPath);
14
-
15
- const pkgLocation = path.join(dir, pkgPath);
16
- const pkg = require(pkgLocation);
17
- let bin = pkg.bin[script];
18
-
19
- if (!bin && typeof pkg.bin === 'string') {
20
- bin = pkg.bin;
21
- }
22
-
23
- if (!bin) { throw new Error(`binary path for ${script} not found`); }
24
-
25
- return path.resolve(path.dirname(pkgLocation), bin);
26
- }
27
-
28
- module.exports = which;
@@ -1,43 +0,0 @@
1
- 'use strict';
2
-
3
- const URI = require('urijs');
4
-
5
- const isHealthcheckUrl = (path, healthcheckUrls) => healthcheckUrls.some(url => path.includes(url));
6
- const secureHttps = config => config.protocol === 'https' || config.env === 'production';
7
-
8
- module.exports = options => {
9
- const checkName = 'hof-cookie-check';
10
- const cookieName = (options || {})['cookie-name'] || checkName;
11
- const paramName = (options || {})['param-name'] || checkName;
12
- let healthcheckUrls;
13
-
14
- if (options && options.healthcheckUrls) {
15
- healthcheckUrls = options.healthcheckUrls;
16
- } else {
17
- healthcheckUrls = ['/healthz', '/livez', '/readyz'];
18
- }
19
-
20
- return (req, res, next) => {
21
- const reqIncludesCookies = req.cookies && Object.keys(req.cookies).length;
22
- const reqIsCookieCheckRedirect = req.query[paramName] !== undefined;
23
-
24
- if (reqIncludesCookies || isHealthcheckUrl(req.path, healthcheckUrls)) {
25
- const prefs = 'cookie_preferences' in req.cookies ? JSON.parse(req.cookies.cookie_preferences) : {};
26
- res.locals.cookiesAccepted = Boolean(prefs.usage);
27
- next();
28
- } else if (req.cookies === undefined || (!Object.keys(req.cookies).length && reqIsCookieCheckRedirect)) {
29
- const err = new Error('Cookies required');
30
- err.code = 'NO_COOKIES';
31
- next(err, req, res, next);
32
- } else {
33
- // Set samesite to lax to allow setting cookies on redirects from Gov.UK
34
- res.cookie(cookieName, 1, { sameSite: 'lax', secure: secureHttps(options), httpOnly: true });
35
-
36
- const uriClean = req.originalUrl && req.originalUrl.match(/^\/[^\/\\]/);
37
- const uriToRedirect = uriClean ? req.originalUrl : '/';
38
- const redirectURL = new URI(uriToRedirect).addQuery(encodeURIComponent(paramName));
39
-
40
- res.redirect(redirectURL.toString());
41
- }
42
- };
43
- };
@@ -1,32 +0,0 @@
1
- 'use strict';
2
-
3
- const _ = require('lodash');
4
-
5
- const Translator = (translate, req) => function deepTranslate(key) {
6
- let translated = translate(key);
7
- if (_.isPlainObject(translated)) {
8
- translated = _.reduceRight(translated, (prev, item, tKey) => {
9
- let translationPath = key + '.' + tKey;
10
- if (_.isPlainObject(item) && req.sessionModel) {
11
- let value = req.sessionModel.get(tKey);
12
- if (value) {
13
- value = value.toString();
14
- }
15
- translationPath += '.' + value;
16
- }
17
- const result = deepTranslate(translationPath);
18
- return result !== translationPath ? result : prev;
19
- }, '');
20
- }
21
- return translated;
22
- };
23
-
24
- module.exports = opts => {
25
- const options = opts || {};
26
- return (req, res, next) => {
27
- const translate = options.translate || req.translate || (a => a);
28
- req.translate = Translator(translate, req);
29
- req.rawTranslate = translate;
30
- next();
31
- };
32
- };
@@ -1,119 +0,0 @@
1
- /* eslint-disable no-unused-vars */
2
- 'use strict';
3
-
4
- const rateLimitsConfig = require('../config/rate-limits');
5
-
6
- const errorTitle = code => `${code}_ERROR`;
7
- const errorMsg = code => `There is a ${code}_ERROR`;
8
-
9
- // eslint-disable-next-line complexity
10
- const getContent = (err, translate) => {
11
- const content = {};
12
-
13
- // Helper to safely call translate if it's a function
14
- const t = key => (typeof translate === 'function' ? translate(key) : undefined);
15
-
16
- if (err.code === 'SESSION_TIMEOUT') {
17
- err.status = 401;
18
- err.template = 'session-timeout';
19
- err.serviceName = t('journey.serviceName') || t('journey.header');
20
- err.title = t('errors.session.title');
21
- err.message = t('errors.session.message');
22
- content.serviceName = t('journey.serviceName') || t('journey.header');
23
- content.title = t('errors.session.title');
24
- content.message = t('errors.session.message');
25
- }
26
-
27
- if (err.code === 'NO_COOKIES') {
28
- err.status = 403;
29
- err.template = 'cookie-error';
30
- content.serviceName = t('journey.serviceName') || t('journey.header');
31
- content.title = t('errors.cookies-required.title');
32
- content.message = t('errors.cookies-required.message');
33
- }
34
-
35
- if (err.code === 'DDOS_RATE_LIMIT') {
36
- err.status = 429;
37
- err.template = 'rate-limit-error';
38
- err.serviceName = t('journey.serviceName') || t('journey.header');
39
- err.title = t('errors.ddos-rate-limit.title');
40
- err.message = t('errors.ddos-rate-limit.message');
41
- err.preTimeToWait = t('errors.ddos-rate-limit.pre-time-to-wait');
42
- err.timeToWait = rateLimitsConfig.rateLimits.requests.windowSizeInMinutes;
43
- err.postTimeToWait = t('errors.ddos-rate-limit.post-time-to-wait');
44
- content.title = t('errors.ddos-rate-limit.title');
45
- content.serviceName = t('journey.serviceName') || t('journey.header');
46
- content.message = t('errors.ddos-rate-limit.message');
47
- content.preTimeToWait = t('errors.ddos-rate-limit.pre-time-to-wait');
48
- content.timeToWait = rateLimitsConfig.rateLimits.requests.windowSizeInMinutes;
49
- content.postTimeToWait = t('errors.ddos-rate-limit.post-time-to-wait');
50
- }
51
-
52
- if (err.code === 'SUBMISSION_RATE_LIMIT') {
53
- err.status = 429;
54
- err.template = 'rate-limit-error';
55
- err.serviceName = t('journey.serviceName') || t('journey.header');
56
- err.title = t('errors.submission-rate-limit.title');
57
- err.message = t('errors.submission-rate-limit.message');
58
- err.preTimeToWait = t('errors.submission-rate-limit.pre-time-to-wait');
59
- err.timeToWait = rateLimitsConfig.rateLimits.submissions.windowSizeInMinutes;
60
- err.postTimeToWait = t('errors.submission-rate-limit.post-time-to-wait');
61
- content.serviceName = t('journey.serviceName') || t('journey.header');
62
- content.title = t('errors.submission-rate-limit.title');
63
- content.message = t('errors.submission-rate-limit.message');
64
- content.preTimeToWait = t('errors.submission-rate-limit.pre-time-to-wait');
65
- content.timeToWait = rateLimitsConfig.rateLimits.submissions.windowSizeInMinutes;
66
- content.postTimeToWait = t('errors.submission-rate-limit.post-time-to-wait');
67
- }
68
-
69
- err.code = err.code || 'UNKNOWN';
70
- err.status = err.status || 500;
71
-
72
- if (!content.title) {
73
- content.title = t('errors.default.title') || errorTitle(err.code);
74
- }
75
- if (!content.message) {
76
- content.message = t('errors.default.message') || errorMsg(err.code);
77
- }
78
- return content;
79
- };
80
-
81
- const returnBaseUrl = url => {
82
- const splitUrl = url.split('/');
83
- if (splitUrl.length > 2) {
84
- return `/${splitUrl[1]}`;
85
- }
86
- return '/';
87
- };
88
-
89
- module.exports = options => {
90
- const opts = options || {};
91
- const logger = opts.logger;
92
- const debug = opts.debug;
93
-
94
- return (err, req, res, next) => {
95
- const translate = opts.translate || req.translate;
96
- const content = getContent(err, translate);
97
- const locals = {
98
- error: err,
99
- serviceName: content.serviceName,
100
- content: debug === true ? err : content,
101
- showStack: debug === true,
102
- startLink: returnBaseUrl(req.path),
103
- baseUrl: returnBaseUrl(req.path)
104
- };
105
-
106
- if (logger && logger.error) {
107
- logger.error(err.message || err.error, err);
108
- }
109
-
110
- res.status(err.status);
111
- res.render(err.template || 'error', locals, (e, html) => {
112
- if (e) {
113
- res.render('error', locals);
114
- } else {
115
- res.send(html);
116
- }
117
- });
118
- };
119
- };
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- cookies: require('./cookies'),
5
- errors: require('./errors'),
6
- notFound: require('./not-found'),
7
- deepTranslate: require('./deep-translate'),
8
- rateLimiter: require('./rate-limiter'),
9
- serviceUnavailable: require('./service-unavailable')
10
- };
@@ -1,38 +0,0 @@
1
- 'use strict';
2
-
3
- const getTranslations = translate => {
4
- const translations = {
5
- title: 'Not found',
6
- description: 'There is nothing here'
7
- };
8
-
9
- if (translate) {
10
- translations.title = translate('errors.404.title');
11
- translations.description = translate('errors.404.description');
12
- }
13
-
14
- return translations;
15
- };
16
-
17
- module.exports = options => {
18
- const opts = options || {};
19
- const logger = opts.logger;
20
-
21
- return (req, res) => {
22
- const translate = opts.translate || req.translate;
23
- const translations = getTranslations(translate);
24
-
25
- if (logger && logger.warn) {
26
- logger.warn(`Cannot find: ${req.url}`);
27
- }
28
-
29
- res.status(404).render('404', {
30
- title: translations.title,
31
- description: translations.description,
32
- // Finds the first word in the path of the
33
- // url and removes the leading slash.
34
- // Where url is `/foo/bar`, this returns `foo`.
35
- startLink: req.url.replace(/^\/([^\/]*).*$/, '$1')
36
- });
37
- };
38
- };