@adyen/adyen-web 6.4.0 → 6.5.1

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 (348) hide show
  1. package/README.md +16 -5
  2. package/dist/cjs/adyen.css +7 -3
  3. package/dist/cjs/adyen.css.map +1 -1
  4. package/dist/cjs/index.cjs +2 -2
  5. package/dist/cjs/index.cjs.map +1 -1
  6. package/dist/cjs/index.d.cts +27 -19
  7. package/dist/es/adyen.css +7 -3
  8. package/dist/es/adyen.css.map +1 -1
  9. package/dist/es/components/ANCV/ANCV.js +1 -1
  10. package/dist/es/components/ANCV/ANCV.js.map +1 -1
  11. package/dist/es/components/Ach/Ach.js +1 -1
  12. package/dist/es/components/Ach/Ach.js.map +1 -1
  13. package/dist/es/components/Address/Address.js +1 -1
  14. package/dist/es/components/Address/Address.js.map +1 -1
  15. package/dist/es/components/Affirm/Affirm.js +1 -1
  16. package/dist/es/components/Affirm/Affirm.js.map +1 -1
  17. package/dist/es/components/AfterPay/AfterPay.js +1 -1
  18. package/dist/es/components/AfterPay/AfterPay.js.map +1 -1
  19. package/dist/es/components/AfterPay/AfterPayB2B.js +1 -1
  20. package/dist/es/components/AfterPay/AfterPayB2B.js.map +1 -1
  21. package/dist/es/components/AmazonPay/AmazonPay.js +1 -1
  22. package/dist/es/components/AmazonPay/AmazonPay.js.map +1 -1
  23. package/dist/es/components/ApplePay/ApplePay.js +1 -1
  24. package/dist/es/components/ApplePay/ApplePay.js.map +1 -1
  25. package/dist/es/components/ApplePay/ApplePayService.js +1 -1
  26. package/dist/es/components/ApplePay/ApplePayService.js.map +1 -1
  27. package/dist/es/components/ApplePay/components/ApplePayButton.js +1 -1
  28. package/dist/es/components/ApplePay/components/ApplePayButton.js.map +1 -1
  29. package/dist/es/components/Atome/Atome.js +1 -1
  30. package/dist/es/components/Atome/Atome.js.map +1 -1
  31. package/dist/es/components/BacsDD/BacsDD.js +1 -1
  32. package/dist/es/components/BacsDD/BacsDD.js.map +1 -1
  33. package/dist/es/components/BankTransfer/BankTransfer.js +1 -1
  34. package/dist/es/components/BankTransfer/BankTransfer.js.map +1 -1
  35. package/dist/es/components/BcmcMobile/BcmcMobile.js +1 -1
  36. package/dist/es/components/BcmcMobile/BcmcMobile.js.map +1 -1
  37. package/dist/es/components/BillDesk/BillDeskOnline.js +1 -1
  38. package/dist/es/components/BillDesk/BillDeskOnline.js.map +1 -1
  39. package/dist/es/components/BillDesk/BillDeskWallet.js +1 -1
  40. package/dist/es/components/BillDesk/BillDeskWallet.js.map +1 -1
  41. package/dist/es/components/Blik/Blik.js +1 -1
  42. package/dist/es/components/Blik/Blik.js.map +1 -1
  43. package/dist/es/components/Boleto/Boleto.js +1 -1
  44. package/dist/es/components/Boleto/Boleto.js.map +1 -1
  45. package/dist/es/components/Card/Bancontact.js +1 -1
  46. package/dist/es/components/Card/Bancontact.js.map +1 -1
  47. package/dist/es/components/Card/Card.js +1 -1
  48. package/dist/es/components/Card/Card.js.map +1 -1
  49. package/dist/es/components/Card/components/CardInput/components/CVCHint.js.map +1 -1
  50. package/dist/es/components/CashAppPay/CashAppPay.js +1 -1
  51. package/dist/es/components/CashAppPay/CashAppPay.js.map +1 -1
  52. package/dist/es/components/CashAppPay/services/CashAppService.js +1 -1
  53. package/dist/es/components/CashAppPay/services/CashAppService.js.map +1 -1
  54. package/dist/es/components/ClickToPay/ClickToPay.js +1 -1
  55. package/dist/es/components/ClickToPay/ClickToPay.js.map +1 -1
  56. package/dist/es/components/CustomCard/CustomCard.js +1 -1
  57. package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
  58. package/dist/es/components/Doku/Doku.js +1 -1
  59. package/dist/es/components/Doku/Doku.js.map +1 -1
  60. package/dist/es/components/Donation/Donation.js +1 -1
  61. package/dist/es/components/Donation/Donation.js.map +1 -1
  62. package/dist/es/components/Dotpay/index.js +1 -1
  63. package/dist/es/components/Dotpay/index.js.map +1 -1
  64. package/dist/es/components/Dragonpay/Dragonpay.js +1 -1
  65. package/dist/es/components/Dragonpay/Dragonpay.js.map +1 -1
  66. package/dist/es/components/Dropin/Dropin.js +1 -1
  67. package/dist/es/components/Dropin/Dropin.js.map +1 -1
  68. package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
  69. package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
  70. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
  71. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  72. package/dist/es/components/DuitNow/DuitNow.js +1 -1
  73. package/dist/es/components/DuitNow/DuitNow.js.map +1 -1
  74. package/dist/es/components/EPS/index.js +1 -1
  75. package/dist/es/components/EPS/index.js.map +1 -1
  76. package/dist/es/components/Econtext/Econtext.js +1 -1
  77. package/dist/es/components/Econtext/Econtext.js.map +1 -1
  78. package/dist/es/components/FacilyPay/FacilyPay10x.js +1 -1
  79. package/dist/es/components/FacilyPay/FacilyPay10x.js.map +1 -1
  80. package/dist/es/components/FacilyPay/FacilyPay12x.js +1 -1
  81. package/dist/es/components/FacilyPay/FacilyPay12x.js.map +1 -1
  82. package/dist/es/components/FacilyPay/FacilyPay3x.js +1 -1
  83. package/dist/es/components/FacilyPay/FacilyPay3x.js.map +1 -1
  84. package/dist/es/components/FacilyPay/FacilyPay4x.js +1 -1
  85. package/dist/es/components/FacilyPay/FacilyPay4x.js.map +1 -1
  86. package/dist/es/components/FacilyPay/FacilyPay6x.js +1 -1
  87. package/dist/es/components/FacilyPay/FacilyPay6x.js.map +1 -1
  88. package/dist/es/components/Giftcard/Giftcard.js +1 -1
  89. package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
  90. package/dist/es/components/Giftcard/components/GiftcardComponent.js +1 -1
  91. package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  92. package/dist/es/components/Giropay/Giropay.js +1 -1
  93. package/dist/es/components/Giropay/Giropay.js.map +1 -1
  94. package/dist/es/components/GooglePay/GooglePay.js +1 -1
  95. package/dist/es/components/GooglePay/GooglePay.js.map +1 -1
  96. package/dist/es/components/GooglePay/GooglePayService.js +1 -1
  97. package/dist/es/components/GooglePay/GooglePayService.js.map +1 -1
  98. package/dist/es/components/Klarna/KlarnaPayments.js +1 -1
  99. package/dist/es/components/Klarna/KlarnaPayments.js.map +1 -1
  100. package/dist/es/components/MBWay/MBWay.js +1 -1
  101. package/dist/es/components/MBWay/MBWay.js.map +1 -1
  102. package/dist/es/components/MealVoucherFR/MealVoucherFR.js +1 -1
  103. package/dist/es/components/MealVoucherFR/MealVoucherFR.js.map +1 -1
  104. package/dist/es/components/MolPayEBanking/MolPayEBankingMY.js +1 -1
  105. package/dist/es/components/MolPayEBanking/MolPayEBankingMY.js.map +1 -1
  106. package/dist/es/components/MolPayEBanking/MolPayEBankingTH.js +1 -1
  107. package/dist/es/components/MolPayEBanking/MolPayEBankingTH.js.map +1 -1
  108. package/dist/es/components/MolPayEBanking/MolPayEBankingVN.js +1 -1
  109. package/dist/es/components/MolPayEBanking/MolPayEBankingVN.js.map +1 -1
  110. package/dist/es/components/Multibanco/Multibanco.js +1 -1
  111. package/dist/es/components/Multibanco/Multibanco.js.map +1 -1
  112. package/dist/es/components/OnlineBankingCZ/index.js +1 -1
  113. package/dist/es/components/OnlineBankingCZ/index.js.map +1 -1
  114. package/dist/es/components/OnlineBankingFI/OnlineBankingFI.js +1 -1
  115. package/dist/es/components/OnlineBankingFI/OnlineBankingFI.js.map +1 -1
  116. package/dist/es/components/OnlineBankingIN/index.js +1 -1
  117. package/dist/es/components/OnlineBankingIN/index.js.map +1 -1
  118. package/dist/es/components/OnlineBankingPL/OnlineBankingPL.js +1 -1
  119. package/dist/es/components/OnlineBankingPL/OnlineBankingPL.js.map +1 -1
  120. package/dist/es/components/OnlineBankingSK/index.js +1 -1
  121. package/dist/es/components/OnlineBankingSK/index.js.map +1 -1
  122. package/dist/es/components/Oxxo/Oxxo.js +1 -1
  123. package/dist/es/components/Oxxo/Oxxo.js.map +1 -1
  124. package/dist/es/components/PayByBank/PayByBank.js +1 -1
  125. package/dist/es/components/PayByBank/PayByBank.js.map +1 -1
  126. package/dist/es/components/PayByBankUS/PayByBankUS.js +1 -1
  127. package/dist/es/components/PayByBankUS/PayByBankUS.js.map +1 -1
  128. package/dist/es/components/PayMe/PayMe.js +1 -1
  129. package/dist/es/components/PayMe/PayMe.js.map +1 -1
  130. package/dist/es/components/PayMe/components/PayMeInstructions.js +2 -0
  131. package/dist/es/components/PayMe/components/PayMeInstructions.js.map +1 -0
  132. package/dist/es/components/PayMe/components/PayMeIntroduction.js +2 -0
  133. package/dist/es/components/PayMe/components/PayMeIntroduction.js.map +1 -0
  134. package/dist/es/components/PayNow/PayNow.js +1 -1
  135. package/dist/es/components/PayNow/PayNow.js.map +1 -1
  136. package/dist/es/components/PayNow/components/PayNowInstructions.js +2 -0
  137. package/dist/es/components/PayNow/components/PayNowInstructions.js.map +1 -0
  138. package/dist/es/components/PayNow/components/PayNowIntroduction.js +2 -0
  139. package/dist/es/components/PayNow/components/PayNowIntroduction.js.map +1 -0
  140. package/dist/es/components/PayPal/Paypal.js +1 -1
  141. package/dist/es/components/PayPal/Paypal.js.map +1 -1
  142. package/dist/es/components/PayU/PayuCashcard.js +1 -1
  143. package/dist/es/components/PayU/PayuCashcard.js.map +1 -1
  144. package/dist/es/components/PayU/PayuNetBanking.js +1 -1
  145. package/dist/es/components/PayU/PayuNetBanking.js.map +1 -1
  146. package/dist/es/components/PersonalDetails/PersonalDetails.js +1 -1
  147. package/dist/es/components/PersonalDetails/PersonalDetails.js.map +1 -1
  148. package/dist/es/components/Pix/Pix.js +1 -1
  149. package/dist/es/components/Pix/Pix.js.map +1 -1
  150. package/dist/es/components/PromptPay/PromptPay.js +1 -1
  151. package/dist/es/components/PromptPay/PromptPay.js.map +1 -1
  152. package/dist/es/components/RatePay/RatePay.js +1 -1
  153. package/dist/es/components/RatePay/RatePay.js.map +1 -1
  154. package/dist/es/components/RatePay/RatePayDirectDebit.js +1 -1
  155. package/dist/es/components/RatePay/RatePayDirectDebit.js.map +1 -1
  156. package/dist/es/components/Redirect/Redirect.js +1 -1
  157. package/dist/es/components/Redirect/Redirect.js.map +1 -1
  158. package/dist/es/components/Redirect/components/RedirectShopper/RedirectShopper.js +1 -1
  159. package/dist/es/components/Redirect/components/RedirectShopper/RedirectShopper.js.map +1 -1
  160. package/dist/es/components/Riverty/Riverty.js +1 -1
  161. package/dist/es/components/Riverty/Riverty.js.map +1 -1
  162. package/dist/es/components/Sepa/Sepa.js +1 -1
  163. package/dist/es/components/Sepa/Sepa.js.map +1 -1
  164. package/dist/es/components/Swish/Swish.js +1 -1
  165. package/dist/es/components/Swish/Swish.js.map +1 -1
  166. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  167. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  168. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  169. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  170. package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js +1 -1
  171. package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
  172. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  173. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  174. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js +1 -1
  175. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js.map +1 -1
  176. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  177. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  178. package/dist/es/components/ThreeDS2/components/Form/ThreeDS2Form.js +1 -1
  179. package/dist/es/components/ThreeDS2/components/Form/ThreeDS2Form.js.map +1 -1
  180. package/dist/es/components/Trustly/Trustly.js +1 -1
  181. package/dist/es/components/Trustly/Trustly.js.map +1 -1
  182. package/dist/es/components/Twint/Twint.js +1 -1
  183. package/dist/es/components/Twint/Twint.js.map +1 -1
  184. package/dist/es/components/UPI/UPI.js +1 -1
  185. package/dist/es/components/UPI/UPI.js.map +1 -1
  186. package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
  187. package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
  188. package/dist/es/components/Vipps/Vipps.js +1 -1
  189. package/dist/es/components/Vipps/Vipps.js.map +1 -1
  190. package/dist/es/components/WalletIN/index.js +1 -1
  191. package/dist/es/components/WalletIN/index.js.map +1 -1
  192. package/dist/es/components/WeChat/WeChat.js +1 -1
  193. package/dist/es/components/WeChat/WeChat.js.map +1 -1
  194. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
  195. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  196. package/dist/es/components/helpers/OpenInvoiceContainer/OpenInvoiceContainer.js +1 -1
  197. package/dist/es/components/helpers/OpenInvoiceContainer/OpenInvoiceContainer.js.map +1 -1
  198. package/dist/es/components/helpers/QRLoaderContainer/QRLoaderContainer.js +1 -1
  199. package/dist/es/components/helpers/QRLoaderContainer/QRLoaderContainer.js.map +1 -1
  200. package/dist/es/components/internal/Address/Address.js +1 -1
  201. package/dist/es/components/internal/Address/Address.js.map +1 -1
  202. package/dist/es/components/internal/Address/Specifications.js +1 -1
  203. package/dist/es/components/internal/Address/Specifications.js.map +1 -1
  204. package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
  205. package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
  206. package/dist/es/components/internal/Button/Button.js +1 -1
  207. package/dist/es/components/internal/Button/Button.js.map +1 -1
  208. package/dist/es/components/internal/ClickToPay/errors/TimeoutError.js +1 -1
  209. package/dist/es/components/internal/ClickToPay/errors/TimeoutError.js.map +1 -1
  210. package/dist/es/components/internal/ClickToPay/models/ShopperCard.js +1 -1
  211. package/dist/es/components/internal/ClickToPay/models/ShopperCard.js.map +1 -1
  212. package/dist/es/components/internal/ClickToPay/services/ClickToPayService.js +1 -1
  213. package/dist/es/components/internal/ClickToPay/services/ClickToPayService.js.map +1 -1
  214. package/dist/es/components/internal/ClickToPay/services/sdks/AbstractSrcInitiator.js +1 -1
  215. package/dist/es/components/internal/ClickToPay/services/sdks/AbstractSrcInitiator.js.map +1 -1
  216. package/dist/es/components/internal/ClickToPay/services/sdks/MastercardSdk.js +1 -1
  217. package/dist/es/components/internal/ClickToPay/services/sdks/MastercardSdk.js.map +1 -1
  218. package/dist/es/components/internal/ClickToPay/services/sdks/SrcSdkLoader.js +1 -1
  219. package/dist/es/components/internal/ClickToPay/services/sdks/SrcSdkLoader.js.map +1 -1
  220. package/dist/es/components/internal/ClickToPay/services/sdks/SrciError.js +1 -1
  221. package/dist/es/components/internal/ClickToPay/services/sdks/SrciError.js.map +1 -1
  222. package/dist/es/components/internal/ClickToPay/services/sdks/VisaSdk.js +1 -1
  223. package/dist/es/components/internal/ClickToPay/services/sdks/VisaSdk.js.map +1 -1
  224. package/dist/es/components/internal/Countdown/CountdownA11yReporter.js +1 -1
  225. package/dist/es/components/internal/Countdown/CountdownA11yReporter.js.map +1 -1
  226. package/dist/es/components/internal/FormFields/ConsentCheckbox/ConsentCheckbox.js +1 -1
  227. package/dist/es/components/internal/FormFields/ConsentCheckbox/ConsentCheckbox.js.map +1 -1
  228. package/dist/es/components/internal/IFrame/Iframe.js +1 -1
  229. package/dist/es/components/internal/IFrame/Iframe.js.map +1 -1
  230. package/dist/es/components/internal/IbanInput/IbanInput.js +1 -1
  231. package/dist/es/components/internal/IbanInput/IbanInput.js.map +1 -1
  232. package/dist/es/components/internal/QRLoader/QRLoader.js +1 -1
  233. package/dist/es/components/internal/QRLoader/QRLoader.js.map +1 -1
  234. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
  235. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  236. package/dist/es/components/internal/SecuredFields/lib/CSF/AbstractCSF.js +1 -1
  237. package/dist/es/components/internal/SecuredFields/lib/CSF/AbstractCSF.js.map +1 -1
  238. package/dist/es/components/internal/SecuredFields/lib/CSF/CSF.js +1 -1
  239. package/dist/es/components/internal/SecuredFields/lib/CSF/CSF.js.map +1 -1
  240. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js.map +1 -1
  241. package/dist/es/components/internal/SecuredFields/lib/CSF/utils/cardType.js.map +1 -1
  242. package/dist/es/components/internal/SecuredFields/lib/constants.js +1 -1
  243. package/dist/es/components/internal/SecuredFields/lib/constants.js.map +1 -1
  244. package/dist/es/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js +1 -1
  245. package/dist/es/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js.map +1 -1
  246. package/dist/es/components/internal/SecuredFields/lib/securedField/SecuredField.js +1 -1
  247. package/dist/es/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
  248. package/dist/es/components/internal/SecuredFields/lib/utilities/logger.js.map +1 -1
  249. package/dist/es/components/internal/Timeline/Timeline.js +2 -0
  250. package/dist/es/components/internal/Timeline/Timeline.js.map +1 -0
  251. package/dist/es/components/internal/Timeline/TimelineWrapper.js +2 -0
  252. package/dist/es/components/internal/Timeline/TimelineWrapper.js.map +1 -0
  253. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  254. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  255. package/dist/es/core/CheckoutSession/CheckoutSession.js +1 -1
  256. package/dist/es/core/CheckoutSession/CheckoutSession.js.map +1 -1
  257. package/dist/es/core/Context/Resources.js +1 -1
  258. package/dist/es/core/Context/Resources.js.map +1 -1
  259. package/dist/es/core/Errors/AdyenCheckoutError.js +1 -1
  260. package/dist/es/core/Errors/AdyenCheckoutError.js.map +1 -1
  261. package/dist/es/core/Errors/SRPanel.js +1 -1
  262. package/dist/es/core/Errors/SRPanel.js.map +1 -1
  263. package/dist/es/core/ProcessResponse/PaymentMethods/PaymentMethods.js +1 -1
  264. package/dist/es/core/ProcessResponse/PaymentMethods/PaymentMethods.js.map +1 -1
  265. package/dist/es/core/RiskModule/RiskModule.js +1 -1
  266. package/dist/es/core/RiskModule/RiskModule.js.map +1 -1
  267. package/dist/es/core/RiskModule/components/DeviceFingerprint/DeviceFingerprint.js +1 -1
  268. package/dist/es/core/RiskModule/components/DeviceFingerprint/DeviceFingerprint.js.map +1 -1
  269. package/dist/es/core/RiskModule/components/DeviceFingerprint/GetDeviceFingerprint.js +1 -1
  270. package/dist/es/core/RiskModule/components/DeviceFingerprint/GetDeviceFingerprint.js.map +1 -1
  271. package/dist/es/core/Services/analytics/collect-id.js +1 -1
  272. package/dist/es/core/core.js +1 -1
  273. package/dist/es/core/core.js.map +1 -1
  274. package/dist/es/core/core.registry.js +1 -1
  275. package/dist/es/core/core.registry.js.map +1 -1
  276. package/dist/es/index.d.ts +27 -19
  277. package/dist/es/language/Language.js +1 -1
  278. package/dist/es/language/Language.js.map +1 -1
  279. package/dist/es/utils/Script.js +1 -1
  280. package/dist/es/utils/Script.js.map +1 -1
  281. package/dist/es/utils/Storage.js +1 -1
  282. package/dist/es/utils/Storage.js.map +1 -1
  283. package/dist/es/utils/Validator/ValidationRuleResult.js +1 -1
  284. package/dist/es/utils/Validator/ValidationRuleResult.js.map +1 -1
  285. package/dist/es/utils/Validator/Validator.js +1 -1
  286. package/dist/es/utils/Validator/Validator.js.map +1 -1
  287. package/dist/es/utils/constants/currency-decimals.js +1 -1
  288. package/dist/es/utils/constants/currency-decimals.js.map +1 -1
  289. package/dist/es/utils/constants/currency-minor-units.js.map +1 -1
  290. package/dist/es/utils/useForm/reducer.js +1 -1
  291. package/dist/es/utils/useForm/reducer.js.map +1 -1
  292. package/dist/es/utils/useForm/useForm.js +1 -1
  293. package/dist/es/utils/useForm/useForm.js.map +1 -1
  294. package/dist/es/utils/useIsMobile.js +2 -0
  295. package/dist/es/utils/useIsMobile.js.map +1 -0
  296. package/dist/es-legacy/adyen.css +7 -3
  297. package/dist/es-legacy/adyen.css.map +1 -1
  298. package/dist/es-legacy/components/ApplePay/components/ApplePayButton.js.map +1 -1
  299. package/dist/es-legacy/components/BcmcMobile/BcmcMobile.js +1 -1
  300. package/dist/es-legacy/components/BcmcMobile/BcmcMobile.js.map +1 -1
  301. package/dist/es-legacy/components/Card/components/CardInput/components/CVCHint.js.map +1 -1
  302. package/dist/es-legacy/components/PayMe/PayMe.js +1 -1
  303. package/dist/es-legacy/components/PayMe/PayMe.js.map +1 -1
  304. package/dist/es-legacy/components/PayMe/components/PayMeInstructions.js +2 -0
  305. package/dist/es-legacy/components/PayMe/components/PayMeInstructions.js.map +1 -0
  306. package/dist/es-legacy/components/PayMe/components/PayMeIntroduction.js +2 -0
  307. package/dist/es-legacy/components/PayMe/components/PayMeIntroduction.js.map +1 -0
  308. package/dist/es-legacy/components/PayNow/PayNow.js +1 -1
  309. package/dist/es-legacy/components/PayNow/PayNow.js.map +1 -1
  310. package/dist/es-legacy/components/PayNow/components/PayNowInstructions.js +2 -0
  311. package/dist/es-legacy/components/PayNow/components/PayNowInstructions.js.map +1 -0
  312. package/dist/es-legacy/components/PayNow/components/PayNowIntroduction.js +2 -0
  313. package/dist/es-legacy/components/PayNow/components/PayNowIntroduction.js.map +1 -0
  314. package/dist/es-legacy/components/Swish/Swish.js.map +1 -1
  315. package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
  316. package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
  317. package/dist/es-legacy/components/internal/Address/Address.js +1 -1
  318. package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
  319. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js +1 -1
  320. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js.map +1 -1
  321. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js.map +1 -1
  322. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/cardType.js.map +1 -1
  323. package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js +1 -1
  324. package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js.map +1 -1
  325. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
  326. package/dist/es-legacy/components/internal/SecuredFields/lib/utilities/logger.js.map +1 -1
  327. package/dist/es-legacy/components/internal/Timeline/Timeline.js +2 -0
  328. package/dist/es-legacy/components/internal/Timeline/Timeline.js.map +1 -0
  329. package/dist/es-legacy/components/internal/Timeline/TimelineWrapper.js +2 -0
  330. package/dist/es-legacy/components/internal/Timeline/TimelineWrapper.js.map +1 -0
  331. package/dist/es-legacy/core/CheckoutSession/CheckoutSession.js.map +1 -1
  332. package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
  333. package/dist/es-legacy/core/core.js +1 -1
  334. package/dist/es-legacy/utils/constants/currency-decimals.js +1 -1
  335. package/dist/es-legacy/utils/constants/currency-decimals.js.map +1 -1
  336. package/dist/es-legacy/utils/constants/currency-minor-units.js.map +1 -1
  337. package/dist/es-legacy/utils/useForm/reducer.js +1 -1
  338. package/dist/es-legacy/utils/useForm/reducer.js.map +1 -1
  339. package/dist/es-legacy/utils/useForm/useForm.js +1 -1
  340. package/dist/es-legacy/utils/useForm/useForm.js.map +1 -1
  341. package/dist/es-legacy/utils/useIsMobile.js +2 -0
  342. package/dist/es-legacy/utils/useIsMobile.js.map +1 -0
  343. package/package.json +7 -2
  344. package/styles/adyen.css +7 -3
  345. package/dist/es/components/PayMe/Instructions.js +0 -2
  346. package/dist/es/components/PayMe/Instructions.js.map +0 -1
  347. package/dist/es-legacy/components/PayMe/Instructions.js +0 -2
  348. package/dist/es-legacy/components/PayMe/Instructions.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"QRLoader.js","sources":["../../../../../src/components/internal/QRLoader/QRLoader.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport Countdown from '../Countdown';\nimport Button from '../Button';\nimport Spinner from '../Spinner';\nimport checkPaymentStatus from '../../../core/Services/payment-status';\nimport processResponse from '../../../core/ProcessResponse';\n\nimport './QRLoader.scss';\nimport { QRLoaderProps, QRLoaderState } from './types';\nimport copyToClipboard from '../../../utils/clipboard';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport ContentSeparator from '../ContentSeparator';\nimport { StatusObject } from '../Await/types';\nimport useImage from '../../../core/Context/useImage';\nimport { useA11yReporter } from '../../../core/Errors/useA11yReporter';\nimport useAutoFocus from '../../../utils/useAutoFocus';\nimport { ANALYTICS_DOWNLOAD_STR, ANALYTICS_QR_CODE_DOWNLOAD } from '../../../core/Analytics/constants';\nimport { PREFIX } from '../Icon/constants';\n\nconst QRCODE_URL = 'barcode.shtml?barcodeType=qrCode&fileType=png&data=';\n\nclass QRLoader extends Component<QRLoaderProps, QRLoaderState> {\n private timeoutId;\n\n constructor(props) {\n super(props);\n\n this.state = {\n buttonStatus: 'default',\n completed: false,\n delay: props.delay,\n expired: false,\n loading: true,\n percentage: 100,\n timePassed: 0\n };\n }\n\n public static defaultProps = {\n delay: 2000,\n countdownTime: 15,\n onError: () => {},\n onComplete: () => {},\n throttleTime: 60000,\n classNameModifiers: [],\n throttledInterval: 10000,\n introduction: 'wechatpay.scanqrcode',\n timeToPay: 'wechatpay.timetopay',\n buttonLabel: 'openApp'\n };\n\n componentDidMount() {\n this.statusInterval();\n }\n\n componentWillUnmount() {\n clearTimeout(this.timeoutId);\n }\n\n public redirectToApp = (url: string | URL) => {\n window.location.assign(url);\n };\n\n // Retry until getting a complete response from the server, or it times out\n public statusInterval = (responseTime = 0) => {\n // If we are already in the final statuses, do not poll!\n if (this.state.expired || this.state.completed) return;\n\n this.setState(previous => ({ timePassed: previous.timePassed + this.props.delay + responseTime }));\n // Changes interval time to 10 seconds after 1 minute (60 seconds)\n const newDelay = this.state.timePassed >= this.props.throttleTime ? this.props.throttledInterval : this.state.delay;\n this.pollStatus(newDelay);\n };\n\n private pollStatus(delay: number) {\n clearTimeout(this.timeoutId);\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.timeoutId = setTimeout(async () => {\n // Wait for previous status call to finish.\n // Also taking the server response time into the consideration to calculate timePassed.\n const start = performance.now();\n await this.checkStatus();\n const end = performance.now();\n this.statusInterval(Math.round(end - start));\n }, delay);\n }\n\n private onTick = (time): void => {\n this.setState({ percentage: time.percentage });\n };\n\n private onTimeUp = (): void => {\n this.setState({ expired: true });\n clearTimeout(this.timeoutId);\n this.props.onError(new AdyenCheckoutError('ERROR', 'Payment Expired'));\n };\n\n private onComplete = (status: StatusObject): void => {\n clearTimeout(this.timeoutId);\n this.setState({ completed: true, loading: false });\n\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: this.props.paymentData\n }\n };\n\n this.props.onComplete(state, this);\n };\n\n private onError = (status: StatusObject): void => {\n clearTimeout(this.timeoutId);\n this.setState({ expired: true, loading: false });\n\n if (status.props.payload) {\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: this.props.paymentData\n }\n };\n this.props.onComplete(state, this);\n }\n\n const error = new AdyenCheckoutError('ERROR', 'error result with no payload in response');\n return this.props.onError(error);\n };\n\n private checkStatus = () => {\n const { paymentData, clientKey, loadingContext, throttledInterval } = this.props;\n\n return checkPaymentStatus(paymentData, clientKey, loadingContext, throttledInterval)\n .then(processResponse)\n .catch(response => ({ type: 'network-error', props: response }))\n .then((status: StatusObject) => {\n switch (status.type) {\n case 'success':\n this.onComplete(status);\n break;\n case 'error':\n this.onError(status);\n break;\n default:\n this.setState({ loading: false });\n }\n return status;\n });\n };\n\n render({ amount, url, brandLogo, brandName, countdownTime, type, onActionHandled }: QRLoaderProps, { expired, completed, loading }) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n const qrCodeImage = this.props.qrCodeData ? `${loadingContext}${QRCODE_URL}${this.props.qrCodeData}` : this.props.qrCodeImage;\n const finalState = (image, message) => {\n const status = i18n.get(message);\n useA11yReporter(status);\n return (\n <div className=\"adyen-checkout__qr-loader adyen-checkout__qr-loader--result\">\n <img\n className=\"adyen-checkout__qr-loader__icon adyen-checkout__qr-loader__icon--result\"\n src={getImage({ imageFolder: 'components/' })(image)}\n alt={status}\n />\n <div className=\"adyen-checkout__qr-loader__subtitle adyen-checkout__qr-loader__subtitle--result\">{status}</div>\n </div>\n );\n };\n\n if (expired) {\n return finalState('error', 'error.subtitle.payment');\n }\n\n if (completed) {\n return finalState('success', 'creditCard.success');\n }\n\n if (loading) {\n return (\n <div className=\"adyen-checkout__qr-loader\">\n {brandLogo && <img alt={brandName} src={brandLogo} className=\"adyen-checkout__qr-loader__brand-logo\" />}\n <Spinner />\n </div>\n );\n }\n\n const timeToPayString = i18n.get(this.props.timeToPay).split('%@');\n\n const qrSubtitleRef = useAutoFocus();\n const classnames = this.props.classNameModifiers.map(m => `adyen-checkout__qr-loader--${m}`);\n\n return (\n <div className={`adyen-checkout__qr-loader adyen-checkout__qr-loader--${type} ${classnames.join(' ')}`}>\n {brandLogo && <img src={brandLogo} alt={brandName} className=\"adyen-checkout__qr-loader__brand-logo\" />}\n\n {amount && amount.value && amount.currency && (\n <div className=\"adyen-checkout__qr-loader__payment_amount\">{i18n.amount(amount.value, amount.currency)}</div>\n )}\n\n {url && (\n <div className=\"adyen-checkout__qr-loader__app-link\">\n {this.props.redirectIntroduction && (\n <div className=\"adyen-checkout__qr-loader__subtitle\">{i18n.get(this.props.redirectIntroduction)}</div>\n )}\n <Button classNameModifiers={['qr-loader']} onClick={() => this.redirectToApp(url)} label={i18n.get(this.props.buttonLabel)} />\n <ContentSeparator />\n </div>\n )}\n\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */}\n <div ref={qrSubtitleRef} tabIndex={0} className=\"adyen-checkout__qr-loader__subtitle\">\n {i18n.get(this.props.introduction)}\n </div>\n\n <img\n src={qrCodeImage}\n alt={i18n.get('wechatpay.scanqrcode')}\n onLoad={() => {\n onActionHandled?.({\n componentType: this.props.type,\n actionDescription: 'qr-code-loaded'\n });\n }}\n />\n\n <div className=\"adyen-checkout__qr-loader__progress\">\n <span className=\"adyen-checkout__qr-loader__percentage\" style={{ width: `${this.state.percentage}%` }} />\n </div>\n\n <div className=\"adyen-checkout__qr-loader__countdown\">\n {timeToPayString[0]}&nbsp;\n <Countdown minutesFromNow={countdownTime} onTick={this.onTick} onCompleted={this.onTimeUp} />\n &nbsp;{timeToPayString[1]}\n </div>\n\n {typeof this.props.instructions === 'string' ? (\n <div className=\"adyen-checkout__qr-loader__instructions\">{i18n.get(this.props.instructions)}</div>\n ) : (\n this.props.instructions?.()\n )}\n\n {this.props.copyBtn && (\n <div className=\"adyen-checkout__qr-loader__actions\">\n <Button\n inline\n variant=\"action\"\n onClick={(e, { complete }) => {\n copyToClipboard(this.props.qrCodeData);\n this.props.onSubmitAnalytics({\n type: ANALYTICS_DOWNLOAD_STR,\n target: ANALYTICS_QR_CODE_DOWNLOAD\n });\n complete();\n }}\n icon={getImage({ imageFolder: 'components/' })(`${PREFIX}copy`)}\n label={i18n.get('button.copy')}\n />\n </div>\n )}\n </div>\n );\n }\n}\n\nexport default QRLoader;\n"],"names":["QRLoader","Component","timeoutId","constructor","props","super","this","state","buttonStatus","completed","delay","expired","loading","percentage","timePassed","static","countdownTime","onError","onComplete","throttleTime","classNameModifiers","throttledInterval","introduction","timeToPay","buttonLabel","componentDidMount","statusInterval","componentWillUnmount","clearTimeout","redirectToApp","url","window","location","assign","responseTime","setState","previous","newDelay","pollStatus","setTimeout","async","start","performance","now","checkStatus","end","Math","round","onTick","time","onTimeUp","AdyenCheckoutError","status","data","details","payload","paymentData","error","clientKey","loadingContext","checkPaymentStatus","then","processResponse","catch","response","type","render","amount","brandLogo","brandName","onActionHandled","i18n","useCoreContext","getImage","useImage","qrCodeImage","qrCodeData","finalState","image","message","get","useA11yReporter","h","div","className","img","src","imageFolder","alt","Spinner","timeToPayString","split","qrSubtitleRef","useAutoFocus","classnames","map","m","join","value","currency","redirectIntroduction","Button","onClick","label","ContentSeparator","ref","tabIndex","onLoad","componentType","actionDescription","span","style","width","Countdown","minutesFromNow","onCompleted","instructions","copyBtn","inline","variant","e","complete","copyToClipboard","onSubmitAnalytics","ANALYTICS_DOWNLOAD_STR","target","ANALYTICS_QR_CODE_DOWNLOAD","icon","PREFIX"],"mappings":"24BAsBA,MAAMA,UAAiBC,EACXC,UAERC,WAAAA,CAAYC,GACRC,MAAMD,GAENE,KAAKC,MAAQ,CACTC,aAAc,UACdC,WAAW,EACXC,MAAON,EAAMM,MACbC,SAAS,EACTC,SAAS,EACTC,WAAY,IACZC,WAAY,EAEpB,CAEAC,oBAA6B,CACzBL,MAAO,IACPM,cAAe,GACfC,QAAS,OACTC,WAAY,OACZC,aAAc,IACdC,mBAAoB,GACpBC,kBAAmB,IACnBC,aAAc,uBACdC,UAAW,sBACXC,YAAa,WAGjBC,iBAAAA,GACInB,KAAKoB,gBACT,CAEAC,oBAAAA,GACIC,aAAatB,KAAKJ,UACtB,CAEO2B,cAAiBC,IACpBC,OAAOC,SAASC,OAAOH,EAAAA,EAIpBJ,eAAiB,CAACQ,EAAe,KAEpC,GAAI5B,KAAKC,MAAMI,SAAWL,KAAKC,MAAME,UAAW,OAEhDH,KAAK6B,UAASC,IAAa,CAAEtB,WAAYsB,EAAStB,WAAaR,KAAKF,MAAMM,MAAQwB,MAElF,MAAMG,EAAW/B,KAAKC,MAAMO,YAAcR,KAAKF,MAAMe,aAAeb,KAAKF,MAAMiB,kBAAoBf,KAAKC,MAAMG,MAC9GJ,KAAKgC,WAAWD,EAAAA,EAGZC,UAAAA,CAAW5B,GACfkB,aAAatB,KAAKJ,WAGlBI,KAAKJ,UAAYqC,YAAWC,UAGxB,MAAMC,EAAQC,YAAYC,YACpBrC,KAAKsC,c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BtE,KAAKF,MAAMuH,kBAAkB,CACzB1D,KAAM2D,EACNC,OAAQC,IAEZL,GAAAA,EAEJM,KAAMtD,EAAS,CAAEc,YAAa,eAAxBd,CAAyC,GAAGuD,SAClDzB,MAAOhC,EAAKS,IAAI,kBAMxC"}
1
+ {"version":3,"file":"QRLoader.js","sources":["../../../../../src/components/internal/QRLoader/QRLoader.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport Countdown from '../Countdown';\nimport Button from '../Button';\nimport Spinner from '../Spinner';\nimport checkPaymentStatus from '../../../core/Services/payment-status';\nimport processResponse from '../../../core/ProcessResponse';\n\nimport './QRLoader.scss';\nimport { QRLoaderProps, QRLoaderState } from './types';\nimport copyToClipboard from '../../../utils/clipboard';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport ContentSeparator from '../ContentSeparator';\nimport { StatusObject } from '../Await/types';\nimport useImage from '../../../core/Context/useImage';\nimport { useA11yReporter } from '../../../core/Errors/useA11yReporter';\nimport useAutoFocus from '../../../utils/useAutoFocus';\nimport { ANALYTICS_DOWNLOAD_STR, ANALYTICS_QR_CODE_DOWNLOAD } from '../../../core/Analytics/constants';\nimport { PREFIX } from '../Icon/constants';\n\nconst QRCODE_URL = 'barcode.shtml?barcodeType=qrCode&fileType=png&data=';\n\nclass QRLoader extends Component<QRLoaderProps, QRLoaderState> {\n private timeoutId;\n\n constructor(props) {\n super(props);\n\n this.state = {\n buttonStatus: 'default',\n completed: false,\n delay: props.delay,\n expired: false,\n loading: true,\n percentage: 100,\n timePassed: 0\n };\n }\n\n public static defaultProps = {\n delay: 2000,\n countdownTime: 15,\n onError: () => {},\n onComplete: () => {},\n throttleTime: 60000,\n classNameModifiers: [],\n throttledInterval: 10000,\n introduction: 'wechatpay.scanqrcode',\n timeToPay: 'wechatpay.timetopay',\n buttonLabel: 'openApp'\n };\n\n componentDidMount() {\n this.statusInterval();\n }\n\n componentWillUnmount() {\n clearTimeout(this.timeoutId);\n }\n\n public redirectToApp = (url: string | URL) => {\n window.location.assign(url);\n };\n\n // Retry until getting a complete response from the server, or it times out\n public statusInterval = (responseTime = 0) => {\n // If we are already in the final statuses, do not poll!\n if (this.state.expired || this.state.completed) return;\n\n this.setState(previous => ({ timePassed: previous.timePassed + this.props.delay + responseTime }));\n // Changes interval time to 10 seconds after 1 minute (60 seconds)\n const newDelay = this.state.timePassed >= this.props.throttleTime ? this.props.throttledInterval : this.state.delay;\n this.pollStatus(newDelay);\n };\n\n private pollStatus(delay: number) {\n clearTimeout(this.timeoutId);\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.timeoutId = setTimeout(async () => {\n // Wait for previous status call to finish.\n // Also taking the server response time into the consideration to calculate timePassed.\n const start = performance.now();\n await this.checkStatus();\n const end = performance.now();\n this.statusInterval(Math.round(end - start));\n }, delay);\n }\n\n private onTick = (time): void => {\n this.setState({ percentage: time.percentage });\n };\n\n private onTimeUp = (): void => {\n this.setState({ expired: true });\n clearTimeout(this.timeoutId);\n this.props.onError(new AdyenCheckoutError('ERROR', 'Payment Expired'));\n };\n\n private onComplete = (status: StatusObject): void => {\n clearTimeout(this.timeoutId);\n this.setState({ completed: true, loading: false });\n\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: this.props.paymentData\n }\n };\n\n this.props.onComplete(state, this);\n };\n\n private onError = (status: StatusObject): void => {\n clearTimeout(this.timeoutId);\n this.setState({ expired: true, loading: false });\n\n if (status.props.payload) {\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: this.props.paymentData\n }\n };\n this.props.onComplete(state, this);\n }\n\n const error = new AdyenCheckoutError('ERROR', 'error result with no payload in response');\n return this.props.onError(error);\n };\n\n private checkStatus = () => {\n const { paymentData, clientKey, loadingContext, throttledInterval } = this.props;\n\n return checkPaymentStatus(paymentData, clientKey, loadingContext, throttledInterval)\n .then(processResponse)\n .catch(response => ({ type: 'network-error', props: response }))\n .then((status: StatusObject) => {\n switch (status.type) {\n case 'success':\n this.onComplete(status);\n break;\n case 'error':\n this.onError(status);\n break;\n default:\n this.setState({ loading: false });\n }\n return status;\n });\n };\n\n render({ amount, url, brandLogo, brandName, countdownTime, type, onActionHandled }: QRLoaderProps, { expired, completed, loading }) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n const qrCodeImage = this.props.qrCodeData ? `${loadingContext}${QRCODE_URL}${this.props.qrCodeData}` : this.props.qrCodeImage;\n const finalState = (image, message) => {\n const status = i18n.get(message);\n useA11yReporter(status);\n return (\n <div className=\"adyen-checkout__qr-loader adyen-checkout__qr-loader--result\">\n <img\n className=\"adyen-checkout__qr-loader__icon adyen-checkout__qr-loader__icon--result\"\n src={getImage({ imageFolder: 'components/' })(image)}\n alt={status}\n />\n <div className=\"adyen-checkout__qr-loader__subtitle\">{status}</div>\n </div>\n );\n };\n\n if (expired) {\n return finalState('error', 'error.subtitle.payment');\n }\n\n if (completed) {\n return finalState('success', 'creditCard.success');\n }\n\n if (loading) {\n return (\n <div className=\"adyen-checkout__qr-loader\">\n {brandLogo && (\n <div className=\"adyen-checkout__qr-loader__brand-logo-wrapper\">\n <img alt={brandName} src={brandLogo} className=\"adyen-checkout__qr-loader__brand-logo\" />\n </div>\n )}\n <Spinner />\n </div>\n );\n }\n\n const timeToPayString = i18n.get(this.props.timeToPay).split('%@');\n\n const qrSubtitleRef = useAutoFocus();\n const classnames = this.props.classNameModifiers.map(m => `adyen-checkout__qr-loader--${m}`);\n\n return (\n <div className={`adyen-checkout__qr-loader adyen-checkout__qr-loader--${type} ${classnames.join(' ')}`}>\n {brandLogo && (\n <div className=\"adyen-checkout__qr-loader__brand-logo-wrapper\">\n <img src={brandLogo} alt={brandName} className=\"adyen-checkout__qr-loader__brand-logo\" />\n </div>\n )}\n\n {amount && amount.value && amount.currency && (\n <div className=\"adyen-checkout__qr-loader__payment_amount\">{i18n.amount(amount.value, amount.currency)}</div>\n )}\n\n {url && (\n <div className=\"adyen-checkout__qr-loader__app-link\">\n {this.props.redirectIntroduction && (\n <div className=\"adyen-checkout__qr-loader__subtitle\">{i18n.get(this.props.redirectIntroduction)}</div>\n )}\n <Button classNameModifiers={['qr-loader']} onClick={() => this.redirectToApp(url)} label={i18n.get(this.props.buttonLabel)} />\n <ContentSeparator />\n </div>\n )}\n\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */}\n <div ref={qrSubtitleRef} tabIndex={0} className=\"adyen-checkout__qr-loader__subtitle\">\n {typeof this.props.introduction === 'string' ? i18n.get(this.props.introduction) : this.props.introduction?.()}\n </div>\n\n <img\n src={qrCodeImage}\n alt={i18n.get('wechatpay.scanqrcode')}\n onLoad={() => {\n onActionHandled?.({\n componentType: this.props.type,\n actionDescription: 'qr-code-loaded'\n });\n }}\n />\n\n <div className=\"adyen-checkout__qr-loader__progress\">\n <span className=\"adyen-checkout__qr-loader__percentage\" style={{ width: `${this.state.percentage}%` }} />\n </div>\n\n <div className=\"adyen-checkout__qr-loader__countdown\">\n {timeToPayString[0]}&nbsp;\n <Countdown minutesFromNow={countdownTime} onTick={this.onTick} onCompleted={this.onTimeUp} />\n &nbsp;{timeToPayString[1]}\n </div>\n\n {this.props.instructions && (\n <div className=\"adyen-checkout__qr-loader__instructions\">\n {typeof this.props.instructions === 'string' ? i18n.get(this.props.instructions) : this.props.instructions?.()}\n </div>\n )}\n\n {this.props.copyBtn && (\n <div className=\"adyen-checkout__qr-loader__actions\">\n <Button\n inline\n variant=\"action\"\n onClick={(e, { complete }) => {\n copyToClipboard(this.props.qrCodeData);\n this.props.onSubmitAnalytics({\n type: ANALYTICS_DOWNLOAD_STR,\n target: ANALYTICS_QR_CODE_DOWNLOAD\n });\n complete();\n }}\n icon={getImage({ imageFolder: 'components/' })(`${PREFIX}copy`)}\n label={i18n.get('button.copy')}\n />\n </div>\n )}\n </div>\n );\n }\n}\n\nexport default QRLoader;\n"],"names":["QRLoader","Component","componentDidMount","this","statusInterval","componentWillUnmount","clearTimeout","timeoutId","pollStatus","delay","setTimeout","async","start","performance","now","checkStatus","end","Math","round","render","amount","url","brandLogo","brandName","countdownTime","type","onActionHandled","expired","completed","loading","i18n","loadingContext","useCoreContext","getImage","useImage","qrCodeImage","props","qrCodeData","finalState","image","message","status","get","useA11yReporter","h","div","className","img","src","imageFolder","alt","Spinner","timeToPayString","timeToPay","split","qrSubtitleRef","useAutoFocus","classnames","classNameModifiers","map","m","join","value","currency","redirectIntroduction","Button","onClick","redirectToApp","label","buttonLabel","ContentSeparator","ref","tabIndex","introduction","onLoad","componentType","actionDescription","span","style","width","state","percentage","Countdown","minutesFromNow","onTick","onCompleted","onTimeUp","instructions","copyBtn","inline","variant","e","complete","copyToClipboard","onSubmitAnalytics","ANALYTICS_DOWNLOAD_STR","target","ANALYTICS_QR_CODE_DOWNLOAD","icon","PREFIX","constructor","super","_define_property","window","location","assign","responseTime","setState","previous","timePassed","newDelay","throttleTime","throttledInterval","time","onError","AdyenCheckoutError","onComplete","data","details","payload","paymentData","error","clientKey","checkPaymentStatus","then","processResponse","catch","response","buttonStatus","defaultProps"],"mappings":"mgCAsBA,MAAMA,UAAiBC,EA8BnBC,iBAAAA,GACIC,KAAKC,gBACT,CAEAC,oBAAAA,GACIC,aAAaH,KAAKI,UACtB,CAiBQC,UAAAA,CAAWC,GACfH,aAAaH,KAAKI,WAGlBJ,KAAKI,UAAYG,YAAWC,UAGxB,MAAMC,EAAQC,YAAYC,YACpBX,KAAKY,cACX,MAAMC,EAAMH,YAAYC,MACxBX,KAAKC,eAAea,KAAKC,MAAMF,EAAMJ,GAAAA,GACtCH,EACP,CAiEAU,MAAAA,EAAOC,OAAEA,EAAMC,IAAEA,EAAGC,UAAEA,EAASC,UAAEA,EAASC,cAAEA,EAAaC,KAAEA,EAAIC,gBAAEA,IAAkCC,QAAEA,EAAOC,UAAEA,EAASC,QAAEA,IACrH,MAAMC,KAAEA,EAAIC,eAAEA,GAAmBC,IAC3BC,EAAWC,IACXC,EAAchC,KAAKiC,MAAMC,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jCC,YAAarH,KAAKiC,MAAMoF,cAGhCrH,KAAKiC,MAAMgF,WAAWpC,EAAO7E,KACjC,CAEA,MAAMsH,EAAQ,IAAIN,EAAmB,QAAS,4CAC9C,OAAOhH,KAAKiC,MAAM8E,QAAQO,EAAAA,IAG9BnB,EAAAnG,KAAQY,eAAc,KAClB,MAAMyG,YAAEA,EAAWE,UAAEA,EAAS3F,eAAEA,EAAciF,kBAAEA,GAAsB7G,KAAKiC,MAE3E,OAAOuF,EAAmBH,EAAaE,EAAW3F,EAAgBiF,GAC7DY,KAAKC,GACLC,OAAMC,IAAa,CAAEtG,KAAM,gBAAiBW,MAAO2F,MACnDH,MAAMnF,IACH,OAAQA,EAAOhB,MACX,IAAK,UACDtB,KAAKiH,WAAW3E,GAChB,MACJ,IAAK,QACDtC,KAAK+G,QAAQzE,GACb,MACJ,QACItC,KAAKwG,SAAS,CAAE9E,SAAS,IAEjC,OAAOY,CAAAA,GACX,IAzHJtC,KAAK6E,MAAQ,CACTgD,aAAc,UACdpG,WAAW,EACXnB,MAAO2B,EAAM3B,MACbkB,SAAS,EACTE,SAAS,EACToD,WAAY,IACZ4B,WAAY,EAEpB,EAEAP,EAjBEtG,EAiBYiI,eAAe,CACzBxH,MAAO,IACPe,cAAe,GACf0F,QAAS,OACTE,WAAY,OACZL,aAAc,IACdrD,mBAAoB,GACpBsD,kBAAmB,IACnBvC,aAAc,uBACdpB,UAAW,sBACXgB,YAAa"}
@@ -1,2 +1,2 @@
1
- import{Component as s}from"../../../../external/preact/dist/preact.js";import{getFields as t,validFieldsReducer as e,getErrorReducer as i,getErrorObject as o}from"./SFPUtils.js";import n from"../lib/CSF/initCSF.js";import r from"./SecuredFieldsProviderHandlers.js";import a from"./defaultProps.js";import{CVC_POLICY_REQUIRED as d,DATE_POLICY_REQUIRED as h,ENCRYPTED_PWD_FIELD as l,ENCRYPTED_CARD_NUMBER as p,DEDICATED_CARD_COMPONENTS as c}from"../lib/constants.js";import u from"../../../../core/Errors/AdyenCheckoutError.js";import{getErrorMessageFromCode as f}from"../../../../core/Errors/utils.js";import{SF_ErrorCodes as m}from"../../../../core/Errors/constants.js";class F extends s{csfLoadFailTimeout;csfLoadFailTimeoutMS;csfConfigFailTimeout;csfConfigFailTimeoutMS;numCharsInField;rootNode;numDateFields;csf;handleOnLoad;handleOnConfigSuccess;handleOnFieldValid;handleOnAllValid;handleOnBrand;handleFocus;handleOnError;handleOnAutoComplete;handleOnNoDataRequired;handleOnTouchstartIOS;handleKeyPressed;state;props;issuingCountryCode;constructor(s){super(s);const t={status:"loading",brand:s.type,errors:{},valid:{},data:{},cvcPolicy:d,expiryDatePolicy:h,isSfpValid:!1,hasKoreanFields:s.hasKoreanFields};this.state=t,this.csfLoadFailTimeout=null,this.csfLoadFailTimeoutMS=3e4,this.csfConfigFailTimeout=null,this.csfConfigFailTimeoutMS=15e3,this.numCharsInField={},this.handleOnLoad=r.handleOnLoad.bind(this),this.handleOnConfigSuccess=r.handleOnConfigSuccess.bind(this),this.handleOnFieldValid=r.handleOnFieldValid.bind(this),this.handleOnAllValid=r.handleOnAllValid.bind(this),this.handleOnBrand=r.handleOnBrand.bind(this),this.handleFocus=r.handleFocus.bind(this),this.handleOnError=r.handleOnError.bind(this),this.handleOnNoDataRequired=r.handleOnNoDataRequired.bind(this),this.handleOnAutoComplete=r.handleOnAutoComplete.bind(this),this.handleOnTouchstartIOS=r.handleOnTouchstartIOS.bind(this),this.handleKeyPressed=r.handleKeyPressed.bind(this),this.processBinLookupResponse=this.processBinLookupResponse.bind(this),this.setFocusOn=this.setFocusOn.bind(this),this.updateStyles=this.updateStyles.bind(this),this.handleUnsupportedCard=this.handleUnsupportedCard.bind(this),this.showValidation=this.showValidation.bind(this),this.destroy=this.destroy.bind(this)}static defaultProps=a;componentDidMount(){this.props.rootNode&&this.setRootNode(this.props.rootNode);const s=t(this.rootNode),i=s.reduce(e,{});this.setState({valid:i}),s.forEach((s=>{this.numCharsInField[s]=0})),this.numDateFields=s.filter((s=>s.match(/Expiry/))).length,s.length?(this.destroy(),this.initializeCSF(this.rootNode)):this.handleOnNoDataRequired()}componentDidUpdate(){this.checkForKCPFields()}componentWillUnmount(){this.csf=null,clearTimeout(this.csfLoadFailTimeout),clearTimeout(this.csfConfigFailTimeout)}initializeCSF(s){let t=this.props.loadingContext;const e={rootNode:s,type:this.props.type,clientKey:this.props.clientKey,cardGroupTypes:this.props.brands,autoFocus:this.props.autoFocus,trimTrailingSeparator:this.props.trimTrailingSeparator,loadingContext:t,keypadFix:this.props.keypadFix,showWarnings:this.props.showWarnings,iframeUIConfig:{sfStyles:this.props.styles},i18n:this.props.i18n,callbacks:{onLoad:this.handleOnLoad,onConfigSuccess:this.handleOnConfigSuccess,onFieldValid:this.handleOnFieldValid,onAllValid:this.handleOnAllValid,onBrand:this.handleOnBrand,onError:this.handleOnError,onFocus:this.handleFocus,onBinValue:this.props.onBinValue,onAutoComplete:this.handleOnAutoComplete,onAdditionalSFConfig:this.props.onAdditionalSFConfig,onAdditionalSFRemoved:this.props.onAdditionalSFRemoved,onTouchstartIOS:this.handleOnTouchstartIOS,onKeyPressed:this.handleKeyPressed},isKCP:this.state.hasKoreanFields,legacyInputMode:this.props.legacyInputMode,minimumExpiryDate:this.props.minimumExpiryDate,implementationType:this.props.implementationType||"components",forceCompat:this.props.forceCompat,maskSecurityCode:this.props.maskSecurityCode,exposeExpiryDate:this.props.exposeExpiryDate,shouldDisableIOSArrowKeys:!!this.props.disableIOSArrowKeys,placeholders:this.props.placeholders??{},showContextualElement:this.props.showContextualElement};this.csf=n(e),this.csfLoadFailTimeout=setTimeout((()=>{"ready"!==this.state.status&&(this.setState({status:"csfLoadFailure"}),this.props.onError(new u("ERROR","secured field iframes have failed to load")))}),this.csfLoadFailTimeoutMS)}checkForKCPFields(){let s=!1;if(this.props.koreanAuthenticationRequired&&(s=this.issuingCountryCode?"kr"===this.issuingCountryCode:"kr"===this.props.countryCode),this.state.hasKoreanFields&&!s){const s=s=>({data:{...s.data,[l]:void 0},valid:{...s.valid,[l]:!1},errors:{...s.errors,[l]:!1},hasKoreanFields:!1});this.setState(s,(()=>{this.props.onChange(this.state)})),this.csf.removeSecuredField(l),this.csf.setKCPStatus(!1)}if(!this.state.hasKoreanFields&&s){const s=s=>({valid:{...s.valid,[l]:!1},hasKoreanFields:!0,isSfpValid:!1});this.setState(s,(()=>{this.props.onChange(this.state)})),this.csf.addSecuredField(l),this.csf.setKCPStatus(!0)}}getChildContext(){return{i18n:this.props.i18n}}handleUnsupportedCard(s){const t=!!s.error;return t&&this.setState({detectedUnsupportedBrands:s.detectedBrands}),s.rootNode=this.rootNode,this.handleOnError(s,t),this.csf&&this.csf.hasUnsupportedCard(p,s.error),t}setFocusOn(s){this.csf&&this.csf.setFocusOnFrame(s)}updateStyles(s){this.csf&&this.csf.updateStyles(s)}sfIsOptionalOrHidden(s){return this.csf.sfIsOptionalOrHidden(s)}destroy(){this.csf&&this.csf.destroy()}showValidation(){const{numDateFields:s,state:t}=this;Object.keys(t.valid).reduce(i(s,t),[]).forEach((s=>{const e=o(s,this.rootNode,t);this.handleOnError(e,!!t.detectedUnsupportedBrands),this.csf&&this.csf.isValidated&&this.csf.isValidated(s,e.error)}))}mapErrorsToValidationRuleResult(){return Object.keys(this.state.errors).reduce(((s,t)=>{const e=this.state.errors[t];return s[t]=e?{isValid:!1,errorMessage:f(e,m),errorI18n:this.props.i18n.get(e),error:e,rootNode:this.rootNode,...this.state.detectedUnsupportedBrands&&{detectedBrands:this.state.detectedUnsupportedBrands}}:null,s}),{})}processBinLookupResponse(s,t){if(this.state.detectedUnsupportedBrands&&(this.setState((s=>({errors:{...s.errors,[p]:!1},detectedUnsupportedBrands:null}))),this.csf&&s)){const s={type:"card",fieldType:"encryptedCardNumber",error:""};this.handleUnsupportedCard(s)}this.issuingCountryCode=s?.issuingCountryCode?.toLowerCase();const e=t?.brand,i=e&&c.includes(t.brand);i&&this.setState(t,(()=>{this.props.onChange(this.state)})),this.csf&&this.csf.brandsFromBinLookup(s,i?t:null)}setRootNode=s=>{this.rootNode=s};render(s,t){return s.render({setRootNode:this.setRootNode,setFocusOn:this.setFocusOn},t)}}export{F as default};
1
+ import{Component as s}from"../../../../external/preact/dist/preact.js";import{getFields as t,validFieldsReducer as e,getErrorReducer as i,getErrorObject as o}from"./SFPUtils.js";import n from"../lib/CSF/initCSF.js";import r from"./SecuredFieldsProviderHandlers.js";import d from"./defaultProps.js";import{ENCRYPTED_PWD_FIELD as a,ENCRYPTED_CARD_NUMBER as h,DEDICATED_CARD_COMPONENTS as l,CVC_POLICY_REQUIRED as p,DATE_POLICY_REQUIRED as c}from"../lib/constants.js";import u from"../../../../core/Errors/AdyenCheckoutError.js";import{getErrorMessageFromCode as f}from"../../../../core/Errors/utils.js";import{SF_ErrorCodes as m}from"../../../../core/Errors/constants.js";function F(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}class C extends s{componentDidMount(){this.props.rootNode&&this.setRootNode(this.props.rootNode);const s=t(this.rootNode),i=s.reduce(e,{});this.setState({valid:i}),s.forEach((s=>{this.numCharsInField[s]=0})),this.numDateFields=s.filter((s=>s.match(/Expiry/))).length,s.length?(this.destroy(),this.initializeCSF(this.rootNode)):this.handleOnNoDataRequired()}componentDidUpdate(){this.checkForKCPFields()}componentWillUnmount(){this.csf=null,clearTimeout(this.csfLoadFailTimeout),clearTimeout(this.csfConfigFailTimeout)}initializeCSF(s){let t=this.props.loadingContext;const e={rootNode:s,type:this.props.type,clientKey:this.props.clientKey,cardGroupTypes:this.props.brands,autoFocus:this.props.autoFocus,trimTrailingSeparator:this.props.trimTrailingSeparator,loadingContext:t,keypadFix:this.props.keypadFix,showWarnings:this.props.showWarnings,iframeUIConfig:{sfStyles:this.props.styles},i18n:this.props.i18n,callbacks:{onLoad:this.handleOnLoad,onConfigSuccess:this.handleOnConfigSuccess,onFieldValid:this.handleOnFieldValid,onAllValid:this.handleOnAllValid,onBrand:this.handleOnBrand,onError:this.handleOnError,onFocus:this.handleFocus,onBinValue:this.props.onBinValue,onAutoComplete:this.handleOnAutoComplete,onAdditionalSFConfig:this.props.onAdditionalSFConfig,onAdditionalSFRemoved:this.props.onAdditionalSFRemoved,onTouchstartIOS:this.handleOnTouchstartIOS,onKeyPressed:this.handleKeyPressed},isKCP:this.state.hasKoreanFields,legacyInputMode:this.props.legacyInputMode,minimumExpiryDate:this.props.minimumExpiryDate,implementationType:this.props.implementationType||"components",forceCompat:this.props.forceCompat,maskSecurityCode:this.props.maskSecurityCode,exposeExpiryDate:this.props.exposeExpiryDate,shouldDisableIOSArrowKeys:!!this.props.disableIOSArrowKeys,placeholders:this.props.placeholders??{},showContextualElement:this.props.showContextualElement};this.csf=n(e),this.csfLoadFailTimeout=setTimeout((()=>{"ready"!==this.state.status&&(this.setState({status:"csfLoadFailure"}),this.props.onError(new u("ERROR","secured field iframes have failed to load")))}),this.csfLoadFailTimeoutMS)}checkForKCPFields(){let s=!1;if(this.props.koreanAuthenticationRequired&&(s=this.issuingCountryCode?"kr"===this.issuingCountryCode:"kr"===this.props.countryCode),this.state.hasKoreanFields&&!s){const s=s=>({data:{...s.data,[a]:void 0},valid:{...s.valid,[a]:!1},errors:{...s.errors,[a]:!1},hasKoreanFields:!1});this.setState(s,(()=>{this.props.onChange(this.state)})),this.csf.removeSecuredField(a),this.csf.setKCPStatus(!1)}if(!this.state.hasKoreanFields&&s){const s=s=>({valid:{...s.valid,[a]:!1},hasKoreanFields:!0,isSfpValid:!1});this.setState(s,(()=>{this.props.onChange(this.state)})),this.csf.addSecuredField(a),this.csf.setKCPStatus(!0)}}getChildContext(){return{i18n:this.props.i18n}}handleUnsupportedCard(s){const t=!!s.error;return t&&this.setState({detectedUnsupportedBrands:s.detectedBrands}),s.rootNode=this.rootNode,this.handleOnError(s,t),this.csf&&this.csf.hasUnsupportedCard(h,s.error),t}setFocusOn(s){this.csf&&this.csf.setFocusOnFrame(s)}updateStyles(s){this.csf&&this.csf.updateStyles(s)}sfIsOptionalOrHidden(s){return this.csf.sfIsOptionalOrHidden(s)}destroy(){this.csf&&this.csf.destroy()}showValidation(){const{numDateFields:s,state:t}=this;Object.keys(t.valid).reduce(i(s,t),[]).forEach((s=>{const e=o(s,this.rootNode,t);this.handleOnError(e,!!t.detectedUnsupportedBrands),this.csf&&this.csf.isValidated&&this.csf.isValidated(s,e.error)}))}mapErrorsToValidationRuleResult(){return Object.keys(this.state.errors).reduce(((s,t)=>{const e=this.state.errors[t];return s[t]=e?{isValid:!1,errorMessage:f(e,m),errorI18n:this.props.i18n.get(e),error:e,rootNode:this.rootNode,...this.state.detectedUnsupportedBrands&&{detectedBrands:this.state.detectedUnsupportedBrands}}:null,s}),{})}processBinLookupResponse(s,t){if(this.state.detectedUnsupportedBrands&&(this.setState((s=>({errors:{...s.errors,[h]:!1},detectedUnsupportedBrands:null}))),this.csf&&s)){const s={type:"card",fieldType:"encryptedCardNumber",error:""};this.handleUnsupportedCard(s)}this.issuingCountryCode=s?.issuingCountryCode?.toLowerCase();const e=t?.brand,i=e&&l.includes(t.brand);i&&this.setState(t,(()=>{this.props.onChange(this.state)})),this.csf&&this.csf.brandsFromBinLookup(s,i?t:null)}render(s,t){return s.render({setRootNode:this.setRootNode,setFocusOn:this.setFocusOn},t)}constructor(s){super(s),F(this,"csfLoadFailTimeout",void 0),F(this,"csfLoadFailTimeoutMS",void 0),F(this,"csfConfigFailTimeout",void 0),F(this,"csfConfigFailTimeoutMS",void 0),F(this,"numCharsInField",void 0),F(this,"rootNode",void 0),F(this,"numDateFields",void 0),F(this,"csf",void 0),F(this,"handleOnLoad",void 0),F(this,"handleOnConfigSuccess",void 0),F(this,"handleOnFieldValid",void 0),F(this,"handleOnAllValid",void 0),F(this,"handleOnBrand",void 0),F(this,"handleFocus",void 0),F(this,"handleOnError",void 0),F(this,"handleOnAutoComplete",void 0),F(this,"handleOnNoDataRequired",void 0),F(this,"handleOnTouchstartIOS",void 0),F(this,"handleKeyPressed",void 0),F(this,"state",void 0),F(this,"props",void 0),F(this,"issuingCountryCode",void 0),F(this,"setRootNode",(s=>{this.rootNode=s}));const t={status:"loading",brand:s.type,errors:{},valid:{},data:{},cvcPolicy:p,expiryDatePolicy:c,isSfpValid:!1,hasKoreanFields:s.hasKoreanFields};this.state=t,this.csfLoadFailTimeout=null,this.csfLoadFailTimeoutMS=3e4,this.csfConfigFailTimeout=null,this.csfConfigFailTimeoutMS=15e3,this.numCharsInField={},this.handleOnLoad=r.handleOnLoad.bind(this),this.handleOnConfigSuccess=r.handleOnConfigSuccess.bind(this),this.handleOnFieldValid=r.handleOnFieldValid.bind(this),this.handleOnAllValid=r.handleOnAllValid.bind(this),this.handleOnBrand=r.handleOnBrand.bind(this),this.handleFocus=r.handleFocus.bind(this),this.handleOnError=r.handleOnError.bind(this),this.handleOnNoDataRequired=r.handleOnNoDataRequired.bind(this),this.handleOnAutoComplete=r.handleOnAutoComplete.bind(this),this.handleOnTouchstartIOS=r.handleOnTouchstartIOS.bind(this),this.handleKeyPressed=r.handleKeyPressed.bind(this),this.processBinLookupResponse=this.processBinLookupResponse.bind(this),this.setFocusOn=this.setFocusOn.bind(this),this.updateStyles=this.updateStyles.bind(this),this.handleUnsupportedCard=this.handleUnsupportedCard.bind(this),this.showValidation=this.showValidation.bind(this),this.destroy=this.destroy.bind(this)}}F(C,"defaultProps",d);export{C as default};
2
2
  //# sourceMappingURL=SecuredFieldsProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SecuredFieldsProvider.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SecuredFieldsProvider.ts"],"sourcesContent":["import { Component } from 'preact';\nimport { getErrorObject, getFields, getErrorReducer, validFieldsReducer } from './SFPUtils';\nimport initCSF from '../lib/CSF';\nimport handlers from './SecuredFieldsProviderHandlers';\nimport defaultProps from './defaultProps';\nimport { SFPProps, SFPState, SingleBrandResetObject } from './types';\nimport {\n StylesObject,\n CbObjOnError,\n CbObjOnFocus,\n CbObjOnBrand,\n CbObjOnAllValid,\n CbObjOnFieldValid,\n CbObjOnAutoComplete,\n CbObjOnConfigSuccess,\n CbObjOnLoad,\n SFKeyPressObj\n} from '../lib/types';\nimport { CSFReturnObject, CSFSetupObject } from '../lib/CSF/types';\nimport { CVC_POLICY_REQUIRED, DATE_POLICY_REQUIRED, DEDICATED_CARD_COMPONENTS, ENCRYPTED_CARD_NUMBER, ENCRYPTED_PWD_FIELD } from '../lib/constants';\nimport { BinLookupResponse } from '../../../Card/types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { SFStateErrorObj } from '../../../Card/components/CardInput/types';\nimport { getErrorMessageFromCode } from '../../../../core/Errors/utils';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\n\n/**\n * SecuredFieldsProvider:\n * Initialises & handles the client-side part of SecuredFields\n */\nclass SecuredFieldsProvider extends Component<SFPProps, SFPState> {\n private csfLoadFailTimeout: number;\n private csfLoadFailTimeoutMS: number;\n private csfConfigFailTimeout: number;\n private csfConfigFailTimeoutMS: number;\n private numCharsInField: object;\n private rootNode;\n private numDateFields: number;\n private csf: CSFReturnObject;\n private handleOnLoad: (obj: CbObjOnLoad) => void;\n private handleOnConfigSuccess: (obj: CbObjOnConfigSuccess) => void;\n private handleOnFieldValid: (obj: CbObjOnFieldValid) => void;\n private handleOnAllValid: (obj: CbObjOnAllValid) => void;\n private handleOnBrand: (obj: CbObjOnBrand) => void;\n private handleFocus: (obj: CbObjOnFocus) => void;\n private handleOnError: (obj: CbObjOnError, hasUnsupportedCard?: boolean) => void;\n private handleOnAutoComplete: (obj: CbObjOnAutoComplete) => void;\n private handleOnNoDataRequired: () => void;\n private handleOnTouchstartIOS: (obj) => void;\n private handleKeyPressed: (obj: SFKeyPressObj) => void;\n public state: SFPState;\n public props;\n private issuingCountryCode;\n\n constructor(props: SFPProps) {\n super(props);\n\n const stateObj: SFPState = {\n status: 'loading',\n brand: props.type,\n errors: {},\n valid: {},\n data: {},\n cvcPolicy: CVC_POLICY_REQUIRED,\n expiryDatePolicy: DATE_POLICY_REQUIRED,\n isSfpValid: false,\n hasKoreanFields: props.hasKoreanFields\n };\n this.state = stateObj;\n\n this.csfLoadFailTimeout = null;\n this.csfLoadFailTimeoutMS = 30000;\n\n this.csfConfigFailTimeout = null;\n this.csfConfigFailTimeoutMS = 15000;\n\n this.numCharsInField = {};\n\n // Handlers\n this.handleOnLoad = handlers.handleOnLoad.bind(this);\n this.handleOnConfigSuccess = handlers.handleOnConfigSuccess.bind(this);\n this.handleOnFieldValid = handlers.handleOnFieldValid.bind(this);\n this.handleOnAllValid = handlers.handleOnAllValid.bind(this);\n this.handleOnBrand = handlers.handleOnBrand.bind(this);\n this.handleFocus = handlers.handleFocus.bind(this);\n this.handleOnError = handlers.handleOnError.bind(this);\n this.handleOnNoDataRequired = handlers.handleOnNoDataRequired.bind(this);\n this.handleOnAutoComplete = handlers.handleOnAutoComplete.bind(this);\n this.handleOnTouchstartIOS = handlers.handleOnTouchstartIOS.bind(this); // Only called when iOS detected\n this.handleKeyPressed = handlers.handleKeyPressed.bind(this);\n\n this.processBinLookupResponse = this.processBinLookupResponse.bind(this);\n\n // Bindings for functions exposed to users of this component: SecuredFields & CardInput\n this.setFocusOn = this.setFocusOn.bind(this);\n this.updateStyles = this.updateStyles.bind(this);\n this.handleUnsupportedCard = this.handleUnsupportedCard.bind(this);\n this.showValidation = this.showValidation.bind(this);\n this.destroy = this.destroy.bind(this);\n }\n\n public static defaultProps = defaultProps;\n\n public componentDidMount(): void {\n // When SFP instantiated through SecuredFieldsInput c.f. CardInput\n if (this.props.rootNode) {\n this.setRootNode(this.props.rootNode);\n }\n\n // Find encryptedFields and map them to the values we use to store valid states\n const fields = getFields(this.rootNode);\n const valid = fields.reduce(validFieldsReducer, {});\n\n this.setState({ valid });\n\n // Populate numCharsInField object\n fields.forEach(field => {\n this.numCharsInField[field] = 0;\n });\n\n // Store how many dateFields we are dealing with visually\n this.numDateFields = fields.filter(f => f.match(/Expiry/)).length;\n\n if (fields.length) {\n this.destroy(); // TODO test if this solves the React double render problem.\n this.initializeCSF(this.rootNode);\n } else {\n this.handleOnNoDataRequired();\n }\n }\n\n public componentDidUpdate() {\n this.checkForKCPFields();\n }\n\n public componentWillUnmount(): void {\n this.csf = null;\n clearTimeout(this.csfLoadFailTimeout);\n clearTimeout(this.csfConfigFailTimeout);\n }\n\n private initializeCSF(root: HTMLElement): void {\n let loadingContext = this.props.loadingContext;\n\n // For loading securedFields from local server during development\n if (process.env.NODE_ENV === 'development' && process.env.__SF_ENV__ !== 'build') {\n loadingContext = process.env.__SF_ENV__;\n }\n\n // TODO\n // if(!this.props.keypadFix){\n // send analytics action because to know if anyone *ever* sets this config prop\n // }\n\n const csfSetupObj: CSFSetupObject = {\n rootNode: root,\n type: this.props.type,\n clientKey: this.props.clientKey,\n cardGroupTypes: this.props.brands,\n autoFocus: this.props.autoFocus,\n trimTrailingSeparator: this.props.trimTrailingSeparator,\n loadingContext,\n keypadFix: this.props.keypadFix,\n showWarnings: this.props.showWarnings,\n iframeUIConfig: {\n sfStyles: this.props.styles\n },\n i18n: this.props.i18n,\n callbacks: {\n onLoad: this.handleOnLoad,\n onConfigSuccess: this.handleOnConfigSuccess,\n onFieldValid: this.handleOnFieldValid,\n onAllValid: this.handleOnAllValid,\n onBrand: this.handleOnBrand,\n onError: this.handleOnError,\n onFocus: this.handleFocus,\n onBinValue: this.props.onBinValue,\n onAutoComplete: this.handleOnAutoComplete,\n onAdditionalSFConfig: this.props.onAdditionalSFConfig,\n onAdditionalSFRemoved: this.props.onAdditionalSFRemoved,\n onTouchstartIOS: this.handleOnTouchstartIOS,\n onKeyPressed: this.handleKeyPressed\n },\n isKCP: this.state.hasKoreanFields,\n legacyInputMode: this.props.legacyInputMode,\n minimumExpiryDate: this.props.minimumExpiryDate,\n implementationType: this.props.implementationType || 'components', // to distinguish between 'regular' and 'custom' card component\n forceCompat: this.props.forceCompat,\n maskSecurityCode: this.props.maskSecurityCode,\n exposeExpiryDate: this.props.exposeExpiryDate,\n shouldDisableIOSArrowKeys: !!this.props.disableIOSArrowKeys, // convert whether function has been defined into a boolean\n placeholders: this.props.placeholders ?? {},\n showContextualElement: this.props.showContextualElement\n };\n\n this.csf = initCSF(csfSetupObj);\n\n /**\n * Expect to at least have had the handleOnLoad callback called within this time\n * - if this hasn't happened then something has happened to interrupt the loading of the securedFields\n * So we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n // @ts-ignore - timout 'type' is a number\n this.csfLoadFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfLoadFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured field iframes have failed to load'));\n }\n }, this.csfLoadFailTimeoutMS);\n }\n\n private checkForKCPFields() {\n let needsKoreanFields = false;\n if (this.props.koreanAuthenticationRequired) {\n needsKoreanFields = this.issuingCountryCode ? this.issuingCountryCode === 'kr' : this.props.countryCode === 'kr';\n }\n\n // Was korean, now isn't - hide password field\n if (this.state.hasKoreanFields && !needsKoreanFields) {\n // Clear any stored data\n const setRemovedFieldState = prevState => ({\n data: { ...prevState.data, [ENCRYPTED_PWD_FIELD]: undefined },\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n errors: { ...prevState.errors, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: false\n });\n\n this.setState(setRemovedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.removeSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(false);\n }\n\n // Wasn't korean, now is - show password field\n if (!this.state.hasKoreanFields && needsKoreanFields) {\n const setAddedFieldState = prevState => ({\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: true,\n isSfpValid: false\n });\n\n this.setState(setAddedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.addSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(true);\n }\n }\n\n public getChildContext(): object {\n return { i18n: this.props.i18n };\n }\n\n public handleUnsupportedCard(errObj: CbObjOnError): boolean {\n const hasUnsupportedCard = !!errObj.error;\n\n // Store the brand(s) we detected and which we don't support\n if (hasUnsupportedCard) {\n this.setState({ detectedUnsupportedBrands: errObj.detectedBrands });\n }\n\n errObj.rootNode = this.rootNode; // Needed for CustomCard\n this.handleOnError(errObj, hasUnsupportedCard);\n // Inform CSF that the number field has an unsupportedCard error (or that it has been cleared)\n if (this.csf) {\n this.csf.hasUnsupportedCard(ENCRYPTED_CARD_NUMBER, errObj.error);\n }\n return hasUnsupportedCard;\n }\n\n public setFocusOn(frame: string): void {\n if (this.csf) this.csf.setFocusOnFrame(frame);\n }\n\n public updateStyles(stylesObj: StylesObject): void {\n if (this.csf) this.csf.updateStyles(stylesObj);\n }\n\n public sfIsOptionalOrHidden(fieldType: string): boolean {\n return this.csf.sfIsOptionalOrHidden(fieldType);\n }\n\n public destroy(): void {\n if (this.csf) this.csf.destroy();\n }\n\n public showValidation(): void {\n const { numDateFields, state }: SecuredFieldsProvider = this;\n\n Object.keys(state.valid)\n .reduce(getErrorReducer(numDateFields, state), [])\n .forEach(field => {\n // For each detected error pass an error object to the handler (calls error callback & sets state)\n const errorObj: CbObjOnError = getErrorObject(field, this.rootNode, state);\n this.handleOnError(errorObj, !!state.detectedUnsupportedBrands);\n // Inform the secured-fields instance of which fields have been found to have errors\n if (this.csf && this.csf.isValidated) {\n this.csf.isValidated(field, errorObj.error);\n }\n });\n }\n\n /**\n * Map SF errors to ValidationRuleResult-like objects, for CardInput component\n */\n public mapErrorsToValidationRuleResult(): SFStateErrorObj {\n const fieldNames: string[] = Object.keys(this.state.errors);\n\n const sfStateErrorsObj = fieldNames.reduce((acc, fieldName) => {\n const errorCode = this.state.errors[fieldName];\n if (errorCode) {\n acc[fieldName] = {\n isValid: false,\n errorMessage: getErrorMessageFromCode(errorCode, SF_ErrorCodes), // this is the human-readable, untranslated, explanation of the error that will exist on the error object in card.state.errors\n // For v5 the object found in state.errors should also contain the additional properties that used to be sent to the onError callback\n // namely: translation, errorCode, a ref to rootNode &, in the case of failed binLookup, an array of the detectedBrands\n errorI18n: this.props.i18n.get(errorCode),\n error: errorCode,\n rootNode: this.rootNode,\n ...(this.state.detectedUnsupportedBrands && { detectedBrands: this.state.detectedUnsupportedBrands })\n };\n } else {\n acc[fieldName] = null;\n }\n return acc;\n }, {});\n return sfStateErrorsObj;\n }\n\n public processBinLookupResponse(binLookupResponse: BinLookupResponse, resetObject: SingleBrandResetObject): void {\n // If we were dealing with an unsupported card & now we have a valid /binLookup response (or a response triggering a reset of the UI),\n // - reset state to clear the error & the stored unsupportedBrands and, in the case of a valid /binLookup response, inform CSF (via handleUnsupportedCard)\n // (Scenario: from an unsupportedCard state the shopper has pasted another number long enough to trigger a /binLookup)\n if (this.state.detectedUnsupportedBrands) {\n this.setState(prevState => ({\n errors: { ...prevState.errors, [ENCRYPTED_CARD_NUMBER]: false },\n detectedUnsupportedBrands: null\n }));\n\n // If we have some sort of binLookupResponse object then this isn't the reset caused by digits dropping below a threshold\n // - so call handleUnsupportedCard to clear the error\n if (this.csf && binLookupResponse) {\n const errObj: CbObjOnError = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n this.handleUnsupportedCard(errObj);\n }\n }\n\n this.issuingCountryCode = binLookupResponse?.issuingCountryCode?.toLowerCase();\n\n const hasBrandedResetObj = resetObject?.brand;\n\n /**\n * Are we dealing with a \"dedicated\" card scenario i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands\n * - in which case we will need to reset brand and pass on the resetObj to CSF\n */\n const mustResetDedicatedBrand = hasBrandedResetObj && DEDICATED_CARD_COMPONENTS.includes(resetObject.brand);\n\n if (mustResetDedicatedBrand) {\n // resetObject.brand will be the value of the brand whose logo we want to reshow in the UI\n this.setState(resetObject, () => {\n this.props.onChange(this.state);\n });\n }\n\n /**\n * Scenarios:\n *\n * - RESET (binLookupResponse === null): The number of digits in number field has dropped below threshold for BIN lookup\n * - RESULT (binLookupResponse.supportedBrands.length === 1): binLookup has found a result so inform CSF\n *\n * In the RESET scenario, for \"dedicated\" card components we also need to pass on the resetObject since this contains information about\n * the brand that CSF needs to reset to, internally.\n */\n if (this.csf) this.csf.brandsFromBinLookup(binLookupResponse, mustResetDedicatedBrand ? resetObject : null);\n }\n\n private setRootNode = (input: HTMLElement): void => {\n this.rootNode = input;\n };\n\n public render(props, state) {\n return props.render({ setRootNode: this.setRootNode, setFocusOn: this.setFocusOn }, state);\n }\n}\n\nexport default SecuredFieldsProvider;\n"],"names":["SecuredFieldsProvider","Component","csfLoadFailTimeout","csfLoadFailTimeoutMS","csfConfigFailTimeout","csfConfigFailTimeoutMS","numCharsInField","rootNode","numDateFields","csf","handleOnLoad","handleOnConfigSuccess","handleOnFieldValid","handleOnAllValid","handleOnBrand","handleFocus","handleOnError","handleOnAutoComplete","handleOnNoDataRequired","handleOnTouchstartIOS","handleKeyPressed","state","props","issuingCountryCode","constructor","super","stateObj","status","brand","type","errors","valid","data","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","isSfpValid","hasKoreanFields","this","handlers","bind","processBinLookupResponse","setFocusOn","updateStyles","handleUnsupportedCard","showValidation","destroy","static","defaultProps","componentDidMount","setRootNode","fields","getFields","reduce","validFieldsReducer","setState","forEach","field","filter","f","match","length","initializeCSF","componentDidUpdate","checkForKCPFields","componentWillUnmount","clearTimeout","root","loadingContext","csfSetupObj","clientKey","cardGroupTypes","brands","autoFocus","trimTrailingSeparator","keypadFix","showWarnings","iframeUIConfig","sfStyles","styles","i18n","callbacks","onLoad","onConfigSuccess","onFieldValid","onAllValid","onBrand","onError","onFocus","onBinValue","onAutoComplete","onAdditionalSFConfig","onAdditionalSFRemoved","onTouchstartIOS","onKeyPressed","isKCP","legacyInputMode","minimumExpiryDate","implementationType","forceCompat","maskSecurityCode","exposeExpiryDate","shouldDisableIOSArrowKeys","disableIOSArrowKeys","placeholders","showContextualElement","initCSF","setTimeout","AdyenCheckoutError","needsKoreanFields","koreanAuthenticationRequired","countryCode","setRemovedFieldState","prevState","ENCRYPTED_PWD_FIELD","undefined","onChange","removeSecuredField","setKCPStatus","setAddedFieldState","addSecuredField","getChildContext","errObj","hasUnsupportedCard","error","detectedUnsupportedBrands","detectedBrands","ENCRYPTED_CARD_NUMBER","frame","setFocusOnFrame","stylesObj","sfIsOptionalOrHidden","fieldType","Object","keys","getErrorReducer","errorObj","getErrorObject","isValidated","mapErrorsToValidationRuleResult","acc","fieldName","errorCode","isValid","errorMessage","getErrorMessageFromCode","SF_ErrorCodes","errorI18n","get","binLookupResponse","resetObject","toLowerCase","hasBrandedResetObj","mustResetDedicatedBrand","DEDICATED_CARD_COMPONENTS","includes","brandsFromBinLookup","input","render"],"mappings":"8pBA8BA,MAAMA,UAA8BC,EACxBC,mBACAC,qBACAC,qBACAC,uBACAC,gBACAC,SACAC,cACAC,IACAC,aACAC,sBACAC,mBACAC,iBACAC,cACAC,YACAC,cACAC,qBACAC,uBACAC,sBACAC,iBACDC,MACAC,MACCC,mBAERC,WAAAA,CAAYF,GACRG,MAAMH,GAEN,MAAMI,EAAqB,CACvBC,OAAQ,UACRC,MAAON,EAAMO,KACbC,OAAQ,CAAC,EACTC,MAAO,CAAC,EACRC,KAAM,CAAC,EACPC,UAAWC,EACXC,iBAAkBC,EAClBC,YAAY,EACZC,gBAAiBhB,EAAMgB,iBAE3BC,KAAKlB,MAAQK,EAEba,KAAKrC,mBAAqB,KAC1BqC,KAAKpC,qBAAuB,IAE5BoC,KAAKnC,qBAAuB,KAC5BmC,KAAKlC,uBAAyB,KAE9BkC,KAAKjC,gBAAkB,GAGvBiC,KAAK7B,aAAe8B,EAAS9B,aAAa+B,KAAKF,MAC/CA,KAAK5B,sBAAwB6B,EAAS7B,sBAAsB8B,KAAKF,MACjEA,KAAK3B,mBAAqB4B,EAAS5B,mBAAmB6B,KAAKF,MAC3DA,KAAK1B,iBAAmB2B,EAAS3B,iBAAiB4B,KAA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XvF,KAAKiB,UAAS0D,IAAc,CACxBpF,OAAQ,IAAKoF,EAAUpF,OAAQkG,CAACA,IAAwB,GACxDF,0BAA2B,SAK3BvF,KAAK9B,KAAO6I,GAAmB,CAC/B,MAAM3B,EAAuB,CACzB9F,KAAM,OACNwG,UAAW,sBACXR,MAAO,IAEXtF,KAAKM,sBAAsB8E,EAC/B,CAGJpF,KAAKhB,mBAAqB+H,GAAmB/H,oBAAoBiI,cAEjE,MAAMC,EAAqBF,GAAa3H,MAMlC8H,EAA0BD,GAAsBE,EAA0BC,SAASL,EAAY3H,OAEjG8H,GAEAnH,KAAKiB,SAAS+F,GAAa,KACvBhH,KAAKjB,MAAM+F,SAAS9E,KAAKlB,MAAK,IAalCkB,KAAK9B,KAAK8B,KAAK9B,IAAIoJ,oBAAoBP,EAAmBI,EAA0BH,EAAc,KAC1G,CAEQpG,YAAe2G,IACnBvH,KAAKhC,SAAWuJ,CAAAA,EAGbC,MAAAA,CAAOzI,EAAOD,GACjB,OAAOC,EAAMyI,OAAO,CAAE5G,YAAaZ,KAAKY,YAAaR,WAAYJ,KAAKI,YAActB,EACxF"}
1
+ {"version":3,"file":"SecuredFieldsProvider.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SecuredFieldsProvider.ts"],"sourcesContent":["import { Component } from 'preact';\nimport { getErrorObject, getFields, getErrorReducer, validFieldsReducer } from './SFPUtils';\nimport initCSF from '../lib/CSF';\nimport handlers from './SecuredFieldsProviderHandlers';\nimport defaultProps from './defaultProps';\nimport { SFPProps, SFPState, SingleBrandResetObject } from './types';\nimport {\n StylesObject,\n CbObjOnError,\n CbObjOnFocus,\n CbObjOnBrand,\n CbObjOnAllValid,\n CbObjOnFieldValid,\n CbObjOnAutoComplete,\n CbObjOnConfigSuccess,\n CbObjOnLoad,\n SFKeyPressObj\n} from '../lib/types';\nimport { CSFReturnObject, CSFSetupObject } from '../lib/CSF/types';\nimport { CVC_POLICY_REQUIRED, DATE_POLICY_REQUIRED, DEDICATED_CARD_COMPONENTS, ENCRYPTED_CARD_NUMBER, ENCRYPTED_PWD_FIELD } from '../lib/constants';\nimport { BinLookupResponse } from '../../../Card/types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { SFStateErrorObj } from '../../../Card/components/CardInput/types';\nimport { getErrorMessageFromCode } from '../../../../core/Errors/utils';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\n\n/**\n * SecuredFieldsProvider:\n * Initialises & handles the client-side part of SecuredFields\n */\nclass SecuredFieldsProvider extends Component<SFPProps, SFPState> {\n private csfLoadFailTimeout: number;\n private csfLoadFailTimeoutMS: number;\n private csfConfigFailTimeout: number;\n private csfConfigFailTimeoutMS: number;\n private numCharsInField: object;\n private rootNode;\n private numDateFields: number;\n private csf: CSFReturnObject;\n private handleOnLoad: (obj: CbObjOnLoad) => void;\n private handleOnConfigSuccess: (obj: CbObjOnConfigSuccess) => void;\n private handleOnFieldValid: (obj: CbObjOnFieldValid) => void;\n private handleOnAllValid: (obj: CbObjOnAllValid) => void;\n private handleOnBrand: (obj: CbObjOnBrand) => void;\n private handleFocus: (obj: CbObjOnFocus) => void;\n private handleOnError: (obj: CbObjOnError, hasUnsupportedCard?: boolean) => void;\n private handleOnAutoComplete: (obj: CbObjOnAutoComplete) => void;\n private handleOnNoDataRequired: () => void;\n private handleOnTouchstartIOS: (obj) => void;\n private handleKeyPressed: (obj: SFKeyPressObj) => void;\n public state: SFPState;\n public props;\n private issuingCountryCode;\n\n constructor(props: SFPProps) {\n super(props);\n\n const stateObj: SFPState = {\n status: 'loading',\n brand: props.type,\n errors: {},\n valid: {},\n data: {},\n cvcPolicy: CVC_POLICY_REQUIRED,\n expiryDatePolicy: DATE_POLICY_REQUIRED,\n isSfpValid: false,\n hasKoreanFields: props.hasKoreanFields\n };\n this.state = stateObj;\n\n this.csfLoadFailTimeout = null;\n this.csfLoadFailTimeoutMS = 30000;\n\n this.csfConfigFailTimeout = null;\n this.csfConfigFailTimeoutMS = 15000;\n\n this.numCharsInField = {};\n\n // Handlers\n this.handleOnLoad = handlers.handleOnLoad.bind(this);\n this.handleOnConfigSuccess = handlers.handleOnConfigSuccess.bind(this);\n this.handleOnFieldValid = handlers.handleOnFieldValid.bind(this);\n this.handleOnAllValid = handlers.handleOnAllValid.bind(this);\n this.handleOnBrand = handlers.handleOnBrand.bind(this);\n this.handleFocus = handlers.handleFocus.bind(this);\n this.handleOnError = handlers.handleOnError.bind(this);\n this.handleOnNoDataRequired = handlers.handleOnNoDataRequired.bind(this);\n this.handleOnAutoComplete = handlers.handleOnAutoComplete.bind(this);\n this.handleOnTouchstartIOS = handlers.handleOnTouchstartIOS.bind(this); // Only called when iOS detected\n this.handleKeyPressed = handlers.handleKeyPressed.bind(this);\n\n this.processBinLookupResponse = this.processBinLookupResponse.bind(this);\n\n // Bindings for functions exposed to users of this component: SecuredFields & CardInput\n this.setFocusOn = this.setFocusOn.bind(this);\n this.updateStyles = this.updateStyles.bind(this);\n this.handleUnsupportedCard = this.handleUnsupportedCard.bind(this);\n this.showValidation = this.showValidation.bind(this);\n this.destroy = this.destroy.bind(this);\n }\n\n public static defaultProps = defaultProps;\n\n public componentDidMount(): void {\n // When SFP instantiated through SecuredFieldsInput c.f. CardInput\n if (this.props.rootNode) {\n this.setRootNode(this.props.rootNode);\n }\n\n // Find encryptedFields and map them to the values we use to store valid states\n const fields = getFields(this.rootNode);\n const valid = fields.reduce(validFieldsReducer, {});\n\n this.setState({ valid });\n\n // Populate numCharsInField object\n fields.forEach(field => {\n this.numCharsInField[field] = 0;\n });\n\n // Store how many dateFields we are dealing with visually\n this.numDateFields = fields.filter(f => f.match(/Expiry/)).length;\n\n if (fields.length) {\n this.destroy(); // TODO test if this solves the React double render problem.\n this.initializeCSF(this.rootNode);\n } else {\n this.handleOnNoDataRequired();\n }\n }\n\n public componentDidUpdate() {\n this.checkForKCPFields();\n }\n\n public componentWillUnmount(): void {\n this.csf = null;\n clearTimeout(this.csfLoadFailTimeout);\n clearTimeout(this.csfConfigFailTimeout);\n }\n\n private initializeCSF(root: HTMLElement): void {\n let loadingContext = this.props.loadingContext;\n\n // For loading securedFields from local server during development\n if (process.env.NODE_ENV === 'development' && process.env.__SF_ENV__ !== 'build') {\n loadingContext = process.env.__SF_ENV__;\n }\n\n // TODO\n // if(!this.props.keypadFix){\n // send analytics action because to know if anyone *ever* sets this config prop\n // }\n\n const csfSetupObj: CSFSetupObject = {\n rootNode: root,\n type: this.props.type,\n clientKey: this.props.clientKey,\n cardGroupTypes: this.props.brands,\n autoFocus: this.props.autoFocus,\n trimTrailingSeparator: this.props.trimTrailingSeparator,\n loadingContext,\n keypadFix: this.props.keypadFix,\n showWarnings: this.props.showWarnings,\n iframeUIConfig: {\n sfStyles: this.props.styles\n },\n i18n: this.props.i18n,\n callbacks: {\n onLoad: this.handleOnLoad,\n onConfigSuccess: this.handleOnConfigSuccess,\n onFieldValid: this.handleOnFieldValid,\n onAllValid: this.handleOnAllValid,\n onBrand: this.handleOnBrand,\n onError: this.handleOnError,\n onFocus: this.handleFocus,\n onBinValue: this.props.onBinValue,\n onAutoComplete: this.handleOnAutoComplete,\n onAdditionalSFConfig: this.props.onAdditionalSFConfig,\n onAdditionalSFRemoved: this.props.onAdditionalSFRemoved,\n onTouchstartIOS: this.handleOnTouchstartIOS,\n onKeyPressed: this.handleKeyPressed\n },\n isKCP: this.state.hasKoreanFields,\n legacyInputMode: this.props.legacyInputMode,\n minimumExpiryDate: this.props.minimumExpiryDate,\n implementationType: this.props.implementationType || 'components', // to distinguish between 'regular' and 'custom' card component\n forceCompat: this.props.forceCompat,\n maskSecurityCode: this.props.maskSecurityCode,\n exposeExpiryDate: this.props.exposeExpiryDate,\n shouldDisableIOSArrowKeys: !!this.props.disableIOSArrowKeys, // convert whether function has been defined into a boolean\n placeholders: this.props.placeholders ?? {},\n showContextualElement: this.props.showContextualElement\n };\n\n this.csf = initCSF(csfSetupObj);\n\n /**\n * Expect to at least have had the handleOnLoad callback called within this time\n * - if this hasn't happened then something has happened to interrupt the loading of the securedFields\n * So we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n // @ts-ignore - timout 'type' is a number\n this.csfLoadFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfLoadFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured field iframes have failed to load'));\n }\n }, this.csfLoadFailTimeoutMS);\n }\n\n private checkForKCPFields() {\n let needsKoreanFields = false;\n if (this.props.koreanAuthenticationRequired) {\n needsKoreanFields = this.issuingCountryCode ? this.issuingCountryCode === 'kr' : this.props.countryCode === 'kr';\n }\n\n // Was korean, now isn't - hide password field\n if (this.state.hasKoreanFields && !needsKoreanFields) {\n // Clear any stored data\n const setRemovedFieldState = prevState => ({\n data: { ...prevState.data, [ENCRYPTED_PWD_FIELD]: undefined },\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n errors: { ...prevState.errors, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: false\n });\n\n this.setState(setRemovedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.removeSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(false);\n }\n\n // Wasn't korean, now is - show password field\n if (!this.state.hasKoreanFields && needsKoreanFields) {\n const setAddedFieldState = prevState => ({\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: true,\n isSfpValid: false\n });\n\n this.setState(setAddedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.addSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(true);\n }\n }\n\n public getChildContext(): object {\n return { i18n: this.props.i18n };\n }\n\n public handleUnsupportedCard(errObj: CbObjOnError): boolean {\n const hasUnsupportedCard = !!errObj.error;\n\n // Store the brand(s) we detected and which we don't support\n if (hasUnsupportedCard) {\n this.setState({ detectedUnsupportedBrands: errObj.detectedBrands });\n }\n\n errObj.rootNode = this.rootNode; // Needed for CustomCard\n this.handleOnError(errObj, hasUnsupportedCard);\n // Inform CSF that the number field has an unsupportedCard error (or that it has been cleared)\n if (this.csf) {\n this.csf.hasUnsupportedCard(ENCRYPTED_CARD_NUMBER, errObj.error);\n }\n return hasUnsupportedCard;\n }\n\n public setFocusOn(frame: string): void {\n if (this.csf) this.csf.setFocusOnFrame(frame);\n }\n\n public updateStyles(stylesObj: StylesObject): void {\n if (this.csf) this.csf.updateStyles(stylesObj);\n }\n\n public sfIsOptionalOrHidden(fieldType: string): boolean {\n return this.csf.sfIsOptionalOrHidden(fieldType);\n }\n\n public destroy(): void {\n if (this.csf) this.csf.destroy();\n }\n\n public showValidation(): void {\n const { numDateFields, state }: SecuredFieldsProvider = this;\n\n Object.keys(state.valid)\n .reduce(getErrorReducer(numDateFields, state), [])\n .forEach(field => {\n // For each detected error pass an error object to the handler (calls error callback & sets state)\n const errorObj: CbObjOnError = getErrorObject(field, this.rootNode, state);\n this.handleOnError(errorObj, !!state.detectedUnsupportedBrands);\n // Inform the secured-fields instance of which fields have been found to have errors\n if (this.csf && this.csf.isValidated) {\n this.csf.isValidated(field, errorObj.error);\n }\n });\n }\n\n /**\n * Map SF errors to ValidationRuleResult-like objects, for CardInput component\n */\n public mapErrorsToValidationRuleResult(): SFStateErrorObj {\n const fieldNames: string[] = Object.keys(this.state.errors);\n\n const sfStateErrorsObj = fieldNames.reduce((acc, fieldName) => {\n const errorCode = this.state.errors[fieldName];\n if (errorCode) {\n acc[fieldName] = {\n isValid: false,\n errorMessage: getErrorMessageFromCode(errorCode, SF_ErrorCodes), // this is the human-readable, untranslated, explanation of the error that will exist on the error object in card.state.errors\n // For v5 the object found in state.errors should also contain the additional properties that used to be sent to the onError callback\n // namely: translation, errorCode, a ref to rootNode &, in the case of failed binLookup, an array of the detectedBrands\n errorI18n: this.props.i18n.get(errorCode),\n error: errorCode,\n rootNode: this.rootNode,\n ...(this.state.detectedUnsupportedBrands && { detectedBrands: this.state.detectedUnsupportedBrands })\n };\n } else {\n acc[fieldName] = null;\n }\n return acc;\n }, {});\n return sfStateErrorsObj;\n }\n\n public processBinLookupResponse(binLookupResponse: BinLookupResponse, resetObject: SingleBrandResetObject): void {\n // If we were dealing with an unsupported card & now we have a valid /binLookup response (or a response triggering a reset of the UI),\n // - reset state to clear the error & the stored unsupportedBrands and, in the case of a valid /binLookup response, inform CSF (via handleUnsupportedCard)\n // (Scenario: from an unsupportedCard state the shopper has pasted another number long enough to trigger a /binLookup)\n if (this.state.detectedUnsupportedBrands) {\n this.setState(prevState => ({\n errors: { ...prevState.errors, [ENCRYPTED_CARD_NUMBER]: false },\n detectedUnsupportedBrands: null\n }));\n\n // If we have some sort of binLookupResponse object then this isn't the reset caused by digits dropping below a threshold\n // - so call handleUnsupportedCard to clear the error\n if (this.csf && binLookupResponse) {\n const errObj: CbObjOnError = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n this.handleUnsupportedCard(errObj);\n }\n }\n\n this.issuingCountryCode = binLookupResponse?.issuingCountryCode?.toLowerCase();\n\n const hasBrandedResetObj = resetObject?.brand;\n\n /**\n * Are we dealing with a \"dedicated\" card scenario i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands\n * - in which case we will need to reset brand and pass on the resetObj to CSF\n */\n const mustResetDedicatedBrand = hasBrandedResetObj && DEDICATED_CARD_COMPONENTS.includes(resetObject.brand);\n\n if (mustResetDedicatedBrand) {\n // resetObject.brand will be the value of the brand whose logo we want to reshow in the UI\n this.setState(resetObject, () => {\n this.props.onChange(this.state);\n });\n }\n\n /**\n * Scenarios:\n *\n * - RESET (binLookupResponse === null): The number of digits in number field has dropped below threshold for BIN lookup\n * - RESULT (binLookupResponse.supportedBrands.length === 1): binLookup has found a result so inform CSF\n *\n * In the RESET scenario, for \"dedicated\" card components we also need to pass on the resetObject since this contains information about\n * the brand that CSF needs to reset to, internally.\n */\n if (this.csf) this.csf.brandsFromBinLookup(binLookupResponse, mustResetDedicatedBrand ? resetObject : null);\n }\n\n private setRootNode = (input: HTMLElement): void => {\n this.rootNode = input;\n };\n\n public render(props, state) {\n return props.render({ setRootNode: this.setRootNode, setFocusOn: this.setFocusOn }, state);\n }\n}\n\nexport default SecuredFieldsProvider;\n"],"names":["SecuredFieldsProvider","Component","componentDidMount","this","props","rootNode","setRootNode","fields","getFields","valid","reduce","validFieldsReducer","setState","forEach","field","numCharsInField","numDateFields","filter","f","match","length","destroy","initializeCSF","handleOnNoDataRequired","componentDidUpdate","checkForKCPFields","componentWillUnmount","csf","clearTimeout","csfLoadFailTimeout","csfConfigFailTimeout","root","loadingContext","csfSetupObj","type","clientKey","cardGroupTypes","brands","autoFocus","trimTrailingSeparator","keypadFix","showWarnings","iframeUIConfig","sfStyles","styles","i18n","callbacks","onLoad","handleOnLoad","onConfigSuccess","handleOnConfigSuccess","onFieldValid","handleOnFieldValid","onAllValid","handleOnAllValid","onBrand","handleOnBrand","onError","handleOnError","onFocus","handleFocus","onBinValue","onAutoComplete","handleOnAutoComplete","onAdditionalSFConfig","onAdditionalSFRemoved","onTouchstartIOS","handleOnTouchstartIOS","onKeyPressed","handleKeyPressed","isKCP","state","hasKoreanFields","legacyInputMode","minimumExpiryDate","implementationType","forceCompat","maskSecurityCode","exposeExpiryDate","shouldDisableIOSArrowKeys","disableIOSArrowKeys","placeholders","showContextualElement","initCSF","setTimeout","status","AdyenCheckoutError","csfLoadFailTimeoutMS","needsKoreanFields","koreanAuthenticationRequired","issuingCountryCode","countryCode","setRemovedFieldState","prevState","data","ENCRYPTED_PWD_FIELD","undefined","errors","onChange","removeSecuredField","setKCPStatus","setAddedFieldState","isSfpValid","addSecuredField","getChildContext","handleUnsupportedCard","errObj","hasUnsupportedCard","error","detectedUnsupportedBrands","detectedBrands","ENCRYPTED_CARD_NUMBER","setFocusOn","frame","setFocusOnFrame","updateStyles","stylesObj","sfIsOptionalOrHidden","fieldType","showValidation","Object","keys","getErrorReducer","errorObj","getErrorObject","isValidated","mapErrorsToValidationRuleResult","acc","fieldName","errorCode","isValid","errorMessage","getErrorMessageFromCode","SF_ErrorCodes","errorI18n","get","processBinLookupResponse","binLookupResponse","resetObject","toLowerCase","hasBrandedResetObj","brand","mustResetDedicatedBrand","DEDICATED_CARD_COMPONENTS","includes","brandsFromBinLookup","render","constructor","super","_define_property","csfConfigFailTimeoutMS","input","stateObj","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","handlers","bind","defaultProps"],"mappings":"sxBA8BA,MAAMA,UAA8BC,EAyEzBC,iBAAAA,GAECC,KAAKC,MAAMC,UACXF,KAAKG,YAAYH,KAAKC,MAAMC,UAIhC,MAAME,EAASC,EAAUL,KAAKE,UACxBI,EAAQF,EAAOG,OAAOC,EAAoB,CAAC,GAEjDR,KAAKS,SAAS,CAAEH,UAGhBF,EAAOM,SAAQC,IACXX,KAAKY,gBAAgBD,GAAS,CAAA,IAIlCX,KAAKa,cAAgBT,EAAOU,QAAOC,GAAKA,EAAEC,MAAM,YAAWC,OAEvDb,EAAOa,QACPjB,KAAKkB,UACLlB,KAAKmB,cAAcnB,KAAKE,WAExBF,KAAKoB,wBAEb,CAEOC,kBAAAA,GACHrB,KAAKsB,mBACT,CAEOC,oBAAAA,GACHvB,KAAKwB,IAAM,KACXC,aAAazB,KAAK0B,oBAClBD,aAAazB,KAAK2B,qBACtB,CAEQR,aAAAA,CAAcS,GAClB,IAAIC,EAAiB7B,KAAKC,MAAM4B,eAYhC,MAAMC,EAA8B,CAChC5B,SAAU0B,EACVG,KAAM/B,KAAKC,MAAM8B,KACjBC,UAAWhC,KAAKC,MAAM+B,UACtBC,eAAgBjC,KAAKC,MAAMiC,OAC3BC,UAAWnC,KAAKC,MAAMkC,UACtBC,sBAAuBpC,KAAKC,MAAMmC,sBAClCP,iBACAQ,UAAWrC,KAAKC,MAAMoC,UACtBC,aAActC,KAAKC,MAAMqC,aACzBC,eAAgB,CACZC,SAAUxC,KAAKC,MAAMwC,QAEzBC,KAAM1C,KAA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BAE3BrE,KAAKoE,MAAQiF,EAEbrJ,KAAK0B,mBAAqB,KAC1B1B,KAAKoF,qBAAuB,IAE5BpF,KAAK2B,qBAAuB,KAC5B3B,KAAKmJ,uBAAyB,KAE9BnJ,KAAKY,gBAAkB,GAGvBZ,KAAK6C,aAAe6G,EAAS7G,aAAa8G,KAAK3J,MAC/CA,KAAK+C,sBAAwB2G,EAAS3G,sBAAsB4G,KAAK3J,MACjEA,KAAKiD,mBAAqByG,EAASzG,mBAAmB0G,KAAK3J,MAC3DA,KAAKmD,iBAAmBuG,EAASvG,iBAAiBwG,KAAK3J,MACvDA,KAAKqD,cAAgBqG,EAASrG,cAAcsG,KAAK3J,MACjDA,KAAKyD,YAAciG,EAASjG,YAAYkG,KAAK3J,MAC7CA,KAAKuD,cAAgBmG,EAASnG,cAAcoG,KAAK3J,MACjDA,KAAKoB,uBAAyBsI,EAAStI,uBAAuBuI,KAAK3J,MACnEA,KAAK4D,qBAAuB8F,EAAS9F,qBAAqB+F,KAAK3J,MAC/DA,KAAKgE,sBAAwB0F,EAAS1F,sBAAsB2F,KAAK3J,MACjEA,KAAKkE,iBAAmBwF,EAASxF,iBAAiByF,KAAK3J,MAEvDA,KAAKqI,yBAA2BrI,KAAKqI,yBAAyBsB,KAAK3J,MAGnEA,KAAK6G,WAAa7G,KAAK6G,WAAW8C,KAAK3J,MACvCA,KAAKgH,aAAehH,KAAKgH,aAAa2C,KAAK3J,MAC3CA,KAAKsG,sBAAwBtG,KAAKsG,sBAAsBqD,KAAK3J,MAC7DA,KAAKoH,eAAiBpH,KAAKoH,eAAeuC,KAAK3J,MAC/CA,KAAKkB,QAAUlB,KAAKkB,QAAQyI,KAAK3J,KACrC,EAEAkJ,EAvEErJ,EAuEY+J,eAAeA"}
@@ -1,2 +1,2 @@
1
- class e{callbacks;config;props;state;validateForm;handleBrandFromBinLookup;callbacksHandler;configHandler;createCardSecuredFields;createNonCardSecuredFields;createSecuredFields;destroySecuredFields;handleIOSTouchEvents;destroyTouchendListener;destroyTouchstartListener;handleBinValue;handleEncryption;handleFocus;handleIframeConfigFeedback;handleValidation;handleSFShiftTab;handleShiftTab;isConfigured;postMessageToAllIframes;processAutoComplete;processBrand;sendBrandToCardSF;sendExpiryDatePolicyToSF;setFocusOnFrame;setupSecuredField;touchendListener;touchstartListener;hasGenuineTouchEvents;encryptedAttrName;hasRedundantCVCField;isSingleBrandedCard;securityCode;constructor(e){this.props=e,this.state={},this.config={},this.callbacks={}}}export{e as default};
1
+ function i(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}class e{constructor(e){i(this,"callbacks",void 0),i(this,"config",void 0),i(this,"props",void 0),i(this,"state",void 0),i(this,"validateForm",void 0),i(this,"handleBrandFromBinLookup",void 0),i(this,"callbacksHandler",void 0),i(this,"configHandler",void 0),i(this,"createCardSecuredFields",void 0),i(this,"createNonCardSecuredFields",void 0),i(this,"createSecuredFields",void 0),i(this,"destroySecuredFields",void 0),i(this,"handleIOSTouchEvents",void 0),i(this,"destroyTouchendListener",void 0),i(this,"destroyTouchstartListener",void 0),i(this,"handleBinValue",void 0),i(this,"handleEncryption",void 0),i(this,"handleFocus",void 0),i(this,"handleIframeConfigFeedback",void 0),i(this,"handleValidation",void 0),i(this,"handleSFShiftTab",void 0),i(this,"handleShiftTab",void 0),i(this,"isConfigured",void 0),i(this,"postMessageToAllIframes",void 0),i(this,"processAutoComplete",void 0),i(this,"processBrand",void 0),i(this,"sendBrandToCardSF",void 0),i(this,"sendExpiryDatePolicyToSF",void 0),i(this,"setFocusOnFrame",void 0),i(this,"setupSecuredField",void 0),i(this,"touchendListener",void 0),i(this,"touchstartListener",void 0),i(this,"hasGenuineTouchEvents",void 0),i(this,"encryptedAttrName",void 0),i(this,"hasRedundantCVCField",void 0),i(this,"isSingleBrandedCard",void 0),i(this,"securityCode",void 0),this.props=e,this.state={},this.config={},this.callbacks={}}}export{e as default};
2
2
  //# sourceMappingURL=AbstractCSF.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractCSF.js","sources":["../../../../../../../src/components/internal/SecuredFields/lib/CSF/AbstractCSF.ts"],"sourcesContent":["import { CSFSetupObject, CSFConfigObject, CSFCallbacksConfig, CSFStateObject } from './types';\nimport { SFFeedbackObj, SendBrandObject, SendExpiryDateObject, CVCPolicyType, DatePolicyType, SFFieldType } from '../types';\nimport { createSecuredFields } from './extensions/createSecuredFields';\nimport processBrand from './partials/processBrand';\nimport handleBrandFromBinLookup from './extensions/handleBrandFromBinLookup';\n\nabstract class AbstractCSF {\n // Set in CSF\n protected callbacks: CSFCallbacksConfig;\n protected config: CSFConfigObject;\n protected props: CSFSetupObject;\n protected state: CSFStateObject;\n protected validateForm: () => void;\n protected handleBrandFromBinLookup: typeof handleBrandFromBinLookup;\n protected callbacksHandler: (callbacksObj: object) => void;\n protected configHandler: (props: CSFSetupObject) => void;\n protected createCardSecuredFields: (securedFields: HTMLElement[], cvcPolicy: CVCPolicyType, expiryDatePolicy: DatePolicyType) => Promise<any>;\n protected createNonCardSecuredFields: (securedFields: HTMLElement[]) => Promise<any>;\n protected createSecuredFields: typeof createSecuredFields;\n protected destroySecuredFields: () => void;\n protected handleIOSTouchEvents: () => void;\n protected destroyTouchendListener: () => void;\n protected destroyTouchstartListener: () => void;\n protected handleBinValue: (pFeedbackObj: SFFeedbackObj) => void;\n protected handleEncryption: (pFeedbackObj: SFFeedbackObj) => void;\n protected handleFocus: (pFeedbackObj: SFFeedbackObj) => void;\n protected handleIframeConfigFeedback: (pFeedbackObj) => boolean;\n protected handleValidation: (pFeedbackObj: SFFeedbackObj) => void;\n protected handleSFShiftTab: (fieldType: string) => void;\n protected handleShiftTab: (fieldType: string) => void;\n protected isConfigured: () => void;\n protected postMessageToAllIframes: (pDataObj: object) => void;\n protected processAutoComplete: (pFeedbackObj: SFFeedbackObj) => void;\n protected processBrand: typeof processBrand;\n protected sendBrandToCardSF: (brandObj: SendBrandObject) => void;\n protected sendExpiryDatePolicyToSF: (dateObj: SendExpiryDateObject) => void;\n protected setFocusOnFrame: (pFieldType: SFFieldType, doLog?: boolean) => void;\n protected setupSecuredField: (pItem: HTMLElement) => void;\n protected touchendListener: (e: Event) => void;\n protected touchstartListener: () => void;\n protected hasGenuineTouchEvents: boolean;\n // Set in createSecuredFields\n protected encryptedAttrName: string;\n protected hasRedundantCVCField: boolean;\n protected isSingleBrandedCard: boolean;\n protected securityCode: string;\n // --\n protected constructor(setupObj: CSFSetupObject) {\n this.props = setupObj;\n this.state = {} as any as CSFStateObject;\n\n // Initialise storage objects\n this.config = {} as any as CSFConfigObject; // {} as ConfigObject fails in linting\n this.callbacks = {} as any as CSFCallbacksConfig;\n }\n}\nexport default AbstractCSF;\n"],"names":["AbstractCSF","callbacks","config","props","state","validateForm","handleBrandFromBinLookup","callbacksHandler","configHandler","createCardSecuredFields","createNonCardSecuredFields","createSecuredFields","destroySecuredFields","handleIOSTouchEvents","destroyTouchendListener","destroyTouchstartListener","handleBinValue","handleEncryption","handleFocus","handleIframeConfigFeedback","handleValidation","handleSFShiftTab","handleShiftTab","isConfigured","postMessageToAllIframes","processAutoComplete","processBrand","sendBrandToCardSF","sendExpiryDatePolicyToSF","setFocusOnFrame","setupSecuredField","touchendListener","touchstartListener","hasGenuineTouchEvents","encryptedAttrName","hasRedundantCVCField","isSingleBrandedCard","securityCode","constructor","setupObj","this"],"mappings":"AAMA,MAAeA,EAEDC,UACAC,OACAC,MACAC,MACAC,aACAC,yBACAC,iBACAC,cACAC,wBACAC,2BACAC,oBACAC,qBACAC,qBACAC,wBACAC,0BACAC,eACAC,iBACAC,YACAC,2BACAC,iBACAC,iBACAC,eACAC,aACAC,wBACAC,oBACAC,aACAC,kBACAC,yBACAC,gBACAC,kBACAC,iBACAC,mBACAC,sBAEAC,kBACAC,qBACAC,oBACAC,aAEV,WAAAC,CAAsBC,GAClBC,KAAKrC,MAAQoC,EACbC,KAAKpC,MAAQ,GAGboC,KAAKtC,OAAS,GACdsC,KAAKvC,UAAY,EACrB"}
1
+ {"version":3,"file":"AbstractCSF.js","sources":["../../../../../../../src/components/internal/SecuredFields/lib/CSF/AbstractCSF.ts"],"sourcesContent":["import { CSFSetupObject, CSFConfigObject, CSFCallbacksConfig, CSFStateObject } from './types';\nimport { SFFeedbackObj, SendBrandObject, SendExpiryDateObject, CVCPolicyType, DatePolicyType, SFFieldType } from '../types';\nimport { createSecuredFields } from './extensions/createSecuredFields';\nimport processBrand from './partials/processBrand';\nimport handleBrandFromBinLookup from './extensions/handleBrandFromBinLookup';\n\nabstract class AbstractCSF {\n // Set in CSF\n protected callbacks: CSFCallbacksConfig;\n protected config: CSFConfigObject;\n protected props: CSFSetupObject;\n protected state: CSFStateObject;\n protected validateForm: () => void;\n protected handleBrandFromBinLookup: typeof handleBrandFromBinLookup;\n protected callbacksHandler: (callbacksObj: object) => void;\n protected configHandler: (props: CSFSetupObject) => void;\n protected createCardSecuredFields: (securedFields: HTMLElement[], cvcPolicy: CVCPolicyType, expiryDatePolicy: DatePolicyType) => Promise<any>;\n protected createNonCardSecuredFields: (securedFields: HTMLElement[]) => Promise<any>;\n protected createSecuredFields: typeof createSecuredFields;\n protected destroySecuredFields: () => void;\n protected handleIOSTouchEvents: () => void;\n protected destroyTouchendListener: () => void;\n protected destroyTouchstartListener: () => void;\n protected handleBinValue: (pFeedbackObj: SFFeedbackObj) => void;\n protected handleEncryption: (pFeedbackObj: SFFeedbackObj) => void;\n protected handleFocus: (pFeedbackObj: SFFeedbackObj) => void;\n protected handleIframeConfigFeedback: (pFeedbackObj) => boolean;\n protected handleValidation: (pFeedbackObj: SFFeedbackObj) => void;\n protected handleSFShiftTab: (fieldType: string) => void;\n protected handleShiftTab: (fieldType: string) => void;\n protected isConfigured: () => void;\n protected postMessageToAllIframes: (pDataObj: object) => void;\n protected processAutoComplete: (pFeedbackObj: SFFeedbackObj) => void;\n protected processBrand: typeof processBrand;\n protected sendBrandToCardSF: (brandObj: SendBrandObject) => void;\n protected sendExpiryDatePolicyToSF: (dateObj: SendExpiryDateObject) => void;\n protected setFocusOnFrame: (pFieldType: SFFieldType, doLog?: boolean) => void;\n protected setupSecuredField: (pItem: HTMLElement) => void;\n protected touchendListener: (e: Event) => void;\n protected touchstartListener: () => void;\n protected hasGenuineTouchEvents: boolean;\n // Set in createSecuredFields\n protected encryptedAttrName: string;\n protected hasRedundantCVCField: boolean;\n protected isSingleBrandedCard: boolean;\n protected securityCode: string;\n // --\n protected constructor(setupObj: CSFSetupObject) {\n this.props = setupObj;\n this.state = {} as any as CSFStateObject;\n\n // Initialise storage objects\n this.config = {} as any as CSFConfigObject; // {} as ConfigObject fails in linting\n this.callbacks = {} as any as CSFCallbacksConfig;\n }\n}\nexport default AbstractCSF;\n"],"names":["AbstractCSF","constructor","setupObj","_define_property","this","callbacks","config","props","state","validateForm","handleBrandFromBinLookup","callbacksHandler","configHandler","createCardSecuredFields","createNonCardSecuredFields","createSecuredFields","destroySecuredFields","handleIOSTouchEvents","destroyTouchendListener","destroyTouchstartListener","handleBinValue","handleEncryption","handleFocus","handleIframeConfigFeedback","handleValidation","handleSFShiftTab","handleShiftTab","isConfigured","postMessageToAllIframes","processAutoComplete","processBrand","sendBrandToCardSF","sendExpiryDatePolicyToSF","setFocusOnFrame","setupSecuredField","touchendListener","touchstartListener","hasGenuineTouchEvents","encryptedAttrName","hasRedundantCVCField","isSingleBrandedCard","securityCode"],"mappings":"wHAMA,MAAeA,EAyCX,WAAAC,CAAsBC,GAvCtBC,EAAAC,KAAUC,iBAAV,GACAF,EAAAC,KAAUE,cAAV,GACAH,EAAAC,KAAUG,aAAV,GACAJ,EAAAC,KAAUI,aAAV,GACAL,EAAAC,KAAUK,oBAAV,GACAN,EAAAC,KAAUM,gCAAV,GACAP,EAAAC,KAAUO,wBAAV,GACAR,EAAAC,KAAUQ,qBAAV,GACAT,EAAAC,KAAUS,+BAAV,GACAV,EAAAC,KAAUU,kCAAV,GACAX,EAAAC,KAAUW,2BAAV,GACAZ,EAAAC,KAAUY,4BAAV,GACAb,EAAAC,KAAUa,4BAAV,GACAd,EAAAC,KAAUc,+BAAV,GACAf,EAAAC,KAAUe,iCAAV,GACAhB,EAAAC,KAAUgB,sBAAV,GACAjB,EAAAC,KAAUiB,wBAAV,GACAlB,EAAAC,KAAUkB,mBAAV,GACAnB,EAAAC,KAAUmB,kCAAV,GACApB,EAAAC,KAAUoB,wBAAV,GACArB,EAAAC,KAAUqB,wBAAV,GACAtB,EAAAC,KAAUsB,sBAAV,GACAvB,EAAAC,KAAUuB,oBAAV,GACAxB,EAAAC,KAAUwB,+BAAV,GACAzB,EAAAC,KAAUyB,2BAAV,GACA1B,EAAAC,KAAU0B,oBAAV,GACA3B,EAAAC,KAAU2B,yBAAV,GACA5B,EAAAC,KAAU4B,gCAAV,GACA7B,EAAAC,KAAU6B,uBAAV,GACA9B,EAAAC,KAAU8B,yBAAV,GACA/B,EAAAC,KAAU+B,wBAAV,GACAhC,EAAAC,KAAUgC,0BAAV,GACAjC,EAAAC,KAAUiC,6BAAV,GAEAlC,EAAAC,KAAUkC,yBAAV,GACAnC,EAAAC,KAAUmC,4BAAV,GACApC,EAAAC,KAAUoC,2BAAV,GACArC,EAAAC,KAAUqC,oBAAV,GAGIrC,KAAKG,MAAQL,EACbE,KAAKI,MAAQ,GAGbJ,KAAKE,OAAS,GACdF,KAAKC,UAAY,EACrB"}
@@ -1,2 +1,2 @@
1
- import e from"./AbstractCSF.js";import{handleConfig as s}from"./extensions/handleConfig.js";import{configureCallbacks as t}from"./extensions/configureCallbacks.js";import{handleValidation as i}from"./extensions/handleValidation.js";import{handleEncryption as r}from"./extensions/handleEncryption.js";import{createSecuredFields as o,createNonCardSecuredFields as a,createCardSecuredFields as n,setupSecuredField as d}from"./extensions/createSecuredFields.js";import h from"./extensions/handleIOSTouchEvents.js";import l from"./extensions/handleTab.js";import c,{sendBrandToCardSF as u,sendExpiryDatePolicyToSF as p}from"./extensions/handleBrandFromBinLookup.js";import{setFocusOnFrame as m}from"./partials/setFocusOnFrame.js";import{postMessageToAllIframes as f}from"./partials/postMessageToAllIframes.js";import F from"./partials/processBrand.js";import{processAutoComplete as y}from"./partials/processAutoComplete.js";import{handleFocus as C}from"./partials/handleFocus.js";import{handleIframeConfigFeedback as g}from"./partials/handleIframeConfigFeedback.js";import{isConfigured as S}from"./partials/isConfigured.js";import b from"./partials/validateForm.js";import{handleBinValue as j}from"./partials/handleBinValue.js";import{destroySecuredFields as T}from"./utils/destroySecuredFields.js";import I from"./utils/iframes/postMessageToIframe.js";import k from"./utils/iframes/getIframeContentWin.js";import{warn as O}from"../utilities/logger.js";import{selectOne as x}from"../utilities/dom.js";import{on as v}from"../../../../../utils/listenerUtils.js";import{partial as L}from"../utilities/commonUtils.js";import{hasOwnProperty as B}from"../../../../../utils/hasOwnProperty.js";import K from"./utils/userAgent.js";const P=(e="You cannot use secured fields")=>{O(`${e} - they are not yet configured. Use the 'onConfigSuccess' callback to know when this has happened.`)};class V extends e{constructor(e){super(e),this.state={type:this.props.type,brand:"card"!==this.props.type?{brand:this.props.type,cvcPolicy:"required"}:{brand:null,cvcPolicy:"required"},allValid:void 0,numIframes:0,originalNumIframes:0,iframeCount:0,iframeConfigCount:0,isConfigured:!1,hasSeparateDateFields:!1,currentFocusObject:null,registerFieldForIos:!1,securedFields:{},isKCP:!1};const I={csfState:this.state,csfConfig:this.config,csfProps:this.props,csfCallbacks:this.callbacks};this.configHandler=s,this.callbacksHandler=t,this.validateForm=L(b,I),this.isConfigured=L(S,I,this.validateForm),this.handleIframeConfigFeedback=L(g,I,this.isConfigured),this.processBrand=L(F,I),this.handleValidation=i,this.handleEncryption=r,this.createSecuredFields=o,this.createNonCardSecuredFields=a,this.createCardSecuredFields=n,this.setupSecuredField=d,this.postMessageToAllIframes=L(f,I),this.handleIOSTouchEvents=h.handleTouchend.bind(this),this.touchendListener=h.touchendListener.bind(this),this.destroyTouchendListener=h.destroyTouchendListener.bind(this),this.touchstartListener=h.touchstartListener.bind(this),this.destroyTouchstartListener=h.destroyTouchstartListener.bind(this),this.setFocusOnFrame=L(m,I),this.handleFocus=L(C,I,this.handleIOSTouchEvents),this.handleSFShiftTab=l.handleSFShiftTab,this.handleShiftTab=l.handleShiftTab,this.destroySecuredFields=T,this.processAutoComplete=L(y,I),this.handleBinValue=L(j,I),this.handleBrandFromBinLookup=c,this.sendBrandToCardSF=u,this.sendExpiryDatePolicyToSF=p,this.init()}init(){this.configHandler(this.props),this.callbacksHandler(this.props.callbacks);const e=this.createSecuredFields();this.state.numIframes=this.state.originalNumIframes=e,this.state.isKCP=!!this.props.isKCP,K.__IS_IOS&&this.props.shouldDisableIOSArrowKeys&&(this.hasGenuineTouchEvents=!1,v(document,"touchstart",this.touchstartListener))}createReturnObject(){return{updateStyles:e=>{this.state.isConfigured?this.postMessageToAllIframes({styleObject:e}):O("You cannot update the secured fields styling - they are not yet configured. Use the 'onConfigSuccess' callback to know when this has happened.")},setFocusOnFrame:e=>{this.state.isConfigured?this.setFocusOnFrame(e):P("You cannot set focus on any secured field")},isValidated:(e,s)=>{if(this.state.isConfigured){if(B(this.state.securedFields,e)){this.state.securedFields[e].hasError=!0,""===this.state.securedFields[e].errorType&&(this.state.securedFields[e].errorType="isValidated");const t={txVariant:this.state.type,fieldType:e,externalValidation:!0,code:s,numKey:this.state.securedFields[e].numKey};I(t,k(this.state,e),this.config.loadingContext)}}else P("You cannot set validated on any secured field")},hasUnsupportedCard:(e,s)=>{if(this.state.isConfigured){if(B(this.state.securedFields,e)){this.state.securedFields[e].hasError=!!s,this.state.securedFields[e].errorType=s;const t={txVariant:this.state.type,fieldType:e,unsupportedCard:!!s,code:s,numKey:this.state.securedFields[e].numKey};I(t,k(this.state,e),this.config.loadingContext)}}else P("You cannot set hasUnsupportedCard on any secured field")},destroy:()=>{this.state.isConfigured?this.destroySecuredFields():P("You cannot destroy secured fields")},brandsFromBinLookup:(e,s)=>{if(!this.config.isCreditCardType)return null;this.state.isConfigured?this.handleBrandFromBinLookup(e,s):P("You cannot set pass brands to secured fields")},addSecuredField:e=>{const s=x(this.props.rootNode,`[data-cse="${e}"]`);s&&(this.state.numIframes+=1,this.setupSecuredField(s))},removeSecuredField:e=>{if(this.state.securedFields[e]){this.state.securedFields[e].destroy(),delete this.state.securedFields[e],this.state.numIframes-=1,this.state.iframeCount-=1;const s={additionalIframeRemoved:!0,fieldType:e,type:this.state.type};this.callbacks.onAdditionalSFRemoved(s)}},setKCPStatus:e=>{this.state.isKCP=e},sfIsOptionalOrHidden:e=>this.state.securedFields[e].isOptionalOrHidden()}}}export{V as default};
1
+ import e from"./AbstractCSF.js";import{handleConfig as s}from"./extensions/handleConfig.js";import{configureCallbacks as t}from"./extensions/configureCallbacks.js";import{handleValidation as i}from"./extensions/handleValidation.js";import{handleEncryption as r}from"./extensions/handleEncryption.js";import{createSecuredFields as o,createNonCardSecuredFields as a,createCardSecuredFields as n,setupSecuredField as d}from"./extensions/createSecuredFields.js";import h from"./extensions/handleIOSTouchEvents.js";import l from"./extensions/handleTab.js";import c,{sendBrandToCardSF as u,sendExpiryDatePolicyToSF as p}from"./extensions/handleBrandFromBinLookup.js";import{setFocusOnFrame as m}from"./partials/setFocusOnFrame.js";import{postMessageToAllIframes as f}from"./partials/postMessageToAllIframes.js";import F from"./partials/processBrand.js";import{processAutoComplete as y}from"./partials/processAutoComplete.js";import{handleFocus as C}from"./partials/handleFocus.js";import{handleIframeConfigFeedback as g}from"./partials/handleIframeConfigFeedback.js";import{isConfigured as S}from"./partials/isConfigured.js";import b from"./partials/validateForm.js";import{handleBinValue as j}from"./partials/handleBinValue.js";import{destroySecuredFields as T}from"./utils/destroySecuredFields.js";import I from"./utils/iframes/postMessageToIframe.js";import k from"./utils/iframes/getIframeContentWin.js";import{warn as O}from"../utilities/logger.js";import{selectOne as x}from"../utilities/dom.js";import{on as v}from"../../../../../utils/listenerUtils.js";import{partial as L}from"../utilities/commonUtils.js";import{hasOwnProperty as B}from"../../../../../utils/hasOwnProperty.js";import K from"./utils/userAgent.js";const P=(e="You cannot use secured fields")=>{O(`${e} - they are not yet configured. Use the 'onConfigSuccess' callback to know when this has happened.`)};class V extends e{init(){this.configHandler(this.props),this.callbacksHandler(this.props.callbacks);const e=this.createSecuredFields();this.state.numIframes=this.state.originalNumIframes=e,this.state.isKCP=!!this.props.isKCP,K.__IS_IOS&&this.props.shouldDisableIOSArrowKeys&&(this.hasGenuineTouchEvents=!1,v(document,"touchstart",this.touchstartListener))}createReturnObject(){return{updateStyles:e=>{this.state.isConfigured?this.postMessageToAllIframes({styleObject:e}):O("You cannot update the secured fields styling - they are not yet configured. Use the 'onConfigSuccess' callback to know when this has happened.")},setFocusOnFrame:e=>{this.state.isConfigured?this.setFocusOnFrame(e):P("You cannot set focus on any secured field")},isValidated:(e,s)=>{if(this.state.isConfigured){if(B(this.state.securedFields,e)){this.state.securedFields[e].hasError=!0,""===this.state.securedFields[e].errorType&&(this.state.securedFields[e].errorType="isValidated");const t={txVariant:this.state.type,fieldType:e,externalValidation:!0,code:s,numKey:this.state.securedFields[e].numKey};I(t,k(this.state,e),this.config.loadingContext)}}else P("You cannot set validated on any secured field")},hasUnsupportedCard:(e,s)=>{if(this.state.isConfigured){if(B(this.state.securedFields,e)){this.state.securedFields[e].hasError=!!s,this.state.securedFields[e].errorType=s;const t={txVariant:this.state.type,fieldType:e,unsupportedCard:!!s,code:s,numKey:this.state.securedFields[e].numKey};I(t,k(this.state,e),this.config.loadingContext)}}else P("You cannot set hasUnsupportedCard on any secured field")},destroy:()=>{this.state.isConfigured?this.destroySecuredFields():P("You cannot destroy secured fields")},brandsFromBinLookup:(e,s)=>{if(!this.config.isCreditCardType)return null;this.state.isConfigured?this.handleBrandFromBinLookup(e,s):P("You cannot set pass brands to secured fields")},addSecuredField:e=>{const s=x(this.props.rootNode,`[data-cse="${e}"]`);s&&(this.state.numIframes+=1,this.setupSecuredField(s))},removeSecuredField:e=>{if(this.state.securedFields[e]){this.state.securedFields[e].destroy(),delete this.state.securedFields[e],this.state.numIframes-=1,this.state.iframeCount-=1;const s={additionalIframeRemoved:!0,fieldType:e,type:this.state.type};this.callbacks.onAdditionalSFRemoved(s)}},setKCPStatus:e=>{this.state.isKCP=e},sfIsOptionalOrHidden:e=>this.state.securedFields[e].isOptionalOrHidden()}}constructor(e){super(e),this.state={type:this.props.type,brand:"card"!==this.props.type?{brand:this.props.type,cvcPolicy:"required"}:{brand:null,cvcPolicy:"required"},allValid:void 0,numIframes:0,originalNumIframes:0,iframeCount:0,iframeConfigCount:0,isConfigured:!1,hasSeparateDateFields:!1,currentFocusObject:null,registerFieldForIos:!1,securedFields:{},isKCP:!1};const I={csfState:this.state,csfConfig:this.config,csfProps:this.props,csfCallbacks:this.callbacks};this.configHandler=s,this.callbacksHandler=t,this.validateForm=L(b,I),this.isConfigured=L(S,I,this.validateForm),this.handleIframeConfigFeedback=L(g,I,this.isConfigured),this.processBrand=L(F,I),this.handleValidation=i,this.handleEncryption=r,this.createSecuredFields=o,this.createNonCardSecuredFields=a,this.createCardSecuredFields=n,this.setupSecuredField=d,this.postMessageToAllIframes=L(f,I),this.handleIOSTouchEvents=h.handleTouchend.bind(this),this.touchendListener=h.touchendListener.bind(this),this.destroyTouchendListener=h.destroyTouchendListener.bind(this),this.touchstartListener=h.touchstartListener.bind(this),this.destroyTouchstartListener=h.destroyTouchstartListener.bind(this),this.setFocusOnFrame=L(m,I),this.handleFocus=L(C,I,this.handleIOSTouchEvents),this.handleSFShiftTab=l.handleSFShiftTab,this.handleShiftTab=l.handleShiftTab,this.destroySecuredFields=T,this.processAutoComplete=L(y,I),this.handleBinValue=L(j,I),this.handleBrandFromBinLookup=c,this.sendBrandToCardSF=u,this.sendExpiryDatePolicyToSF=p,this.init()}}export{V as default};
2
2
  //# sourceMappingURL=CSF.js.map
@@ -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 } from './types';\nimport { StylesObject, CbObjOnAdditionalSF, 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 // --\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;\n\n this.callbacksHandler = configureCallbacks;\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;\n this.handleEncryption = handleEncryption;\n\n this.createSecuredFields = createSecuredFields;\n this.createNonCardSecuredFields = createNonCardSecuredFields;\n this.createCardSecuredFields = createCardSecuredFields;\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.setupSecuredField = setupSecuredField;\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;\n this.handleShiftTab = handleTab.handleShiftTab;\n\n this.destroySecuredFields = destroySecuredFields;\n\n this.processAutoComplete = partial(processAutoComplete, thisObj);\n\n this.handleBinValue = partial(handleBinValue, thisObj);\n\n this.handleBrandFromBinLookup = handleBrandFromBinLookup;\n this.sendBrandToCardSF = sendBrandToCardSF;\n this.sendExpiryDatePolicyToSF = sendExpiryDatePolicyToSF;\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: CbObjOnAdditionalSF = { 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","constructor","setupObj","super","this","state","type","props","brand","cvcPolicy","allValid","undefined","numIframes","originalNumIframes","iframeCount","iframeConfigCount","isConfigured","hasSeparateDateFields","currentFocusObject","registerFieldForIos","securedFields","isKCP","thisObj","csfState","csfConfig","config","csfProps","csfCallbacks","callbacks","configHandler","handleConfig","callbacksHandler","configureCallbacks","validateForm","partial","handleIframeConfigFeedback","processBrand","handleValidation","handleEncryption","createSecuredFields","createNonCardSecuredFields","createCardSecuredFields","setupSecuredField","postMessageToAllIframes","handleIOSTouchEvents","handleTouchend","bind","touchendListener","destroyTouchendListener","touchstartListener","destroyTouchstartListener","setFocusOnFrame","handleFocus","handleSFShiftTab","handleTab","handleShiftTab","destroySecuredFields","processAutoComplete","handleBinValue","handleBrandFromBinLookup","sendBrandToCardSF","sendExpiryDatePolicyToSF","init","ua","__IS_IOS","shouldDisableIOSArrowKeys","hasGenuineTouchEvents","on","document","createReturnObject","updateStyles","pStyleObject","styleObject","pFieldType","isValidated","code","hasOwnProperty","hasError","errorType","dataObj","txVariant","fieldType","externalValidation","numKey","postMessageToIframe","getIframeContentWin","loadingContext","hasUnsupportedCard","unsupportedCard","destroy","brandsFromBinLookup","binLookupResponse","resetObj","isCreditCardType","addSecuredField","securedField","selectOne","rootNode","removeSecuredField","callbackObj","additionalIframeRemoved","onAdditionalSFRemoved","setKCPStatus","sfIsOptionalOrHidden","isOptionalOrHidden"],"mappings":"qrDAgCA,MAAMA,EAAuB,CAACC,EAAM,mCAChCC,EAAY,GAAGD,sGAAuG,EAG1H,MAAME,UAAYC,EAEdC,WAAAA,CAAYC,GAURC,MAAMD,GAENE,KAAKC,MAAQ,CAMTC,KAAMF,KAAKG,MAAMD,KAKjBE,MAA2B,SAApBJ,KAAKG,MAAMD,KAAkB,CAAEE,MAAOJ,KAAKG,MAAMD,KAAMG,UAAW,YAAe,CAAED,MAAO,KAAMC,UAAW,YAClHC,cAAUC,EACVC,WAAY,EACZC,mBAAoB,EACpBC,YAAa,EACbC,kBAAmB,EACnBC,cAAc,EACdC,uBAAuB,EACvBC,mBAAoB,KACpBC,qBAAqB,EACrBC,cAAe,CAAC,EAChBC,OAAO,GAIX,MAAMC,EAAyB,CAAEC,SAAUnB,KAAKC,MAAOmB,UAAWpB,KAAKqB,OAAQC,SAAUtB,KAAKG,MAAOoB,aAAcvB,KAAKwB,WAGxHxB,KAAKyB,cAAgBC,EAErB1B,KAAK2B,iBAAmBC,EAExB5B,KAAK6B,aAAeC,EAAQD,EAAcX,GAE1ClB,KAAKY,aAAekB,EAAQlB,EAAcM,EAASlB,KAAK6B,cACxD7B,KAAK+B,2BAA6BD,EAAQC,EAA4Bb,EAASlB,KAAKY,cAEpFZ,KAAKgC,aAAeF,EAAQE,EAAcd,GAE1ClB,KAAKiC,iBAAmBA,EACxBjC,KAAKkC,iBAAmBA,EAExBlC,KAAKmC,oBAAsBA,EAC3BnC,KAAKoC,2BAA6BA,EAClCpC,KAAKqC,wBAA0BA,EAE/BrC,KAAKsC,kBAAoBA,EAEzBtC,KAAKuC,wBAA0BT,EAAQS,EAAyBrB,GAEhElB,KAAKwC,qBAAuBA,EAAqB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BR,KAAKsC,kBAAkBqD,GAC3B,EAEJG,mBAAqBzB,IACjB,GAAIrE,KAAKC,MAAMe,cAAcqD,GAAa,CACtCrE,KAAKC,MAAMe,cAAcqD,GAAYgB,iBAC9BrF,KAAKC,MAAMe,cAAcqD,GAChCrE,KAAKC,MAAMO,YAAc,EACzBR,KAAKC,MAAMS,aAAe,EAE1B,MAAMqF,EAAmC,CAAEC,yBAAyB,EAAMnB,UAAWR,EAAYnE,KAAMF,KAAKC,MAAMC,MAClHF,KAAKwB,UAAUyE,sBAAsBF,EACzC,GAEJG,aAAejF,IACXjB,KAAKC,MAAMgB,MAAQA,CAAAA,EAEvBkF,qBAAuBtB,GACZ7E,KAAKC,MAAMe,cAAc6D,GAAWuB,qBAKvD"}
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 } from './types';\nimport { StylesObject, CbObjOnAdditionalSF, 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 // --\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;\n\n this.callbacksHandler = configureCallbacks;\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;\n this.handleEncryption = handleEncryption;\n\n this.createSecuredFields = createSecuredFields;\n this.createNonCardSecuredFields = createNonCardSecuredFields;\n this.createCardSecuredFields = createCardSecuredFields;\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.setupSecuredField = setupSecuredField;\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;\n this.handleShiftTab = handleTab.handleShiftTab;\n\n this.destroySecuredFields = destroySecuredFields;\n\n this.processAutoComplete = partial(processAutoComplete, thisObj);\n\n this.handleBinValue = partial(handleBinValue, thisObj);\n\n this.handleBrandFromBinLookup = handleBrandFromBinLookup;\n this.sendBrandToCardSF = sendBrandToCardSF;\n this.sendExpiryDatePolicyToSF = sendExpiryDatePolicyToSF;\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: CbObjOnAdditionalSF = { 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","configureCallbacks","validateForm","partial","handleIframeConfigFeedback","processBrand","handleValidation","handleEncryption","createNonCardSecuredFields","createCardSecuredFields","handleIOSTouchEvents","handleTouchend","bind","touchendListener","destroyTouchendListener","destroyTouchstartListener","handleFocus","handleSFShiftTab","handleTab","handleShiftTab","processAutoComplete","handleBinValue","sendBrandToCardSF","sendExpiryDatePolicyToSF"],"mappings":"qrDAgCA,MAAMA,EAAuB,CAACC,EAAM,mCAChCC,EAAY,GAAGD,sGAAuG,EAG1H,MAAME,UAAYC,EA2FNC,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,aAA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AAKG,iBAAmB6E,EAExBhF,KAAKiF,aAAeC,EAAQD,EAAcP,GAE1C1E,KAAKoB,aAAe8D,EAAQ9D,EAAcsD,EAAS1E,KAAKiF,cACxDjF,KAAKmF,2BAA6BD,EAAQC,EAA4BT,EAAS1E,KAAKoB,cAEpFpB,KAAKoF,aAAeF,EAAQE,EAAcV,GAE1C1E,KAAKqF,iBAAmBA,EACxBrF,KAAKsF,iBAAmBA,EAExBtF,KAAKM,oBAAsBA,EAC3BN,KAAKuF,2BAA6BA,EAClCvF,KAAKwF,wBAA0BA,EAE/BxF,KAAKsD,kBAAoBA,EAEzBtD,KAAKqB,wBAA0B6D,EAAQ7D,EAAyBqD,GAEhE1E,KAAKyF,qBAAuBA,EAAqBC,eAAeC,KAAK3F,MACrEA,KAAK4F,iBAAmBH,EAAqBG,iBAAiBD,KAAK3F,MACnEA,KAAK6F,wBAA0BJ,EAAqBI,wBAAwBF,KAAK3F,MACjFA,KAAKgB,mBAAqByE,EAAqBzE,mBAAmB2E,KAAK3F,MACvEA,KAAK8F,0BAA4BL,EAAqBK,0BAA0BH,KAAK3F,MAErFA,KAAKuB,gBAAkB2D,EAAQ3D,EAAiBmD,GAChD1E,KAAK+F,YAAcb,EAAQa,EAAarB,EAAS1E,KAAKyF,sBAEtDzF,KAAKgG,iBAAmBC,EAAUD,iBAClChG,KAAKkG,eAAiBD,EAAUC,eAEhClG,KAAK4C,qBAAuBA,EAE5B5C,KAAKmG,oBAAsBjB,EAAQiB,EAAqBzB,GAExD1E,KAAKoG,eAAiBlB,EAAQkB,EAAgB1B,GAE9C1E,KAAKiD,yBAA2BA,EAChCjD,KAAKqG,kBAAoBA,EACzBrG,KAAKsG,yBAA2BA,EAGhCtG,KAAKD,MACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"handleIOSTouchEvents.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.ts"],"sourcesContent":["import { selectOne } from '../../utilities/dom';\nimport ua from '../utils/userAgent';\nimport { on, off } from '../../../../../../utils/listenerUtils';\n\nconst getCaretPos = (pNode: HTMLInputElement | HTMLTextAreaElement): number => {\n if ('selectionStart' in pNode) {\n return pNode.selectionStart;\n }\n return 0;\n};\n\n/**\n * Detect if touched element is an input or textArea.\n * - If it is do some quirky shit to set focus and caret position on this element\n * - Else do some quirky shit to make the iOS keyboard retract\n *\n * Always then remove this listener and set var saying we have done so (read in CSF...handleFocus)\n * Tell all securedFields some other element now has focus so they can blur themselves\n *\n * @param e -\n */\nfunction touchendListener(e: Event): void {\n const targetEl: EventTarget = e.target;\n\n // If other element is Input or TextArea\n if (targetEl instanceof HTMLInputElement || (HTMLTextAreaElement && targetEl instanceof HTMLTextAreaElement)) {\n // Force caret to show - 'requires' resetting field's value\n const val: string = targetEl.value;\n\n let caretPos: number = getCaretPos(targetEl);\n\n let adjFlag = false;\n\n // For some annoying, iOS Safari, reason if caretPos is at the end of the string then it won't show up\n // - so first decrease it; then set it again, asynchronously\n if (caretPos === val.length) {\n caretPos -= 1;\n adjFlag = true;\n }\n\n targetEl.value = val;\n\n /**\n * If the input element is of an unexpected type (perhaps the merchant is using a custom button that is an input element, type=\"button\", or,\n * it is something presented in the 3DS2 flow - both, TBC) then this next line will not work.\n * However, the input element still has a setSelectionRange property of type \"function\", but trying to call it will throw an error...\n * so, try, to see if setSelectionRange can be called\n */\n try {\n if (targetEl.setSelectionRange) {\n targetEl.focus();\n targetEl.setSelectionRange(caretPos, caretPos);\n\n // Quirky! (see comment about iOS Safari, above)\n if (adjFlag) {\n caretPos += 1;\n setTimeout(() => {\n targetEl.setSelectionRange(caretPos, caretPos);\n }, 0);\n }\n }\n /* eslint-disable-next-line */\n } catch (e) {}\n } else {\n /**\n * Workaround for iOS/Safari bug where keypad doesn't retract when SF paymentMethod is no longer active\n */\n const hasKeypadFix: boolean = this.config.keypadFix; // to avoid linting no-lonely-if\n if (hasKeypadFix) {\n // Create an input we can add focus to.\n // Otherwise 2nd & sub times the caret gets left in the SF even though it has lost focus and cannot be typed into\n const rootNode: HTMLElement = this.props.rootNode;\n const nuInput: HTMLInputElement = document.createElement('input');\n nuInput.style.width = '1px';\n nuInput.style.height = '1px';\n nuInput.style.opacity = '0';\n nuInput.style.fontSize = '18px'; // prevents zoom\n rootNode.appendChild(nuInput);\n nuInput.focus(); // Takes caret from SF\n rootNode.removeChild(nuInput); // Without this numpad will be replaced with text pad\n }\n }\n\n // Remove listener - it gets reset by next call to handleAdditionalFields from handleFocus\n this.destroyTouchendListener(); \n\n // Store the fact we have unset the listener\n this.state.registerFieldForIos = false;\n\n // Clear focus on secured field inputs now this checkout element has gained focus\n this.postMessageToAllIframes({ fieldType: 'webInternalElement', fieldClick: true });\n}\n\n/**\n * re. Disabling arrow keys in iOS - need to enable all fields in the form and tell SFs to disable\n *\n * NOTE: Only called when iOS detected & this.props.shouldDisableIOSArrowKeys = true\n */\nfunction touchstartListener(e: Event): void {\n this.hasGenuineTouchEvents = true;\n const targetEl: EventTarget = e.target;\n // If other element is Input or Span (i.e. label text) TODO apply to other types of el?\n if (targetEl instanceof HTMLInputElement || targetEl instanceof HTMLSpanElement) {\n this.postMessageToAllIframes({ fieldType: 'webInternalElement', checkoutTouchEvent: true });\n\n const name = targetEl.getAttribute('name') ?? targetEl.getAttribute('data-id'); // if targetEl is a label's span it will only have a data-id\n this.callbacks.onTouchstartIOS?.({ fieldType: 'webInternalElement', name });\n }\n}\n\n/**\n * This works with the touchend handler to allow us to catch (click) events on non-securedFields elements\n * (re. http://gravitydept.com/blog/js-click-event-bubbling-on-ios - events don't bubble unless the click takes place on a link or input)\n *\n * We can use this event to:\n * 1. Set focus on these other elements, and\n * 2. Tell SecuredFields that this has happened so they can blur themselves\n * (see note in adyen-secured-fields...inputBase.js - \"Blur event never fires on input field\")\n *\n * NOTE: Only called when iOS detected\n */\nfunction handleTouchend(): void {\n const bodyEl: HTMLBodyElement = selectOne(document, 'body');\n bodyEl.style.cursor = 'pointer';\n\n on(bodyEl, 'touchend', this.touchendListener);\n\n // Store the fact we have set the listener\n this.state.registerFieldForIos = true;\n}\n\nfunction destroyTouchendListener(): boolean {\n if (!ua.__IS_IOS) return false; // For when fn is called as result of destroy being called on main csf instance\n\n const bodyEl: HTMLBodyElement = selectOne(document, 'body');\n bodyEl.style.cursor = 'auto';\n off(bodyEl, 'touchend', this.touchendListener);\n return true;\n}\n\nfunction destroyTouchstartListener(): boolean {\n if (!ua.__IS_IOS) return false; // For when fn is called as result of destroy being called on main csf instance\n\n off(document, 'touchstart', this.touchstartListener);\n return true;\n}\n\nexport default {\n touchendListener,\n touchstartListener,\n handleTouchend,\n destroyTouchendListener,\n destroyTouchstartListener\n};\n"],"names":["handleIOSTouchEvents","touchendListener","e","targetEl","target","HTMLInputElement","HTMLTextAreaElement","val","value","caretPos","pNode","selectionStart","adjFlag","length","setSelectionRange","focus","setTimeout","this","config","keypadFix","rootNode","props","nuInput","document","createElement","style","width","height","opacity","fontSize","appendChild","removeChild","destroyTouchendListener","state","registerFieldForIos","postMessageToAllIframes","fieldType","fieldClick","touchstartListener","hasGenuineTouchEvents","HTMLSpanElement","checkoutTouchEvent","name","getAttribute","callbacks","onTouchstartIOS","handleTouchend","bodyEl","selectOne","cursor","on","ua","__IS_IOS","off","destroyTouchstartListener"],"mappings":"+JAmJA,IAAeA,EAAA,CACXC,iBA/HJ,SAA0BC,GACtB,MAAMC,EAAwBD,EAAEE,OAGhC,GAAID,aAAoBE,kBAAqBC,qBAAuBH,aAAoBG,oBAAsB,CAE1G,MAAMC,EAAcJ,EAASK,MAE7B,IAAIC,EAxBJ,mBADaC,EAyBsBP,GAvB5BO,EAAMC,eAEV,EAuBCC,GAAU,EAIVH,IAAaF,EAAIM,SACjBJ,GAAY,EACZG,GAAU,GAGdT,EAASK,MAAQD,EAQjB,IACQJ,EAASW,oBACTX,EAASY,QACTZ,EAASW,kBAAkBL,EAAUA,GAGjCG,IACAH,GAAY,EACZO,YAAW,KACPb,EAASW,kBAAkBL,EAAUA,EAAAA,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/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.ts"],"sourcesContent":["import { selectOne } from '../../utilities/dom';\nimport ua from '../utils/userAgent';\nimport { on, off } from '../../../../../../utils/listenerUtils';\n\nconst getCaretPos = (pNode: HTMLInputElement | HTMLTextAreaElement): number => {\n if ('selectionStart' in pNode) {\n return pNode.selectionStart;\n }\n return 0;\n};\n\n/**\n * Detect if touched element is an input or textArea.\n * - If it is do some quirky shit to set focus and caret position on this element\n * - Else do some quirky shit to make the iOS keyboard retract\n *\n * Always then remove this listener and set var saying we have done so (read in CSF...handleFocus)\n * Tell all securedFields some other element now has focus so they can blur themselves\n *\n * @param e -\n */\nfunction touchendListener(e: Event): void {\n const targetEl: EventTarget = e.target;\n\n // If other element is Input or TextArea\n if (targetEl instanceof HTMLInputElement || (HTMLTextAreaElement && targetEl instanceof HTMLTextAreaElement)) {\n // Force caret to show - 'requires' resetting field's value\n const val: string = targetEl.value;\n\n let caretPos: number = getCaretPos(targetEl);\n\n let adjFlag = false;\n\n // For some annoying, iOS Safari, reason if caretPos is at the end of the string then it won't show up\n // - so first decrease it; then set it again, asynchronously\n if (caretPos === val.length) {\n caretPos -= 1;\n adjFlag = true;\n }\n\n targetEl.value = val;\n\n /**\n * If the input element is of an unexpected type (perhaps the merchant is using a custom button that is an input element, type=\"button\", or,\n * it is something presented in the 3DS2 flow - both, TBC) then this next line will not work.\n * However, the input element still has a setSelectionRange property of type \"function\", but trying to call it will throw an error...\n * so, try, to see if setSelectionRange can be called\n */\n try {\n if (targetEl.setSelectionRange) {\n targetEl.focus();\n targetEl.setSelectionRange(caretPos, caretPos);\n\n // Quirky! (see comment about iOS Safari, above)\n if (adjFlag) {\n caretPos += 1;\n setTimeout(() => {\n targetEl.setSelectionRange(caretPos, caretPos);\n }, 0);\n }\n }\n /* eslint-disable-next-line */\n } catch (e) {}\n } else {\n /**\n * Workaround for iOS/Safari bug where keypad doesn't retract when SF paymentMethod is no longer active\n */\n const hasKeypadFix: boolean = this.config.keypadFix; // to avoid linting no-lonely-if\n if (hasKeypadFix) {\n // Create an input we can add focus to.\n // Otherwise 2nd & sub times the caret gets left in the SF even though it has lost focus and cannot be typed into\n const rootNode: HTMLElement = this.props.rootNode;\n const nuInput: HTMLInputElement = document.createElement('input');\n nuInput.style.width = '1px';\n nuInput.style.height = '1px';\n nuInput.style.opacity = '0';\n nuInput.style.fontSize = '18px'; // prevents zoom\n rootNode.appendChild(nuInput);\n nuInput.focus(); // Takes caret from SF\n rootNode.removeChild(nuInput); // Without this numpad will be replaced with text pad\n }\n }\n\n // Remove listener - it gets reset by next call to handleAdditionalFields from handleFocus\n this.destroyTouchendListener();\n\n // Store the fact we have unset the listener\n this.state.registerFieldForIos = false;\n\n // Clear focus on secured field inputs now this checkout element has gained focus\n this.postMessageToAllIframes({ fieldType: 'webInternalElement', fieldClick: true });\n}\n\n/**\n * re. Disabling arrow keys in iOS - need to enable all fields in the form and tell SFs to disable\n *\n * NOTE: Only called when iOS detected & this.props.shouldDisableIOSArrowKeys = true\n */\nfunction touchstartListener(e: Event): void {\n this.hasGenuineTouchEvents = true;\n const targetEl: EventTarget = e.target;\n // If other element is Input or Span (i.e. label text) TODO apply to other types of el?\n if (targetEl instanceof HTMLInputElement || targetEl instanceof HTMLSpanElement) {\n this.postMessageToAllIframes({ fieldType: 'webInternalElement', checkoutTouchEvent: true });\n\n const name = targetEl.getAttribute('name') ?? targetEl.getAttribute('data-id'); // if targetEl is a label's span it will only have a data-id\n this.callbacks.onTouchstartIOS?.({ fieldType: 'webInternalElement', name });\n }\n}\n\n/**\n * This works with the touchend handler to allow us to catch (click) events on non-securedFields elements\n * (re. http://gravitydept.com/blog/js-click-event-bubbling-on-ios - events don't bubble unless the click takes place on a link or input)\n *\n * We can use this event to:\n * 1. Set focus on these other elements, and\n * 2. Tell SecuredFields that this has happened so they can blur themselves\n * (see note in adyen-secured-fields...inputBase.js - \"Blur event never fires on input field\")\n *\n * NOTE: Only called when iOS detected\n */\nfunction handleTouchend(): void {\n const bodyEl: HTMLBodyElement = selectOne(document, 'body');\n bodyEl.style.cursor = 'pointer';\n\n on(bodyEl, 'touchend', this.touchendListener);\n\n // Store the fact we have set the listener\n this.state.registerFieldForIos = true;\n}\n\nfunction destroyTouchendListener(): boolean {\n if (!ua.__IS_IOS) return false; // For when fn is called as result of destroy being called on main csf instance\n\n const bodyEl: HTMLBodyElement = selectOne(document, 'body');\n bodyEl.style.cursor = 'auto';\n off(bodyEl, 'touchend', this.touchendListener);\n return true;\n}\n\nfunction destroyTouchstartListener(): boolean {\n if (!ua.__IS_IOS) return false; // For when fn is called as result of destroy being called on main csf instance\n\n off(document, 'touchstart', this.touchstartListener);\n return true;\n}\n\nexport default {\n touchendListener,\n touchstartListener,\n handleTouchend,\n destroyTouchendListener,\n destroyTouchstartListener\n};\n"],"names":["handleIOSTouchEvents","touchendListener","e","targetEl","target","HTMLInputElement","HTMLTextAreaElement","val","value","caretPos","pNode","selectionStart","adjFlag","length","setSelectionRange","focus","setTimeout","this","config","keypadFix","rootNode","props","nuInput","document","createElement","style","width","height","opacity","fontSize","appendChild","removeChild","destroyTouchendListener","state","registerFieldForIos","postMessageToAllIframes","fieldType","fieldClick","touchstartListener","hasGenuineTouchEvents","HTMLSpanElement","checkoutTouchEvent","name","getAttribute","callbacks","onTouchstartIOS","handleTouchend","bodyEl","selectOne","cursor","on","ua","__IS_IOS","off","destroyTouchstartListener"],"mappings":"+JAmJA,IAAeA,EAAA,CACXC,iBA/HJ,SAA0BC,GACtB,MAAMC,EAAwBD,EAAEE,OAGhC,GAAID,aAAoBE,kBAAqBC,qBAAuBH,aAAoBG,oBAAsB,CAE1G,MAAMC,EAAcJ,EAASK,MAE7B,IAAIC,EAxBJ,mBADaC,EAyBsBP,GAvB5BO,EAAMC,eAEV,EAuBCC,GAAU,EAIVH,IAAaF,EAAIM,SACjBJ,GAAY,EACZG,GAAU,GAGdT,EAASK,MAAQD,EAQjB,IACQJ,EAASW,oBACTX,EAASY,QACTZ,EAASW,k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