@adyen/adyen-web 6.28.0 → 6.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/dist/cjs/adyen.css +8 -6
  2. package/dist/cjs/adyen.css.map +1 -1
  3. package/dist/cjs/index.cjs +2 -2
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/index.d.cts +2688 -2557
  6. package/dist/es/adyen.css +8 -6
  7. package/dist/es/adyen.css.map +1 -1
  8. package/dist/es/components/Card/Card.js +1 -1
  9. package/dist/es/components/Card/Card.js.map +1 -1
  10. package/dist/es/components/Card/components/CardInput/CardInput.js +1 -1
  11. package/dist/es/components/Card/components/CardInput/CardInput.js.map +1 -1
  12. package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
  13. package/dist/es/components/Econtext/Econtext.js +1 -1
  14. package/dist/es/components/Econtext/Econtext.js.map +1 -1
  15. package/dist/es/components/Econtext/components/EcontextInput/EcontextInput.js +1 -1
  16. package/dist/es/components/Econtext/components/EcontextInput/EcontextInput.js.map +1 -1
  17. package/dist/es/components/Econtext/components/EcontextVoucherResult/EcontextVoucherResult.js +1 -1
  18. package/dist/es/components/Econtext/components/EcontextVoucherResult/EcontextVoucherResult.js.map +1 -1
  19. package/dist/es/components/Iris/Iris.js +2 -0
  20. package/dist/es/components/Iris/Iris.js.map +1 -0
  21. package/dist/es/components/Iris/components/IrisComponent.js +2 -0
  22. package/dist/es/components/Iris/components/IrisComponent.js.map +1 -0
  23. package/dist/es/components/Iris/components/IrisComponent.module.scss.js +2 -0
  24. package/dist/es/components/Iris/components/IrisComponent.module.scss.js.map +1 -0
  25. package/dist/es/components/Iris/components/IrisGenerateQRCode.js +2 -0
  26. package/dist/es/components/Iris/components/IrisGenerateQRCode.js.map +1 -0
  27. package/dist/es/components/Iris/components/IrisGenerateQRCode.module.scss.js +2 -0
  28. package/dist/es/components/Iris/components/IrisGenerateQRCode.module.scss.js.map +1 -0
  29. package/dist/es/components/Iris/components/IrisQrCodeInstructions.js +2 -0
  30. package/dist/es/components/Iris/components/IrisQrCodeInstructions.js.map +1 -0
  31. package/dist/es/components/Iris/constants.js +2 -0
  32. package/dist/es/components/Iris/constants.js.map +1 -0
  33. package/dist/es/components/Iris/types.js +2 -0
  34. package/dist/es/components/Iris/types.js.map +1 -0
  35. package/dist/es/components/Iris/utils.js +2 -0
  36. package/dist/es/components/Iris/utils.js.map +1 -0
  37. package/dist/es/components/PayTo/components/PayToComponent.js +1 -1
  38. package/dist/es/components/PayTo/components/PayToComponent.js.map +1 -1
  39. package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
  40. package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
  41. package/dist/es/components/components-name-map.js +1 -1
  42. package/dist/es/components/components-name-map.js.map +1 -1
  43. package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  44. package/dist/es/components/index.js +1 -1
  45. package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
  46. package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
  47. package/dist/es/components/internal/PersonalDetails/PersonalDetails.js +1 -1
  48. package/dist/es/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
  49. package/dist/es/components/internal/QRLoader/QRLoader.js.map +1 -1
  50. package/dist/es/components/internal/SegmentedControl/SegmentedControl.js +1 -1
  51. package/dist/es/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
  52. package/dist/es/components/internal/SegmentedControl/SegmentedControlRegion.js +2 -0
  53. package/dist/es/components/internal/SegmentedControl/SegmentedControlRegion.js.map +1 -0
  54. package/dist/es/components/internal/Voucher/Voucher.js +1 -1
  55. package/dist/es/components/internal/Voucher/Voucher.js.map +1 -1
  56. package/dist/es/components/internal/Voucher/utils.js.map +1 -1
  57. package/dist/es/components/tx-variants.js +1 -1
  58. package/dist/es/components/tx-variants.js.map +1 -1
  59. package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
  60. package/dist/es/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
  61. package/dist/es/core/ProcessResponse/PaymentMethods/PaymentMethods.js +1 -1
  62. package/dist/es/core/ProcessResponse/PaymentMethods/PaymentMethods.js.map +1 -1
  63. package/dist/es/core/ProcessResponse/PaymentMethods/utils.js +1 -1
  64. package/dist/es/core/ProcessResponse/PaymentMethods/utils.js.map +1 -1
  65. package/dist/es/core/config.js +1 -1
  66. package/dist/es/index.d.ts +2688 -2557
  67. package/dist/es/index.js +1 -1
  68. package/dist/es/language/Language.js.map +1 -1
  69. package/dist/es/utils/createSdkData.js +2 -0
  70. package/dist/es/utils/createSdkData.js.map +1 -0
  71. package/dist/es-legacy/adyen.css +8 -6
  72. package/dist/es-legacy/adyen.css.map +1 -1
  73. package/dist/es-legacy/components/ApplePay/ApplePay.js +1 -1
  74. package/dist/es-legacy/components/ApplePay/ApplePay.js.map +1 -1
  75. package/dist/es-legacy/components/ApplePay/utils/payment-request.js +1 -1
  76. package/dist/es-legacy/components/ApplePay/utils/payment-request.js.map +1 -1
  77. package/dist/es-legacy/components/BankTransfer/components/BankTransferResult/BankTransferVoucher.js +1 -1
  78. package/dist/es-legacy/components/BankTransfer/components/BankTransferResult/BankTransferVoucher.js.map +1 -1
  79. package/dist/es-legacy/components/Card/Card.js +1 -1
  80. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  81. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js +1 -1
  82. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js.map +1 -1
  83. package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js +1 -1
  84. package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js.map +1 -1
  85. package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
  86. package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js.map +1 -1
  87. package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
  88. package/dist/es-legacy/components/Card/components/CardInput/useSRPanelForCardInputErrors.js +1 -1
  89. package/dist/es-legacy/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -1
  90. package/dist/es-legacy/components/Card/components/CardInput/utils.js +1 -1
  91. package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
  92. package/dist/es-legacy/components/Card/components/ClickToPayWrapper.js +1 -1
  93. package/dist/es-legacy/components/Card/components/ClickToPayWrapper.js.map +1 -1
  94. package/dist/es-legacy/components/CustomCard/CustomCard.js +1 -1
  95. package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
  96. package/dist/es-legacy/components/Dragonpay/Dragonpay.js +1 -1
  97. package/dist/es-legacy/components/Dragonpay/Dragonpay.js.map +1 -1
  98. package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
  99. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  100. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
  101. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  102. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js +1 -1
  103. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodList.js.map +1 -1
  104. package/dist/es-legacy/components/Econtext/Econtext.js +1 -1
  105. package/dist/es-legacy/components/Econtext/Econtext.js.map +1 -1
  106. package/dist/es-legacy/components/Econtext/components/EcontextInput/EcontextInput.js +1 -1
  107. package/dist/es-legacy/components/Econtext/components/EcontextInput/EcontextInput.js.map +1 -1
  108. package/dist/es-legacy/components/Econtext/components/EcontextVoucherResult/EcontextVoucherResult.js +1 -1
  109. package/dist/es-legacy/components/Econtext/components/EcontextVoucherResult/EcontextVoucherResult.js.map +1 -1
  110. package/dist/es-legacy/components/GooglePay/GooglePay.js +1 -1
  111. package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
  112. package/dist/es-legacy/components/GooglePay/requests.js +1 -1
  113. package/dist/es-legacy/components/GooglePay/requests.js.map +1 -1
  114. package/dist/es-legacy/components/Iris/Iris.js +2 -0
  115. package/dist/es-legacy/components/Iris/Iris.js.map +1 -0
  116. package/dist/es-legacy/components/Iris/components/IrisComponent.js +2 -0
  117. package/dist/es-legacy/components/Iris/components/IrisComponent.js.map +1 -0
  118. package/dist/es-legacy/components/Iris/components/IrisComponent.module.scss.js +2 -0
  119. package/dist/es-legacy/components/Iris/components/IrisComponent.module.scss.js.map +1 -0
  120. package/dist/es-legacy/components/Iris/components/IrisGenerateQRCode.js +2 -0
  121. package/dist/es-legacy/components/Iris/components/IrisGenerateQRCode.js.map +1 -0
  122. package/dist/es-legacy/components/Iris/components/IrisGenerateQRCode.module.scss.js +2 -0
  123. package/dist/es-legacy/components/Iris/components/IrisGenerateQRCode.module.scss.js.map +1 -0
  124. package/dist/es-legacy/components/Iris/components/IrisQrCodeInstructions.js +2 -0
  125. package/dist/es-legacy/components/Iris/components/IrisQrCodeInstructions.js.map +1 -0
  126. package/dist/es-legacy/components/Iris/constants.js +2 -0
  127. package/dist/es-legacy/components/Iris/constants.js.map +1 -0
  128. package/dist/es-legacy/components/Iris/types.js +2 -0
  129. package/dist/es-legacy/components/Iris/types.js.map +1 -0
  130. package/dist/es-legacy/components/Iris/utils.js +2 -0
  131. package/dist/es-legacy/components/Iris/utils.js.map +1 -0
  132. package/dist/es-legacy/components/Klarna/components/KlarnaContainer/KlarnaContainer.js +1 -1
  133. package/dist/es-legacy/components/Klarna/components/KlarnaContainer/KlarnaContainer.js.map +1 -1
  134. package/dist/es-legacy/components/Klarna/components/KlarnaWidget/KlarnaWidget.js +1 -1
  135. package/dist/es-legacy/components/Klarna/components/KlarnaWidget/KlarnaWidget.js.map +1 -1
  136. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js +1 -1
  137. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js.map +1 -1
  138. package/dist/es-legacy/components/PayPal/Paypal.js +1 -1
  139. package/dist/es-legacy/components/PayPal/Paypal.js.map +1 -1
  140. package/dist/es-legacy/components/PayPal/components/PaypalButtons.js +1 -1
  141. package/dist/es-legacy/components/PayPal/components/PaypalButtons.js.map +1 -1
  142. package/dist/es-legacy/components/PayPal/components/PaypalComponent.js +1 -1
  143. package/dist/es-legacy/components/PayPal/components/PaypalComponent.js.map +1 -1
  144. package/dist/es-legacy/components/PayTo/components/PayToComponent.js +1 -1
  145. package/dist/es-legacy/components/PayTo/components/PayToComponent.js.map +1 -1
  146. package/dist/es-legacy/components/PreAuthorizedDebitCanada/PreAuthorizedDebitCanada.js +1 -1
  147. package/dist/es-legacy/components/PreAuthorizedDebitCanada/PreAuthorizedDebitCanada.js.map +1 -1
  148. package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
  149. package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js.map +1 -1
  150. package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
  151. package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
  152. package/dist/es-legacy/components/components-name-map.js +1 -1
  153. package/dist/es-legacy/components/components-name-map.js.map +1 -1
  154. package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
  155. package/dist/es-legacy/components/index.js +1 -1
  156. package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
  157. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
  158. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  159. package/dist/es-legacy/components/internal/Button/CopyButton.js +1 -1
  160. package/dist/es-legacy/components/internal/Button/CopyButton.js.map +1 -1
  161. package/dist/es-legacy/components/internal/Button/CopyIconButton.js +1 -1
  162. package/dist/es-legacy/components/internal/Button/CopyIconButton.js.map +1 -1
  163. package/dist/es-legacy/components/internal/FormFields/Checkbox/Checkbox.js +1 -1
  164. package/dist/es-legacy/components/internal/FormFields/Checkbox/Checkbox.js.map +1 -1
  165. package/dist/es-legacy/components/internal/FormFields/ConsentCheckbox/ConsentCheckbox.js +1 -1
  166. package/dist/es-legacy/components/internal/FormFields/ConsentCheckbox/ConsentCheckbox.js.map +1 -1
  167. package/dist/es-legacy/components/internal/FormFields/InputBase.js +1 -1
  168. package/dist/es-legacy/components/internal/FormFields/InputBase.js.map +1 -1
  169. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  170. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  171. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectList.js +1 -1
  172. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectList.js.map +1 -1
  173. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectListItem.js +1 -1
  174. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectListItem.js.map +1 -1
  175. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
  176. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js.map +1 -1
  177. package/dist/es-legacy/components/internal/Modal/Modal.js +1 -1
  178. package/dist/es-legacy/components/internal/Modal/Modal.js.map +1 -1
  179. package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js +1 -1
  180. package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
  181. package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js +1 -1
  182. package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
  183. package/dist/es-legacy/components/internal/PayButton/PayButton.js +1 -1
  184. package/dist/es-legacy/components/internal/PayButton/PayButton.js.map +1 -1
  185. package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js +1 -1
  186. package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
  187. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputFields.js +1 -1
  188. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputFields.js.map +1 -1
  189. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputForm.js +1 -1
  190. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputForm.js.map +1 -1
  191. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js.map +1 -1
  192. package/dist/es-legacy/components/internal/QRLoader/QRLoaderDetailsProvider.js +1 -1
  193. package/dist/es-legacy/components/internal/QRLoader/QRLoaderDetailsProvider.js.map +1 -1
  194. package/dist/es-legacy/components/internal/RedirectButton/RedirectButton.js +1 -1
  195. package/dist/es-legacy/components/internal/RedirectButton/RedirectButton.js.map +1 -1
  196. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
  197. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  198. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js +1 -1
  199. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map +1 -1
  200. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
  201. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
  202. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js +1 -1
  203. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js.map +1 -1
  204. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.js +1 -1
  205. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.js.map +1 -1
  206. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js +1 -1
  207. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js.map +1 -1
  208. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/utils/processPlaceholders.js.map +1 -1
  209. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js +1 -1
  210. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
  211. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControlRegion.js +2 -0
  212. package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControlRegion.js.map +1 -0
  213. package/dist/es-legacy/components/internal/StoreDetails/StoreDetails.js +1 -1
  214. package/dist/es-legacy/components/internal/StoreDetails/StoreDetails.js.map +1 -1
  215. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  216. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  217. package/dist/es-legacy/components/internal/Voucher/Voucher.js +1 -1
  218. package/dist/es-legacy/components/internal/Voucher/Voucher.js.map +1 -1
  219. package/dist/es-legacy/components/internal/Voucher/utils.js.map +1 -1
  220. package/dist/es-legacy/components/tx-variants.js +1 -1
  221. package/dist/es-legacy/components/tx-variants.js.map +1 -1
  222. package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js +1 -1
  223. package/dist/es-legacy/core/Analytics/events/AnalyticsInfoEvent.js.map +1 -1
  224. package/dist/es-legacy/core/Analytics/utils.js +1 -1
  225. package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
  226. package/dist/es-legacy/core/Context/Resources.js +1 -1
  227. package/dist/es-legacy/core/Context/Resources.js.map +1 -1
  228. package/dist/es-legacy/core/ProcessResponse/PaymentMethods/PaymentMethods.js +1 -1
  229. package/dist/es-legacy/core/ProcessResponse/PaymentMethods/PaymentMethods.js.map +1 -1
  230. package/dist/es-legacy/core/ProcessResponse/PaymentMethods/utils.js +1 -1
  231. package/dist/es-legacy/core/ProcessResponse/PaymentMethods/utils.js.map +1 -1
  232. package/dist/es-legacy/core/config.js +1 -1
  233. package/dist/es-legacy/core/core.js +1 -1
  234. package/dist/es-legacy/core/core.js.map +1 -1
  235. package/dist/es-legacy/hooks/usePaymentStatusTimer/usePaymentStatusTimer.js +1 -1
  236. package/dist/es-legacy/hooks/usePaymentStatusTimer/usePaymentStatusTimer.js.map +1 -1
  237. package/dist/es-legacy/index.js +1 -1
  238. package/dist/es-legacy/language/Language.js.map +1 -1
  239. package/dist/es-legacy/utils/Validator/Validator.js.map +1 -1
  240. package/dist/es-legacy/utils/commonUtils.js.map +1 -1
  241. package/dist/es-legacy/utils/createSdkData.js +2 -0
  242. package/dist/es-legacy/utils/createSdkData.js.map +1 -0
  243. package/dist/es-legacy/utils/useForm/reducer.js +1 -1
  244. package/dist/es-legacy/utils/useForm/reducer.js.map +1 -1
  245. package/package.json +12 -12
  246. package/styles/adyen.css +8 -6
@@ -1 +1 @@
1
- {"version":3,"file":"createSecuredFields.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.ts"],"sourcesContent":["import { select, getAttribute } from '../../utilities/dom';\nimport {\n ENCRYPTED_EXPIRY_YEAR,\n DATE_POLICY_REQUIRED,\n CVC_POLICY_REQUIRED,\n DATA_ENCRYPTED_FIELD_ATTR,\n DATA_INFO,\n DATA_UID,\n SF_CONFIG_TIMEOUT,\n ALL_SECURED_FIELDS,\n ENCRYPTED_EXPIRY_MONTH\n} from '../../constants';\nimport { existy } from '../../../../../../utils/commonUtils';\nimport cardType from '../utils/cardType';\nimport { SecuredFieldSetupObject } from '../../types';\nimport SecuredField from '../../securedField/SecuredField';\nimport { CardObject, CardBrandData, SFFeedbackObj, CardLoadData, CVCPolicyType, DatePolicyType } from '../../types';\nimport AdyenCheckoutError from '../../../../../../core/Errors/AdyenCheckoutError';\nimport type { SFKeyPressObj } from '../../types';\n\n/**\n * Bound to the instance of CSF\n * Handles specific functionality related to configuring & creating SecuredFields\n */\nexport function createSecuredFields(): number {\n this.encryptedAttrName = DATA_ENCRYPTED_FIELD_ATTR;\n\n // Detect DOM elements that qualify as securedField holders & filter them for valid types\n const securedFields: HTMLElement[] = select(this.props.rootNode, `[${this.encryptedAttrName}]`).filter(field => {\n const fieldType: string = getAttribute(field, this.encryptedAttrName);\n\n if (fieldType === ENCRYPTED_EXPIRY_MONTH) {\n // TODO send analytics about separate date fields\n }\n\n const isValidType = ALL_SECURED_FIELDS.includes(fieldType);\n if (!isValidType) {\n console.warn(\n `WARNING: '${fieldType}' is not a valid type for the '${this.encryptedAttrName}' attribute. A SecuredField will not be created for this element.`\n );\n }\n return isValidType;\n });\n\n /**\n * cvcPolicy - 'required' | 'optional' | 'hidden'\n * - Always 'required' for GiftCards\n * - Usually 'required' for single branded Credit Cards but with exceptions e.g. maestro ('optional'), bcmc ('hidden').\n * - Always 'required' for generic Credit Cards at start up - in this case, subsequent, supporting information about whether cvc stops being required\n * comes from the SF in the brand information (as the shopper inputs the cc number)\n */\n const cvcPolicy: CVCPolicyType = CVC_POLICY_REQUIRED;\n\n /** Usually 'required' for single branded Credit Cards but with exceptions e.g. ticket ('hidden', *technically* a meal voucher) */\n const expiryDatePolicy: DatePolicyType = DATE_POLICY_REQUIRED;\n\n // CHECK IF THIS SECURED FIELD IS NOT OF A CREDIT CARD TYPE\n if (!this.config.isCreditCardType) {\n this.createNonCardSecuredFields(securedFields);\n return securedFields.length;\n }\n\n // CONTINUE AS CREDIT-CARD TYPE...\n this.isSingleBrandedCard = false;\n\n this.securityCode = '';\n\n this.createCardSecuredFields(securedFields, cvcPolicy, expiryDatePolicy);\n\n // Return the number of iframes we're going to create\n return securedFields.length;\n}\n\n/**\n * i.e. giftcard and ach fields\n *\n * Create a new SecuredField for each detected holding element\n */\nexport async function createNonCardSecuredFields(securedFields: HTMLElement[]): Promise<any> {\n for (let i = 0; i < securedFields.length; i++) {\n const securedField = securedFields[i];\n await this.setupSecuredField(securedField).catch(e => {\n if (window._b$dl) console.log('Secured fields setup failure. e=', e);\n });\n }\n}\n\nexport async function createCardSecuredFields(\n securedFields: HTMLElement[],\n cvcPolicy: CVCPolicyType,\n expiryDatePolicy: DatePolicyType\n): Promise<any> {\n // Declared card type from the initialisation of CSF\n let type: string = this.state.type;\n\n // Maybe it's a single branded card defined by setting type: 'card' & a single item in cardGroupTypes\n // In which case update the type var both locally AND in State\n if (type === 'card' && this.config.cardGroupTypes.length === 1) {\n type = this.config.cardGroupTypes[0];\n this.state.type = type;\n }\n\n // So, is it a single branded card?\n this.isSingleBrandedCard = type !== 'card';\n\n // If single branded card field...\n if (this.isSingleBrandedCard) {\n // Check that type exists\n const card: CardObject = cardType.getCardByBrand(type);\n\n // It's possible we don't recognise the card type -\n // scenario: frontend initially recognises card as e.g. Visa - but then backend tokenises it as a sub-brand which we currently don't recognise\n if (!existy(card)) {\n this.state.type = 'unrecognised-single-brand'; // Will let CVC field accept 4 digits in the input\n } else {\n // Assess whether cvc field is required based on the card type & whether the cvc field should even be visible\n cvcPolicy = card.cvcPolicy || CVC_POLICY_REQUIRED;\n expiryDatePolicy = card.expiryDatePolicy || DATE_POLICY_REQUIRED;\n\n this.securityCode = card.securityCode;\n }\n }\n\n /**\n * Create a new SecuredField for each detected holding element\n *\n * - we do this in sequence, waiting until one has configured before creating the next.\n * We do it this way to avoid the 'bug' whereby if something interrupts the loading of an iframe the listener we have for its load event\n * never fires; which means the iframe never configures.\n * (NB - you can recreate this 'bug' by creating the securedFields in a synchronous loop:\n * securedFields.forEach(this.setupSecuredField.bind(this));\n * and putting a breakpoint on the line where we declare the setupSecuredField function)\n *\n * Also note we tried the Array.map/Promise.all way of asynchronously looping through an array - but it didn't fix the issue,\n * - so we fall back to a good old for-loop\n */\n for (let i = 0; i < securedFields.length; i++) {\n const securedField = securedFields[i];\n if (window._b$dl) console.log('\\nAbout to set up securedField:', securedField);\n await this.setupSecuredField(securedField, cvcPolicy, expiryDatePolicy).catch(e => {\n if (window._b$dl) console.log('Secured fields setup failure. e=', e);\n });\n if (window._b$dl) console.log('Finished setting up securedField:', securedField);\n }\n if (window._b$dl) console.log('Finished setting up all securedFields');\n\n /**\n * Now the securedFields have all been created and configured...\n *\n * For a single branded card we call to onBrand callback once.\n * This allows the UI to set the correct logo if they haven't already,\n * and we also pass the cvcPolicy & expiryDatePolicy so the UI can hide the iframe holders if necessary\n */\n if (this.isSingleBrandedCard) {\n const callbackObj: CardBrandData = {\n type: this.state.type,\n rootNode: this.props.rootNode,\n brand: type,\n cvcPolicy,\n expiryDatePolicy,\n cvcText: this.securityCode\n };\n\n // Allow a tick for the securedField to finish rendering\n setTimeout(() => {\n this.callbacks.onBrand(callbackObj);\n }, 0);\n }\n}\n\n// Run for each detected holder of a securedField...\nexport function setupSecuredField(pItem: HTMLElement, cvcPolicy?: CVCPolicyType, expiryDatePolicy?: DatePolicyType): Promise<any> {\n return new Promise((resolve, reject) => {\n /**\n * possible values:\n * encryptedCardNumber\n * encryptedExpiryDate\n * encryptedExpiryMonth\n * encryptedExpiryYear\n * encryptedSecurityCode\n * encryptedPassword\n * encryptedPin???\n * encryptedBankAccountNumber\n * encryptedBankLocationId\n * encryptedIBAN\n */\n const fieldType: string = getAttribute(pItem, this.encryptedAttrName);\n\n if (fieldType === ENCRYPTED_EXPIRY_YEAR) {\n this.state.hasSeparateDateFields = true;\n }\n\n const extraFieldData: string = getAttribute(pItem, DATA_INFO);\n const uid = getAttribute(pItem, DATA_UID);\n\n // CREATE SecuredField passing config object\n const sfInitObj: SecuredFieldSetupObject = {\n fieldType,\n extraFieldData,\n uid,\n cvcPolicy,\n holderEl: pItem,\n expiryDatePolicy,\n txVariant: this.state.type,\n // from this.config (calculated)\n cardGroupTypes: this.config.cardGroupTypes,\n iframeUIConfig: this.config.iframeUIConfig,\n sfLogAtStart: this.config.sfLogAtStart,\n trimTrailingSeparator: this.config.trimTrailingSeparator,\n isCreditCardType: this.config.isCreditCardType,\n iframeSrc: this.config.iframeSrc,\n loadingContext: this.config.loadingContext,\n showWarnings: this.config.showWarnings,\n legacyInputMode: this.config.legacyInputMode,\n minimumExpiryDate: this.config.minimumExpiryDate,\n // from this.props (passed straight thru)\n maskSecurityCode: this.props.maskSecurityCode,\n exposeExpiryDate: this.props.exposeExpiryDate,\n disableIOSArrowKeys: this.props.shouldDisableIOSArrowKeys,\n implementationType: this.props.implementationType,\n showContextualElement: this.props.showContextualElement,\n placeholders: this.props.placeholders\n };\n\n const sf: SecuredField = new SecuredField(sfInitObj, this.props.i18n)\n .onIframeLoaded((): void => {\n // Count\n this.state.iframeCount += 1;\n\n if (window._b$dl) console.log('### createSecuredFields::onIframeLoaded:: this.state.iframeCount=', this.state.iframeCount);\n\n // One of our existing securedFields has just loaded new content!\n if (this.state.iframeCount > this.state.numIframes) {\n this.destroySecuredFields();\n // TODO send analytics about this error\n throw new AdyenCheckoutError(\n 'ERROR',\n `One or more securedFields has just loaded new content. This should never happen. securedFields have been removed.\n iframe load count=${this.state.iframeCount}. Expected count:${this.state.numIframes}`\n );\n }\n\n /** Create timeout within which time we expect the securedField to configure */\n // @ts-ignore - timeout 'type' *is* a number\n sf.loadToConfigTimeout = setTimeout(() => {\n reject({ type: sfInitObj.fieldType, failReason: 'sf took too long to config' });\n }, SF_CONFIG_TIMEOUT);\n\n // If all iframes are loaded - call onLoad callback\n if (this.state.iframeCount === this.state.originalNumIframes) {\n const callbackObj: CardLoadData = { iframesLoaded: true };\n this.callbacks.onLoad(callbackObj);\n }\n })\n .onConfig((pFeedbackObj: SFFeedbackObj): void => {\n this.handleIframeConfigFeedback(pFeedbackObj);\n\n // Clear timeout since the securedField has configured\n clearTimeout(sf.loadToConfigTimeout);\n sf.loadToConfigTimeout = null;\n\n resolve(pFeedbackObj);\n })\n .onFocus((pFeedbackObj: SFFeedbackObj): void => {\n this.handleFocus(pFeedbackObj);\n })\n .onBinValue((pFeedbackObj: SFFeedbackObj): void => {\n this.handleBinValue(pFeedbackObj);\n })\n .onTouchstart((pFeedbackObj: SFFeedbackObj): void => {\n // re. Disabling arrow keys in iOS - need to disable all other fields in the form\n if (this.props.shouldDisableIOSArrowKeys) {\n /**\n * re. this.hasGenuineTouchEvents...\n * There seems to be an issue with Responsive Design mode in Safari that means it allows setting focus on cross-origin iframes,\n * without enabling the touch events that allow the \"disableIOSArrowKeys\" workaround to fully function.\n * This results in a click on an securedFields *label* leading to, for example, the holderName field being disabled, but w/o access\n * to the touch events that would let it re-enable itself.\n *\n * So we prevent the \"disableIOSArrowKeys\" workaround unless we genuinely have touch events available.\n */\n if (this.hasGenuineTouchEvents || pFeedbackObj.hasGenuineTouchEvents) {\n this.callbacks.onTouchstartIOS({ fieldType: pFeedbackObj.fieldType });\n }\n }\n\n // Only perform this step if we genuinely have touch events available\n if (pFeedbackObj.hasGenuineTouchEvents || this.hasGenuineTouchEvents) {\n // iOS ONLY - RE. iOS BUGS AROUND BLUR AND FOCUS EVENTS\n // - pass information about which field has just been clicked (gained focus) to the other iframes\n this.postMessageToAllIframes({ fieldType: pFeedbackObj.fieldType, fieldClick: true });\n }\n })\n .onShiftTab((pFeedbackObj: SFFeedbackObj): void => {\n // Only happens for Firefox & IE <= 11\n this.handleSFShiftTab(pFeedbackObj.fieldType);\n })\n .onEncryption((pFeedbackObj: SFFeedbackObj): void => {\n this.handleEncryption(pFeedbackObj);\n })\n .onValidation((pFeedbackObj: SFFeedbackObj): void => {\n this.handleValidation(pFeedbackObj);\n })\n .onAutoComplete((pFeedbackObj: SFFeedbackObj): void => {\n this.processAutoComplete(pFeedbackObj);\n })\n .onKeyPressed((pFeedbackObj: SFFeedbackObj): void => {\n const { numKey, ...rest } = pFeedbackObj;\n this.callbacks.onKeyPressed(rest as SFKeyPressObj);\n });\n\n // Store reference to securedField in this.state (under fieldType)\n this.state.securedFields[fieldType] = sf;\n });\n}\n"],"names":["createSecuredFields","this","encryptedAttrName","DATA_ENCRYPTED_FIELD_ATTR","securedFields","select","props","rootNode","filter","field","fieldType","getAttribute","isValidType","ALL_SECURED_FIELDS","includes","console","warn","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","config","isCreditCardType","isSingleBrandedCard","securityCode","createCardSecuredFields","length","createNonCardSecuredFields","async","i","securedField","setupSecuredField","catch","e","window","_b$dl","log","type","state","cardGroupTypes","card","cardType","getCardByBrand","existy","callbackObj","brand","cvcText","setTimeout","callbacks","onBrand","pItem","Promise","resolve","reject","ENCRYPTED_EXPIRY_YEAR","hasSeparateDateFields","sfInitObj","extraFieldData","DATA_INFO","uid","DATA_UID","holderEl","txVariant","iframeUIConfig","sfLogAtStart","trimTrailingSeparator","iframeSrc","loadingContext","showWarnings","legacyInputMode","minimumExpiryDate","maskSecurityCode","exposeExpiryDate","disableIOSArrowKeys","shouldDisableIOSArrowKeys","implementationType","showContextualElement","placeholders","sf","SecuredField","i18n","onIframeLoaded","iframeCount","numIframes","destroySecuredFields","AdyenCheckoutError","loadToConfigTimeout","failReason","SF_CONFIG_TIMEOUT","originalNumIframes","iframesLoaded","onLoad","onConfig","pFeedbackObj","handleIframeConfigFeedback","clearTimeout","onFocus","handleFocus","onBinValue","handleBinValue","onTouchstart","hasGenuineTouchEvents","onTouchstartIOS","postMessageToAllIframes","fieldClick","onShiftTab","handleSFShiftTab","onEncryption","handleEncryption","onValidation","handleValidation","onAutoComplete","processAutoComplete","onKeyPressed","numKey","rest"],"mappings":"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"}
1
+ {"version":3,"file":"createSecuredFields.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.ts"],"sourcesContent":["import { select, getAttribute } from '../../utilities/dom';\nimport {\n ENCRYPTED_EXPIRY_YEAR,\n DATE_POLICY_REQUIRED,\n CVC_POLICY_REQUIRED,\n DATA_ENCRYPTED_FIELD_ATTR,\n DATA_INFO,\n DATA_UID,\n SF_CONFIG_TIMEOUT,\n ALL_SECURED_FIELDS,\n ENCRYPTED_EXPIRY_MONTH\n} from '../../constants';\nimport { existy } from '../../../../../../utils/commonUtils';\nimport cardType from '../utils/cardType';\nimport { SecuredFieldSetupObject } from '../../types';\nimport SecuredField from '../../securedField/SecuredField';\nimport { CardObject, CardBrandData, SFFeedbackObj, CardLoadData, CVCPolicyType, DatePolicyType } from '../../types';\nimport AdyenCheckoutError from '../../../../../../core/Errors/AdyenCheckoutError';\nimport type { SFKeyPressObj } from '../../types';\n\n/**\n * Bound to the instance of CSF\n * Handles specific functionality related to configuring & creating SecuredFields\n */\nexport function createSecuredFields(): number {\n this.encryptedAttrName = DATA_ENCRYPTED_FIELD_ATTR;\n\n // Detect DOM elements that qualify as securedField holders & filter them for valid types\n const securedFields: HTMLElement[] = select(this.props.rootNode, `[${this.encryptedAttrName}]`).filter(field => {\n const fieldType: string = getAttribute(field, this.encryptedAttrName);\n\n if (fieldType === ENCRYPTED_EXPIRY_MONTH) {\n // TODO send analytics about separate date fields\n }\n\n const isValidType = ALL_SECURED_FIELDS.includes(fieldType);\n if (!isValidType) {\n console.warn(\n `WARNING: '${fieldType}' is not a valid type for the '${this.encryptedAttrName}' attribute. A SecuredField will not be created for this element.`\n );\n }\n return isValidType;\n });\n\n /**\n * cvcPolicy - 'required' | 'optional' | 'hidden'\n * - Always 'required' for GiftCards\n * - Usually 'required' for single branded Credit Cards but with exceptions e.g. maestro ('optional'), bcmc ('hidden').\n * - Always 'required' for generic Credit Cards at start up - in this case, subsequent, supporting information about whether cvc stops being required\n * comes from the SF in the brand information (as the shopper inputs the cc number)\n */\n const cvcPolicy: CVCPolicyType = CVC_POLICY_REQUIRED;\n\n /** Usually 'required' for single branded Credit Cards but with exceptions e.g. ticket ('hidden', *technically* a meal voucher) */\n const expiryDatePolicy: DatePolicyType = DATE_POLICY_REQUIRED;\n\n // CHECK IF THIS SECURED FIELD IS NOT OF A CREDIT CARD TYPE\n if (!this.config.isCreditCardType) {\n this.createNonCardSecuredFields(securedFields);\n return securedFields.length;\n }\n\n // CONTINUE AS CREDIT-CARD TYPE...\n this.isSingleBrandedCard = false;\n\n this.securityCode = '';\n\n this.createCardSecuredFields(securedFields, cvcPolicy, expiryDatePolicy);\n\n // Return the number of iframes we're going to create\n return securedFields.length;\n}\n\n/**\n * i.e. giftcard and ach fields\n *\n * Create a new SecuredField for each detected holding element\n */\nexport async function createNonCardSecuredFields(securedFields: HTMLElement[]): Promise<any> {\n for (let i = 0; i < securedFields.length; i++) {\n const securedField = securedFields[i];\n await this.setupSecuredField(securedField).catch(e => {\n if (window._b$dl) console.log('Secured fields setup failure. e=', e);\n });\n }\n}\n\nexport async function createCardSecuredFields(\n securedFields: HTMLElement[],\n cvcPolicy: CVCPolicyType,\n expiryDatePolicy: DatePolicyType\n): Promise<any> {\n // Declared card type from the initialisation of CSF\n let type: string = this.state.type;\n\n // Maybe it's a single branded card defined by setting type: 'card' & a single item in cardGroupTypes\n // In which case update the type var both locally AND in State\n if (type === 'card' && this.config.cardGroupTypes.length === 1) {\n type = this.config.cardGroupTypes[0];\n this.state.type = type;\n }\n\n // So, is it a single branded card?\n this.isSingleBrandedCard = type !== 'card';\n\n // If single branded card field...\n if (this.isSingleBrandedCard) {\n // Check that type exists\n const card: CardObject = cardType.getCardByBrand(type);\n\n // It's possible we don't recognise the card type -\n // scenario: frontend initially recognises card as e.g. Visa - but then backend tokenises it as a sub-brand which we currently don't recognise\n if (!existy(card)) {\n this.state.type = 'unrecognised-single-brand'; // Will let CVC field accept 4 digits in the input\n } else {\n // Assess whether cvc field is required based on the card type & whether the cvc field should even be visible\n cvcPolicy = card.cvcPolicy || CVC_POLICY_REQUIRED;\n expiryDatePolicy = card.expiryDatePolicy || DATE_POLICY_REQUIRED;\n\n this.securityCode = card.securityCode;\n }\n }\n\n /**\n * Create a new SecuredField for each detected holding element\n *\n * - we do this in sequence, waiting until one has configured before creating the next.\n * We do it this way to avoid the 'bug' whereby if something interrupts the loading of an iframe the listener we have for its load event\n * never fires; which means the iframe never configures.\n * (NB - you can recreate this 'bug' by creating the securedFields in a synchronous loop:\n * securedFields.forEach(this.setupSecuredField.bind(this));\n * and putting a breakpoint on the line where we declare the setupSecuredField function)\n *\n * Also note we tried the Array.map/Promise.all way of asynchronously looping through an array - but it didn't fix the issue,\n * - so we fall back to a good old for-loop\n */\n for (let i = 0; i < securedFields.length; i++) {\n const securedField = securedFields[i];\n if (window._b$dl) console.log('\\nAbout to set up securedField:', securedField);\n await this.setupSecuredField(securedField, cvcPolicy, expiryDatePolicy).catch(e => {\n if (window._b$dl) console.log('Secured fields setup failure. e=', e);\n });\n if (window._b$dl) console.log('Finished setting up securedField:', securedField);\n }\n if (window._b$dl) console.log('Finished setting up all securedFields');\n\n /**\n * Now the securedFields have all been created and configured...\n *\n * For a single branded card we call to onBrand callback once.\n * This allows the UI to set the correct logo if they haven't already,\n * and we also pass the cvcPolicy & expiryDatePolicy so the UI can hide the iframe holders if necessary\n */\n if (this.isSingleBrandedCard) {\n const callbackObj: CardBrandData = {\n type: this.state.type,\n rootNode: this.props.rootNode,\n brand: type,\n cvcPolicy,\n expiryDatePolicy,\n cvcText: this.securityCode\n };\n\n // Allow a tick for the securedField to finish rendering\n setTimeout(() => {\n this.callbacks.onBrand(callbackObj);\n }, 0);\n }\n}\n\n// Run for each detected holder of a securedField...\nexport function setupSecuredField(pItem: HTMLElement, cvcPolicy?: CVCPolicyType, expiryDatePolicy?: DatePolicyType): Promise<any> {\n return new Promise((resolve, reject) => {\n /**\n * possible values:\n * encryptedCardNumber\n * encryptedExpiryDate\n * encryptedExpiryMonth\n * encryptedExpiryYear\n * encryptedSecurityCode\n * encryptedPassword\n * encryptedPin???\n * encryptedBankAccountNumber\n * encryptedBankLocationId\n * encryptedIBAN\n */\n const fieldType: string = getAttribute(pItem, this.encryptedAttrName);\n\n if (fieldType === ENCRYPTED_EXPIRY_YEAR) {\n this.state.hasSeparateDateFields = true;\n }\n\n const extraFieldData: string = getAttribute(pItem, DATA_INFO);\n const uid = getAttribute(pItem, DATA_UID);\n\n // CREATE SecuredField passing config object\n const sfInitObj: SecuredFieldSetupObject = {\n fieldType,\n extraFieldData,\n uid,\n cvcPolicy,\n holderEl: pItem,\n expiryDatePolicy,\n txVariant: this.state.type,\n // from this.config (calculated)\n cardGroupTypes: this.config.cardGroupTypes,\n iframeUIConfig: this.config.iframeUIConfig,\n sfLogAtStart: this.config.sfLogAtStart,\n trimTrailingSeparator: this.config.trimTrailingSeparator,\n isCreditCardType: this.config.isCreditCardType,\n iframeSrc: this.config.iframeSrc,\n loadingContext: this.config.loadingContext,\n showWarnings: this.config.showWarnings,\n legacyInputMode: this.config.legacyInputMode,\n minimumExpiryDate: this.config.minimumExpiryDate,\n // from this.props (passed straight thru)\n maskSecurityCode: this.props.maskSecurityCode,\n exposeExpiryDate: this.props.exposeExpiryDate,\n disableIOSArrowKeys: this.props.shouldDisableIOSArrowKeys,\n implementationType: this.props.implementationType,\n showContextualElement: this.props.showContextualElement,\n placeholders: this.props.placeholders\n };\n\n const sf: SecuredField = new SecuredField(sfInitObj, this.props.i18n)\n .onIframeLoaded((): void => {\n // Count\n this.state.iframeCount += 1;\n\n if (window._b$dl) console.log('### createSecuredFields::onIframeLoaded:: this.state.iframeCount=', this.state.iframeCount);\n\n // One of our existing securedFields has just loaded new content!\n if (this.state.iframeCount > this.state.numIframes) {\n this.destroySecuredFields();\n // TODO send analytics about this error\n throw new AdyenCheckoutError(\n 'ERROR',\n `One or more securedFields has just loaded new content. This should never happen. securedFields have been removed.\n iframe load count=${this.state.iframeCount}. Expected count:${this.state.numIframes}`\n );\n }\n\n /** Create timeout within which time we expect the securedField to configure */\n // @ts-ignore - timeout 'type' *is* a number\n sf.loadToConfigTimeout = setTimeout(() => {\n reject({ type: sfInitObj.fieldType, failReason: 'sf took too long to config' });\n }, SF_CONFIG_TIMEOUT);\n\n // If all iframes are loaded - call onLoad callback\n if (this.state.iframeCount === this.state.originalNumIframes) {\n const callbackObj: CardLoadData = { iframesLoaded: true };\n this.callbacks.onLoad(callbackObj);\n }\n })\n .onConfig((pFeedbackObj: SFFeedbackObj): void => {\n this.handleIframeConfigFeedback(pFeedbackObj);\n\n // Clear timeout since the securedField has configured\n clearTimeout(sf.loadToConfigTimeout);\n sf.loadToConfigTimeout = null;\n\n resolve(pFeedbackObj);\n })\n .onFocus((pFeedbackObj: SFFeedbackObj): void => {\n this.handleFocus(pFeedbackObj);\n })\n .onBinValue((pFeedbackObj: SFFeedbackObj): void => {\n this.handleBinValue(pFeedbackObj);\n })\n .onTouchstart((pFeedbackObj: SFFeedbackObj): void => {\n // re. Disabling arrow keys in iOS - need to disable all other fields in the form\n if (this.props.shouldDisableIOSArrowKeys) {\n /**\n * re. this.hasGenuineTouchEvents...\n * There seems to be an issue with Responsive Design mode in Safari that means it allows setting focus on cross-origin iframes,\n * without enabling the touch events that allow the \"disableIOSArrowKeys\" workaround to fully function.\n * This results in a click on an securedFields *label* leading to, for example, the holderName field being disabled, but w/o access\n * to the touch events that would let it re-enable itself.\n *\n * So we prevent the \"disableIOSArrowKeys\" workaround unless we genuinely have touch events available.\n */\n if (this.hasGenuineTouchEvents || pFeedbackObj.hasGenuineTouchEvents) {\n this.callbacks.onTouchstartIOS({ fieldType: pFeedbackObj.fieldType });\n }\n }\n\n // Only perform this step if we genuinely have touch events available\n if (pFeedbackObj.hasGenuineTouchEvents || this.hasGenuineTouchEvents) {\n // iOS ONLY - RE. iOS BUGS AROUND BLUR AND FOCUS EVENTS\n // - pass information about which field has just been clicked (gained focus) to the other iframes\n this.postMessageToAllIframes({ fieldType: pFeedbackObj.fieldType, fieldClick: true });\n }\n })\n .onShiftTab((pFeedbackObj: SFFeedbackObj): void => {\n // Only happens for Firefox & IE <= 11\n this.handleSFShiftTab(pFeedbackObj.fieldType);\n })\n .onEncryption((pFeedbackObj: SFFeedbackObj): void => {\n this.handleEncryption(pFeedbackObj);\n })\n .onValidation((pFeedbackObj: SFFeedbackObj): void => {\n this.handleValidation(pFeedbackObj);\n })\n .onAutoComplete((pFeedbackObj: SFFeedbackObj): void => {\n this.processAutoComplete(pFeedbackObj);\n })\n .onKeyPressed((pFeedbackObj: SFFeedbackObj): void => {\n const { numKey, ...rest } = pFeedbackObj;\n this.callbacks.onKeyPressed(rest as SFKeyPressObj);\n });\n\n // Store reference to securedField in this.state (under fieldType)\n this.state.securedFields[fieldType] = sf;\n });\n}\n"],"names":["createSecuredFields","this","encryptedAttrName","DATA_ENCRYPTED_FIELD_ATTR","securedFields","select","props","rootNode","filter","field","fieldType","getAttribute","isValidType","ALL_SECURED_FIELDS","includes","console","warn","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","config","isCreditCardType","isSingleBrandedCard","securityCode","createCardSecuredFields","length","createNonCardSecuredFields","async","i","securedField","setupSecuredField","catch","e","window","_b$dl","log","type","state","cardGroupTypes","card","cardType","getCardByBrand","existy","callbackObj","brand","cvcText","setTimeout","callbacks","onBrand","pItem","Promise","resolve","reject","ENCRYPTED_EXPIRY_YEAR","hasSeparateDateFields","sfInitObj","extraFieldData","DATA_INFO","uid","DATA_UID","holderEl","txVariant","iframeUIConfig","sfLogAtStart","trimTrailingSeparator","iframeSrc","loadingContext","showWarnings","legacyInputMode","minimumExpiryDate","maskSecurityCode","exposeExpiryDate","disableIOSArrowKeys","shouldDisableIOSArrowKeys","implementationType","showContextualElement","placeholders","sf","SecuredField","i18n","onIframeLoaded","iframeCount","numIframes","destroySecuredFields","AdyenCheckoutError","loadToConfigTimeout","failReason","SF_CONFIG_TIMEOUT","originalNumIframes","iframesLoaded","onLoad","onConfig","pFeedbackObj","handleIframeConfigFeedback","clearTimeout","onFocus","handleFocus","onBinValue","handleBinValue","onTouchstart","hasGenuineTouchEvents","onTouchstartIOS","postMessageToAllIframes","fieldClick","onShiftTab","handleSFShiftTab","onEncryption","handleEncryption","onValidation","handleValidation","onAutoComplete","processAutoComplete","onKeyPressed","numKey","rest"],"mappings":"qmCAwBO,SAASA,IACZC,KAAKC,kBAAoBC,EAGzB,MAAMC,EAA+BC,EAAOJ,KAAKK,MAAMC,SAAU,IAAIN,KAAKC,sBAAsBM,OAAOC,IACnG,MAAMC,EAAoBC,EAAaF,EAAOR,KAAKC,mBAM7CU,EAAcC,EAAmBC,SAASJ,GAMhD,OALKE,GACDG,QAAQC,KACJ,aAAaN,mCAA2CT,KAAKC,sFAG9DU,IAULK,EAA2BC,EAG3BC,EAAmCC,EAGzC,OAAKnB,KAAKoB,OAAOC,kBAMjBrB,KAAKsB,qBAAsB,EAE3BtB,KAAKuB,aAAe,GAEpBvB,KAAKwB,wBAAwBrB,EAAea,EAAWE,GAGhDf,EAAcsB,SAZjBzB,KAAK0B,2BAA2BvB,GACzBA,EAAcsB,OAY7B,CAOOE,eAAeD,EAA2BvB,GAC7C,IAAK,IAAIyB,EAAI,EAAGA,EAAIzB,EAAcsB,OAAQG,IAAK,CAC3C,MAAMC,EAAe1B,EAAcyB,SAC7B5B,KAAK8B,kBAAkBD,GAAcE,MAAMC,IACzCC,OAAOC,OAAOpB,QAAQqB,IAAI,mCAAoCH,IAE1E,CACJ,CAEOL,eAAeH,EAClBrB,EACAa,EACAE,GAGA,IAAIkB,EAAepC,KAAKqC,MAAMD,KAa9B,GATa,SAATA,GAAyD,IAAtCpC,KAAKoB,OAAOkB,eAAeb,SAC9CW,EAAOpC,KAAKoB,OAAOkB,eAAe,GAClCtC,KAAKqC,MAAMD,KAAOA,GAItBpC,KAAKsB,oBAA+B,SAATc,EAGvBpC,KAAKsB,oBAAqB,CAE1B,MAAMiB,EAAmBC,EAASC,eAAeL,GAI5CM,EAAOH,IAIRvB,EAAYuB,EAAKvB,WAAaC,EAC9BC,EAAmBqB,EAAKrB,kBAAoBC,EAE5CnB,KAAKuB,aAAegB,EAAKhB,cANzBvB,KAAKqC,MAAMD,KAAO,2BAQ1B,CAeA,IAAK,IAAIR,EAAI,EAAGA,EAAIzB,EAAcsB,OAAQG,IAAK,CAC3C,MAAMC,EAAe1B,EAAcyB,GAC/BK,OAAOC,OAAOpB,QAAQqB,IAAI,kCAAmCN,SAC3D7B,KAAK8B,kBAAkBD,EAAcb,EAAWE,GAAkBa,MAAMC,IACtEC,OAAOC,OAAOpB,QAAQqB,IAAI,mCAAoCH,KAElEC,OAAOC,OAAOpB,QAAQqB,IAAI,oCAAqCN,EACvE,CAUA,GATII,OAAOC,OAAOpB,QAAQqB,IAAI,yCAS1BnC,KAAKsB,oBAAqB,CAC1B,MAAMqB,EAA6B,CAC/BP,KAAMpC,KAAKqC,MAAMD,KACjB9B,SAAUN,KAAKK,MAAMC,SACrBsC,MAAOR,EACPpB,YACAE,mBACA2B,QAAS7C,KAAKuB,cAIlBuB,WAAW,KACP9C,KAAK+C,UAAUC,QAAQL,IACxB,EACP,CACJ,CAGO,SAASb,EAAkBmB,EAAoBjC,EAA2BE,GAC7E,OAAO,IAAIgC,QAAQ,CAACC,EAASC,KAczB,MAAM3C,EAAoBC,EAAauC,EAAOjD,KAAKC,mBAE/CQ,IAAc4C,IACdrD,KAAKqC,MAAMiB,uBAAwB,GAGvC,MAIMC,EAAqC,CACvC9C,YACA+C,eAN2B9C,EAAauC,EAAOQ,GAO/CC,IANQhD,EAAauC,EAAOU,GAO5B3C,YACA4C,SAAUX,EACV/B,mBACA2C,UAAW7D,KAAKqC,MAAMD,KAEtBE,eAAgBtC,KAAKoB,OAAOkB,eAC5BwB,eAAgB9D,KAAKoB,OAAO0C,eAC5BC,aAAc/D,KAAKoB,OAAO2C,aAC1BC,sBAAuBhE,KAAKoB,OAAO4C,sBACnC3C,iBAAkBrB,KAAKoB,OAAOC,iBAC9B4C,UAAWjE,KAAKoB,OAAO6C,UACvBC,eAAgBlE,KAAKoB,OAAO8C,eAC5BC,aAAcnE,KAAKoB,OAAO+C,aAC1BC,gBAAiBpE,KAAKoB,OAAOgD,gBAC7BC,kBAAmBrE,KAAKoB,OAAOiD,kBAE/BC,iBAAkBtE,KAAKK,MAAMiE,iBAC7BC,iBAAkBvE,KAAKK,MAAMkE,iBAC7BC,oBAAqBxE,KAAKK,MAAMoE,0BAChCC,mBAAoB1E,KAAKK,MAAMqE,mBAC/BC,sBAAuB3E,KAAKK,MAAMsE,sBAClCC,aAAc5E,KAAKK,MAAMuE,cAGvBC,EAAmB,IAAIC,EAAavB,EAAWvD,KAAKK,MAAM0E,MAC3DC,eAAe,KAOZ,GALAhF,KAAKqC,MAAM4C,aAAe,EAEtBhD,OAAOC,OAAOpB,QAAQqB,IAAI,oEAAqEnC,KAAKqC,MAAM4C,aAG1GjF,KAAKqC,MAAM4C,YAAcjF,KAAKqC,MAAM6C,WAGpC,MAFAlF,KAAKmF,uBAEC,IAAIC,EACN,QACA,gKACoBpF,KAAKqC,MAAM4C,+BAA+BjF,KAAKqC,MAAM6C,cAWjF,GALAL,EAAGQ,oBAAsBvC,WAAW,KAChCM,EAAO,CAAEhB,KAAMmB,EAAU9C,UAAW6E,WAAY,gCACjDC,GAGCvF,KAAKqC,MAAM4C,cAAgBjF,KAAKqC,MAAMmD,mBAAoB,CAC1D,MAAM7C,EAA4B,CAAE8C,eAAe,GACnDzF,KAAK+C,UAAU2C,OAAO/C,EAC1B,IAEHgD,SAAUC,IACP5F,KAAK6F,2BAA2BD,GAGhCE,aAAajB,EAAGQ,qBAChBR,EAAGQ,oBAAsB,KAEzBlC,EAAQyC,KAEXG,QAASH,IACN5F,KAAKgG,YAAYJ,KAEpBK,WAAYL,IACT5F,KAAKkG,eAAeN,KAEvBO,aAAcP,IAEP5F,KAAKK,MAAMoE,4BAUPzE,KAAKoG,uBAAyBR,EAAaQ,wBAC3CpG,KAAK+C,UAAUsD,gBAAgB,CAAE5F,UAAWmF,EAAanF,aAK7DmF,EAAaQ,uBAAyBpG,KAAKoG,wBAG3CpG,KAAKsG,wBAAwB,CAAE7F,UAAWmF,EAAanF,UAAW8F,YAAY,MAGrFC,WAAYZ,IAET5F,KAAKyG,iBAAiBb,EAAanF,aAEtCiG,aAAcd,IACX5F,KAAK2G,iBAAiBf,KAEzBgB,aAAchB,IACX5F,KAAK6G,iBAAiBjB,KAEzBkB,eAAgBlB,IACb5F,KAAK+G,oBAAoBnB,KAE5BoB,aAAcpB,IACX,MAAMqB,OAAEA,GAAoBrB,EAATsB,EAAAA,EAAStB,EAAAA,YAC5B5F,KAAK+C,UAAUiE,aAAaE,KAIpClH,KAAKqC,MAAMlC,cAAcM,GAAaoE,GAE9C"}
@@ -1,2 +1,2 @@
1
- import{DATE_POLICY_REQUIRED as e,ENCRYPTED_EXPIRY_DATE as t,DATE_POLICY_HIDDEN as s,ENCRYPTED_CARD_NUMBER as i,ENCRYPTED_SECURITY_CODE as r,ENCRYPTED_EXPIRY_MONTH as n,ENCRYPTED_EXPIRY_YEAR as o}from"../../constants.js";import c from"../utils/iframes/postMessageToIframe.js";import{hasOwnProperty as a}from"../../../../../../utils/hasOwnProperty.js";import l from"../utils/iframes/getIframeContentWin.js";function d(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function u(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},i=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(s).filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),i.forEach(function(t){d(e,t,s[t])})}return e}function y(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t.push.apply(t,s)}return t}(Object(t)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(t,s))}),e}function p(e){if(a(this.state.securedFields,i)){const t=y(u({txVariant:this.state.type},e),{fieldType:i,numKey:this.state.securedFields[i].numKey});c(t,l(this.state,i),this.config.loadingContext)}}function h(e){(a(this.state.securedFields,n)&&a(this.state.securedFields,o)?[n,o]:[t]).forEach(t=>{const s=y(u({txVariant:this.state.type},e),{fieldType:t,numKey:this.state.securedFields[t].numKey});c(s,l(this.state,t),this.config.loadingContext)})}function f(c,l){const d="card"===this.state.type;if(!c||!Object.keys(c).length)return d?(this.sendBrandToCardSF({brand:"reset"}),this.sendExpiryDatePolicyToSF({expiryDatePolicy:e})):l&&this.processBrand(y(u({},l),{fieldType:i})),void("card"===this.state.type&&a(this.state.securedFields,t)&&(this.state.securedFields[t].expiryDatePolicy=e));const p=c.supportedBrands[0],h=p.brand;var f;const b=null!==(f=p.expiryDatePolicy)&&void 0!==f?f:!0===p.showExpiryDate?e:s;var P;const m={brand:h,cvcPolicy:p.cvcPolicy,expiryDatePolicy:b,cvcText:"Security code",showSocialSecurityNumber:null!==(P=p.showSocialSecurityNumber)&&void 0!==P&&P,fieldType:i};if(this.processBrand(m),d){const e=u({brand:h,enableLuhnCheck:!1!==c.supportedBrands[0].enableLuhnCheck},(null==p?void 0:p.panLength)&&!c.isDualBrandSelection&&{panLength:null==p?void 0:p.panLength});this.sendBrandToCardSF(e),this.sendExpiryDatePolicyToSF({expiryDatePolicy:b})}a(this.state.securedFields,r)&&(this.state.securedFields[r].cvcPolicy=p.cvcPolicy),a(this.state.securedFields,t)?this.state.securedFields[t].expiryDatePolicy=b:a(this.state.securedFields,n)&&a(this.state.securedFields,o)&&(this.state.securedFields[n].expiryDatePolicy=b,this.state.securedFields[o].expiryDatePolicy=b),this.validateForm()}export{f as default,p as sendBrandToCardSF,h as sendExpiryDatePolicyToSF};
1
+ import{DATE_POLICY_REQUIRED as e,ENCRYPTED_EXPIRY_DATE as t,DATE_POLICY_HIDDEN as s,ENCRYPTED_CARD_NUMBER as i,ENCRYPTED_SECURITY_CODE as r,ENCRYPTED_EXPIRY_MONTH as n,ENCRYPTED_EXPIRY_YEAR as o}from"../../constants.js";import c from"../utils/iframes/postMessageToIframe.js";import{hasOwnProperty as a}from"../../../../../../utils/hasOwnProperty.js";import l from"../utils/iframes/getIframeContentWin.js";function d(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function u(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},i=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(s).filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),i.forEach(function(t){d(e,t,s[t])})}return e}function y(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t.push.apply(t,s)}return t}(Object(t)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(t,s))}),e}function p(e){if(a(this.state.securedFields,i)){const t=y(u({txVariant:this.state.type},e),{fieldType:i,numKey:this.state.securedFields[i].numKey});c(t,l(this.state,i),this.config.loadingContext)}}function h(e){(a(this.state.securedFields,n)&&a(this.state.securedFields,o)?[n,o]:[t]).forEach(t=>{const s=y(u({txVariant:this.state.type},e),{fieldType:t,numKey:this.state.securedFields[t].numKey});c(s,l(this.state,t),this.config.loadingContext)})}function f(c,l){var d,p;const h="card"===this.state.type;if(!c||!Object.keys(c).length)return h?(this.sendBrandToCardSF({brand:"reset"}),this.sendExpiryDatePolicyToSF({expiryDatePolicy:e})):l&&this.processBrand(y(u({},l),{fieldType:i})),void("card"===this.state.type&&a(this.state.securedFields,t)&&(this.state.securedFields[t].expiryDatePolicy=e));const f=c.supportedBrands[0],b=f.brand,P=null!==(d=f.expiryDatePolicy)&&void 0!==d?d:!0===f.showExpiryDate?e:s,m={brand:b,cvcPolicy:f.cvcPolicy,expiryDatePolicy:P,cvcText:"Security code",showSocialSecurityNumber:null!==(p=f.showSocialSecurityNumber)&&void 0!==p&&p,fieldType:i};if(this.processBrand(m),h){const e=u({brand:b,enableLuhnCheck:!1!==c.supportedBrands[0].enableLuhnCheck},(null==f?void 0:f.panLength)&&!c.isDualBrandSelection&&{panLength:null==f?void 0:f.panLength});this.sendBrandToCardSF(e),this.sendExpiryDatePolicyToSF({expiryDatePolicy:P})}a(this.state.securedFields,r)&&(this.state.securedFields[r].cvcPolicy=f.cvcPolicy),a(this.state.securedFields,t)?this.state.securedFields[t].expiryDatePolicy=P:a(this.state.securedFields,n)&&a(this.state.securedFields,o)&&(this.state.securedFields[n].expiryDatePolicy=P,this.state.securedFields[o].expiryDatePolicy=P),this.validateForm()}export{f as default,p as sendBrandToCardSF,h as sendExpiryDatePolicyToSF};
2
2
  //# sourceMappingURL=handleBrandFromBinLookup.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"handleBrandFromBinLookup.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.ts"],"sourcesContent":["import {\n ENCRYPTED_SECURITY_CODE,\n ENCRYPTED_CARD_NUMBER,\n DATE_POLICY_REQUIRED,\n DATE_POLICY_HIDDEN,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR\n} from '../../constants';\nimport postMessageToIframe from '../utils/iframes/postMessageToIframe';\nimport { SFFeedbackObj, SendBrandObject, SendExpiryDateObject } from '../../types';\nimport { BinLookupResponse, BrandObject } from '../../../../../Card/types';\nimport { hasOwnProperty } from '../../../../../../utils/hasOwnProperty';\nimport getIframeContentWin from '../utils/iframes/getIframeContentWin';\nimport { SingleBrandResetObject } from '../../../SFP/types';\n\nexport function sendBrandToCardSF(brandObj: SendBrandObject): void {\n if (hasOwnProperty(this.state.securedFields, ENCRYPTED_CARD_NUMBER)) {\n const dataObj: object = {\n txVariant: this.state.type,\n ...brandObj,\n fieldType: ENCRYPTED_CARD_NUMBER,\n numKey: this.state.securedFields[ENCRYPTED_CARD_NUMBER].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(this.state, ENCRYPTED_CARD_NUMBER), this.config.loadingContext);\n }\n}\n\nexport function sendExpiryDatePolicyToSF(expiryDateObj: SendExpiryDateObject): void {\n const separateDateFields =\n hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_MONTH) && hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_YEAR);\n\n const dateIframesArr = separateDateFields ? [ENCRYPTED_EXPIRY_MONTH, ENCRYPTED_EXPIRY_YEAR] : [ENCRYPTED_EXPIRY_DATE];\n\n dateIframesArr.forEach((key: string) => {\n const dataObj: object = {\n txVariant: this.state.type,\n ...expiryDateObj,\n fieldType: key,\n numKey: this.state.securedFields[key].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(this.state, key), this.config.loadingContext);\n });\n}\n\nexport default function handleBrandFromBinLookup(binLookupResponse: BinLookupResponse, resetObj: SingleBrandResetObject): void {\n const isGenericCard: boolean = this.state.type === 'card';\n\n /**\n * The number of digits in number field has dropped below threshold for BIN lookup (or the bin wasn't found in the DB)\n * - so tell SF to reset & republish the brand it detects\n */\n if (!binLookupResponse || !Object.keys(binLookupResponse).length) {\n if (isGenericCard) {\n // This will be sent to CardNumber SF which will trigger the brand to be re-evaluated and broadcast\n // (which will reset cvcPolicy & expiryDatePolicy in state, here in Checkout)\n this.sendBrandToCardSF({ brand: 'reset' });\n // Also pass the reset expiryDatePolicy to the date related SFs so they can reset visibility & aria-required attrs\n this.sendExpiryDatePolicyToSF({ expiryDatePolicy: DATE_POLICY_REQUIRED });\n } else {\n /**\n * For \"dedicated\" card components, i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands,\n * there will be no to-and-fro with the securedField iframe to reset brand.\n * The presence of a resetObj indicates we are in this \"dedicated\"\" scenario, so we need to use the information contained within this object\n * to internally reset the brand\n */\n if (resetObj) {\n this.processBrand({ ...resetObj, fieldType: ENCRYPTED_CARD_NUMBER } as SFFeedbackObj);\n }\n }\n\n // Reset expiryDatePolicy - which never comes from SF // TODO find out under which circumstances this clause is still required\n if (this.state.type === 'card' && hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_DATE)) {\n this.state.securedFields[ENCRYPTED_EXPIRY_DATE].expiryDatePolicy = DATE_POLICY_REQUIRED;\n }\n\n return;\n }\n\n const binBrandObj: BrandObject = binLookupResponse.supportedBrands[0];\n\n const passedBrand: string = binBrandObj.brand;\n\n // Look first for expiryDatePolicy string otherwise use showExpiryDate boolean\n const expiryDatePolicy = binBrandObj.expiryDatePolicy ?? (binBrandObj.showExpiryDate === true ? DATE_POLICY_REQUIRED : DATE_POLICY_HIDDEN);\n\n const brandObj: object = {\n brand: passedBrand,\n cvcPolicy: binBrandObj.cvcPolicy,\n expiryDatePolicy,\n cvcText: 'Security code',\n showSocialSecurityNumber: binBrandObj.showSocialSecurityNumber ?? false,\n fieldType: ENCRYPTED_CARD_NUMBER\n };\n\n // Take advantage of function used to handle brand messages from SF in order to process this new brand information\n this.processBrand(brandObj as SFFeedbackObj);\n\n if (isGenericCard) {\n // Pass brand to CardNumber SF\n const cardObj: SendBrandObject = {\n brand: passedBrand,\n enableLuhnCheck: binLookupResponse.supportedBrands[0].enableLuhnCheck !== false,\n // Only pass the panLength if a) we have one & b) we're not in a switching-between-dual-brands scenario\n // (because it causes unnecessary callbacks from SF which uses panLength to trigger moving focus to the expiryDate field)\n ...(binBrandObj?.panLength && !binLookupResponse.isDualBrandSelection && { panLength: binBrandObj?.panLength })\n };\n this.sendBrandToCardSF(cardObj);\n\n // Inform the date related securedFields\n // - if expiryDatePolicy is 'optional' or 'hidden' they need to set the aria-required attribute / hide themselves\n this.sendExpiryDatePolicyToSF({ expiryDatePolicy });\n }\n\n /**\n * CHECK IF BRAND CHANGE MEANS FORM IS NOW VALID e.g maestro/bcmc (which don't require cvc) OR bcmc/visa (one of which doesn't require cvc, one of which does)\n */\n\n /**\n * First set the cvcPolicy value on the relevant SecuredFields instance (which will reflect in the cvc field being considered valid,\n * as long as it is not in error)...\n */\n if (hasOwnProperty(this.state.securedFields, ENCRYPTED_SECURITY_CODE)) {\n this.state.securedFields[ENCRYPTED_SECURITY_CODE].cvcPolicy = binBrandObj.cvcPolicy;\n }\n\n /**\n * ...then set the expiryDatePolicy...\n */\n if (hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_DATE)) {\n this.state.securedFields[ENCRYPTED_EXPIRY_DATE].expiryDatePolicy = expiryDatePolicy;\n } else if (hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_MONTH) && hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_YEAR)) {\n this.state.securedFields[ENCRYPTED_EXPIRY_MONTH].expiryDatePolicy = expiryDatePolicy;\n this.state.securedFields[ENCRYPTED_EXPIRY_YEAR].expiryDatePolicy = expiryDatePolicy;\n }\n\n /**\n * ...and now re-check if form i.e all the SecuredFields, are valid\n */\n this.validateForm();\n}\n"],"names":["sendBrandToCardSF","brandObj","hasOwnProperty","this","state","securedFields","ENCRYPTED_CARD_NUMBER","dataObj","_object_spread_props","_object_spread","txVariant","type","fieldType","numKey","postMessageToIframe","getIframeContentWin","config","loadingContext","sendExpiryDatePolicyToSF","expiryDateObj","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","ENCRYPTED_EXPIRY_DATE","forEach","key","handleBrandFromBinLookup","binLookupResponse","resetObj","isGenericCard","Object","keys","length","brand","expiryDatePolicy","DATE_POLICY_REQUIRED","processBrand","binBrandObj","supportedBrands","passedBrand","showExpiryDate","DATE_POLICY_HIDDEN","cvcPolicy","cvcText","showSocialSecurityNumber","cardObj","enableLuhnCheck","panLength","isDualBrandSelection","ENCRYPTED_SECURITY_CODE","validateForm"],"mappings":"8rCAgBO,SAASA,EAAkBC,GAC9B,GAAIC,EAAeC,KAAKC,MAAMC,cAAeC,GAAwB,CACjE,MAAMC,EAAkBC,EAAAC,EAAA,CACpBC,UAAWP,KAAKC,MAAMO,MACnBV,GAAAA,CACHW,UAAWN,EACXO,OAAQV,KAAKC,MAAMC,cAAcC,GAAuBO,SAE5DC,EAAoBP,EAASQ,EAAoBZ,KAAKC,MAAOE,GAAwBH,KAAKa,OAAOC,eACrG,CACJ,CAEO,SAASC,EAAyBC,IAEjCjB,EAAeC,KAAKC,MAAMC,cAAee,IAA2BlB,EAAeC,KAAKC,MAAMC,cAAegB,GAErE,CAACD,EAAwBC,GAAyB,CAACC,IAEhFC,QAASC,IACpB,MAAMjB,EAAkBC,EAAAC,EAAA,CACpBC,UAAWP,KAAKC,MAAMO,MACnBQ,GAAAA,CACHP,UAAWY,EACXX,OAAQV,KAAKC,MAAMC,cAAcmB,GAAKX,SAE1CC,EAAoBP,EAASQ,EAAoBZ,KAAKC,MAAOoB,GAAMrB,KAAKa,OAAOC,iBAEvF,CAEe,SAASQ,EAAyBC,EAAsCC,GACnF,MAAMC,EAA6C,SAApBzB,KAAKC,MAAMO,KAM1C,IAAKe,IAAsBG,OAAOC,KAAKJ,GAAmBK,OAwBtD,OAvBIH,GAGAzB,KAAKH,kBAAkB,CAAEgC,MAAO,UAEhC7B,KAAKe,yBAAyB,CAAEe,iBAAkBC,KAQ9CP,GACAxB,KAAKgC,aAAa3B,EAAAC,EAAA,CAAA,EAAKkB,GAAAA,CAAUf,UAAWN,UAK5B,SAApBH,KAAKC,MAAMO,MAAmBT,EAAeC,KAAKC,MAAMC,cAAeiB,KACvEnB,KAAKC,MAAMC,cAAciB,GAAuBW,iBAAmBC,IAM3E,MAAME,EAA2BV,EAAkBW,gBAAgB,GAE7DC,EAAsBF,EAAYJ,MAGfI,IAAAA,EAAzB,MAAMH,EAA+C,QAA5BG,EAAAA,EAAYH,wBAAZG,IAAAA,EAAAA,GAAgE,IAA/BA,EAAYG,eAA0BL,EAAuBM,EAOzFJ,IAAAA,EAL9B,MAAMnC,EAAmB,CACrB+B,MAAOM,EACPG,UAAWL,EAAYK,UACvBR,mBACAS,QAAS,gBACTC,yBAA8D,QAApCP,EAAAA,EAAYO,oCAAZP,GAAAA,EAC1BxB,UAAWN,GAMf,GAFAH,KAAKgC,aAAalC,GAEd2B,EAAe,CAEf,MAAMgB,EAA2BnC,EAAA,CAC7BuB,MAAOM,EACPO,iBAA0E,IAAzDnB,EAAkBW,gBAAgB,GAAGQ,kBAGlDT,eAAAA,EAAaU,aAAcpB,EAAkBqB,sBAAwB,CAAED,UAAWV,aAAAA,EAAAA,EAAaU,YAEvG3C,KAAKH,kBAAkB4C,GAIvBzC,KAAKe,yBAAyB,CAAEe,oBACpC,CAUI/B,EAAeC,KAAKC,MAAMC,cAAe2C,KACzC7C,KAAKC,MAAMC,cAAc2C,GAAyBP,UAAYL,EAAYK,WAM1EvC,EAAeC,KAAKC,MAAMC,cAAeiB,GACzCnB,KAAKC,MAAMC,cAAciB,GAAuBW,iBAAmBA,EAC5D/B,EAAeC,KAAKC,MAAMC,cAAee,IAA2BlB,EAAeC,KAAKC,MAAMC,cAAegB,KACpHlB,KAAKC,MAAMC,cAAce,GAAwBa,iBAAmBA,EACpE9B,KAAKC,MAAMC,cAAcgB,GAAuBY,iBAAmBA,GAMvE9B,KAAK8C,cACT"}
1
+ {"version":3,"file":"handleBrandFromBinLookup.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.ts"],"sourcesContent":["import {\n ENCRYPTED_SECURITY_CODE,\n ENCRYPTED_CARD_NUMBER,\n DATE_POLICY_REQUIRED,\n DATE_POLICY_HIDDEN,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR\n} from '../../constants';\nimport postMessageToIframe from '../utils/iframes/postMessageToIframe';\nimport { SFFeedbackObj, SendBrandObject, SendExpiryDateObject } from '../../types';\nimport { BinLookupResponse, BrandObject } from '../../../../../Card/types';\nimport { hasOwnProperty } from '../../../../../../utils/hasOwnProperty';\nimport getIframeContentWin from '../utils/iframes/getIframeContentWin';\nimport { SingleBrandResetObject } from '../../../SFP/types';\n\nexport function sendBrandToCardSF(brandObj: SendBrandObject): void {\n if (hasOwnProperty(this.state.securedFields, ENCRYPTED_CARD_NUMBER)) {\n const dataObj: object = {\n txVariant: this.state.type,\n ...brandObj,\n fieldType: ENCRYPTED_CARD_NUMBER,\n numKey: this.state.securedFields[ENCRYPTED_CARD_NUMBER].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(this.state, ENCRYPTED_CARD_NUMBER), this.config.loadingContext);\n }\n}\n\nexport function sendExpiryDatePolicyToSF(expiryDateObj: SendExpiryDateObject): void {\n const separateDateFields =\n hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_MONTH) && hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_YEAR);\n\n const dateIframesArr = separateDateFields ? [ENCRYPTED_EXPIRY_MONTH, ENCRYPTED_EXPIRY_YEAR] : [ENCRYPTED_EXPIRY_DATE];\n\n dateIframesArr.forEach((key: string) => {\n const dataObj: object = {\n txVariant: this.state.type,\n ...expiryDateObj,\n fieldType: key,\n numKey: this.state.securedFields[key].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(this.state, key), this.config.loadingContext);\n });\n}\n\nexport default function handleBrandFromBinLookup(binLookupResponse: BinLookupResponse, resetObj: SingleBrandResetObject): void {\n const isGenericCard: boolean = this.state.type === 'card';\n\n /**\n * The number of digits in number field has dropped below threshold for BIN lookup (or the bin wasn't found in the DB)\n * - so tell SF to reset & republish the brand it detects\n */\n if (!binLookupResponse || !Object.keys(binLookupResponse).length) {\n if (isGenericCard) {\n // This will be sent to CardNumber SF which will trigger the brand to be re-evaluated and broadcast\n // (which will reset cvcPolicy & expiryDatePolicy in state, here in Checkout)\n this.sendBrandToCardSF({ brand: 'reset' });\n // Also pass the reset expiryDatePolicy to the date related SFs so they can reset visibility & aria-required attrs\n this.sendExpiryDatePolicyToSF({ expiryDatePolicy: DATE_POLICY_REQUIRED });\n } else {\n /**\n * For \"dedicated\" card components, i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands,\n * there will be no to-and-fro with the securedField iframe to reset brand.\n * The presence of a resetObj indicates we are in this \"dedicated\"\" scenario, so we need to use the information contained within this object\n * to internally reset the brand\n */\n if (resetObj) {\n this.processBrand({ ...resetObj, fieldType: ENCRYPTED_CARD_NUMBER } as SFFeedbackObj);\n }\n }\n\n // Reset expiryDatePolicy - which never comes from SF // TODO find out under which circumstances this clause is still required\n if (this.state.type === 'card' && hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_DATE)) {\n this.state.securedFields[ENCRYPTED_EXPIRY_DATE].expiryDatePolicy = DATE_POLICY_REQUIRED;\n }\n\n return;\n }\n\n const binBrandObj: BrandObject = binLookupResponse.supportedBrands[0];\n\n const passedBrand: string = binBrandObj.brand;\n\n // Look first for expiryDatePolicy string otherwise use showExpiryDate boolean\n const expiryDatePolicy = binBrandObj.expiryDatePolicy ?? (binBrandObj.showExpiryDate === true ? DATE_POLICY_REQUIRED : DATE_POLICY_HIDDEN);\n\n const brandObj: object = {\n brand: passedBrand,\n cvcPolicy: binBrandObj.cvcPolicy,\n expiryDatePolicy,\n cvcText: 'Security code',\n showSocialSecurityNumber: binBrandObj.showSocialSecurityNumber ?? false,\n fieldType: ENCRYPTED_CARD_NUMBER\n };\n\n // Take advantage of function used to handle brand messages from SF in order to process this new brand information\n this.processBrand(brandObj as SFFeedbackObj);\n\n if (isGenericCard) {\n // Pass brand to CardNumber SF\n const cardObj: SendBrandObject = {\n brand: passedBrand,\n enableLuhnCheck: binLookupResponse.supportedBrands[0].enableLuhnCheck !== false,\n // Only pass the panLength if a) we have one & b) we're not in a switching-between-dual-brands scenario\n // (because it causes unnecessary callbacks from SF which uses panLength to trigger moving focus to the expiryDate field)\n ...(binBrandObj?.panLength && !binLookupResponse.isDualBrandSelection && { panLength: binBrandObj?.panLength })\n };\n this.sendBrandToCardSF(cardObj);\n\n // Inform the date related securedFields\n // - if expiryDatePolicy is 'optional' or 'hidden' they need to set the aria-required attribute / hide themselves\n this.sendExpiryDatePolicyToSF({ expiryDatePolicy });\n }\n\n /**\n * CHECK IF BRAND CHANGE MEANS FORM IS NOW VALID e.g maestro/bcmc (which don't require cvc) OR bcmc/visa (one of which doesn't require cvc, one of which does)\n */\n\n /**\n * First set the cvcPolicy value on the relevant SecuredFields instance (which will reflect in the cvc field being considered valid,\n * as long as it is not in error)...\n */\n if (hasOwnProperty(this.state.securedFields, ENCRYPTED_SECURITY_CODE)) {\n this.state.securedFields[ENCRYPTED_SECURITY_CODE].cvcPolicy = binBrandObj.cvcPolicy;\n }\n\n /**\n * ...then set the expiryDatePolicy...\n */\n if (hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_DATE)) {\n this.state.securedFields[ENCRYPTED_EXPIRY_DATE].expiryDatePolicy = expiryDatePolicy;\n } else if (hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_MONTH) && hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_YEAR)) {\n this.state.securedFields[ENCRYPTED_EXPIRY_MONTH].expiryDatePolicy = expiryDatePolicy;\n this.state.securedFields[ENCRYPTED_EXPIRY_YEAR].expiryDatePolicy = expiryDatePolicy;\n }\n\n /**\n * ...and now re-check if form i.e all the SecuredFields, are valid\n */\n this.validateForm();\n}\n"],"names":["sendBrandToCardSF","brandObj","hasOwnProperty","this","state","securedFields","ENCRYPTED_CARD_NUMBER","dataObj","_object_spread_props","_object_spread","txVariant","type","fieldType","numKey","postMessageToIframe","getIframeContentWin","config","loadingContext","sendExpiryDatePolicyToSF","expiryDateObj","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","ENCRYPTED_EXPIRY_DATE","forEach","key","handleBrandFromBinLookup","binLookupResponse","resetObj","binBrandObj","isGenericCard","Object","keys","length","brand","expiryDatePolicy","DATE_POLICY_REQUIRED","processBrand","supportedBrands","passedBrand","showExpiryDate","DATE_POLICY_HIDDEN","cvcPolicy","cvcText","showSocialSecurityNumber","cardObj","enableLuhnCheck","panLength","isDualBrandSelection","ENCRYPTED_SECURITY_CODE","validateForm"],"mappings":"8rCAgBO,SAASA,EAAkBC,GAC9B,GAAIC,EAAeC,KAAKC,MAAMC,cAAeC,GAAwB,CACjE,MAAMC,EAAkBC,EAAAC,EAAA,CACpBC,UAAWP,KAAKC,MAAMO,MACnBV,GAAAA,CACHW,UAAWN,EACXO,OAAQV,KAAKC,MAAMC,cAAcC,GAAuBO,SAE5DC,EAAoBP,EAASQ,EAAoBZ,KAAKC,MAAOE,GAAwBH,KAAKa,OAAOC,eACrG,CACJ,CAEO,SAASC,EAAyBC,IAEjCjB,EAAeC,KAAKC,MAAMC,cAAee,IAA2BlB,EAAeC,KAAKC,MAAMC,cAAegB,GAErE,CAACD,EAAwBC,GAAyB,CAACC,IAEhFC,QAASC,IACpB,MAAMjB,EAAkBC,EAAAC,EAAA,CACpBC,UAAWP,KAAKC,MAAMO,MACnBQ,GAAAA,CACHP,UAAWY,EACXX,OAAQV,KAAKC,MAAMC,cAAcmB,GAAKX,SAE1CC,EAAoBP,EAASQ,EAAoBZ,KAAKC,MAAOoB,GAAMrB,KAAKa,OAAOC,iBAEvF,CAEe,SAASQ,EAAyBC,EAAsCC,OAuC1DC,EAOKA,EA7C9B,MAAMC,EAA6C,SAApB1B,KAAKC,MAAMO,KAM1C,IAAKe,IAAsBI,OAAOC,KAAKL,GAAmBM,OAwBtD,OAvBIH,GAGA1B,KAAKH,kBAAkB,CAAEiC,MAAO,UAEhC9B,KAAKe,yBAAyB,CAAEgB,iBAAkBC,KAQ9CR,GACAxB,KAAKiC,aAAa5B,EAAAC,EAAA,CAAA,EAAKkB,GAAAA,CAAUf,UAAWN,UAK5B,SAApBH,KAAKC,MAAMO,MAAmBT,EAAeC,KAAKC,MAAMC,cAAeiB,KACvEnB,KAAKC,MAAMC,cAAciB,GAAuBY,iBAAmBC,IAM3E,MAAMP,EAA2BF,EAAkBW,gBAAgB,GAE7DC,EAAsBV,EAAYK,MAGlCC,EAA+C,QAA5BN,EAAAA,EAAYM,wBAAZN,IAAAA,EAAAA,GAAgE,IAA/BA,EAAYW,eAA0BJ,EAAuBK,EAEjHvC,EAAmB,CACrBgC,MAAOK,EACPG,UAAWb,EAAYa,UACvBP,mBACAQ,QAAS,gBACTC,yBAA8D,QAApCf,EAAAA,EAAYe,oCAAZf,GAAAA,EAC1BhB,UAAWN,GAMf,GAFAH,KAAKiC,aAAanC,GAEd4B,EAAe,CAEf,MAAMe,EAA2BnC,EAAA,CAC7BwB,MAAOK,EACPO,iBAA0E,IAAzDnB,EAAkBW,gBAAgB,GAAGQ,kBAGlDjB,eAAAA,EAAakB,aAAcpB,EAAkBqB,sBAAwB,CAAED,UAAWlB,aAAAA,EAAAA,EAAakB,YAEvG3C,KAAKH,kBAAkB4C,GAIvBzC,KAAKe,yBAAyB,CAAEgB,oBACpC,CAUIhC,EAAeC,KAAKC,MAAMC,cAAe2C,KACzC7C,KAAKC,MAAMC,cAAc2C,GAAyBP,UAAYb,EAAYa,WAM1EvC,EAAeC,KAAKC,MAAMC,cAAeiB,GACzCnB,KAAKC,MAAMC,cAAciB,GAAuBY,iBAAmBA,EAC5DhC,EAAeC,KAAKC,MAAMC,cAAee,IAA2BlB,EAAeC,KAAKC,MAAMC,cAAegB,KACpHlB,KAAKC,MAAMC,cAAce,GAAwBc,iBAAmBA,EACpE/B,KAAKC,MAAMC,cAAcgB,GAAuBa,iBAAmBA,GAMvE/B,KAAK8C,cACT"}
@@ -1,2 +1,2 @@
1
- import{getCardGroupTypes as i}from"../utils/getCardGroupTypes.js";import{NON_CREDIT_CARD_TYPE_SECURED_FIELDS as o,SF_VERSION as t}from"../../constants.js";import{warn as n}from"../../utilities/logger.js";function e(e){this.config.cardGroupTypes=i(e.cardGroupTypes);const r=e.loadingContext;if(!r)return void n("WARNING Config :: no loadingContext has been specified!");var s,a;this.config.loadingContext="/"===(s=r).charAt(s.length-1)?r:`${r}/`,this.config.isCreditCardType=!1===o.includes(e.type),this.config.iframeUIConfig=null!==(a=e.iframeUIConfig)&&void 0!==a?a:{},this.config.autoFocus=!(!1===e.autoFocus||"false"===e.autoFocus),this.config.showWarnings=!0===e.showWarnings||"true"===e.showWarnings,this.config.trimTrailingSeparator=!(!1===e.trimTrailingSeparator||"false"===e.trimTrailingSeparator),this.config.keypadFix=!(!1===e.keypadFix||"false"===e.keypadFix),this.config.legacyInputMode=e.legacyInputMode||null,this.config.minimumExpiryDate=e.minimumExpiryDate||null,this.config.sfLogAtStart=!0===window._b$dl;const c=this.config.isCreditCardType?"card":e.type,g=btoa(window.location.origin),f=`${c}${!this.config.loadingContext.includes("live")&&e.forceCompat?"Compat":""}`;this.config.iframeSrc=`${this.config.loadingContext}securedfields/${e.clientKey}/${t}/securedFields.html?type=${f}&d=${g}`}export{e as handleConfig};
1
+ import{getCardGroupTypes as i}from"../utils/getCardGroupTypes.js";import{NON_CREDIT_CARD_TYPE_SECURED_FIELDS as o,SF_VERSION as t}from"../../constants.js";import{warn as n}from"../../utilities/logger.js";function e(e){var r;this.config.cardGroupTypes=i(e.cardGroupTypes);const s=e.loadingContext;if(!s)return void n("WARNING Config :: no loadingContext has been specified!");var a;this.config.loadingContext="/"===(a=s).charAt(a.length-1)?s:`${s}/`,this.config.isCreditCardType=!1===o.includes(e.type),this.config.iframeUIConfig=null!==(r=e.iframeUIConfig)&&void 0!==r?r:{},this.config.autoFocus=!(!1===e.autoFocus||"false"===e.autoFocus),this.config.showWarnings=!0===e.showWarnings||"true"===e.showWarnings,this.config.trimTrailingSeparator=!(!1===e.trimTrailingSeparator||"false"===e.trimTrailingSeparator),this.config.keypadFix=!(!1===e.keypadFix||"false"===e.keypadFix),this.config.legacyInputMode=e.legacyInputMode||null,this.config.minimumExpiryDate=e.minimumExpiryDate||null,this.config.sfLogAtStart=!0===window._b$dl;const c=this.config.isCreditCardType?"card":e.type,g=btoa(window.location.origin),f=`${c}${!this.config.loadingContext.includes("live")&&e.forceCompat?"Compat":""}`;this.config.iframeSrc=`${this.config.loadingContext}securedfields/${e.clientKey}/${t}/securedFields.html?type=${f}&d=${g}`}export{e as handleConfig};
2
2
  //# sourceMappingURL=handleConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"handleConfig.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.ts"],"sourcesContent":["import { getCardGroupTypes } from '../utils/getCardGroupTypes';\nimport { NON_CREDIT_CARD_TYPE_SECURED_FIELDS, SF_VERSION } from '../../constants';\nimport * as logger from '../../utilities/logger';\nimport { CSFSetupObject } from '../types';\n\n/**\n * Parses this.props to set 'config' type vars on this (CSFComp)\n * - properties that just need to be set once, at startup, and then don't change\n *\n * See interface CSFConfigObject in types.ts\n */\nexport function handleConfig(props: CSFSetupObject): void {\n // --\n this.config.cardGroupTypes = getCardGroupTypes(props.cardGroupTypes);\n\n if (process.env.NODE_ENV === 'development' && window._b$dl) {\n logger.log('### StoreCls::init:: this.config.cardGroupTypes=', this.config.cardGroupTypes);\n }\n\n const loadingContext: string = props.loadingContext;\n\n if (!loadingContext) {\n logger.warn('WARNING Config :: no loadingContext has been specified!');\n return;\n }\n\n // Ensure passed loadingContext has trailing slash\n const lastChar = str => str.charAt(str.length - 1);\n this.config.loadingContext = lastChar(loadingContext) === '/' ? loadingContext : `${loadingContext}/`;\n\n // Is this for the regular creditCard or for another use-case for securedFields e.g. 'ach' or 'giftcard'\n this.config.isCreditCardType = NON_CREDIT_CARD_TYPE_SECURED_FIELDS.includes(props.type) === false;\n\n // Configuration object for individual txVariants - contains styling object values for securedFields inputs\n this.config.iframeUIConfig = props.iframeUIConfig ?? {};\n\n // By default CSF is allowed to automatically shift focus from the date to CVC fields - user of CSF must explicitly 'opt-out' to prevent this happening\n this.config.autoFocus = !(props.autoFocus === false || props.autoFocus === 'false');\n\n // By default CSF will NOT perform a console.warn when receiving postMessages with origin or numKey mismatches - user of CSF must explicitly 'opt-in' to get this\n this.config.showWarnings = props.showWarnings === true || props.showWarnings === 'true';\n\n // By default CSF will strip the trailing separator character from valid credit card numbers - user of CSF must explicitly 'opt-out' to prevent this happening\n this.config.trimTrailingSeparator = !(props.trimTrailingSeparator === false || props.trimTrailingSeparator === 'false');\n\n // By default CSF is allowed to add a fix for iOS to force the keypad to retract - user of CSF must explicitly 'opt-out' to prevent this happening\n this.config.keypadFix = !(props.keypadFix === false || props.keypadFix === 'false');\n\n // To set the type on the iframe input fields to 'tel' c.f. the default 'text' (with inputmode='numeric')\n this.config.legacyInputMode = props.legacyInputMode || null;\n\n // To configure the minimum expiry date to a merchant defined value - this means the card has to be valid until at least this date\n this.config.minimumExpiryDate = props.minimumExpiryDate || null;\n\n this.config.sfLogAtStart = window._b$dl === true;\n\n const sfBundleType: string = this.config.isCreditCardType ? 'card' : props.type;\n\n // Add a hash of the origin to ensure urls are different across domains\n const d = btoa(window.location.origin);\n\n /**\n * Don't allow compat version on Live - it is only for if the merchant wants to *test* with a custom http url.\n * Otherwise, set it passed on the config prop\n */\n const needsJWECompatVersion = this.config.loadingContext.includes('live') ? false : props.forceCompat;\n\n const bundleModifier = !needsJWECompatVersion ? '' : 'Compat';\n\n const bundleType = `${sfBundleType}${bundleModifier}`; // e.g. 'card' or 'cardCompat'\n\n this.config.iframeSrc = `${this.config.loadingContext}securedfields/${props.clientKey}/${SF_VERSION}/securedFields.html?type=${bundleType}&d=${d}`;\n\n // TODO###### FOR QUICK LOCAL TESTING of sf\n if (process.env.NODE_ENV === 'development' && process.env.__SF_ENV__ !== 'build') {\n this.config.iframeSrc = `${process.env.__SF_ENV__}securedFields.${SF_VERSION}.html?type=${sfBundleType}`;\n }\n // TODO######\n}\n"],"names":["handleConfig","props","this","config","cardGroupTypes","getCardGroupTypes","loadingContext","logger","str","charAt","length","isCreditCardType","NON_CREDIT_CARD_TYPE_SECURED_FIELDS","includes","type","iframeUIConfig","autoFocus","showWarnings","trimTrailingSeparator","keypadFix","legacyInputMode","minimumExpiryDate","sfLogAtStart","window","_b$dl","sfBundleType","d","btoa","location","origin","bundleType","forceCompat","iframeSrc","clientKey","SF_VERSION"],"mappings":"4MAWO,SAASA,EAAaC,GAEzBC,KAAKC,OAAOC,eAAiBC,EAAkBJ,EAAMG,gBAMrD,MAAME,EAAyBL,EAAMK,eAErC,IAAKA,EAED,YADAC,EAAY,2DAKCC,IAAAA,EAOYP,EAN7BC,KAAKC,OAAOG,eAA8C,OADzCE,EACqBF,GADVG,OAAOD,EAAIE,OAAS,GACgBJ,EAAiB,GAAGA,KAGpFJ,KAAKC,OAAOQ,kBAAgF,IAA7DC,EAAoCC,SAASZ,EAAMa,MAGlFZ,KAAKC,OAAOY,eAAqC,QAApBd,EAAAA,EAAMc,sBAANd,IAAAA,EAAAA,EAAwB,CAAA,EAGrDC,KAAKC,OAAOa,aAAkC,IAApBf,EAAMe,WAA2C,UAApBf,EAAMe,WAG7Dd,KAAKC,OAAOc,cAAsC,IAAvBhB,EAAMgB,cAAgD,SAAvBhB,EAAMgB,aAGhEf,KAAKC,OAAOe,yBAA0D,IAAhCjB,EAAMiB,uBAAmE,UAAhCjB,EAAMiB,uBAGrFhB,KAAKC,OAAOgB,aAAkC,IAApBlB,EAAMkB,WAA2C,UAApBlB,EAAMkB,WAG7DjB,KAAKC,OAAOiB,gBAAkBnB,EAAMmB,iBAAmB,KAGvDlB,KAAKC,OAAOkB,kBAAoBpB,EAAMoB,mBAAqB,KAE3DnB,KAAKC,OAAOmB,cAAgC,IAAjBC,OAAOC,MAElC,MAAMC,EAAuBvB,KAAKC,OAAOQ,iBAAmB,OAASV,EAAMa,KAGrEY,EAAIC,KAAKJ,OAAOK,SAASC,QAUzBC,EAAa,GAAGL,KAJQvB,KAAKC,OAAOG,eAAeO,SAAS,SAAkBZ,EAAM8B,YAErC,SAAL,KAIhD7B,KAAKC,OAAO6B,UAAY,GAAG9B,KAAKC,OAAOG,+BAA+BL,EAAMgC,aAAaC,6BAAsCJ,OAAgBJ,GAOnJ"}
1
+ {"version":3,"file":"handleConfig.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.ts"],"sourcesContent":["import { getCardGroupTypes } from '../utils/getCardGroupTypes';\nimport { NON_CREDIT_CARD_TYPE_SECURED_FIELDS, SF_VERSION } from '../../constants';\nimport * as logger from '../../utilities/logger';\nimport { CSFSetupObject } from '../types';\n\n/**\n * Parses this.props to set 'config' type vars on this (CSFComp)\n * - properties that just need to be set once, at startup, and then don't change\n *\n * See interface CSFConfigObject in types.ts\n */\nexport function handleConfig(props: CSFSetupObject): void {\n // --\n this.config.cardGroupTypes = getCardGroupTypes(props.cardGroupTypes);\n\n if (process.env.NODE_ENV === 'development' && window._b$dl) {\n logger.log('### StoreCls::init:: this.config.cardGroupTypes=', this.config.cardGroupTypes);\n }\n\n const loadingContext: string = props.loadingContext;\n\n if (!loadingContext) {\n logger.warn('WARNING Config :: no loadingContext has been specified!');\n return;\n }\n\n // Ensure passed loadingContext has trailing slash\n const lastChar = str => str.charAt(str.length - 1);\n this.config.loadingContext = lastChar(loadingContext) === '/' ? loadingContext : `${loadingContext}/`;\n\n // Is this for the regular creditCard or for another use-case for securedFields e.g. 'ach' or 'giftcard'\n this.config.isCreditCardType = NON_CREDIT_CARD_TYPE_SECURED_FIELDS.includes(props.type) === false;\n\n // Configuration object for individual txVariants - contains styling object values for securedFields inputs\n this.config.iframeUIConfig = props.iframeUIConfig ?? {};\n\n // By default CSF is allowed to automatically shift focus from the date to CVC fields - user of CSF must explicitly 'opt-out' to prevent this happening\n this.config.autoFocus = !(props.autoFocus === false || props.autoFocus === 'false');\n\n // By default CSF will NOT perform a console.warn when receiving postMessages with origin or numKey mismatches - user of CSF must explicitly 'opt-in' to get this\n this.config.showWarnings = props.showWarnings === true || props.showWarnings === 'true';\n\n // By default CSF will strip the trailing separator character from valid credit card numbers - user of CSF must explicitly 'opt-out' to prevent this happening\n this.config.trimTrailingSeparator = !(props.trimTrailingSeparator === false || props.trimTrailingSeparator === 'false');\n\n // By default CSF is allowed to add a fix for iOS to force the keypad to retract - user of CSF must explicitly 'opt-out' to prevent this happening\n this.config.keypadFix = !(props.keypadFix === false || props.keypadFix === 'false');\n\n // To set the type on the iframe input fields to 'tel' c.f. the default 'text' (with inputmode='numeric')\n this.config.legacyInputMode = props.legacyInputMode || null;\n\n // To configure the minimum expiry date to a merchant defined value - this means the card has to be valid until at least this date\n this.config.minimumExpiryDate = props.minimumExpiryDate || null;\n\n this.config.sfLogAtStart = window._b$dl === true;\n\n const sfBundleType: string = this.config.isCreditCardType ? 'card' : props.type;\n\n // Add a hash of the origin to ensure urls are different across domains\n const d = btoa(window.location.origin);\n\n /**\n * Don't allow compat version on Live - it is only for if the merchant wants to *test* with a custom http url.\n * Otherwise, set it passed on the config prop\n */\n const needsJWECompatVersion = this.config.loadingContext.includes('live') ? false : props.forceCompat;\n\n const bundleModifier = !needsJWECompatVersion ? '' : 'Compat';\n\n const bundleType = `${sfBundleType}${bundleModifier}`; // e.g. 'card' or 'cardCompat'\n\n this.config.iframeSrc = `${this.config.loadingContext}securedfields/${props.clientKey}/${SF_VERSION}/securedFields.html?type=${bundleType}&d=${d}`;\n\n // TODO###### FOR QUICK LOCAL TESTING of sf\n if (process.env.NODE_ENV === 'development' && process.env.__SF_ENV__ !== 'build') {\n this.config.iframeSrc = `${process.env.__SF_ENV__}securedFields.${SF_VERSION}.html?type=${sfBundleType}`;\n }\n // TODO######\n}\n"],"names":["handleConfig","props","this","config","cardGroupTypes","getCardGroupTypes","loadingContext","logger","str","charAt","length","isCreditCardType","NON_CREDIT_CARD_TYPE_SECURED_FIELDS","includes","type","iframeUIConfig","autoFocus","showWarnings","trimTrailingSeparator","keypadFix","legacyInputMode","minimumExpiryDate","sfLogAtStart","window","_b$dl","sfBundleType","d","btoa","location","origin","bundleType","forceCompat","iframeSrc","clientKey","SF_VERSION"],"mappings":"4MAWO,SAASA,EAAaC,GAuBIA,IAAAA,EArB7BC,KAAKC,OAAOC,eAAiBC,EAAkBJ,EAAMG,gBAMrD,MAAME,EAAyBL,EAAMK,eAErC,IAAKA,EAED,YADAC,EAAY,2DAKCC,IAAAA,EACjBN,KAAKC,OAAOG,eAA8C,OADzCE,EACqBF,GADVG,OAAOD,EAAIE,OAAS,GACgBJ,EAAiB,GAAGA,KAGpFJ,KAAKC,OAAOQ,kBAAgF,IAA7DC,EAAoCC,SAASZ,EAAMa,MAGlFZ,KAAKC,OAAOY,eAAqC,QAApBd,EAAAA,EAAMc,sBAANd,IAAAA,EAAAA,EAAwB,CAAA,EAGrDC,KAAKC,OAAOa,aAAkC,IAApBf,EAAMe,WAA2C,UAApBf,EAAMe,WAG7Dd,KAAKC,OAAOc,cAAsC,IAAvBhB,EAAMgB,cAAgD,SAAvBhB,EAAMgB,aAGhEf,KAAKC,OAAOe,yBAA0D,IAAhCjB,EAAMiB,uBAAmE,UAAhCjB,EAAMiB,uBAGrFhB,KAAKC,OAAOgB,aAAkC,IAApBlB,EAAMkB,WAA2C,UAApBlB,EAAMkB,WAG7DjB,KAAKC,OAAOiB,gBAAkBnB,EAAMmB,iBAAmB,KAGvDlB,KAAKC,OAAOkB,kBAAoBpB,EAAMoB,mBAAqB,KAE3DnB,KAAKC,OAAOmB,cAAgC,IAAjBC,OAAOC,MAElC,MAAMC,EAAuBvB,KAAKC,OAAOQ,iBAAmB,OAASV,EAAMa,KAGrEY,EAAIC,KAAKJ,OAAOK,SAASC,QAUzBC,EAAa,GAAGL,KAJQvB,KAAKC,OAAOG,eAAeO,SAAS,SAAkBZ,EAAM8B,YAErC,SAAL,KAIhD7B,KAAKC,OAAO6B,UAAY,GAAG9B,KAAKC,OAAOG,+BAA+BL,EAAMgC,aAAaC,6BAAsCJ,OAAgBJ,GAOnJ"}
@@ -1,2 +1,2 @@
1
- import{selectOne as t}from"../../utilities/dom.js";import e from"../utils/userAgent.js";import{on as n,off as s}from"../../../../../../utils/listenerUtils.js";var o={touchendListener:function(t){const e=t.target;if(e instanceof HTMLInputElement||HTMLTextAreaElement&&e instanceof HTMLTextAreaElement){const s=e.value;let o="selectionStart"in(n=e)?n.selectionStart:0,i=!1;o===s.length&&(o-=1,i=!0),e.value=s;try{e.setSelectionRange&&(e.focus(),e.setSelectionRange(o,o),i&&(o+=1,setTimeout(()=>{e.setSelectionRange(o,o)},0)))}catch(t){}}else{if(this.config.keypadFix){const t=this.props.rootNode,e=document.createElement("input");e.style.width="1px",e.style.height="1px",e.style.opacity="0",e.style.fontSize="18px",t.appendChild(e),e.focus(),t.removeChild(e)}}var n;this.destroyTouchendListener(),this.state.registerFieldForIos=!1,this.postMessageToAllIframes({fieldType:"webInternalElement",fieldClick:!0})},touchstartListener:function(t){this.hasGenuineTouchEvents=!0;const e=t.target;if(e instanceof HTMLInputElement||e instanceof HTMLSpanElement){var n,s,o;this.postMessageToAllIframes({fieldType:"webInternalElement",checkoutTouchEvent:!0});const t=null!==(o=e.getAttribute("name"))&&void 0!==o?o:e.getAttribute("data-id");null===(n=(s=this.callbacks).onTouchstartIOS)||void 0===n||n.call(s,{fieldType:"webInternalElement",name:t})}},handleTouchend:function(){const e=t(document,"body");e.style.cursor="pointer",n(e,"touchend",this.touchendListener),this.state.registerFieldForIos=!0},destroyTouchendListener:function(){if(!e.__IS_IOS)return!1;const n=t(document,"body");return n.style.cursor="auto",s(n,"touchend",this.touchendListener),!0},destroyTouchstartListener:function(){return!!e.__IS_IOS&&(s(document,"touchstart",this.touchstartListener),!0)}};export{o as default};
1
+ import{selectOne as t}from"../../utilities/dom.js";import e from"../utils/userAgent.js";import{on as n,off as s}from"../../../../../../utils/listenerUtils.js";var o={touchendListener:function(t){const e=t.target;if(e instanceof HTMLInputElement||HTMLTextAreaElement&&e instanceof HTMLTextAreaElement){const s=e.value;let o="selectionStart"in(n=e)?n.selectionStart:0,i=!1;o===s.length&&(o-=1,i=!0),e.value=s;try{e.setSelectionRange&&(e.focus(),e.setSelectionRange(o,o),i&&(o+=1,setTimeout(()=>{e.setSelectionRange(o,o)},0)))}catch(t){}}else{if(this.config.keypadFix){const t=this.props.rootNode,e=document.createElement("input");e.style.width="1px",e.style.height="1px",e.style.opacity="0",e.style.fontSize="18px",t.appendChild(e),e.focus(),t.removeChild(e)}}var n;this.destroyTouchendListener(),this.state.registerFieldForIos=!1,this.postMessageToAllIframes({fieldType:"webInternalElement",fieldClick:!0})},touchstartListener:function(t){this.hasGenuineTouchEvents=!0;const e=t.target;if(e instanceof HTMLInputElement||e instanceof HTMLSpanElement){var n,s,o;this.postMessageToAllIframes({fieldType:"webInternalElement",checkoutTouchEvent:!0});const t=null!==(n=e.getAttribute("name"))&&void 0!==n?n:e.getAttribute("data-id");null===(s=(o=this.callbacks).onTouchstartIOS)||void 0===s||s.call(o,{fieldType:"webInternalElement",name:t})}},handleTouchend:function(){const e=t(document,"body");e.style.cursor="pointer",n(e,"touchend",this.touchendListener),this.state.registerFieldForIos=!0},destroyTouchendListener:function(){if(!e.__IS_IOS)return!1;const n=t(document,"body");return n.style.cursor="auto",s(n,"touchend",this.touchendListener),!0},destroyTouchstartListener:function(){return!!e.__IS_IOS&&(s(document,"touchstart",this.touchstartListener),!0)}};export{o as default};
2
2
  //# sourceMappingURL=handleIOSTouchEvents.js.map
@@ -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","_this_callbacks_onTouchstartIOS","_this_callbacks","checkoutTouchEvent","name","getAttribute","callbacks","onTouchstartIOS","call","handleTouchend","bodyEl","selectOne","cursor","on","ua","__IS_IOS","off","destroyTouchstartListener"],"mappings":"+JAmJA,IAAAA,EAAe,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,WAAW,KACPb,EAASW,kBAAkBL,EAAUA,IACtC,IAIf,CAAE,MAAOP,GAAI,CACjB,KAAO,CAKH,GAD8Be,KAAKC,OAAOC,UACxB,CAGd,MAAMC,EAAwBH,KAAKI,MAAMD,SACnCE,EAA4BC,SAASC,cAAc,SACzDF,EAAQG,MAAMC,MAAQ,MACtBJ,EAAQG,MAAME,OAAS,MACvBL,EAAQG,MAAMG,QAAU,IACxBN,EAAQG,MAAMI,SAAW,OACzBT,EAASU,YAAYR,GACrBA,EAAQP,QACRK,EAASW,YAAYT,EACzB,CACJ,CA7EgB,IAACZ,EAgFjBO,KAAKe,0BAGLf,KAAKgB,MAAMC,qBAAsB,EAGjCjB,KAAKkB,wBAAwB,CAAEC,UAAW,qBAAsBC,YAAY,GAChF,EA0DIC,mBAnDJ,SAA4BpC,GACxBe,KAAKsB,uBAAwB,EAC7B,MAAMpC,EAAwBD,EAAEE,OAEhC,GAAID,aAAoBE,kBAAoBF,aAAoBqC,gBAAiB,KAI7EC,EAAAC,EADavC,EAFbc,KAAKkB,wBAAwB,CAAEC,UAAW,qBAAsBO,oBAAoB,IAEpF,MAAMC,EAA6B,QAAtBzC,EAAAA,EAAS0C,aAAa,eAAtB1C,IAAAA,EAAAA,EAAiCA,EAAS0C,aAAa,WACtC,QAA9BJ,GAAAC,EAAAzB,KAAK6B,WAAUC,uBAAf,IAAAN,GAAAA,EAAAO,KAAAN,EAAiC,CAAEN,UAAW,qBAAsBQ,QACxE,CACJ,EA0CIK,eA7BJ,WACI,MAAMC,EAA0BC,EAAU5B,SAAU,QACpD2B,EAAOzB,MAAM2B,OAAS,UAEtBC,EAAGH,EAAQ,WAAYjC,KAAKhB,kBAG5BgB,KAAKgB,MAAMC,qBAAsB,CACrC,EAsBIF,wBApBJ,WACI,IAAKsB,EAAGC,SAAU,OAAO,EAEzB,MAAML,EAA0BC,EAAU5B,SAAU,QAGpD,OAFA2B,EAAOzB,MAAM2B,OAAS,OACtBI,EAAIN,EAAQ,WAAYjC,KAAKhB,mBACtB,CACX,EAcIwD,0BAZJ,WACI,QAAKH,EAAGC,WAERC,EAAIjC,SAAU,aAAcN,KAAKqB,qBAC1B,EACX"}
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","_this_callbacks_onTouchstartIOS","_this_callbacks","checkoutTouchEvent","name","getAttribute","callbacks","onTouchstartIOS","call","handleTouchend","bodyEl","selectOne","cursor","on","ua","__IS_IOS","off","destroyTouchstartListener"],"mappings":"+JAmJA,IAAAA,EAAe,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,WAAW,KACPb,EAASW,kBAAkBL,EAAUA,IACtC,IAIf,CAAE,MAAOP,GAAI,CACjB,KAAO,CAKH,GAD8Be,KAAKC,OAAOC,UACxB,CAGd,MAAMC,EAAwBH,KAAKI,MAAMD,SACnCE,EAA4BC,SAASC,cAAc,SACzDF,EAAQG,MAAMC,MAAQ,MACtBJ,EAAQG,MAAME,OAAS,MACvBL,EAAQG,MAAMG,QAAU,IACxBN,EAAQG,MAAMI,SAAW,OACzBT,EAASU,YAAYR,GACrBA,EAAQP,QACRK,EAASW,YAAYT,EACzB,CACJ,CA7EgB,IAACZ,EAgFjBO,KAAKe,0BAGLf,KAAKgB,MAAMC,qBAAsB,EAGjCjB,KAAKkB,wBAAwB,CAAEC,UAAW,qBAAsBC,YAAY,GAChF,EA0DIC,mBAnDJ,SAA4BpC,GACxBe,KAAKsB,uBAAwB,EAC7B,MAAMpC,EAAwBD,EAAEE,OAEhC,GAAID,aAAoBE,kBAAoBF,aAAoBqC,gBAAiB,CAGhErC,IAAAA,EACbsC,EAAAC,EAHAzB,KAAKkB,wBAAwB,CAAEC,UAAW,qBAAsBO,oBAAoB,IAEpF,MAAMC,EAA6B,QAAtBzC,EAAAA,EAAS0C,aAAa,eAAtB1C,IAAAA,EAAAA,EAAiCA,EAAS0C,aAAa,WACtC,QAA9BJ,GAAAC,EAAAzB,KAAK6B,WAAUC,uBAAf,IAAAN,GAAAA,EAAAO,KAAAN,EAAiC,CAAEN,UAAW,qBAAsBQ,QACxE,CACJ,EA0CIK,eA7BJ,WACI,MAAMC,EAA0BC,EAAU5B,SAAU,QACpD2B,EAAOzB,MAAM2B,OAAS,UAEtBC,EAAGH,EAAQ,WAAYjC,KAAKhB,kBAG5BgB,KAAKgB,MAAMC,qBAAsB,CACrC,EAsBIF,wBApBJ,WACI,IAAKsB,EAAGC,SAAU,OAAO,EAEzB,MAAML,EAA0BC,EAAU5B,SAAU,QAGpD,OAFA2B,EAAOzB,MAAM2B,OAAS,OACtBI,EAAIN,EAAQ,WAAYjC,KAAKhB,mBACtB,CACX,EAcIwD,0BAZJ,WACI,QAAKH,EAAGC,WAERC,EAAIjC,SAAU,aAAcN,KAAKqB,qBAC1B,EACX"}
@@ -1 +1 @@
1
- {"version":3,"file":"processPlaceholders.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/securedField/utils/processPlaceholders.ts"],"sourcesContent":["import { SFPlaceholdersObject } from '../../types';\nimport { Placeholders } from '../../../SFP/types';\nimport {\n ENCRYPTED_SECURITY_CODE,\n ENCRYPTED_SECURITY_CODE_3_DIGITS,\n ENCRYPTED_SECURITY_CODE_4_DIGITS,\n GIFT_CARD,\n SF_FIELDS_MAP\n} from '../../constants';\nimport { Placeholders as GiftcardPlaceholders } from '../../../../../Giftcard/components/types';\nimport { CardPlaceholders } from '../../../../../Card/types';\n\n/**\n * Create placeholders with a value from merchant's configuration\n *\n * Based on txVariant & fieldType, maps the entries in the passed placeholders object to create a field specific placeholder object\n */\nexport function processPlaceholders(txVariant: string, fieldType: string, placeholders: Placeholders): SFPlaceholdersObject {\n switch (txVariant) {\n case GIFT_CARD:\n return { [fieldType]: (placeholders as GiftcardPlaceholders)[SF_FIELDS_MAP[fieldType]] ?? '' };\n\n default:\n switch (fieldType) {\n case ENCRYPTED_SECURITY_CODE:\n return {\n [ENCRYPTED_SECURITY_CODE_3_DIGITS]: (placeholders as CardPlaceholders).securityCodeThreeDigits ?? '',\n [ENCRYPTED_SECURITY_CODE_4_DIGITS]: (placeholders as CardPlaceholders).securityCodeFourDigits ?? ''\n };\n\n default:\n return { [fieldType]: (placeholders as CardPlaceholders)[SF_FIELDS_MAP[fieldType]] ?? '' };\n }\n }\n}\n"],"names":["processPlaceholders","txVariant","fieldType","placeholders","_placeholders_SF_FIELDS_MAP_fieldType","_placeholders_securityCodeThreeDigits","_placeholders_securityCodeFourDigits","_placeholders_SF_FIELDS_MAP_fieldType1","GIFT_CARD","SF_FIELDS_MAP","ENCRYPTED_SECURITY_CODE","ENCRYPTED_SECURITY_CODE_3_DIGITS","securityCodeThreeDigits","ENCRYPTED_SECURITY_CODE_4_DIGITS","securityCodeFourDigits"],"mappings":"2KAiBO,SAASA,EAAoBC,EAAmBC,EAAmBC,GAGxC,IAAAC,EAM0BC,EACAC,EAIlBC,EAbtC,OAAQN,IACCO,EACM,CAAEN,CAACA,GAA4E,QAAhEE,EAAAD,EAAuCM,EAAcP,eAArDE,EAAAA,EAAoE,IAGlFF,IACCQ,EACM,CACHC,CAACA,GAA6F,QAA1DN,EAAAF,EAAmCS,+BAAnC,IAAAP,EAAAA,EAA8D,GAClGQ,CAACA,GAA4F,QAAzDP,EAAAH,EAAmCW,8BAAnC,IAAAR,EAAAA,EAA6D,IAI9F,CAAEJ,CAACA,GAAwE,QAA5DK,EAAAJ,EAAmCM,EAAcP,eAAjDK,EAAAA,EAAgE,GAG1G"}
1
+ {"version":3,"file":"processPlaceholders.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/securedField/utils/processPlaceholders.ts"],"sourcesContent":["import { SFPlaceholdersObject } from '../../types';\nimport { Placeholders } from '../../../SFP/types';\nimport {\n ENCRYPTED_SECURITY_CODE,\n ENCRYPTED_SECURITY_CODE_3_DIGITS,\n ENCRYPTED_SECURITY_CODE_4_DIGITS,\n GIFT_CARD,\n SF_FIELDS_MAP\n} from '../../constants';\nimport { Placeholders as GiftcardPlaceholders } from '../../../../../Giftcard/components/types';\nimport { CardPlaceholders } from '../../../../../Card/types';\n\n/**\n * Create placeholders with a value from merchant's configuration\n *\n * Based on txVariant & fieldType, maps the entries in the passed placeholders object to create a field specific placeholder object\n */\nexport function processPlaceholders(txVariant: string, fieldType: string, placeholders: Placeholders): SFPlaceholdersObject {\n switch (txVariant) {\n case GIFT_CARD:\n return { [fieldType]: (placeholders as GiftcardPlaceholders)[SF_FIELDS_MAP[fieldType]] ?? '' };\n\n default:\n switch (fieldType) {\n case ENCRYPTED_SECURITY_CODE:\n return {\n [ENCRYPTED_SECURITY_CODE_3_DIGITS]: (placeholders as CardPlaceholders).securityCodeThreeDigits ?? '',\n [ENCRYPTED_SECURITY_CODE_4_DIGITS]: (placeholders as CardPlaceholders).securityCodeFourDigits ?? ''\n };\n\n default:\n return { [fieldType]: (placeholders as CardPlaceholders)[SF_FIELDS_MAP[fieldType]] ?? '' };\n }\n }\n}\n"],"names":["processPlaceholders","txVariant","fieldType","placeholders","_placeholders_SF_FIELDS_MAP_fieldType","_placeholders_securityCodeThreeDigits","_placeholders_securityCodeFourDigits","_placeholders_SF_FIELDS_MAP_fieldType1","GIFT_CARD","SF_FIELDS_MAP","ENCRYPTED_SECURITY_CODE","ENCRYPTED_SECURITY_CODE_3_DIGITS","securityCodeThreeDigits","ENCRYPTED_SECURITY_CODE_4_DIGITS","securityCodeFourDigits"],"mappings":"2KAiBO,SAASA,EAAoBC,EAAmBC,EAAmBC,GAGxC,IAAAC,EAM0BC,EACAC,EAIlBC,EAbtC,OAAQN,IACCO,EACM,CAAEN,CAACA,GAA4E,QAAhEE,EAACD,EAAsCM,EAAcP,WAArD,IAAAE,EAAAA,EAAoE,IAGlFF,IACCQ,EACM,CACHC,CAACA,GAA6F,QAA1DN,EAACF,EAAkCS,mCAAnCP,EAAAA,EAA8D,GAClGQ,CAACA,GAA4F,QAAzDP,EAACH,EAAkCW,kCAAnCR,EAAAA,EAA6D,IAI9F,CAAEJ,CAACA,GAAwE,QAA5DK,EAACJ,EAAkCM,EAAcP,WAAjD,IAAAK,EAAAA,EAAgE,GAG1G"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import t from"../../../_virtual/index.js";import{stopPropagationForActionKeys as n}from"../Button/stopPropagationForActionKeys.js";function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r({classNameModifiers:r=[],selectedValue:a,disabled:c=!1,options:l,onChange:s}){return l&&0!==l.length?e("div",{className:t("adyen-checkout__segmented-control",{"adyen-checkout__segmented-control--disabled":c},...r.map(e=>`adyen-checkout__segmented-control--${e}`)),role:"group"},l.map(({label:r,value:l,controls:i,htmlProps:u})=>e("button",function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){o(e,t,n[t])})}return e}({disabled:c,key:l,onClick:e=>s(l,e),onKeyPress:n,onKeyDown:n,className:t("adyen-checkout__segmented-control-segment",{"adyen-checkout__segmented-control-segment--selected":a===l}),"aria-controls":i,"aria-expanded":a===l,type:"button"},u),r))):null}export{r as default};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import t from"../../../_virtual/index.js";import{stopPropagationForActionKeys as o}from"../Button/stopPropagationForActionKeys.js";function n(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}const r=({classNameModifiers:r=[],selectedValue:c,disabled:a=!1,options:l,onChange:s})=>l&&0!==l.length?e("div",{className:t("adyen-checkout__segmented-control",{"adyen-checkout__segmented-control--disabled":a},...r.map(e=>`adyen-checkout__segmented-control--${e}`)),role:"group"},l.map(({label:r,value:l,controls:i,htmlProps:u})=>e("button",function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),r.forEach(function(t){n(e,t,o[t])})}return e}({disabled:a,key:l,onClick:e=>s(l,e),onKeyPress:o,onKeyDown:o,className:t("adyen-checkout__segmented-control-segment",{"adyen-checkout__segmented-control-segment--selected":c===l}),"aria-controls":i,"aria-expanded":c===l,type:"button"},u),r))):null;export{r as SegmentedControl};
2
2
  //# sourceMappingURL=SegmentedControl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentedControl.js","sources":["../../../../../src/components/internal/SegmentedControl/SegmentedControl.tsx"],"sourcesContent":["import { h } from 'preact';\nimport cx from 'classnames';\nimport './SegmentedControl.scss';\nimport { stopPropagationForActionKeys } from '../Button/stopPropagationForActionKeys';\n\nexport interface SegmentedControlOption<T> {\n label: string;\n value: T;\n id: string;\n controls: string;\n htmlProps?: {};\n}\n\nexport type SegmentedControlOptions<T> = Array<SegmentedControlOption<T>>;\n\nexport interface SegmentedControlProps<T> {\n classNameModifiers?: string[];\n selectedValue: T;\n disabled?: boolean;\n options: SegmentedControlOptions<T>;\n onChange(value: T, event: MouseEvent): void;\n}\n\n/**\n *\n * example:\n * <SegmentedControl\n * onChange={(value) = setMode(value)}\n * selectedValue={mode}\n * disabled={status === 'loading'}\n * classNameModifiers={['css-class']}\n * options={segmentedControlOptions}\n * />\n *\n * @param classNameModifiers\n * @param selectedValue\n * @param disabled\n * @param options\n * @param onChange\n * @constructor\n */\nfunction SegmentedControl<T>({ classNameModifiers = [], selectedValue, disabled = false, options, onChange }: SegmentedControlProps<T>) {\n if (!options || options.length === 0) {\n return null;\n }\n\n return (\n <div\n className={cx(\n 'adyen-checkout__segmented-control',\n { 'adyen-checkout__segmented-control--disabled': disabled },\n ...classNameModifiers.map(modifier => `adyen-checkout__segmented-control--${modifier}`)\n )}\n role=\"group\"\n >\n {options.map(({ label, value, controls, htmlProps }: SegmentedControlOption<T>) => (\n <button\n disabled={disabled}\n key={value}\n onClick={(event: MouseEvent) => onChange(value, event)}\n // Workaround: See ADR-0001-uielement-keyboard-event-propagation-workaround\n onKeyPress={stopPropagationForActionKeys}\n onKeyDown={stopPropagationForActionKeys}\n className={cx('adyen-checkout__segmented-control-segment', {\n 'adyen-checkout__segmented-control-segment--selected': selectedValue === value\n })}\n aria-controls={controls}\n aria-expanded={selectedValue === value}\n type=\"button\"\n {...htmlProps}\n >\n {label}\n </button>\n ))}\n </div>\n );\n}\n\nexport default SegmentedControl;\n"],"names":["SegmentedControl","classNameModifiers","selectedValue","disabled","options","onChange","length","h","div","className","cx","map","modifier","role","label","value","controls","htmlProps","button","key","onClick","event","onKeyPress","stopPropagationForActionKeys","onKeyDown","aria-controls","aria-expanded","type"],"mappings":"mUAyCA,SAASA,GAAoBC,mBAAEA,EAAqB,GAAEC,cAAEA,EAAaC,SAAEA,GAAW,EAAKC,QAAEA,EAAOC,SAAEA,IAC9F,OAAKD,GAA8B,IAAnBA,EAAQE,OAKpBC,EAACC,MAAAA,CACGC,UAAWC,EACP,oCACA,CAAE,8CAA+CP,MAC9CF,EAAmBU,IAAIC,GAAY,sCAAsCA,MAEhFC,KAAK,SAEJT,EAAQO,IAAI,EAAGG,QAAOC,QAAOC,WAAUC,eACpCV,EAACW,2UAAAA,CAAAA,CACGf,SAAUA,EACVgB,IAAKJ,EACLK,QAAUC,GAAsBhB,EAASU,EAAOM,GAEhDC,WAAYC,EACZC,UAAWD,EACXd,UAAWC,EAAG,4CAA6C,CACvD,sDAAuDR,IAAkBa,IAE7EU,gBAAeT,EACfU,gBAAexB,IAAkBa,EACjCY,KAAK,UACDV,GAEHH,KA5BN,IAiCf"}
1
+ {"version":3,"file":"SegmentedControl.js","sources":["../../../../../src/components/internal/SegmentedControl/SegmentedControl.tsx"],"sourcesContent":["import { h } from 'preact';\nimport cx from 'classnames';\nimport './SegmentedControl.scss';\nimport { stopPropagationForActionKeys } from '../Button/stopPropagationForActionKeys';\n\nexport interface SegmentedControlOption<T> {\n label: string;\n value: T;\n id: string;\n controls: string;\n htmlProps?: {};\n}\n\nexport type SegmentedControlOptions<T> = Array<SegmentedControlOption<T>>;\n\nexport interface SegmentedControlProps<T> {\n classNameModifiers?: string[];\n selectedValue: T;\n disabled?: boolean;\n options: SegmentedControlOptions<T>;\n onChange(value: T, event: MouseEvent): void;\n}\n\n/**\n *\n * example:\n * <SegmentedControl\n * onChange={(value) = setMode(value)}\n * selectedValue={mode}\n * disabled={status === 'loading'}\n * classNameModifiers={['css-class']}\n * options={segmentedControlOptions}\n * />\n *\n * @param classNameModifiers\n * @param selectedValue\n * @param disabled\n * @param options\n * @param onChange\n * @constructor\n */\nexport const SegmentedControl = <T,>({ classNameModifiers = [], selectedValue, disabled = false, options, onChange }: SegmentedControlProps<T>) => {\n if (!options || options.length === 0) {\n return null;\n }\n\n return (\n <div\n className={cx(\n 'adyen-checkout__segmented-control',\n { 'adyen-checkout__segmented-control--disabled': disabled },\n ...classNameModifiers.map(modifier => `adyen-checkout__segmented-control--${modifier}`)\n )}\n role=\"group\"\n >\n {options.map(({ label, value, controls, htmlProps }: SegmentedControlOption<T>) => (\n <button\n disabled={disabled}\n key={value}\n onClick={(event: MouseEvent) => onChange(value, event)}\n // Workaround: See ADR-0001-uielement-keyboard-event-propagation-workaround\n onKeyPress={stopPropagationForActionKeys}\n onKeyDown={stopPropagationForActionKeys}\n className={cx('adyen-checkout__segmented-control-segment', {\n 'adyen-checkout__segmented-control-segment--selected': selectedValue === value\n })}\n aria-controls={controls}\n aria-expanded={selectedValue === value}\n type=\"button\"\n {...htmlProps}\n >\n {label}\n </button>\n ))}\n </div>\n );\n};\n"],"names":["SegmentedControl","classNameModifiers","selectedValue","disabled","options","onChange","length","h","div","className","cx","map","modifier","role","label","value","controls","htmlProps","button","key","onClick","event","onKeyPress","stopPropagationForActionKeys","onKeyDown","aria-controls","aria-expanded","type"],"mappings":"mUAyCO,MAAMA,EAAmB,EAAOC,qBAAqB,GAAIC,gBAAeC,YAAW,EAAOC,UAASC,cACjGD,GAA8B,IAAnBA,EAAQE,OAKpBC,EAACC,MAAAA,CACGC,UAAWC,EACP,oCACA,CAAE,8CAA+CP,MAC9CF,EAAmBU,IAAIC,GAAY,sCAAsCA,MAEhFC,KAAK,SAEJT,EAAQO,IAAI,EAAGG,QAAOC,QAAOC,WAAUC,eACpCV,EAACW,2UAAAA,CAAAA,CACGf,SAAUA,EACVgB,IAAKJ,EACLK,QAAUC,GAAsBhB,EAASU,EAAOM,GAEhDC,WAAYC,EACZC,UAAWD,EACXd,UAAWC,EAAG,4CAA6C,CACvD,sDAAuDR,IAAkBa,IAE7EU,gBAAeT,EACfU,gBAAexB,IAAkBa,EACjCY,KAAK,UACDV,GAEHH,KA5BN"}
@@ -0,0 +1,2 @@
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";const a=({id:a,ariaLabelledBy:r,className:l,children:i})=>e("div",{id:a,"aria-labelledby":r,className:l,role:"region"},i);export{a as SegmentedControlRegion};
2
+ //# sourceMappingURL=SegmentedControlRegion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SegmentedControlRegion.js","sources":["../../../../../src/components/internal/SegmentedControl/SegmentedControlRegion.tsx"],"sourcesContent":["import { h } from 'preact';\n\nexport interface SegmentedControlRegionProps {\n id: string;\n ariaLabelledBy: string;\n className?: string;\n children: h.JSX.Element | h.JSX.Element[];\n}\n\nexport const SegmentedControlRegion = ({ id, ariaLabelledBy, className, children }: SegmentedControlRegionProps) => {\n return (\n <div id={id} aria-labelledby={ariaLabelledBy} className={className} role=\"region\">\n {children}\n </div>\n );\n};\n"],"names":["SegmentedControlRegion","id","ariaLabelledBy","className","children","h","div","aria-labelledby","role"],"mappings":"wEASO,MAAMA,EAAyB,EAAGC,KAAIC,iBAAgBC,YAAWC,cAEhEC,EAACC,MAAAA,CAAIL,GAAIA,EAAIM,kBAAiBL,EAAgBC,UAAWA,EAAWK,KAAK,UACpEJ"}
@@ -1,2 +1,2 @@
1
- import{useState as e,useEffect as t}from"../../../external/preact/hooks/dist/hooks.js";import{createElement as r}from"../../../external/preact/dist/preact.js";import{useCoreContext as o}from"../../../core/Context/CoreProvider.js";import s from"../FormFields/Checkbox/Checkbox.js";import a from"../../../_virtual/index.js";function n(e,t){if(null==e)return{};var r,o,s=function(e,t){if(null==e)return{};var r,o,s={},a=Object.keys(e);for(o=0;o<a.length;o++)r=a[o],t.indexOf(r)>=0||(s[r]=e[r]);return s}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)r=a[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(s[r]=e[r])}return s}function l(l){var{storeDetails:i=!1,disabled:c=!1,className:m=""}=l,d=n(l,["storeDetails","disabled","className"]);const{i18n:f}=o(),[u,p]=e(i);return t(()=>{d.onChange(u)},[u]),r("div",{className:a("adyen-checkout__store-details",m)},r(s,{onChange:e=>{p(e.target.checked)},disabled:c,label:f.get("storeDetails"),name:"storeDetails"}))}export{l as default};
1
+ import{useState as e,useEffect as t}from"../../../external/preact/hooks/dist/hooks.js";import{createElement as r}from"../../../external/preact/dist/preact.js";import{useCoreContext as o}from"../../../core/Context/CoreProvider.js";import s from"../FormFields/Checkbox/Checkbox.js";import n from"../../../_virtual/index.js";function a(e,t){if(null==e)return{};var r,o,s,n={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(r=Reflect.ownKeys(e),s=0;s<r.length;s++)o=r[s],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o]);return n}if(n=function(e,t){if(null==e)return{};var r,o,s={},n=Object.getOwnPropertyNames(e);for(o=0;o<n.length;o++)r=n[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(s[r]=e[r]);return s}(e,t),Object.getOwnPropertySymbols)for(r=Object.getOwnPropertySymbols(e),s=0;s<r.length;s++)o=r[s],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o]);return n}function l(l){let{storeDetails:i=!1,disabled:c=!1,className:f=""}=l,p=a(l,["storeDetails","disabled","className"]);const{i18n:m}=o(),[d,u]=e(i);return t(()=>{p.onChange(d)},[d]),r("div",{className:n("adyen-checkout__store-details",f)},r(s,{onChange:e=>{u(e.target.checked)},disabled:c,label:m.get("storeDetails"),name:"storeDetails"}))}export{l as default};
2
2
  //# sourceMappingURL=StoreDetails.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StoreDetails.js","sources":["../../../../../src/components/internal/StoreDetails/StoreDetails.tsx"],"sourcesContent":["import { useState, useEffect } from 'preact/hooks';\nimport { h } from 'preact';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport Checkbox from '../FormFields/Checkbox';\nimport cx from 'classnames';\n\nimport './StoreDetails.scss';\n\ninterface StoreDetailsProps {\n storeDetails?: boolean;\n onChange: (value: boolean) => void;\n disabled?: boolean;\n className?: string;\n}\n\n/**\n * \"Store details\" generic checkbox\n */\nfunction StoreDetails({ storeDetails = false, disabled = false, className = '', ...props }: StoreDetailsProps) {\n const { i18n } = useCoreContext();\n const [value, setValue] = useState(storeDetails);\n\n const onChange = e => {\n setValue(e.target.checked);\n };\n\n useEffect(() => {\n props.onChange(value);\n }, [value]);\n\n return (\n <div className={cx('adyen-checkout__store-details', className)}>\n <Checkbox onChange={onChange} disabled={disabled} label={i18n.get('storeDetails')} name={'storeDetails'} />\n </div>\n );\n}\n\nexport default StoreDetails;\n"],"names":["StoreDetails","_param","storeDetails","disabled","className","props","i18n","useCoreContext","value","setValue","useState","useEffect","onChange","h","div","cx","Checkbox","e","target","checked","label","get","name"],"mappings":"srBAkBA,SAASA,EAAaC,OAAAC,aAAEA,GAAe,EAAKC,SAAEA,GAAW,EAAKC,UAAEA,EAAY,IAAtDH,EAA6DI,EAAAA,EAA7DJ,EAAA,CAAEC,eAAsBC,WAAkBC,cAC5D,MAAME,KAAEA,GAASC,KACVC,EAAOC,GAAYC,EAASR,GAUnC,OAJAS,EAAU,KACNN,EAAMO,SAASJ,IAChB,CAACA,IAGAK,EAACC,MAAAA,CAAIV,UAAWW,EAAG,gCAAiCX,IAChDS,EAACG,EAAAA,CAASJ,SAVDK,IACbR,EAASQ,EAAEC,OAAOC,UASgBhB,SAAUA,EAAUiB,MAAOd,EAAKe,IAAI,gBAAiBC,KAAM,iBAGrG"}
1
+ {"version":3,"file":"StoreDetails.js","sources":["../../../../../src/components/internal/StoreDetails/StoreDetails.tsx"],"sourcesContent":["import { useState, useEffect } from 'preact/hooks';\nimport { h } from 'preact';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport Checkbox from '../FormFields/Checkbox';\nimport cx from 'classnames';\n\nimport './StoreDetails.scss';\n\ninterface StoreDetailsProps {\n storeDetails?: boolean;\n onChange: (value: boolean) => void;\n disabled?: boolean;\n className?: string;\n}\n\n/**\n * \"Store details\" generic checkbox\n */\nfunction StoreDetails({ storeDetails = false, disabled = false, className = '', ...props }: StoreDetailsProps) {\n const { i18n } = useCoreContext();\n const [value, setValue] = useState(storeDetails);\n\n const onChange = e => {\n setValue(e.target.checked);\n };\n\n useEffect(() => {\n props.onChange(value);\n }, [value]);\n\n return (\n <div className={cx('adyen-checkout__store-details', className)}>\n <Checkbox onChange={onChange} disabled={disabled} label={i18n.get('storeDetails')} name={'storeDetails'} />\n </div>\n );\n}\n\nexport default StoreDetails;\n"],"names":["StoreDetails","_0","storeDetails","disabled","className","props","i18n","useCoreContext","value","setValue","useState","useEffect","onChange","h","div","cx","Checkbox","e","target","checked","label","get","name"],"mappings":"m7BAkBA,SAASA,EAAaC,OAAAC,aAAEA,GAAe,EAAKC,SAAEA,GAAW,EAAKC,UAAEA,EAAY,IAAiCH,EAA1BI,EAAAA,EAAAA,EAAAA,yCAC/E,MAAMC,KAAEA,GAASC,KACVC,EAAOC,GAAYC,EAASR,GAUnC,OAJAS,EAAU,KACNN,EAAMO,SAASJ,IAChB,CAACA,IAGAK,EAACC,MAAAA,CAAIV,UAAWW,EAAG,gCAAiCX,IAChDS,EAACG,EAAAA,CAASJ,SAVDK,IACbR,EAASQ,EAAEC,OAAOC,UASgBhB,SAAUA,EAAUiB,MAAOd,EAAKe,IAAI,gBAAiBC,KAAM,iBAGrG"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../external/preact/dist/preact.js";import t,{NETWORK_ERROR as s}from"../../../core/Errors/AdyenCheckoutError.js";import{hasOwnProperty as n}from"../../../utils/hasOwnProperty.js";import i from"../BaseElement/BaseElement.js";import o from"../PayButton/PayButton.js";import{assertIsDropin as r,getRegulatoryDefaults as a,sanitizeResponse as l,verifyPaymentDidNotFail as h,cleanupFinalResult as d}from"./utils.js";import{AnalyticsErrorEvent as c,ErrorEventType as p}from"../../../core/Analytics/events/AnalyticsErrorEvent.js";import{AnalyticsInfoEvent as m,InfoEventType as u}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";import{AnalyticsLogEvent as y,LogEventType as f}from"../../../core/Analytics/events/AnalyticsLogEvent.js";import v from"../../../core/Errors/CancelError.js";import{CoreProvider as b}from"../../../core/Context/CoreProvider.js";import R from"../../../core/Errors/SRPanelProvider.js";function P(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function g(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},n=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(s).filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),n.forEach(function(t){P(e,t,s[t])})}return e}function E(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t.push.apply(t,s)}return t}(Object(t)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(t,s))}),e}class A extends i{createBeforeRenderHook(e){const t=this.render;this.render=(...s)=>(this.beforeRender(e),t.apply(this,s))}beforeRender(e){if(null==e?void 0:e.originalAction)return;const t=new m(g({type:u.rendered,component:this.type,configData:E(g({},e),{showPayButton:this.props.showPayButton})},(null==e?void 0:e.oneClick)&&{isStoredPaymentMethod:!0}));this.analytics.sendAnalytics(t)}reportIntegrationFlavor(){this.analytics.sendFlavor("components")}get analytics(){return this.core.modules.analytics}get srPanel(){return this.core.modules.srPanel}getPaymentMethodConfigFromResponse(e){return(null==e?void 0:e.storedPaymentMethodId)?this.getStoredPaymentMethodDetails(e.storedPaymentMethodId):this.getPaymentMethodFromPaymentMethodsResponse(null==e?void 0:e.type,null==e?void 0:e.paymentMethodId)}buildElementProps(e){const t=g({showPayButton:!0},this.core.getCorePropsForComponent(),this.getPaymentMethodConfigFromResponse(e),e),s=r(this);this.props=this.formatProps(g({},this.constructor.defaultProps,a(this.core.options.countryCode,s),t))}getStoredPaymentMethodDetails(e){return this.core.paymentMethodsResponse.findStoredPaymentMethod(e)}getPaymentMethodFromPaymentMethodsResponse(e,t){var s;return t?this.core.paymentMethodsResponse.findById(t):null===(s=this.core.paymentMethodsResponse)||void 0===s?void 0:s.find(e||this.constructor.type)}storeElementRefOnCore(e){(null==e?void 0:e.isDropin)||this.core.storeElementReference(this)}isAvailable(){return Promise.resolve()}setState(e){this.state=g({},this.state,e),this.onChange()}showValidation(){return this.componentRef&&this.componentRef.showValidation&&this.componentRef.showValidation(),this}setElementStatus(e,t){var s;return null===(s=this.elementRef)||void 0===s||s.setStatus(e,t),this}setStatus(e,t){var s;return(null===(s=this.componentRef)||void 0===s?void 0:s.setStatus)&&this.componentRef.setStatus(e,t),this}onChange(){var e,t;null===(e=(t=this.props).onChange)||void 0===e||e.call(t,{data:this.data,isValid:this.isValid,errors:this.state.errors,valid:this.state.valid},this.elementRef)}submitAnalytics(e){this.analytics.sendAnalytics(e)}submit(){this.isValid?this.makePaymentsCall().then(l).then(h).then(this.handleResponse).catch(e=>{e instanceof v?this.setElementStatus("ready"):this.handleFailedResult(e)}):this.showValidation()}makePaymentsCall(){if(this.setElementStatus("loading"),this.props.onSubmit)return this.submitUsingAdvancedFlow();if(this.core.session){return(this.props.beforeSubmit?new Promise((e,t)=>this.props.beforeSubmit(this.data,this.elementRef,{resolve:e,reject:()=>t(new v("beforeSubmitRejected"))})):Promise.resolve(this.data)).then(this.submitUsingSessionsFlow)}this.handleError(new t("IMPLEMENTATION_ERROR",'It can not perform /payments call. Callback "onSubmit" is missing or Checkout session is not available'))}async submitUsingAdvancedFlow(){const e=new y({component:this.type,type:f.submit,message:"Shopper clicked pay"});return this.submitAnalytics(e),new Promise((e,t)=>{this.props.onSubmit({data:this.data,isValid:this.isValid},this.elementRef,{resolve:e,reject:t})})}async submitUsingSessionsFlow(e){const s=new y({component:this.type,type:f.submit,message:"Shopper clicked pay"});this.submitAnalytics(s);try{return await this.core.session.submitPayment(e)}catch(e){return e instanceof t?this.handleError(e):this.handleError(new t("ERROR","Error when making /payments call",{cause:e})),Promise.reject(e)}}onComplete(e){this.handleAdditionalDetails(e)}handleAdditionalDetails(e){this.makeAdditionalDetailsCall(e).then(l).then(h).then(this.handleResponse).catch(this.handleFailedResult)}makeAdditionalDetailsCall(e){return this.props.onAdditionalDetails?new Promise((t,s)=>{this.props.onAdditionalDetails(e,this.elementRef,{resolve:t,reject:s})}):this.core.session?this.submitAdditionalDetailsUsingSessionsFlow(e.data):void this.handleError(new t("IMPLEMENTATION_ERROR",'It can not perform /payments/details call. Callback "onAdditionalDetails" is missing or Checkout session is not available'))}async submitAdditionalDetailsUsingSessionsFlow(e){try{return await this.core.session.submitDetails(e)}catch(e){return e instanceof t?this.handleError(e):this.handleError(new t("ERROR","Error when making /details call",{cause:e})),Promise.reject(e)}}handleAction(e,t={}){if(!e||!e.type){if(n(e,"action")&&n(e,"resultCode"))throw new Error('handleAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('handleAction::Invalid Action - the passed action object does not have a "type" property')}const s=this.core.createFromAction(e,g({},this.elementRef.props,t));return s?(this.unmount(),s.mount(this._node)):null}onActionHandled(e){var t,s;null===(s=this.props)||void 0===s||null===(t=s.onActionHandled)||void 0===t||t.call(s,g({originalAction:this.props.originalAction},e))}handleResponse(e){var t,s;e.action?this.elementRef.handleAction(e.action):(null===(s=e.order)||void 0===s||null===(t=s.remainingAmount)||void 0===t?void 0:t.value)>0?this.handleOrder(e):this.handleSuccessResult(e)}handleKeyPress(e){var t;"Enter"!==e.key&&"Enter"!==e.code||(e.preventDefault(),this.onEnterKeyPressed(null===(t=document)||void 0===t?void 0:t.activeElement,this))}onEnterKeyPressed(e,t){this.props.onEnterKeyPressed?this.props.onEnterKeyPressed(e,t):(e.blur(),this.submit())}updateParent(e={}){return this.elementRef.core.update(e)}get isValid(){return!1}get icon(){const e=this.props.paymentMethodType||this.type;var t;return null!==(t=this.props.icon)&&void 0!==t?t:this.resources.getImage()(e)}get displayName(){var e,t;const s=null===(t=this.core.paymentMethodsResponse)||void 0===t||null===(e=t.paymentMethods)||void 0===e?void 0:e.find(e=>e.type===this.type);return this.props.name||(null==s?void 0:s.name)||this.type}get accessibleName(){return this.displayName}get additionalInfo(){return null}get type(){return this.props.type||this.constructor.type}async handleAdvanceFlowPaymentMethodsUpdate(e,s){return new Promise((t,s)=>{if(!this.props.onPaymentMethodsRequest)return t();this.props.onPaymentMethodsRequest(E(g({},e&&{order:{orderData:e.orderData,pspReference:e.pspReference}}),{locale:this.core.options.locale}),{resolve:t,reject:s})}).catch(e=>{this.handleError(new t("IMPLEMENTATION_ERROR","Something failed during payment methods update or onPaymentMethodsRequest was not implemented",{cause:e}))}).then(t=>this.core.update(E(g({},t&&{paymentMethodsResponse:t}),{order:e,amount:e?e.remainingAmount:s})))}render(){return e(b,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources,analytics:this.analytics},e(R,{srPanel:this.srPanel},this.componentToRender()))}constructor(t,n){super(t,n),P(this,"componentRef",void 0),P(this,"resources",void 0),P(this,"elementRef",void 0),P(this,"handleError",e=>{if(this.setElementStatus("ready"),e.name===s&&e.options.code){const t=new c({component:this.type,errorType:p.apiError,code:e.options.code});this.submitAnalytics(t)}this.props.onError&&this.props.onError(e,this.elementRef)}),P(this,"handleOrder",e=>{const{order:t}=e;(this.core.session?this.core.update({order:t}):this.handleAdvanceFlowPaymentMethodsUpdate(t)).then(()=>{var e,s;null===(e=(s=this.props).onOrderUpdated)||void 0===e||e.call(s,{order:t})})}),P(this,"handleFailedResult",e=>{var t,s;r(this.elementRef)&&this.elementRef.displayFinalAnimation("error"),d(e),null===(t=(s=this.props).onPaymentFailed)||void 0===t||t.call(s,e,this.elementRef)}),P(this,"handleSuccessResult",e=>{var t,s;r(this.elementRef)&&this.elementRef.displayFinalAnimation("success"),d(e),null===(t=(s=this.props).onPaymentCompleted)||void 0===t||t.call(s,e,this.elementRef)}),P(this,"setComponentRef",e=>{this.componentRef=e}),P(this,"payButton",t=>e(o,E(g({},t),{amount:this.props.amount,secondaryAmount:this.props.secondaryAmount,onClick:this.submit}))),this.core.register(this.constructor),this.submit=this.submit.bind(this),this.setState=this.setState.bind(this),this.onComplete=this.onComplete.bind(this),this.handleAction=this.handleAction.bind(this),this.handleOrder=this.handleOrder.bind(this),this.handleAdditionalDetails=this.handleAdditionalDetails.bind(this),this.handleResponse=this.handleResponse.bind(this),this.setElementStatus=this.setElementStatus.bind(this),this.submitAnalytics=this.submitAnalytics.bind(this),this.makePaymentsCall=this.makePaymentsCall.bind(this),this.makeAdditionalDetailsCall=this.makeAdditionalDetailsCall.bind(this),this.submitUsingSessionsFlow=this.submitUsingSessionsFlow.bind(this),this.elementRef=n&&n.elementRef||this,this.resources=this.props.modules?this.props.modules.resources:void 0,this.storeElementRefOnCore(this.props),this.onEnterKeyPressed=this.onEnterKeyPressed.bind(this),this.onActionHandled=this.onActionHandled.bind(this),this.createBeforeRenderHook(n),this.reportIntegrationFlavor()}}P(A,"type",void 0),P(A,"txVariants",[]);export{A as UIElement,A as default};
1
+ import{createElement as e}from"../../../external/preact/dist/preact.js";import t,{NETWORK_ERROR as s}from"../../../core/Errors/AdyenCheckoutError.js";import{hasOwnProperty as n}from"../../../utils/hasOwnProperty.js";import i from"../BaseElement/BaseElement.js";import o from"../PayButton/PayButton.js";import{assertIsDropin as r,getRegulatoryDefaults as a,sanitizeResponse as l,verifyPaymentDidNotFail as h,cleanupFinalResult as d}from"./utils.js";import{AnalyticsErrorEvent as c,ErrorEventType as p}from"../../../core/Analytics/events/AnalyticsErrorEvent.js";import{AnalyticsInfoEvent as m,InfoEventType as u}from"../../../core/Analytics/events/AnalyticsInfoEvent.js";import{AnalyticsLogEvent as y,LogEventType as f}from"../../../core/Analytics/events/AnalyticsLogEvent.js";import v from"../../../core/Errors/CancelError.js";import{CoreProvider as b}from"../../../core/Context/CoreProvider.js";import R from"../../../core/Errors/SRPanelProvider.js";function P(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function g(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},n=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(s).filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),n.forEach(function(t){P(e,t,s[t])})}return e}function E(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t.push.apply(t,s)}return t}(Object(t)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(t,s))}),e}class A extends i{createBeforeRenderHook(e){const t=this.render;this.render=(...s)=>(this.beforeRender(e),t.apply(this,s))}beforeRender(e){if(null==e?void 0:e.originalAction)return;const t=new m(g({type:u.rendered,component:this.type,configData:E(g({},e),{showPayButton:this.props.showPayButton})},(null==e?void 0:e.oneClick)&&{isStoredPaymentMethod:!0}));this.analytics.sendAnalytics(t)}reportIntegrationFlavor(){this.analytics.sendFlavor("components")}get analytics(){return this.core.modules.analytics}get srPanel(){return this.core.modules.srPanel}getPaymentMethodConfigFromResponse(e){return(null==e?void 0:e.storedPaymentMethodId)?this.getStoredPaymentMethodDetails(e.storedPaymentMethodId):this.getPaymentMethodFromPaymentMethodsResponse(null==e?void 0:e.type,null==e?void 0:e.paymentMethodId)}buildElementProps(e){const t=g({showPayButton:!0},this.core.getCorePropsForComponent(),this.getPaymentMethodConfigFromResponse(e),e),s=r(this);this.props=this.formatProps(g({},this.constructor.defaultProps,a(this.core.options.countryCode,s),t))}getStoredPaymentMethodDetails(e){return this.core.paymentMethodsResponse.findStoredPaymentMethod(e)}getPaymentMethodFromPaymentMethodsResponse(e,t){var s;return t?this.core.paymentMethodsResponse.findById(t):null===(s=this.core.paymentMethodsResponse)||void 0===s?void 0:s.find(e||this.constructor.type)}storeElementRefOnCore(e){(null==e?void 0:e.isDropin)||this.core.storeElementReference(this)}isAvailable(){return Promise.resolve()}setState(e){this.state=g({},this.state,e),this.onChange()}showValidation(){return this.componentRef&&this.componentRef.showValidation&&this.componentRef.showValidation(),this}setElementStatus(e,t){var s;return null===(s=this.elementRef)||void 0===s||s.setStatus(e,t),this}setStatus(e,t){var s;return(null===(s=this.componentRef)||void 0===s?void 0:s.setStatus)&&this.componentRef.setStatus(e,t),this}onChange(){var e,t;null===(e=(t=this.props).onChange)||void 0===e||e.call(t,{data:this.data,isValid:this.isValid,errors:this.state.errors,valid:this.state.valid},this.elementRef)}submitAnalytics(e){this.analytics.sendAnalytics(e)}submit(){this.isValid?this.makePaymentsCall().then(l).then(h).then(this.handleResponse).catch(e=>{e instanceof v?this.setElementStatus("ready"):this.handleFailedResult(e)}):this.showValidation()}makePaymentsCall(){if(this.setElementStatus("loading"),this.props.onSubmit)return this.submitUsingAdvancedFlow();if(this.core.session){return(this.props.beforeSubmit?new Promise((e,t)=>this.props.beforeSubmit(this.data,this.elementRef,{resolve:e,reject:()=>t(new v("beforeSubmitRejected"))})):Promise.resolve(this.data)).then(this.submitUsingSessionsFlow)}this.handleError(new t("IMPLEMENTATION_ERROR",'It can not perform /payments call. Callback "onSubmit" is missing or Checkout session is not available'))}async submitUsingAdvancedFlow(){const e=new y({component:this.type,type:f.submit,message:"Shopper clicked pay"});return this.submitAnalytics(e),new Promise((e,t)=>{this.props.onSubmit({data:this.data,isValid:this.isValid},this.elementRef,{resolve:e,reject:t})})}async submitUsingSessionsFlow(e){const s=new y({component:this.type,type:f.submit,message:"Shopper clicked pay"});this.submitAnalytics(s);try{return await this.core.session.submitPayment(e)}catch(e){return e instanceof t?this.handleError(e):this.handleError(new t("ERROR","Error when making /payments call",{cause:e})),Promise.reject(e)}}onComplete(e){this.handleAdditionalDetails(e)}handleAdditionalDetails(e){this.makeAdditionalDetailsCall(e).then(l).then(h).then(this.handleResponse).catch(this.handleFailedResult)}makeAdditionalDetailsCall(e){return this.props.onAdditionalDetails?new Promise((t,s)=>{this.props.onAdditionalDetails(e,this.elementRef,{resolve:t,reject:s})}):this.core.session?this.submitAdditionalDetailsUsingSessionsFlow(e.data):void this.handleError(new t("IMPLEMENTATION_ERROR",'It can not perform /payments/details call. Callback "onAdditionalDetails" is missing or Checkout session is not available'))}async submitAdditionalDetailsUsingSessionsFlow(e){try{return await this.core.session.submitDetails(e)}catch(e){return e instanceof t?this.handleError(e):this.handleError(new t("ERROR","Error when making /details call",{cause:e})),Promise.reject(e)}}handleAction(e,t={}){if(!e||!e.type){if(n(e,"action")&&n(e,"resultCode"))throw new Error('handleAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('handleAction::Invalid Action - the passed action object does not have a "type" property')}const s=this.core.createFromAction(e,g({},this.elementRef.props,t));return s?(this.unmount(),s.mount(this._node)):null}onActionHandled(e){var t,s;null===(s=this.props)||void 0===s||null===(t=s.onActionHandled)||void 0===t||t.call(s,g({originalAction:this.props.originalAction},e))}handleResponse(e){var t,s;e.action?this.elementRef.handleAction(e.action):(null===(s=e.order)||void 0===s||null===(t=s.remainingAmount)||void 0===t?void 0:t.value)>0?this.handleOrder(e):this.handleSuccessResult(e)}handleKeyPress(e){var t;"Enter"!==e.key&&"Enter"!==e.code||(e.preventDefault(),this.onEnterKeyPressed(null===(t=document)||void 0===t?void 0:t.activeElement,this))}onEnterKeyPressed(e,t){this.props.onEnterKeyPressed?this.props.onEnterKeyPressed(e,t):(e.blur(),this.submit())}updateParent(e={}){return this.elementRef.core.update(e)}get isValid(){return!1}get icon(){var e;const t=this.props.paymentMethodType||this.type;return null!==(e=this.props.icon)&&void 0!==e?e:this.resources.getImage()(t)}get displayName(){var e,t;const s=null===(t=this.core.paymentMethodsResponse)||void 0===t||null===(e=t.paymentMethods)||void 0===e?void 0:e.find(e=>e.type===this.type);return this.props.name||(null==s?void 0:s.name)||this.type}get accessibleName(){return this.displayName}get additionalInfo(){return null}get type(){return this.props.type||this.constructor.type}async handleAdvanceFlowPaymentMethodsUpdate(e,s){return new Promise((t,s)=>{if(!this.props.onPaymentMethodsRequest)return t();this.props.onPaymentMethodsRequest(E(g({},e&&{order:{orderData:e.orderData,pspReference:e.pspReference}}),{locale:this.core.options.locale}),{resolve:t,reject:s})}).catch(e=>{this.handleError(new t("IMPLEMENTATION_ERROR","Something failed during payment methods update or onPaymentMethodsRequest was not implemented",{cause:e}))}).then(t=>this.core.update(E(g({},t&&{paymentMethodsResponse:t}),{order:e,amount:e?e.remainingAmount:s})))}render(){return e(b,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources,analytics:this.analytics},e(R,{srPanel:this.srPanel},this.componentToRender()))}constructor(t,n){super(t,n),P(this,"componentRef",void 0),P(this,"resources",void 0),P(this,"elementRef",void 0),P(this,"handleError",e=>{if(this.setElementStatus("ready"),e.name===s&&e.options.code){const t=new c({component:this.type,errorType:p.apiError,code:e.options.code});this.submitAnalytics(t)}this.props.onError&&this.props.onError(e,this.elementRef)}),P(this,"handleOrder",e=>{const{order:t}=e;(this.core.session?this.core.update({order:t}):this.handleAdvanceFlowPaymentMethodsUpdate(t)).then(()=>{var e,s;null===(e=(s=this.props).onOrderUpdated)||void 0===e||e.call(s,{order:t})})}),P(this,"handleFailedResult",e=>{var t,s;r(this.elementRef)&&this.elementRef.displayFinalAnimation("error"),d(e),null===(t=(s=this.props).onPaymentFailed)||void 0===t||t.call(s,e,this.elementRef)}),P(this,"handleSuccessResult",e=>{var t,s;r(this.elementRef)&&this.elementRef.displayFinalAnimation("success"),d(e),null===(t=(s=this.props).onPaymentCompleted)||void 0===t||t.call(s,e,this.elementRef)}),P(this,"setComponentRef",e=>{this.componentRef=e}),P(this,"payButton",t=>e(o,E(g({},t),{amount:this.props.amount,secondaryAmount:this.props.secondaryAmount,onClick:this.submit}))),this.core.register(this.constructor),this.submit=this.submit.bind(this),this.setState=this.setState.bind(this),this.onComplete=this.onComplete.bind(this),this.handleAction=this.handleAction.bind(this),this.handleOrder=this.handleOrder.bind(this),this.handleAdditionalDetails=this.handleAdditionalDetails.bind(this),this.handleResponse=this.handleResponse.bind(this),this.setElementStatus=this.setElementStatus.bind(this),this.submitAnalytics=this.submitAnalytics.bind(this),this.makePaymentsCall=this.makePaymentsCall.bind(this),this.makeAdditionalDetailsCall=this.makeAdditionalDetailsCall.bind(this),this.submitUsingSessionsFlow=this.submitUsingSessionsFlow.bind(this),this.elementRef=n&&n.elementRef||this,this.resources=this.props.modules?this.props.modules.resources:void 0,this.storeElementRefOnCore(this.props),this.onEnterKeyPressed=this.onEnterKeyPressed.bind(this),this.onActionHandled=this.onActionHandled.bind(this),this.createBeforeRenderHook(n),this.reportIntegrationFlavor()}}P(A,"type",void 0),P(A,"txVariants",[]);export{A as UIElement,A as default};
2
2
  //# sourceMappingURL=UIElement.js.map