Commit Graph

100 Commits

Author SHA1 Message Date
Beverly Nguyen
e5a9eed626 installing socketio 2024-06-05 14:56:22 -07:00
Beverly Nguyen
6855a6ebe4 installing chart.js via npm 2024-05-15 15:35:39 -07:00
dependabot[bot]
353383d323 Bump postcss and @uswds/compile
Bumps [postcss](https://github.com/postcss/postcss) to 8.4.31 and updates ancestor dependency [@uswds/compile](https://github.com/uswds/uswds-compile). These dependencies need to be updated together.


Updates `postcss` from 7.0.39 to 8.4.31
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/postcss/compare/7.0.39...8.4.31)

Updates `@uswds/compile` from 1.0.0 to 1.1.0
- [Release notes](https://github.com/uswds/uswds-compile/releases)
- [Commits](https://github.com/uswds/uswds-compile/compare/v1.0.0...v1.1.0)

---
updated-dependencies:
- dependency-name: postcss
  dependency-type: indirect
- dependency-name: "@uswds/compile"
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-13 17:11:55 +00:00
Jonathan Bobel
7ba937b14a Updated sass-embedded to see if this fixes the dependency error 2023-11-01 11:14:02 -04:00
Jonathan Bobel
54eb8df9f7 - Added new flag imagery for favicon and related images
- Removed preloaded fonts - legacy UK site stuff
- Added the ability to run pa11y scan with npm run pa11y-ci
2023-09-20 13:52:54 -04:00
Jonathan Bobel
84d436baf2 Adding back in sass-embedded 2023-08-28 16:36:35 -04:00
Jonathan Bobel
42c4670c89 Removing more sass includes to see if this addresses my issue 2023-08-28 16:33:25 -04:00
Jonathan Bobel
c7b756e46c Removing sass 2023-08-28 16:25:01 -04:00
Jonathan Bobel
8ab550a22f Radio buttons and list edits 2023-08-25 15:31:44 -04:00
Jonathan Bobel
eaf3681ae1 Initial USWDS install 2023-04-24 14:57:35 -04:00
stvnrlly
8a415bc31b remove leaflet - it was for broadcasts 2022-12-14 13:30:27 -05:00
stvnrlly
219dc7b2ec update package.json for gsa 2022-11-29 08:55:22 -05:00
Ryan Ahearn
bb2d57b27b Update tests to use most recent jest and supporting libraries 2022-10-27 11:12:39 -04:00
Ryan Ahearn
98b772f959 Separate test and lint steps 2022-10-27 11:10:13 -04:00
Ryan Ahearn
f9cacac204 Update js dependencies 2022-10-26 14:15:49 +00:00
Ryan Ahearn
fa7b1a41b8 Add python and npm audits to checks.yml 2022-08-25 16:55:33 -04:00
Ben Thorner
51f9b0cef0 Fix missing audit task in package.json
This was intended to go in [^1] but I think it got lost in a rebase.

[^1]: https://github.com/alphagov/notifications-admin/pull/4237
2022-05-10 11:33:24 +01:00
Ben Thorner
b348e8ed03 Add better-npm-audit to check production packages
This is the same as [^1].

[^1]: https://github.com/alphagov/document-download-frontend/pull/120
2022-05-09 12:05:42 +01:00
Ben Thorner
da7dd3a852 Fix incorrect group for NPM dependencies
This means we can use tools like "npm audit" to look for security
vulnerabilities we definitely need to fix as they could pose a
direct risk to users. I've checked each of them with @tombye and
also against an external set of principles [^1].

Note: I've skimmed through the package-lock.json to check the only
changes are to add "dev: true", as well as a few integrity hashes.

[^1]: https://betterprogramming.pub/is-this-a-dependency-or-a-devdependency-678e04a55a5c
2022-05-06 12:31:10 +01:00
Ben Thorner
b6321ef4ae Remove unused "del" package
This was added in [^1] and later removed in [^2].

[^1]: e1dc6ddaef
[^2]: https://github.com/alphagov/notifications-admin/pull/3198
2022-05-05 14:51:19 +01:00
Tom Byers
77f7d1453c Replace domdiff library with morphdom
We added domdiff to replace the DiffDOM library
here:

87f54d1e88

DiffDOM had updated its code to be written to the
ECMAScript 6 (ES6) standard and so needed extra
work to work with the older browsers in our
support matrix. This was recorded as an issue
here:

https://www.pivotaltracker.com/n/projects/1443052/stories/165380360

Domdiff didn't work (see below for more details)
so this replaces it with the morphdom library.
Morphdom supports the same browsers as us and is
relied on by a range of large open source
projects:

https://github.com/patrick-steele-idem/morphdom#what-projects-are-using-morphdom

It was tricky to find alternatives to DiffDOM so
if we have to source alternatives in future, other
options could be:
- https://github.com/choojs/nanomorph
- https://diffhtml.org/index.html (using its
  outerHTML method)

Why domdiff didn't work

Turns out that domdiff was replacing the page HTML
with the HTML from the AJAX response every time,
not just when they differed. This isn't a bug.
Domdiff is bare bones enough that it compares old
DOM nodes to new DOM nodes with ===. With our
code, this always results to false because our new
nodes are made from HTML strings from AJAX
response so are never the same node as the old
one.
2022-01-27 11:37:53 +00:00
Tom Byers
c61698753f Remove version restrictions for NPM
We do need NPM to be run above those versions but
I'd rather enforce that here after I'm sure this
app will run on images that have a valid version.
2021-09-22 12:05:47 +01:00
Tom Byers
aeaa96124c Fix node version & lock down npm version
The intention behind the version of node in the
engines property was for that version to be the
minimum required so it was always missing the `>=`
prefix.

This adds that prefix and also adds a setting for
npm, to prevent use of insecure versions. See this
article for details:

https://github.blog/2021-09-08-github-security-update-vulnerabilities-tar-npmcli-arborist/
2021-09-22 12:05:47 +01:00
Tom Byers
87f54d1e88 Replace diffDOM library with domdiff
A while ago diffDOM moved its code to use ES6
modules and started using various language
features specific to ES6. These two things
happened independently btw.

The result of this is that the version of diffDOM
suitable for our build pipeline, structured as an
immediately invoked function evocation (IIFE),
now requires polyfills of some ES6 features to
work in the older browsers we support, like IE11.

It's also worth noting that in the move to ES6
the maintainers of diffDOM have adopted a process
whereby users who need to support older browsers
now have to add polyfill code for any ES6 features
they choose to use.

This commmit proposes a move to the domdiff
library instead because:
- it runs on all javascript runtimes with no
  polyfills
- it is 2KB instead of diffDOM's 25KB

Domdiff takes a different approach to diffDOM, in
that it compares existing nodes and new nodes and
replaces the existing ones with the new ones if
there are differences. By contrast, diffDOM will
make in-place changes to nodes if there are enough
similarities. In other words, in most situations,
diffDOM won't change the node in $component
whereas domdiff will.

Because of this, I've had to change the
updateContent.js code to cache the data-key
attribute's value so we don't lose access to it by
overwrite the $component variable with a different
jQuery selection.
2021-09-22 12:05:47 +01:00
Tom Byers
bec77a2c66 Bump gulp-sass
Intended to deal with this security vulnerability:

https://github.blog/2021-09-08-github-security-update-vulnerabilities-tar-npmcli-arborist/

Bumping gulp-sass to version 5 removes its
dependency on the tar package mentioned in that
article.

Version 5 requires you to specify a compiler
directly in the gulpfile so that code is changed
in line with this guidance:

https://github.com/dlmanning/gulp-sass/tree/master#migrating-to-version-5

Note: node-sass is now deprecated so this also
changes the sass compiler gulp-sass uses to
dart-sass (aka 'sass'), the compiler now
recommended by the Sass project:

https://sass-lang.com/dart-sass

This also bumps gulp and all its plugin modules to
their latest versions, for parity.
2021-09-22 12:05:47 +01:00
Ben Thorner
e2cf3e2c70 Support registering a new authenticator
This adds Yubico's FIDO2 library and two APIs for working with the
"navigator.credentials.create()" function in JavaScript. The GET
API uses the library to generate options for the "create()" function,
and the POST API decodes and verifies the resulting credential. While
the options and response are dict-like, CBOR is necessary to encode
some of the byte-level values, which can't be represented in JSON.

Much of the code here is based on the Yubico library example [1][2].

Implementation notes:

- There are definitely better ways to alert the user about failure, but
window.alert() will do for the time being. Using location.reload() is
also a bit jarring if the page scrolls, but not a major issue.

- Ideally we would use window.fetch() to do AJAX calls, but we don't
have a polyfill for this, and we use $.ajax() elsewhere [3]. We need
to do a few weird tricks [6] to stop jQuery trashing the data.

- The FIDO2 server doesn't serve web requests; it's just a "server" in
the sense of WebAuthn terminology. It lives in its own module, since it
needs to be initialised with the app / config.

- $.ajax returns a promise-like object. Although we've used ".fail()"
elsewhere [3], I couldn't find a stub object that supports it, so I've
gone for ".catch()", and used a Promise stub object in tests.

- WebAuthn only works over HTTPS, but there's an exception for "localhost"
[4].  However, the library is a bit too strict [5], so we have to disable
origin verification to avoid needing HTTPS for dev work.

[1]: c42d9628a4/examples/server/server.py
[2]: c42d9628a4/examples/server/static/register.html
[3]: 91453d3639/app/assets/javascripts/updateContent.js (L33)
[4]: https://stackoverflow.com/questions/55971593/navigator-credentials-is-null-on-local-server
[5]: c42d9628a4/fido2/rpid.py (L69)
[6]: https://stackoverflow.com/questions/12394622/does-jquery-ajax-or-load-allow-for-responsetype-arraybuffer
2021-05-13 10:22:23 +01:00
Rebecca Law
01a3df6edc Update _delete_template_cache_for_service to delete all template version cache and not just the one ending in "None"
Update all methods that were previous calling @cache.delete('service-{service-id}-template-None') to instead call _delete_template_cache_for_service
Remove call to get service templates, it's not needed since all template version cache is being deleted.
2021-01-25 16:28:20 +00:00
Chris Hill-Scott
a2f4abf0d3 Remove inlining of images
In very old browsers it used to be that you could only make 2 concurrent
requests from the same origin.

So base64 encoding of images into CSS was an optimisation that became
popular because it reduced the number of separate requests.

However base64 encoding images has a few disadvantages:
- it increases the size of the image by about 30%
- it increases the size of the CSS file, which is a
  [render blocking resource](https://web.dev/render-blocking-resources/)
  so makes the page appear to load more slowly for the sake of some
  images which, on most pages, never get used
- GZipping things that are already compressed (for example PNG data) is
  very CPU intensive, and might be why Cloudfront sometimes gives up

Removing the inlining of images reduces the size of the CSS we’re
sending to the browser considerably:

–| Before | After | Saving
---|---|---|---
Uncompressed | 198kb | 164kb | 17%
Compressed | 38kb | 23kb | 39%
2020-12-29 18:40:16 +00:00
Tom Byers
24db85684c Revert "Merge pull request #3738 from alphagov/test-pre-compressed-asset"
This reverts commit 2a817024a1, reversing
changes made to d5f54d2d78.
2020-12-21 21:12:16 +00:00
Tom Byers
80f34d8c3d Generate asset to test CDN compression config
Cloudfront, our CDN, sometimes decides not to gzip
assets. Because of this, we're going to gzip them
ourselves prior to upload instead.

This will involve:
1. adding gzipping to the make task that uploads
   them
2. turning compression off in Cloudfront

There is already a pull request up for number 1:

https://github.com/alphagov/notifications-admin/pull/3733

Because deploying all this will, at some point,
create a state where Cloudfront is set to compress
assets that are already compressed, we need to
test that it doesn't re-compress them.

This adds a frontend build task that generates a
test asset which is:
- a copy of app/static/stylesheets/main.css
- renamed to include a MD5 SHA of its contents
- already gzipped

Once deployed, the test will be to:
1. download the asset from the live environment
2. unzip it
3. diff it against app/static/stylesheets/main.css
2020-12-09 10:24:36 +00:00
Chris Hill-Scott
8e1c75883a Add Leaflet.js for rendering slippy maps
Leaflet seems to be the go-to library for rendering maps these days. It
will be useful for the broadcast work.

This commit add the leaflet Javascript and CSS to our asset pipeline.
The Javascript is already minified so all we need to do is copy it. The
CSS is uncompressed so we put it through the same pipe as our other
stylesheets.

I’m keeping these as separate files because they’re quite heavy (or the
JS is at least – 38kb minified) so I want them to only be loaded on the
pages where they’re used. Most users of Notify will never need to see a
map.
2020-07-03 09:53:41 +01:00
dependabot[bot]
6b31d37fbd Bump jquery from 3.4.1 to 3.5.0
Bumps [jquery](https://github.com/jquery/jquery) from 3.4.1 to 3.5.0.
- [Release notes](https://github.com/jquery/jquery/releases)
- [Commits](https://github.com/jquery/jquery/compare/3.4.1...3.5.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-04-29 22:56:45 +00:00
Chris Hill-Scott
a2929ad748 Delay AJAX calls if the server is slow to respond
By default our AJAX calls were 2 seconds. Then they were 5 seconds
because someone reckoned 2 seconds was putting too much load on the
system. Then we made them 10 seconds while we were having an incident.
Then we made them 20 seconds for the heaviest pages, but back to 5
seconds or 2 seconds for the rest of the pages.

This is not a good situation because:
- it slows all services down equally, no  matter how much traffic they
  have, or which features they have  switched on
- it slows everything down by the same amount, no matter how much load
  the platform is under
- the values are set based on our worst performance, until we manually
  remember to switch them back
- we spend time during incidents deploying changes to slow down the
  dashboard refresh time because it’s a nothing-to-lose change that
  might relieve some symptoms, when we could be spending time digging
  into the underlying cause

This pull request makes the Javascript smarter about how long it waits
until it makes another AJAX call. It bases the delay on how long the
server takes to respond (as a proxy for how much load the server is
under).

It’s based on the square root of the response time, so is more sensitive
to slow downs early on, and less sensitive to slow downs later on. This
helps us give a more pronounced difference in delay between an AJAX call
that is fast (for example the page for a single notification) and one
that is slow (for example a dashboard for a service with lots of
traffic).

*Some examples of what this would mean for various pages*

Page | Response time | Wait until next AJAX call
---|---|---
Check a reply to address | 130ms | 1,850ms
Brand new service dashboard | 229ms | 2,783ms
HM Passport Office dashboard | 634ms | 5,294ms
NHS Coronavirus Service dashboard | 779ms | 5,977ms
_Example of the kind of slowness we’ve seen during an incident_ | 6,000ms | 18,364ms
GOV.UK email dashboard | `HTTP 504` | 😬
2020-04-09 12:05:18 +01:00
Tom Byers
eccd943c1a Rewrite URLs in CSS based on environment
Fix for issue that caused this revert:

https://github.com/alphagov/notifications-admin/pull/3196

Note:

gulp-css-url-adjuster operates on an Abstract
Syntax Tree (AST) derived from `main.css`. The
CSS output from this loses the compression
gulp-sass applies.

This moves compression out of Sass, to a step
after the URLs are adjusted.
2019-11-27 14:15:32 +00:00
Tom Byers
bb9b7f9005 Switch to using gulp-better-rollup
Means our rollup bundling doesn't leave any
artefact files lying around that we'd then have to
deal with.

Also includes:
- removal of some JSHint config' marking the
  artefacts as scripts to ignore
- use of streamqueue package to allow the same
  ordering of scripts as before
2019-11-27 14:15:32 +00:00
Tom Byers
e1dc6ddaef Clean up JS files created by modules build
Any files left over can effect future builds.
2019-11-27 14:15:32 +00:00
Tom Byers
cd877fe0db Add JS modules support & use for GOVUKFrontend
The JS for GOVUKFrontend components is available
individually so you can only include what you
need:

https://github.com/alphagov/govuk-frontend/blob/v2.13.0/docs/installation/installing-with-npm.md#option-2-import-javascript

This uses the JS Modules syntax:

*[JS module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)

Our JS is delivered as one file so we need to use
a bundler to convert the modules to a single file.

This adds a build step to transpile all modules
into a single file, which is then added to the
files combined into the one that get delivered.

Rollup is used as the simplest bundler to use for
this purpose. It also introduces the least
boilerplate JS.

Note: the CommonJS plugin is needed as GOV.UK
Frontend components are published as UMD modules.

In future, this work should let us work on this
story dependencies:

https://www.pivotaltracker.com/story/show/165380360
2019-11-27 14:15:32 +00:00
Tom Byers
ae27e94a35 Remove GOVUK Template files
Includes Sass that targeted GOV.UK Template HTML
and also moves some link styles to `globals.scss`.

Also removes bits of frontend build that copied
over GOVUK Template files.
2019-11-27 14:15:32 +00:00
Tom Byers
e09d510ab8 Revert "Replace govuk template with govuk frontend components - rewrite" 2019-11-26 12:14:09 +00:00
Tom Byers
0e10879ef2 Switch to using gulp-better-rollup
Means our rollup bundling doesn't leave any
artefact files lying around that we'd then have to
deal with.

Also includes:
- removal of some JSHint config' marking the
  artefacts as scripts to ignore
- use of streamqueue package to allow the same
  ordering of scripts as before
2019-11-25 11:43:30 +00:00
Tom Byers
e034f5b77a Clean up JS files created by modules build
Any files left over can effect future builds.
2019-11-25 11:43:30 +00:00
Tom Byers
85f0543b11 Add JS modules support & use for GOVUKFrontend
The JS for GOVUKFrontend components is available
individually so you can only include what you
need:

https://github.com/alphagov/govuk-frontend/blob/v2.13.0/docs/installation/installing-with-npm.md#option-2-import-javascript

This uses the JS Modules syntax:

*[JS module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)

Our JS is delivered as one file so we need to use
a bundler to convert the modules to a single file.

This adds a build step to transpile all modules
into a single file, which is then added to the
files combined into the one that get delivered.

Rollup is used as the simplest bundler to use for
this purpose. It also introduces the least
boilerplate JS.

Note: the CommonJS plugin is needed as GOV.UK
Frontend components are published as UMD modules.

In future, this work should let us work on this
story dependencies:

https://www.pivotaltracker.com/story/show/165380360
2019-11-25 11:43:30 +00:00
Tom Byers
c8de91c161 Remove GOVUK Template files
Includes Sass that targeted GOV.UK Template HTML
and also moves some link styles to `globals.scss`.

Also removes bits of frontend build that copied
over GOVUK Template files.
2019-11-25 11:43:30 +00:00
Tom Byers
e02f94f238 Revert "Replace govuk template with govuk frontend components" 2019-11-25 10:37:35 +00:00
Tom Byers
aff73293e4 Switch to using gulp-better-rollup
Means our rollup bundling doesn't leave any
artefact files lying around that we'd then have to
deal with.

Also includes:
- removal of some JSHint config' marking the
  artefacts as scripts to ignore
- use of streamqueue package to allow the same
  ordering of scripts as before
2019-11-22 17:45:45 +00:00
Tom Byers
3f420be0b7 Clean up JS files created by modules build
Any files left over can effect future builds.
2019-11-22 17:45:45 +00:00
Tom Byers
efe7e2f35e Add JS modules support & use for GOVUKFrontend
The JS for GOVUKFrontend components is available
individually so you can only include what you
need:

https://github.com/alphagov/govuk-frontend/blob/v2.13.0/docs/installation/installing-with-npm.md#option-2-import-javascript

This uses the JS Modules syntax:

*[JS module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)

Our JS is delivered as one file so we need to use
a bundler to convert the modules to a single file.

This adds a build step to transpile all modules
into a single file, which is then added to the
files combined into the one that get delivered.

Rollup is used as the simplest bundler to use for
this purpose. It also introduces the least
boilerplate JS.

Note: the CommonJS plugin is needed as GOV.UK
Frontend components are published as UMD modules.

In future, this work should let us work on this
story dependencies:

https://www.pivotaltracker.com/story/show/165380360
2019-11-22 17:45:45 +00:00
Tom Byers
278a70ecc7 Remove GOVUK Template files
Includes Sass that targeted GOV.UK Template HTML
and also moves some link styles to `globals.scss`.

Also removes bits of frontend build that copied
over GOVUK Template files.
2019-11-22 17:45:45 +00:00
Tom Byers
059fb66fae Merge pull request #3173 from alphagov/dependabot/npm_and_yarn/jquery-3.4.1
Bump jquery from 1.12.4 to 3.4.1
2019-11-11 14:23:06 +00:00
dependabot[bot]
f2b7c42f53 Bump jquery from 1.12.4 to 3.4.1
Bumps [jquery](https://github.com/jquery/jquery) from 1.12.4 to 3.4.1.
- [Release notes](https://github.com/jquery/jquery/releases)
- [Commits](https://github.com/jquery/jquery/compare/1.12.4...3.4.1)

Signed-off-by: dependabot[bot] <support@github.com>
2019-11-01 12:09:59 +00:00