@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.
Files changed (86) hide show
  1. package/.github/workflows/run-tests.yml +3 -3
  2. package/.idea/codeStyles/Project.xml +2 -5
  3. package/.idea/misc.xml +0 -3
  4. package/.idea/sonarlint/issuestore/index.pb +0 -119
  5. package/images/custom/gwent-police.png +0 -0
  6. package/lib/analytics/cookies/validate.js +1 -24
  7. package/lib/analytics/dist/cookies.js +1 -24
  8. package/lib/analytics/index.js +0 -1
  9. package/lib/browsered/field-validation/field-validation.js +4 -22
  10. package/lib/constants/index.js +1 -1
  11. package/lib/index.js +2 -7
  12. package/lib/logging/format.js +1 -2
  13. package/lib/logging/index.js +1 -4
  14. package/lib/logging/keys.js +66 -33
  15. package/lib/logging/request-log-format.js +0 -2
  16. package/lib/nunjucks-filters/country-iso-to-name.js +1 -2
  17. package/lib/nunjucks-filters/datetime.js +0 -3
  18. package/lib/nunjucks-filters/remove-indefinite-articles.js +1 -0
  19. package/lib/nunjucks-filters/slugify.js +0 -1
  20. package/lib/utils/countries.js +8 -10
  21. package/lib/utils/currency-formatter.js +2 -10
  22. package/lib/utils/field-validation-checks.js +6 -22
  23. package/lib/utils/is-valid-email.js +2 -3
  24. package/package.json +3 -3
  25. package/sass/custom/gwent-police.scss +55 -0
  26. package/.idea/aws.xml +0 -11
  27. package/.idea/jpa-buddy.xml +0 -6
  28. package/.idea/sonarlint/issuestore/0/3/0398ccd0f49298b10a3d76a47800d2ebecd49859 +0 -0
  29. package/.idea/sonarlint/issuestore/0/a/0aafd45b83a7a2f2979edee0ecd4f69921cb6914 +0 -0
  30. package/.idea/sonarlint/issuestore/0/a/0ab90bbd755fb821ff9a7a389d27ecf24fde7721 +0 -0
  31. package/.idea/sonarlint/issuestore/0/f/0f2db5e04bd1a4d58f88f0b5e06da8f75879068c +0 -0
  32. package/.idea/sonarlint/issuestore/1/0/1059ffd486aaf829fa5d1e15979d3afff31267be +0 -0
  33. package/.idea/sonarlint/issuestore/1/b/1b953f6fcfc364492f8d5a0320de136123cf5e7b +0 -0
  34. package/.idea/sonarlint/issuestore/1/d/1d086eb8ad446fac3834cef1541ba21ae3251bcc +0 -0
  35. package/.idea/sonarlint/issuestore/1/f/1f037704682f11e39f492baff56efed0cdebda24 +0 -0
  36. package/.idea/sonarlint/issuestore/2/2/2237bd8a346687a1cac0fa10af53b9f44b83975d +0 -0
  37. package/.idea/sonarlint/issuestore/2/7/279de1c4b2460f3d77db4439c32d24a5e8f4daa5 +0 -0
  38. package/.idea/sonarlint/issuestore/2/8/28a669ba97fc48322050d552b704fee882e22ea1 +0 -0
  39. package/.idea/sonarlint/issuestore/2/c/2c2e25e54af134656f786492369f2d309af6fc5d +0 -0
  40. package/.idea/sonarlint/issuestore/2/d/2d83766dd283a47d86fda16cefdc1d9ff0e10ebf +0 -0
  41. package/.idea/sonarlint/issuestore/3/0/3095dbf3cf3c05f05d4f32eadb2235861331dceb +0 -0
  42. package/.idea/sonarlint/issuestore/3/f/3f1338f565197b8d3fae4ce389ffcf4781c0940a +0 -0
  43. package/.idea/sonarlint/issuestore/4/6/4618075fb32da882b46f5fa15732392152d50ecb +0 -0
  44. package/.idea/sonarlint/issuestore/5/9/59403cebb5f53e0d0d6a43d33c6d48735b723ef2 +0 -0
  45. package/.idea/sonarlint/issuestore/6/1/61f351241eb319746c9e47ca6a4c3a5d1622a391 +0 -0
  46. package/.idea/sonarlint/issuestore/6/6/66d847400b1fd796f14ab3b04c1c578a7266cde3 +0 -0
  47. package/.idea/sonarlint/issuestore/6/b/6bc677a389caa5fb3a8e282cbf69ade319fc9a21 +0 -0
  48. package/.idea/sonarlint/issuestore/6/d/6d5c5d647c0e0271ba0ce9383f68956c485b7109 +0 -0
  49. package/.idea/sonarlint/issuestore/6/d/6d86fb56fc16c3b07b7720091ec21623bfd901b6 +0 -0
  50. package/.idea/sonarlint/issuestore/6/f/6facc008124fe02a29743441c6504e92d6552fa4 +0 -0
  51. package/.idea/sonarlint/issuestore/7/2/72f6352a42775f83fdc03e7894ace532dbb6f517 +0 -0
  52. package/.idea/sonarlint/issuestore/7/3/73f8180a536551397babaf20e8ba02db8fcc8018 +0 -0
  53. package/.idea/sonarlint/issuestore/7/4/74f3a79eac0dbec82b9a27402e12d0073e08a5f8 +0 -0
  54. package/.idea/sonarlint/issuestore/7/5/758a4f5d479af1e5210875f0f98433be652f3fbe +0 -0
  55. package/.idea/sonarlint/issuestore/7/8/7876a5b99181b0fabab7cc0139177b0d28437231 +0 -0
  56. package/.idea/sonarlint/issuestore/7/a/7af2f4f8529d55f0d321898d1d1432bc82062bfb +0 -0
  57. package/.idea/sonarlint/issuestore/7/f/7f9487bbbd0beaa9bb22a2869949b73f98bcb381 +0 -0
  58. package/.idea/sonarlint/issuestore/8/1/8136864071632c6a6005186e654fffb6c71ab55c +0 -0
  59. package/.idea/sonarlint/issuestore/8/2/8278e8d1860b14a402edb0bf2dd8635b9494b825 +0 -0
  60. package/.idea/sonarlint/issuestore/8/9/89d7784ed3c4a135de160b8d15fa1ba408a1b95b +0 -0
  61. package/.idea/sonarlint/issuestore/8/c/8c479353042b750132c1b668ab300ad15cf62b6b +0 -0
  62. package/.idea/sonarlint/issuestore/8/e/8e8b5c51bd5ce0407afd8f6a27b00b6a4de1f7cc +0 -0
  63. package/.idea/sonarlint/issuestore/a/1/a16ffce9c4014536b0d5997f1ff408f19a8510f7 +0 -0
  64. package/.idea/sonarlint/issuestore/a/3/a3882a485e785ac85771fbc3472bc0f8db07e074 +0 -0
  65. package/.idea/sonarlint/issuestore/a/b/ab50b2d311d3896c85a763e50b918113b4ef432d +0 -0
  66. package/.idea/sonarlint/issuestore/a/c/ac144cdcf526351c17f77f4845a5e6d0c46c5420 +0 -0
  67. package/.idea/sonarlint/issuestore/b/3/b32d76c4339f54eb551e11b44e4442dba06ab61e +0 -0
  68. package/.idea/sonarlint/issuestore/b/3/b3f38ade028e88019dd06ebcf5ca13096ca42238 +0 -0
  69. package/.idea/sonarlint/issuestore/b/8/b8c547eabe39aba372c866c1536d31bb75113eae +0 -0
  70. package/.idea/sonarlint/issuestore/b/9/b990dd75f097078d3650d1f96db34389de3006f0 +0 -0
  71. package/.idea/sonarlint/issuestore/b/9/b9ccc38dcaeab6f307ef082a1949fb667086e1d4 +0 -0
  72. package/.idea/sonarlint/issuestore/b/f/bf508a13685ded4f0ec65ce26175cc8817dff2a4 +0 -0
  73. package/.idea/sonarlint/issuestore/c/0/c05b26827bd656232e66b52c6308aa5964872576 +0 -0
  74. package/.idea/sonarlint/issuestore/c/5/c58a0bc65aae46f70f89ccc3ee87b23d1ed6450a +0 -0
  75. package/.idea/sonarlint/issuestore/c/5/c5befeaa8e93d7c83f1cc31a8d2813217dcdb78a +0 -0
  76. package/.idea/sonarlint/issuestore/c/8/c8effc650c46f8b8849324e542704a2a4590fda1 +0 -0
  77. package/.idea/sonarlint/issuestore/d/6/d6ca95ce28b96fac596da957816f6d5c412d710e +0 -0
  78. package/.idea/sonarlint/issuestore/d/9/d90a7ced84c440cd9d5a64b40706da73ad5ddcc7 +0 -0
  79. package/.idea/sonarlint/issuestore/d/b/db86b36380665f2fa5018837e2883be30ccecfce +0 -0
  80. package/.idea/sonarlint/issuestore/e/5/e5132d8ae9db481b8157a52af70817a8c75a4285 +0 -0
  81. package/.idea/sonarlint/issuestore/e/8/e8dbcbeccb811bc561c49e95a487033a5e7b28fe +0 -0
  82. package/.idea/sonarlint/issuestore/e/a/ea864c9949202498771817849e38d80c7cba1e2b +0 -0
  83. package/.idea/sonarlint/issuestore/f/7/f7a87ae0426cafc2323c6c7ea540fb129c638c87 +0 -0
  84. package/.idea/sonarlint/issuestore/f/a/fa288d1472d29beccb489a676f68739ad365fc47 +0 -0
  85. package/.idea/sonarlint/issuestore/f/c/fc17fd10e100b024763ee6c8df2361587d6f282a +0 -0
  86. package/.idea/sonarlint/issuestore/f/c/fce3b30bccc478e9ebb36570f32eb3de1e4205cf +0 -0
@@ -1,75 +1,108 @@
1
- 'use strict'; // This file needs to be kept in sync with its Java consociate
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
- exports.PAYMENT_TYPE = 'payment_type'; // "payment", "mandate", "refund"
9
+ // "payment", "mandate", "refund"
10
+ exports.RESOURCE_TYPE = 'resource_type';
6
11
 
7
- exports.RESOURCE_TYPE = 'resource_type'; // "sandbox", "Worldpay", "Smartpay", "ePDQ", "Stripe", "GoCardless"
12
+ // "sandbox", "Worldpay", "Smartpay", "ePDQ", "Stripe", "GoCardless"
13
+ exports.PROVIDER = 'provider';
8
14
 
9
- exports.PROVIDER = 'provider'; // The digital wallet used for a payment
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
- exports.WALLET = 'wallet'; // The type of a gateway account
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
- exports.GATEWAY_ACCOUNT_TYPE = 'gateway_account_type'; // The type of operation being performed with a gateway for a card payment
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
- exports.GATEWAY_CARD_OPERATION = 'gateway_card_operation'; // The amount of a payment in pence
30
+ // The amount of a payment in pence
31
+ exports.AMOUNT = 'amount';
22
32
 
23
- exports.AMOUNT = 'amount'; // Mandate external id
33
+ // Mandate external id
34
+ exports.MANDATE_EXTERNAL_ID = 'mandate_external_id';
24
35
 
25
- exports.MANDATE_EXTERNAL_ID = 'mandate_external_id'; // The PSP's identifier for a payment
36
+ // The PSP's identifier for a payment
37
+ exports.PROVIDER_PAYMENT_ID = 'provider_payment_id';
26
38
 
27
- exports.PROVIDER_PAYMENT_ID = 'provider_payment_id'; // The ID a provider gives to an event (e.g. one in a notification)
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
- exports.PROVIDER_EVENT_ID = 'provider_event_id'; // The reference a partner service assigns to a payment, mandate etc.
42
+ // The reference a partner service assigns to a payment, mandate etc.
43
+ exports.SERVICE_PAYMENT_REFERENCE = 'service_reference';
30
44
 
31
- exports.SERVICE_PAYMENT_REFERENCE = 'service_reference'; // The ID GOV.UK Pay gives to a gateway account
45
+ // The ID GOV.UK Pay gives to a gateway account
46
+ exports.GATEWAY_ACCOUNT_ID = 'gateway_account_id';
32
47
 
33
- exports.GATEWAY_ACCOUNT_ID = 'gateway_account_id'; // The ID of an event emitted to ledger
48
+ // The ID of an event emitted to ledger
49
+ exports.LEDGER_EVENT_ID = 'ledger_event_id';
34
50
 
35
- exports.LEDGER_EVENT_ID = 'ledger_event_id'; // The type of an event emitted to ledger
51
+ // The type of an event emitted to ledger
52
+ exports.LEDGER_EVENT_TYPE = 'ledger_event_type';
36
53
 
37
- exports.LEDGER_EVENT_TYPE = 'ledger_event_type'; // The type of an internal event recorded by Direct Debit
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
- exports.DIRECT_DEBIT_INTERNAL_EVENT_TYPE = 'direct_debit_internal_event_type'; // The current (or new if transitioning) internal state of a payment, mandate etc.
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
- exports.PREVIOUS_INTERNAL_STATUS = 'previous_internal_status'; // The last event (status) that Worldpay recorded for a payment, refund etc.
62
+ // The previous internal state of a payment, mandate etc. when transitioning
63
+ exports.PREVIOUS_INTERNAL_STATUS = 'previous_internal_status';
46
64
 
47
- exports.WORLDPAY_LAST_EVENT = 'worldpay_last_event'; // The result code (status) that Smartpay recorded for a payment, refund etc.
65
+ // The last event (status) that Worldpay recorded for a payment, refund etc.
66
+ exports.WORLDPAY_LAST_EVENT = 'worldpay_last_event';
48
67
 
49
- exports.SMARTPAY_RESULT_CODE = 'smartpay_result_code'; // The status code that ePDQ recorded for a payment, refund etc.
68
+ // The result code (status) that Smartpay recorded for a payment, refund etc.
69
+ exports.SMARTPAY_RESULT_CODE = 'smartpay_result_code';
50
70
 
51
- exports.EPDQ_STATUS = 'epdq_status'; // The status that Stripe recorded for a payment, refund etc.
71
+ // The status code that ePDQ recorded for a payment, refund etc.
72
+ exports.EPDQ_STATUS = 'epdq_status';
52
73
 
53
- exports.STRIPE_STATUS = 'stripe_status'; // The action that GoCardless recorded for a payment, mandate etc.
74
+ // The status that Stripe recorded for a payment, refund etc.
75
+ exports.STRIPE_STATUS = 'stripe_status';
54
76
 
55
- exports.GOCARDLESS_PAYMENT_ACTION = 'gocardless_action'; // The HTTP status we sent to a client
77
+ // The action that GoCardless recorded for a payment, mandate etc.
78
+ exports.GOCARDLESS_PAYMENT_ACTION = 'gocardless_action';
56
79
 
57
- exports.HTTP_STATUS = 'http_status'; // The HTTP status code we received from a remote server (e.g. a payment provider)
80
+ // The HTTP status we sent to a client
81
+ exports.HTTP_STATUS = 'http_status';
58
82
 
59
- exports.REMOTE_HTTP_STATUS = 'remote_http_status'; // AWS error code
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
- exports.AWS_ERROR_CODE = 'aws_error_code'; // The correlation id for the request
86
+ // AWS error code
87
+ exports.AWS_ERROR_CODE = 'aws_error_code';
62
88
 
63
- exports.CORRELATION_ID = 'x_request_id'; // Payment External Id
89
+ // The correlation id for the request
90
+ exports.CORRELATION_ID = 'x_request_id';
64
91
 
65
- exports.PAYMENT_EXTERNAL_ID = 'payment_external_id'; // Refund External Id
92
+ // Payment External Id
93
+ exports.PAYMENT_EXTERNAL_ID = 'payment_external_id';
66
94
 
67
- exports.REFUND_EXTERNAL_ID = 'refund_external_id'; // Secure Token
95
+ // Refund External Id
96
+ exports.REFUND_EXTERNAL_ID = 'refund_external_id';
68
97
 
69
- exports.SECURE_TOKEN = 'secure_token'; // User external id
98
+ // Secure Token
99
+ exports.SECURE_TOKEN = 'secure_token';
70
100
 
71
- exports.USER_EXTERNAL_ID = 'user_external_id'; // A service's external id
101
+ // User external id
102
+ exports.USER_EXTERNAL_ID = 'user_external_id';
72
103
 
73
- exports.SERVICE_EXTERNAL_ID = 'service_external_id'; // product external id
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,8 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var _require = require('../utils/countries'),
4
- translateAlpha2 = _require.translateAlpha2;
5
-
4
+ translateAlpha2 = _require.translateAlpha2;
6
5
  module.exports = function (iso) {
7
6
  return translateAlpha2(iso);
8
7
  };
@@ -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
  };
@@ -2,6 +2,7 @@
2
2
 
3
3
  // Removes indefinite articles (a/an)
4
4
  // Removes definite articles (the)
5
+
5
6
  module.exports = function (string) {
6
7
  return string.replace(/\ba\s|\ban\s|\bthe\s/gi, '');
7
8
  };
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var slugify = require('slugify');
4
-
5
4
  module.exports = function (string) {
6
5
  slugify.extend({
7
6
  ŵ: 'w',
@@ -1,18 +1,17 @@
1
- 'use strict'; // NPM Dependencies
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
- var extensions = require('../data/country-record-extension.json'); // Merge the additional data into the register data
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
- }); // Exports
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'; // Local contants
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'; // NPM dependencies
1
+ 'use strict';
2
2
 
3
- var parseInt = require('lodash/parseInt'); // Local dependencies
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'; // NPM dependencies
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.7",
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.41",
138
+ "moment-timezone": "0.5.42",
139
139
  "rfc822-validate": "1.0.0",
140
- "slugify": "1.6.5",
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>
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="JpaBuddyIdeaProjectConfig">
4
- <option name="renamerInitialized" value="true" />
5
- </component>
6
- </project>