@adyen/adyen-web 6.34.1 → 6.36.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 (220) hide show
  1. package/dist/cjs/adyen.css +7 -8
  2. package/dist/cjs/adyen.css.map +1 -1
  3. package/dist/cjs/index.cjs +2 -2
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/index.d.cts +2649 -1958
  6. package/dist/es/adyen.css +7 -8
  7. package/dist/es/adyen.css.map +1 -1
  8. package/dist/es/components/ApplePay/services/ApplePayService.js.map +1 -1
  9. package/dist/es/components/Card/components/CardInput/CardInput.js +1 -1
  10. package/dist/es/components/Card/components/CardInput/CardInput.js.map +1 -1
  11. package/dist/es/components/Card/components/CardInput/components/BrandIcon.js +1 -1
  12. package/dist/es/components/Card/components/CardInput/components/BrandIcon.js.map +1 -1
  13. package/dist/es/components/Card/components/CardInput/components/CardFields.js +1 -1
  14. package/dist/es/components/Card/components/CardInput/components/CardFields.js.map +1 -1
  15. package/dist/es/components/Card/components/CardInput/components/CardFieldsWrapper.js +1 -1
  16. package/dist/es/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
  17. package/dist/es/components/Card/components/CardInput/components/CardNumber.js +1 -1
  18. package/dist/es/components/Card/components/CardInput/components/CardNumber.js.map +1 -1
  19. package/dist/es/components/Card/components/CardInput/components/DualBrandSelector.js +2 -0
  20. package/dist/es/components/Card/components/CardInput/components/DualBrandSelector.js.map +1 -0
  21. package/dist/es/components/Card/components/CardInput/components/DualBrandSelector.module.scss.js +2 -0
  22. package/dist/es/components/Card/components/CardInput/components/DualBrandSelector.module.scss.js.map +1 -0
  23. package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
  24. package/dist/es/components/Card/components/CardInput/utils.js +1 -1
  25. package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
  26. package/dist/es/components/Card/constants.js.map +1 -1
  27. package/dist/es/components/CustomCard/CustomCard.js +1 -1
  28. package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
  29. package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
  30. package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
  31. package/dist/es/components/Donation/Donation.js +1 -1
  32. package/dist/es/components/Donation/Donation.js.map +1 -1
  33. package/dist/es/components/Donation/DonationCampaignService.js +2 -0
  34. package/dist/es/components/Donation/DonationCampaignService.js.map +1 -0
  35. package/dist/es/components/Donation/components/DonationComponent.js +1 -1
  36. package/dist/es/components/Donation/components/DonationComponent.js.map +1 -1
  37. package/dist/es/components/Donation/components/utils.js.map +1 -1
  38. package/dist/es/components/Giftcard/components/GiftcardComponent.js +1 -1
  39. package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  40. package/dist/es/components/Iris/Iris.js +1 -1
  41. package/dist/es/components/Iris/Iris.js.map +1 -1
  42. package/dist/es/components/Iris/types.js.map +1 -1
  43. package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js +1 -1
  44. package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -1
  45. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  46. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  47. package/dist/es/components/internal/Address/Address.js +1 -1
  48. package/dist/es/components/internal/Address/Address.js.map +1 -1
  49. package/dist/es/components/internal/Address/components/AddressSearch.js.map +1 -1
  50. package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
  51. package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
  52. package/dist/es/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.js +1 -1
  53. package/dist/es/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.js.map +1 -1
  54. package/dist/es/components/internal/DisclaimerMessage/DisclaimerMessage.js +1 -1
  55. package/dist/es/components/internal/DisclaimerMessage/DisclaimerMessage.js.map +1 -1
  56. package/dist/es/components/internal/FormFields/Field/Field.js +1 -1
  57. package/dist/es/components/internal/FormFields/Field/Field.js.map +1 -1
  58. package/dist/es/components/internal/FormFields/Fieldset/Fieldset.js +1 -1
  59. package/dist/es/components/internal/FormFields/Fieldset/Fieldset.js.map +1 -1
  60. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  61. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  62. package/dist/es/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.js +1 -1
  63. package/dist/es/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.js.map +1 -1
  64. package/dist/es/components/internal/IssuerList/IssuerList.js +1 -1
  65. package/dist/es/components/internal/IssuerList/IssuerList.js.map +1 -1
  66. package/dist/es/components/internal/SecuredFields/SFP/SFPUtils.js +1 -1
  67. package/dist/es/components/internal/SecuredFields/SFP/SFPUtils.js.map +1 -1
  68. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  69. package/dist/es/components/internal/SecuredFields/binLookup/extensions.js +1 -1
  70. package/dist/es/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
  71. package/dist/es/components/internal/SecuredFields/lib/CSF/CSF.js.map +1 -1
  72. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js +1 -1
  73. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js.map +1 -1
  74. package/dist/es/components/internal/SecuredFields/lib/CSF/partials/processBrand.js +1 -1
  75. package/dist/es/components/internal/SecuredFields/lib/CSF/partials/processBrand.js.map +1 -1
  76. package/dist/es/components/internal/SecuredFields/lib/CSF/utils/cardType.js +1 -1
  77. package/dist/es/components/internal/SecuredFields/lib/CSF/utils/cardType.js.map +1 -1
  78. package/dist/es/components/internal/SecuredFields/lib/constants.js +1 -1
  79. package/dist/es/components/internal/SecuredFields/lib/constants.js.map +1 -1
  80. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  81. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  82. package/dist/es/components/internal/UIElement/utils.js +1 -1
  83. package/dist/es/components/internal/UIElement/utils.js.map +1 -1
  84. package/dist/es/core/Analytics/Analytics.js +1 -1
  85. package/dist/es/core/Analytics/Analytics.js.map +1 -1
  86. package/dist/es/core/Analytics/AnalyticsService.js.map +1 -1
  87. package/dist/es/core/Analytics/events/AnalyticsErrorEvent.js.map +1 -1
  88. package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
  89. package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
  90. package/dist/es/core/Analytics/events/AnalyticsLogEvent.js +1 -1
  91. package/dist/es/core/Analytics/events/AnalyticsLogEvent.js.map +1 -1
  92. package/dist/es/core/CheckoutSession/CheckoutSession.js +1 -1
  93. package/dist/es/core/CheckoutSession/CheckoutSession.js.map +1 -1
  94. package/dist/es/core/Services/sessions/constants.js +1 -1
  95. package/dist/es/core/Services/sessions/constants.js.map +1 -1
  96. package/dist/es/core/Services/sessions/fetch-donation-campaigns.js +2 -0
  97. package/dist/es/core/Services/sessions/fetch-donation-campaigns.js.map +1 -0
  98. package/dist/es/core/Services/sessions/make-donation.js +2 -0
  99. package/dist/es/core/Services/sessions/make-donation.js.map +1 -0
  100. package/dist/es/core/config.js +1 -1
  101. package/dist/es/core/config.js.map +1 -1
  102. package/dist/es/core/core.registry.js +1 -1
  103. package/dist/es/core/core.registry.js.map +1 -1
  104. package/dist/es/core/utils.js +1 -1
  105. package/dist/es/core/utils.js.map +1 -1
  106. package/dist/es/index.d.ts +2649 -1958
  107. package/dist/es/utils/createSdkData.js +1 -1
  108. package/dist/es/utils/createSdkData.js.map +1 -1
  109. package/dist/es-legacy/adyen.css +7 -8
  110. package/dist/es-legacy/adyen.css.map +1 -1
  111. package/dist/es-legacy/components/ApplePay/services/ApplePayService.js.map +1 -1
  112. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js +1 -1
  113. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js.map +1 -1
  114. package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js +1 -1
  115. package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js.map +1 -1
  116. package/dist/es-legacy/components/Card/components/CardInput/components/CardFields.js +1 -1
  117. package/dist/es-legacy/components/Card/components/CardInput/components/CardFields.js.map +1 -1
  118. package/dist/es-legacy/components/Card/components/CardInput/components/CardFieldsWrapper.js +1 -1
  119. package/dist/es-legacy/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
  120. package/dist/es-legacy/components/Card/components/CardInput/components/CardNumber.js +1 -1
  121. package/dist/es-legacy/components/Card/components/CardInput/components/CardNumber.js.map +1 -1
  122. package/dist/es-legacy/components/Card/components/CardInput/components/DualBrandSelector.js +2 -0
  123. package/dist/es-legacy/components/Card/components/CardInput/components/DualBrandSelector.js.map +1 -0
  124. package/dist/es-legacy/components/Card/components/CardInput/components/DualBrandSelector.module.scss.js +2 -0
  125. package/dist/es-legacy/components/Card/components/CardInput/components/DualBrandSelector.module.scss.js.map +1 -0
  126. package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
  127. package/dist/es-legacy/components/Card/components/CardInput/utils.js +1 -1
  128. package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
  129. package/dist/es-legacy/components/Card/constants.js.map +1 -1
  130. package/dist/es-legacy/components/CustomCard/CustomCard.js +1 -1
  131. package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
  132. package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
  133. package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
  134. package/dist/es-legacy/components/Donation/Donation.js +1 -1
  135. package/dist/es-legacy/components/Donation/Donation.js.map +1 -1
  136. package/dist/es-legacy/components/Donation/DonationCampaignService.js +2 -0
  137. package/dist/es-legacy/components/Donation/DonationCampaignService.js.map +1 -0
  138. package/dist/es-legacy/components/Donation/components/DonationComponent.js +1 -1
  139. package/dist/es-legacy/components/Donation/components/DonationComponent.js.map +1 -1
  140. package/dist/es-legacy/components/Donation/components/utils.js.map +1 -1
  141. package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js +1 -1
  142. package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  143. package/dist/es-legacy/components/Iris/Iris.js +1 -1
  144. package/dist/es-legacy/components/Iris/Iris.js.map +1 -1
  145. package/dist/es-legacy/components/Iris/types.js.map +1 -1
  146. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js +1 -1
  147. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -1
  148. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  149. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  150. package/dist/es-legacy/components/internal/Address/Address.js +1 -1
  151. package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
  152. package/dist/es-legacy/components/internal/Address/components/AddressSearch.js.map +1 -1
  153. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
  154. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  155. package/dist/es-legacy/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.js +1 -1
  156. package/dist/es-legacy/components/internal/ClickToPay/components/CtPInfo/CtPInfoModal/CtPInfoModal.js.map +1 -1
  157. package/dist/es-legacy/components/internal/DisclaimerMessage/DisclaimerMessage.js +1 -1
  158. package/dist/es-legacy/components/internal/DisclaimerMessage/DisclaimerMessage.js.map +1 -1
  159. package/dist/es-legacy/components/internal/FormFields/Field/Field.js +1 -1
  160. package/dist/es-legacy/components/internal/FormFields/Field/Field.js.map +1 -1
  161. package/dist/es-legacy/components/internal/FormFields/Fieldset/Fieldset.js +1 -1
  162. package/dist/es-legacy/components/internal/FormFields/Fieldset/Fieldset.js.map +1 -1
  163. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  164. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  165. package/dist/es-legacy/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.js +1 -1
  166. package/dist/es-legacy/components/internal/IssuerList/IssuerButtonGroup/IssuerButtonGroup.js.map +1 -1
  167. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
  168. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js.map +1 -1
  169. package/dist/es-legacy/components/internal/SecuredFields/SFP/SFPUtils.js +1 -1
  170. package/dist/es-legacy/components/internal/SecuredFields/SFP/SFPUtils.js.map +1 -1
  171. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  172. package/dist/es-legacy/components/internal/SecuredFields/binLookup/extensions.js +1 -1
  173. package/dist/es-legacy/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
  174. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/CSF.js.map +1 -1
  175. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js +1 -1
  176. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js.map +1 -1
  177. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/processBrand.js +1 -1
  178. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/processBrand.js.map +1 -1
  179. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/cardType.js +1 -1
  180. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/cardType.js.map +1 -1
  181. package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js +1 -1
  182. package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js.map +1 -1
  183. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  184. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  185. package/dist/es-legacy/components/internal/UIElement/utils.js +1 -1
  186. package/dist/es-legacy/components/internal/UIElement/utils.js.map +1 -1
  187. package/dist/es-legacy/core/Analytics/Analytics.js +1 -1
  188. package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
  189. package/dist/es-legacy/core/Analytics/AnalyticsService.js.map +1 -1
  190. package/dist/es-legacy/core/Analytics/events/AnalyticsErrorEvent.js.map +1 -1
  191. package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
  192. package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
  193. package/dist/es-legacy/core/Analytics/events/AnalyticsLogEvent.js +1 -1
  194. package/dist/es-legacy/core/Analytics/events/AnalyticsLogEvent.js.map +1 -1
  195. package/dist/es-legacy/core/CheckoutSession/CheckoutSession.js +1 -1
  196. package/dist/es-legacy/core/CheckoutSession/CheckoutSession.js.map +1 -1
  197. package/dist/es-legacy/core/Services/sessions/constants.js +1 -1
  198. package/dist/es-legacy/core/Services/sessions/constants.js.map +1 -1
  199. package/dist/es-legacy/core/Services/sessions/fetch-donation-campaigns.js +2 -0
  200. package/dist/es-legacy/core/Services/sessions/fetch-donation-campaigns.js.map +1 -0
  201. package/dist/es-legacy/core/Services/sessions/make-donation.js +2 -0
  202. package/dist/es-legacy/core/Services/sessions/make-donation.js.map +1 -0
  203. package/dist/es-legacy/core/config.js +1 -1
  204. package/dist/es-legacy/core/config.js.map +1 -1
  205. package/dist/es-legacy/core/core.registry.js +1 -1
  206. package/dist/es-legacy/core/core.registry.js.map +1 -1
  207. package/dist/es-legacy/core/utils.js +1 -1
  208. package/dist/es-legacy/core/utils.js.map +1 -1
  209. package/dist/es-legacy/utils/createSdkData.js +1 -1
  210. package/dist/es-legacy/utils/createSdkData.js.map +1 -1
  211. package/package.json +21 -21
  212. package/styles/adyen.css +7 -8
  213. package/dist/es/components/internal/FormFields/RadioGroupExtended/RadioButtonIcon.js +0 -2
  214. package/dist/es/components/internal/FormFields/RadioGroupExtended/RadioButtonIcon.js.map +0 -1
  215. package/dist/es/components/internal/FormFields/RadioGroupExtended/RadioGroupExtended.js +0 -2
  216. package/dist/es/components/internal/FormFields/RadioGroupExtended/RadioGroupExtended.js.map +0 -1
  217. package/dist/es-legacy/components/internal/FormFields/RadioGroupExtended/RadioButtonIcon.js +0 -2
  218. package/dist/es-legacy/components/internal/FormFields/RadioGroupExtended/RadioButtonIcon.js.map +0 -1
  219. package/dist/es-legacy/components/internal/FormFields/RadioGroupExtended/RadioGroupExtended.js +0 -2
  220. package/dist/es-legacy/components/internal/FormFields/RadioGroupExtended/RadioGroupExtended.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"extensions.js","sources":["../../../../../../src/components/internal/SecuredFields/binLookup/extensions.ts"],"sourcesContent":["import { SingleBrandResetObject } from '../SFP/types';\nimport { BrandObject } from '../../../Card/types';\nimport createCardVariantSwitcher from './createCardVariantSwitcher';\nimport { BRAND_ICON_UI_EXCLUSION_LIST } from '../lib/constants';\nimport { mustHandleDualBrandingAccordingToEURegulations } from '../../../Card/components/CardInput/utils';\nimport { DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM } from '../../../Card/constants';\n\n// Externally testable utils\nexport const containsExcludedBrand = (brandsArr: BrandObject[], excludedBrands: string[]): boolean => {\n return brandsArr.reduce((acc, brandObj) => acc || excludedBrands.includes(brandObj.brand), false);\n};\n\nexport const cloneBrandsArr = (brandsArr: BrandObject[]): BrandObject[] => brandsArr.map(item => ({ ...item }));\n\nexport const removeExcludedBrand = (brandsArr: BrandObject[], mainBrand1 = 'mc', mainBrand2 = 'visa'): BrandObject[] => {\n const clonedBrands: BrandObject[] = cloneBrandsArr(brandsArr);\n\n if (clonedBrands[0].brand !== mainBrand1 && clonedBrands[0].brand !== mainBrand2) clonedBrands.reverse();\n clonedBrands.length = 1;\n return clonedBrands;\n};\n// --\n\nexport default function extensions(props, refs, states, hasPanLengthRef: Partial<{ current }> = {}) {\n // Destructure props, refs and state hooks\n const { type, cvcPolicy } = props;\n const { sfp } = refs;\n const { dualBrandSelectElements, setDualBrandSelectElements, setSelectedBrandValue, issuingCountryCode, setIssuingCountryCode } = states;\n\n return {\n /**\n * Handle the binLookup response object generated in triggerBinLookup and process it in relation to the CardInput and it's sub-components.\n * e.g. we might need to add/remove additional markup (a selector for brands), and inform SFP of the issuingCountryCode & detected brand(s).\n *\n * @param binLookupResponse -\n * @param isReset -\n */\n processBinLookup: (binLookupResponse, isReset) => {\n const issuingCode = binLookupResponse?.issuingCountryCode ? binLookupResponse.issuingCountryCode.toLowerCase() : null;\n setIssuingCountryCode(issuingCode);\n\n // Reset UI\n if (!binLookupResponse || !Object.keys(binLookupResponse).length) {\n setDualBrandSelectElements([]);\n setSelectedBrandValue('');\n\n // If /binLookup has 'reset' then for a generic card the internal regex will kick in to show the right brand icon - so set to null\n // However for a single-branded card we need to pass the \"base\" type so the brand logo is reset - so set to type\n const brandToReset = isReset && type !== 'card' ? type : null;\n\n sfp.current.processBinLookupResponse(binLookupResponse, {\n brand: brandToReset,\n cvcPolicy: cvcPolicy // undefined except for Bancontact\n } as SingleBrandResetObject);\n\n // Reset storage var\n hasPanLengthRef.current = 0;\n return;\n }\n\n // RESULT: binLookup has found a result so proceed accordingly\n if (binLookupResponse.supportedBrands?.length) {\n const hasExcludedBrand: boolean = containsExcludedBrand(binLookupResponse.supportedBrands, BRAND_ICON_UI_EXCLUSION_LIST);\n\n const supportedBrands: BrandObject[] = hasExcludedBrand\n ? removeExcludedBrand(binLookupResponse.supportedBrands)\n : cloneBrandsArr(binLookupResponse.supportedBrands);\n\n // 1) Multiple options found - add to the UI & inform SFP\n if (supportedBrands.length > 1) {\n // --\n\n // Only if the brands in DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM are present in the binLookup response should we handle dual branding based on EU regulations\n const preselectBrand = mustHandleDualBrandingAccordingToEURegulations(\n DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM,\n supportedBrands,\n 'brand'\n );\n\n const switcherObj = createCardVariantSwitcher(supportedBrands, preselectBrand);\n\n // Set properties on state to trigger the dual branding icons in the UI\n setDualBrandSelectElements(switcherObj.dualBrandSelectElements);\n setSelectedBrandValue(switcherObj.selectedBrandValue); // initially this value from switcherObj will be ''\n\n // Pass an object through to SFP\n sfp.current.processBinLookupResponse({\n issuingCountryCode: binLookupResponse.issuingCountryCode,\n supportedBrands: [switcherObj.leadBrand]\n });\n\n // Store the fact the binLookup obj has a panLength prop\n if (switcherObj.leadBrand.panLength > 0) {\n hasPanLengthRef.current = switcherObj.leadBrand.panLength;\n }\n\n // 2) Single option found (binValueObject.supportedBrands.length === 1)\n } else {\n // Reset UI\n setDualBrandSelectElements([]);\n setSelectedBrandValue('');\n\n // Set (single) value from binLookup so it will be added to the 'brand' property in the paymentMethod object\n // EXCEPT - if we are dealing with a brand that we exclude from the UI\n if (!hasExcludedBrand) setSelectedBrandValue(supportedBrands[0].brand);\n\n // Pass object through to SFP\n sfp.current.processBinLookupResponse({\n issuingCountryCode: binLookupResponse.issuingCountryCode,\n supportedBrands\n });\n\n // Store the fact the binLookup obj has a panLength prop\n if (supportedBrands[0].panLength > 0) {\n hasPanLengthRef.current = supportedBrands[0].panLength;\n }\n }\n }\n },\n /**\n * Handler for clicks on the icons added in response to the /binLookup call\n * Inform SFP of the brand changes when these selections are made\n */\n handleDualBrandSelection: (e: Event | string): void => {\n let value: Event | string = e;\n if (e instanceof Event) {\n const target = e.target as HTMLLIElement;\n value = target.getAttribute('data-value') || target.getAttribute('value');\n }\n\n // Check if we have a value and whether that value corresponds to a brandObject we can propagate\n // If either are false then abandon the process\n let brandObjArr: BrandObject[] = [];\n if (value) {\n // Find the brandObject with the matching brand value and place into an array\n brandObjArr = dualBrandSelectElements.reduce((acc, item) => {\n if (item.brandObject.brand === value) {\n acc.push(item.brandObject);\n }\n return acc;\n }, []);\n\n if (!brandObjArr.length) {\n return; // no brand object associated with value was found\n }\n } else {\n return; // no value passed\n }\n\n setSelectedBrandValue(value);\n\n // Pass brand object into SecuredFields\n sfp.current.processBinLookupResponse({\n issuingCountryCode,\n supportedBrands: brandObjArr,\n isDualBrandSelection: true\n });\n }\n };\n}\n"],"names":["containsExcludedBrand","brandsArr","excludedBrands","reduce","acc","brandObj","includes","brand","cloneBrandsArr","map","item","_object_spread","removeExcludedBrand","mainBrand1","mainBrand2","clonedBrands","reverse","length","extensions","props","refs","states","hasPanLengthRef","type","cvcPolicy","sfp","dualBrandSelectElements","setDualBrandSelectElements","setSelectedBrandValue","issuingCountryCode","setIssuingCountryCode","processBinLookup","binLookupResponse","isReset","issuingCode","toLowerCase","Object","keys","brandToReset","current","processBinLookupResponse","supportedBrands","hasExcludedBrand","BRAND_ICON_UI_EXCLUSION_LIST","preselectBrand","mustHandleDualBrandingAccordingToEURegulations","DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM","switcherObj","createCardVariantSwitcher","selectedBrandValue","leadBrand","panLength","handleDualBrandSelection","e","value","Event","target","getAttribute","brandObjArr","brandObject","push","isDualBrandSelection"],"mappings":"6aAQO,MAAMA,EAAwB,CAACC,EAA0BC,IACrDD,EAAUE,OAAO,CAACC,EAAKC,IAAaD,GAAOF,EAAeI,SAASD,EAASE,QAAQ,GAGlFC,EAAkBP,GAA4CA,EAAUQ,IAAIC,qUAASC,CAAA,CAAA,EAAKD,IAE1FE,EAAsB,CAACX,EAA0BY,EAAa,KAAMC,EAAa,UAC1F,MAAMC,EAA8BP,EAAeP,GAInD,OAFIc,EAAa,GAAGR,QAAUM,GAAcE,EAAa,GAAGR,QAAUO,GAAYC,EAAaC,UAC/FD,EAAaE,OAAS,EACfF,GAII,SAASG,EAAWC,EAAOC,EAAMC,EAAQC,EAAwC,CAAA,GAE5F,MAAMC,KAAEA,EAAIC,UAAEA,GAAcL,GACtBM,IAAEA,GAAQL,GACVM,wBAAEA,EAAuBC,2BAAEA,EAA0BC,sBAAEA,EAAqBC,mBAAEA,EAAkBC,sBAAEA,GAA0BT,EAElI,MAAO,CAQHU,iBAAkB,C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QACrE,CAIA,IAAIC,EAA6B,GAC7BJ,IAEAI,EAAchC,EAAwBvB,OAAO,CAACC,EAAKM,KAC3CA,EAAKiD,YAAYpD,QAAU+C,GAC3BlD,EAAIwD,KAAKlD,EAAKiD,aAEXvD,GACR,IAEEsD,EAAYzC,SAOrBW,EAAsB0B,GAGtB7B,EAAIc,QAAQC,yBAAyB,CACjCX,qBACAY,gBAAiBiB,EACjBG,sBAAsB,OAItC"}
1
+ {"version":3,"file":"extensions.js","sources":["../../../../../../src/components/internal/SecuredFields/binLookup/extensions.ts"],"sourcesContent":["import { SingleBrandResetObject } from '../SFP/types';\nimport { BrandObject } from '../../../Card/types';\nimport createCardVariantSwitcher from './createCardVariantSwitcher';\nimport { BRAND_ICON_UI_EXCLUSION_LIST } from '../lib/constants';\nimport { requiresDualBrandSelection } from '../../../Card/components/CardInput/utils';\nimport { DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM } from '../../../Card/constants';\n\n// Externally testable utils\nexport const containsExcludedBrand = (brandsArr: BrandObject[], excludedBrands: string[]): boolean => {\n return brandsArr.reduce((acc, brandObj) => acc || excludedBrands.includes(brandObj.brand), false);\n};\n\nexport const cloneBrandsArr = (brandsArr: BrandObject[]): BrandObject[] => brandsArr.map(item => ({ ...item }));\n\nexport const removeExcludedBrand = (brandsArr: BrandObject[], mainBrand1 = 'mc', mainBrand2 = 'visa'): BrandObject[] => {\n const clonedBrands: BrandObject[] = cloneBrandsArr(brandsArr);\n\n if (clonedBrands[0].brand !== mainBrand1 && clonedBrands[0].brand !== mainBrand2) clonedBrands.reverse();\n clonedBrands.length = 1;\n return clonedBrands;\n};\n// --\n\nexport default function extensions(props, refs, states, hasPanLengthRef: Partial<{ current }> = {}) {\n // Destructure props, refs and state hooks\n const { type, cvcPolicy } = props;\n const { sfp } = refs;\n const { dualBrandSelectElements, setDualBrandSelectElements, setSelectedBrandValue, issuingCountryCode, setIssuingCountryCode } = states;\n\n return {\n /**\n * Handle the binLookup response object generated in triggerBinLookup and process it in relation to the CardInput and it's sub-components.\n * e.g. we might need to add/remove additional markup (a selector for brands), and inform SFP of the issuingCountryCode & detected brand(s).\n *\n * @param binLookupResponse -\n * @param isReset -\n */\n processBinLookup: (binLookupResponse, isReset) => {\n const issuingCode = binLookupResponse?.issuingCountryCode ? binLookupResponse.issuingCountryCode.toLowerCase() : null;\n setIssuingCountryCode(issuingCode);\n\n // Reset UI\n if (!binLookupResponse || !Object.keys(binLookupResponse).length) {\n setDualBrandSelectElements([]);\n setSelectedBrandValue('');\n\n // If /binLookup has 'reset' then for a generic card the internal regex will kick in to show the right brand icon - so set to null\n // However for a single-branded card we need to pass the \"base\" type so the brand logo is reset - so set to type\n const brandToReset = isReset && type !== 'card' ? type : null;\n\n sfp.current.processBinLookupResponse(binLookupResponse, {\n brand: brandToReset,\n cvcPolicy: cvcPolicy // undefined except for Bancontact\n } as SingleBrandResetObject);\n\n // Reset storage var\n hasPanLengthRef.current = 0;\n return;\n }\n\n // RESULT: binLookup has found a result so proceed accordingly\n if (binLookupResponse.supportedBrands?.length) {\n const hasExcludedBrand: boolean = containsExcludedBrand(binLookupResponse.supportedBrands, BRAND_ICON_UI_EXCLUSION_LIST);\n\n const supportedBrands: BrandObject[] = hasExcludedBrand\n ? removeExcludedBrand(binLookupResponse.supportedBrands)\n : cloneBrandsArr(binLookupResponse.supportedBrands);\n\n // 1) Multiple options found - add to the UI & inform SFP\n if (supportedBrands.length > 1) {\n // --\n\n // Only if the brands in DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM are present in the binLookup response should we show the dual brand selector\n const preselectBrand = requiresDualBrandSelection(DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM, supportedBrands, 'brand');\n\n const switcherObj = createCardVariantSwitcher(supportedBrands, preselectBrand);\n\n // Set properties on state to trigger the dual branding icons in the UI\n setDualBrandSelectElements(switcherObj.dualBrandSelectElements);\n setSelectedBrandValue(switcherObj.selectedBrandValue); // initially this value from switcherObj will be ''\n\n // Pass an object through to SFP\n sfp.current.processBinLookupResponse({\n issuingCountryCode: binLookupResponse.issuingCountryCode,\n supportedBrands: [switcherObj.leadBrand]\n });\n\n // Store the fact the binLookup obj has a panLength prop\n if (switcherObj.leadBrand.panLength > 0) {\n hasPanLengthRef.current = switcherObj.leadBrand.panLength;\n }\n\n // 2) Single option found (binValueObject.supportedBrands.length === 1)\n } else {\n // Reset UI\n setDualBrandSelectElements([]);\n setSelectedBrandValue('');\n\n // Set (single) value from binLookup so it will be added to the 'brand' property in the paymentMethod object\n // EXCEPT - if we are dealing with a brand that we exclude from the UI\n if (!hasExcludedBrand) setSelectedBrandValue(supportedBrands[0].brand);\n\n // Pass object through to SFP\n sfp.current.processBinLookupResponse({\n issuingCountryCode: binLookupResponse.issuingCountryCode,\n supportedBrands\n });\n\n // Store the fact the binLookup obj has a panLength prop\n if (supportedBrands[0].panLength > 0) {\n hasPanLengthRef.current = supportedBrands[0].panLength;\n }\n }\n }\n },\n /**\n * Handler for clicks on the icons added in response to the /binLookup call\n * Inform SFP of the brand changes when these selections are made\n */\n handleDualBrandSelection: (brandValue: string): void => {\n // Check if we have a value and whether that value corresponds to a brandObject we can propagate\n // If either are false then abandon the process\n let brandObjArr: BrandObject[] = [];\n if (brandValue) {\n // Find the brandObject with the matching brand value and place into an array\n brandObjArr = dualBrandSelectElements.reduce((acc, item) => {\n if (item.brandObject.brand === brandValue) {\n acc.push(item.brandObject);\n }\n return acc;\n }, []);\n\n if (!brandObjArr.length) {\n return; // no brand object associated with value was found\n }\n } else {\n return; // no value passed\n }\n\n setSelectedBrandValue(brandValue);\n\n // Pass brand object into SecuredFields\n sfp.current.processBinLookupResponse({\n issuingCountryCode,\n supportedBrands: brandObjArr,\n isDualBrandSelection: true\n });\n }\n };\n}\n"],"names":["containsExcludedBrand","brandsArr","excludedBrands","reduce","acc","brandObj","includes","brand","cloneBrandsArr","map","item","_object_spread","removeExcludedBrand","mainBrand1","mainBrand2","clonedBrands","reverse","length","extensions","props","refs","states","hasPanLengthRef","type","cvcPolicy","sfp","dualBrandSelectElements","setDualBrandSelectElements","setSelectedBrandValue","issuingCountryCode","setIssuingCountryCode","processBinLookup","binLookupResponse","isReset","issuingCode","toLowerCase","Object","keys","brandToReset","current","processBinLookupResponse","supportedBrands","hasExcludedBrand","BRAND_ICON_UI_EXCLUSION_LIST","preselectBrand","requiresDualBrandSelection","DUAL_BRANDS_THAT_NEED_SELECTION_MECHANISM","switcherObj","createCardVariantSwitcher","selectedBrandValue","leadBrand","panLength","handleDualBrandSelection","brandValue","brandObjArr","brandObject","push","isDualBrandSelection"],"mappings":"yZAQO,MAAMA,EAAwB,CAACC,EAA0BC,IACrDD,EAAUE,OAAO,CAACC,EAAKC,IAAaD,GAAOF,EAAeI,SAASD,EAASE,QAAQ,GAGlFC,EAAkBP,GAA4CA,EAAUQ,IAAIC,qUAASC,CAAA,CAAA,EAAKD,IAE1FE,EAAsB,CAACX,EAA0BY,EAAa,KAAMC,EAAa,UAC1F,MAAMC,EAA8BP,EAAeP,GAInD,OAFIc,EAAa,GAAGR,QAAUM,GAAcE,EAAa,GAAGR,QAAUO,GAAYC,EAAaC,UAC/FD,EAAaE,OAAS,EACfF,GAII,SAASG,EAAWC,EAAOC,EAAMC,EAAQC,EAAwC,CAAA,GAE5F,MAAMC,KAAEA,EAAIC,UAAEA,GAAcL,GACtBM,IAAEA,GAAQL,GACVM,wBAAEA,EAAuBC,2BAAEA,EAA0BC,sBAAEA,EAAqBC,mBAAEA,EAAkBC,sBAAEA,GAA0BT,EAElI,MAAO,CAQHU,iBAAkB,CAACC,EAAmBC,KAwB9BD,IAAAA,EAvBJ,MAAME,GAAcF,eAAAA,EAAmBH,oBAAqBG,EAAkBH,mBAAmBM,cAAgB,KAIjH,GAHAL,EAAsBI,IAGjBF,IAAsBI,OAAOC,KAAKL,GAAmBf,OAAQ,CAC9DU,EAA2B,IAC3BC,EAAsB,IAItB,MAAMU,EAAeL,GAAoB,SAATV,EAAkBA,EAAO,KASzD,OAPAE,EAAIc,QAAQC,yBAAyBR,EAAmB,CACpDzB,MAAO+B,EACPd,UAAWA,SAIfF,EAAgBiB,QAAU,EAE9B,CAGA,WAAIP,EAAAA,EAAkBS,2BAAlBT,OAAAA,EAAAA,EAAmCf,OAAQ,CAC3C,MAAMyB,EAA4B1C,EAAsBgC,EAAkBS,gBAAiBE,GAErFF,EAAiCC,EACjC9B,EAAoBoB,EAAkBS,iBACtCjC,EAAewB,EAAkBS,iBAGvC,GAAIA,EAAgBxB,OAAS,EAAG,CAI5B,MAAM2B,EAAiBC,EAA2BC,EAA2CL,EAAiB,SAExGM,EAAcC,EAA0BP,EAAiBG,GAG/DjB,EAA2BoB,EAAYrB,yBACvCE,EAAsBmB,EAAYE,oBAGlCxB,EAAIc,QAAQC,yBAAyB,CACjCX,mBAAoBG,EAAkBH,mBACtCY,gBAAiB,CAACM,EAAYG,aAI9BH,EAAYG,UAAUC,UAAY,IAClC7B,EAAgBiB,QAAUQ,EAAYG,UAAUC,UAIxD,MAEIxB,EAA2B,IAC3BC,EAAsB,IAIjBc,GAAkBd,EAAsBa,EAAgB,GAAGlC,OAGhEkB,EAAIc,QAAQC,yBAAyB,CACjCX,mBAAoBG,EAAkBH,mBACtCY,oBAIAA,EAAgB,GAAGU,UAAY,IAC/B7B,EAAgBiB,QAAUE,EAAgB,GAAGU,UAGzD,GAMJC,yBAA2BC,IAGvB,IAAIC,EAA6B,GAC7BD,IAEAC,EAAc5B,EAAwBvB,OAAO,CAACC,EAAKM,KAC3CA,EAAK6C,YAAYhD,QAAU8C,GAC3BjD,EAAIoD,KAAK9C,EAAK6C,aAEXnD,GACR,IAEEkD,EAAYrC,SAOrBW,EAAsByB,GAGtB5B,EAAIc,QAAQC,yBAAyB,CACjCX,qBACAY,gBAAiBa,EACjBG,sBAAsB,OAItC"}
@@ -1 +1 @@
1
- {"version":3,"file":"CSF.js","sources":["../../../../../../../src/components/internal/SecuredFields/lib/CSF/CSF.ts"],"sourcesContent":["import AbstractCSF from './AbstractCSF';\nimport { CSFReturnObject, CSFSetupObject, CSFStateObject, CSFThisObject, CSFCallbacksConfig, CSFConfigObject } from './types';\nimport { StylesObject, CardAdditionalSFData, SFFieldType } from '../types';\nimport { BinLookupResponse } from '../../../../Card/types';\nimport { handleConfig } from './extensions/handleConfig';\nimport { configureCallbacks } from './extensions/configureCallbacks';\nimport { handleValidation } from './extensions/handleValidation';\nimport { handleEncryption } from './extensions/handleEncryption';\nimport { createSecuredFields, createNonCardSecuredFields, createCardSecuredFields, setupSecuredField } from './extensions/createSecuredFields';\nimport handleIOSTouchEvents from './extensions/handleIOSTouchEvents';\nimport handleTab from './extensions/handleTab';\nimport handleBrandFromBinLookup, { sendBrandToCardSF, sendExpiryDatePolicyToSF } from './extensions/handleBrandFromBinLookup';\nimport { setFocusOnFrame } from './partials/setFocusOnFrame';\nimport { postMessageToAllIframes } from './partials/postMessageToAllIframes';\nimport processBrand from './partials/processBrand';\nimport { processAutoComplete } from './partials/processAutoComplete';\nimport { handleFocus } from './partials/handleFocus';\nimport { handleIframeConfigFeedback } from './partials/handleIframeConfigFeedback';\nimport { isConfigured } from './partials/isConfigured';\nimport validateForm from './partials/validateForm';\nimport { handleBinValue } from './partials/handleBinValue';\nimport { destroySecuredFields } from './utils/destroySecuredFields';\nimport postMessageToIframe from './utils/iframes/postMessageToIframe';\nimport getIframeContentWin from './utils/iframes/getIframeContentWin';\nimport * as logger from '../utilities/logger';\nimport { selectOne } from '../utilities/dom';\nimport { on } from '../../../../../utils/listenerUtils';\nimport { partial } from '../utilities/commonUtils';\nimport { hasOwnProperty } from '../../../../../utils/hasOwnProperty';\nimport ua from './utils/userAgent';\nimport { SingleBrandResetObject } from '../../SFP/types';\n\nconst notConfiguredWarning = (str = 'You cannot use secured fields') => {\n logger.warn(`${str} - they are not yet configured. Use the 'onConfigSuccess' callback to know when this has happened.`);\n};\n\nclass CSF extends AbstractCSF {\n declare protected callbacks: CSFCallbacksConfig;\n declare protected config: CSFConfigObject;\n declare protected state: CSFStateObject;\n\n constructor(setupObj: CSFSetupObject) {\n /**\n * Initialises:\n * - this.props = setupObj: CSFSetupObject\n *\n * and empty objects for:\n * - this.config: CSFConfigObject (populated in handleConfig.ts)\n * - this.callbacks: CSFCallbacksConfig (populated in configureCallbacks.ts\n * - this.state: CSFStateObject (populated below)\n */\n super(setupObj);\n\n this.state = {\n /**\n * For generic card will always be 'card'.\n * For non-generic card will be hardcoded to a particular txVariant e.g. 'mc' or 'visa'\n * For other types of SecuredField will be the passed type e.g. 'ach' or 'giftcard'\n */\n type: this.props.type,\n /**\n * For generic card will change as shopper types\n * For non-generic card will be fixed\n */\n brand: this.props.type !== 'card' ? { brand: this.props.type, cvcPolicy: 'required' } : { brand: null, cvcPolicy: 'required' },\n allValid: undefined,\n numIframes: 0,\n originalNumIframes: 0,\n iframeCount: 0,\n iframeConfigCount: 0,\n isConfigured: false,\n hasSeparateDateFields: false,\n currentFocusObject: null,\n registerFieldForIos: false,\n securedFields: {},\n isKCP: false\n } as CSFStateObject;\n\n // Create object of references to properties on 'this', that can be used to set up the partials\n const thisObj: CSFThisObject = { csfState: this.state, csfConfig: this.config, csfProps: this.props, csfCallbacks: this.callbacks };\n\n // Setup 'this' references\n this.configHandler = handleConfig.bind(this);\n\n this.callbacksHandler = configureCallbacks.bind(this);\n\n this.validateForm = partial(validateForm, thisObj);\n\n this.isConfigured = partial(isConfigured, thisObj, this.validateForm);\n this.handleIframeConfigFeedback = partial(handleIframeConfigFeedback, thisObj, this.isConfigured);\n\n this.processBrand = partial(processBrand, thisObj);\n\n this.handleValidation = handleValidation.bind(this);\n this.handleEncryption = handleEncryption.bind(this);\n\n this.createSecuredFields = createSecuredFields.bind(this);\n this.createNonCardSecuredFields = createNonCardSecuredFields.bind(this);\n this.createCardSecuredFields = createCardSecuredFields.bind(this);\n \n this.setupSecuredField = setupSecuredField.bind(this);\n\n this.postMessageToAllIframes = partial(postMessageToAllIframes, thisObj);\n\n this.handleIOSTouchEvents = handleIOSTouchEvents.handleTouchend.bind(this);\n this.touchendListener = handleIOSTouchEvents.touchendListener.bind(this);\n this.destroyTouchendListener = handleIOSTouchEvents.destroyTouchendListener.bind(this);\n this.touchstartListener = handleIOSTouchEvents.touchstartListener.bind(this);\n this.destroyTouchstartListener = handleIOSTouchEvents.destroyTouchstartListener.bind(this);\n\n this.setFocusOnFrame = partial(setFocusOnFrame, thisObj);\n this.handleFocus = partial(handleFocus, thisObj, this.handleIOSTouchEvents);\n\n this.handleSFShiftTab = handleTab.handleSFShiftTab.bind(this);\n this.handleShiftTab = handleTab.handleShiftTab.bind(this);\n\n this.destroySecuredFields = destroySecuredFields.bind(this);\n\n this.processAutoComplete = partial(processAutoComplete, thisObj);\n\n this.handleBinValue = partial(handleBinValue, thisObj);\n\n this.handleBrandFromBinLookup = handleBrandFromBinLookup.bind(this);\n this.sendBrandToCardSF = sendBrandToCardSF.bind(this);\n this.sendExpiryDatePolicyToSF = sendExpiryDatePolicyToSF.bind(this);\n\n // Populate config & callbacks objects & create securedFields\n this.init();\n }\n\n private init(): void {\n this.configHandler(this.props);\n this.callbacksHandler(this.props.callbacks);\n\n /**\n * Create all the securedFields\n */\n const numIframes: number = this.createSecuredFields();\n\n this.state.numIframes = this.state.originalNumIframes = numIframes;\n\n this.state.isKCP = !!this.props.isKCP;\n\n /**\n * Add touchstart listener\n * re. Disabling arrow keys in iOS\n */\n if (ua.__IS_IOS && this.props.shouldDisableIOSArrowKeys) {\n this.hasGenuineTouchEvents = false;\n on(document, 'touchstart', this.touchstartListener);\n }\n }\n\n // Expose functions that can be called on the CSF instance\n public createReturnObject(): CSFReturnObject {\n // --\n const returnObj: CSFReturnObject = {\n // --\n updateStyles: (pStyleObject: StylesObject): void => {\n if (this.state.isConfigured) {\n this.postMessageToAllIframes({ styleObject: pStyleObject });\n } else {\n logger.warn(\n 'You cannot update the secured fields styling ' +\n \"- they are not yet configured. Use the 'onConfigSuccess' callback to know when this has happened.\"\n );\n }\n },\n setFocusOnFrame: (pFieldType: SFFieldType): void => {\n if (this.state.isConfigured) {\n this.setFocusOnFrame(pFieldType);\n // Comment in a quick way to test destroying secured fields (also see comment in destroySecuredFields)\n // this.destroySecuredFields();\n } else {\n notConfiguredWarning('You cannot set focus on any secured field');\n }\n },\n // For component based implementation - if showValidation function is called on the component use this\n // function as a way to notify the CSF that a field is in error\n isValidated: (pFieldType: SFFieldType, code: string): void => {\n if (this.state.isConfigured) {\n if (hasOwnProperty(this.state.securedFields, pFieldType)) {\n this.state.securedFields[pFieldType].hasError = true;\n\n // If there's not already an errorType, set one\n // NOTE: fixes issue in Components where you first validate and then start typing a maestro number\n // - w/o this and the corresponding fix in the SecuredField class the maestro PM will never register as valid\n if (this.state.securedFields[pFieldType].errorType === '') {\n this.state.securedFields[pFieldType].errorType = 'isValidated';\n }\n\n // Inform iframe\n const dataObj: object = {\n txVariant: this.state.type,\n fieldType: pFieldType,\n externalValidation: true,\n code,\n numKey: this.state.securedFields[pFieldType].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(this.state, pFieldType), this.config.loadingContext);\n }\n } else {\n notConfiguredWarning('You cannot set validated on any secured field');\n }\n },\n hasUnsupportedCard: (pFieldType: SFFieldType, code: string): void => {\n if (this.state.isConfigured) {\n if (hasOwnProperty(this.state.securedFields, pFieldType)) {\n //\n this.state.securedFields[pFieldType].hasError = !!code;\n this.state.securedFields[pFieldType].errorType = code;\n\n // Inform iframe\n const dataObj: object = {\n txVariant: this.state.type,\n fieldType: pFieldType,\n unsupportedCard: !!code,\n code,\n numKey: this.state.securedFields[pFieldType].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(this.state, pFieldType), this.config.loadingContext);\n }\n } else {\n notConfiguredWarning('You cannot set hasUnsupportedCard on any secured field');\n }\n },\n destroy: (): void => {\n if (this.state.isConfigured) {\n this.destroySecuredFields();\n } else {\n notConfiguredWarning('You cannot destroy secured fields');\n }\n },\n brandsFromBinLookup: (binLookupResponse: BinLookupResponse, resetObj: SingleBrandResetObject): void => {\n if (!this.config.isCreditCardType) return null;\n\n if (this.state.isConfigured) {\n this.handleBrandFromBinLookup(binLookupResponse, resetObj);\n } else {\n notConfiguredWarning('You cannot set pass brands to secured fields');\n }\n },\n addSecuredField: (pFieldType: SFFieldType): void => {\n const securedField: HTMLElement = selectOne(this.props.rootNode, `[data-cse=\"${pFieldType}\"]`);\n if (securedField) {\n this.state.numIframes += 1;\n this.setupSecuredField(securedField);\n }\n },\n removeSecuredField: (pFieldType: SFFieldType): void => {\n if (this.state.securedFields[pFieldType]) {\n this.state.securedFields[pFieldType].destroy();\n delete this.state.securedFields[pFieldType];\n this.state.numIframes -= 1;\n this.state.iframeCount -= 1;\n\n const callbackObj: CardAdditionalSFData = { additionalIframeRemoved: true, fieldType: pFieldType, type: this.state.type };\n this.callbacks.onAdditionalSFRemoved(callbackObj);\n }\n },\n setKCPStatus: (isKCP: boolean): void => {\n this.state.isKCP = isKCP;\n },\n sfIsOptionalOrHidden: (fieldType: string): boolean => {\n return this.state.securedFields[fieldType].isOptionalOrHidden();\n }\n };\n\n return returnObj;\n }\n}\n\nexport default CSF;\n"],"names":["notConfiguredWarning","str","logger","CSF","AbstractCSF","init","this","configHandler","props","callbacksHandler","callbacks","numIframes","createSecuredFields","state","originalNumIframes","isKCP","ua","__IS_IOS","shouldDisableIOSArrowKeys","hasGenuineTouchEvents","on","document","touchstartListener","createReturnObject","updateStyles","pStyleObject","isConfigured","postMessageToAllIframes","styleObject","setFocusOnFrame","pFieldType","isValidated","code","hasOwnProperty","securedFields","hasError","errorType","dataObj","txVariant","type","fieldType","externalValidation","numKey","postMessageToIframe","getIframeContentWin","config","loadingContext","hasUnsupportedCard","unsupportedCard","destroy","destroySecuredFields","brandsFromBinLookup","binLookupResponse","resetObj","isCreditCardType","handleBrandFromBinLookup","addSecuredField","securedField","selectOne","rootNode","setupSecuredField","removeSecuredField","iframeCount","callbackObj","additionalIframeRemoved","onAdditionalSFRemoved","setKCPStatus","sfIsOptionalOrHidden","isOptionalOrHidden","constructor","setupObj","super","brand","cvcPolicy","allValid","undefined","iframeConfigCount","hasSeparateDateFields","currentFocusObject","registerFieldForIos","thisObj","csfState","csfConfig","csfProps","csfCallbacks","handleConfig","bind","configureCallbacks","validateForm","partial","handleIframeConfigFeedback","processBrand","handleValidation","handleEncryption","createNonCardSecuredFields","createCardSecuredFields","handleIOSTouchEvents","handleTouchend","touchendListener","destroyTouchendListener","destroyTouchstartListener","handleFocus","handleSFShiftTab","handleTab","handleShiftTab","processAutoComplete","handleBinValue","sendBrandToCardSF","sendExpiryDatePolicyToSF"],"mappings":"qrDAgCA,MAAMA,EAAuB,CAACC,EAAM,mCAChCC,EAAY,GAAGD,wGAGnB,MAAME,UAAYC,EA8FNC,IAAAA,GACJC,KAAKC,cAAcD,KAAKE,OACxBF,KAAKG,iBAAiBH,KAAKE,MAAME,WAKjC,MAAMC,EAAqBL,KAAKM,sBAEhCN,KAAKO,MAAMF,WAAaL,KAAKO,MAAMC,mBAAqBH,EAExDL,KAAKO,MAAME,QAAUT,KAAKE,MAAMO,MAM5BC,EAAGC,UAAYX,KAAKE,MAAMU,4BAC1BZ,KAAKa,uBAAwB,EAC7BC,EAAGC,SAAU,aAAcf,KAAKgB,oBAExC,CAGOC,kBAAAA,GAkHH,MAhHmC,CAE/BC,aAAeC,IACPnB,KAAKO,MAAMa,aACXpB,KAAKqB,wBAAwB,CAAEC,YAAaH,IAE5CvB,EACI,mJAKZ2B,gBAAkBC,IACVxB,KAAKO,MAAMa,aACXpB,KAAKuB,gBAAgBC,GAIrB9B,EAAqB,8CAK7B+B,YAAa,CAACD,EAAyBE,KACnC,GAAI1B,KAAKO,MAAMa,cACX,GAAIO,EAAe3B,KAAKO,MAAMqB,cAAeJ,GAAa,CACtDxB,KAAKO,MAAMqB,cAAcJ,GAAYK,UAAW,EAKO,KAAnD7B,KAAKO,MAAMqB,cAAcJ,GAAYM,YACrC9B,KAAKO,MAAMqB,cAAcJ,GAAYM,UAAY,eAIrD,MAAMC,EAAkB,CACpBC,UAAWhC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0B,KAAKhF,MAEhDA,KAAKqB,wBAA0B8D,EAAQ9D,EAAyBqD,GAEhE1E,KAAK0F,qBAAuBA,EAAqBC,eAAeX,KAAKhF,MACrEA,KAAK4F,iBAAmBF,EAAqBE,iBAAiBZ,KAAKhF,MACnEA,KAAK6F,wBAA0BH,EAAqBG,wBAAwBb,KAAKhF,MACjFA,KAAKgB,mBAAqB0E,EAAqB1E,mBAAmBgE,KAAKhF,MACvEA,KAAK8F,0BAA4BJ,EAAqBI,0BAA0Bd,KAAKhF,MAErFA,KAAKuB,gBAAkB4D,EAAQ5D,EAAiBmD,GAChD1E,KAAK+F,YAAcZ,EAAQY,EAAarB,EAAS1E,KAAK0F,sBAEtD1F,KAAKgG,iBAAmBC,EAAUD,iBAAiBhB,KAAKhF,MACxDA,KAAKkG,eAAiBD,EAAUC,eAAelB,KAAKhF,MAEpDA,KAAK4C,qBAAuBA,EAAqBoC,KAAKhF,MAEtDA,KAAKmG,oBAAsBhB,EAAQgB,EAAqBzB,GAExD1E,KAAKoG,eAAiBjB,EAAQiB,EAAgB1B,GAE9C1E,KAAKiD,yBAA2BA,EAAyB+B,KAAKhF,MAC9DA,KAAKqG,kBAAoBA,EAAkBrB,KAAKhF,MAChDA,KAAKsG,yBAA2BA,EAAyBtB,KAAKhF,MAG9DA,KAAKD,MACT"}
1
+ {"version":3,"file":"CSF.js","sources":["../../../../../../../src/components/internal/SecuredFields/lib/CSF/CSF.ts"],"sourcesContent":["import AbstractCSF from './AbstractCSF';\nimport { CSFReturnObject, CSFSetupObject, CSFStateObject, CSFThisObject, CSFCallbacksConfig, CSFConfigObject } from './types';\nimport { StylesObject, CardAdditionalSFData, SFFieldType } from '../types';\nimport { BinLookupResponse } from '../../../../Card/types';\nimport { handleConfig } from './extensions/handleConfig';\nimport { configureCallbacks } from './extensions/configureCallbacks';\nimport { handleValidation } from './extensions/handleValidation';\nimport { handleEncryption } from './extensions/handleEncryption';\nimport { createSecuredFields, createNonCardSecuredFields, createCardSecuredFields, setupSecuredField } from './extensions/createSecuredFields';\nimport handleIOSTouchEvents from './extensions/handleIOSTouchEvents';\nimport handleTab from './extensions/handleTab';\nimport handleBrandFromBinLookup, { sendBrandToCardSF, sendExpiryDatePolicyToSF } from './extensions/handleBrandFromBinLookup';\nimport { setFocusOnFrame } from './partials/setFocusOnFrame';\nimport { postMessageToAllIframes } from './partials/postMessageToAllIframes';\nimport processBrand from './partials/processBrand';\nimport { processAutoComplete } from './partials/processAutoComplete';\nimport { handleFocus } from './partials/handleFocus';\nimport { handleIframeConfigFeedback } from './partials/handleIframeConfigFeedback';\nimport { isConfigured } from './partials/isConfigured';\nimport validateForm from './partials/validateForm';\nimport { handleBinValue } from './partials/handleBinValue';\nimport { destroySecuredFields } from './utils/destroySecuredFields';\nimport postMessageToIframe from './utils/iframes/postMessageToIframe';\nimport getIframeContentWin from './utils/iframes/getIframeContentWin';\nimport * as logger from '../utilities/logger';\nimport { selectOne } from '../utilities/dom';\nimport { on } from '../../../../../utils/listenerUtils';\nimport { partial } from '../utilities/commonUtils';\nimport { hasOwnProperty } from '../../../../../utils/hasOwnProperty';\nimport ua from './utils/userAgent';\nimport { SingleBrandResetObject } from '../../SFP/types';\n\nconst notConfiguredWarning = (str = 'You cannot use secured fields') => {\n logger.warn(`${str} - they are not yet configured. Use the 'onConfigSuccess' callback to know when this has happened.`);\n};\n\nclass CSF extends AbstractCSF {\n declare protected callbacks: CSFCallbacksConfig;\n declare protected config: CSFConfigObject;\n declare protected state: CSFStateObject;\n\n constructor(setupObj: CSFSetupObject) {\n /**\n * Initialises:\n * - this.props = setupObj: CSFSetupObject\n *\n * and empty objects for:\n * - this.config: CSFConfigObject (populated in handleConfig.ts)\n * - this.callbacks: CSFCallbacksConfig (populated in configureCallbacks.ts\n * - this.state: CSFStateObject (populated below)\n */\n super(setupObj);\n\n this.state = {\n /**\n * For generic card will always be 'card'.\n * For non-generic card will be hardcoded to a particular txVariant e.g. 'mc' or 'visa'\n * For other types of SecuredField will be the passed type e.g. 'ach' or 'giftcard'\n */\n type: this.props.type,\n /**\n * For generic card will change as shopper types\n * For non-generic card will be fixed\n */\n brand: this.props.type !== 'card' ? { brand: this.props.type, cvcPolicy: 'required' } : { brand: null, cvcPolicy: 'required' },\n allValid: undefined,\n numIframes: 0,\n originalNumIframes: 0,\n iframeCount: 0,\n iframeConfigCount: 0,\n isConfigured: false,\n hasSeparateDateFields: false,\n currentFocusObject: null,\n registerFieldForIos: false,\n securedFields: {},\n isKCP: false\n } as CSFStateObject;\n\n // Create object of references to properties on 'this', that can be used to set up the partials\n const thisObj: CSFThisObject = { csfState: this.state, csfConfig: this.config, csfProps: this.props, csfCallbacks: this.callbacks };\n\n // Setup 'this' references\n this.configHandler = handleConfig.bind(this);\n\n this.callbacksHandler = configureCallbacks.bind(this);\n\n this.validateForm = partial(validateForm, thisObj);\n\n this.isConfigured = partial(isConfigured, thisObj, this.validateForm);\n this.handleIframeConfigFeedback = partial(handleIframeConfigFeedback, thisObj, this.isConfigured);\n\n this.processBrand = partial(processBrand, thisObj);\n\n this.handleValidation = handleValidation.bind(this);\n this.handleEncryption = handleEncryption.bind(this);\n\n this.createSecuredFields = createSecuredFields.bind(this);\n this.createNonCardSecuredFields = createNonCardSecuredFields.bind(this);\n this.createCardSecuredFields = createCardSecuredFields.bind(this);\n\n this.setupSecuredField = setupSecuredField.bind(this);\n\n this.postMessageToAllIframes = partial(postMessageToAllIframes, thisObj);\n\n this.handleIOSTouchEvents = handleIOSTouchEvents.handleTouchend.bind(this);\n this.touchendListener = handleIOSTouchEvents.touchendListener.bind(this);\n this.destroyTouchendListener = handleIOSTouchEvents.destroyTouchendListener.bind(this);\n this.touchstartListener = handleIOSTouchEvents.touchstartListener.bind(this);\n this.destroyTouchstartListener = handleIOSTouchEvents.destroyTouchstartListener.bind(this);\n\n this.setFocusOnFrame = partial(setFocusOnFrame, thisObj);\n this.handleFocus = partial(handleFocus, thisObj, this.handleIOSTouchEvents);\n\n this.handleSFShiftTab = handleTab.handleSFShiftTab.bind(this);\n this.handleShiftTab = handleTab.handleShiftTab.bind(this);\n\n this.destroySecuredFields = destroySecuredFields.bind(this);\n\n this.processAutoComplete = partial(processAutoComplete, thisObj);\n\n this.handleBinValue = partial(handleBinValue, thisObj);\n\n this.handleBrandFromBinLookup = handleBrandFromBinLookup.bind(this);\n this.sendBrandToCardSF = sendBrandToCardSF.bind(this);\n this.sendExpiryDatePolicyToSF = sendExpiryDatePolicyToSF.bind(this);\n\n // Populate config & callbacks objects & create securedFields\n this.init();\n }\n\n private init(): void {\n this.configHandler(this.props);\n this.callbacksHandler(this.props.callbacks);\n\n /**\n * Create all the securedFields\n */\n const numIframes: number = this.createSecuredFields();\n\n this.state.numIframes = this.state.originalNumIframes = numIframes;\n\n this.state.isKCP = !!this.props.isKCP;\n\n /**\n * Add touchstart listener\n * re. Disabling arrow keys in iOS\n */\n if (ua.__IS_IOS && this.props.shouldDisableIOSArrowKeys) {\n this.hasGenuineTouchEvents = false;\n on(document, 'touchstart', this.touchstartListener);\n }\n }\n\n // Expose functions that can be called on the CSF instance\n public createReturnObject(): CSFReturnObject {\n // --\n const returnObj: CSFReturnObject = {\n // --\n updateStyles: (pStyleObject: StylesObject): void => {\n if (this.state.isConfigured) {\n this.postMessageToAllIframes({ styleObject: pStyleObject });\n } else {\n logger.warn(\n 'You cannot update the secured fields styling ' +\n \"- they are not yet configured. Use the 'onConfigSuccess' callback to know when this has happened.\"\n );\n }\n },\n setFocusOnFrame: (pFieldType: SFFieldType): void => {\n if (this.state.isConfigured) {\n this.setFocusOnFrame(pFieldType);\n // Comment in a quick way to test destroying secured fields (also see comment in destroySecuredFields)\n // this.destroySecuredFields();\n } else {\n notConfiguredWarning('You cannot set focus on any secured field');\n }\n },\n // For component based implementation - if showValidation function is called on the component use this\n // function as a way to notify the CSF that a field is in error\n isValidated: (pFieldType: SFFieldType, code: string): void => {\n if (this.state.isConfigured) {\n if (hasOwnProperty(this.state.securedFields, pFieldType)) {\n this.state.securedFields[pFieldType].hasError = true;\n\n // If there's not already an errorType, set one\n // NOTE: fixes issue in Components where you first validate and then start typing a maestro number\n // - w/o this and the corresponding fix in the SecuredField class the maestro PM will never register as valid\n if (this.state.securedFields[pFieldType].errorType === '') {\n this.state.securedFields[pFieldType].errorType = 'isValidated';\n }\n\n // Inform iframe\n const dataObj: object = {\n txVariant: this.state.type,\n fieldType: pFieldType,\n externalValidation: true,\n code,\n numKey: this.state.securedFields[pFieldType].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(this.state, pFieldType), this.config.loadingContext);\n }\n } else {\n notConfiguredWarning('You cannot set validated on any secured field');\n }\n },\n hasUnsupportedCard: (pFieldType: SFFieldType, code: string): void => {\n if (this.state.isConfigured) {\n if (hasOwnProperty(this.state.securedFields, pFieldType)) {\n //\n this.state.securedFields[pFieldType].hasError = !!code;\n this.state.securedFields[pFieldType].errorType = code;\n\n // Inform iframe\n const dataObj: object = {\n txVariant: this.state.type,\n fieldType: pFieldType,\n unsupportedCard: !!code,\n code,\n numKey: this.state.securedFields[pFieldType].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(this.state, pFieldType), this.config.loadingContext);\n }\n } else {\n notConfiguredWarning('You cannot set hasUnsupportedCard on any secured field');\n }\n },\n destroy: (): void => {\n if (this.state.isConfigured) {\n this.destroySecuredFields();\n } else {\n notConfiguredWarning('You cannot destroy secured fields');\n }\n },\n brandsFromBinLookup: (binLookupResponse: BinLookupResponse, resetObj: SingleBrandResetObject): void => {\n if (!this.config.isCreditCardType) return null;\n\n if (this.state.isConfigured) {\n this.handleBrandFromBinLookup(binLookupResponse, resetObj);\n } else {\n notConfiguredWarning('You cannot set pass brands to secured fields');\n }\n },\n addSecuredField: (pFieldType: SFFieldType): void => {\n const securedField: HTMLElement = selectOne(this.props.rootNode, `[data-cse=\"${pFieldType}\"]`);\n if (securedField) {\n this.state.numIframes += 1;\n this.setupSecuredField(securedField);\n }\n },\n removeSecuredField: (pFieldType: SFFieldType): void => {\n if (this.state.securedFields[pFieldType]) {\n this.state.securedFields[pFieldType].destroy();\n delete this.state.securedFields[pFieldType];\n this.state.numIframes -= 1;\n this.state.iframeCount -= 1;\n\n const callbackObj: CardAdditionalSFData = { additionalIframeRemoved: true, fieldType: pFieldType, type: this.state.type };\n this.callbacks.onAdditionalSFRemoved(callbackObj);\n }\n },\n setKCPStatus: (isKCP: boolean): void => {\n this.state.isKCP = isKCP;\n },\n sfIsOptionalOrHidden: (fieldType: string): boolean => {\n return this.state.securedFields[fieldType].isOptionalOrHidden();\n }\n };\n\n return returnObj;\n }\n}\n\nexport default CSF;\n"],"names":["notConfiguredWarning","str","logger","CSF","AbstractCSF","init","this","configHandler","props","callbacksHandler","callbacks","numIframes","createSecuredFields","state","originalNumIframes","isKCP","ua","__IS_IOS","shouldDisableIOSArrowKeys","hasGenuineTouchEvents","on","document","touchstartListener","createReturnObject","updateStyles","pStyleObject","isConfigured","postMessageToAllIframes","styleObject","setFocusOnFrame","pFieldType","isValidated","code","hasOwnProperty","securedFields","hasError","errorType","dataObj","txVariant","type","fieldType","externalValidation","numKey","postMessageToIframe","getIframeContentWin","config","loadingContext","hasUnsupportedCard","unsupportedCard","destroy","destroySecuredFields","brandsFromBinLookup","binLookupResponse","resetObj","isCreditCardType","handleBrandFromBinLookup","addSecuredField","securedField","selectOne","rootNode","setupSecuredField","removeSecuredField","iframeCount","callbackObj","additionalIframeRemoved","onAdditionalSFRemoved","setKCPStatus","sfIsOptionalOrHidden","isOptionalOrHidden","constructor","setupObj","super","brand","cvcPolicy","allValid","undefined","iframeConfigCount","hasSeparateDateFields","currentFocusObject","registerFieldForIos","thisObj","csfState","csfConfig","csfProps","csfCallbacks","handleConfig","bind","configureCallbacks","validateForm","partial","handleIframeConfigFeedback","processBrand","handleValidation","handleEncryption","createNonCardSecuredFields","createCardSecuredFields","handleIOSTouchEvents","handleTouchend","touchendListener","destroyTouchendListener","destroyTouchstartListener","handleFocus","handleSFShiftTab","handleTab","handleShiftTab","processAutoComplete","handleBinValue","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,0BAA0Bd,KAAKhF,MAErFA,KAAKuB,gBAAkB4D,EAAQ5D,EAAiBmD,GAChD1E,KAAK+F,YAAcZ,EAAQY,EAAarB,EAAS1E,KAAK0F,sBAEtD1F,KAAKgG,iBAAmBC,EAAUD,iBAAiBhB,KAAKhF,MACxDA,KAAKkG,eAAiBD,EAAUC,eAAelB,KAAKhF,MAEpDA,KAAK4C,qBAAuBA,EAAqBoC,KAAKhF,MAEtDA,KAAKmG,oBAAsBhB,EAAQgB,EAAqBzB,GAExD1E,KAAKoG,eAAiBjB,EAAQiB,EAAgB1B,GAE9C1E,KAAKiD,yBAA2BA,EAAyB+B,KAAKhF,MAC9DA,KAAKqG,kBAAoBA,EAAkBrB,KAAKhF,MAChDA,KAAKsG,yBAA2BA,EAAyBtB,KAAKhF,MAG9DA,KAAKD,MACT"}
@@ -1,2 +1,2 @@
1
- import{DATE_POLICY_REQUIRED as e,ENCRYPTED_EXPIRY_DATE as t,DATE_POLICY_HIDDEN as s,ENCRYPTED_CARD_NUMBER as i,ENCRYPTED_SECURITY_CODE as r,ENCRYPTED_EXPIRY_MONTH as n,ENCRYPTED_EXPIRY_YEAR as o}from"../../constants.js";import c from"../utils/iframes/postMessageToIframe.js";import{hasOwnProperty as a}from"../../../../../../utils/hasOwnProperty.js";import l from"../utils/iframes/getIframeContentWin.js";function d(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function u(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},i=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(s).filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),i.forEach(function(t){d(e,t,s[t])})}return e}function y(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t.push.apply(t,s)}return t}(Object(t)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(t,s))}),e}function p(e){if(a(this.state.securedFields,i)){const t=y(u({txVariant:this.state.type},e),{fieldType:i,numKey:this.state.securedFields[i].numKey});c(t,l(this.state,i),this.config.loadingContext)}}function h(e){(a(this.state.securedFields,n)&&a(this.state.securedFields,o)?[n,o]:[t]).forEach(t=>{const s=y(u({txVariant:this.state.type},e),{fieldType:t,numKey:this.state.securedFields[t].numKey});c(s,l(this.state,t),this.config.loadingContext)})}function f(c,l){var d,p;const h="card"===this.state.type;if(!c||!Object.keys(c).length)return h?(this.sendBrandToCardSF({brand:"reset"}),this.sendExpiryDatePolicyToSF({expiryDatePolicy:e})):l&&this.processBrand(y(u({},l),{fieldType:i})),void("card"===this.state.type&&a(this.state.securedFields,t)&&(this.state.securedFields[t].expiryDatePolicy=e));const f=c.supportedBrands[0],b=f.brand,P=null!==(d=f.expiryDatePolicy)&&void 0!==d?d:!0===f.showExpiryDate?e:s,m={brand:b,cvcPolicy:f.cvcPolicy,expiryDatePolicy:P,cvcText:"Security code",showSocialSecurityNumber:null!==(p=f.showSocialSecurityNumber)&&void 0!==p&&p,fieldType:i};if(this.processBrand(m),h){const e=u({brand:b,enableLuhnCheck:!1!==c.supportedBrands[0].enableLuhnCheck},(null==f?void 0:f.panLength)&&!c.isDualBrandSelection&&{panLength:null==f?void 0:f.panLength});this.sendBrandToCardSF(e),this.sendExpiryDatePolicyToSF({expiryDatePolicy:P})}a(this.state.securedFields,r)&&(this.state.securedFields[r].cvcPolicy=f.cvcPolicy),a(this.state.securedFields,t)?this.state.securedFields[t].expiryDatePolicy=P:a(this.state.securedFields,n)&&a(this.state.securedFields,o)&&(this.state.securedFields[n].expiryDatePolicy=P,this.state.securedFields[o].expiryDatePolicy=P),this.validateForm()}export{f as default,p as sendBrandToCardSF,h as sendExpiryDatePolicyToSF};
1
+ import{DATE_POLICY_REQUIRED as e,ENCRYPTED_EXPIRY_DATE as t,DATE_POLICY_HIDDEN as s,BIN_LOOKUP_MODE as i,ENCRYPTED_CARD_NUMBER as r,ENCRYPTED_SECURITY_CODE as n,ENCRYPTED_EXPIRY_MONTH as o,ENCRYPTED_EXPIRY_YEAR as c}from"../../constants.js";import a from"../utils/iframes/postMessageToIframe.js";import{hasOwnProperty as l}from"../../../../../../utils/hasOwnProperty.js";import d from"../utils/iframes/getIframeContentWin.js";function u(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function y(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},i=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(s).filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),i.forEach(function(t){u(e,t,s[t])})}return e}function p(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t.push.apply(t,s)}return t}(Object(t)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(t,s))}),e}function h(e){if(l(this.state.securedFields,r)){const t=p(y({txVariant:this.state.type},e),{fieldType:r,numKey:this.state.securedFields[r].numKey});a(t,d(this.state,r),this.config.loadingContext)}}function f(e){(l(this.state.securedFields,o)&&l(this.state.securedFields,c)?[o,c]:[t]).forEach(t=>{const s=p(y({txVariant:this.state.type},e),{fieldType:t,numKey:this.state.securedFields[t].numKey});a(s,d(this.state,t),this.config.loadingContext)})}function b(a,d){var u,h;const f="card"===this.state.type;if(!a||!Object.keys(a).length)return f?(this.sendBrandToCardSF({brand:"reset"}),this.sendExpiryDatePolicyToSF({expiryDatePolicy:e})):d&&this.processBrand(p(y({},d),{fieldType:r})),void("card"===this.state.type&&l(this.state.securedFields,t)&&(this.state.securedFields[t].expiryDatePolicy=e));const b=a.supportedBrands[0],m=b.brand,P=null!==(u=b.expiryDatePolicy)&&void 0!==u?u:!0===b.showExpiryDate?e:s,O={brand:m,cvcPolicy:b.cvcPolicy,expiryDatePolicy:P,cvcText:"Security code",showSocialSecurityNumber:null!==(h=b.showSocialSecurityNumber)&&void 0!==h&&h,fieldType:r,mode:i};if(this.processBrand(O),f){const e=y({brand:m,enableLuhnCheck:!1!==a.supportedBrands[0].enableLuhnCheck},(null==b?void 0:b.panLength)&&!a.isDualBrandSelection&&{panLength:null==b?void 0:b.panLength});this.sendBrandToCardSF(e),this.sendExpiryDatePolicyToSF({expiryDatePolicy:P})}l(this.state.securedFields,n)&&(this.state.securedFields[n].cvcPolicy=b.cvcPolicy),l(this.state.securedFields,t)?this.state.securedFields[t].expiryDatePolicy=P:l(this.state.securedFields,o)&&l(this.state.securedFields,c)&&(this.state.securedFields[o].expiryDatePolicy=P,this.state.securedFields[c].expiryDatePolicy=P),this.validateForm()}export{b as default,h as sendBrandToCardSF,f as sendExpiryDatePolicyToSF};
2
2
  //# sourceMappingURL=handleBrandFromBinLookup.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"handleBrandFromBinLookup.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.ts"],"sourcesContent":["import {\n ENCRYPTED_SECURITY_CODE,\n ENCRYPTED_CARD_NUMBER,\n DATE_POLICY_REQUIRED,\n DATE_POLICY_HIDDEN,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR\n} from '../../constants';\nimport postMessageToIframe from '../utils/iframes/postMessageToIframe';\nimport { SFFeedbackObj, SendBrandObject, SendExpiryDateObject } from '../../types';\nimport { BinLookupResponse, BrandObject } from '../../../../../Card/types';\nimport { hasOwnProperty } from '../../../../../../utils/hasOwnProperty';\nimport getIframeContentWin from '../utils/iframes/getIframeContentWin';\nimport { SingleBrandResetObject } from '../../../SFP/types';\n\nexport function sendBrandToCardSF(brandObj: SendBrandObject): void {\n if (hasOwnProperty(this.state.securedFields, ENCRYPTED_CARD_NUMBER)) {\n const dataObj: object = {\n txVariant: this.state.type,\n ...brandObj,\n fieldType: ENCRYPTED_CARD_NUMBER,\n numKey: this.state.securedFields[ENCRYPTED_CARD_NUMBER].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(this.state, ENCRYPTED_CARD_NUMBER), this.config.loadingContext);\n }\n}\n\nexport function sendExpiryDatePolicyToSF(expiryDateObj: SendExpiryDateObject): void {\n const separateDateFields =\n hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_MONTH) && hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_YEAR);\n\n const dateIframesArr = separateDateFields ? [ENCRYPTED_EXPIRY_MONTH, ENCRYPTED_EXPIRY_YEAR] : [ENCRYPTED_EXPIRY_DATE];\n\n dateIframesArr.forEach((key: string) => {\n const dataObj: object = {\n txVariant: this.state.type,\n ...expiryDateObj,\n fieldType: key,\n numKey: this.state.securedFields[key].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(this.state, key), this.config.loadingContext);\n });\n}\n\nexport default function handleBrandFromBinLookup(binLookupResponse: BinLookupResponse, resetObj: SingleBrandResetObject): void {\n const isGenericCard: boolean = this.state.type === 'card';\n\n /**\n * The number of digits in number field has dropped below threshold for BIN lookup (or the bin wasn't found in the DB)\n * - so tell SF to reset & republish the brand it detects\n */\n if (!binLookupResponse || !Object.keys(binLookupResponse).length) {\n if (isGenericCard) {\n // This will be sent to CardNumber SF which will trigger the brand to be re-evaluated and broadcast\n // (which will reset cvcPolicy & expiryDatePolicy in state, here in Checkout)\n this.sendBrandToCardSF({ brand: 'reset' });\n // Also pass the reset expiryDatePolicy to the date related SFs so they can reset visibility & aria-required attrs\n this.sendExpiryDatePolicyToSF({ expiryDatePolicy: DATE_POLICY_REQUIRED });\n } else {\n /**\n * For \"dedicated\" card components, i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands,\n * there will be no to-and-fro with the securedField iframe to reset brand.\n * The presence of a resetObj indicates we are in this \"dedicated\"\" scenario, so we need to use the information contained within this object\n * to internally reset the brand\n */\n if (resetObj) {\n this.processBrand({ ...resetObj, fieldType: ENCRYPTED_CARD_NUMBER } as SFFeedbackObj);\n }\n }\n\n // Reset expiryDatePolicy - which never comes from SF // TODO find out under which circumstances this clause is still required\n if (this.state.type === 'card' && hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_DATE)) {\n this.state.securedFields[ENCRYPTED_EXPIRY_DATE].expiryDatePolicy = DATE_POLICY_REQUIRED;\n }\n\n return;\n }\n\n const binBrandObj: BrandObject = binLookupResponse.supportedBrands[0];\n\n const passedBrand: string = binBrandObj.brand;\n\n // Look first for expiryDatePolicy string otherwise use showExpiryDate boolean\n const expiryDatePolicy = binBrandObj.expiryDatePolicy ?? (binBrandObj.showExpiryDate === true ? DATE_POLICY_REQUIRED : DATE_POLICY_HIDDEN);\n\n const brandObj: object = {\n brand: passedBrand,\n cvcPolicy: binBrandObj.cvcPolicy,\n expiryDatePolicy,\n cvcText: 'Security code',\n showSocialSecurityNumber: binBrandObj.showSocialSecurityNumber ?? false,\n fieldType: ENCRYPTED_CARD_NUMBER\n };\n\n // Take advantage of function used to handle brand messages from SF in order to process this new brand information\n this.processBrand(brandObj as SFFeedbackObj);\n\n if (isGenericCard) {\n // Pass brand to CardNumber SF\n const cardObj: SendBrandObject = {\n brand: passedBrand,\n enableLuhnCheck: binLookupResponse.supportedBrands[0].enableLuhnCheck !== false,\n // Only pass the panLength if a) we have one & b) we're not in a switching-between-dual-brands scenario\n // (because it causes unnecessary callbacks from SF which uses panLength to trigger moving focus to the expiryDate field)\n ...(binBrandObj?.panLength && !binLookupResponse.isDualBrandSelection && { panLength: binBrandObj?.panLength })\n };\n this.sendBrandToCardSF(cardObj);\n\n // Inform the date related securedFields\n // - if expiryDatePolicy is 'optional' or 'hidden' they need to set the aria-required attribute / hide themselves\n this.sendExpiryDatePolicyToSF({ expiryDatePolicy });\n }\n\n /**\n * CHECK IF BRAND CHANGE MEANS FORM IS NOW VALID e.g maestro/bcmc (which don't require cvc) OR bcmc/visa (one of which doesn't require cvc, one of which does)\n */\n\n /**\n * First set the cvcPolicy value on the relevant SecuredFields instance (which will reflect in the cvc field being considered valid,\n * as long as it is not in error)...\n */\n if (hasOwnProperty(this.state.securedFields, ENCRYPTED_SECURITY_CODE)) {\n this.state.securedFields[ENCRYPTED_SECURITY_CODE].cvcPolicy = binBrandObj.cvcPolicy;\n }\n\n /**\n * ...then set the expiryDatePolicy...\n */\n if (hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_DATE)) {\n this.state.securedFields[ENCRYPTED_EXPIRY_DATE].expiryDatePolicy = expiryDatePolicy;\n } else if (hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_MONTH) && hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_YEAR)) {\n this.state.securedFields[ENCRYPTED_EXPIRY_MONTH].expiryDatePolicy = expiryDatePolicy;\n this.state.securedFields[ENCRYPTED_EXPIRY_YEAR].expiryDatePolicy = expiryDatePolicy;\n }\n\n /**\n * ...and now re-check if form i.e all the SecuredFields, are valid\n */\n this.validateForm();\n}\n"],"names":["sendBrandToCardSF","brandObj","hasOwnProperty","this","state","securedFields","ENCRYPTED_CARD_NUMBER","dataObj","_object_spread_props","_object_spread","txVariant","type","fieldType","numKey","postMessageToIframe","getIframeContentWin","config","loadingContext","sendExpiryDatePolicyToSF","expiryDateObj","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","ENCRYPTED_EXPIRY_DATE","forEach","key","handleBrandFromBinLookup","binLookupResponse","resetObj","binBrandObj","isGenericCard","Object","keys","length","brand","expiryDatePolicy","DATE_POLICY_REQUIRED","processBrand","supportedBrands","passedBrand","showExpiryDate","DATE_POLICY_HIDDEN","cvcPolicy","cvcText","showSocialSecurityNumber","cardObj","enableLuhnCheck","panLength","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A,EAAYM,wBAAZN,IAAAA,EAAAA,GAAgE,IAA/BA,EAAYW,eAA0BJ,EAAuBK,EAEjHvC,EAAmB,CACrBgC,MAAOK,EACPG,UAAWb,EAAYa,UACvBP,mBACAQ,QAAS,gBACTC,yBAA8D,QAApCf,EAAAA,EAAYe,oCAAZf,GAAAA,EAC1BhB,UAAWN,GAMf,GAFAH,KAAKiC,aAAanC,GAEd4B,EAAe,CAEf,MAAMe,EAA2BnC,EAAA,CAC7BwB,MAAOK,EACPO,iBAA0E,IAAzDnB,EAAkBW,gBAAgB,GAAGQ,kBAGlDjB,eAAAA,EAAakB,aAAcpB,EAAkBqB,sBAAwB,CAAED,UAAWlB,aAAAA,EAAAA,EAAakB,YAEvG3C,KAAKH,kBAAkB4C,GAIvBzC,KAAKe,yBAAyB,CAAEgB,oBACpC,CAUIhC,EAAeC,KAAKC,MAAMC,cAAe2C,KACzC7C,KAAKC,MAAMC,cAAc2C,GAAyBP,UAAYb,EAAYa,WAM1EvC,EAAeC,KAAKC,MAAMC,cAAeiB,GACzCnB,KAAKC,MAAMC,cAAciB,GAAuBY,iBAAmBA,EAC5DhC,EAAeC,KAAKC,MAAMC,cAAee,IAA2BlB,EAAeC,KAAKC,MAAMC,cAAegB,KACpHlB,KAAKC,MAAMC,cAAce,GAAwBc,iBAAmBA,EACpE/B,KAAKC,MAAMC,cAAcgB,GAAuBa,iBAAmBA,GAMvE/B,KAAK8C,cACT"}
1
+ {"version":3,"file":"handleBrandFromBinLookup.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.ts"],"sourcesContent":["import {\n ENCRYPTED_SECURITY_CODE,\n ENCRYPTED_CARD_NUMBER,\n DATE_POLICY_REQUIRED,\n DATE_POLICY_HIDDEN,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR,\n BIN_LOOKUP_MODE\n} from '../../constants';\nimport postMessageToIframe from '../utils/iframes/postMessageToIframe';\nimport { SFFeedbackObj, SendBrandObject, SendExpiryDateObject } from '../../types';\nimport { BinLookupResponse, BrandObject } from '../../../../../Card/types';\nimport { hasOwnProperty } from '../../../../../../utils/hasOwnProperty';\nimport getIframeContentWin from '../utils/iframes/getIframeContentWin';\nimport { SingleBrandResetObject } from '../../../SFP/types';\n\nexport function sendBrandToCardSF(brandObj: SendBrandObject): void {\n if (hasOwnProperty(this.state.securedFields, ENCRYPTED_CARD_NUMBER)) {\n const dataObj: object = {\n txVariant: this.state.type,\n ...brandObj,\n fieldType: ENCRYPTED_CARD_NUMBER,\n numKey: this.state.securedFields[ENCRYPTED_CARD_NUMBER].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(this.state, ENCRYPTED_CARD_NUMBER), this.config.loadingContext);\n }\n}\n\nexport function sendExpiryDatePolicyToSF(expiryDateObj: SendExpiryDateObject): void {\n const separateDateFields =\n hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_MONTH) && hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_YEAR);\n\n const dateIframesArr = separateDateFields ? [ENCRYPTED_EXPIRY_MONTH, ENCRYPTED_EXPIRY_YEAR] : [ENCRYPTED_EXPIRY_DATE];\n\n dateIframesArr.forEach((key: string) => {\n const dataObj: object = {\n txVariant: this.state.type,\n ...expiryDateObj,\n fieldType: key,\n numKey: this.state.securedFields[key].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(this.state, key), this.config.loadingContext);\n });\n}\n\nexport default function handleBrandFromBinLookup(binLookupResponse: BinLookupResponse, resetObj: SingleBrandResetObject): void {\n const isGenericCard: boolean = this.state.type === 'card';\n\n /**\n * The number of digits in number field has dropped below threshold for BIN lookup (or the bin wasn't found in the DB)\n * - so tell SF to reset & republish the brand it detects\n */\n if (!binLookupResponse || !Object.keys(binLookupResponse).length) {\n if (isGenericCard) {\n // This will be sent to CardNumber SF which will trigger the brand to be re-evaluated and broadcast\n // (which will reset cvcPolicy & expiryDatePolicy in state, here in Checkout)\n this.sendBrandToCardSF({ brand: 'reset' });\n // Also pass the reset expiryDatePolicy to the date related SFs so they can reset visibility & aria-required attrs\n this.sendExpiryDatePolicyToSF({ expiryDatePolicy: DATE_POLICY_REQUIRED });\n } else {\n /**\n * For \"dedicated\" card components, i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands,\n * there will be no to-and-fro with the securedField iframe to reset brand.\n * The presence of a resetObj indicates we are in this \"dedicated\"\" scenario, so we need to use the information contained within this object\n * to internally reset the brand\n */\n if (resetObj) {\n this.processBrand({ ...resetObj, fieldType: ENCRYPTED_CARD_NUMBER } as SFFeedbackObj);\n }\n }\n\n // Reset expiryDatePolicy - which never comes from SF // TODO find out under which circumstances this clause is still required\n if (this.state.type === 'card' && hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_DATE)) {\n this.state.securedFields[ENCRYPTED_EXPIRY_DATE].expiryDatePolicy = DATE_POLICY_REQUIRED;\n }\n\n return;\n }\n\n const binBrandObj: BrandObject = binLookupResponse.supportedBrands[0];\n\n const passedBrand: string = binBrandObj.brand;\n\n // Look first for expiryDatePolicy string otherwise use showExpiryDate boolean\n const expiryDatePolicy = binBrandObj.expiryDatePolicy ?? (binBrandObj.showExpiryDate === true ? DATE_POLICY_REQUIRED : DATE_POLICY_HIDDEN);\n\n const brandObj: object = {\n brand: passedBrand,\n cvcPolicy: binBrandObj.cvcPolicy,\n expiryDatePolicy,\n cvcText: 'Security code',\n showSocialSecurityNumber: binBrandObj.showSocialSecurityNumber ?? false,\n fieldType: ENCRYPTED_CARD_NUMBER,\n mode: BIN_LOOKUP_MODE\n };\n\n // Take advantage of function used to handle brand messages from SF in order to process this new brand information\n this.processBrand(brandObj as SFFeedbackObj);\n\n if (isGenericCard) {\n // Pass brand to CardNumber SF\n const cardObj: SendBrandObject = {\n brand: passedBrand,\n enableLuhnCheck: binLookupResponse.supportedBrands[0].enableLuhnCheck !== false,\n // Only pass the panLength if a) we have one & b) we're not in a switching-between-dual-brands scenario\n // (because it causes unnecessary callbacks from SF which uses panLength to trigger moving focus to the expiryDate field)\n ...(binBrandObj?.panLength && !binLookupResponse.isDualBrandSelection && { panLength: binBrandObj?.panLength })\n };\n this.sendBrandToCardSF(cardObj);\n\n // Inform the date related securedFields\n // - if expiryDatePolicy is 'optional' or 'hidden' they need to set the aria-required attribute / hide themselves\n this.sendExpiryDatePolicyToSF({ expiryDatePolicy });\n }\n\n /**\n * CHECK IF BRAND CHANGE MEANS FORM IS NOW VALID e.g maestro/bcmc (which don't require cvc) OR bcmc/visa (one of which doesn't require cvc, one of which does)\n */\n\n /**\n * First set the cvcPolicy value on the relevant SecuredFields instance (which will reflect in the cvc field being considered valid,\n * as long as it is not in error)...\n */\n if (hasOwnProperty(this.state.securedFields, ENCRYPTED_SECURITY_CODE)) {\n this.state.securedFields[ENCRYPTED_SECURITY_CODE].cvcPolicy = binBrandObj.cvcPolicy;\n }\n\n /**\n * ...then set the expiryDatePolicy...\n */\n if (hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_DATE)) {\n this.state.securedFields[ENCRYPTED_EXPIRY_DATE].expiryDatePolicy = expiryDatePolicy;\n } else if (hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_MONTH) && hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_YEAR)) {\n this.state.securedFields[ENCRYPTED_EXPIRY_MONTH].expiryDatePolicy = expiryDatePolicy;\n this.state.securedFields[ENCRYPTED_EXPIRY_YEAR].expiryDatePolicy = expiryDatePolicy;\n }\n\n /**\n * ...and now re-check if form i.e all the SecuredFields, are valid\n */\n this.validateForm();\n}\n"],"names":["sendBrandToCardSF","brandObj","hasOwnProperty","this","state","securedFields","ENCRYPTED_CARD_NUMBER","dataObj","_object_spread_props","_object_spread","txVariant","type","fieldType","numKey","postMessageToIframe","getIframeContentWin","config","loadingContext","sendExpiryDatePolicyToSF","expiryDateObj","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","ENCRYPTED_EXPIRY_DATE","forEach","key","handleBrandFromBinLookup","binLookupResponse","resetObj","binBrandObj","isGenericCard","Object","keys","length","brand","expiryDatePolicy","DATE_POLICY_REQUIRED","processBrand","supportedBrands","passedBrand","showExpiryDate","DATE_POLICY_HIDDEN","cvcPolicy","cvcText","showSocialSecurityNumber","mode","BIN_LOOKUP_MODE","cardObj","enableLuhnCheck","panLength","isDualBrandSelection","ENCRYPTED_SECURITY_CODE","validateForm"],"mappings":"mtCAiBO,SAASA,EAAkBC,GAC9B,GAAIC,EAAeC,KAAKC,MAAMC,cAAeC,GAAwB,CACjE,MAAMC,EAAkBC,EAAAC,EAAA,CACpBC,UAAWP,KAAKC,MAAMO,MACnBV,GAAAA,CACHW,UAAWN,EACXO,OAAQV,KAAKC,MAAMC,cAAcC,GAAuBO,SAE5DC,EAAoBP,EAASQ,EAAoBZ,KAAKC,MAAOE,GAAwBH,KAAKa,OAAOC,eACrG,CACJ,CAEO,SAASC,EAAyBC,IAEjCjB,EAAeC,KAAKC,MAAMC,cAAee,IAA2BlB,EAAeC,KAAKC,MAAMC,cAAegB,GAErE,CAACD,EAAwBC,GAAyB,CAACC,IAEhFC,QAASC,IACpB,MAAMjB,EAAkBC,EAAAC,EAAA,CACpBC,UAAWP,KAAKC,MAAMO,MACnBQ,GAAAA,CACHP,UAAWY,EACXX,OAAQV,KAAKC,MAAMC,cAAcmB,GAAKX,SAE1CC,EAAoBP,EAASQ,EAAoBZ,KAAKC,MAAOoB,GAAMrB,KAAKa,OAAOC,iBAEvF,CAEe,SAASQ,EAAyBC,EAAsCC,OAuC1DC,EAOKA,EA7C9B,MAAMC,EAA6C,SAApB1B,KAAKC,MAAMO,KAM1C,IAAKe,IAAsBI,OAAOC,KAAKL,GAAmBM,OAwBtD,OAvBIH,GAGA1B,KAAKH,kBAAkB,CAAEiC,MAAO,UAEhC9B,KAAKe,yBAAyB,CAAEgB,iBAAkBC,KAQ9CR,GACAxB,KAAKiC,aAAa5B,E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ODE as r}from"../../constants.js";import t from"../utils/iframes/postMessageToIframe.js";import{objectsDeepEqual as e}from"../../utilities/commonUtils.js";import{pick as i}from"../../../../../../utils/commonUtils.js";import{hasOwnProperty as c}from"../../../../../../utils/hasOwnProperty.js";import s from"../utils/iframes/getIframeContentWin.js";function n({csfState:n,csfConfig:a,csfProps:l,csfCallbacks:m},f){if(f.fieldType===o){const o={brand:f.brand,cvcPolicy:f.cvcPolicy,expiryDatePolicy:f.expiryDatePolicy,showSocialSecurityNumber:f.showSocialSecurityNumber},d=(y=o,u=n.brand,!e(y,u));if(!d)return null;const p="card"===n.type||"bcmc"===n.type;if(p&&d&&(n.brand=o,c(n.securedFields,r))){const e={txVariant:n.type,brand:o.brand,fieldType:r,cvcPolicy:f.cvcPolicy,numKey:n.securedFields[r].numKey};t(e,s(n,r),a.loadingContext)}const b=p?i(["brand","cvcPolicy","cvcText","expiryDatePolicy","showSocialSecurityNumber"]).from(f):null;if(b&&b.brand){const o=b;o.type=n.type,o.rootNode=l.rootNode,m.onBrand(o)}return!0}var y,u;return!1}export{n as default};
1
+ import{ENCRYPTED_CARD_NUMBER as o,ENCRYPTED_SECURITY_CODE as r}from"../../constants.js";import t from"../utils/iframes/postMessageToIframe.js";import{objectsDeepEqual as e}from"../../utilities/commonUtils.js";import{pick as i}from"../../../../../../utils/commonUtils.js";import{hasOwnProperty as c}from"../../../../../../utils/hasOwnProperty.js";import s from"../utils/iframes/getIframeContentWin.js";function n({csfState:n,csfConfig:a,csfProps:l,csfCallbacks:m},f){if(f.fieldType===o){const o={brand:f.brand,cvcPolicy:f.cvcPolicy,expiryDatePolicy:f.expiryDatePolicy,showSocialSecurityNumber:f.showSocialSecurityNumber},d=(y=o,u=n.brand,!e(y,u));if(!d)return null;const p="card"===n.type||"bcmc"===n.type;if(p&&d&&(n.brand=o,c(n.securedFields,r))){const e={txVariant:n.type,brand:o.brand,fieldType:r,cvcPolicy:f.cvcPolicy,numKey:n.securedFields[r].numKey};t(e,s(n,r),a.loadingContext)}const b=p?i(["brand","cvcPolicy","cvcText","expiryDatePolicy","showSocialSecurityNumber","mode"]).from(f):null;if(b&&b.brand){const o=b;o.type=n.type,o.rootNode=l.rootNode,m.onBrand(o)}return!0}var y,u;return!1}export{n as default};
2
2
  //# sourceMappingURL=processBrand.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"processBrand.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/partials/processBrand.ts"],"sourcesContent":["import { ENCRYPTED_CARD_NUMBER, ENCRYPTED_SECURITY_CODE } from '../../constants';\nimport postMessageToIframe from '../utils/iframes/postMessageToIframe';\nimport { objectsDeepEqual } from '../../utilities/commonUtils';\nimport { BrandStorageObject, CardBrandData, SFFeedbackObj, SFFieldType } from '../../types';\nimport { pick } from '../../../../../../utils/commonUtils';\nimport { hasOwnProperty } from '../../../../../../utils/hasOwnProperty';\nimport getIframeContentWin from '../utils/iframes/getIframeContentWin';\nimport { CSFThisObject } from '../types';\n\nconst checkForBrandChange = (pBrand: BrandStorageObject, storedBrand: BrandStorageObject): boolean => {\n // if the objects aren't the same - then return true = brandChange has happened\n return !objectsDeepEqual(pBrand, storedBrand);\n};\n\n/**\n * - If generic card type AND passed brand doesn't equal stored brand - send the new brand to the cvc input\n * (so it can reassess what length it should be and if any value it contains is now valid)\n *\n * - Create object for onBrand callback aka SFPHandlers.handleOnBrand\n *\n * @param csfState - comes from initial, partial, implementation\n * @param csfConfig - comes from initial, partial, implementation\n * @param csfProps - comes from initial, partial, implementation\n * @param csfCallbacks - comes from initial, partial, implementation\n *\n * @param pFeedbackObj -\n */\nexport default function processBrand({ csfState, csfConfig, csfProps, csfCallbacks }: CSFThisObject, pFeedbackObj: SFFeedbackObj): boolean {\n const fieldType: SFFieldType = pFeedbackObj.fieldType;\n\n if (fieldType === ENCRYPTED_CARD_NUMBER) {\n // Check for new brand...\n const newBrandObj: BrandStorageObject = {\n brand: pFeedbackObj.brand,\n cvcPolicy: pFeedbackObj.cvcPolicy,\n expiryDatePolicy: pFeedbackObj.expiryDatePolicy,\n showSocialSecurityNumber: pFeedbackObj.showSocialSecurityNumber\n };\n const newBrand: boolean = checkForBrandChange(newBrandObj, csfState.brand);\n\n if (!newBrand) {\n return null;\n }\n\n // Now BCMC can dual brand with Visa it must also be treated as a generic card so we can show/hide the CVC field\n const treatAsGenericCard: boolean = csfState.type === 'card' || csfState.type === 'bcmc';\n\n // ...if also a generic card - tell cvc field...\n if (treatAsGenericCard && newBrand) {\n // Store on state so for subsequent brand messages we can compare the new and the old\n csfState.brand = newBrandObj;\n\n // Perform postMessage to send brand to CVC field - this also needs to happen for BCMC, single branded cards,\n // because it needs to know the cvcPolicy (to set the aria-required attribute & to show the iframe)\n if (hasOwnProperty(csfState.securedFields, ENCRYPTED_SECURITY_CODE)) {\n const dataObj: object = {\n txVariant: csfState.type,\n brand: newBrandObj.brand,\n fieldType: ENCRYPTED_SECURITY_CODE,\n cvcPolicy: pFeedbackObj.cvcPolicy,\n numKey: csfState.securedFields[ENCRYPTED_SECURITY_CODE].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(csfState, ENCRYPTED_SECURITY_CODE), csfConfig.loadingContext);\n }\n }\n\n // Create object with brand related properties\n const brandInfoObj = treatAsGenericCard\n ? pick(['brand', 'cvcPolicy', 'cvcText', 'expiryDatePolicy', 'showSocialSecurityNumber']).from(pFeedbackObj)\n : null;\n\n if (brandInfoObj && brandInfoObj.brand) {\n const callbackObj: CardBrandData = brandInfoObj as CardBrandData;\n callbackObj.type = csfState.type;\n callbackObj.rootNode = csfProps.rootNode as HTMLElement;\n\n // ...and call SFPHandlers.handleOnBrand\n csfCallbacks.onBrand(callbackObj);\n }\n\n return true;\n }\n\n return false;\n}\n"],"names":["processBrand","csfState","csfConfig","csfProps","csfCallbacks","pFeedbackObj","fieldType","ENCRYPTED_CARD_NUMBER","newBrandObj","brand","cvcPolicy","expiryDatePolicy","showSocialSecurityNumber","newBrand","pBrand","storedBrand","objectsDeepEqual","treatAsGenericCard","type","hasOwnProperty","securedFields","ENCRYPTED_SECURITY_CODE","dataObj","txVariant","numKey","postMessageToIframe","getIframeContentWin","loadingContext","brandInfoObj","pick","from","callbackObj","rootNode","onBrand"],"mappings":"iZA2Be,SAASA,GAAaC,SAAEA,EAAQC,UAAEA,EAASC,SAAEA,EAAQC,aAAEA,GAA+BC,GAGjG,GAF+BA,EAAaC,YAE1BC,EAAuB,CAErC,MAAMC,EAAkC,CACpCC,MAAOJ,EAAaI,MACpBC,UAAWL,EAAaK,UACxBC,iBAAkBN,EAAaM,iBAC/BC,yBAA0BP,EAAaO,0BAErCC,GA7BeC,EA6ByBN,EA7BGO,EA6BUd,EAASQ,OA3BhEO,EAAiBF,EAAQC,IA6B7B,IAAKF,EACD,OAAO,KAIX,MAAMI,EAAgD,SAAlBhB,EAASiB,MAAqC,SAAlBjB,EAASiB,KAGzE,GAAID,GAAsBJ,IAEtBZ,EAASQ,MAAQD,EAIbW,EAAelB,EAASmB,cAAeC,IAA0B,CACjE,MAAMC,EAAkB,CACpBC,UAAWtB,EAASiB,KACpBT,MAAOD,EAAYC,MACnBH,UAAWe,EACXX,UAAWL,EAAaK,UACxBc,OAAQvB,EAASmB,cAAcC,GAAyBG,QAE5DC,EAAoBH,EAASI,EAAoBzB,EAAUoB,GAA0BnB,EAAUyB,eACnG,CAIJ,MAAMC,EAAeX,EACfY,EAAK,CAAC,QAAS,YAAa,UAAW,mBAAoB,6BAA6BC,KAAKzB,GAC7F,KAEN,GAAIuB,GAAgBA,EAAanB,MAAO,CACpC,MAAMsB,EAA6BH,EACnCG,EAAYb,KAAOjB,EAASiB,KAC5Ba,EAAYC,SAAW7B,EAAS6B,SAGhC5B,EAAa6B,QAAQF,EACzB,CAEA,OAAO,CACX,CAxEwB,IAACjB,EAA4BC,EA0ErD,OAAO,CACX"}
1
+ {"version":3,"file":"processBrand.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/partials/processBrand.ts"],"sourcesContent":["import { ENCRYPTED_CARD_NUMBER, ENCRYPTED_SECURITY_CODE } from '../../constants';\nimport postMessageToIframe from '../utils/iframes/postMessageToIframe';\nimport { objectsDeepEqual } from '../../utilities/commonUtils';\nimport { BrandStorageObject, CardBrandData, SFFeedbackObj, SFFieldType } from '../../types';\nimport { pick } from '../../../../../../utils/commonUtils';\nimport { hasOwnProperty } from '../../../../../../utils/hasOwnProperty';\nimport getIframeContentWin from '../utils/iframes/getIframeContentWin';\nimport { CSFThisObject } from '../types';\n\nconst checkForBrandChange = (pBrand: BrandStorageObject, storedBrand: BrandStorageObject): boolean => {\n // if the objects aren't the same - then return true = brandChange has happened\n return !objectsDeepEqual(pBrand, storedBrand);\n};\n\n/**\n * - If generic card type AND passed brand doesn't equal stored brand - send the new brand to the cvc input\n * (so it can reassess what length it should be and if any value it contains is now valid)\n *\n * - Create object for onBrand callback aka SFPHandlers.handleOnBrand\n *\n * @param csfState - comes from initial, partial, implementation\n * @param csfConfig - comes from initial, partial, implementation\n * @param csfProps - comes from initial, partial, implementation\n * @param csfCallbacks - comes from initial, partial, implementation\n *\n * @param pFeedbackObj -\n */\nexport default function processBrand({ csfState, csfConfig, csfProps, csfCallbacks }: CSFThisObject, pFeedbackObj: SFFeedbackObj): boolean {\n const fieldType: SFFieldType = pFeedbackObj.fieldType;\n\n if (fieldType === ENCRYPTED_CARD_NUMBER) {\n // Check for new brand...\n const newBrandObj: BrandStorageObject = {\n brand: pFeedbackObj.brand,\n cvcPolicy: pFeedbackObj.cvcPolicy,\n expiryDatePolicy: pFeedbackObj.expiryDatePolicy,\n showSocialSecurityNumber: pFeedbackObj.showSocialSecurityNumber\n };\n const newBrand: boolean = checkForBrandChange(newBrandObj, csfState.brand);\n\n if (!newBrand) {\n return null;\n }\n\n // Now BCMC can dual brand with Visa it must also be treated as a generic card so we can show/hide the CVC field\n const treatAsGenericCard: boolean = csfState.type === 'card' || csfState.type === 'bcmc';\n\n // ...if also a generic card - tell cvc field...\n if (treatAsGenericCard && newBrand) {\n // Store on state so for subsequent brand messages we can compare the new and the old\n csfState.brand = newBrandObj;\n\n // Perform postMessage to send brand to CVC field - this also needs to happen for BCMC, single branded cards,\n // because it needs to know the cvcPolicy (to set the aria-required attribute & to show the iframe)\n if (hasOwnProperty(csfState.securedFields, ENCRYPTED_SECURITY_CODE)) {\n const dataObj: object = {\n txVariant: csfState.type,\n brand: newBrandObj.brand,\n fieldType: ENCRYPTED_SECURITY_CODE,\n cvcPolicy: pFeedbackObj.cvcPolicy,\n numKey: csfState.securedFields[ENCRYPTED_SECURITY_CODE].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(csfState, ENCRYPTED_SECURITY_CODE), csfConfig.loadingContext);\n }\n }\n\n // Create object with brand related properties\n const brandInfoObj = treatAsGenericCard\n ? pick(['brand', 'cvcPolicy', 'cvcText', 'expiryDatePolicy', 'showSocialSecurityNumber', 'mode']).from(pFeedbackObj)\n : null;\n\n if (brandInfoObj && brandInfoObj.brand) {\n const callbackObj: CardBrandData = brandInfoObj as CardBrandData;\n callbackObj.type = csfState.type;\n callbackObj.rootNode = csfProps.rootNode as HTMLElement;\n\n // ...and call SFPHandlers.handleOnBrand\n csfCallbacks.onBrand(callbackObj);\n }\n\n return true;\n }\n\n return false;\n}\n"],"names":["processBrand","csfState","csfConfig","csfProps","csfCallbacks","pFeedbackObj","fieldType","ENCRYPTED_CARD_NUMBER","newBrandObj","brand","cvcPolicy","expiryDatePolicy","showSocialSecurityNumber","newBrand","pBrand","storedBrand","objectsDeepEqual","treatAsGenericCard","type","hasOwnProperty","securedFields","ENCRYPTED_SECURITY_CODE","dataObj","txVariant","numKey","postMessageToIframe","getIframeContentWin","loadingContext","brandInfoObj","pick","from","callbackObj","rootNode","onBrand"],"mappings":"iZA2Be,SAASA,GAAaC,SAAEA,EAAQC,UAAEA,EAASC,SAAEA,EAAQC,aAAEA,GAA+BC,GAGjG,GAF+BA,EAAaC,YAE1BC,EAAuB,CAErC,MAAMC,EAAkC,CACpCC,MAAOJ,EAAaI,MACpBC,UAAWL,EAAaK,UACxBC,iBAAkBN,EAAaM,iBAC/BC,yBAA0BP,EAAaO,0BAErCC,GA7BeC,EA6ByBN,EA7BGO,EA6BUd,EAASQ,OA3BhEO,EAAiBF,EAAQC,IA6B7B,IAAKF,EACD,OAAO,KAIX,MAAMI,EAAgD,SAAlBhB,EAASiB,MAAqC,SAAlBjB,EAASiB,KAGzE,GAAID,GAAsBJ,IAEtBZ,EAASQ,MAAQD,EAIbW,EAAelB,EAASmB,cAAeC,IAA0B,CACjE,MAAMC,EAAkB,CACpBC,UAAWtB,EAASiB,KACpBT,MAAOD,EAAYC,MACnBH,UAAWe,EACXX,UAAWL,EAAaK,UACxBc,OAAQvB,EAASmB,cAAcC,GAAyBG,QAE5DC,EAAoBH,EAASI,EAAoBzB,EAAUoB,GAA0BnB,EAAUyB,eACnG,CAIJ,MAAMC,EAAeX,EACfY,EAAK,CAAC,QAAS,YAAa,UAAW,mBAAoB,2BAA4B,SAASC,KAAKzB,GACrG,KAEN,GAAIuB,GAAgBA,EAAanB,MAAO,CACpC,MAAMsB,EAA6BH,EACnCG,EAAYb,KAAOjB,EAASiB,KAC5Ba,EAAYC,SAAW7B,EAAS6B,SAGhC5B,EAAa6B,QAAQF,EACzB,CAEA,OAAO,CACX,CAxEwB,IAACjB,EAA4BC,EA0ErD,OAAO,CACX"}
@@ -1,2 +1,2 @@
1
- import{hasOwnProperty as t}from"../../../../../../utils/hasOwnProperty.js";let e;const r={__NO_BRAND:"noBrand",cards:[]};r.cards.push({cardType:"mc",startingRules:[51,52,53,54,55,22,23,24,25,26,27],permittedLengths:[16],pattern:/^(5[1-5][0-9]{0,14}|2[2-7][0-9]{0,14})$/,securityCode:"CVC"}),r.cards.push({cardType:"visadankort",startingRules:[4571],permittedLengths:[16],pattern:/^(4571)[0-9]{0,12}$/}),r.cards.push({cardType:"visa",startingRules:[4],permittedLengths:[13,16,19],pattern:/^4[0-9]{0,18}$/,securityCode:"CVV"}),r.cards.push({cardType:"amex",startingRules:[34,37],permittedLengths:[15],pattern:/^3[47][0-9]{0,13}$/,securityCode:"CID"}),r.cards.push({cardType:"diners",startingRules:[36],permittedLengths:[14,15,16,17,18,19],pattern:/^(36)[0-9]{0,12}$/}),r.cards.push({cardType:"maestrouk",startingRules:[6759],permittedLengths:[16,18,19],pattern:/^(6759)[0-9]{0,15}$/}),r.cards.push({cardType:"solo",startingRules:[6767],permittedLengths:[16,18,19],pattern:/^(6767)[0-9]{0,15}$/}),r.cards.push({cardType:"laser",startingRules:[6304,6706,677117,677120],permittedLengths:[16,17,18,19],pattern:/^(6304|6706|6709|6771)[0-9]{0,15}$/,cvcPolicy:"optional"}),r.cards.push({cardType:"discover",startingRules:[6011,644,645,646,647,648,649,65],permittedLengths:[16,17,18,19],pattern:/^(6011[0-9]{0,12}|(644|645|646|647|648|649)[0-9]{0,13}|65[0-9]{0,14})$/}),r.cards.push({cardType:"jcb",startingRules:[3528,3529,353,354,355,356,357,358],permittedLengths:[16,19],pattern:/^(352[8,9]{1}[0-9]{0,15}|35[4-8]{1}[0-9]{0,16})$/,securityCode:"CAV"}),r.cards.push({cardType:"bcmc",startingRules:[6703,479658,606005],permittedLengths:[16,17,18,19],pattern:/^((6703)[0-9]{0,15}|(479658|606005)[0-9]{0,13})$/,cvcPolicy:"hidden"}),r.cards.push({cardType:"bijcard",startingRules:[5100081],permittedLengths:[16],pattern:/^(5100081)[0-9]{0,9}$/}),r.cards.push({cardType:"dankort",startingRules:[5019],permittedLengths:[16],pattern:/^(5019)[0-9]{0,12}$/}),r.cards.push({cardType:"hipercard",startingRules:[606282],permittedLengths:[16],pattern:/^(606282)[0-9]{0,10}$/}),r.cards.push({cardType:"cup",startingRules:[62,81],permittedLengths:[14,15,16,17,18,19],pattern:/^(62|81)[0-9]{0,17}$/}),r.cards.push({cardType:"maestro",startingRules:[50,56,57,58,6],permittedLengths:[16,17,18,19],pattern:/^(5[0|6-8][0-9]{0,17}|6[0-9]{0,18})$/,cvcPolicy:"optional"}),r.cards.push({cardType:"elo",startingRules:[506699,50670,50671,50672,50673,50674,50675,50676,506770,506771,506772,506773,506774,506775,506776,506777,506778,401178,438935,451416,457631,457632,504175,627780,636297,636368],permittedLengths:[16],pattern:/^((((506699)|(506770)|(506771)|(506772)|(506773)|(506774)|(506775)|(506776)|(506777)|(506778)|(401178)|(438935)|(451416)|(457631)|(457632)|(504175)|(627780)|(636368)|(636297))[0-9]{0,10})|((50676)|(50675)|(50674)|(50673)|(50672)|(50671)|(50670))[0-9]{0,11})$/}),r.cards.push({cardType:"uatp",startingRules:[1],permittedLengths:[15],pattern:/^1[0-9]{0,14}$/,cvcPolicy:"optional"}),r.cards.push({cardType:"cartebancaire",startingRules:[4,5,6],permittedLengths:[16],pattern:/^[4-6][0-9]{0,15}$/}),r.cards.push({cardType:"visaalphabankbonus",startingRules:[450903],permittedLengths:[16],pattern:/^(450903)[0-9]{0,10}$/}),r.cards.push({cardType:"mcalphabankbonus",startingRules:[510099],permittedLengths:[16],pattern:/^(510099)[0-9]{0,10}$/}),r.cards.push({cardType:"hiper",startingRules:[637095,637568,637599,637609,637612],permittedLengths:[16],pattern:/^(637095|637568|637599|637609|637612)[0-9]{0,10}$/}),r.cards.push({cardType:"oasis",startingRules:[982616],permittedLengths:[16],pattern:/^(982616)[0-9]{0,10}$/,cvcPolicy:"optional"}),r.cards.push({cardType:"karenmillen",startingRules:[98261465],permittedLengths:[16],pattern:/^(98261465)[0-9]{0,8}$/,cvcPolicy:"optional"}),r.cards.push({cardType:"warehouse",startingRules:[982633],permittedLengths:[16],pattern:/^(982633)[0-9]{0,10}$/,cvcPolicy:"optional"}),r.cards.push({cardType:"mir",startingRules:[220],permittedLengths:[16,17,18,19],pattern:/^(220)[0-9]{0,16}$/}),r.cards.push({cardType:"codensa",startingRules:[590712],permittedLengths:[16],pattern:/^(590712)[0-9]{0,10}$/}),r.cards.push({cardType:"naranja",startingRules:[377798,377799,402917,402918,527571,527572,589562],permittedLengths:[16,17,18,19],pattern:/^(37|40|5[28])([279])\d*$/}),r.cards.push({cardType:"cabal",startingRules:[589657,600691,603522,6042,6043,636908],permittedLengths:[16,17,18,19],pattern:/^(58|6[03])([03469])\d*$/}),r.cards.push({cardType:"shopping",startingRules:[2799,589407,603488],permittedLengths:[16,17,18,19],pattern:/^(27|58|60)([39])\d*$/}),r.cards.push({cardType:"argencard",startingRules:[501],permittedLengths:[16,17,18,19],pattern:/^(50)(1)\d*$/}),r.cards.push({cardType:"troy",startingRules:[9792],permittedLengths:[16],pattern:/^(97)(9)\d*$/}),r.cards.push({cardType:"forbrugsforeningen",startingRules:[600722],permittedLengths:[16],pattern:/^(60)(0)\d*$/}),r.cards.push({cardType:"vpay",startingRules:[401,408,413,434,435,437,439,441,442,443,444,446,447,455,458,460,461,463,466,471,479,482,483,487],permittedLengths:[13,14,15,16,17,18,19],pattern:/^(40[1,8]|413|43[4,5]|44[1,2,3,4,6,7]|45[5,8]|46[0,1,3,6]|47[1,9]|48[2,3,7])[0-9]{0,16}$/}),r.cards.push({cardType:"rupay",startingRules:[508528],permittedLengths:[16],pattern:/^(100003|508(2|[5-9])|60(69|[7-8])|652(1[5-9]|[2-5][0-9]|8[5-9])|65300[3-4]|8172([0-1]|[3-5]|7|9)|817(3[3-8]|40[6-9]|410)|35380([0-2]|[5-6]|9))[0-9]{0,12}$/}),r.cards.push({cardType:"ticket",expiryDatePolicy:"hidden"});var s={detectCard:(e,s)=>{let a,n,p;if(s){if(a=r.cards.filter(t=>s.includes(t.cardType)).filter(r=>t(r,"pattern")&&e.match(r.pattern)),a.length){if(1===a.length)return a[0];for(n=0,p=a.length;n<p;n+=1)if(!a[n].longestRule){const t=a[n].startingRules.reduce((t,e)=>t>e?t:e);a[n].longestRule=String(t).length}return a.reduce((t,e)=>t.longestRule>=e.longestRule?t:e)}return{cardType:r.__NO_BRAND}}return{cardType:r.__NO_BRAND}},detectCardLength:(t,e)=>{let s,a,n=0,p=!1,d=e;const c=t.cardType!==r.__NO_BRAND?t.permittedLengths[t.permittedLengths.length-1]:0;if(c&&d>c&&(n=d.length-c,n>0&&(d=d.substring(0,d.length-n),a=d)),t.permittedLengths.forEach(t=>{d.length===t&&(p=!0)}),d.length===c){const e=Math.floor(d.length/4);s=c+(d.length%4>0?e:e-1),"amex"===t.cardType.toLowerCase()&&(s=c+2)}return{shortenedNewValue:a,maxLength:s,reachedValidLength:p}},getShortestPermittedCardLength:()=>{if(!e){let t=[];r.cards.forEach(e=>{var r;t=t.concat(null!==(r=e.permittedLengths)&&void 0!==r?r:[])}),e=Math.min.apply(null,t)}return e},getCardByBrand:t=>r.cards.filter(e=>e.cardType===t)[0],isGenericCardType:t=>{if(!t)throw new Error("Error: isGenericCardType: type param has not been specified");return"card"===t||"scheme"===t},__NO_BRAND:r.__NO_BRAND,allCards:r.cards};export{s as default};
1
+ import{hasOwnProperty as e}from"../../../../../../utils/hasOwnProperty.js";let t;const r={__NO_BRAND:"noBrand",cards:[]};r.cards.push({cardType:"mc",permittedLengths:[16],pattern:/^(5[1-5][0-9]{0,14}|2[2-7][0-9]{0,14})$/,securityCode:"CVC"}),r.cards.push({cardType:"visadankort",permittedLengths:[16],pattern:/^(4571)[0-9]{0,12}$/}),r.cards.push({cardType:"visa",permittedLengths:[13,16,19],pattern:/^4[0-9]{0,18}$/,securityCode:"CVV"}),r.cards.push({cardType:"amex",permittedLengths:[15],pattern:/^3[47][0-9]{0,13}$/,securityCode:"CID"}),r.cards.push({cardType:"diners",permittedLengths:[14,15,16,17,18,19],pattern:/^(36)[0-9]{0,12}$/}),r.cards.push({cardType:"maestrouk",permittedLengths:[16,18,19],pattern:/^(6759)[0-9]{0,15}$/}),r.cards.push({cardType:"solo",permittedLengths:[16,18,19],pattern:/^(6767)[0-9]{0,15}$/}),r.cards.push({cardType:"laser",permittedLengths:[16,17,18,19],pattern:/^(6304|6706|6709|6771)[0-9]{0,15}$/,cvcPolicy:"optional"}),r.cards.push({cardType:"discover",permittedLengths:[16,17,18,19],pattern:/^(6011[0-9]{0,12}|(644|645|646|647|648|649)[0-9]{0,13}|65[0-9]{0,14})$/}),r.cards.push({cardType:"jcb",permittedLengths:[16,19],pattern:/^(352[8,9]{1}[0-9]{0,15}|35[4-8]{1}[0-9]{0,16})$/,securityCode:"CAV"}),r.cards.push({cardType:"bcmc",permittedLengths:[16,17,18,19],pattern:/^((6703)[0-9]{0,15}|(479658|606005)[0-9]{0,13})$/,cvcPolicy:"hidden"}),r.cards.push({cardType:"bijcard",permittedLengths:[16],pattern:/^(5100081)[0-9]{0,9}$/}),r.cards.push({cardType:"dankort",permittedLengths:[16],pattern:/^(5|50|501|5019[0-9]{0,12}|4|45|457|4571[0-9]{0,12}|3|35|357|3571[0-9]{0,12})$/}),r.cards.push({cardType:"hipercard",permittedLengths:[16],pattern:/^(606282)[0-9]{0,10}$/}),r.cards.push({cardType:"cup",permittedLengths:[14,15,16,17,18,19],pattern:/^(62|81)[0-9]{0,17}$/}),r.cards.push({cardType:"maestro",permittedLengths:[16,17,18,19],pattern:/^(5[0|6-8][0-9]{0,17}|6[0-9]{0,18})$/,cvcPolicy:"optional"}),r.cards.push({cardType:"elo",permittedLengths:[16],pattern:/^((((506699)|(506770)|(506771)|(506772)|(506773)|(506774)|(506775)|(506776)|(506777)|(506778)|(401178)|(438935)|(451416)|(457631)|(457632)|(504175)|(627780)|(636368)|(636297))[0-9]{0,10})|((50676)|(50675)|(50674)|(50673)|(50672)|(50671)|(50670))[0-9]{0,11})$/}),r.cards.push({cardType:"uatp",permittedLengths:[15],pattern:/^1[0-9]{0,14}$/,cvcPolicy:"optional"}),r.cards.push({cardType:"cartebancaire",permittedLengths:[16],pattern:/^[4-6][0-9]{0,15}$/}),r.cards.push({cardType:"visaalphabankbonus",permittedLengths:[16],pattern:/^(450903)[0-9]{0,10}$/}),r.cards.push({cardType:"mcalphabankbonus",permittedLengths:[16],pattern:/^(510099)[0-9]{0,10}$/}),r.cards.push({cardType:"hiper",permittedLengths:[16],pattern:/^(637095|637568|637599|637609|637612)[0-9]{0,10}$/}),r.cards.push({cardType:"oasis",permittedLengths:[16],pattern:/^(982616)[0-9]{0,10}$/,cvcPolicy:"optional"}),r.cards.push({cardType:"karenmillen",permittedLengths:[16],pattern:/^(98261465)[0-9]{0,8}$/,cvcPolicy:"optional"}),r.cards.push({cardType:"warehouse",permittedLengths:[16],pattern:/^(982633)[0-9]{0,10}$/,cvcPolicy:"optional"}),r.cards.push({cardType:"mir",permittedLengths:[16,17,18,19],pattern:/^(220)[0-9]{0,16}$/}),r.cards.push({cardType:"codensa",permittedLengths:[16],pattern:/^(590712)[0-9]{0,10}$/}),r.cards.push({cardType:"naranja",permittedLengths:[16,17,18,19],pattern:/^(37|40|5[28])([279])\d*$/}),r.cards.push({cardType:"cabal",permittedLengths:[16,17,18,19],pattern:/^(58|6[03])([03469])\d*$/}),r.cards.push({cardType:"shopping",permittedLengths:[16,17,18,19],pattern:/^(27|58|60)([39])\d*$/}),r.cards.push({cardType:"argencard",permittedLengths:[16,17,18,19],pattern:/^(50)(1)\d*$/}),r.cards.push({cardType:"troy",permittedLengths:[16],pattern:/^(97)(9)\d*$/}),r.cards.push({cardType:"forbrugsforeningen",permittedLengths:[16],pattern:/^(60)(0)\d*$/}),r.cards.push({cardType:"vpay",permittedLengths:[13,14,15,16,17,18,19],pattern:/^(40[1,8]|413|43[4,5]|44[1,2,3,4,6,7]|45[5,8]|46[0,1,3,6]|47[1,9]|48[2,3,7])[0-9]{0,16}$/}),r.cards.push({cardType:"rupay",permittedLengths:[16],pattern:/^(100003|508(2|[5-9])|60(69|[7-8])|652(1[5-9]|[2-5][0-9]|8[5-9])|65300[3-4]|8172([0-1]|[3-5]|7|9)|817(3[3-8]|40[6-9]|410)|35380([0-2]|[5-6]|9))[0-9]{0,12}$/}),r.cards.push({cardType:"ticket",expiryDatePolicy:"hidden"});var a={detectCard:(t,a)=>{let p;return a?(p=r.cards.filter(e=>a.includes(e.cardType)).filter(r=>e(r,"pattern")&&t.match(r.pattern)),p.length?(1===p.length||p.sort((e,t)=>a.indexOf(e.cardType)-a.indexOf(t.cardType)),p[0]):{cardType:r.__NO_BRAND}):{cardType:r.__NO_BRAND}},detectCardLength:(e,t)=>{let a,p,d=0,s=!1,c=t;const n=e.cardType!==r.__NO_BRAND?e.permittedLengths[e.permittedLengths.length-1]:0;if(n&&c>n&&(d=c.length-n,d>0&&(c=c.substring(0,c.length-d),p=c)),e.permittedLengths.forEach(e=>{c.length===e&&(s=!0)}),c.length===n){const t=Math.floor(c.length/4);a=n+(c.length%4>0?t:t-1),"amex"===e.cardType.toLowerCase()&&(a=n+2)}return{shortenedNewValue:p,maxLength:a,reachedValidLength:s}},getShortestPermittedCardLength:()=>{if(!t){let e=[];r.cards.forEach(t=>{var r;e=e.concat(null!==(r=t.permittedLengths)&&void 0!==r?r:[])}),t=Math.min.apply(null,e)}return t},getCardByBrand:e=>r.cards.filter(t=>t.cardType===e)[0],isGenericCardType:e=>{if(!e)throw new Error("Error: isGenericCardType: type param has not been specified");return"card"===e||"scheme"===e},__NO_BRAND:r.__NO_BRAND,allCards:r.cards};export{a as default};
2
2
  //# sourceMappingURL=cardType.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cardType.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/utils/cardType.ts"],"sourcesContent":["import { CardObject } from '../../types';\nimport { hasOwnProperty } from '../../../../../../utils/hasOwnProperty';\n\nlet shortestPermittedCardLength;\n\ninterface CardType {\n __NO_BRAND?: string;\n cards?: CardObject[];\n}\n\nconst CardType: CardType = {};\nCardType.__NO_BRAND = 'noBrand';\n\nCardType.cards = [];\n\nCardType.cards.push({\n cardType: 'mc',\n startingRules: [51, 52, 53, 54, 55, 22, 23, 24, 25, 26, 27],\n permittedLengths: [16],\n pattern: /^(5[1-5][0-9]{0,14}|2[2-7][0-9]{0,14})$/,\n securityCode: 'CVC'\n});\n\nCardType.cards.push({ cardType: 'visadankort', startingRules: [4571], permittedLengths: [16], pattern: /^(4571)[0-9]{0,12}$/ });\n\nCardType.cards.push({\n cardType: 'visa',\n startingRules: [4],\n permittedLengths: [13, 16, 19],\n pattern: /^4[0-9]{0,18}$/,\n securityCode: 'CVV'\n});\n\nCardType.cards.push({ cardType: 'amex', startingRules: [34, 37], permittedLengths: [15], pattern: /^3[47][0-9]{0,13}$/, securityCode: 'CID' });\n\nCardType.cards.push({ cardType: 'diners', startingRules: [36], permittedLengths: [14, 15, 16, 17, 18, 19], pattern: /^(36)[0-9]{0,12}$/ });\n\nCardType.cards.push({ cardType: 'maestrouk', startingRules: [6759], permittedLengths: [16, 18, 19], pattern: /^(6759)[0-9]{0,15}$/ });\n\nCardType.cards.push({ cardType: 'solo', startingRules: [6767], permittedLengths: [16, 18, 19], pattern: /^(6767)[0-9]{0,15}$/ });\n\nCardType.cards.push({\n cardType: 'laser',\n startingRules: [6304, 6706, 677117, 677120],\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(6304|6706|6709|6771)[0-9]{0,15}$/,\n cvcPolicy: 'optional'\n});\n\nCardType.cards.push({\n cardType: 'discover',\n startingRules: [6011, 644, 645, 646, 647, 648, 649, 65],\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(6011[0-9]{0,12}|(644|645|646|647|648|649)[0-9]{0,13}|65[0-9]{0,14})$/\n});\n\nCardType.cards.push({\n cardType: 'jcb',\n startingRules: [3528, 3529, 353, 354, 355, 356, 357, 358],\n permittedLengths: [16, 19],\n pattern: /^(352[8,9]{1}[0-9]{0,15}|35[4-8]{1}[0-9]{0,16})$/,\n securityCode: 'CAV'\n});\n\nCardType.cards.push({\n cardType: 'bcmc',\n startingRules: [6703, 479658, 606005],\n permittedLengths: [16, 17, 18, 19],\n pattern: /^((6703)[0-9]{0,15}|(479658|606005)[0-9]{0,13})$/,\n cvcPolicy: 'hidden'\n});\n\nCardType.cards.push({ cardType: 'bijcard', startingRules: [5100081], permittedLengths: [16], pattern: /^(5100081)[0-9]{0,9}$/ });\n\nCardType.cards.push({ cardType: 'dankort', startingRules: [5019], permittedLengths: [16], pattern: /^(5019)[0-9]{0,12}$/ });\n\nCardType.cards.push({ cardType: 'hipercard', startingRules: [606282], permittedLengths: [16], pattern: /^(606282)[0-9]{0,10}$/ });\n\n// Moved above maestro (from position below uatp) to stop maestro being recognised over cup\nCardType.cards.push({ cardType: 'cup', startingRules: [62, 81], permittedLengths: [14, 15, 16, 17, 18, 19], pattern: /^(62|81)[0-9]{0,17}$/ }); // orig & android v1 + modified to include our test cards (81...)\n\nCardType.cards.push({\n cardType: 'maestro',\n startingRules: [50, 56, 57, 58, 6],\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(5[0|6-8][0-9]{0,17}|6[0-9]{0,18})$/,\n cvcPolicy: 'optional'\n});\n\nCardType.cards.push({\n cardType: 'elo',\n // prettier-ignore\n startingRules: [506699, 50670, 50671, 50672, 50673, 50674, 50675, 50676, 506770, 506771, 506772, 506773, 506774, 506775, 506776, 506777, 506778, 401178, 438935, 451416, 457631, 457632, 504175, 627780, 636297, 636368],\n permittedLengths: [16],\n // prettier-ignore\n pattern:\n /^((((506699)|(506770)|(506771)|(506772)|(506773)|(506774)|(506775)|(506776)|(506777)|(506778)|(401178)|(438935)|(451416)|(457631)|(457632)|(504175)|(627780)|(636368)|(636297))[0-9]{0,10})|((50676)|(50675)|(50674)|(50673)|(50672)|(50671)|(50670))[0-9]{0,11})$/\n});\n\nCardType.cards.push({ cardType: 'uatp', startingRules: [1], permittedLengths: [15], pattern: /^1[0-9]{0,14}$/, cvcPolicy: 'optional' });\n\nCardType.cards.push({\n cardType: 'cartebancaire',\n startingRules: [4, 5, 6],\n permittedLengths: [16],\n pattern: /^[4-6][0-9]{0,15}$/\n});\n\nCardType.cards.push({ cardType: 'visaalphabankbonus', startingRules: [450903], permittedLengths: [16], pattern: /^(450903)[0-9]{0,10}$/ });\n\nCardType.cards.push({ cardType: 'mcalphabankbonus', startingRules: [510099], permittedLengths: [16], pattern: /^(510099)[0-9]{0,10}$/ });\n\nCardType.cards.push({\n cardType: 'hiper',\n startingRules: [637095, 637568, 637599, 637609, 637612],\n permittedLengths: [16],\n pattern: /^(637095|637568|637599|637609|637612)[0-9]{0,10}$/\n});\n\nCardType.cards.push({ cardType: 'oasis', startingRules: [982616], permittedLengths: [16], pattern: /^(982616)[0-9]{0,10}$/, cvcPolicy: 'optional' });\n\nCardType.cards.push({\n cardType: 'karenmillen',\n startingRules: [98261465],\n permittedLengths: [16],\n pattern: /^(98261465)[0-9]{0,8}$/,\n cvcPolicy: 'optional'\n});\n\nCardType.cards.push({\n cardType: 'warehouse',\n startingRules: [982633],\n permittedLengths: [16],\n pattern: /^(982633)[0-9]{0,10}$/,\n cvcPolicy: 'optional'\n});\n\nCardType.cards.push({ cardType: 'mir', startingRules: [220], permittedLengths: [16, 17, 18, 19], pattern: /^(220)[0-9]{0,16}$/ });\n\nCardType.cards.push({ cardType: 'codensa', startingRules: [590712], permittedLengths: [16], pattern: /^(590712)[0-9]{0,10}$/ });\n\nCardType.cards.push({\n cardType: 'naranja',\n startingRules: [377798, 377799, 402917, 402918, 527571, 527572, 589562],\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(37|40|5[28])([279])\\d*$/\n});\n\n// TODO: 589657 clashes with naranja, rest ok\nCardType.cards.push({\n cardType: 'cabal',\n startingRules: [589657, 600691, 603522, 6042, 6043, 636908],\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(58|6[03])([03469])\\d*$/\n});\n\nCardType.cards.push({\n cardType: 'shopping',\n startingRules: [2799, 589407, 603488],\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(27|58|60)([39])\\d*$/\n});\n\nCardType.cards.push({ cardType: 'argencard', startingRules: [501], permittedLengths: [16, 17, 18, 19], pattern: /^(50)(1)\\d*$/ }); // NOTE: starting rule changed, from 501105, to not clash with dankort. Plus it now matches its regEx!\n\nCardType.cards.push({ cardType: 'troy', startingRules: [9792], permittedLengths: [16], pattern: /^(97)(9)\\d*$/ });\n\n// TODO: clashes with cabal\nCardType.cards.push({ cardType: 'forbrugsforeningen', startingRules: [600722], permittedLengths: [16], pattern: /^(60)(0)\\d*$/ });\n\nCardType.cards.push({\n cardType: 'vpay',\n startingRules: [401, 408, 413, 434, 435, 437, 439, 441, 442, 443, 444, 446, 447, 455, 458, 460, 461, 463, 466, 471, 479, 482, 483, 487],\n permittedLengths: [13, 14, 15, 16, 17, 18, 19],\n pattern: /^(40[1,8]|413|43[4,5]|44[1,2,3,4,6,7]|45[5,8]|46[0,1,3,6]|47[1,9]|48[2,3,7])[0-9]{0,16}$/ // ^(4[0-1|3-8][0-9]{1,17})$\n});\n\nCardType.cards.push({\n cardType: 'rupay',\n startingRules: [508528],\n permittedLengths: [16],\n // prettier-ignore\n pattern:\n /^(100003|508(2|[5-9])|60(69|[7-8])|652(1[5-9]|[2-5][0-9]|8[5-9])|65300[3-4]|8172([0-1]|[3-5]|7|9)|817(3[3-8]|40[6-9]|410)|35380([0-2]|[5-6]|9))[0-9]{0,12}$/\n});\n\nCardType.cards.push({\n cardType: 'ticket',\n expiryDatePolicy: 'hidden'\n});\n\nconst detectCard = (pCardNumber, pAvailableCards?) => {\n let matchedCards;\n let i;\n let len;\n\n if (pAvailableCards) {\n // Filter CardType.cards down to those that are found in pAvailableCards\n matchedCards = CardType.cards\n .filter(card => pAvailableCards.includes(card.cardType))\n // Further filter them to those with a regEx pattern that matches pCardNumber\n .filter(card => hasOwnProperty(card, 'pattern') && pCardNumber.match(card.pattern));\n\n // If we have matched cards: if there's only one - return it; else return the one with the longest startingRule\n if (matchedCards.length) {\n if (matchedCards.length === 1) {\n return matchedCards[0];\n }\n\n // Find longest rule for each matched card & store it as a property on the card\n for (i = 0, len = matchedCards.length; i < len; i += 1) {\n if (!matchedCards[i].longestRule) {\n const longestRule = matchedCards[i].startingRules.reduce((a, b) => (a > b ? a : b));\n // What we actually store is how many chars are in the rule\n matchedCards[i].longestRule = String(longestRule).length;\n }\n }\n\n // Based on each matched cards longest rule - find the card with the longest one!\n return matchedCards.reduce((a, b) => (a.longestRule >= b.longestRule ? a : b));\n }\n\n return { cardType: CardType.__NO_BRAND };\n }\n\n return { cardType: CardType.__NO_BRAND };\n};\n\nconst detectCardLength = (pCard, pUnformattedVal) => {\n let maxLength;\n let shortenedNewValue;\n let lengthDiff = 0;\n let reachedValidLength = false;\n let unformattedVal = pUnformattedVal;\n\n // Find the longest of the permitted card number lengths for this card brand\n const maxPermittedLength = pCard.cardType !== CardType.__NO_BRAND ? pCard.permittedLengths[pCard.permittedLengths.length - 1] : 0;\n\n // If the input value is longer than it's max permitted length then shorten it to that length\n if (maxPermittedLength && unformattedVal > maxPermittedLength) {\n lengthDiff = unformattedVal.length - maxPermittedLength;\n\n if (lengthDiff > 0) {\n unformattedVal = unformattedVal.substring(0, unformattedVal.length - lengthDiff);\n shortenedNewValue = unformattedVal;\n }\n }\n\n // If cardNumber has reached one of the cardBrand's 'permitted lengths' - mark it as 'valid'\n pCard.permittedLengths.forEach(pItem => {\n if (unformattedVal.length === pItem) {\n reachedValidLength = true;\n }\n });\n\n // If cardNumber is as long as the cardBrand's maximum permitted length then set the maxLength var\n if (unformattedVal.length === maxPermittedLength) {\n // Set maxlength to max + the right amount of spaces (one for every 4 digits, but not on the last block)\n const div = Math.floor(unformattedVal.length / 4);\n const mod = unformattedVal.length % 4;\n const numSpaces = mod > 0 ? div : div - 1;\n\n maxLength = maxPermittedLength + numSpaces;\n\n if (pCard.cardType.toLowerCase() === 'amex') {\n maxLength = maxPermittedLength + 2; // = 17 = 15 digits with space after 4th & 10th\n }\n }\n\n return {\n shortenedNewValue,\n maxLength,\n reachedValidLength\n };\n};\n\nconst getShortestPermittedCardLength = () => {\n if (!shortestPermittedCardLength) {\n let permittedLengthsArray = [];\n\n CardType.cards.forEach(pItem => {\n permittedLengthsArray = permittedLengthsArray.concat(pItem.permittedLengths ?? []);\n });\n\n shortestPermittedCardLength = Math.min.apply(null, permittedLengthsArray);\n }\n\n return shortestPermittedCardLength;\n};\n\nconst getCardByBrand = pBrand => {\n const cardType = CardType.cards.filter(card => card.cardType === pBrand);\n\n return cardType[0];\n};\n\nconst isGenericCardType = type => {\n if (!type) throw new Error('Error: isGenericCardType: type param has not been specified');\n return type === 'card' || type === 'scheme';\n};\n\nexport default {\n detectCard,\n detectCardLength,\n getShortestPermittedCardLength,\n getCardByBrand,\n isGenericCardType,\n __NO_BRAND: CardType.__NO_BRAND,\n allCards: CardType.cards\n};\n"],"names":["shortestPermittedCardLength","CardType","cards","push","cardType","startingRules","permittedLengths","pattern","securityCode","cvcPolicy","expiryDatePolicy","detectCard","pCardNumber","pAvailableCards","matchedCards","i","len","filter","card","includes","hasOwnProperty","match","length","longestRule","reduce","a","b","String","__NO_BRAND","detectCardLength","pCard","pUnformattedVal","maxLength","shortenedNewValue","lengthDiff","reachedValidLength","unformattedVal","maxPermittedLength","substring","forEach","pItem","div","Math","floor","toLowerCase","getShortestPermittedCardLength","permittedLengthsArray","concat","min","apply","getCardByBrand","pBrand","isGenericCardType","type","Error","allCards"],"mappings":"2EAGA,IAAIA,EAOJ,MAAMC,EAAqB,CAC3BA,WAAsB,UAEtBA,MAAiB,IAEjBA,EAASC,MAAMC,KAAK,CAChBC,SAAU,KACVC,cAAe,CAAC,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,IACxDC,iBAAkB,CAAC,IACnBC,QAAS,0CACTC,aAAc,QAGlBP,EAASC,MAAMC,KAAK,CAAEC,SAAU,cAAeC,cAAe,CAAC,MAAOC,iBAAkB,CAAC,IAAKC,QAAS,wBAEvGN,EAASC,MAAMC,KAAK,CAChBC,SAAU,OACVC,cAAe,CAAC,GAChBC,iBAAkB,CAAC,GAAI,GAAI,IAC3BC,QAAS,iBACTC,aAAc,QAGlBP,EAASC,MAAMC,KAAK,CAAEC,SAAU,OAAQC,cAAe,CAAC,GAAI,IAAKC,iBAAkB,CAAC,IAAKC,QAAS,qBAAsBC,aAAc,QAEtIP,EAASC,MAAMC,KAAK,CAAEC,SAAU,SAAUC,cAAe,CAAC,IA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IACbE,EAAiBA,EAAeE,UAAU,EAAGF,EAAed,OAASY,GACrED,EAAoBG,IAK5BN,EAAMxB,iBAAiBiC,QAAQC,IACvBJ,EAAed,SAAWkB,IAC1BL,GAAqB,KAKzBC,EAAed,SAAWe,EAAoB,CAE9C,MAAMI,EAAMC,KAAKC,MAAMP,EAAed,OAAS,GAI/CU,EAAYK,GAHAD,EAAed,OAAS,EACZ,EAAImB,EAAMA,EAAM,GAIH,SAAjCX,EAAM1B,SAASwC,gBACfZ,EAAYK,EAAqB,EAEzC,CAEA,MAAO,CACHJ,oBACAD,YACAG,uBAgCJU,+BA5BmC,KACnC,IAAK7C,EAA6B,CAC9B,IAAI8C,EAAwB,GAE5B7C,EAASC,MAAMqC,QAAQC,IACkCA,IAAAA,EAArDM,EAAwBA,EAAsBC,OAA6B,QAAtBP,EAAAA,EAAMlC,4BAANkC,EAAAA,EAA0B,MAGnFxC,EAA8B0C,KAAKM,IAAIC,MAAM,KAAMH,EACvD,CAEA,OAAO9C,GAkBPkD,eAfmBC,GACFlD,EAASC,MAAMe,OAAOC,GAAQA,EAAKd,WAAa+C,GAEjD,GAahBC,kBAVsBC,IACtB,IAAKA,EAAM,MAAM,IAAIC,MAAM,+DAC3B,MAAgB,SAATD,GAA4B,WAATA,GAS1BzB,WAAY3B,EAAS2B,WACrB2B,SAAUtD,EAASC"}
1
+ {"version":3,"file":"cardType.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/utils/cardType.ts"],"sourcesContent":["import { CardObject } from '../../types';\nimport { hasOwnProperty } from '../../../../../../utils/hasOwnProperty';\n\nlet shortestPermittedCardLength;\n\ninterface CardType {\n __NO_BRAND?: string;\n cards?: CardObject[];\n}\n\nconst CardType: CardType = {};\nCardType.__NO_BRAND = 'noBrand';\n\nCardType.cards = [];\n\nCardType.cards.push({\n cardType: 'mc',\n permittedLengths: [16],\n pattern: /^(5[1-5][0-9]{0,14}|2[2-7][0-9]{0,14})$/,\n securityCode: 'CVC'\n});\n\nCardType.cards.push({ cardType: 'visadankort', permittedLengths: [16], pattern: /^(4571)[0-9]{0,12}$/ });\n\nCardType.cards.push({\n cardType: 'visa',\n permittedLengths: [13, 16, 19],\n pattern: /^4[0-9]{0,18}$/,\n securityCode: 'CVV'\n});\n\nCardType.cards.push({ cardType: 'amex', permittedLengths: [15], pattern: /^3[47][0-9]{0,13}$/, securityCode: 'CID' });\n\nCardType.cards.push({ cardType: 'diners', permittedLengths: [14, 15, 16, 17, 18, 19], pattern: /^(36)[0-9]{0,12}$/ });\n\nCardType.cards.push({ cardType: 'maestrouk', permittedLengths: [16, 18, 19], pattern: /^(6759)[0-9]{0,15}$/ });\n\nCardType.cards.push({ cardType: 'solo', permittedLengths: [16, 18, 19], pattern: /^(6767)[0-9]{0,15}$/ });\n\nCardType.cards.push({\n cardType: 'laser',\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(6304|6706|6709|6771)[0-9]{0,15}$/,\n cvcPolicy: 'optional'\n});\n\nCardType.cards.push({\n cardType: 'discover',\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(6011[0-9]{0,12}|(644|645|646|647|648|649)[0-9]{0,13}|65[0-9]{0,14})$/\n});\n\nCardType.cards.push({\n cardType: 'jcb',\n permittedLengths: [16, 19],\n pattern: /^(352[8,9]{1}[0-9]{0,15}|35[4-8]{1}[0-9]{0,16})$/,\n securityCode: 'CAV'\n});\n\nCardType.cards.push({\n cardType: 'bcmc',\n permittedLengths: [16, 17, 18, 19],\n pattern: /^((6703)[0-9]{0,15}|(479658|606005)[0-9]{0,13})$/,\n cvcPolicy: 'hidden'\n});\n\nCardType.cards.push({ cardType: 'bijcard', permittedLengths: [16], pattern: /^(5100081)[0-9]{0,9}$/ });\n\nCardType.cards.push({\n cardType: 'dankort',\n permittedLengths: [16],\n pattern: /^(5|50|501|5019[0-9]{0,12}|4|45|457|4571[0-9]{0,12}|3|35|357|3571[0-9]{0,12})$/\n});\n\nCardType.cards.push({ cardType: 'hipercard', permittedLengths: [16], pattern: /^(606282)[0-9]{0,10}$/ });\n\n// Moved above maestro (from position below uatp) to stop maestro being recognised over cup\nCardType.cards.push({ cardType: 'cup', permittedLengths: [14, 15, 16, 17, 18, 19], pattern: /^(62|81)[0-9]{0,17}$/ }); // orig & android v1 + modified to include our test cards (81...)\n\nCardType.cards.push({\n cardType: 'maestro',\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(5[0|6-8][0-9]{0,17}|6[0-9]{0,18})$/,\n cvcPolicy: 'optional'\n});\n\nCardType.cards.push({\n cardType: 'elo',\n permittedLengths: [16],\n // prettier-ignore\n pattern:\n /^((((506699)|(506770)|(506771)|(506772)|(506773)|(506774)|(506775)|(506776)|(506777)|(506778)|(401178)|(438935)|(451416)|(457631)|(457632)|(504175)|(627780)|(636368)|(636297))[0-9]{0,10})|((50676)|(50675)|(50674)|(50673)|(50672)|(50671)|(50670))[0-9]{0,11})$/\n});\n\nCardType.cards.push({ cardType: 'uatp', permittedLengths: [15], pattern: /^1[0-9]{0,14}$/, cvcPolicy: 'optional' });\n\nCardType.cards.push({\n cardType: 'cartebancaire',\n permittedLengths: [16],\n pattern: /^[4-6][0-9]{0,15}$/\n});\n\nCardType.cards.push({ cardType: 'visaalphabankbonus', permittedLengths: [16], pattern: /^(450903)[0-9]{0,10}$/ });\n\nCardType.cards.push({ cardType: 'mcalphabankbonus', permittedLengths: [16], pattern: /^(510099)[0-9]{0,10}$/ });\n\nCardType.cards.push({\n cardType: 'hiper',\n permittedLengths: [16],\n pattern: /^(637095|637568|637599|637609|637612)[0-9]{0,10}$/\n});\n\nCardType.cards.push({ cardType: 'oasis', permittedLengths: [16], pattern: /^(982616)[0-9]{0,10}$/, cvcPolicy: 'optional' });\n\nCardType.cards.push({\n cardType: 'karenmillen',\n permittedLengths: [16],\n pattern: /^(98261465)[0-9]{0,8}$/,\n cvcPolicy: 'optional'\n});\n\nCardType.cards.push({\n cardType: 'warehouse',\n permittedLengths: [16],\n pattern: /^(982633)[0-9]{0,10}$/,\n cvcPolicy: 'optional'\n});\n\nCardType.cards.push({ cardType: 'mir', permittedLengths: [16, 17, 18, 19], pattern: /^(220)[0-9]{0,16}$/ });\n\nCardType.cards.push({ cardType: 'codensa', permittedLengths: [16], pattern: /^(590712)[0-9]{0,10}$/ });\n\nCardType.cards.push({\n cardType: 'naranja',\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(37|40|5[28])([279])\\d*$/\n});\n\n// TODO: 589657 clashes with naranja, rest ok\nCardType.cards.push({\n cardType: 'cabal',\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(58|6[03])([03469])\\d*$/\n});\n\nCardType.cards.push({\n cardType: 'shopping',\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(27|58|60)([39])\\d*$/\n});\n\nCardType.cards.push({ cardType: 'argencard', permittedLengths: [16, 17, 18, 19], pattern: /^(50)(1)\\d*$/ }); // NOTE: starting rule changed, from 501105, to not clash with dankort. Plus it now matches its regEx!\n\nCardType.cards.push({ cardType: 'troy', permittedLengths: [16], pattern: /^(97)(9)\\d*$/ });\n\n// TODO: clashes with cabal\nCardType.cards.push({ cardType: 'forbrugsforeningen', permittedLengths: [16], pattern: /^(60)(0)\\d*$/ });\n\nCardType.cards.push({\n cardType: 'vpay',\n permittedLengths: [13, 14, 15, 16, 17, 18, 19],\n pattern: /^(40[1,8]|413|43[4,5]|44[1,2,3,4,6,7]|45[5,8]|46[0,1,3,6]|47[1,9]|48[2,3,7])[0-9]{0,16}$/ // ^(4[0-1|3-8][0-9]{1,17})$\n});\n\nCardType.cards.push({\n cardType: 'rupay',\n permittedLengths: [16],\n // prettier-ignore\n pattern:\n /^(100003|508(2|[5-9])|60(69|[7-8])|652(1[5-9]|[2-5][0-9]|8[5-9])|65300[3-4]|8172([0-1]|[3-5]|7|9)|817(3[3-8]|40[6-9]|410)|35380([0-2]|[5-6]|9))[0-9]{0,12}$/\n});\n\nCardType.cards.push({\n cardType: 'ticket',\n expiryDatePolicy: 'hidden'\n});\n\nconst detectCard = (pCardNumber: string, pCardGroupTypes?: string[]): CardObject => {\n let matchedCards: CardObject[];\n\n if (pCardGroupTypes) {\n // Filter CardType.cards down to those that are found in pAvailableCards\n matchedCards = CardType.cards\n .filter(card => pCardGroupTypes.includes(card.cardType))\n // Further filter them to those with a regEx pattern that matches pCardNumber\n .filter(card => hasOwnProperty(card, 'pattern') && pCardNumber.match(card.pattern));\n\n // If we have matched cards: if there's only one - return it; else return the one with the longest startingRule\n if (matchedCards.length) {\n if (matchedCards.length === 1) {\n return matchedCards[0];\n }\n\n // Sort matchedCards to follow the same order as pCardGroupTypes\n matchedCards.sort((a, b) => {\n const aIndex = pCardGroupTypes.indexOf(a.cardType);\n const bIndex = pCardGroupTypes.indexOf(b.cardType);\n return aIndex - bIndex;\n });\n\n return matchedCards[0];\n }\n\n return { cardType: CardType.__NO_BRAND };\n }\n\n return { cardType: CardType.__NO_BRAND };\n};\n\nconst detectCardLength = (pCard, pUnformattedVal) => {\n let maxLength;\n let shortenedNewValue;\n let lengthDiff = 0;\n let reachedValidLength = false;\n let unformattedVal = pUnformattedVal;\n\n // Find the longest of the permitted card number lengths for this card brand\n const maxPermittedLength = pCard.cardType !== CardType.__NO_BRAND ? pCard.permittedLengths[pCard.permittedLengths.length - 1] : 0;\n\n // If the input value is longer than it's max permitted length then shorten it to that length\n if (maxPermittedLength && unformattedVal > maxPermittedLength) {\n lengthDiff = unformattedVal.length - maxPermittedLength;\n\n if (lengthDiff > 0) {\n unformattedVal = unformattedVal.substring(0, unformattedVal.length - lengthDiff);\n shortenedNewValue = unformattedVal;\n }\n }\n\n // If cardNumber has reached one of the cardBrand's 'permitted lengths' - mark it as 'valid'\n pCard.permittedLengths.forEach(pItem => {\n if (unformattedVal.length === pItem) {\n reachedValidLength = true;\n }\n });\n\n // If cardNumber is as long as the cardBrand's maximum permitted length then set the maxLength var\n if (unformattedVal.length === maxPermittedLength) {\n // Set maxlength to max + the right amount of spaces (one for every 4 digits, but not on the last block)\n const div = Math.floor(unformattedVal.length / 4);\n const mod = unformattedVal.length % 4;\n const numSpaces = mod > 0 ? div : div - 1;\n\n maxLength = maxPermittedLength + numSpaces;\n\n if (pCard.cardType.toLowerCase() === 'amex') {\n maxLength = maxPermittedLength + 2; // = 17 = 15 digits with space after 4th & 10th\n }\n }\n\n return {\n shortenedNewValue,\n maxLength,\n reachedValidLength\n };\n};\n\nconst getShortestPermittedCardLength = () => {\n if (!shortestPermittedCardLength) {\n let permittedLengthsArray = [];\n\n CardType.cards.forEach(pItem => {\n permittedLengthsArray = permittedLengthsArray.concat(pItem.permittedLengths ?? []);\n });\n\n shortestPermittedCardLength = Math.min.apply(null, permittedLengthsArray);\n }\n\n return shortestPermittedCardLength;\n};\n\nconst getCardByBrand = pBrand => {\n const cardType = CardType.cards.filter(card => card.cardType === pBrand);\n\n return cardType[0];\n};\n\nconst isGenericCardType = type => {\n if (!type) throw new Error('Error: isGenericCardType: type param has not been specified');\n return type === 'card' || type === 'scheme';\n};\n\nexport default {\n detectCard,\n detectCardLength,\n getShortestPermittedCardLength,\n getCardByBrand,\n isGenericCardType,\n __NO_BRAND: CardType.__NO_BRAND,\n allCards: CardType.cards\n};\n"],"names":["shortestPermittedCardLength","CardType","cards","push","cardType","permittedLengths","pattern","securityCode","cvcPolicy","expiryDatePolicy","detectCard","pCardNumber","pCardGroupTypes","matchedCards","filter","card","includes","hasOwnProperty","match","length","sort","a","b","indexOf","__NO_BRAND","detectCardLength","pCard","pUnformattedVal","maxLength","shortenedNewValue","lengthDiff","reachedValidLength","unformattedVal","maxPermittedLength","substring","forEach","pItem","div","Math","floor","toLowerCase","getShortestPermittedCardLength","permittedLengthsArray","concat","min","apply","getCardByBrand","pBrand","isGenericCardType","type","Error","allCards"],"mappings":"2EAGA,IAAIA,EAOJ,MAAMC,EAAqB,CAC3BA,WAAsB,UAEtBA,MAAiB,IAEjBA,EAASC,MAAMC,KAAK,CAChBC,SAAU,KACVC,iBAAkB,CAAC,IACnBC,QAAS,0CACTC,aAAc,QAGlB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c,GAAsBD,EAAiBC,IACvCH,EAAaE,EAAeb,OAASc,EAEjCH,EAAa,IACbE,EAAiBA,EAAeE,UAAU,EAAGF,EAAeb,OAASW,GACrED,EAAoBG,IAK5BN,EAAMrB,iBAAiB8B,QAAQC,IACvBJ,EAAeb,SAAWiB,IAC1BL,GAAqB,KAKzBC,EAAeb,SAAWc,EAAoB,CAE9C,MAAMI,EAAMC,KAAKC,MAAMP,EAAeb,OAAS,GAI/CS,EAAYK,GAHAD,EAAeb,OAAS,EACZ,EAAIkB,EAAMA,EAAM,GAIH,SAAjCX,EAAMtB,SAASoC,gBACfZ,EAAYK,EAAqB,EAEzC,CAEA,MAAO,CACHJ,oBACAD,YACAG,uBAgCJU,+BA5BmC,KACnC,IAAKzC,EAA6B,CAC9B,IAAI0C,EAAwB,GAE5BzC,EAASC,MAAMiC,QAAQC,IACkCA,IAAAA,EAArDM,EAAwBA,EAAsBC,OAA6B,QAAtBP,EAAAA,EAAM/B,4BAAN+B,EAAAA,EAA0B,MAGnFpC,EAA8BsC,KAAKM,IAAIC,MAAM,KAAMH,EACvD,CAEA,OAAO1C,GAkBP8C,eAfmBC,GACF9C,EAASC,MAAMY,OAAOC,GAAQA,EAAKX,WAAa2C,GAEjD,GAahBC,kBAVsBC,IACtB,IAAKA,EAAM,MAAM,IAAIC,MAAM,+DAC3B,MAAgB,SAATD,GAA4B,WAATA,GAS1BzB,WAAYvB,EAASuB,WACrB2B,SAAUlD,EAASC"}
@@ -1,2 +1,2 @@
1
- const e="encrypted",r="encryptedCardNumber",c="encryptedExpiryDate",i="encryptedExpiryMonth",d="encryptedExpiryYear",t="encryptedSecurityCode",a="encryptedPassword",s="encryptedSecurityCode3digits",n="encryptedSecurityCode4digits",o="giftcard",y="6.1.0",p=["amex","mc","visa"],u=[o],C=[r,c,i,d,t,a],m=C,x=["bcmc"],b="required",D="optional",g="hidden",h=b,l=D,v=g,E=b,M=D,S=g,f="data-cse",j="data-info",B="data-uid",w=["accel","pulse","star","nyce"],A={visa:"VISA",mc:"MasterCard",amex:"American Express",discover:"Discover",cup:"China Union Pay",jcb:"JCB",diners:"Diners Club",maestro:"Maestro",bcmc:"Bancontact card",bijcard:"de Bijenkorf Card"},N={[r]:"cardNumber",[c]:"expiryDate",[t]:"securityCode",[i]:"expiryMonth",[d]:"expiryYear",[a]:"password",[s]:"securityCodeThreeDigits",[n]:"securityCodeFourDigits"},P=6e3;export{m as ALL_SECURED_FIELDS,w as BRAND_ICON_UI_EXCLUSION_LIST,A as BRAND_READABLE_NAME_MAP,C as CREDIT_CARD_SF_FIELDS,v as CVC_POLICY_HIDDEN,l as CVC_POLICY_OPTIONAL,h as CVC_POLICY_REQUIRED,f as DATA_ENCRYPTED_FIELD_ATTR,j as DATA_INFO,B as DATA_UID,S as DATE_POLICY_HIDDEN,M as DATE_POLICY_OPTIONAL,E as DATE_POLICY_REQUIRED,x as DEDICATED_CARD_COMPONENTS,p as DEFAULT_CARD_GROUP_TYPES,e as ENCRYPTED,r as ENCRYPTED_CARD_NUMBER,c as ENCRYPTED_EXPIRY_DATE,i as ENCRYPTED_EXPIRY_MONTH,d as ENCRYPTED_EXPIRY_YEAR,a as ENCRYPTED_PWD_FIELD,t as ENCRYPTED_SECURITY_CODE,s as ENCRYPTED_SECURITY_CODE_3_DIGITS,n as ENCRYPTED_SECURITY_CODE_4_DIGITS,o as GIFT_CARD,g as HIDDEN,u as NON_CREDIT_CARD_TYPE_SECURED_FIELDS,D as OPTIONAL,b as REQUIRED,P as SF_CONFIG_TIMEOUT,N as SF_FIELDS_MAP,y as SF_VERSION};
1
+ const e="encrypted",r="encryptedCardNumber",i="encryptedExpiryDate",c="encryptedExpiryMonth",d="encryptedExpiryYear",t="encryptedSecurityCode",a="encryptedPassword",n="encryptedSecurityCode3digits",s="encryptedSecurityCode4digits",o="giftcard",y="6.2.0",p=["amex","mc","visa"],u=[o],C=[r,i,c,d,t,a],m=C,x=["bcmc"],b="required",D="optional",g="hidden",h=b,l=D,v=g,E=b,M=D,S=g,f="data-cse",j="data-info",B="data-uid",k=["accel","pulse","star","nyce"],w={visa:"VISA",mc:"MasterCard",amex:"American Express",discover:"Discover",cup:"China Union Pay",jcb:"JCB",diners:"Diners Club",maestro:"Maestro",bcmc:"Bancontact card",bijcard:"de Bijenkorf Card"},A={[r]:"cardNumber",[i]:"expiryDate",[t]:"securityCode",[c]:"expiryMonth",[d]:"expiryYear",[a]:"password",[n]:"securityCodeThreeDigits",[s]:"securityCodeFourDigits"},N=6e3,P="bin-lookup";export{m as ALL_SECURED_FIELDS,P as BIN_LOOKUP_MODE,k as BRAND_ICON_UI_EXCLUSION_LIST,w as BRAND_READABLE_NAME_MAP,C as CREDIT_CARD_SF_FIELDS,v as CVC_POLICY_HIDDEN,l as CVC_POLICY_OPTIONAL,h as CVC_POLICY_REQUIRED,f as DATA_ENCRYPTED_FIELD_ATTR,j as DATA_INFO,B as DATA_UID,S as DATE_POLICY_HIDDEN,M as DATE_POLICY_OPTIONAL,E as DATE_POLICY_REQUIRED,x as DEDICATED_CARD_COMPONENTS,p as DEFAULT_CARD_GROUP_TYPES,e as ENCRYPTED,r as ENCRYPTED_CARD_NUMBER,i as ENCRYPTED_EXPIRY_DATE,c as ENCRYPTED_EXPIRY_MONTH,d as ENCRYPTED_EXPIRY_YEAR,a as ENCRYPTED_PWD_FIELD,t as ENCRYPTED_SECURITY_CODE,n as ENCRYPTED_SECURITY_CODE_3_DIGITS,s as ENCRYPTED_SECURITY_CODE_4_DIGITS,o as GIFT_CARD,g as HIDDEN,u as NON_CREDIT_CARD_TYPE_SECURED_FIELDS,D as OPTIONAL,b as REQUIRED,N as SF_CONFIG_TIMEOUT,A as SF_FIELDS_MAP,y as SF_VERSION};
2
2
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../../../../../../src/components/internal/SecuredFields/lib/constants.ts"],"sourcesContent":["import { CVCPolicyType, DatePolicyType } from './types';\n\nexport const ENCRYPTED = 'encrypted';\n\nexport const ENCRYPTED_CARD_NUMBER = 'encryptedCardNumber';\nexport const ENCRYPTED_EXPIRY_DATE = 'encryptedExpiryDate';\nexport const ENCRYPTED_EXPIRY_MONTH = 'encryptedExpiryMonth';\nexport const ENCRYPTED_EXPIRY_YEAR = 'encryptedExpiryYear';\nexport const ENCRYPTED_SECURITY_CODE = 'encryptedSecurityCode';\nexport const ENCRYPTED_PWD_FIELD = 'encryptedPassword';\nexport const ENCRYPTED_PIN_FIELD = 'encryptedPin';\n\nexport const ENCRYPTED_SECURITY_CODE_3_DIGITS = 'encryptedSecurityCode3digits';\nexport const ENCRYPTED_SECURITY_CODE_4_DIGITS = 'encryptedSecurityCode4digits';\n\nexport const GIFT_CARD = 'giftcard';\n\nexport const SF_VERSION = '6.1.0';\n\nexport const DEFAULT_CARD_GROUP_TYPES = ['amex', 'mc', 'visa'];\n\nexport const NON_CREDIT_CARD_TYPE_SECURED_FIELDS = [GIFT_CARD]; // Maybe, sometime in the future will include 'sepa' & 'sepadirectdebit'\n\n// Credit card (CardInput) related securedFields (based on the data-cse attribute)\nexport const CREDIT_CARD_SF_FIELDS = [\n ENCRYPTED_CARD_NUMBER,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR,\n ENCRYPTED_SECURITY_CODE,\n ENCRYPTED_PWD_FIELD\n] as const;\n\n/** A list of all the data-cse attributes that relate to securedFields (as found in card, giftcard) */\nexport const ALL_SECURED_FIELDS = CREDIT_CARD_SF_FIELDS;\n\n// Card components created as: checkout.create({BRAND}) e.g. checkout.create('bcmc')\n// - which are dedicated to a single, core, brand e.g. 'bcmc' BUT which can in effect handle multiple brands e.g. \"bcmc\", \"maestro\", \"visa\"\nexport const DEDICATED_CARD_COMPONENTS = ['bcmc'];\n\nexport const REQUIRED = 'required';\nexport const OPTIONAL = 'optional';\nexport const HIDDEN = 'hidden';\n\nexport const CVC_POLICY_REQUIRED: CVCPolicyType = REQUIRED;\nexport const CVC_POLICY_OPTIONAL: CVCPolicyType = OPTIONAL;\nexport const CVC_POLICY_HIDDEN: CVCPolicyType = HIDDEN;\n\nexport const DATE_POLICY_REQUIRED: DatePolicyType = REQUIRED;\nexport const DATE_POLICY_OPTIONAL: DatePolicyType = OPTIONAL;\nexport const DATE_POLICY_HIDDEN: DatePolicyType = HIDDEN;\n\nexport const DATA_ENCRYPTED_FIELD_ATTR = 'data-cse';\nexport const DATA_INFO = 'data-info';\nexport const DATA_UID = 'data-uid';\n\nexport const BRAND_ICON_UI_EXCLUSION_LIST = ['accel', 'pulse', 'star', 'nyce'];\n\nexport const BRAND_READABLE_NAME_MAP = {\n visa: 'VISA',\n mc: 'MasterCard',\n amex: 'American Express',\n discover: 'Discover',\n cup: 'China Union Pay',\n jcb: 'JCB',\n diners: 'Diners Club',\n maestro: 'Maestro',\n bcmc: 'Bancontact card',\n bijcard: 'de Bijenkorf Card'\n};\n\nexport const SF_FIELDS_MAP = {\n [ENCRYPTED_CARD_NUMBER]: 'cardNumber', // ph\n [ENCRYPTED_EXPIRY_DATE]: 'expiryDate', // ph\n [ENCRYPTED_SECURITY_CODE]: 'securityCode',\n [ENCRYPTED_EXPIRY_MONTH]: 'expiryMonth', // ph\n [ENCRYPTED_EXPIRY_YEAR]: 'expiryYear', // ph\n //\n [ENCRYPTED_PWD_FIELD]: 'password',\n //\n [ENCRYPTED_SECURITY_CODE_3_DIGITS]: 'securityCodeThreeDigits', // ph\n [ENCRYPTED_SECURITY_CODE_4_DIGITS]: 'securityCodeFourDigits' // ph\n};\n\n/** time within which we expect to receive a \"configured\" message from a securedField iframe, once it has registered as having loaded */\nexport const SF_CONFIG_TIMEOUT = 6000;\n"],"names":["ENCRYPTED","ENCRYPTED_CARD_NUMBER","ENCRYPTED_EXPIRY_DATE","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","ENCRYPTED_SECURITY_CODE","ENCRYPTED_PWD_FIELD","ENCRYPTED_SECURITY_CODE_3_DIGITS","ENCRYPTED_SECURITY_CODE_4_DIGITS","GIFT_CARD","SF_VERSION","DEFAULT_CARD_GROUP_TYPES","NON_CREDIT_CARD_TYPE_SECURED_FIELDS","CREDIT_CARD_SF_FIELDS","ALL_SECURED_FIELDS","DEDICATED_CARD_COMPONENTS","REQUIRED","OPTIONAL","HIDDEN","CVC_POLICY_REQUIRED","CVC_POLICY_OPTIONAL","CVC_POLICY_HIDDEN","DATE_POLICY_REQUIRED","DATE_POLICY_OPTIONAL","DATE_POLICY_HIDDEN","DATA_ENCRYPTED_FIELD_ATTR","DATA_INFO","DATA_UID","BRAND_ICON_UI_EXCLUSION_LIST","BRAND_READABLE_NAME_MAP","visa","mc","amex","discover","cup","jcb","diners","maestro","bcmc","bijcard","SF_FIELDS_MAP","SF_CONFIG_TIMEOUT"],"mappings":"AAEO,MAAMA,EAAY,YAEZC,EAAwB,sBACxBC,EAAwB,sBACxBC,EAAyB,uBACzBC,EAAwB,sBACxBC,EAA0B,wBAC1BC,EAAsB,oBAGtBC,EAAmC,+BACnCC,EAAmC,+BAEnCC,EAAY,WAEZC,EAAa,QAEbC,EAA2B,CAAC,OAAQ,KAAM,QAE1CC,EAAsC,CAACH,GAGvCI,EAAwB,CACjCZ,EACAC,EACAC,EACAC,EACAC,EACAC,GAISQ,EAAqBD,EAIrBE,EAA4B,CAAC,QAE7BC,EAAW,WACXC,EAAW,WACXC,EAAS,SAETC,EAAqCH,EACrCI,EAAqCH,EACrCI,EAAmCH,EAEnCI,EAAuCN,EACvCO,EAAuCN,EACvCO,EAAqCN,EAErCO,EAA4B,WAC5BC,EAAY,YACZC,EAAW,WAEXC,EAA+B,CAAC,QAAS,QAAS,OAAQ,QAE1DC,EAA0B,CACnCC,KAAM,OACNC,GAAI,aACJC,KAAM,mBACNC,SAAU,WACVC,IAAK,kBACLC,IAAK,MACLC,OAAQ,cACRC,QAAS,UACTC,KAAM,kBACNC,QAAS,qBAGAC,EAAgB,CACzBvC,CAACA,GAAwB,aACzBC,CAACA,GAAwB,aACzBG,CAACA,GAA0B,eAC3BF,CAACA,GAAyB,cAC1BC,CAACA,GAAwB,aAEzBE,CAACA,GAAsB,WAEvBC,CAACA,GAAmC,0BACpCC,CAACA,GAAmC,0BAI3BiC,EAAoB"}
1
+ {"version":3,"file":"constants.js","sources":["../../../../../../src/components/internal/SecuredFields/lib/constants.ts"],"sourcesContent":["import { CVCPolicyType, DatePolicyType } from './types';\n\nexport const ENCRYPTED = 'encrypted';\n\nexport const ENCRYPTED_CARD_NUMBER = 'encryptedCardNumber';\nexport const ENCRYPTED_EXPIRY_DATE = 'encryptedExpiryDate';\nexport const ENCRYPTED_EXPIRY_MONTH = 'encryptedExpiryMonth';\nexport const ENCRYPTED_EXPIRY_YEAR = 'encryptedExpiryYear';\nexport const ENCRYPTED_SECURITY_CODE = 'encryptedSecurityCode';\nexport const ENCRYPTED_PWD_FIELD = 'encryptedPassword';\nexport const ENCRYPTED_PIN_FIELD = 'encryptedPin';\n\nexport const ENCRYPTED_SECURITY_CODE_3_DIGITS = 'encryptedSecurityCode3digits';\nexport const ENCRYPTED_SECURITY_CODE_4_DIGITS = 'encryptedSecurityCode4digits';\n\nexport const GIFT_CARD = 'giftcard';\n\nexport const SF_VERSION = '6.2.0';\n\nexport const DEFAULT_CARD_GROUP_TYPES = ['amex', 'mc', 'visa'];\n\nexport const NON_CREDIT_CARD_TYPE_SECURED_FIELDS = [GIFT_CARD]; // Maybe, sometime in the future will include 'sepa' & 'sepadirectdebit'\n\n// Credit card (CardInput) related securedFields (based on the data-cse attribute)\nexport const CREDIT_CARD_SF_FIELDS = [\n ENCRYPTED_CARD_NUMBER,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR,\n ENCRYPTED_SECURITY_CODE,\n ENCRYPTED_PWD_FIELD\n] as const;\n\n/** A list of all the data-cse attributes that relate to securedFields (as found in card, giftcard) */\nexport const ALL_SECURED_FIELDS = CREDIT_CARD_SF_FIELDS;\n\n// Card components created as: checkout.create({BRAND}) e.g. checkout.create('bcmc')\n// - which are dedicated to a single, core, brand e.g. 'bcmc' BUT which can in effect handle multiple brands e.g. \"bcmc\", \"maestro\", \"visa\"\nexport const DEDICATED_CARD_COMPONENTS = ['bcmc'];\n\nexport const REQUIRED = 'required';\nexport const OPTIONAL = 'optional';\nexport const HIDDEN = 'hidden';\n\nexport const CVC_POLICY_REQUIRED: CVCPolicyType = REQUIRED;\nexport const CVC_POLICY_OPTIONAL: CVCPolicyType = OPTIONAL;\nexport const CVC_POLICY_HIDDEN: CVCPolicyType = HIDDEN;\n\nexport const DATE_POLICY_REQUIRED: DatePolicyType = REQUIRED;\nexport const DATE_POLICY_OPTIONAL: DatePolicyType = OPTIONAL;\nexport const DATE_POLICY_HIDDEN: DatePolicyType = HIDDEN;\n\nexport const DATA_ENCRYPTED_FIELD_ATTR = 'data-cse';\nexport const DATA_INFO = 'data-info';\nexport const DATA_UID = 'data-uid';\n\nexport const BRAND_ICON_UI_EXCLUSION_LIST = ['accel', 'pulse', 'star', 'nyce'];\n\nexport const BRAND_READABLE_NAME_MAP: Record<string, string> = {\n visa: 'VISA',\n mc: 'MasterCard',\n amex: 'American Express',\n discover: 'Discover',\n cup: 'China Union Pay',\n jcb: 'JCB',\n diners: 'Diners Club',\n maestro: 'Maestro',\n bcmc: 'Bancontact card',\n bijcard: 'de Bijenkorf Card'\n};\n\nexport const SF_FIELDS_MAP = {\n [ENCRYPTED_CARD_NUMBER]: 'cardNumber', // ph\n [ENCRYPTED_EXPIRY_DATE]: 'expiryDate', // ph\n [ENCRYPTED_SECURITY_CODE]: 'securityCode',\n [ENCRYPTED_EXPIRY_MONTH]: 'expiryMonth', // ph\n [ENCRYPTED_EXPIRY_YEAR]: 'expiryYear', // ph\n //\n [ENCRYPTED_PWD_FIELD]: 'password',\n //\n [ENCRYPTED_SECURITY_CODE_3_DIGITS]: 'securityCodeThreeDigits', // ph\n [ENCRYPTED_SECURITY_CODE_4_DIGITS]: 'securityCodeFourDigits' // ph\n};\n\n/** time within which we expect to receive a \"configured\" message from a securedField iframe, once it has registered as having loaded */\nexport const SF_CONFIG_TIMEOUT = 6000;\n\nexport const BEST_GUESS_MODE = 'best-guess';\nexport const BIN_LOOKUP_MODE = 'bin-lookup';\n"],"names":["ENCRYPTED","ENCRYPTED_CARD_NUMBER","ENCRYPTED_EXPIRY_DATE","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","ENCRYPTED_SECURITY_CODE","ENCRYPTED_PWD_FIELD","ENCRYPTED_SECURITY_CODE_3_DIGITS","ENCRYPTED_SECURITY_CODE_4_DIGITS","GIFT_CARD","SF_VERSION","DEFAULT_CARD_GROUP_TYPES","NON_CREDIT_CARD_TYPE_SECURED_FIELDS","CREDIT_CARD_SF_FIELDS","ALL_SECURED_FIELDS","DEDICATED_CARD_COMPONENTS","REQUIRED","OPTIONAL","HIDDEN","CVC_POLICY_REQUIRED","CVC_POLICY_OPTIONAL","CVC_POLICY_HIDDEN","DATE_POLICY_REQUIRED","DATE_POLICY_OPTIONAL","DATE_POLICY_HIDDEN","DATA_ENCRYPTED_FIELD_ATTR","DATA_INFO","DATA_UID","BRAND_ICON_UI_EXCLUSION_LIST","BRAND_READABLE_NAME_MAP","visa","mc","amex","discover","cup","jcb","diners","maestro","bcmc","bijcard","SF_FIELDS_MAP","SF_CONFIG_TIMEOUT","BIN_LOOKUP_MODE"],"mappings":"AAEO,MAAMA,EAAY,YAEZC,EAAwB,sBACxBC,EAAwB,sBACxBC,EAAyB,uBACzBC,EAAwB,sBACxBC,EAA0B,wBAC1BC,EAAsB,oBAGtBC,EAAmC,+BACnCC,EAAmC,+BAEnCC,EAAY,WAEZC,EAAa,QAEbC,EAA2B,CAAC,OAAQ,KAAM,QAE1CC,EAAsC,CAACH,GAGvCI,EAAwB,CACjCZ,EACAC,EACAC,EACAC,EACAC,EACAC,GAISQ,EAAqBD,EAIrBE,EAA4B,CAAC,QAE7BC,EAAW,WACXC,EAAW,WACXC,EAAS,SAETC,EAAqCH,EACrCI,EAAqCH,EACrCI,EAAmCH,EAEnCI,EAAuCN,EACvCO,EAAuCN,EACvCO,EAAqCN,EAErCO,EAA4B,WAC5BC,EAAY,YACZC,EAAW,WAEXC,EAA+B,CAAC,QAAS,QAAS,OAAQ,QAE1DC,EAAkD,CAC3DC,KAAM,OACNC,GAAI,aACJC,KAAM,mBACNC,SAAU,WACVC,IAAK,kBACLC,IAAK,MACLC,OAAQ,cACRC,QAAS,UACTC,KAAM,kBACNC,QAAS,qBAGAC,EAAgB,CACzBvC,CAACA,GAAwB,aACzBC,CAACA,GAAwB,aACzBG,CAACA,GAA0B,eAC3BF,CAACA,GAAyB,cAC1BC,CAACA,GAAwB,aAEzBE,CAACA,GAAsB,WAEvBC,CAACA,GAAmC,0BACpCC,CAACA,GAAmC,0BAI3BiC,EAAoB,IAGpBC,EAAkB"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,createRef as t}from"../../../external/preact/dist/preact.js";import s,{NETWORK_ERROR as n}from"../../../core/Errors/AdyenCheckoutError.js";import{hasOwnProperty as i}from"../../../utils/hasOwnProperty.js";import o from"../BaseElement/BaseElement.js";import r from"../PayButton/PayButton.js";import{assertIsDropin as a,getRegulatoryDefaults as l,sanitizeResponse as h,verifyPaymentDidNotFail as d,cleanupFinalResult as c}from"./utils.js";import{AnalyticsErrorEvent as p,ErrorEventType as m}from"../../../core/Analytics/events/AnalyticsErrorEvent.js";import{AnalyticsInfoEvent as u,InfoEventType as y}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";import{AnalyticsLogEvent as f,LogEventType as v}from"../../../core/Analytics/events/AnalyticsLogEvent.js";import b from"../../../core/Errors/CancelError.js";import{CoreProvider as R}from"../../../core/Context/CoreProvider.js";import P from"../../../core/Errors/SRPanelProvider.js";import{AmountProvider as A}from"../../../core/Context/AmountProvider.js";function g(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function E(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},n=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(s).filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),n.forEach(function(t){g(e,t,s[t])})}return e}function w(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t.push.apply(t,s)}return t}(Object(t)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(t,s))}),e}class S extends o{createBeforeRenderHook(e){const t=this.render;this.render=(...s)=>(this.beforeRender(e),t.apply(this,s))}beforeRender(e){if(null==e?void 0:e.originalAction)return;const t=new u(E({type:y.rendered,component:this.type,configData:w(E({},e),{showPayButton:this.props.showPayButton})},(null==e?void 0:e.oneClick)&&{isStoredPaymentMethod:!0}));this.analytics.sendAnalytics(t)}reportIntegrationFlavor(){this.analytics.sendFlavor("components")}get analytics(){return this.core.modules.analytics}get srPanel(){return this.core.modules.srPanel}getPaymentMethodConfigFromResponse(e){return(null==e?void 0:e.storedPaymentMethodId)?this.getStoredPaymentMethodDetails(e.storedPaymentMethodId):this.getPaymentMethodFromPaymentMethodsResponse(null==e?void 0:e.type,null==e?void 0:e.paymentMethodId)}buildElementProps(e){const t=E({showPayButton:!0},this.core.getCorePropsForComponent(),this.getPaymentMethodConfigFromResponse(e),e),s=a(this);this.props=this.formatProps(E({},this.constructor.defaultProps,l(this.core.options.countryCode,s),t))}getStoredPaymentMethodDetails(e){return this.core.paymentMethodsResponse.findStoredPaymentMethod(e)}getPaymentMethodFromPaymentMethodsResponse(e,t){var s;return t?this.core.paymentMethodsResponse.findById(t):null===(s=this.core.paymentMethodsResponse)||void 0===s?void 0:s.find(e||this.constructor.type)}storeElementRefOnCore(e){(null==e?void 0:e.isDropin)||this.core.storeElementReference(this)}isAvailable(){return Promise.resolve()}setState(e){this.state=E({},this.state,e),this.onChange()}showValidation(){return this.componentRef&&this.componentRef.showValidation&&this.componentRef.showValidation(),this}updateAmount(e,t){var s;this.props=E({},this.props,e&&{amount:e},t&&{secondaryAmount:t}),null===(s=this.amountProviderRef.current)||void 0===s||s.update(e,t)}setElementStatus(e,t){var s;return null===(s=this.elementRef)||void 0===s||s.setStatus(e,t),this}setStatus(e,t){var s;return(null===(s=this.componentRef)||void 0===s?void 0:s.setStatus)&&this.componentRef.setStatus(e,t),this}onChange(){var e,t;null===(e=(t=this.props).onChange)||void 0===e||e.call(t,{data:this.data,isValid:this.isValid,errors:this.state.errors,valid:this.state.valid},this.elementRef)}submitAnalytics(e){this.analytics.sendAnalytics(e)}submit(){this.isValid?this.makePaymentsCall().then(h).then(d).then(this.handleResponse).catch(e=>{e instanceof b?this.setElementStatus("ready"):this.handleFailedResult(e)}):this.showValidation()}makePaymentsCall(){if(this.setElementStatus("loading"),this.props.onSubmit)return this.submitUsingAdvancedFlow();if(this.core.session){return(this.props.beforeSubmit?new Promise((e,t)=>{this.props.beforeSubmit(this.data,this.elementRef,{resolve:e,reject:()=>t(new b("beforeSubmitRejected"))})}):Promise.resolve(this.data)).then(this.submitUsingSessionsFlow)}this.handleError(new s("IMPLEMENTATION_ERROR",'It can not perform /payments call. Callback "onSubmit" is missing or Checkout session is not available'))}async submitUsingAdvancedFlow(){const e=new f({component:this.type,type:v.submit,message:"Shopper clicked pay"});return this.submitAnalytics(e),new Promise((e,t)=>{this.props.onSubmit({data:this.data,isValid:this.isValid},this.elementRef,{resolve:e,reject:t})})}async submitUsingSessionsFlow(e){const t=new f({component:this.type,type:v.submit,message:"Shopper clicked pay"});this.submitAnalytics(t);try{return await this.core.session.submitPayment(e)}catch(e){return e instanceof s?this.handleError(e):this.handleError(new s("ERROR","Error when making /payments call",{cause:e})),Promise.reject(e)}}onComplete(e){this.handleAdditionalDetails(e)}handleAdditionalDetails(e){this.makeAdditionalDetailsCall(e).then(h).then(d).then(this.handleResponse).catch(this.handleFailedResult)}makeAdditionalDetailsCall(e){return this.props.onAdditionalDetails?new Promise((t,s)=>{this.props.onAdditionalDetails(e,this.elementRef,{resolve:t,reject:s})}):this.core.session?this.submitAdditionalDetailsUsingSessionsFlow(e.data):void this.handleError(new s("IMPLEMENTATION_ERROR",'It can not perform /payments/details call. Callback "onAdditionalDetails" is missing or Checkout session is not available'))}async submitAdditionalDetailsUsingSessionsFlow(e){try{return await this.core.session.submitDetails(e)}catch(e){return e instanceof s?this.handleError(e):this.handleError(new s("ERROR","Error when making /details call",{cause:e})),Promise.reject(e)}}handleAction(e,t={}){if(!e||!e.type){if(i(e,"action")&&i(e,"resultCode"))throw new Error('handleAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('handleAction::Invalid Action - the passed action object does not have a "type" property')}const s=this.core.createFromAction(e,E({},this.elementRef.props,t));return s?(this.unmount(),s.mount(this._node)):null}onActionHandled(e){var t,s;null===(s=this.props)||void 0===s||null===(t=s.onActionHandled)||void 0===t||t.call(s,E({originalAction:this.props.originalAction},e))}handleResponse(e){var t,s;e.action?this.elementRef.handleAction(e.action):(null===(s=e.order)||void 0===s||null===(t=s.remainingAmount)||void 0===t?void 0:t.value)>0?this.handleOrder(e):this.handleSuccessResult(e)}handleKeyPress(e){var t;"Enter"!==e.key&&"Enter"!==e.code||(e.preventDefault(),this.onEnterKeyPressed(null===(t=document)||void 0===t?void 0:t.activeElement,this))}onEnterKeyPressed(e,t){this.props.onEnterKeyPressed?this.props.onEnterKeyPressed(e,t):(e.blur(),this.submit())}updateParent(e={}){return this.elementRef.core.update(e)}get isValid(){return!1}get icon(){var e;const t=this.props.paymentMethodType||this.type;return null!==(e=this.props.icon)&&void 0!==e?e:this.resources.getImage()(t)}get displayName(){var e,t;const s=null===(t=this.core.paymentMethodsResponse)||void 0===t||null===(e=t.paymentMethods)||void 0===e?void 0:e.find(e=>e.type===this.type);return this.props.name||(null==s?void 0:s.name)||this.type}get accessibleName(){return this.displayName}get additionalInfo(){return null}get type(){return this.props.type||this.constructor.type}async handleAdvanceFlowPaymentMethodsUpdate(e,t){return new Promise((t,s)=>{if(!this.props.onPaymentMethodsRequest)return t();this.props.onPaymentMethodsRequest(w(E({},e&&{order:{orderData:e.orderData,pspReference:e.pspReference}}),{locale:this.core.options.locale}),{resolve:t,reject:s})}).catch(e=>{this.handleError(new s("IMPLEMENTATION_ERROR","Something failed during payment methods update or onPaymentMethodsRequest was not implemented",{cause:e}))}).then(s=>this.core.update(w(E({},s&&{paymentMethodsResponse:s}),{order:e,amount:e?e.remainingAmount:t})))}render(){return e(R,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources,analytics:this.analytics},e(P,{srPanel:this.srPanel},e(A,{amount:this.props.amount,secondaryAmount:this.props.secondaryAmount,providerRef:this.amountProviderRef},this.componentToRender())))}constructor(s,i){super(s,i),g(this,"componentRef",void 0),g(this,"resources",void 0),g(this,"elementRef",void 0),g(this,"amountProviderRef",t()),g(this,"handleError",e=>{if(this.setElementStatus("ready"),e.name===n&&e.options.code){const t=new p({component:this.type,errorType:m.apiError,code:e.options.code});this.submitAnalytics(t)}this.props.onError&&this.props.onError(e,this.elementRef)}),g(this,"handleOrder",e=>{const{order:t}=e;(this.core.session?this.core.update({order:t}):this.handleAdvanceFlowPaymentMethodsUpdate(t)).then(()=>{var e,s;null===(e=(s=this.props).onOrderUpdated)||void 0===e||e.call(s,{order:t})})}),g(this,"handleFailedResult",e=>{var t,s;a(this.elementRef)&&this.elementRef.displayFinalAnimation("error"),c(e),null===(t=(s=this.props).onPaymentFailed)||void 0===t||t.call(s,e,this.elementRef)}),g(this,"handleSuccessResult",e=>{var t,s;a(this.elementRef)&&this.elementRef.displayFinalAnimation("success"),c(e),null===(t=(s=this.props).onPaymentCompleted)||void 0===t||t.call(s,e,this.elementRef)}),g(this,"setComponentRef",e=>{this.componentRef=e}),g(this,"payButton",t=>e(r,w(E({},t),{onClick:this.submit}))),this.core.register(this.constructor),this.submit=this.submit.bind(this),this.setState=this.setState.bind(this),this.onComplete=this.onComplete.bind(this),this.handleAction=this.handleAction.bind(this),this.handleOrder=this.handleOrder.bind(this),this.handleAdditionalDetails=this.handleAdditionalDetails.bind(this),this.handleResponse=this.handleResponse.bind(this),this.setElementStatus=this.setElementStatus.bind(this),this.submitAnalytics=this.submitAnalytics.bind(this),this.makePaymentsCall=this.makePaymentsCall.bind(this),this.makeAdditionalDetailsCall=this.makeAdditionalDetailsCall.bind(this),this.submitUsingSessionsFlow=this.submitUsingSessionsFlow.bind(this),this.updateAmount=this.updateAmount.bind(this),this.elementRef=i&&i.elementRef||this,this.resources=this.props.modules?this.props.modules.resources:void 0,this.storeElementRefOnCore(this.props),this.onEnterKeyPressed=this.onEnterKeyPressed.bind(this),this.onActionHandled=this.onActionHandled.bind(this),this.createBeforeRenderHook(i),this.reportIntegrationFlavor()}}g(S,"type",void 0),g(S,"txVariants",[]);export{S as UIElement,S as default};
1
+ import{createElement as e,createRef as t}from"../../../external/preact/dist/preact.js";import s,{NETWORK_ERROR as n}from"../../../core/Errors/AdyenCheckoutError.js";import{hasOwnProperty as o}from"../../../utils/hasOwnProperty.js";import i from"../BaseElement/BaseElement.js";import r from"../PayButton/PayButton.js";import{assertIsDropin as a,getRegulatoryDefaults as l,sanitizeResponse as h,verifyPaymentDidNotFail as d,cleanupFinalResult as c}from"./utils.js";import{AnalyticsErrorEvent as p,ErrorEventType as m}from"../../../core/Analytics/events/AnalyticsErrorEvent.js";import{AnalyticsInfoEvent as u,InfoEventType as y}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";import{AnalyticsLogEvent as f,LogEventType as v}from"../../../core/Analytics/events/AnalyticsLogEvent.js";import b from"../../../core/Errors/CancelError.js";import{CoreProvider as R}from"../../../core/Context/CoreProvider.js";import P from"../../../core/Errors/SRPanelProvider.js";import{AmountProvider as A}from"../../../core/Context/AmountProvider.js";import{TxVariants as g}from"../../tx-variants.js";function E(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function w(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},n=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(s).filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),n.forEach(function(t){E(e,t,s[t])})}return e}function S(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t.push.apply(t,s)}return t}(Object(t)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(t,s))}),e}class C extends i{createBeforeRenderHook(e){const t=this.render;this.render=(...s)=>(this.beforeRender(e),t.apply(this,s))}beforeRender(e){if(null==e?void 0:e.originalAction)return;const t=new u(w({type:y.rendered,component:this.type,configData:S(w({},e),{showPayButton:this.props.showPayButton})},(null==e?void 0:e.oneClick)&&{isStoredPaymentMethod:!0}));this.analytics.sendAnalytics(t)}reportIntegrationFlavor(){this.analytics.sendFlavor("components")}get analytics(){return this.core.modules.analytics}get srPanel(){return this.core.modules.srPanel}getPaymentMethodConfigFromResponse(e){return(null==e?void 0:e.storedPaymentMethodId)?this.getStoredPaymentMethodDetails(e.storedPaymentMethodId):this.getPaymentMethodFromPaymentMethodsResponse(null==e?void 0:e.type,null==e?void 0:e.paymentMethodId)}buildElementProps(e){const t=w({showPayButton:!0},this.core.getCorePropsForComponent(),this.getPaymentMethodConfigFromResponse(e),e),s=a(this);this.props=this.formatProps(w({},this.constructor.defaultProps,l(this.core.options.countryCode,s),t))}getStoredPaymentMethodDetails(e){return this.core.paymentMethodsResponse.findStoredPaymentMethod(e)}getPaymentMethodFromPaymentMethodsResponse(e,t){var s;return t?this.core.paymentMethodsResponse.findById(t):null===(s=this.core.paymentMethodsResponse)||void 0===s?void 0:s.find(e||this.constructor.type)}storeElementRefOnCore(e){(null==e?void 0:e.isDropin)||this.core.storeElementReference(this)}isAvailable(){return Promise.resolve()}setState(e){this.state=w({},this.state,e),this.onChange()}showValidation(){return this.componentRef&&this.componentRef.showValidation&&this.componentRef.showValidation(),this}updateAmount(e,t){var s;this.props=w({},this.props,e&&{amount:e},t&&{secondaryAmount:t}),null===(s=this.amountProviderRef.current)||void 0===s||s.update(e,t)}setElementStatus(e,t){var s;return null===(s=this.elementRef)||void 0===s||s.setStatus(e,t),this}setStatus(e,t){var s;return(null===(s=this.componentRef)||void 0===s?void 0:s.setStatus)&&this.componentRef.setStatus(e,t),this}onChange(){var e,t;null===(e=(t=this.props).onChange)||void 0===e||e.call(t,{data:this.data,isValid:this.isValid,errors:this.state.errors,valid:this.state.valid},this.elementRef)}submitAnalytics(e){this.analytics.sendAnalytics(e)}submit(){this.isValid?this.makePaymentsCall().then(h).then(d).then(this.handleResponse).catch(e=>{e instanceof b?this.setElementStatus("ready"):this.handleFailedResult(e)}):this.showValidation()}makePaymentsCall(){if(this.setElementStatus("loading"),this.props.onSubmit)return this.submitUsingAdvancedFlow();if(this.core.session){return(this.props.beforeSubmit?new Promise((e,t)=>{this.props.beforeSubmit(this.data,this.elementRef,{resolve:e,reject:()=>t(new b("beforeSubmitRejected"))})}):Promise.resolve(this.data)).then(this.submitUsingSessionsFlow)}this.handleError(new s("IMPLEMENTATION_ERROR",'It can not perform /payments call. Callback "onSubmit" is missing or Checkout session is not available'))}async submitUsingAdvancedFlow(){const e=new f({component:this.type,type:v.submit,message:"Shopper clicked pay"});return this.submitAnalytics(e),new Promise((e,t)=>{this.props.onSubmit({data:this.data,isValid:this.isValid},this.elementRef,{resolve:e,reject:t})})}async submitUsingSessionsFlow(e){const t=new f({component:this.type,type:v.submit,message:"Shopper clicked pay"});this.submitAnalytics(t);try{return await this.core.session.submitPayment(e)}catch(e){return e instanceof s?this.handleError(e):this.handleError(new s("ERROR","Error when making /payments call",{cause:e})),Promise.reject(e)}}onComplete(e){this.handleAdditionalDetails(e)}handleAdditionalDetails(e){this.makeAdditionalDetailsCall(e).then(h).then(d).then(this.handleResponse).catch(this.handleFailedResult)}makeAdditionalDetailsCall(e){return this.props.onAdditionalDetails?new Promise((t,s)=>{this.props.onAdditionalDetails(e,this.elementRef,{resolve:t,reject:s})}):this.core.session?this.submitAdditionalDetailsUsingSessionsFlow(e.data):void this.handleError(new s("IMPLEMENTATION_ERROR",'It can not perform /payments/details call. Callback "onAdditionalDetails" is missing or Checkout session is not available'))}async submitAdditionalDetailsUsingSessionsFlow(e){try{return await this.core.session.submitDetails(e)}catch(e){return e instanceof s?this.handleError(e):this.handleError(new s("ERROR","Error when making /details call",{cause:e})),Promise.reject(e)}}handleAction(e,t={}){if(!e||!e.type){if(o(e,"action")&&o(e,"resultCode"))throw new Error('handleAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('handleAction::Invalid Action - the passed action object does not have a "type" property')}const s=this.core.createFromAction(e,w({},this.elementRef.props,t));return s?(this.unmount(),s.mount(this._node)):null}onActionHandled(e){var t,s;null===(s=this.props)||void 0===s||null===(t=s.onActionHandled)||void 0===t||t.call(s,w({originalAction:this.props.originalAction},e))}setupSessionsDonation(){const{amount:e,donation:t}=this.props;if(!1!==(null==t?void 0:t.autoMount)){const t=a(this.elementRef)?this.elementRef._node:this._node;new(this.core.getComponent(g.donation))(this.core,{rootNode:t,commercialTxAmount:e.value})}}handleResponse(e){var t,s;e.action?this.elementRef.handleAction(e.action):(null===(s=e.order)||void 0===s||null===(t=s.remainingAmount)||void 0===t?void 0:t.value)>0?this.handleOrder(e):this.handleSuccessResult(e)}handleKeyPress(e){var t;"Enter"!==e.key&&"Enter"!==e.code||(e.preventDefault(),this.onEnterKeyPressed(null===(t=document)||void 0===t?void 0:t.activeElement,this))}onEnterKeyPressed(e,t){this.props.onEnterKeyPressed?this.props.onEnterKeyPressed(e,t):(e.blur(),this.submit())}updateParent(e={}){return this.elementRef.core.update(e)}get isValid(){return!1}get icon(){var e;const t=this.props.paymentMethodType||this.type;return null!==(e=this.props.icon)&&void 0!==e?e:this.resources.getImage()(t)}get displayName(){var e,t;const s=null===(t=this.core.paymentMethodsResponse)||void 0===t||null===(e=t.paymentMethods)||void 0===e?void 0:e.find(e=>e.type===this.type);return this.props.name||(null==s?void 0:s.name)||this.type}get accessibleName(){return this.displayName}get additionalInfo(){return null}get type(){return this.props.type||this.constructor.type}async handleAdvanceFlowPaymentMethodsUpdate(e,t){return new Promise((t,s)=>{if(!this.props.onPaymentMethodsRequest)return t();this.props.onPaymentMethodsRequest(S(w({},e&&{order:{orderData:e.orderData,pspReference:e.pspReference}}),{locale:this.core.options.locale}),{resolve:t,reject:s})}).catch(e=>{this.handleError(new s("IMPLEMENTATION_ERROR","Something failed during payment methods update or onPaymentMethodsRequest was not implemented",{cause:e}))}).then(s=>this.core.update(S(w({},s&&{paymentMethodsResponse:s}),{order:e,amount:e?e.remainingAmount:t})))}render(){return e(R,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources,analytics:this.analytics},e(P,{srPanel:this.srPanel},e(A,{amount:this.props.amount,secondaryAmount:this.props.secondaryAmount,providerRef:this.amountProviderRef},this.componentToRender())))}constructor(s,o){super(s,o),E(this,"componentRef",void 0),E(this,"resources",void 0),E(this,"elementRef",void 0),E(this,"amountProviderRef",t()),E(this,"handleError",e=>{if(this.setElementStatus("ready"),e.name===n&&e.options.code){const t=new p({component:this.type,errorType:m.apiError,code:e.options.code});this.submitAnalytics(t)}this.props.onError&&this.props.onError(e,this.elementRef)}),E(this,"handleOrder",e=>{const{order:t}=e;(this.core.session?this.core.update({order:t}):this.handleAdvanceFlowPaymentMethodsUpdate(t)).then(()=>{var e,s;null===(e=(s=this.props).onOrderUpdated)||void 0===e||e.call(s,{order:t})})}),E(this,"handleFailedResult",e=>{var t,s;a(this.elementRef)&&this.elementRef.displayFinalAnimation("error"),c(e),null===(t=(s=this.props).onPaymentFailed)||void 0===t||t.call(s,e,this.elementRef)}),E(this,"handleSuccessResult",e=>{var t,s;a(this.elementRef)&&this.elementRef.displayFinalAnimation("success"),c(e),this.core.session&&!0===e.askDonation&&this.setupSessionsDonation(),null===(t=(s=this.props).onPaymentCompleted)||void 0===t||t.call(s,e,this.elementRef)}),E(this,"setComponentRef",e=>{this.componentRef=e}),E(this,"payButton",t=>e(r,S(w({},t),{onClick:this.submit}))),this.core.register(this.constructor),this.submit=this.submit.bind(this),this.setState=this.setState.bind(this),this.onComplete=this.onComplete.bind(this),this.handleAction=this.handleAction.bind(this),this.handleOrder=this.handleOrder.bind(this),this.handleAdditionalDetails=this.handleAdditionalDetails.bind(this),this.handleResponse=this.handleResponse.bind(this),this.setElementStatus=this.setElementStatus.bind(this),this.submitAnalytics=this.submitAnalytics.bind(this),this.makePaymentsCall=this.makePaymentsCall.bind(this),this.makeAdditionalDetailsCall=this.makeAdditionalDetailsCall.bind(this),this.submitUsingSessionsFlow=this.submitUsingSessionsFlow.bind(this),this.updateAmount=this.updateAmount.bind(this),this.setupSessionsDonation=this.setupSessionsDonation.bind(this),this.elementRef=o&&o.elementRef||this,this.resources=this.props.modules?this.props.modules.resources:void 0,this.storeElementRefOnCore(this.props),this.onEnterKeyPressed=this.onEnterKeyPressed.bind(this),this.onActionHandled=this.onActionHandled.bind(this),this.createBeforeRenderHook(o),this.reportIntegrationFlavor()}}E(C,"type",void 0),E(C,"txVariants",[]);export{C as UIElement,C as default};
2
2
  //# sourceMappingURL=UIElement.js.map