@ministryofjustice/hmpps-probation-frontend-components 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,163 +1,9 @@
1
1
  # hmpps-probation-frontend-components
2
2
 
3
- `hmpps-probation-frontend-components` is a Node.js client library to simplify the process of incorporating global components
4
- within PDS applications. We welcome feedback on this Slack channel [here](https://moj.enterprise.slack.com/archives/C08RXCS63TM)
5
- in order to improve it.
3
+ `hmpps-probation-frontend-components` is a Node.js client library to simplify the process of incorporating global components
4
+ within PDS applications. We welcome feedback on the [#moj-design-system-support Slack channel](https://moj.enterprise.slack.com/archives/CH5RUSB27) in order to improve it.
6
5
 
7
6
  ## Contents
8
7
 
9
- 1. [Using the library](#using-the-library)
10
- 2. [For library developers](#for-library-developers)
11
-
12
-
13
- ## Using the library
14
-
15
- ### Prerequisites
16
-
17
- The package assumes adherance to the standard [hmpps-template-typescript](https://github.com/ministryofjustice/hmpps-template-typescript) project.
18
- It requires:
19
- - a user object to be available on `res.locals` containing a token and displayName.
20
- - nunjucks to be setup
21
- - the environment variable `COMPONENT_API_URL` to be set for each environment
22
- - the environment variables `AUTH_CODE_CLIENT_ID` and `AUTH_CODE_CLIENT_SECRET` to be set to allow authenticating with the dev environment locally
23
- - the environment variable `HMPPS_AUTH_URL` to be set to `https://sign-in-dev.hmpps.service.justice.gov.uk/auth` to authenticate with the dev environment locally
24
- - to be run AFTER helmet middleware
25
-
26
- ### Installation
27
-
28
- To install the package, run the following command:
29
-
30
- ```bash
31
- npm install @ministryofjustice/hmpps-probation-frontend-components
32
- ```
33
-
34
- ### Usage
35
-
36
- Add environment variables to the `helm_deploy/values-{env}.yaml` files for `COMPONENT_API_URL`. Populate with the following values:
37
-
38
- dev - https://probation-frontend-components-dev.hmpps.service.justice.gov.uk
39
-
40
- preprod - https://probation-frontend-components-preprod.hmpps.service.justice.gov.uk
41
-
42
- prod - https://probation-frontend-components.hmpps.service.justice.gov.uk
43
-
44
- You can also add this to your `.env` or `docker-compose` files with the dev url, as follows:
45
-
46
- ```
47
- - COMPONENT_API_URL=https://probation-frontend-components-dev.hmpps.service.justice.gov.uk
48
- ```
49
-
50
- Add a block for the component library in the `apis` section of `server/config.ts`, for example:
51
-
52
- ```javascript
53
- probationApi: {
54
- url: get('COMPONENT_API_URL', 'https://probation-frontend-components-dev.hmpps.service.justice.gov.uk', requiredInProduction),
55
- healthPath: '/health/ping'
56
- }
57
- ```
58
-
59
- Currently, the package provides the header and the footer component.
60
-
61
- To incorporate use the middleware for appropriate routes within your Express application (after the `setUpCurrentUser` middleware):
62
-
63
- ```javascript
64
- import pdsComponents from '@ministryofjustice/hmpps-probation-frontend-components'
65
-
66
- ...
67
-
68
- app.use(pdsComponents.getPageComponents({
69
- pdsUrl: config.apis.probationApi.url,
70
- logger,
71
- }))
72
- ```
73
-
74
- **However, please 🙏 consider carefully whether you need the components for EVERY request.**
75
-
76
- It may be sufficient for you app to only request components for GET requests for example, in which case
77
-
78
- ```javascript
79
- app.get('*', pdsComponents.getPageComponents({
80
- pdsUrl: config.apis.probationApi.url,
81
- logger,
82
- })
83
- )
84
- ```
85
-
86
- Add the `hmpps-probation-frontend-components` path to the nunjucksSetup.ts file to enable css to be loaded:
87
-
88
- ```javascript
89
- const njkEnv = nunjucks.configure(
90
- [
91
- path.join(__dirname, '../../server/views'),
92
- 'node_modules/govuk-frontend/dist/',
93
- 'node_modules/govuk-frontend/dist/components/',
94
- 'node_modules/@ministryofjustice/frontend/',
95
- 'node_modules/@ministryofjustice/frontend/moj/components/',
96
- 'node_modules/@ministryofjustice/hmpps-probation-frontend-components/dist/assets/',
97
- ],
98
- {
99
- autoescape: true,
100
- express: app,
101
- },
102
- )
103
- ```
104
-
105
- Include the package scss within the `index.scss` file
106
- ```scss
107
- @import 'node_modules/@ministryofjustice/hmpps-probation-frontend-components/dist/assets/footer';
108
- @import 'node_modules/@ministryofjustice/hmpps-probation-frontend-components/dist/assets/header';
109
- ```
110
-
111
- Include reference to the components in your layout.njk file:
112
-
113
- ```typescript
114
- {% for js in feComponents.jsIncludes %}
115
- <script src="{{ js }}" nonce="{{ cspNonce }}"></script>
116
- {% endfor %}
117
-
118
- {% for css in feComponents.cssIncludes %}
119
- <link href="{{ css }}" nonce="{{ cspNonce }}" rel="stylesheet" />
120
- {% endfor %}
121
- ```
122
- ```typescript
123
- {% block header %}
124
- {{ feComponents.header | safe }}
125
- {% endblock %}
126
- ```
127
- ```typescript
128
- {% block footer %}
129
- {{ feComponents.footer | safe }}
130
- {% endblock %}
131
- ```
132
-
133
- ### Extra calls
134
-
135
- It may be that you need to add some extra requests for the page components for pages that do not fit the normal flow
136
- of routes. e.g. in `setUpAuthentication.ts` on the `/autherror` path:
137
-
138
- ```javascript
139
- router.get(
140
- '/autherror',
141
- pdsComponents.getPageComponents({ pdsUrl: config.serviceUrls.digitalProbation }),
142
- (req, res) => {
143
- res.status(401)
144
- return res.render('autherror')
145
- },
146
- )
147
- ```
148
-
149
- This will provide a stripped down header if there is no user object on `res.locals`.
150
-
151
- ### CSP
152
-
153
- The package updates the content-security-middleware to include references to the fe-components API. This package should
154
- be run after Helmet to prevent this being overwritten.
155
-
156
- ### Note
157
-
158
- In the event of a failure to retrieve the components, the package will populate the html fields with fallback components.
159
-
160
-
161
- ## For library developers:
162
-
163
- 1. [Publishing to NPM](readme/publishing.md)
8
+ 1. [Using the library](USAGE.md)
9
+ 2. [For library developers](DEVELOPER.md)
@@ -7,6 +7,7 @@ exports.default = getFrontendComponents;
7
7
  const componentApiClient_1 = __importDefault(require("./data/componentApi/componentApiClient"));
8
8
  const fallbacks_1 = require("./utils/fallbacks");
9
9
  const updateCsp_1 = __importDefault(require("./utils/updateCsp"));
10
+ const sanitizeHtml_1 = require("./utils/sanitizeHtml");
10
11
  const defaultOptions = {
11
12
  logger: console,
12
13
  timeoutOptions: { response: 2500, deadline: 2500 },
@@ -44,16 +45,16 @@ function getFrontendComponents(requestOptions) {
44
45
  classes,
45
46
  });
46
47
  res.locals.feComponents = {
47
- header: header.html,
48
- footer: footer.html,
48
+ header: (0, sanitizeHtml_1.sanitizeComponentHtml)(header.html),
49
+ footer: (0, sanitizeHtml_1.sanitizeComponentHtml)(footer.html),
49
50
  cssIncludes: [...header.css, ...footer.css],
50
51
  jsIncludes: [...header.javascript, ...footer.javascript],
51
52
  };
52
53
  (0, updateCsp_1.default)(res);
53
54
  return next();
54
55
  }
55
- catch (_error) {
56
- logger.error('Failed to retrieve front end components, using fallbacks');
56
+ catch (error) {
57
+ logger.error(error, 'Failed to retrieve front end components, using fallbacks');
57
58
  useFallbacks(res.locals.user);
58
59
  return next();
59
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"componentsService.js","sourceRoot":"","sources":["../../src/componentsService.ts"],"names":[],"mappings":";;;;;AAaA,wCAoDC;AAhED,gGAAuE;AACvE,iDAAwE;AAExE,kEAAyC;AAGzC,MAAM,cAAc,GAA4B;IAC9C,MAAM,EAAE,OAAO;IACf,cAAc,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;IAClD,qBAAqB,EAAE,KAAK;CAC7B,CAAA;AAED,SAAwB,qBAAqB,CAAC,cAA+B;IAC3E,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,qBAAqB,EAAE,OAAO,EAAE,GAAG;QACjE,GAAG,cAAc;QACjB,GAAG,cAAc;KAClB,CAAA;IAED,OAAO,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC/B,MAAM,YAAY,GAAG,CAAC,IAAe,EAAE,EAAE;YACvC,GAAG,CAAC,MAAM,CAAC,YAAY,GAAG;gBACxB,MAAM,EAAE,IAAA,6BAAiB,EAAC,IAAI,EAAE,cAAc,CAAC;gBAC/C,MAAM,EAAE,IAAA,6BAAiB,GAAE;gBAC3B,WAAW,EAAE,EAAE;gBACf,UAAU,EAAE,EAAE;aACf,CAAA;QACH,CAAC,C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M,4BAAkB,CAAC,aAAa,CAAC;gBAChE,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAM;gBACjC,cAAc,EAAE,cAAe;gBAC/B,GAAG,EAAE,MAAO;gBACZ,OAAO;aACR,CAAC,CAAA;YAEF,GAAG,CAAC,MAAM,CAAC,YAAY,GAAG;gBACxB,MAAM,EAAE,IAAA,oCAAqB,EAAC,MAAM,CAAC,IAAI,CAAC;gBAC1C,MAAM,EAAE,IAAA,oCAAqB,EAAC,MAAM,CAAC,IAAI,CAAC;gBAC1C,WAAW,EAAE,CAAC,GAAG,MAAM,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC;gBAC3C,UAAU,EAAE,CAAC,GAAG,MAAM,CAAC,UAAU,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC;aACzD,CAAA;YAED,IAAA,mBAAS,EAAC,GAAG,CAAC,CAAA;YAEd,OAAO,IAAI,EAAE,CAAA;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,0DAA0D,CAAC,CAAA;YAC/E,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YAC7B,OAAO,IAAI,EAAE,CAAA;QACf,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
@@ -21,7 +21,8 @@ exports.default = {
21
21
  })
22
22
  .query(generateQueryParams(param))
23
23
  .set({ 'x-user-token': param.userToken })
24
- .timeout(param.timeoutOptions);
24
+ .timeout(param.timeoutOptions)
25
+ .maxResponseSize(50 * 1024 * 1024);
25
26
  return result.body;
26
27
  },
27
28
  };
@@ -1 +1 @@
1
- {"version":3,"file":"componentApiClient.js","sourceRoot":"","sources":["../../../../src/data/componentApi/componentApiClient.ts"],"names":[],"mappings":";;;;;AAAA,4DAAmC;AAGnC,0DAAiC;AAajC,SAAS,mBAAmB,CAAC,KAAuB;IAClD,OAAO,KAAK,CAAC,OAAO;QAClB,CAAC,CAAC,6CAA6C,KAAK,CAAC,OAAO,EAAE;QAC9D,CAAC,CAAC,mCAAmC,CAAA;AACzC,CAAC;AAED,kBAAe;IACb,KAAK,CAAC,aAAa,CAAiC,KAAuB;QACzE,MAAM,MAAM,GAAG,MAAM,oBAAU;aAC5B,GAAG,CAAC,GAAG,gBAAM,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,iBAAiB,CAAC;aACrD,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACtB,IAAI,GAAG;gBAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,sCAAsC,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;YACxF,OAAO,SAAS,CAAA,CAAC,uEAAuE;QAC1F,CAAC,CAAC;aACD,KAAK,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;aACjC,GAAG,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;aACxC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;QAEhC,OAAO,MAAM,CAAC,IAAI,CAAA;IACpB,CAAC;CACF,CAAA"}
1
+ {"version":3,"file":"componentApiClient.js","sourceRoot":"","sources":["../../../../src/data/componentApi/componentApiClient.ts"],"names":[],"mappings":";;;;;AAAA,4DAAmC;AAGnC,0DAAiC;AAajC,SAAS,mBAAmB,CAAC,KAAuB;IAClD,OAAO,KAAK,CAAC,OAAO;QAClB,CAAC,CAAC,6CAA6C,KAAK,CAAC,OAAO,EAAE;QAC9D,CAAC,CAAC,mCAAmC,CAAA;AACzC,CAAC;AAED,kBAAe;IACb,KAAK,CAAC,aAAa,CAAiC,KAAuB;QACzE,MAAM,MAAM,GAAG,MAAM,oBAAU;aAC5B,GAAG,CAAC,GAAG,gBAAM,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,iBAAiB,CAAC;aACrD,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACtB,IAAI,GAAG;gBAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,sCAAsC,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;YACxF,OAAO,SAAS,CAAA,CAAC,uEAAuE;QAC1F,CAAC,CAAC;aACD,KAAK,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;aACjC,GAAG,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;aACxC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC;aAC7B,eAAe,CAAC,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAA;QAEpC,OAAO,MAAM,CAAC,IAAI,CAAA;IACpB,CAAC;CACF,CAAA"}
@@ -10,7 +10,7 @@ declare const _default: {
10
10
  * @param requestOptions - config object for request
11
11
  * @param requestOptions.pdsUrl - url to the dps homepage to be used in the header
12
12
  * @param requestOptions.environmentName - if you require environment tags on the fallback banner "DEV", "PRE-PRODUCTION" or "PRODUCTION" can be passed in
13
- * @param requestOptions.logger - pass in the bunyen logger if you want to use it. Falls back to console if not provided
13
+ * @param requestOptions.logger - pass in the service bunyan logger so fallback/retry messages appear in your service logs. Falls back to console if not provided
14
14
  * @param requestOptions.timeoutOptions - timeout object for superagent. Defaults to 2500ms
15
15
  * @param requestOptions.useFallbacksByDefault - if your service requires only the basic fallback header and footer to be used by default, set this to true, it will not attempt to fetch the components from the frontend components service
16
16
  */
package/dist/src/index.js CHANGED
@@ -15,7 +15,7 @@ exports.default = {
15
15
  * @param requestOptions - config object for request
16
16
  * @param requestOptions.pdsUrl - url to the dps homepage to be used in the header
17
17
  * @param requestOptions.environmentName - if you require environment tags on the fallback banner "DEV", "PRE-PRODUCTION" or "PRODUCTION" can be passed in
18
- * @param requestOptions.logger - pass in the bunyen logger if you want to use it. Falls back to console if not provided
18
+ * @param requestOptions.logger - pass in the service bunyan logger so fallback/retry messages appear in your service logs. Falls back to console if not provided
19
19
  * @param requestOptions.timeoutOptions - timeout object for superagent. Defaults to 2500ms
20
20
  * @param requestOptions.useFallbacksByDefault - if your service requires only the basic fallback header and footer to be used by default, set this to true, it will not attempt to fetch the components from the frontend components service
21
21
  */
@@ -0,0 +1 @@
1
+ export declare function sanitizeComponentHtml(html: string): string;
@@ -0,0 +1,223 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.sanitizeComponentHtml = sanitizeComponentHtml;
7
+ const sanitize_html_1 = __importDefault(require("sanitize-html"));
8
+ const componentHtmlOptions = {
9
+ allowedTags: [
10
+ 'a',
11
+ 'abbr',
12
+ 'address',
13
+ 'article',
14
+ 'aside',
15
+ 'audio',
16
+ 'audio',
17
+ 'b',
18
+ 'base',
19
+ 'bdi',
20
+ 'bdo',
21
+ 'blockquote',
22
+ 'body',
23
+ 'br',
24
+ 'button',
25
+ 'caption',
26
+ 'cite',
27
+ 'code',
28
+ 'col',
29
+ 'colgroup',
30
+ 'data',
31
+ 'datalist',
32
+ 'dd',
33
+ 'del',
34
+ 'details',
35
+ 'dfn',
36
+ 'dialog',
37
+ 'div',
38
+ 'dl',
39
+ 'dt',
40
+ 'em',
41
+ 'fieldset',
42
+ 'figcaption',
43
+ 'figure',
44
+ 'footer',
45
+ 'form',
46
+ 'h1',
47
+ 'h2',
48
+ 'h3',
49
+ 'h4',
50
+ 'h5',
51
+ 'h6',
52
+ 'head',
53
+ 'header',
54
+ 'hgroup',
55
+ 'hr',
56
+ 'html',
57
+ 'i',
58
+ 'img',
59
+ 'input',
60
+ 'ins',
61
+ 'kbd',
62
+ 'label',
63
+ 'legend',
64
+ 'li',
65
+ 'link',
66
+ 'main',
67
+ 'mark',
68
+ 'menu',
69
+ 'meta',
70
+ 'meter',
71
+ 'nav',
72
+ 'ol',
73
+ 'optgroup',
74
+ 'option',
75
+ 'output',
76
+ 'p',
77
+ 'pre',
78
+ 'progress',
79
+ 'q',
80
+ 'rp',
81
+ 'rt',
82
+ 'ruby',
83
+ 's',
84
+ 'samp',
85
+ 'section',
86
+ 'select',
87
+ 'small',
88
+ 'span',
89
+ 'strong',
90
+ 'sub',
91
+ 'summary',
92
+ 'sup',
93
+ 'table',
94
+ 'tbody',
95
+ 'td',
96
+ 'textarea',
97
+ 'tfoot',
98
+ 'th',
99
+ 'thead',
100
+ 'time',
101
+ 'title',
102
+ 'tr',
103
+ 'u',
104
+ 'ul',
105
+ 'var',
106
+ 'video',
107
+ 'video',
108
+ 'wbr',
109
+ ],
110
+ allowedAttributes: {
111
+ '*': [
112
+ 'abbr',
113
+ 'accept',
114
+ 'accept-charset',
115
+ 'accesskey',
116
+ 'action',
117
+ 'allow',
118
+ 'alt',
119
+ 'aria-*',
120
+ 'as',
121
+ 'autocapitalize',
122
+ 'autocomplete',
123
+ 'blocking',
124
+ 'charset',
125
+ 'cite',
126
+ 'class',
127
+ 'color',
128
+ 'cols',
129
+ 'colspan',
130
+ 'content',
131
+ 'contenteditable',
132
+ 'coords',
133
+ 'crossorigin',
134
+ 'data',
135
+ 'datetime',
136
+ 'decoding',
137
+ 'dir',
138
+ 'dirname',
139
+ 'download',
140
+ 'draggable',
141
+ 'enctype',
142
+ 'enterkeyhint',
143
+ 'fetchpriority',
144
+ 'for',
145
+ 'form',
146
+ 'formenctype',
147
+ 'formmethod',
148
+ 'formtarget',
149
+ 'headers',
150
+ 'height',
151
+ 'hidden',
152
+ 'high',
153
+ 'href',
154
+ 'hreflang',
155
+ 'http-equiv',
156
+ 'id',
157
+ 'imagesizes',
158
+ 'imagesrcset',
159
+ 'inputmode',
160
+ 'integrity',
161
+ 'itemid',
162
+ 'itemprop',
163
+ 'itemref',
164
+ 'itemtype',
165
+ 'kind',
166
+ 'label',
167
+ 'lang',
168
+ 'list',
169
+ 'loading',
170
+ 'low',
171
+ 'max',
172
+ 'maxlength',
173
+ 'media',
174
+ 'method',
175
+ 'min',
176
+ 'minlength',
177
+ 'name',
178
+ 'nonce',
179
+ 'optimum',
180
+ 'pattern',
181
+ 'placeholder',
182
+ 'popover',
183
+ 'popovertarget',
184
+ 'popovertargetaction',
185
+ 'poster',
186
+ 'preload',
187
+ 'referrerpolicy',
188
+ 'rel',
189
+ 'role',
190
+ 'rows',
191
+ 'rowspan',
192
+ 'sandbox',
193
+ 'scope',
194
+ 'shape',
195
+ 'size',
196
+ 'sizes',
197
+ 'span',
198
+ 'spellcheck',
199
+ 'src',
200
+ 'srclang',
201
+ 'srcset',
202
+ 'start',
203
+ 'step',
204
+ 'tabindex',
205
+ 'target',
206
+ 'title',
207
+ 'translate',
208
+ 'type',
209
+ 'usemap',
210
+ 'value',
211
+ 'width',
212
+ 'wrap',
213
+ ],
214
+ },
215
+ allowedSchemes: ['https'],
216
+ allowProtocolRelative: false,
217
+ disallowedTagsMode: 'discard',
218
+ enforceHtmlBoundary: true,
219
+ };
220
+ function sanitizeComponentHtml(html) {
221
+ return (0, sanitize_html_1.default)(html, componentHtmlOptions);
222
+ }
223
+ //# sourceMappingURL=sanitizeHtml.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitizeHtml.js","sourceRoot":"","sources":["../../../src/utils/sanitizeHtml.ts"],"names":[],"mappings":";;;;;AAuNA,sDAEC;AAzND,kEAAwC;AAExC,MAAM,oBAAoB,GAA0B;IAClD,WAAW,EAAE;QACX,GAAG;QACH,MAAM;QACN,SAAS;QACT,SAAS;QACT,OAAO;QACP,OAAO;QACP,OAAO;QACP,GAAG;QACH,MAAM;QACN,KAAK;QACL,KAAK;QACL,YAAY;QACZ,MAAM;QACN,IAAI;QACJ,QAAQ;QACR,SAAS;QACT,MAAM;QACN,MAAM;QACN,KAAK;QACL,UAAU;QACV,MAAM;QACN,UAAU;QACV,IAAI;QACJ,KAAK;QACL,SAAS;QACT,KAAK;QACL,QAAQ;QACR,KAAK;QACL,IAAI;QACJ,IAAI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Z,YAAY;YACZ,SAAS;YACT,QAAQ;YACR,QAAQ;YACR,MAAM;YACN,MAAM;YACN,UAAU;YACV,YAAY;YACZ,IAAI;YACJ,YAAY;YACZ,aAAa;YACb,WAAW;YACX,WAAW;YACX,QAAQ;YACR,UAAU;YACV,SAAS;YACT,UAAU;YACV,MAAM;YACN,OAAO;YACP,MAAM;YACN,MAAM;YACN,SAAS;YACT,KAAK;YACL,KAAK;YACL,WAAW;YACX,OAAO;YACP,QAAQ;YACR,KAAK;YACL,WAAW;YACX,MAAM;YACN,OAAO;YACP,SAAS;YACT,SAAS;YACT,aAAa;YACb,SAAS;YACT,eAAe;YACf,qBAAqB;YACrB,QAAQ;YACR,SAAS;YACT,gBAAgB;YAChB,KAAK;YACL,MAAM;YACN,MAAM;YACN,SAAS;YACT,SAAS;YACT,OAAO;YACP,OAAO;YACP,MAAM;YACN,OAAO;YACP,MAAM;YACN,YAAY;YACZ,KAAK;YACL,SAAS;YACT,QAAQ;YACR,OAAO;YACP,MAAM;YACN,UAAU;YACV,QAAQ;YACR,OAAO;YACP,WAAW;YACX,MAAM;YACN,QAAQ;YACR,OAAO;YACP,OAAO;YACP,MAAM;SACP;KACF;IACD,cAAc,EAAE,CAAC,OAAO,CAAC;IACzB,qBAAqB,EAAE,KAAK;IAC5B,kBAAkB,EAAE,SAAS;IAC7B,mBAAmB,EAAE,IAAI;CAC1B,CAAA;AAED,SAAgB,qBAAqB,CAAC,IAAY;IAChD,OAAO,IAAA,uBAAY,EAAC,IAAI,EAAE,oBAAoB,CAAC,CAAA;AACjD,CAAC"}
@@ -1,2 +1,8 @@
1
1
  import bunyan from 'bunyan';
2
- export declare function fakeLogger(): bunyan;
2
+ export type FakeLogger = {
3
+ info: jest.Mock;
4
+ error: jest.Mock;
5
+ warn: jest.Mock;
6
+ debug: jest.Mock;
7
+ };
8
+ export declare function fakeLogger(): FakeLogger & bunyan;
@@ -2,6 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fakeLogger = fakeLogger;
4
4
  function fakeLogger() {
5
- return { error: jest.fn() };
5
+ return {
6
+ info: jest.fn(),
7
+ error: jest.fn(),
8
+ warn: jest.fn(),
9
+ debug: jest.fn(),
10
+ };
6
11
  }
7
12
  //# sourceMappingURL=loggerStub.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"loggerStub.js","sourceRoot":"","sources":["../../../test/helpers/loggerStub.ts"],"names":[],"mappings":";;AAEA,gCAEC;AAFD,SAAgB,UAAU;IACxB,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,EAAmB,CAAA;AAC9C,CAAC"}
1
+ {"version":3,"file":"loggerStub.js","sourceRoot":"","sources":["../../../test/helpers/loggerStub.ts"],"names":[],"mappings":";;AASA,gCAOC;AAPD,SAAgB,UAAU;IACxB,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;QACf,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE;QAChB,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;QACf,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE;KACM,CAAA;AAC1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ministryofjustice/hmpps-probation-frontend-components",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "A package to allow the inclusion of connect pds micro frontend components within pds applications",
5
5
  "main": "./dist/src/index.js",
6
6
  "types": "./dist/src/index.d.ts",
@@ -30,13 +30,16 @@
30
30
  },
31
31
  "jest": {
32
32
  "transform": {
33
- "^.+\\.tsx?$": [
33
+ "^.+\\.[tj]sx?$": [
34
34
  "ts-jest",
35
35
  {
36
36
  "isolatedModules": true
37
37
  }
38
38
  ]
39
39
  },
40
+ "transformIgnorePatterns": [
41
+ "/node_modules/(?!sanitize-html/|htmlparser2/|domhandler/|domutils/|domelementtype/|dom-serializer/|entities/)"
42
+ ],
40
43
  "testMatch": [
41
44
  "<rootDir>/**/**/?(*.)(cy|test).{ts,js,jsx,mjs}"
42
45
  ],
@@ -80,6 +83,7 @@
80
83
  "@types/bunyan": "^1.8.11",
81
84
  "@types/express": "^5.0.6",
82
85
  "@types/jest": "^30.0.0",
86
+ "@types/sanitize-html": "^2.16.1",
83
87
  "@types/superagent": "^8.1.9",
84
88
  "@types/supertest": "^7.2.0",
85
89
  "@typescript-eslint/eslint-plugin": "^8.38.0",
@@ -97,16 +101,18 @@
97
101
  "ts-jest": "^29.3.4"
98
102
  },
99
103
  "dependencies": {
100
- "@types/node": "22.20.1",
104
+ "@ministryofjustice/hmpps-probation-frontend-components": "^1.1.1",
105
+ "@types/node": "22.20.5",
101
106
  "@types/nunjucks": "^3.2.6",
102
107
  "nunjucks": "^3.2.4",
103
- "superagent": "^9.0.2"
108
+ "sanitize-html": "2.18.0",
109
+ "superagent": "^10.4.1"
104
110
  },
105
111
  "overrides": {
106
112
  "@babel/core": "^7.29.0",
107
113
  "body-parser": "^2.2.2",
108
114
  "brace-expansion": "^5.0.7",
109
115
  "js-yaml": "^4.2.0",
110
- "undici": "^7.29.0"
116
+ "undici": "^7.30.0"
111
117
  }
112
118
  }