@sheerid/jslib 1.139.1 → 1.141.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.
Files changed (51) hide show
  1. package/es5/Tmetrix.bundle.js +4 -4
  2. package/es5/messages_ar.bundle.js +4 -4
  3. package/es5/messages_bg.bundle.js +4 -4
  4. package/es5/messages_cs.bundle.js +4 -4
  5. package/es5/messages_da.bundle.js +4 -4
  6. package/es5/messages_de.bundle.js +4 -4
  7. package/es5/messages_el.bundle.js +4 -4
  8. package/es5/messages_en-GB.bundle.js +4 -4
  9. package/es5/messages_es-ES.bundle.js +4 -4
  10. package/es5/messages_es.bundle.js +4 -4
  11. package/es5/messages_fi.bundle.js +4 -4
  12. package/es5/messages_fr-CA.bundle.js +4 -4
  13. package/es5/messages_fr.bundle.js +4 -4
  14. package/es5/messages_ga.bundle.js +4 -4
  15. package/es5/messages_hr.bundle.js +4 -4
  16. package/es5/messages_hu.bundle.js +4 -4
  17. package/es5/messages_id.bundle.js +4 -4
  18. package/es5/messages_it.bundle.js +4 -4
  19. package/es5/messages_iw.bundle.js +4 -4
  20. package/es5/messages_ja.bundle.js +4 -4
  21. package/es5/messages_ko.bundle.js +4 -4
  22. package/es5/messages_lo.bundle.js +4 -4
  23. package/es5/messages_lt.bundle.js +4 -4
  24. package/es5/messages_ms.bundle.js +4 -4
  25. package/es5/messages_nl.bundle.js +4 -4
  26. package/es5/messages_no.bundle.js +4 -4
  27. package/es5/messages_pl.bundle.js +4 -4
  28. package/es5/messages_pt-BR.bundle.js +4 -4
  29. package/es5/messages_pt.bundle.js +4 -4
  30. package/es5/messages_ru.bundle.js +4 -4
  31. package/es5/messages_sk.bundle.js +4 -4
  32. package/es5/messages_sl.bundle.js +4 -4
  33. package/es5/messages_sr.bundle.js +4 -4
  34. package/es5/messages_sv.bundle.js +4 -4
  35. package/es5/messages_th.bundle.js +4 -4
  36. package/es5/messages_tr.bundle.js +4 -4
  37. package/es5/messages_zh-HK.bundle.js +4 -4
  38. package/es5/messages_zh.bundle.js +4 -4
  39. package/manifest.json +43 -43
  40. package/package.json +2 -1
  41. package/sheerid-requestOrg.css +4 -4
  42. package/sheerid-requestOrg.js +6 -6
  43. package/sheerid-requestOrg.js.map +1 -1
  44. package/sheerid-utils.js +4 -4
  45. package/sheerid.css +4 -4
  46. package/sheerid.js +6 -6
  47. package/sheerid.js.map +1 -1
  48. package/sheerides6.js +44 -7
  49. package/sheerides6.js.map +1 -1
  50. package/src/lib/validators/validators.d.ts +5 -0
  51. package/types-reference.zip +0 -0
package/sheerides6.js CHANGED
@@ -4307,6 +4307,25 @@ const postcodeValidatorExistsForCountry = (country) => {
4307
4307
  return POSTCODE_REGEXES.has(country);
4308
4308
  };
4309
4309
 
4310
+ var fastLuhn = (function (array) {
4311
+ return function luhn (number) {
4312
+ if (typeof number !== 'string') throw new TypeError('Expected string input')
4313
+ if (!number) return false
4314
+ let length = number.length;
4315
+ let bit = 1;
4316
+ let sum = 0;
4317
+ let value;
4318
+
4319
+ while (length) {
4320
+ value = parseInt(number.charAt(--length), 10);
4321
+ bit ^= 1;
4322
+ sum += bit ? array[value] : value;
4323
+ }
4324
+
4325
+ return sum % 10 === 0
4326
+ }
4327
+ }([0, 2, 4, 6, 8, 1, 3, 5, 7, 9]));
4328
+
4310
4329
  let overridenValidators = {};
4311
4330
  const overrideValidator = (validatorField, newValidator) => {
4312
4331
  logger.log(`overrideValidator registering ${newValidator} for '${validatorField}'`);
@@ -4329,6 +4348,8 @@ const ADOLESCENT_AGE = 16;
4329
4348
  const MIN_BIRTHYEAR = 1900;
4330
4349
  const MAX_BIRTHYEAR = 3000;
4331
4350
  const MAX_METADATA_KEYS = 50;
4351
+ const MAX_METADATA_KEY_LENGTH = 256;
4352
+ const MAX_METADATA_VALUE_LENGTH = 4096;
4332
4353
  const VALID_PHONE_NUMBER_REGEXPS = [
4333
4354
  /^\+?0*\d{10,}(x[0-9]{0,5})?$/,
4334
4355
  /(^\D?(\d{3})\D?\D?(\d{3})\D?(\d{4})$)/,
@@ -4349,13 +4370,13 @@ const ensureMaxMetadataKeyValueLengths = (metadata) => {
4349
4370
  for (const key in metadata) {
4350
4371
  let newKey = key;
4351
4372
  let newValue = metadata[key];
4352
- if (newValue.length > 256) {
4353
- logger.warn(`Truncating metadata value '${metadata[key]}' for key '${newKey}' (max length 256 characters).`);
4354
- newValue = newValue.substring(0, 256);
4373
+ if (newValue.length > MAX_METADATA_VALUE_LENGTH) {
4374
+ logger.warn(`Truncating metadata value '${metadata[key]}' for key '${newKey}' (max length ${MAX_METADATA_VALUE_LENGTH} characters).`);
4375
+ newValue = newValue.substring(0, MAX_METADATA_VALUE_LENGTH);
4355
4376
  }
4356
- if (newKey.length > 256) {
4357
- logger.warn(`Truncating metadata key '${key}' (max length 256 characters).`);
4358
- newKey = newKey.substring(0, 256);
4377
+ if (newKey.length > MAX_METADATA_KEY_LENGTH) {
4378
+ logger.warn(`Truncating metadata key '${key}' (max length ${MAX_METADATA_KEY_LENGTH} characters).`);
4379
+ newKey = newKey.substring(0, MAX_METADATA_KEY_LENGTH);
4359
4380
  }
4360
4381
  modifiedMetadata[newKey] = newValue;
4361
4382
  }
@@ -4569,6 +4590,22 @@ const getFileValidationError = (file) => {
4569
4590
  return invalidFileSizeEmptyError;
4570
4591
  }
4571
4592
  };
4593
+ const getEbtCardValidationError = (value) => {
4594
+ if (!value.match(/^\d{16,19}$/)) {
4595
+ // Must be 16-19 digits
4596
+ return "invalidEbtCardNumber";
4597
+ }
4598
+ if (value.startsWith("610098") && value.length !== 19) {
4599
+ // this prefix must be 19 digits
4600
+ return "invalidEbtCardNumber";
4601
+ }
4602
+ const checkSumExemptPrefixes = ["600486", "507712", "507714"];
4603
+ const isExempt = checkSumExemptPrefixes.some((pref) => value.startsWith(pref));
4604
+ if (!isExempt && !fastLuhn(value)) {
4605
+ // Failed checksum
4606
+ return "invalidEbtCardNumber";
4607
+ }
4608
+ };
4572
4609
  const getPostalCodeValidationError = (value, formValidationOptions) => {
4573
4610
  const invalidPostalCode = "invalidPostalCode";
4574
4611
  const countryCode = getSafe(() => formValidationOptions.viewModel.countryChoice.value, "US");
@@ -4837,7 +4874,7 @@ const validateFieldById = (fieldId, value, formValidationOptions) => {
4837
4874
  defaultValidator = getFileValidationError;
4838
4875
  return getValidationError(fieldId, value, defaultValidator, overriddenValidator, formValidationOptions);
4839
4876
  case FieldIdEnum.ebtCardNumber:
4840
- defaultValidator = getFileValidationError;
4877
+ defaultValidator = getEbtCardValidationError;
4841
4878
  return getValidationError(fieldId, value, defaultValidator, overriddenValidator, formValidationOptions);
4842
4879
  case FieldIdEnum.overrideCode:
4843
4880
  defaultValidator = getFileValidationError;