@govuk-one-login/frontend-ui 4.1.2 → 4.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/build/all.css +0 -1
- package/build/cjs/backend/index.cjs +0 -259
- package/build/cjs/backend/index.d.cts +0 -166
- package/build/cjs/backend/index.d.ts +0 -166
- package/build/cjs/backend/index.d.ts.map +0 -1
- package/build/cjs/backend/lib/helmet.d.ts +0 -31
- package/build/cjs/backend/lib/helmet.d.ts.map +0 -1
- package/build/cjs/backend/lib/index.d.ts +0 -4
- package/build/cjs/backend/lib/index.d.ts.map +0 -1
- package/build/cjs/backend/lib/locals.d.ts +0 -11
- package/build/cjs/backend/lib/locals.d.ts.map +0 -1
- package/build/cjs/backend/lib/settings.d.ts +0 -21
- package/build/cjs/backend/lib/settings.d.ts.map +0 -1
- package/build/cjs/backend/utils/logger.d.ts +0 -9
- package/build/cjs/backend/utils/logger.d.ts.map +0 -1
- package/build/cjs/frontend/index.cjs +0 -439
- package/build/cjs/frontend/index.d.cts +0 -4
- package/build/cjs/frontend/index.d.ts +0 -4
- package/build/cjs/frontend/index.d.ts.map +0 -1
- package/build/cjs/frontend/progress-button/progress-button.d.ts +0 -2
- package/build/cjs/frontend/progress-button/progress-button.d.ts.map +0 -1
- package/build/cjs/frontend/spinner/__tests__/spinner.test.d.ts +0 -2
- package/build/cjs/frontend/spinner/__tests__/spinner.test.d.ts.map +0 -1
- package/build/cjs/frontend/spinner/spinner.d.ts +0 -64
- package/build/cjs/frontend/spinner/spinner.d.ts.map +0 -1
- package/build/cjs/frontend/utils/types.d.ts +0 -108
- package/build/cjs/frontend/utils/types.d.ts.map +0 -1
- package/build/components/_all.scss +0 -6
- package/build/components/bases/auth/auth-base.njk +0 -136
- package/build/components/bases/home/home-base.njk +0 -133
- package/build/components/bases/identity/identity-base-form.njk +0 -123
- package/build/components/bases/identity/identity-base-page.njk +0 -123
- package/build/components/bases/ipv-core/ipv-core-base.njk +0 -172
- package/build/components/bases/mobile/mobile-base.njk +0 -181
- package/build/components/cookie-banner/cookie-banner.yaml +0 -6
- package/build/components/cookie-banner/macro.njk +0 -1
- package/build/components/cookie-banner/template.njk +0 -106
- package/build/components/footer/_index.scss +0 -28
- package/build/components/footer/footer.yaml +0 -5
- package/build/components/footer/macro.njk +0 -1
- package/build/components/footer/template.njk +0 -12
- package/build/components/header/README.md +0 -34
- package/build/components/header/_index.scss +0 -102
- package/build/components/header/header.yaml +0 -16
- package/build/components/header/macro.njk +0 -3
- package/build/components/header/template.njk +0 -39
- package/build/components/language-select/_index.scss +0 -35
- package/build/components/language-select/language-select.yaml +0 -43
- package/build/components/language-select/macro.njk +0 -2
- package/build/components/language-select/template.njk +0 -38
- package/build/components/macros/logo.njk +0 -75
- package/build/components/phase-banner/_index.scss +0 -28
- package/build/components/phase-banner/macro.njk +0 -3
- package/build/components/phase-banner/phase-banner.yaml +0 -17
- package/build/components/phase-banner/tag/macro.njk +0 -3
- package/build/components/phase-banner/tag/template.njk +0 -3
- package/build/components/phase-banner/template.njk +0 -27
- package/build/components/progress-button/_index.scss +0 -51
- package/build/components/progress-button/macro.njk +0 -2
- package/build/components/progress-button/progress-button.yaml +0 -13
- package/build/components/progress-button/template.njk +0 -112
- package/build/components/skip-link/README.md +0 -10
- package/build/components/skip-link/macro.njk +0 -3
- package/build/components/skip-link/skip-link.yaml +0 -5
- package/build/components/skip-link/template.njk +0 -14
- package/build/components/spinner/README.md +0 -130
- package/build/components/spinner/_index.scss +0 -55
- package/build/components/spinner/macro.njk +0 -3
- package/build/components/spinner/template.njk +0 -18
- package/build/esm/backend/index.d.ts +0 -166
- package/build/esm/backend/index.d.ts.map +0 -1
- package/build/esm/backend/index.js +0 -249
- package/build/esm/backend/lib/helmet.d.ts +0 -31
- package/build/esm/backend/lib/helmet.d.ts.map +0 -1
- package/build/esm/backend/lib/index.d.ts +0 -4
- package/build/esm/backend/lib/index.d.ts.map +0 -1
- package/build/esm/backend/lib/locals.d.ts +0 -11
- package/build/esm/backend/lib/locals.d.ts.map +0 -1
- package/build/esm/backend/lib/settings.d.ts +0 -21
- package/build/esm/backend/lib/settings.d.ts.map +0 -1
- package/build/esm/backend/utils/logger.d.ts +0 -9
- package/build/esm/backend/utils/logger.d.ts.map +0 -1
- package/build/esm/frontend/index.d.ts +0 -4
- package/build/esm/frontend/index.d.ts.map +0 -1
- package/build/esm/frontend/index.js +0 -436
- package/build/esm/frontend/progress-button/progress-button.d.ts +0 -2
- package/build/esm/frontend/progress-button/progress-button.d.ts.map +0 -1
- package/build/esm/frontend/spinner/__tests__/spinner.test.d.ts +0 -2
- package/build/esm/frontend/spinner/__tests__/spinner.test.d.ts.map +0 -1
- package/build/esm/frontend/spinner/spinner.d.ts +0 -64
- package/build/esm/frontend/spinner/spinner.d.ts.map +0 -1
- package/build/esm/frontend/utils/types.d.ts +0 -108
- package/build/esm/frontend/utils/types.d.ts.map +0 -1
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
# Spinner
|
|
2
|
-
|
|
3
|
-
This component:
|
|
4
|
-
- Displays an animated spinner graphic
|
|
5
|
-
- Repeatedly calls a supplied function
|
|
6
|
-
- Stops the spinner animation when the function returns success, failure, or doesn't return either after a certain amount of time
|
|
7
|
-
- Displays different HTML for the different phases of its lifecycle
|
|
8
|
-
|
|
9
|
-
It consists of code in `../../frontend-src/spinner/spinner.ts` and styling in `_index.scss`
|
|
10
|
-
|
|
11
|
-
## Requirements
|
|
12
|
-
|
|
13
|
-
For the spinner to perform correctly it requires the following:
|
|
14
|
-
- A container `div` to display within
|
|
15
|
-
- A polling function to call repeatedly until it returns success or failure
|
|
16
|
-
- An optional success function to call once if the polling function returns success
|
|
17
|
-
- An optional error function to call once if the polling function returns failure, or we reach the abort duration
|
|
18
|
-
- A div with id `no-js-content`. This should contain the HTML to display if the user has JS disabled
|
|
19
|
-
- An optional div with id `wait-content`. This should contain the default HTML to display under the spinner
|
|
20
|
-
- An optional div with id `long-wait-content`. This should contain the HTML to display under the spinner once it has been spinning for the specified long wait duration
|
|
21
|
-
- An optional div with id `success-content`. This should contain the HTML to display under the spinner once the polling function returns success
|
|
22
|
-
- An optional div with id `error-content`. This should contain the HTML to display under the spinner if the polling function returns failure, or doesn't return success before the abort duration is reached
|
|
23
|
-
- An optional data attribute `data-ms-before-informing-of-long-wait` to set the amount of time the spinner will spin before displaying the `long-wait-content`
|
|
24
|
-
- An optional data attribute `data-ms-before-abort` to set the amount of time the spinner will spin before displaying the `error-content` and calling the `errorFunction`
|
|
25
|
-
- An optional data attribute `data-ms-between-dom-update` to set the amount of time between updates to the spinner UI
|
|
26
|
-
- An optional data attribute `data-ms-between-requests` to set the amount of time between calls to the `pollingFunction`
|
|
27
|
-
- An optional data attribute `data-hide-spinner-on-error` to hide the spinner graphic on error (defaults to false)
|
|
28
|
-
- An optional data attribute `data-max-backoff-tries` to set the number of times in a row the polling function can return `backoff` before the error content is displayed (defaults to 3)
|
|
29
|
-
- An optional data attribute `aria-alert-completion-text`. If supplied this text will be set as an aria alert if the spinner completes successfully
|
|
30
|
-
|
|
31
|
-
For example:
|
|
32
|
-
|
|
33
|
-
```html
|
|
34
|
-
<div id="spinner-container"
|
|
35
|
-
data-ms-before-informing-of-long-wait="10000"
|
|
36
|
-
data-ms-before-abort="30000"
|
|
37
|
-
data-ms-between-dom-update="1000"
|
|
38
|
-
data-ms-between-requests="2000"
|
|
39
|
-
data-hide-spinner-on-error="true"
|
|
40
|
-
data-max-backoff-tries="3"
|
|
41
|
-
data-aria-alert-completion-text="Task completed successfully, you may now continue">
|
|
42
|
-
<div id="no-js-content"><p class="centre govuk-body">JS is disabled</p></div>
|
|
43
|
-
<div id="wait-content" style="display:none"><p class="centre govuk-body">Waiting</p></div>
|
|
44
|
-
<div id="long-wait-content" style="display:none"><p class="centre govuk-body">Still waiting</p></div>
|
|
45
|
-
<div id="success-content" style="display:none"><p class="centre govuk-body">Success!</p></div>
|
|
46
|
-
<div id="error-content" style="display:none"><p class="centre govuk-body">Error :(</p></div>
|
|
47
|
-
</div>
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Note that the content divs (except for the no-js div) have `style="display:none"` to hide them until they are needed.
|
|
51
|
-
|
|
52
|
-
```typescript
|
|
53
|
-
async function pollFunction(abortSignal): PollResult {
|
|
54
|
-
// Check for success
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function successFunction(): void {
|
|
58
|
-
// Optionally do stuff, e.g. enable a button, redirect, etc
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function errorFunction(): void {
|
|
62
|
-
// Optionally do stuff, e.g. enable a button, redirect, etc
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
useSpinner("spinner-container", pollingFunction, successFunction, errorFunction);
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Lifecycle
|
|
69
|
-
|
|
70
|
-
The spinner starts in the waiting state and displays the `wait` content under the animated spinner graphic content.
|
|
71
|
-
If a call to the polling function returns `success` the spinner will stop animating, display the `success-content` content, and call the `successFunction` (if specified)
|
|
72
|
-
If a call to the polling function returns `failure` the spinner will stop animating, display the `error-content` content, and call the `errorFunction` (if specified)
|
|
73
|
-
If the spinner waits past the `long-wait` duration while the polling function keeps returning `pending` the spinner will display the `long-wait-content` content
|
|
74
|
-
If the spinner waits past the `abort` duration while the polling function keeps returning `pending` the spinner will stop animating, display the `error-content` content, and call the `errorFunction` (if specified)
|
|
75
|
-
The polling function can optionally return `backoff` if it should be tried again but after a delay (e.g. to account for network instability). On receiving `backoff` the spinner will exponentially increase the time before the
|
|
76
|
-
next call to the polling function. If the polling function returns `backoff` more times than the `max-backoff-tries` value in a row then the final call is treated as if had returned `failure` instead. If a call to the polling
|
|
77
|
-
function returns `pending` then the backoff counter resets.
|
|
78
|
-
|
|
79
|
-
### Page refreshes
|
|
80
|
-
|
|
81
|
-
When the spinner starts for the first time it stores the current time in session storage. If the page is refreshed the spinner will retrieve the initial start time from session storage and update itself appropriately.
|
|
82
|
-
|
|
83
|
-
## Scripts
|
|
84
|
-
|
|
85
|
-
Within the frontend-ui package, this script is bundled within `frontend-src`, so that it can be used in the alpha-app.
|
|
86
|
-
|
|
87
|
-
Please note that in the `package.json` file of the frontend-ui repo the files needed for the spinner are exported as follows:
|
|
88
|
-
|
|
89
|
-
```json
|
|
90
|
-
"exports": {
|
|
91
|
-
".": {
|
|
92
|
-
"import": "./build/esm/index.js",
|
|
93
|
-
"require": "./build/cjs/index.cjs"
|
|
94
|
-
},
|
|
95
|
-
"./frontend": {
|
|
96
|
-
"import": "./build/esm/index-fe.js",
|
|
97
|
-
"require": "./build/cjs/index-fe.cjs"
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
The default import is at the top and the one at the bottom ensures, the correct script files are ported when the package is built.
|
|
103
|
-
|
|
104
|
-
Configurations to the alpha-app have also been made to ensure these script files work accordingly however this should not affect any users wanting to use the spinner component from the frontend-ui package.
|
|
105
|
-
|
|
106
|
-
## Manual Testing
|
|
107
|
-
|
|
108
|
-
The nunjucks files in this folder are to allow automated accessibility testing, most users of the spinner component will only need the CSS and script files.
|
|
109
|
-
|
|
110
|
-
There is a `/spinner` page in the alpha-app that will display the spinner component.
|
|
111
|
-
|
|
112
|
-
An endpoint has been created in the alpha-app at `/api` that will return a pending result for a specified number of requests before returning a success response.
|
|
113
|
-
|
|
114
|
-
```js
|
|
115
|
-
let counter = 0;
|
|
116
|
-
|
|
117
|
-
app.get("/api", (req, res) => {
|
|
118
|
-
counter++;
|
|
119
|
-
const processingTime = req.query.processingTime || 1;
|
|
120
|
-
console.log(
|
|
121
|
-
`Elapsed processing seconds: ${counter}. Processing time limit is: ${processingTime}`,
|
|
122
|
-
);
|
|
123
|
-
if (counter >= processingTime) {
|
|
124
|
-
res.json({ status: "Clear to proceed", counter: counter });
|
|
125
|
-
counter = 0;
|
|
126
|
-
} else {
|
|
127
|
-
res.json({ status: "Still processing", counter: counter });
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
```
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
.spinner {
|
|
2
|
-
width: 80px;
|
|
3
|
-
height: 80px;
|
|
4
|
-
border-radius: 50%;
|
|
5
|
-
border-width: 12px;
|
|
6
|
-
border-style: solid;
|
|
7
|
-
border-color: #dee0e2;
|
|
8
|
-
border-top-color: #005ea5;
|
|
9
|
-
margin-bottom: 15px;
|
|
10
|
-
|
|
11
|
-
@media (forced-colors: active) {
|
|
12
|
-
forced-color-adjust: none;
|
|
13
|
-
border-top-color: transparent !important;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
@media not (prefers-reduced-motion) {
|
|
17
|
-
-webkit-animation: spin 2s linear infinite;
|
|
18
|
-
animation: spin 2s linear infinite;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@media (prefers-reduced-motion) {
|
|
22
|
-
transform: rotate(0.125turn);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
&__finished {
|
|
26
|
-
border-color: #005ea5;
|
|
27
|
-
-webkit-animation: none;
|
|
28
|
-
animation: none;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@-webkit-keyframes spin {
|
|
33
|
-
0% {
|
|
34
|
-
-webkit-transform: rotate(0deg);
|
|
35
|
-
}
|
|
36
|
-
100% {
|
|
37
|
-
-webkit-transform: rotate(360deg);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@keyframes spin {
|
|
42
|
-
0% {
|
|
43
|
-
transform: rotate(0deg);
|
|
44
|
-
}
|
|
45
|
-
100% {
|
|
46
|
-
transform: rotate(360deg);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.centre {
|
|
51
|
-
margin-left: auto;
|
|
52
|
-
margin-right: auto;
|
|
53
|
-
text-align: center;
|
|
54
|
-
display: block;
|
|
55
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{# This template is for use in accessbility testing. #}
|
|
2
|
-
{% block content %}
|
|
3
|
-
|
|
4
|
-
<main>
|
|
5
|
-
<div id="spinner-container"
|
|
6
|
-
data-ms-before-informing-of-long-wait="4000"
|
|
7
|
-
data-ms-before-abort="9000"
|
|
8
|
-
data-ms-between-dom-update="1000"
|
|
9
|
-
data-ms-between-requests="3000">
|
|
10
|
-
<div id="no-js-content"><p class="centre govuk-body">JS is disabled</p></div>
|
|
11
|
-
<div id="wait-content" style="display:none"><p class="centre govuk-body">Waiting</p></div>
|
|
12
|
-
<div id="long-wait-content" style="display:none"><p class="centre govuk-body">Still waiting</p></div>
|
|
13
|
-
<div id="success-content" style="display:none"><p class="centre govuk-body">Success!</p></div>
|
|
14
|
-
<div id="error-content" style="display:none"><p class="centre govuk-body">Error :(</p></div>
|
|
15
|
-
</div>
|
|
16
|
-
</main>
|
|
17
|
-
|
|
18
|
-
{% endblock %}
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import i18next from "i18next";
|
|
2
|
-
import { NextFunction, Request, Response } from "express";
|
|
3
|
-
interface I18nData {
|
|
4
|
-
language: string;
|
|
5
|
-
store: {
|
|
6
|
-
data: {
|
|
7
|
-
[key: string]: unknown;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
interface ExpressRequest extends Request {
|
|
12
|
-
i18n: I18nData;
|
|
13
|
-
}
|
|
14
|
-
interface ExpressResponse extends Response {
|
|
15
|
-
locals: {
|
|
16
|
-
translations: unknown;
|
|
17
|
-
basePath?: string;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
interface PlainRequest {
|
|
21
|
-
i18n: I18nData;
|
|
22
|
-
}
|
|
23
|
-
interface PlainResponse {
|
|
24
|
-
locals: {
|
|
25
|
-
translations: unknown;
|
|
26
|
-
basePath?: string;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export declare function frontendUiMiddleware(req: ExpressRequest, res: ExpressResponse, next: NextFunction): void;
|
|
30
|
-
export declare function frontendUiMiddleware(req: PlainRequest, res: PlainResponse, next: NextFunction): void;
|
|
31
|
-
export declare const setFrontendUiTranslations: (instanceI18n: typeof i18next) => void;
|
|
32
|
-
export declare const frontendUiMiddlewareIdentityBypass: (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => void;
|
|
33
|
-
export declare function addLanguageParam(language: string, url?: URL): string;
|
|
34
|
-
export declare function contactUsUrl(baseUrl: string, urlToAppend: string): string | null;
|
|
35
|
-
export declare const setBaseTranslations: (instanceI18n: typeof i18next, filePath?: string) => void;
|
|
36
|
-
export declare const getTranslationObject: (locale: string, filepath?: string) => Record<string, unknown>;
|
|
37
|
-
export declare const frontendUiTranslationEn: {
|
|
38
|
-
cookieBanner: {
|
|
39
|
-
body1: string;
|
|
40
|
-
body2: string;
|
|
41
|
-
ariaLabel: string;
|
|
42
|
-
headingText: string;
|
|
43
|
-
acceptAdditionalCookies: string;
|
|
44
|
-
rejectAdditionalCookies: string;
|
|
45
|
-
viewCookies: string;
|
|
46
|
-
cookieBannerAccept: {
|
|
47
|
-
body1: string;
|
|
48
|
-
body2: string;
|
|
49
|
-
};
|
|
50
|
-
cookieBannerReject: {
|
|
51
|
-
body1: string;
|
|
52
|
-
body2: string;
|
|
53
|
-
};
|
|
54
|
-
changeCookiePreferencesLink: string;
|
|
55
|
-
hideCookieMessage: string;
|
|
56
|
-
viewCookiesLink: string;
|
|
57
|
-
};
|
|
58
|
-
footer: {
|
|
59
|
-
footerNavItems: ({
|
|
60
|
-
href: string;
|
|
61
|
-
text: string;
|
|
62
|
-
attributes?: undefined;
|
|
63
|
-
} | {
|
|
64
|
-
href: string;
|
|
65
|
-
text: string;
|
|
66
|
-
attributes: {
|
|
67
|
-
rel: string;
|
|
68
|
-
target: string;
|
|
69
|
-
};
|
|
70
|
-
})[];
|
|
71
|
-
copyright: {
|
|
72
|
-
text: string;
|
|
73
|
-
};
|
|
74
|
-
contentLicence: {
|
|
75
|
-
html: string;
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
header: {
|
|
79
|
-
signOut: string;
|
|
80
|
-
ariaLabel: string;
|
|
81
|
-
signOutAriaLabel: string;
|
|
82
|
-
};
|
|
83
|
-
languageSelect: {
|
|
84
|
-
ariaLabel: string;
|
|
85
|
-
};
|
|
86
|
-
phaseBanner: {
|
|
87
|
-
tag: string;
|
|
88
|
-
text: string;
|
|
89
|
-
link: string;
|
|
90
|
-
};
|
|
91
|
-
skipLink: {
|
|
92
|
-
title: string;
|
|
93
|
-
};
|
|
94
|
-
progressButton: {
|
|
95
|
-
text: string;
|
|
96
|
-
waitingText: string;
|
|
97
|
-
longWaitingText: string;
|
|
98
|
-
noJavascriptMessage: string;
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
export declare const frontendUiTranslationCy: {
|
|
102
|
-
cookieBanner: {
|
|
103
|
-
body1: string;
|
|
104
|
-
body2: string;
|
|
105
|
-
ariaLabel: string;
|
|
106
|
-
headingText: string;
|
|
107
|
-
acceptAdditionalCookies: string;
|
|
108
|
-
rejectAdditionalCookies: string;
|
|
109
|
-
viewCookies: string;
|
|
110
|
-
cookieBannerAccept: {
|
|
111
|
-
body1: string;
|
|
112
|
-
body2: string;
|
|
113
|
-
};
|
|
114
|
-
cookieBannerReject: {
|
|
115
|
-
body1: string;
|
|
116
|
-
body2: string;
|
|
117
|
-
};
|
|
118
|
-
changeCookiePreferencesLink: string;
|
|
119
|
-
hideCookieMessage: string;
|
|
120
|
-
viewCookiesLink: string;
|
|
121
|
-
};
|
|
122
|
-
footer: {
|
|
123
|
-
footerNavItems: ({
|
|
124
|
-
href: string;
|
|
125
|
-
text: string;
|
|
126
|
-
attributes?: undefined;
|
|
127
|
-
} | {
|
|
128
|
-
href: string;
|
|
129
|
-
text: string;
|
|
130
|
-
attributes: {
|
|
131
|
-
rel: string;
|
|
132
|
-
target: string;
|
|
133
|
-
};
|
|
134
|
-
})[];
|
|
135
|
-
copyright: {
|
|
136
|
-
text: string;
|
|
137
|
-
};
|
|
138
|
-
contentLicence: {
|
|
139
|
-
html: string;
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
header: {
|
|
143
|
-
signOut: string;
|
|
144
|
-
ariaLabel: string;
|
|
145
|
-
signOutAriaLabel: string;
|
|
146
|
-
};
|
|
147
|
-
languageSelect: {
|
|
148
|
-
ariaLabel: string;
|
|
149
|
-
};
|
|
150
|
-
phaseBanner: {
|
|
151
|
-
tag: string;
|
|
152
|
-
text: string;
|
|
153
|
-
link: string;
|
|
154
|
-
};
|
|
155
|
-
skipLink: {
|
|
156
|
-
title: string;
|
|
157
|
-
};
|
|
158
|
-
progressButton: {
|
|
159
|
-
text: string;
|
|
160
|
-
waitingText: string;
|
|
161
|
-
longWaitingText: string;
|
|
162
|
-
noJavascriptMessage: string;
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
export {};
|
|
166
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AAQ1D,UAAU,QAAQ;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE;QACL,IAAI,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;SAAE,CAAC;KAClC,CAAC;CACH;AAED,UAAU,cAAe,SAAQ,OAAO;IACtC,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,UAAU,eAAgB,SAAQ,QAAQ;IACxC,MAAM,EAAE;QACN,YAAY,EAAE,OAAO,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,UAAU,YAAY;IACpB,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,UAAU,aAAa;IACrB,MAAM,EAAE;QACN,YAAY,EAAE,OAAO,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAGD,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,YAAY,GACjB,IAAI,CAAC;AAER,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,YAAY,EACjB,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,YAAY,GACjB,IAAI,CAAC;AAaR,eAAO,MAAM,yBAAyB,GAAI,cAAc,OAAO,OAAO,SAerE,CAAC;AAGF,eAAO,MAAM,kCAAkC,GAC7C,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,MAAM,YAAY,SAUnB,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,iBAkBhE;AAED,eAAO,MAAM,mBAAmB,GAC9B,cAAc,OAAO,OAAO,EAC5B,WAAW,MAAM,SASlB,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,MAAM,EACd,WAAW,MAAM,KAChB,MAAM,CAAC,MAAM,EAAE,OAAO,CAuBxB,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAgB,CAAC;AACrD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAgB,CAAC"}
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { existsSync, readFileSync } from 'fs';
|
|
3
|
-
|
|
4
|
-
var cookieBanner$1 = {
|
|
5
|
-
body1: "Rydym yn defnyddio rhai cwcis hanfodol i wneud i'r gwasanaeth hwn weithio.",
|
|
6
|
-
body2: "Hoffem osod cwcis ychwanegol er mwyn i ni allu cofio eich gosodiadau, deall sut mae pobl yn defnyddio'r gwasanaeth a gwneud gwelliannau.",
|
|
7
|
-
ariaLabel: "Cwcis ar GOV.UK One Login",
|
|
8
|
-
headingText: "Cwcis ar GOV.UK One Login",
|
|
9
|
-
acceptAdditionalCookies: "Derbyn cwcis ychwanegol",
|
|
10
|
-
rejectAdditionalCookies: "Gwrthod cwcis ychwanegol",
|
|
11
|
-
viewCookies: "Gweld cwcis",
|
|
12
|
-
cookieBannerAccept: {
|
|
13
|
-
body1: "Rydych wedi derbyn cwcis ychwanegol. Gallwch ",
|
|
14
|
-
body2: " ar unrhyw adeg."
|
|
15
|
-
},
|
|
16
|
-
cookieBannerReject: {
|
|
17
|
-
body1: "Rydych wedi gwrthod cwcis ychwanegol. Gallwch ",
|
|
18
|
-
body2: " ar unrhyw adeg."
|
|
19
|
-
},
|
|
20
|
-
changeCookiePreferencesLink: "newid eich gosodiadau cwcis",
|
|
21
|
-
hideCookieMessage: "Cuddio’r neges yma",
|
|
22
|
-
viewCookiesLink: "https://signin.account.gov.uk/cookies"
|
|
23
|
-
};
|
|
24
|
-
var footer$1 = {
|
|
25
|
-
footerNavItems: [
|
|
26
|
-
{
|
|
27
|
-
href: "https://signin.account.gov.uk/accessibility-statement",
|
|
28
|
-
text: "Datganiad hygyrchedd"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
href: "https://signin.account.gov.uk/cookies",
|
|
32
|
-
text: "Cwcis"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
href: "https://signin.account.gov.uk/terms-and-conditions",
|
|
36
|
-
text: "Telerau ac amodau"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
href: "https://www.gov.uk/government/publications/govuk-one-login-privacy-notice",
|
|
40
|
-
text: "Hysbysiad preifatrwydd"
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
href: "https://home.account.gov.uk/contact-gov-uk-one-login",
|
|
44
|
-
text: "Cymorth (agor mewn tab newydd)",
|
|
45
|
-
attributes: {
|
|
46
|
-
rel: "noreferrer noopener",
|
|
47
|
-
target: "_blank"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
],
|
|
51
|
-
copyright: {
|
|
52
|
-
text: "© Hawlfraint y goron"
|
|
53
|
-
},
|
|
54
|
-
contentLicence: {
|
|
55
|
-
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"
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
var header$1 = {
|
|
59
|
-
signOut: "Allgofnodi",
|
|
60
|
-
ariaLabel: "GOV.UK One Login dewislen",
|
|
61
|
-
signOutAriaLabel: "Allgofnodi"
|
|
62
|
-
};
|
|
63
|
-
var languageSelect$1 = {
|
|
64
|
-
ariaLabel: "Switcher iaith"
|
|
65
|
-
};
|
|
66
|
-
var phaseBanner$1 = {
|
|
67
|
-
tag: "BETA",
|
|
68
|
-
text: "Mae hwn yn wasanaeth newydd. Helpwch ni i'w wella a ",
|
|
69
|
-
link: "rhoi eich adborth (agor mewn tab newydd)."
|
|
70
|
-
};
|
|
71
|
-
var skipLink$1 = {
|
|
72
|
-
title: "Neidio i'r prif gynnwys"
|
|
73
|
-
};
|
|
74
|
-
var progressButton$1 = {
|
|
75
|
-
text: "Parhau",
|
|
76
|
-
waitingText: "Aros",
|
|
77
|
-
longWaitingText: "Parhau i aros",
|
|
78
|
-
noJavascriptMessage: "Gall gymryd hyd at 10 eiliad i barhau i'r dudalen nesaf. Ar ôl i chi barhau, peidiwch ag ail-lwytho na chau'r dudalen hon."
|
|
79
|
-
};
|
|
80
|
-
var translationCy = {
|
|
81
|
-
cookieBanner: cookieBanner$1,
|
|
82
|
-
footer: footer$1,
|
|
83
|
-
header: header$1,
|
|
84
|
-
languageSelect: languageSelect$1,
|
|
85
|
-
phaseBanner: phaseBanner$1,
|
|
86
|
-
skipLink: skipLink$1,
|
|
87
|
-
progressButton: progressButton$1
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
var cookieBanner = {
|
|
91
|
-
body1: "We use some essential cookies to make this service work.",
|
|
92
|
-
body2: "We'd like to set additional cookies so we can remember your settings, understand how people use the service and make improvements.",
|
|
93
|
-
ariaLabel: "Cookies on GOV.UK One Login",
|
|
94
|
-
headingText: "Cookies on GOV.UK One Login",
|
|
95
|
-
acceptAdditionalCookies: "Accept additional cookies",
|
|
96
|
-
rejectAdditionalCookies: "Reject additional cookies",
|
|
97
|
-
viewCookies: "View cookies",
|
|
98
|
-
cookieBannerAccept: {
|
|
99
|
-
body1: "You've accepted additional cookies. You can ",
|
|
100
|
-
body2: " at any time."
|
|
101
|
-
},
|
|
102
|
-
cookieBannerReject: {
|
|
103
|
-
body1: "You've rejected additional cookies. You can ",
|
|
104
|
-
body2: " at any time."
|
|
105
|
-
},
|
|
106
|
-
changeCookiePreferencesLink: "change your cookie settings",
|
|
107
|
-
hideCookieMessage: "Hide this message",
|
|
108
|
-
viewCookiesLink: "https://signin.account.gov.uk/cookies"
|
|
109
|
-
};
|
|
110
|
-
var footer = {
|
|
111
|
-
footerNavItems: [
|
|
112
|
-
{
|
|
113
|
-
href: "https://signin.account.gov.uk/accessibility-statement",
|
|
114
|
-
text: "Accessibility statement"
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
href: "https://signin.account.gov.uk/cookies",
|
|
118
|
-
text: "Cookies"
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
href: "https://signin.account.gov.uk/terms-and-conditions",
|
|
122
|
-
text: "Terms and conditions"
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
href: "https://www.gov.uk/government/publications/govuk-one-login-privacy-notice",
|
|
126
|
-
text: "Privacy notice"
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
href: "https://home.account.gov.uk/contact-gov-uk-one-login",
|
|
130
|
-
text: "Support (opens in new tab)",
|
|
131
|
-
attributes: {
|
|
132
|
-
rel: "noreferrer noopener",
|
|
133
|
-
target: "_blank"
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
],
|
|
137
|
-
copyright: {
|
|
138
|
-
text: "© Crown copyright"
|
|
139
|
-
},
|
|
140
|
-
contentLicence: {
|
|
141
|
-
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"
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
var header = {
|
|
145
|
-
signOut: "Sign Out",
|
|
146
|
-
ariaLabel: "GOV.UK One Login menu",
|
|
147
|
-
signOutAriaLabel: "Sign out"
|
|
148
|
-
};
|
|
149
|
-
var languageSelect = {
|
|
150
|
-
ariaLabel: "Select language"
|
|
151
|
-
};
|
|
152
|
-
var phaseBanner = {
|
|
153
|
-
tag: "BETA",
|
|
154
|
-
text: "This is a new service. Help us improve it and ",
|
|
155
|
-
link: "give your feedback (opens in a new tab)."
|
|
156
|
-
};
|
|
157
|
-
var skipLink = {
|
|
158
|
-
title: "Skip to main content"
|
|
159
|
-
};
|
|
160
|
-
var progressButton = {
|
|
161
|
-
text: "Continue",
|
|
162
|
-
waitingText: "Wait",
|
|
163
|
-
longWaitingText: "Keep waiting",
|
|
164
|
-
noJavascriptMessage: "It can take up to 10 seconds to continue to the next page. After you continue, do not reload or close this page."
|
|
165
|
-
};
|
|
166
|
-
var translationEn = {
|
|
167
|
-
cookieBanner: cookieBanner,
|
|
168
|
-
footer: footer,
|
|
169
|
-
header: header,
|
|
170
|
-
languageSelect: languageSelect,
|
|
171
|
-
phaseBanner: phaseBanner,
|
|
172
|
-
skipLink: skipLink,
|
|
173
|
-
progressButton: progressButton
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
// Implementation
|
|
177
|
-
function frontendUiMiddleware(req, res, next) {
|
|
178
|
-
res.locals.translations = req.i18n.store.data[req.i18n.language];
|
|
179
|
-
res.locals.basePath = process.cwd();
|
|
180
|
-
next();
|
|
181
|
-
}
|
|
182
|
-
const setFrontendUiTranslations = (instanceI18n) => {
|
|
183
|
-
instanceI18n.addResourceBundle("en", "translation", translationEn, true, false);
|
|
184
|
-
instanceI18n.addResourceBundle("cy", "translation", translationCy, true, false);
|
|
185
|
-
};
|
|
186
|
-
const frontendUiMiddlewareIdentityBypass = (req, res, next) => {
|
|
187
|
-
const localTranslations = {
|
|
188
|
-
en: translationEn,
|
|
189
|
-
cy: translationCy,
|
|
190
|
-
};
|
|
191
|
-
const language = req.i18n.language;
|
|
192
|
-
res.locals.translations = localTranslations[language] || {};
|
|
193
|
-
res.locals.basePath = process.cwd();
|
|
194
|
-
next();
|
|
195
|
-
};
|
|
196
|
-
function addLanguageParam(language, url) {
|
|
197
|
-
if (!url) {
|
|
198
|
-
console.warn("URL is undefined. The parameter cannot be added, and the toggle will not work.");
|
|
199
|
-
return "#invalid-url-lang-toggle";
|
|
200
|
-
}
|
|
201
|
-
url.searchParams.set("lng", language);
|
|
202
|
-
return url.pathname + url.search;
|
|
203
|
-
}
|
|
204
|
-
function contactUsUrl(baseUrl, urlToAppend) {
|
|
205
|
-
if (!baseUrl) {
|
|
206
|
-
return null;
|
|
207
|
-
}
|
|
208
|
-
try {
|
|
209
|
-
const newUrl = new URL(urlToAppend); // Create a new URL object to modify
|
|
210
|
-
newUrl.search = ''; // Remove the query parameters
|
|
211
|
-
const encodedUrl = encodeURIComponent(newUrl.toString()); // Encode the entire URL
|
|
212
|
-
const searchParams = new URLSearchParams({ fromURL: encodedUrl });
|
|
213
|
-
return `${baseUrl}?${searchParams.toString()}`;
|
|
214
|
-
}
|
|
215
|
-
catch (_a) {
|
|
216
|
-
const encodedUrlToAppend = encodeURIComponent(urlToAppend);
|
|
217
|
-
const searchParams = new URLSearchParams({ fromURL: encodedUrlToAppend });
|
|
218
|
-
return `${baseUrl}?${searchParams.toString()}`;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
const setBaseTranslations = (instanceI18n, filePath) => {
|
|
222
|
-
["cy", "en"].forEach((locale) => {
|
|
223
|
-
instanceI18n.addResourceBundle(locale, "translation", getTranslationObject(locale, filePath));
|
|
224
|
-
});
|
|
225
|
-
};
|
|
226
|
-
const getTranslationObject = (locale, filepath) => {
|
|
227
|
-
const possiblePaths = [
|
|
228
|
-
path.resolve("locales", locale, "translation.json"),
|
|
229
|
-
path.resolve("src/locales", locale, "translation.json"),
|
|
230
|
-
path.resolve(filepath !== null && filepath !== void 0 ? filepath : "", locale, "translation.json"),
|
|
231
|
-
];
|
|
232
|
-
for (const filePath of possiblePaths) {
|
|
233
|
-
if (existsSync(filePath)) {
|
|
234
|
-
try {
|
|
235
|
-
const fileContent = readFileSync(filePath, "utf8");
|
|
236
|
-
return JSON.parse(fileContent);
|
|
237
|
-
}
|
|
238
|
-
catch (error) {
|
|
239
|
-
console.error(`Error reading or parsing translation file at ${filePath}:`, error);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
console.warn(`No translation file found for locale: ${locale}`);
|
|
244
|
-
return {}; // Return an empty object as a fallback
|
|
245
|
-
};
|
|
246
|
-
const frontendUiTranslationEn = translationEn;
|
|
247
|
-
const frontendUiTranslationCy = translationCy;
|
|
248
|
-
|
|
249
|
-
export { addLanguageParam, contactUsUrl, frontendUiMiddleware, frontendUiMiddlewareIdentityBypass, frontendUiTranslationCy, frontendUiTranslationEn, getTranslationObject, setBaseTranslations, setFrontendUiTranslations };
|
|
@@ -1,31 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { NextFunction, Request, Response } 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 { getAssetPath, getGTM, getLanguageToggle };
|
|
11
|
-
//# sourceMappingURL=locals.d.ts.map
|