@govuk-pay/pay-js-commons 3.8.7 → 3.8.8
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/.github/workflows/run-tests.yml +3 -3
- package/.idea/codeStyles/Project.xml +2 -5
- package/.idea/misc.xml +0 -3
- package/.idea/sonarlint/issuestore/index.pb +0 -119
- package/images/custom/gwent-police.png +0 -0
- package/lib/analytics/cookies/validate.js +1 -24
- package/lib/analytics/dist/cookies.js +1 -24
- package/lib/analytics/index.js +0 -1
- package/lib/browsered/field-validation/field-validation.js +4 -22
- package/lib/constants/index.js +1 -1
- package/lib/index.js +2 -7
- package/lib/logging/format.js +1 -2
- package/lib/logging/index.js +1 -4
- package/lib/logging/keys.js +66 -33
- package/lib/logging/request-log-format.js +0 -2
- package/lib/nunjucks-filters/country-iso-to-name.js +1 -2
- package/lib/nunjucks-filters/datetime.js +0 -3
- package/lib/nunjucks-filters/remove-indefinite-articles.js +1 -0
- package/lib/nunjucks-filters/slugify.js +0 -1
- package/lib/utils/countries.js +8 -10
- package/lib/utils/currency-formatter.js +2 -10
- package/lib/utils/field-validation-checks.js +6 -22
- package/lib/utils/is-valid-email.js +2 -3
- package/package.json +3 -3
- package/sass/custom/gwent-police.scss +55 -0
- package/.idea/aws.xml +0 -11
- package/.idea/jpa-buddy.xml +0 -6
- package/.idea/sonarlint/issuestore/0/3/0398ccd0f49298b10a3d76a47800d2ebecd49859 +0 -0
- package/.idea/sonarlint/issuestore/0/a/0aafd45b83a7a2f2979edee0ecd4f69921cb6914 +0 -0
- package/.idea/sonarlint/issuestore/0/a/0ab90bbd755fb821ff9a7a389d27ecf24fde7721 +0 -0
- package/.idea/sonarlint/issuestore/0/f/0f2db5e04bd1a4d58f88f0b5e06da8f75879068c +0 -0
- package/.idea/sonarlint/issuestore/1/0/1059ffd486aaf829fa5d1e15979d3afff31267be +0 -0
- package/.idea/sonarlint/issuestore/1/b/1b953f6fcfc364492f8d5a0320de136123cf5e7b +0 -0
- package/.idea/sonarlint/issuestore/1/d/1d086eb8ad446fac3834cef1541ba21ae3251bcc +0 -0
- package/.idea/sonarlint/issuestore/1/f/1f037704682f11e39f492baff56efed0cdebda24 +0 -0
- package/.idea/sonarlint/issuestore/2/2/2237bd8a346687a1cac0fa10af53b9f44b83975d +0 -0
- package/.idea/sonarlint/issuestore/2/7/279de1c4b2460f3d77db4439c32d24a5e8f4daa5 +0 -0
- package/.idea/sonarlint/issuestore/2/8/28a669ba97fc48322050d552b704fee882e22ea1 +0 -0
- package/.idea/sonarlint/issuestore/2/c/2c2e25e54af134656f786492369f2d309af6fc5d +0 -0
- package/.idea/sonarlint/issuestore/2/d/2d83766dd283a47d86fda16cefdc1d9ff0e10ebf +0 -0
- package/.idea/sonarlint/issuestore/3/0/3095dbf3cf3c05f05d4f32eadb2235861331dceb +0 -0
- package/.idea/sonarlint/issuestore/3/f/3f1338f565197b8d3fae4ce389ffcf4781c0940a +0 -0
- package/.idea/sonarlint/issuestore/4/6/4618075fb32da882b46f5fa15732392152d50ecb +0 -0
- package/.idea/sonarlint/issuestore/5/9/59403cebb5f53e0d0d6a43d33c6d48735b723ef2 +0 -0
- package/.idea/sonarlint/issuestore/6/1/61f351241eb319746c9e47ca6a4c3a5d1622a391 +0 -0
- package/.idea/sonarlint/issuestore/6/6/66d847400b1fd796f14ab3b04c1c578a7266cde3 +0 -0
- package/.idea/sonarlint/issuestore/6/b/6bc677a389caa5fb3a8e282cbf69ade319fc9a21 +0 -0
- package/.idea/sonarlint/issuestore/6/d/6d5c5d647c0e0271ba0ce9383f68956c485b7109 +0 -0
- package/.idea/sonarlint/issuestore/6/d/6d86fb56fc16c3b07b7720091ec21623bfd901b6 +0 -0
- package/.idea/sonarlint/issuestore/6/f/6facc008124fe02a29743441c6504e92d6552fa4 +0 -0
- package/.idea/sonarlint/issuestore/7/2/72f6352a42775f83fdc03e7894ace532dbb6f517 +0 -0
- package/.idea/sonarlint/issuestore/7/3/73f8180a536551397babaf20e8ba02db8fcc8018 +0 -0
- package/.idea/sonarlint/issuestore/7/4/74f3a79eac0dbec82b9a27402e12d0073e08a5f8 +0 -0
- package/.idea/sonarlint/issuestore/7/5/758a4f5d479af1e5210875f0f98433be652f3fbe +0 -0
- package/.idea/sonarlint/issuestore/7/8/7876a5b99181b0fabab7cc0139177b0d28437231 +0 -0
- package/.idea/sonarlint/issuestore/7/a/7af2f4f8529d55f0d321898d1d1432bc82062bfb +0 -0
- package/.idea/sonarlint/issuestore/7/f/7f9487bbbd0beaa9bb22a2869949b73f98bcb381 +0 -0
- package/.idea/sonarlint/issuestore/8/1/8136864071632c6a6005186e654fffb6c71ab55c +0 -0
- package/.idea/sonarlint/issuestore/8/2/8278e8d1860b14a402edb0bf2dd8635b9494b825 +0 -0
- package/.idea/sonarlint/issuestore/8/9/89d7784ed3c4a135de160b8d15fa1ba408a1b95b +0 -0
- package/.idea/sonarlint/issuestore/8/c/8c479353042b750132c1b668ab300ad15cf62b6b +0 -0
- package/.idea/sonarlint/issuestore/8/e/8e8b5c51bd5ce0407afd8f6a27b00b6a4de1f7cc +0 -0
- package/.idea/sonarlint/issuestore/a/1/a16ffce9c4014536b0d5997f1ff408f19a8510f7 +0 -0
- package/.idea/sonarlint/issuestore/a/3/a3882a485e785ac85771fbc3472bc0f8db07e074 +0 -0
- package/.idea/sonarlint/issuestore/a/b/ab50b2d311d3896c85a763e50b918113b4ef432d +0 -0
- package/.idea/sonarlint/issuestore/a/c/ac144cdcf526351c17f77f4845a5e6d0c46c5420 +0 -0
- package/.idea/sonarlint/issuestore/b/3/b32d76c4339f54eb551e11b44e4442dba06ab61e +0 -0
- package/.idea/sonarlint/issuestore/b/3/b3f38ade028e88019dd06ebcf5ca13096ca42238 +0 -0
- package/.idea/sonarlint/issuestore/b/8/b8c547eabe39aba372c866c1536d31bb75113eae +0 -0
- package/.idea/sonarlint/issuestore/b/9/b990dd75f097078d3650d1f96db34389de3006f0 +0 -0
- package/.idea/sonarlint/issuestore/b/9/b9ccc38dcaeab6f307ef082a1949fb667086e1d4 +0 -0
- package/.idea/sonarlint/issuestore/b/f/bf508a13685ded4f0ec65ce26175cc8817dff2a4 +0 -0
- package/.idea/sonarlint/issuestore/c/0/c05b26827bd656232e66b52c6308aa5964872576 +0 -0
- package/.idea/sonarlint/issuestore/c/5/c58a0bc65aae46f70f89ccc3ee87b23d1ed6450a +0 -0
- package/.idea/sonarlint/issuestore/c/5/c5befeaa8e93d7c83f1cc31a8d2813217dcdb78a +0 -0
- package/.idea/sonarlint/issuestore/c/8/c8effc650c46f8b8849324e542704a2a4590fda1 +0 -0
- package/.idea/sonarlint/issuestore/d/6/d6ca95ce28b96fac596da957816f6d5c412d710e +0 -0
- package/.idea/sonarlint/issuestore/d/9/d90a7ced84c440cd9d5a64b40706da73ad5ddcc7 +0 -0
- package/.idea/sonarlint/issuestore/d/b/db86b36380665f2fa5018837e2883be30ccecfce +0 -0
- package/.idea/sonarlint/issuestore/e/5/e5132d8ae9db481b8157a52af70817a8c75a4285 +0 -0
- package/.idea/sonarlint/issuestore/e/8/e8dbcbeccb811bc561c49e95a487033a5e7b28fe +0 -0
- package/.idea/sonarlint/issuestore/e/a/ea864c9949202498771817849e38d80c7cba1e2b +0 -0
- package/.idea/sonarlint/issuestore/f/7/f7a87ae0426cafc2323c6c7ea540fb129c638c87 +0 -0
- package/.idea/sonarlint/issuestore/f/a/fa288d1472d29beccb489a676f68739ad365fc47 +0 -0
- package/.idea/sonarlint/issuestore/f/c/fc17fd10e100b024763ee6c8df2361587d6f282a +0 -0
- package/.idea/sonarlint/issuestore/f/c/fce3b30bccc478e9ebb36570f32eb3de1e4205cf +0 -0
package/lib/logging/keys.js
CHANGED
|
@@ -1,75 +1,108 @@
|
|
|
1
|
-
'use strict';
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// This file needs to be kept in sync with its Java consociate
|
|
2
4
|
// https://github.com/alphagov/pay-java-commons/blob/master/logging/src/main/java/uk/gov/pay/logging/LoggingKeys.java
|
|
5
|
+
|
|
3
6
|
// "card", "Direct Debit"
|
|
7
|
+
exports.PAYMENT_TYPE = 'payment_type';
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
// "payment", "mandate", "refund"
|
|
10
|
+
exports.RESOURCE_TYPE = 'resource_type';
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
// "sandbox", "Worldpay", "Smartpay", "ePDQ", "Stripe", "GoCardless"
|
|
13
|
+
exports.PROVIDER = 'provider';
|
|
8
14
|
|
|
9
|
-
|
|
15
|
+
// The digital wallet used for a payment
|
|
10
16
|
// Value must be a value of the WalletType enum
|
|
11
17
|
// https://github.com/alphagov/pay-connector/blob/master/src/main/java/uk/gov/pay/connector/wallets/WalletType.java
|
|
18
|
+
exports.WALLET = 'wallet';
|
|
12
19
|
|
|
13
|
-
|
|
20
|
+
// The type of a gateway account
|
|
14
21
|
// Value must be a value of the GatewayAccountEntity.Type enum
|
|
15
22
|
// https://github.com/alphagov/pay-connector/blob/master/src/main/java/uk/gov/pay/connector/gatewayaccount/model/GatewayAccountEntity.java
|
|
23
|
+
exports.GATEWAY_ACCOUNT_TYPE = 'gateway_account_type';
|
|
16
24
|
|
|
17
|
-
|
|
25
|
+
// The type of operation being performed with a gateway for a card payment
|
|
18
26
|
// Value must be a value of the OperationType enum
|
|
19
27
|
// https://github.com/alphagov/pay-connector/blob/master/src/main/java/uk/gov/pay/connector/paymentprocessor/model/OperationType.java
|
|
28
|
+
exports.GATEWAY_CARD_OPERATION = 'gateway_card_operation';
|
|
20
29
|
|
|
21
|
-
|
|
30
|
+
// The amount of a payment in pence
|
|
31
|
+
exports.AMOUNT = 'amount';
|
|
22
32
|
|
|
23
|
-
|
|
33
|
+
// Mandate external id
|
|
34
|
+
exports.MANDATE_EXTERNAL_ID = 'mandate_external_id';
|
|
24
35
|
|
|
25
|
-
|
|
36
|
+
// The PSP's identifier for a payment
|
|
37
|
+
exports.PROVIDER_PAYMENT_ID = 'provider_payment_id';
|
|
26
38
|
|
|
27
|
-
|
|
39
|
+
// The ID a provider gives to an event (e.g. one in a notification)
|
|
40
|
+
exports.PROVIDER_EVENT_ID = 'provider_event_id';
|
|
28
41
|
|
|
29
|
-
|
|
42
|
+
// The reference a partner service assigns to a payment, mandate etc.
|
|
43
|
+
exports.SERVICE_PAYMENT_REFERENCE = 'service_reference';
|
|
30
44
|
|
|
31
|
-
|
|
45
|
+
// The ID GOV.UK Pay gives to a gateway account
|
|
46
|
+
exports.GATEWAY_ACCOUNT_ID = 'gateway_account_id';
|
|
32
47
|
|
|
33
|
-
|
|
48
|
+
// The ID of an event emitted to ledger
|
|
49
|
+
exports.LEDGER_EVENT_ID = 'ledger_event_id';
|
|
34
50
|
|
|
35
|
-
|
|
51
|
+
// The type of an event emitted to ledger
|
|
52
|
+
exports.LEDGER_EVENT_TYPE = 'ledger_event_type';
|
|
36
53
|
|
|
37
|
-
|
|
54
|
+
// The type of an internal event recorded by Direct Debit
|
|
38
55
|
// Value must be a value from the GovUkPayEventType enum
|
|
39
56
|
// https://github.com/alphagov/pay-direct-debit-connector/blob/master/src/main/java/uk/gov/pay/directdebit/events/model/GovUkPayEventType.java
|
|
57
|
+
exports.DIRECT_DEBIT_INTERNAL_EVENT_TYPE = 'direct_debit_internal_event_type';
|
|
40
58
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
exports.CURRENT_INTERNAL_STATE = 'current_internal_state'; // The previous internal state of a payment, mandate etc. when transitioning
|
|
59
|
+
// The current (or new if transitioning) internal state of a payment, mandate etc.
|
|
60
|
+
exports.CURRENT_INTERNAL_STATE = 'current_internal_state';
|
|
44
61
|
|
|
45
|
-
|
|
62
|
+
// The previous internal state of a payment, mandate etc. when transitioning
|
|
63
|
+
exports.PREVIOUS_INTERNAL_STATUS = 'previous_internal_status';
|
|
46
64
|
|
|
47
|
-
|
|
65
|
+
// The last event (status) that Worldpay recorded for a payment, refund etc.
|
|
66
|
+
exports.WORLDPAY_LAST_EVENT = 'worldpay_last_event';
|
|
48
67
|
|
|
49
|
-
|
|
68
|
+
// The result code (status) that Smartpay recorded for a payment, refund etc.
|
|
69
|
+
exports.SMARTPAY_RESULT_CODE = 'smartpay_result_code';
|
|
50
70
|
|
|
51
|
-
|
|
71
|
+
// The status code that ePDQ recorded for a payment, refund etc.
|
|
72
|
+
exports.EPDQ_STATUS = 'epdq_status';
|
|
52
73
|
|
|
53
|
-
|
|
74
|
+
// The status that Stripe recorded for a payment, refund etc.
|
|
75
|
+
exports.STRIPE_STATUS = 'stripe_status';
|
|
54
76
|
|
|
55
|
-
|
|
77
|
+
// The action that GoCardless recorded for a payment, mandate etc.
|
|
78
|
+
exports.GOCARDLESS_PAYMENT_ACTION = 'gocardless_action';
|
|
56
79
|
|
|
57
|
-
|
|
80
|
+
// The HTTP status we sent to a client
|
|
81
|
+
exports.HTTP_STATUS = 'http_status';
|
|
58
82
|
|
|
59
|
-
|
|
83
|
+
// The HTTP status code we received from a remote server (e.g. a payment provider)
|
|
84
|
+
exports.REMOTE_HTTP_STATUS = 'remote_http_status';
|
|
60
85
|
|
|
61
|
-
|
|
86
|
+
// AWS error code
|
|
87
|
+
exports.AWS_ERROR_CODE = 'aws_error_code';
|
|
62
88
|
|
|
63
|
-
|
|
89
|
+
// The correlation id for the request
|
|
90
|
+
exports.CORRELATION_ID = 'x_request_id';
|
|
64
91
|
|
|
65
|
-
|
|
92
|
+
// Payment External Id
|
|
93
|
+
exports.PAYMENT_EXTERNAL_ID = 'payment_external_id';
|
|
66
94
|
|
|
67
|
-
|
|
95
|
+
// Refund External Id
|
|
96
|
+
exports.REFUND_EXTERNAL_ID = 'refund_external_id';
|
|
68
97
|
|
|
69
|
-
|
|
98
|
+
// Secure Token
|
|
99
|
+
exports.SECURE_TOKEN = 'secure_token';
|
|
70
100
|
|
|
71
|
-
|
|
101
|
+
// User external id
|
|
102
|
+
exports.USER_EXTERNAL_ID = 'user_external_id';
|
|
72
103
|
|
|
73
|
-
|
|
104
|
+
// A service's external id
|
|
105
|
+
exports.SERVICE_EXTERNAL_ID = 'service_external_id';
|
|
74
106
|
|
|
107
|
+
// product external id
|
|
75
108
|
exports.PRODUCT_EXTERNAL_ID = 'product_external_id';
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
module.exports = function () {
|
|
4
4
|
var correlationIdHeader = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'x-request-id';
|
|
5
|
-
|
|
6
5
|
var format = function format(tokens, req, res) {
|
|
7
6
|
return JSON.stringify({
|
|
8
7
|
/* eslint-disable camelcase */
|
|
@@ -18,7 +17,6 @@ module.exports = function () {
|
|
|
18
17
|
response_time: "".concat(tokens['response-time'](req, res), " ms"),
|
|
19
18
|
x_request_id: tokens.req(req, res, correlationIdHeader)
|
|
20
19
|
/* eslint-enable camelcase */
|
|
21
|
-
|
|
22
20
|
});
|
|
23
21
|
};
|
|
24
22
|
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var moment = require('moment-timezone');
|
|
4
|
-
|
|
5
4
|
module.exports = function (isoTimeString, format) {
|
|
6
5
|
var formatString = 'D MMMM YYYY h:mm:ssa z';
|
|
7
|
-
|
|
8
6
|
if (format === 'date') {
|
|
9
7
|
formatString = 'DD/MM/YYYY';
|
|
10
8
|
} else if (format === 'datelong') {
|
|
@@ -12,6 +10,5 @@ module.exports = function (isoTimeString, format) {
|
|
|
12
10
|
} else if (format === 'time') {
|
|
13
11
|
formatString = 'HH:mm:ss';
|
|
14
12
|
}
|
|
15
|
-
|
|
16
13
|
return moment(isoTimeString).tz('Europe/London').format(formatString);
|
|
17
14
|
};
|
package/lib/utils/countries.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var lodash = require('lodash'); // Local Dependencies
|
|
1
|
+
'use strict';
|
|
4
2
|
|
|
3
|
+
// NPM Dependencies
|
|
4
|
+
var lodash = require('lodash');
|
|
5
5
|
|
|
6
|
+
// Local Dependencies
|
|
6
7
|
var countries = require('../data/countries.json');
|
|
8
|
+
var extensions = require('../data/country-record-extension.json');
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
// Merge the additional data into the register data
|
|
11
11
|
countries.forEach(function (country) {
|
|
12
12
|
var extension = extensions.find(function (item) {
|
|
13
13
|
return item.country === country;
|
|
14
14
|
});
|
|
15
|
-
|
|
16
15
|
if (extension) {
|
|
17
16
|
country.entry.aliases = extension.aliases;
|
|
18
17
|
country.entry.weighting = extension.weighting;
|
|
@@ -21,8 +20,9 @@ countries.forEach(function (country) {
|
|
|
21
20
|
countries = lodash.compact(countries);
|
|
22
21
|
countries = lodash.sortBy(countries, function (country) {
|
|
23
22
|
return country.entry.name.toLowerCase();
|
|
24
|
-
});
|
|
23
|
+
});
|
|
25
24
|
|
|
25
|
+
// Exports
|
|
26
26
|
exports.retrieveCountries = function (selectedCountry) {
|
|
27
27
|
var countriesList = lodash.clone(countries);
|
|
28
28
|
countriesList.forEach(function (country) {
|
|
@@ -30,7 +30,6 @@ exports.retrieveCountries = function (selectedCountry) {
|
|
|
30
30
|
});
|
|
31
31
|
return countriesList;
|
|
32
32
|
};
|
|
33
|
-
|
|
34
33
|
exports.govukFrontendFormatted = function (selectedCountry) {
|
|
35
34
|
var countriesList = lodash.clone(countries);
|
|
36
35
|
countriesList.forEach(function (country) {
|
|
@@ -40,7 +39,6 @@ exports.govukFrontendFormatted = function (selectedCountry) {
|
|
|
40
39
|
});
|
|
41
40
|
return countriesList;
|
|
42
41
|
};
|
|
43
|
-
|
|
44
42
|
exports.translateAlpha2 = function (alpha2Code) {
|
|
45
43
|
return countries.find(function (country) {
|
|
46
44
|
return country.entry.country === alpha2Code;
|
|
@@ -1,44 +1,36 @@
|
|
|
1
|
-
'use strict';
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
+
// Local contants
|
|
3
4
|
var AMOUNT_FORMAT = /^(\d+)(?:\.(\d{1,2}))?$/;
|
|
4
|
-
|
|
5
5
|
var penceToPounds = function penceToPounds(amount) {
|
|
6
6
|
return (amount / 100).toFixed(2);
|
|
7
7
|
};
|
|
8
|
-
|
|
9
8
|
var poundsToPence = function poundsToPence(amount) {
|
|
10
9
|
return (amount * 100).toFixed(0);
|
|
11
10
|
};
|
|
12
|
-
|
|
13
11
|
var penceToPoundsWithCurrency = function penceToPoundsWithCurrency(amount) {
|
|
14
12
|
return new Intl.NumberFormat('en-gb', {
|
|
15
13
|
style: 'currency',
|
|
16
14
|
currency: 'GBP'
|
|
17
15
|
}).format(penceToPounds(amount));
|
|
18
16
|
};
|
|
19
|
-
|
|
20
17
|
var sanitisePoundsAndPenceInput = function sanitisePoundsAndPenceInput(amount) {
|
|
21
18
|
if (amount) {
|
|
22
19
|
var cleanedCurrencyString = amount.replace(/[^0-9.-]+/g, '');
|
|
23
20
|
var result = AMOUNT_FORMAT.exec(cleanedCurrencyString);
|
|
24
|
-
|
|
25
21
|
if (result) {
|
|
26
22
|
var pounds = result[1];
|
|
27
23
|
var pence = result[2];
|
|
28
|
-
|
|
29
24
|
if (pence === undefined) {
|
|
30
25
|
pence = '00';
|
|
31
26
|
} else if (pence.length === 1) {
|
|
32
27
|
pence += '0';
|
|
33
28
|
}
|
|
34
|
-
|
|
35
29
|
return parseInt(pounds + pence, 10);
|
|
36
30
|
}
|
|
37
|
-
|
|
38
31
|
return null;
|
|
39
32
|
}
|
|
40
33
|
};
|
|
41
|
-
|
|
42
34
|
module.exports = {
|
|
43
35
|
penceToPounds: penceToPounds,
|
|
44
36
|
poundsToPence: poundsToPence,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
'use strict';
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var emailValidator = require('./is-valid-email'); // Constants
|
|
3
|
+
// NPM dependencies
|
|
4
|
+
var parseInt = require('lodash/parseInt');
|
|
7
5
|
|
|
6
|
+
// Local dependencies
|
|
7
|
+
var emailValidator = require('./is-valid-email');
|
|
8
8
|
|
|
9
|
+
// Constants
|
|
9
10
|
var NUMBERS_ONLY = /^\d+$/;
|
|
10
11
|
var MAX_AMOUNT = 100000;
|
|
11
12
|
var validationErrors = {
|
|
@@ -19,70 +20,53 @@ var validationErrors = {
|
|
|
19
20
|
isGreaterThanMaxLengthChars: 'The text is too long',
|
|
20
21
|
invalidCharacters: 'You cannot use any of the following characters < > ; : ` ( ) " \' = | , ~ [ ]'
|
|
21
22
|
};
|
|
22
|
-
|
|
23
23
|
exports.isEmpty = function (value) {
|
|
24
24
|
if (value === '') {
|
|
25
25
|
return validationErrors.required;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
27
|
return false;
|
|
29
28
|
};
|
|
30
|
-
|
|
31
29
|
exports.isCurrency = function (value) {
|
|
32
30
|
if (!/^(\d+)(?:\.(\d{1,2}))?$/.test(value)) {
|
|
33
31
|
return validationErrors.currency;
|
|
34
32
|
}
|
|
35
|
-
|
|
36
33
|
return false;
|
|
37
34
|
};
|
|
38
|
-
|
|
39
35
|
exports.isValidEmail = function (value) {
|
|
40
36
|
if (!emailValidator(value)) {
|
|
41
37
|
return validationErrors.validEmail;
|
|
42
38
|
}
|
|
43
|
-
|
|
44
39
|
return false;
|
|
45
40
|
};
|
|
46
|
-
|
|
47
41
|
exports.isPhoneNumber = function (value) {
|
|
48
42
|
var trimmedTelephoneNumber = value.replace(/\s/g, '');
|
|
49
|
-
|
|
50
43
|
if (trimmedTelephoneNumber.length < 11 || !NUMBERS_ONLY.test(trimmedTelephoneNumber)) {
|
|
51
44
|
return validationErrors.phoneNumber;
|
|
52
45
|
}
|
|
53
|
-
|
|
54
46
|
return false;
|
|
55
47
|
};
|
|
56
|
-
|
|
57
48
|
exports.isHttps = function (value) {
|
|
58
49
|
if (value.substr(0, 8) !== 'https://') {
|
|
59
50
|
return validationErrors.isHttps;
|
|
60
51
|
}
|
|
61
|
-
|
|
62
52
|
return false;
|
|
63
53
|
};
|
|
64
|
-
|
|
65
54
|
exports.isAboveMaxAmount = function (value) {
|
|
66
55
|
if (!exports.isCurrency(value) && parseFloat(value) > MAX_AMOUNT) {
|
|
67
56
|
return validationErrors.isAboveMaxAmount;
|
|
68
57
|
}
|
|
69
|
-
|
|
70
58
|
return false;
|
|
71
59
|
};
|
|
72
|
-
|
|
73
60
|
exports.isFieldGreaterThanMaxLengthChars = function (value, maxLength) {
|
|
74
61
|
var parsedMaxLength = parseInt(maxLength);
|
|
75
62
|
return parsedMaxLength && value.length > parsedMaxLength ? validationErrors.isGreaterThanMaxLengthChars : false;
|
|
76
63
|
};
|
|
77
|
-
|
|
78
64
|
exports.isPasswordLessThanTenChars = function (value) {
|
|
79
65
|
return !value || value.length < 10 ? validationErrors.isPasswordLessThanTenChars : false;
|
|
80
66
|
};
|
|
81
|
-
|
|
82
67
|
exports.isNaxsiSafe = function (value) {
|
|
83
68
|
if (/[<>;:`()"'=|,~[\]]+/g.test(value)) {
|
|
84
69
|
return validationErrors.invalidCharacters;
|
|
85
70
|
}
|
|
86
|
-
|
|
87
71
|
return false;
|
|
88
72
|
};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
'use strict';
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
+
// NPM dependencies
|
|
3
4
|
var rfc822Validator = require('rfc822-validate');
|
|
4
|
-
|
|
5
5
|
module.exports = function (email) {
|
|
6
6
|
if (rfc822Validator(email)) {
|
|
7
7
|
var domain = email.split('@')[1];
|
|
8
8
|
return !(domain && domain.indexOf('.') === -1);
|
|
9
9
|
}
|
|
10
|
-
|
|
11
10
|
return false;
|
|
12
11
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@govuk-pay/pay-js-commons",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.8",
|
|
4
4
|
"description": "Reusable js scripts for GOV.UK Pay Node.js projects",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": "^16.14.0"
|
|
@@ -135,9 +135,9 @@
|
|
|
135
135
|
},
|
|
136
136
|
"dependencies": {
|
|
137
137
|
"lodash": "4.17.21",
|
|
138
|
-
"moment-timezone": "0.5.
|
|
138
|
+
"moment-timezone": "0.5.42",
|
|
139
139
|
"rfc822-validate": "1.0.0",
|
|
140
|
-
"slugify": "1.6.
|
|
140
|
+
"slugify": "1.6.6",
|
|
141
141
|
"winston": "3.8.2"
|
|
142
142
|
}
|
|
143
143
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
$govuk-font-family: -apple-system,BlinkMacSystemFont,helvetica neue,helvetica,ubuntu,roboto,noto,segoe ui,arial,sans-serif; // Override font as so not to use New Transport
|
|
2
|
+
@import "application";
|
|
3
|
+
|
|
4
|
+
// CUSTOM BRANDING
|
|
5
|
+
// Use the variables below to control the style
|
|
6
|
+
// Make sure banner colours meet minimum colour contrast levels
|
|
7
|
+
|
|
8
|
+
$custom-banner-colour: #102B66;
|
|
9
|
+
$custom-banner-border-colour: #FBBC1B;
|
|
10
|
+
$custom-text-colour: #ffffff;
|
|
11
|
+
$logo-image-height: 2em;
|
|
12
|
+
|
|
13
|
+
.custom-branding {
|
|
14
|
+
@if $logo-image-height != null {
|
|
15
|
+
.custom-branding-image {
|
|
16
|
+
max-height: $logo-image-height;
|
|
17
|
+
|
|
18
|
+
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
|
|
19
|
+
width: 100%;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.govuk-header {
|
|
25
|
+
background-color: $custom-banner-colour;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.govuk-header__link{
|
|
29
|
+
&:link,
|
|
30
|
+
&:visited {
|
|
31
|
+
color: $custom-text-colour;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.govuk-header__link--service-name {
|
|
36
|
+
color: $custom-text-colour;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.govuk-header__container {
|
|
40
|
+
border-bottom-color: $custom-banner-border-colour;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@include govuk-media-query($from: tablet) {
|
|
44
|
+
.govuk-header__content {
|
|
45
|
+
width: 66%;
|
|
46
|
+
vertical-align: bottom;
|
|
47
|
+
margin-bottom: 7px;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.govuk-button {
|
|
52
|
+
padding: 7px 15px 6px;
|
|
53
|
+
padding: .368421053em .842105263em .315789474em;
|
|
54
|
+
}
|
|
55
|
+
}
|
package/.idea/aws.xml
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="accountSettings">
|
|
4
|
-
<option name="activeRegion" value="eu-west-1" />
|
|
5
|
-
<option name="recentlyUsedRegions">
|
|
6
|
-
<list>
|
|
7
|
-
<option value="eu-west-1" />
|
|
8
|
-
</list>
|
|
9
|
-
</option>
|
|
10
|
-
</component>
|
|
11
|
-
</project>
|
package/.idea/jpa-buddy.xml
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|