Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PP-12021 Upgrade to DS v5 with CSP change #3907

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ module.exports = function (grunt) {
dist: {
src: ['public/javascripts/application.js',
'node_modules/promise-polyfill/dist/polyfill.min.js',
'node_modules/govuk-frontend/govuk/all.js',
'node_modules/govuk-frontend/dist/govuk/all.bundle.js',
'app/assets/javascripts/modules/*.js'],
dest: 'public/javascripts/application.js'
}
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/browsered/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const initialiseAddressCountryAutocomplete = () => {

const toggleButton = (button) => {
if (button) {
button[button.getAttribute('disabled') ? 'removeAttribute' : 'setAttribute']('disabled', 'disabled')
button[button.hasAttribute('disabled') ? 'removeAttribute' : 'setAttribute']('disabled', 'disabled')
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/browsered/web-payments/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const clearErrorSummary = () => {

const toggleWaiting = (paymentMethodSubmitId) => {
const button = document.getElementById(paymentMethodSubmitId)
button[button.getAttribute('disabled') ? 'removeAttribute' : 'setAttribute']('disabled', 'disabled')
button[button.hasAttribute('disabled') ? 'removeAttribute' : 'setAttribute']('disabled', 'disabled')
document.getElementById('spinner').classList.toggle('hidden')
}

Expand Down
21 changes: 0 additions & 21 deletions app/assets/javascripts/modules/analytics-track-click.js

This file was deleted.

70 changes: 0 additions & 70 deletions app/assets/javascripts/modules/cookie-banner.js

This file was deleted.

2 changes: 1 addition & 1 deletion app/assets/javascripts/modules/form-card-type.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var showCardType = function() {
window.showCardType = function() {
var form = document.getElementById('card-details')
var acceptedCards = form.querySelector('.accepted-cards')
var cardInput = form.querySelector('#card-no')
Expand Down
3 changes: 1 addition & 2 deletions app/assets/sass/application.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
@import "govuk-frontend/govuk/all";
@import "govuk-frontend/dist/govuk/all";
@import "govuk-country-and-territory-autocomplete/location-autocomplete";

@import "modules/3ds";
@import "modules/accepted-cards";
@import "modules/accessible-autocomplete";
@import "modules/button-reset";
@import "modules/cookie-message";
@import "modules/cvc";
@import "modules/expiry-date-separator";
@import "modules/input-confirm";
Expand Down
20 changes: 0 additions & 20 deletions app/assets/sass/modules/cookie-message.scss

This file was deleted.

4 changes: 2 additions & 2 deletions app/middleware/csp.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const allowUnsafeEvalScripts = process.env.CSP_ALLOW_UNSAFE_EVAL_SCRIPTS === 'tr
const frontendUrl = process.env.FRONTEND_URL || ''
// Script responsible for setting 'js-enabled' class, extends GOV.UK frontend `layout` which we have no control over
// and never changes
const govUkFrontendLayoutJsEnabledScriptHash = '\'sha256-+6WnXIl4mbFTCARd8N3COQmT3bJJmo32N8q8ZSQAIcU=\''
const govUkFrontendLayoutJsEnabledScriptHash = '\'sha256-GUQ5ad8JK5KmEWmROf3LZd9ge94daqNvd8xy9YS1iDw=\''

const CSP_NONE = ['\'none\'']
const CSP_SELF = ['\'self\'']
Expand Down Expand Up @@ -66,7 +66,7 @@ const cardDetailsCSP = helmet({
formAction: [formActionCardDetails],
fontSrc: CSP_SELF,
frameAncestors: CSP_SELF,
manifestSrc: CSP_NONE,
manifestSrc: CSP_SELF,
mediaSrc: CSP_NONE,
objectSrc: CSP_NONE,
baseUri: CSP_NONE
Expand Down
5 changes: 0 additions & 5 deletions app/views/includes/cookie-message.njk

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/includes/custom.njk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</span>
</div>
<div class="govuk-header__content">
<span class="govuk-header__link--service-name">
<span class="govuk-header__service-name">
{{ serviceName }}
</span>
</div>
Expand Down
3 changes: 1 addition & 2 deletions app/views/includes/scripts.njk
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
confirmationForm.addEventListener('submit', function () {
confirmButton.setAttribute('disabled', 'disabled')
})
analyticsTrackConfirmClick().init('{{analytics.analyticsId}}', '{{analytics.type}}', '{{analytics.paymentProvider}}', '{{analytics.amount}}', '{{hitPage}}')
}
{% if allowGooglePay%}
window.googlePayGatewayMerchantID = '{{ googlePayGatewayMerchantID }}'
Expand All @@ -67,4 +66,4 @@
{% endif %}
})
</script>
<script src="{{ js_path }}"></script>
<script type="module" src="{{ js_path }}"></script>
30 changes: 8 additions & 22 deletions app/views/layout.njk
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,23 @@
<div class="govuk-header__container govuk-width-container">
<div class="govuk-header__logo">
<a href="https://www.gov.uk/" class="govuk-header__link govuk-header__link--homepage">
<span class="govuk-header__logotype">
<!--[if gt IE 8]><!-->
<svg
aria-hidden="true"
focusable="false"
class="govuk-header__logotype-crown"
role="img"
class="govuk-header__logotype"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 32 30"
viewBox="0 0 148 30"
height="30"
width="32"
width="148"
aria-label="GOV.UK"
>
<path
fill="currentColor" fill-rule="evenodd"
d="M22.6 10.4c-1 .4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 2 .1 2.4 1s-.1 2-1 2.4m-5.9 6.7c-.9.4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 2 .1 2.4 1s-.1 2-1 2.4m10.8-3.7c-1 .4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 2 .1 2.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-2v-13h4.1v13.6c0 1.2-.2 2.2-.6 3.1s-1 1.7-1.8 2.4c-.7.7-1.6 1.2-2.7 1.5-1 .4-2.2.5-3.4.5-1.2 0-2.4-.2-3.4-.5-1-.4-1.9-.9-2.7-1.5-.8-.7-1.3-1.5-1.8-2.4-.4-.9-.6-2-.6-3.1V6.9h4.2v13c0 .8.1 1.4.3 2 .2.6.5 1 .9 1.4.4.4.8.6 1.4.8.6.2 1.1.3 1.8.3zm13-17.4h4.2v9.1l7.4-9.1h5.2l-7.2 8.4L148 28h-4.9l-5.5-9.4-2.7 3V28h-4.2V7zm-27.6 16.1c-1.5 0-2.7 1.2-2.7 2.7s1.2 2.7 2.7 2.7 2.7-1.2 2.7-2.7-1.2-2.7-2.7-2.7z"></path>
</svg>
<!--<![endif]-->
<!--[if IE 8]>
<img src="/assets/images/govuk-logotype-tudor-crown.png" class="govuk-header__logotype-crown-fallback-image" width="32" height="30" alt="">
<![endif]-->
<span class="govuk-header__logotype-text">
GOV.UK
</span>
</span>
</a>
</div>
<div class="govuk-header__content">
<span class="govuk-header__link--service-name">
<span class="govuk-header__service-name">
{{serviceName}}
</span>
</div>
Expand All @@ -66,10 +56,6 @@
{% endif %}
{% endblock %}

{% block bodyStart %}
{% include "includes/cookie-message.njk" %}
{% endblock %}

{% block bodyEnd %}
{# Run JavaScript at end of the <body>, to avoid blocking the initial render. #}
{% include "includes/scripts.njk" %}
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"express": "4.19.x",
"express-rate-limit": "^7.1.4",
"gaap-analytics": "^3.1.0",
"govuk-frontend": "^4.8.0",
"govuk-frontend": "^5.6.0",
"helmet": "^7.1.0",
"hpagent": "^1.2.0",
"i18n": "0.15.x",
Expand Down
8 changes: 4 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const publicCaching = { maxAge: oneYear }

// Define app views
const APP_VIEWS = [
path.join(__dirname, 'node_modules/govuk-frontend/'),
path.join(__dirname, 'node_modules/govuk-frontend/dist/'),
path.join(__dirname, '/app/views')
]

Expand All @@ -58,7 +58,7 @@ function initialiseGlobalMiddleware (app) {
app.set('settings', { getVersionedPath: staticify.getVersionedPath })

app.use(/\/((?!images|public|stylesheets|javascripts).)*/, loggingMiddleware())
app.use(favicon(path.join(__dirname, '/node_modules/govuk-frontend/govuk/assets/images', 'favicon.ico')))
app.use(favicon(path.join(__dirname, '/node_modules/govuk-frontend/dist/govuk/assets/images', 'favicon.ico')))
app.use(staticify.middleware)

app.use(function (req, res, next) {
Expand Down Expand Up @@ -140,9 +140,9 @@ function initialisePublic (app) {
app.use('/stylesheets', express.static(path.join(__dirname, '/public/assets/stylesheets'), publicCaching))

if (process.env.NGINX_CACHING_ENABLED === 'true') {
app.use('/', express.static(path.join(__dirname, '/node_modules/govuk-frontend/govuk/'), publicCaching))
app.use('/', express.static(path.join(__dirname, '/node_modules/govuk-frontend/dist/govuk/'), publicCaching))
} else {
app.use('/', express.static(path.join(__dirname, '/node_modules/govuk-frontend/govuk/')))
app.use('/', express.static(path.join(__dirname, '/node_modules/govuk-frontend/dist/govuk/')))
}

app.use('/public', express.static(path.join(__dirname, '/node_modules/@govuk-pay/pay-js-commons/')))
Expand Down
1 change: 0 additions & 1 deletion test/integration/charge-status.ft.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ describe('chargeTests', function () {
expect($('#card-details #csrf').attr('value')).to.not.be.empty // eslint-disable-line
expect($('#amount').text()).to.eql('£23.45')
expect($('#payment-description').text()).to.contain('Payment Description')
expect($('#govuk-script-analytics')[0].children[0].data).to.contains(`init('${gatewayAccount.analyticsId}', '${gatewayAccount.type}', 'sandbox', '23.45', '')`)
expect($('#card-details').attr('action')).to.eql(frontendCardDetailsPostPath)
})
.end(done)
Expand Down
2 changes: 1 addition & 1 deletion test/test-helpers/html-assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const nunjucks = require('nunjucks')
const lodash = require('lodash')

// Global initialisation
const views = ['./app/views', './node_modules/govuk-frontend']
const views = ['./app/views', './node_modules/govuk-frontend/dist']
const environment = nunjucks.configure(views)
const strings = require('./../../locales/en.json')

Expand Down
Loading