@govuk-one-login/frontend-ui 0.0.2 → 1.0.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.
Files changed (65) hide show
  1. package/README.md +155 -1
  2. package/build/all.css +1 -0
  3. package/build/cjs/__tests__/index.spec.d.ts +2 -0
  4. package/build/cjs/__tests__/index.spec.d.ts.map +1 -0
  5. package/build/cjs/__tests__/logger.spec.d.ts +2 -0
  6. package/build/cjs/__tests__/logger.spec.d.ts.map +1 -0
  7. package/build/cjs/index.cjs +193 -0
  8. package/build/cjs/index.d.ts +29 -0
  9. package/build/cjs/index.d.ts.map +1 -0
  10. package/build/cjs/lib/helmet.d.ts +31 -0
  11. package/build/cjs/lib/helmet.d.ts.map +1 -0
  12. package/build/cjs/lib/index.d.ts +4 -0
  13. package/build/cjs/lib/index.d.ts.map +1 -0
  14. package/build/cjs/lib/locals.d.ts +11 -0
  15. package/build/cjs/lib/locals.d.ts.map +1 -0
  16. package/build/cjs/lib/settings.d.ts +21 -0
  17. package/build/cjs/lib/settings.d.ts.map +1 -0
  18. package/build/cjs/utils/logger.d.ts +9 -0
  19. package/build/cjs/utils/logger.d.ts.map +1 -0
  20. package/build/components/_all.scss +3 -0
  21. package/build/components/bases/identity/identity-base-form.njk +82 -0
  22. package/build/components/bases/identity/identity-base-page.njk +82 -0
  23. package/build/components/cookie-banner/cookie-banner.yaml +6 -0
  24. package/build/components/cookie-banner/macro.njk +1 -0
  25. package/build/components/cookie-banner/template.njk +97 -0
  26. package/build/components/footer/footer.yaml +5 -0
  27. package/build/components/footer/macro.njk +1 -0
  28. package/build/components/footer/template.njk +9 -0
  29. package/build/components/header/README.md +34 -0
  30. package/build/components/header/_index.scss +19 -0
  31. package/build/components/header/header.yaml +16 -0
  32. package/build/components/header/macro.njk +3 -0
  33. package/build/components/header/template.njk +88 -0
  34. package/build/components/language-select/_index.scss +35 -0
  35. package/build/components/language-select/language-select.yaml +43 -0
  36. package/build/components/language-select/macro.njk +2 -0
  37. package/build/components/language-select/template.njk +38 -0
  38. package/build/components/phase-banner/_index.scss +20 -0
  39. package/build/components/phase-banner/macro.njk +3 -0
  40. package/build/components/phase-banner/phase-banner.yaml +17 -0
  41. package/build/components/phase-banner/tag/macro.njk +3 -0
  42. package/build/components/phase-banner/tag/template.njk +3 -0
  43. package/build/components/phase-banner/template.njk +22 -0
  44. package/build/components/skip-link/README.md +10 -0
  45. package/build/components/skip-link/macro.njk +3 -0
  46. package/build/components/skip-link/skip-link.yaml +5 -0
  47. package/build/components/skip-link/template.njk +10 -0
  48. package/build/esm/__tests__/index.spec.d.ts +2 -0
  49. package/build/esm/__tests__/index.spec.d.ts.map +1 -0
  50. package/build/esm/__tests__/logger.spec.d.ts +2 -0
  51. package/build/esm/__tests__/logger.spec.d.ts.map +1 -0
  52. package/build/esm/index.d.ts +29 -0
  53. package/build/esm/index.d.ts.map +1 -0
  54. package/build/esm/index.js +188 -0
  55. package/build/esm/lib/helmet.d.ts +31 -0
  56. package/build/esm/lib/helmet.d.ts.map +1 -0
  57. package/build/esm/lib/index.d.ts +4 -0
  58. package/build/esm/lib/index.d.ts.map +1 -0
  59. package/build/esm/lib/locals.d.ts +11 -0
  60. package/build/esm/lib/locals.d.ts.map +1 -0
  61. package/build/esm/lib/settings.d.ts +21 -0
  62. package/build/esm/lib/settings.d.ts.map +1 -0
  63. package/build/esm/utils/logger.d.ts +9 -0
  64. package/build/esm/utils/logger.d.ts.map +1 -0
  65. package/package.json +31 -14
package/README.md CHANGED
@@ -1,3 +1,157 @@
1
1
  [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=govuk-one-login_frontend-ui&metric=coverage)](https://sonarcloud.io/summary/overall?id=govuk-one-login_frontend-ui)
2
2
 
3
- # @govuk-one-login/frontend-ui
3
+ # @govuk-one-login/frontend-ui
4
+
5
+ ## Frontend UI Component Integration Guide
6
+
7
+ This guide outlines the steps to integrate Frontend UI components into your Node.js application using Nunjucks templating.
8
+
9
+ ### 1. Installation
10
+
11
+ Install the NPM package:
12
+
13
+ ```bash
14
+ npm install @govuk-one-login/frontend-ui
15
+ ```
16
+
17
+ ### 2. Configure View Path
18
+
19
+ Add the component's path to your Nunjucks view paths in your application's startup file (e.g., `app.js` or `index.js`):
20
+
21
+ ```javascript
22
+ const path = require('path');
23
+
24
+ // ... other configurations ...
25
+
26
+ app.set(
27
+ 'view engine',
28
+ configureNunjucks(app, [
29
+ // ... other view paths ...
30
+ path.resolve('node_modules/@govuk-one-login/frontend-ui'),
31
+ ]),
32
+ );
33
+ ```
34
+
35
+ **Warning:** Ensure the path to your `node_modules` folder is correct.
36
+
37
+ ### 3. Configure Nunjucks to use exported functions
38
+
39
+ In your `config/nunjucks` file import and set the following to use the language toggle, phase banner etc..
40
+
41
+ Javascript:
42
+ ```javascript
43
+ const frontendUi = require("@govuk-one-login/frontend-ui");
44
+
45
+ nunjucksEnv.addGlobal("addLanguageParam", frontendUi.addLanguageParam);
46
+ nunjucksEnv.addGlobal("contactUsUrl", frontendUi.contactUsUrl);
47
+ ```
48
+ Typescript:
49
+ ```typescript
50
+ import {contactUsUrl, addLanguageParam } from "@govuk-one-login/frontend-ui";
51
+ nunjucksEnv.addGlobal("addLanguageParam", addLanguageParam);
52
+ nunjucksEnv.addGlobal("contactUsUrl", contactUsUrl);
53
+ ```
54
+
55
+ ### 4. Load Translations and Configure Middleware
56
+
57
+ In your `app.js`, import necessary functions and load translations after initializing i18next (Identity teams may need to use the bypass function as their i18n setup is different):
58
+
59
+ ```javascript
60
+ const {
61
+ setFrontendUiTranslations,
62
+ frontendUiMiddleware,
63
+ } = require('@govuk-one-login/frontend-ui');
64
+
65
+ // ... other configurations ...
66
+
67
+ i18next
68
+ .use(Backend)
69
+ .use(i18nextMiddleware.LanguageDetector)
70
+ .init(
71
+ {
72
+ ...i18nextConfigurationOptions(
73
+ path.join(__dirname, 'locales/{{lng}}/{{ns}}.json'),
74
+ ),
75
+ },
76
+ (err) => {
77
+ // Load Frontend UI translations after i18next initialization and pass current instance of i18next
78
+ setFrontendUiTranslations(i18next);
79
+
80
+ if (err) {
81
+ console.error('i18next init failed:', err);
82
+ }
83
+ },
84
+ );
85
+
86
+ // Apply the middleware
87
+ app.use(frontendUiMiddleware);
88
+
89
+ // For Identity teams a language setting bypass may be required, first import the bypass function and then configure router to use the new function at the top of your router.use functions
90
+
91
+ const {
92
+ frontendUiMiddlewareIdentityBypass,
93
+ } = require('@govuk-one-login/frontend-ui');
94
+ ....
95
+
96
+ router.use(frontendUiMiddlewareIdentityBypass);
97
+
98
+ ```
99
+
100
+ ### 5. Import Macro
101
+
102
+ Import the desired component macro into your base Nunjucks template. For example, to use the Cookie Banner component:
103
+
104
+ ```html
105
+ {% from "frontend-ui/build/components/cookie-banner/macro.njk" import frontendUiCookieBanner %}
106
+ ```
107
+
108
+ To replace your basefile you need to change the appropriate extension at the top of your view file:
109
+ ```html
110
+ {% extends "frontend-ui/build/components/bases/identity/identity-base-form.njk" %}
111
+
112
+ or
113
+
114
+ {% extends "frontend-ui/build/components/bases/identity/identity-base-page.njk" %}
115
+
116
+ ```
117
+
118
+ ### 6. Import all.css
119
+ Import the css into your service in the `package.json` via the `build-sass` script
120
+ ```
121
+ sass --no-source-map node_modules/@govuk-one-login/frontend-ui/build/all.css *destination*/frontend-ui.css --style compressed"
122
+ ```
123
+
124
+ include a link to this in your template file
125
+ ```html
126
+ {% block head %}
127
+ '''
128
+ <link href="/stylesheets/frontend-ui.css" rel="stylesheet">
129
+ {% endblock %}
130
+ ```
131
+
132
+
133
+ ### 7. Add Component to Template
134
+
135
+ Render the component in your template, passing any required data. For the Cookie Banner:
136
+
137
+ ```html
138
+ {{ frontendUiCookieBanner({
139
+ translations: translations.translate.cookieBanner
140
+ }) }}
141
+ ```
142
+
143
+ This setup ensures that translations are loaded correctly and the middleware can set necessary local variables for the components to function properly.
144
+
145
+ ### Identity Teams Only
146
+
147
+ Identity teams will also need to install the optional dependency `hmpo-components` and the basefiles
148
+
149
+ To replace your basefile you need to change the appropriate extension at the top of your view file:
150
+ ```html
151
+ {% extends "frontend-ui/build/components/bases/identity/identity-base-form.njk" %}
152
+
153
+ or
154
+
155
+ {% extends "frontend-ui/build/components/bases/identity/identity-base-page.njk" %}
156
+
157
+ ```
package/build/all.css ADDED
@@ -0,0 +1 @@
1
+ @media(max-width: 640px){.govuk-header__navigation-item{border-left:none !important}}.frontendUi_header_signOut-item{padding:5px 0px 5px 30px;border-left:1px solid #b1b4b6;margin-left:auto}.frontendUi_header__signOut{display:flex}.frontendUi-header__content{margin-left:auto}.govuk-tag{font-family:"GDS Transport",arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-weight:700;font-size:14px;font-size:.875rem;line-height:1;display:inline-block;padding-top:5px;padding-right:8px;padding-bottom:4px;padding-left:8px;outline:2px solid rgba(0,0,0,0);outline-offset:-2px;color:#fff !important;background-color:#1d70b8 !important;letter-spacing:1px !important;text-decoration:none !important;text-transform:uppercase !important}/*! Copyright (c) 2011 by Margaret Calvert & Henrik Kubel. All rights reserved. The font has been customised for exclusive use on gov.uk. This cut is not commercially available. */@font-face{font-family:"GDS Transport";font-style:normal;font-weight:normal;src:url("/assets/fonts/light-94a07e06a1-v2.woff2") format("woff2"),url("/assets/fonts/light-f591b13f7d-v2.woff") format("woff");font-display:fallback}@font-face{font-family:"GDS Transport";font-style:normal;font-weight:bold;src:url("/assets/fonts/bold-b542beb274-v2.woff2") format("woff2"),url("/assets/fonts/bold-affa96571d-v2.woff") format("woff");font-display:fallback}@media print{.govuk-tag{font-family:sans-serif}}@media(min-width: 40.0625em){.govuk-tag{font-size:16px;font-size:1rem;line-height:1}}@media print{.govuk-tag{font-size:14pt;line-height:1}}.language-select{margin:15px 0 15px 0}.language-select__list{margin-top:1em;text-align:right}.language-select__list-item{display:inline-block}.language-select__list-item:first-child::after{content:"";display:inline-block;position:relative;top:.1875em;height:1em;border-right:.09375em solid #000}.language-select__list-item a,.language-select__list-item [aria-current]{padding:.3125em}@media screen and (max-width: 641px){.language-select__list{float:none;text-align:left;padding-bottom:10px;border-bottom:1px solid #b1b4b6}}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../../src/__tests__/index.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=logger.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.spec.d.ts","sourceRoot":"","sources":["../../../src/__tests__/logger.spec.ts"],"names":[],"mappings":""}
@@ -1,2 +1,195 @@
1
1
  'use strict';
2
2
 
3
+ var cookieBanner$1 = {
4
+ body1: "Rydym yn defnyddio rhai cwcis hanfodol i wneud i'r gwasanaeth hwn weithio.",
5
+ body2: "Hoffem osod cwcis ychwanegol er mwyn i ni allu cofio eich gosodiadau, deall sut mae pobl yn defnyddio'r gwasanaeth a gwneud gwelliannau.",
6
+ ariaLabel: "Cwcis ar GOV.UK One Login",
7
+ headingText: "Cwcis ar GOV.UK One Login",
8
+ acceptAdditionalCookies: "Derbyn cwcis ychwanegol",
9
+ rejectAdditionalCookies: "Gwrthod cwcis ychwanegol",
10
+ viewCookies: "Gweld cwcis",
11
+ cookieBannerAccept: {
12
+ body1: "Rydych wedi derbyn cwcis ychwanegol. Gallwch ",
13
+ body2: " ar unrhyw adeg."
14
+ },
15
+ cookieBannerReject: {
16
+ body1: "Rydych wedi gwrthod cwcis ychwanegol. Gallwch ",
17
+ body2: " ar unrhyw adeg."
18
+ },
19
+ changeCookiePreferencesLink: "newid eich gosodiadau cwcis",
20
+ hideCookieMessage: "Cuddio’r neges yma",
21
+ viewCookiesLink: "https://signin.account.gov.uk/cookies"
22
+ };
23
+ var footer$1 = {
24
+ footerNavItems: [
25
+ {
26
+ href: "https://signin.account.gov.uk/accessibility-statement",
27
+ text: "Datganiad hygyrchedd"
28
+ },
29
+ {
30
+ href: "https://signin.account.gov.uk/cookies",
31
+ text: "Cwcis"
32
+ },
33
+ {
34
+ href: "https://signin.account.gov.uk/terms-and-conditions",
35
+ text: "Telerau ac amodau"
36
+ },
37
+ {
38
+ href: "https://signin.account.gov.uk/privacy-notice",
39
+ text: "Hysbysiad preifatrwydd"
40
+ },
41
+ {
42
+ href: "https://home.account.gov.uk/contact-gov-uk-one-login",
43
+ text: "Cymorth (agor mewn tab newydd)",
44
+ attributes: {
45
+ rel: "noreferrer noopener",
46
+ target: "_blank"
47
+ }
48
+ }
49
+ ],
50
+ copyright: {
51
+ text: "© Hawlfraint y goron"
52
+ },
53
+ contentLicence: {
54
+ html: "Mae'r holl gynnwys ar gael o dan <a class=\"govuk-footer__link\" href=\"https://www.nationalarchives.gov.uk/doc/open-government-licence-cymraeg/version/3/\" rel=\"licence\">Trwydded Llywodraeth Agored v3.0</a>, oni nodir yn wahanol"
55
+ }
56
+ };
57
+ var header$1 = {
58
+ signOut: "Allgofnodi",
59
+ ariaLabel: "GOV.UK One Login dewislen"
60
+ };
61
+ var languageSelect$1 = {
62
+ ariaLabel: "Switcher iaith"
63
+ };
64
+ var phaseBanner$1 = {
65
+ tag: "BETA",
66
+ text: "Mae hwn yn wasanaeth newydd. Helpwch ni i'w wella a ",
67
+ link: "rhoi eich adborth (agor mewn tab newydd)."
68
+ };
69
+ var skipLink$1 = {
70
+ title: "Neidio i'r prif gynnwys"
71
+ };
72
+ var translationCy = {
73
+ cookieBanner: cookieBanner$1,
74
+ footer: footer$1,
75
+ header: header$1,
76
+ languageSelect: languageSelect$1,
77
+ phaseBanner: phaseBanner$1,
78
+ skipLink: skipLink$1
79
+ };
80
+
81
+ var cookieBanner = {
82
+ body1: "We use some essential cookies to make this service work.",
83
+ body2: "We'd like to set additional cookies so we can remember your settings, understand how people use the service and make improvements.",
84
+ ariaLabel: "Cookies on GOV.UK One Login",
85
+ headingText: "Cookies on GOV.UK One Login",
86
+ acceptAdditionalCookies: "Accept additional cookies",
87
+ rejectAdditionalCookies: "Reject additional cookies",
88
+ viewCookies: "View cookies",
89
+ cookieBannerAccept: {
90
+ body1: "You've accepted additional cookies. You can ",
91
+ body2: " at any time."
92
+ },
93
+ cookieBannerReject: {
94
+ body1: "You've rejected additional cookies. You can ",
95
+ body2: " at any time."
96
+ },
97
+ changeCookiePreferencesLink: "change your cookie settings",
98
+ hideCookieMessage: "Hide this message",
99
+ viewCookiesLink: "https://signin.account.gov.uk/cookies"
100
+ };
101
+ var footer = {
102
+ footerNavItems: [
103
+ {
104
+ href: "https://signin.account.gov.uk/accessibility-statement",
105
+ text: "Accessibility statement"
106
+ },
107
+ {
108
+ href: "https://signin.account.gov.uk/cookies",
109
+ text: "Cookies"
110
+ },
111
+ {
112
+ href: "https://signin.account.gov.uk/terms-and-conditions",
113
+ text: "Terms and conditions"
114
+ },
115
+ {
116
+ href: "https://signin.account.gov.uk/privacy-notice",
117
+ text: "Privacy notice"
118
+ },
119
+ {
120
+ href: "https://home.account.gov.uk/contact-gov-uk-one-login",
121
+ text: "Support (opens in new tab)",
122
+ attributes: {
123
+ rel: "noreferrer noopener",
124
+ target: "_blank"
125
+ }
126
+ }
127
+ ],
128
+ copyright: {
129
+ text: "© Crown copyright"
130
+ },
131
+ contentLicence: {
132
+ html: "All content is available under the <a class=\"govuk-footer__link\" href=\"https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/\" rel=\"licence\">Open Government Licence v3.0</a>, except where otherwise stated"
133
+ }
134
+ };
135
+ var header = {
136
+ signOut: "Sign Out",
137
+ ariaLabel: "GOV.UK One Login menu"
138
+ };
139
+ var languageSelect = {
140
+ ariaLabel: "Select language"
141
+ };
142
+ var phaseBanner = {
143
+ tag: "BETA",
144
+ text: "This is a new service. Help us improve it and ",
145
+ link: "give your feedback (opens in a new tab)."
146
+ };
147
+ var skipLink = {
148
+ title: "Skip to main content"
149
+ };
150
+ var translationEn = {
151
+ cookieBanner: cookieBanner,
152
+ footer: footer,
153
+ header: header,
154
+ languageSelect: languageSelect,
155
+ phaseBanner: phaseBanner,
156
+ skipLink: skipLink
157
+ };
158
+
159
+ const setFrontendUiTranslations = (instanceI18n) => {
160
+ instanceI18n.addResourceBundle("en", "translation", translationEn, true, false);
161
+ instanceI18n.addResourceBundle("cy", "translation", translationCy, true, false);
162
+ };
163
+ const frontendUiMiddleware = (req, res, next) => {
164
+ res.locals.translations = req.i18n.store.data[req.i18n.language];
165
+ next();
166
+ };
167
+ const frontendUiMiddlewareIdentityBypass = (req, res, next) => {
168
+ const localTranslations = {
169
+ en: translationEn,
170
+ cy: translationCy
171
+ };
172
+ res.locals.translations = localTranslations[req.i18n.language];
173
+ next();
174
+ };
175
+ function addLanguageParam(language, url) {
176
+ if (!url) {
177
+ console.warn("URL is undefined. The parameter cannot be added, and the toggle will not work.");
178
+ return "#invalid-url-lang-toggle";
179
+ }
180
+ url.searchParams.set("lng", language);
181
+ return url.pathname + url.search;
182
+ }
183
+ function contactUsUrl(baseUrl, urlToAppend) {
184
+ if (!baseUrl) {
185
+ return null;
186
+ }
187
+ const searchParams = new URLSearchParams({ fromURL: urlToAppend });
188
+ return `${baseUrl}?${searchParams.toString()}`;
189
+ }
190
+
191
+ exports.addLanguageParam = addLanguageParam;
192
+ exports.contactUsUrl = contactUsUrl;
193
+ exports.frontendUiMiddleware = frontendUiMiddleware;
194
+ exports.frontendUiMiddlewareIdentityBypass = frontendUiMiddlewareIdentityBypass;
195
+ exports.setFrontendUiTranslations = setFrontendUiTranslations;
@@ -0,0 +1,29 @@
1
+ import i18next from "i18next";
2
+ import { NextFunction, Request, Response } from "express";
3
+ export declare const setFrontendUiTranslations: (instanceI18n: typeof i18next) => void;
4
+ export declare const frontendUiMiddleware: (req: Request & {
5
+ i18n: {
6
+ language: string;
7
+ store: {
8
+ data: {
9
+ [key: string]: unknown;
10
+ };
11
+ };
12
+ };
13
+ }, res: Response & {
14
+ locals: {
15
+ translations: unknown;
16
+ };
17
+ }, next: NextFunction) => void;
18
+ export declare const frontendUiMiddlewareIdentityBypass: (req: Request & {
19
+ i18n: {
20
+ language: "en" | "cy";
21
+ };
22
+ }, res: Response & {
23
+ locals: {
24
+ translations: unknown;
25
+ };
26
+ }, next: NextFunction) => void;
27
+ export declare function addLanguageParam(language: string, url?: URL): string;
28
+ export declare function contactUsUrl(baseUrl: string, urlToAppend: string): string | null;
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAI1D,eAAO,MAAM,yBAAyB,GAAI,cAAc,OAAO,OAAO,SAerE,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,KAAK,OAAO,GAAG;IACb,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE;YAAE,IAAI,EAAE;gBAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;aAAE,CAAA;SAAE,CAAA;KAAE,CAAC;CACzE,EACD,KAAK,QAAQ,GAAG;IAAE,MAAM,EAAE;QAAE,YAAY,EAAE,OAAO,CAAA;KAAE,CAAA;CAAE,EACrD,MAAM,YAAY,SAInB,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAC7C,KAAK,OAAO,GAAG;IACb,IAAI,EAAE;QACJ,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAA;KACxB,CAAA;CAAC,EACF,KAAK,QAAQ,GAAG;IAAE,MAAM,EAAE;QAAE,YAAY,EAAE,OAAO,CAAA;KAAE,CAAA;CAAE,EACrD,MAAM,YAAY,SAQnB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,UAU3D;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,iBAMhE"}
@@ -0,0 +1,31 @@
1
+ import { Request, Response } from "express";
2
+ declare const _default: {
3
+ contentSecurityPolicy: {
4
+ directives: {
5
+ defaultSrc: string[];
6
+ styleSrc: string[];
7
+ scriptSrc: (string | ((_req: Request, res: Response) => string))[];
8
+ imgSrc: string[];
9
+ formAction: string[];
10
+ objectSrc: string[];
11
+ connectSrc: string[];
12
+ };
13
+ };
14
+ dnsPrefetchControl: {
15
+ allow: boolean;
16
+ };
17
+ frameguard: {
18
+ action: string;
19
+ };
20
+ hsts: {
21
+ maxAge: number;
22
+ preload: boolean;
23
+ includeSubDomains: boolean;
24
+ };
25
+ referrerPolicy: boolean;
26
+ permittedCrossDomainPolicies: boolean;
27
+ expectCt: boolean;
28
+ crossOriginEmbedderPolicy: boolean;
29
+ };
30
+ export default _default;
31
+ //# sourceMappingURL=helmet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helmet.d.ts","sourceRoot":"","sources":["../../../src/lib/helmet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;;;;;;yCAS7B,OAAO,OAAO,QAAQ;;;;;;;;;;;;;;;;;;;;;;;AAPrC,wBA4CE"}
@@ -0,0 +1,4 @@
1
+ export * as locals from "./locals";
2
+ export * as settings from "./settings";
3
+ export * as helmet from "./helmet";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { Request, Response, NextFunction } from "express";
2
+ import { CustomLogger } from "../utils/logger";
3
+ declare const getGTM: (req: Request, res: Response, next: NextFunction) => void;
4
+ declare const getAssetPath: (req: Request, res: Response, next: NextFunction) => void;
5
+ declare const getLanguageToggle: (req: Request & {
6
+ i18n: {
7
+ language: string;
8
+ };
9
+ }, res: Response, next: NextFunction, customLogger?: CustomLogger) => void;
10
+ export { getGTM, getAssetPath, getLanguageToggle };
11
+ //# sourceMappingURL=locals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locals.d.ts","sourceRoot":"","sources":["../../../src/lib/locals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAa,YAAY,EAAmB,MAAM,iBAAiB,CAAC;AAE3E,QAAA,MAAM,MAAM,GAAI,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,KAAG,IA0BjE,CAAC;AAEF,QAAA,MAAM,YAAY,GAChB,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,MAAM,YAAY,KACjB,IAGF,CAAC;AAEF,QAAA,MAAM,iBAAiB,GACrB,KAAK,OAAO,GAAG;IAAE,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EAC7C,KAAK,QAAQ,EACb,MAAM,YAAY,EAClB,eAAe,YAAY,KAC1B,IAkBF,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { Express } from "express";
2
+ interface SetGTM {
3
+ app: Express;
4
+ ga4ContainerId: string;
5
+ analyticsCookieDomain: string;
6
+ ga4Enabled: boolean;
7
+ ga4PageViewEnabled: boolean;
8
+ ga4FormResponseEnabled: boolean;
9
+ ga4FormErrorEnabled: boolean;
10
+ ga4FormChangeEnabled: boolean;
11
+ ga4NavigationEnabled: boolean;
12
+ ga4SelectContentEnabled: boolean;
13
+ analyticsDataSensitive: boolean;
14
+ }
15
+ declare const setGTM: ({ app, ga4ContainerId, analyticsCookieDomain, ga4Enabled, ga4PageViewEnabled, ga4FormResponseEnabled, ga4FormErrorEnabled, ga4FormChangeEnabled, ga4NavigationEnabled, ga4SelectContentEnabled, analyticsDataSensitive, }: SetGTM) => void;
16
+ declare const setLanguageToggle: ({ app, showLanguageToggle, }: {
17
+ app: Express;
18
+ showLanguageToggle: boolean;
19
+ }) => void;
20
+ export { setGTM, setLanguageToggle };
21
+ //# sourceMappingURL=settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../../src/lib/settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,UAAU,MAAM;IACd,GAAG,EAAE,OAAO,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,UAAU,EAAE,OAAO,CAAC;IACpB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,sBAAsB,EAAE,OAAO,CAAC;IAChC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,uBAAuB,EAAE,OAAO,CAAC;IACjC,sBAAsB,EAAE,OAAO,CAAC;CACjC;AAED,QAAA,MAAM,MAAM,GAAI,2NAYb,MAAM,SAWR,CAAC;AAEF,QAAA,MAAM,iBAAiB,GAAI,8BAGxB;IACD,GAAG,EAAE,OAAO,CAAC;IACb,kBAAkB,EAAE,OAAO,CAAC;CAC7B,SAEA,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { pino } from "pino";
2
+ export type CustomLogger = {
3
+ trace: (message: string) => void;
4
+ warn: (message: string) => void;
5
+ };
6
+ export declare const setCustomLogger: (customLogger: CustomLogger) => void;
7
+ export declare const getLogger: () => pino.Logger | CustomLogger;
8
+ export declare const resetLogger: () => void;
9
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAI5B,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,cAAc,YAAY,SAEzD,CAAC;AAEF,eAAO,MAAM,SAAS,QAAO,IAAI,CAAC,MAAM,GAAG,YAW1C,CAAC;AAEF,eAAO,MAAM,WAAW,YAEvB,CAAC"}
@@ -0,0 +1,3 @@
1
+ @use "./header";
2
+ @use "./phase-banner";
3
+ @use "./language-select";
@@ -0,0 +1,82 @@
1
+ {% extends "form-template.njk" %}
2
+
3
+ {% from "frontend-ui/build/components/cookie-banner/macro.njk" import frontendUiCookieBanner %}
4
+ {% from "frontend-ui/build/components/phase-banner/macro.njk" import frontendUiPhaseBanner %}
5
+ {% from "frontend-ui/build/components/header/macro.njk" import frontendUiHeader %}
6
+ {% from "frontend-ui/build/components/footer/macro.njk" import frontendUiFooter %}
7
+ {% from "frontend-ui/build/components/language-select/macro.njk" import frontendUiLanguageSelect %}
8
+
9
+ {%- block pageTitle %}
10
+ {{- (translate("govuk.error", { default: "Error" }) + ": ") if errorlist.length }}{{ hmpoTitle | safe }}{{ " – " + govukServiceName | safe if govukServiceName !== " " }} – GOV.UK One Login
11
+ {%- endblock %}
12
+
13
+ {% block header %}
14
+ {% block cookieBanner %}
15
+ {{ frontendUiCookieBanner({
16
+ translations: translations.cookieBanner
17
+ }
18
+ )}}
19
+ {% endblock %}
20
+
21
+ {% block frontendUiHeader %}
22
+ {{ frontendUiHeader({
23
+ translations: translations.header,
24
+ homepageUrl: "https://www.gov.uk"
25
+ }) }}
26
+ {% endblock %}
27
+ {% endblock %}
28
+
29
+ {% block beforeContent %}
30
+ {{ frontendUiPhaseBanner({
31
+ translations: translations.phaseBanner,
32
+ url: currentUrl,
33
+ contactUrl: 'https://signin.account.gov.uk/contact-us'
34
+ }) }}
35
+ {% block backLink %}
36
+ {{ frontendUiLanguageSelect({
37
+ translations: translations.languageSelect,
38
+ url: currentUrl,
39
+ activeLanguage: htmlLang
40
+ }) }}
41
+ {% if backLink %}
42
+ {% from "govuk/components/back-link/macro.njk" import govukBackLink %}
43
+ <span id="back">{{ govukBackLink({
44
+ text: translate("govuk.backLink"),
45
+ href: backLink}) }}
46
+ </span>
47
+ {% endif %}
48
+
49
+ {% endblock %}
50
+ {% endblock %}
51
+
52
+
53
+ {% block footer %}
54
+ {{ frontendUiFooter({
55
+ translations: translations.footer
56
+ }) }}
57
+ {% endblock %}
58
+
59
+ {% block bodyEnd %}
60
+ {% block scripts %}
61
+ <script type="text/javascript" src="/public/javascripts/all.js"></script>
62
+ <script type="text/javascript" src="/public/javascripts/analytics.js"></script>
63
+ <script type="text/javascript" {% if cspNonce %} nonce="{{ cspNonce }}"{% endif %}>
64
+ window.GOVUKFrontend.initAll()
65
+ window.DI.appInit({
66
+ ga4ContainerId: "{{ga4ContainerId}}",
67
+ uaContainerId:"{{uaContainerId}}"},{
68
+ enableGa4Tracking:{{ga4Enabled}},
69
+ enableUaTracking:{{uaEnabled}},
70
+ enablePageViewTracking:{{ga4PageViewEnabled}},
71
+ enableFormErrorTracking:{{ga4FormErrorEnabled}},
72
+ enableFormChangeTracking:{{ga4FormChangeEnabled}},
73
+ enableFormResponseTracking:{{ga4FormResponseEnabled}},
74
+ enableNavigationTracking:{{ga4NavigationEnabled}},
75
+ enableSelectContentTracking:{{ga4SelectContentEnabled}},
76
+ cookieDomain:"{{analyticsCookieDomain}}",
77
+ isDataSensitive:{{analyticsDataSensitive}}
78
+ }
79
+ );
80
+ </script>
81
+ {% endblock %}
82
+ {% endblock %}