@adyen/adyen-web 6.11.0 → 6.12.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.
- package/dist/cjs/adyen.css +3 -3
- package/dist/cjs/adyen.css.map +1 -1
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +88 -98
- package/dist/es/adyen.css +3 -3
- package/dist/es/adyen.css.map +1 -1
- package/dist/es/components/ANCV/components/ANCVAwait/config.js +1 -1
- package/dist/es/components/ANCV/components/ANCVAwait/config.js.map +1 -1
- package/dist/es/components/Ach/Ach.js +1 -1
- package/dist/es/components/Ach/Ach.js.map +1 -1
- package/dist/es/components/Ach/components/AccountTypeSelector.js +2 -0
- package/dist/es/components/Ach/components/AccountTypeSelector.js.map +1 -0
- package/dist/es/components/Ach/components/AchComponent.js +2 -0
- package/dist/es/components/Ach/components/AchComponent.js.map +1 -0
- package/dist/es/components/Ach/components/useSRPanelForACHErrors.js +2 -0
- package/dist/es/components/Ach/components/useSRPanelForACHErrors.js.map +1 -0
- package/dist/es/components/Ach/components/validate.js +2 -0
- package/dist/es/components/Ach/components/validate.js.map +1 -0
- package/dist/es/components/Ach/defaultProps.js +2 -0
- package/dist/es/components/Ach/defaultProps.js.map +1 -0
- package/dist/es/components/AmazonPay/utils.js +1 -1
- package/dist/es/components/ApplePay/ApplePay.js +1 -1
- package/dist/es/components/Atome/Atome.js +1 -1
- package/dist/es/components/BacsDD/components/BacsInput.js +1 -1
- package/dist/es/components/BcmcMobile/BcmcMobile.js +1 -1
- package/dist/es/components/Boleto/components/BoletoInput/validate.js +1 -1
- package/dist/es/components/Card/components/CardInput/CardInput.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/CVC.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/CardFields.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/DataSfSpan.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/ExpirationDate.js +1 -1
- package/dist/es/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/validate.js +1 -1
- package/dist/es/components/Donation/components/DonationComponent.js +1 -1
- package/dist/es/components/DuitNow/DuitNow.js +1 -1
- package/dist/es/components/GooglePay/GooglePay.js +1 -1
- package/dist/es/components/GooglePay/GooglePay.js.map +1 -1
- package/dist/es/components/PayNow/PayNow.js +1 -1
- package/dist/es/components/PayPal/constants.js +1 -1
- package/dist/es/components/PayPal/constants.js.map +1 -1
- package/dist/es/components/PayTo/PayTo.js.map +1 -1
- package/dist/es/components/Pix/PixInput/PixInput.js.map +1 -1
- package/dist/es/components/PromptPay/PromptPay.js +1 -1
- package/dist/es/components/Redirect/Redirect.js +1 -1
- package/dist/es/components/Riverty/Riverty.js +1 -1
- package/dist/es/components/Riverty/config.js +1 -1
- package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
- package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
- package/dist/es/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
- package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js +1 -1
- package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
- package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
- package/dist/es/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js +1 -1
- package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
- package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
- package/dist/es/components/WeChat/WeChat.js +1 -1
- package/dist/es/components/internal/Address/Address.js +1 -1
- package/dist/es/components/internal/Address/validate.formats.js.map +1 -1
- package/dist/es/components/internal/Countdown/utils.js.map +1 -1
- package/dist/es/components/internal/FormFields/Checkbox/Checkbox.js +1 -1
- package/dist/es/components/internal/FormFields/Checkbox/Checkbox.js.map +1 -1
- package/dist/es/components/internal/FormFields/InputDate/utils.js.map +1 -1
- package/dist/es/components/internal/FormFields/Select/components/SelectButton.js +1 -1
- package/dist/es/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
- package/dist/es/components/internal/IbanInput/validate.js +1 -1
- package/dist/es/components/internal/IssuerList/IssuerList.js +1 -1
- package/dist/es/components/internal/IssuerList/IssuerList.js.map +1 -1
- package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js +1 -1
- package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
- package/dist/es/components/internal/PhoneInput/PhoneInputForm.js +1 -1
- package/dist/es/components/internal/PhoneInput/PhoneInputForm.js.map +1 -1
- package/dist/es/components/internal/PhoneInput/validate.js +1 -1
- package/dist/es/components/internal/QRLoader/QRLoader.js +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleTab.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleTab.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/partials/processAutoComplete.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/utils/iframes/postMessageValidation.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/utils/tabbing/utils.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/utils/userAgent.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/utils/userAgent.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/constants.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/constants.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/securedField/utils/processPlaceholders.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/securedField/utils/processPlaceholders.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/utilities/addContextTranslations.js +1 -1
- package/dist/es/components/internal/StoreDetails/StoreDetails.js +1 -1
- package/dist/es/components/internal/StoreDetails/StoreDetails.js.map +1 -1
- package/dist/es/components/internal/UIElement/UIElement.js +1 -1
- package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
- package/dist/es/core/Analytics/Analytics.js +1 -1
- package/dist/es/core/Analytics/Analytics.js.map +1 -1
- package/dist/es/core/Analytics/constants.js +1 -1
- package/dist/es/core/Analytics/constants.js.map +1 -1
- package/dist/es/core/Analytics/utils.js +1 -1
- package/dist/es/core/Errors/constants.js +1 -1
- package/dist/es/core/Errors/constants.js.map +1 -1
- package/dist/es/core/Errors/utils.js +1 -1
- package/dist/es/core/Errors/utils.js.map +1 -1
- package/dist/es/core/RiskModule/components/DeviceFingerprint/utils.js +1 -1
- package/dist/es/core/RiskModule/constants.js +1 -1
- package/dist/es/core/RiskModule/constants.js.map +1 -1
- package/dist/es/core/Services/analytics/collect-id.js +1 -1
- package/dist/es/core/Services/http.js +1 -1
- package/dist/es/core/core.js +1 -1
- package/dist/es/external/preact/dist/preact.js +1 -1
- package/dist/es/external/preact/dist/preact.js.map +1 -1
- package/dist/es/external/preact/hooks/dist/hooks.js.map +1 -1
- package/dist/es/index.d.ts +88 -98
- package/dist/es/index.js +1 -1
- package/dist/es/utils/Validator/defaultRules.js +1 -1
- package/dist/es/utils/base64.js.map +1 -1
- package/dist/es/utils/browserInfo.js +1 -1
- package/dist/es/utils/browserInfo.js.map +1 -1
- package/dist/es/utils/setFocus.js +1 -1
- package/dist/es/utils/setFocus.js.map +1 -1
- package/dist/es/utils/textUtils.js +1 -1
- package/dist/es/utils/textUtils.js.map +1 -1
- package/dist/es/utils/useForm/useForm.js +1 -1
- package/dist/es-legacy/adyen.css +3 -3
- package/dist/es-legacy/adyen.css.map +1 -1
- package/dist/es-legacy/components/ANCV/components/ANCVAwait/config.js +1 -1
- package/dist/es-legacy/components/ANCV/components/ANCVAwait/config.js.map +1 -1
- package/dist/es-legacy/components/Ach/Ach.js +1 -1
- package/dist/es-legacy/components/Ach/Ach.js.map +1 -1
- package/dist/es-legacy/components/Ach/components/AccountTypeSelector.js +2 -0
- package/dist/es-legacy/components/Ach/components/AccountTypeSelector.js.map +1 -0
- package/dist/es-legacy/components/Ach/components/AchComponent.js +2 -0
- package/dist/es-legacy/components/Ach/components/AchComponent.js.map +1 -0
- package/dist/es-legacy/components/Ach/components/useSRPanelForACHErrors.js +2 -0
- package/dist/es-legacy/components/Ach/components/useSRPanelForACHErrors.js.map +1 -0
- package/dist/es-legacy/components/Ach/components/validate.js +2 -0
- package/dist/es-legacy/components/Ach/components/validate.js.map +1 -0
- package/dist/es-legacy/components/Ach/defaultProps.js +2 -0
- package/dist/es-legacy/components/Ach/defaultProps.js.map +1 -0
- package/dist/es-legacy/components/AmazonPay/utils.js +1 -1
- package/dist/es-legacy/components/ApplePay/ApplePay.js +1 -1
- package/dist/es-legacy/components/Atome/Atome.js +1 -1
- package/dist/es-legacy/components/BacsDD/components/BacsInput.js +1 -1
- package/dist/es-legacy/components/BcmcMobile/BcmcMobile.js +1 -1
- package/dist/es-legacy/components/Boleto/components/BoletoInput/validate.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/CardInput.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CVC.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CardFields.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/DataSfSpan.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/ExpirationDate.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/validate.js +1 -1
- package/dist/es-legacy/components/Donation/components/DonationComponent.js +1 -1
- package/dist/es-legacy/components/DuitNow/DuitNow.js +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePay.js +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
- package/dist/es-legacy/components/PayNow/PayNow.js +1 -1
- package/dist/es-legacy/components/PayPal/constants.js +1 -1
- package/dist/es-legacy/components/PayPal/constants.js.map +1 -1
- package/dist/es-legacy/components/PayTo/PayTo.js.map +1 -1
- package/dist/es-legacy/components/Pix/PixInput/PixInput.js.map +1 -1
- package/dist/es-legacy/components/PromptPay/PromptPay.js +1 -1
- package/dist/es-legacy/components/Redirect/Redirect.js +1 -1
- package/dist/es-legacy/components/Riverty/Riverty.js +1 -1
- package/dist/es-legacy/components/Riverty/config.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
- package/dist/es-legacy/components/WeChat/WeChat.js +1 -1
- package/dist/es-legacy/components/internal/Address/Address.js +1 -1
- package/dist/es-legacy/components/internal/Address/validate.formats.js.map +1 -1
- package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
- package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/services/ClickToPayService.js +1 -1
- package/dist/es-legacy/components/internal/Countdown/utils.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/Checkbox/Checkbox.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/Checkbox/Checkbox.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/InputBase.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/InputBase.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/InputDate/utils.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
- package/dist/es-legacy/components/internal/IbanInput/validate.js +1 -1
- package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
- package/dist/es-legacy/components/internal/IssuerList/IssuerList.js.map +1 -1
- package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js +1 -1
- package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
- package/dist/es-legacy/components/internal/PhoneInput/PhoneInputForm.js +1 -1
- package/dist/es-legacy/components/internal/QRLoader/QRLoader.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleTab.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleTab.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/processAutoComplete.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/iframes/postMessageValidation.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/tabbing/utils.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/userAgent.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/userAgent.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/utils/processPlaceholders.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/utils/processPlaceholders.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/utilities/addContextTranslations.js +1 -1
- package/dist/es-legacy/components/internal/StoreDetails/StoreDetails.js +1 -1
- package/dist/es-legacy/components/internal/StoreDetails/StoreDetails.js.map +1 -1
- package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
- package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
- package/dist/es-legacy/core/Analytics/Analytics.js +1 -1
- package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
- package/dist/es-legacy/core/Analytics/constants.js +1 -1
- package/dist/es-legacy/core/Analytics/constants.js.map +1 -1
- package/dist/es-legacy/core/Analytics/utils.js +1 -1
- package/dist/es-legacy/core/Errors/constants.js +1 -1
- package/dist/es-legacy/core/Errors/constants.js.map +1 -1
- package/dist/es-legacy/core/Errors/utils.js +1 -1
- package/dist/es-legacy/core/Errors/utils.js.map +1 -1
- package/dist/es-legacy/core/RiskModule/RiskModule.js +1 -1
- package/dist/es-legacy/core/RiskModule/components/DeviceFingerprint/utils.js +1 -1
- package/dist/es-legacy/core/RiskModule/constants.js +1 -1
- package/dist/es-legacy/core/RiskModule/constants.js.map +1 -1
- package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
- package/dist/es-legacy/core/core.js +1 -1
- package/dist/es-legacy/external/preact/dist/preact.js +1 -1
- package/dist/es-legacy/external/preact/dist/preact.js.map +1 -1
- package/dist/es-legacy/external/preact/hooks/dist/hooks.js.map +1 -1
- package/dist/es-legacy/index.js +1 -1
- package/dist/es-legacy/utils/Validator/defaultRules.js +1 -1
- package/dist/es-legacy/utils/base64.js.map +1 -1
- package/dist/es-legacy/utils/browserInfo.js +1 -1
- package/dist/es-legacy/utils/browserInfo.js.map +1 -1
- package/dist/es-legacy/utils/setFocus.js +1 -1
- package/dist/es-legacy/utils/setFocus.js.map +1 -1
- package/dist/es-legacy/utils/textUtils.js +1 -1
- package/dist/es-legacy/utils/textUtils.js.map +1 -1
- package/dist/es-legacy/utils/useForm/useForm.js +1 -1
- package/package.json +21 -21
- package/styles/adyen.css +3 -3
- package/dist/es/components/Ach/components/AchInput/AchInput.js +0 -2
- package/dist/es/components/Ach/components/AchInput/AchInput.js.map +0 -1
- package/dist/es/components/Ach/components/AchInput/components/AchSFInput.js +0 -2
- package/dist/es/components/Ach/components/AchInput/components/AchSFInput.js.map +0 -1
- package/dist/es/components/Ach/components/AchInput/components/AchSecuredFields.js +0 -2
- package/dist/es/components/Ach/components/AchInput/components/AchSecuredFields.js.map +0 -1
- package/dist/es/components/Ach/components/AchInput/defaultProps.js +0 -2
- package/dist/es/components/Ach/components/AchInput/defaultProps.js.map +0 -1
- package/dist/es/components/Ach/components/AchInput/defaultStyles.js +0 -2
- package/dist/es/components/Ach/components/AchInput/defaultStyles.js.map +0 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/utils/tabbing/tabScenarioACH.js +0 -2
- package/dist/es/components/internal/SecuredFields/lib/CSF/utils/tabbing/tabScenarioACH.js.map +0 -1
- package/dist/es-legacy/components/Ach/components/AchInput/AchInput.js +0 -2
- package/dist/es-legacy/components/Ach/components/AchInput/AchInput.js.map +0 -1
- package/dist/es-legacy/components/Ach/components/AchInput/components/AchSFInput.js +0 -2
- package/dist/es-legacy/components/Ach/components/AchInput/components/AchSFInput.js.map +0 -1
- package/dist/es-legacy/components/Ach/components/AchInput/components/AchSecuredFields.js +0 -2
- package/dist/es-legacy/components/Ach/components/AchInput/components/AchSecuredFields.js.map +0 -1
- package/dist/es-legacy/components/Ach/components/AchInput/defaultProps.js +0 -2
- package/dist/es-legacy/components/Ach/components/AchInput/defaultProps.js.map +0 -1
- package/dist/es-legacy/components/Ach/components/AchInput/defaultStyles.js +0 -2
- package/dist/es-legacy/components/Ach/components/AchInput/defaultStyles.js.map +0 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/tabbing/tabScenarioACH.js +0 -2
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/tabbing/tabScenarioACH.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useState as s,useCallback as r,useRef as o,useEffect as i}from"../../../external/preact/hooks/dist/hooks.js";import n from"../../../utils/useForm/useForm.js";import a from"../FormFields/Field/Field.js";import l from"./IssuerButtonGroup/IssuerButtonGroup.js";import u from"../ContentSeparator/ContentSeparator.js";import{useCoreContext as c}from"../../../core/Context/CoreProvider.js";import m from"../../../core/Errors/useSRPanelContext.js";import{ERROR_ACTION_FOCUS_FIELD as d}from"../../../core/Errors/constants.js";import{setFocusOnField as g}from"../../../utils/setFocus.js";import h from"../DisclaimerMessage/DisclaimerMessage.js";import
|
|
1
|
+
import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useState as s,useCallback as r,useRef as o,useEffect as i}from"../../../external/preact/hooks/dist/hooks.js";import n from"../../../utils/useForm/useForm.js";import a from"../FormFields/Field/Field.js";import l from"./IssuerButtonGroup/IssuerButtonGroup.js";import u from"../ContentSeparator/ContentSeparator.js";import{useCoreContext as c}from"../../../core/Context/CoreProvider.js";import m from"../../../core/Errors/useSRPanelContext.js";import{ERROR_ACTION_FOCUS_FIELD as d}from"../../../core/Errors/constants.js";import{setFocusOnField as g}from"../../../utils/setFocus.js";import h from"../DisclaimerMessage/DisclaimerMessage.js";import p from"../FormFields/Select/Select.js";import{ANALYTICS_LIST as f,ANALYTICS_FEATURED_ISSUER as y,ANALYTICS_SELECTED_STR as b,ANALYTICS_DISPLAYED_STR as j,ANALYTICS_SEARCH_DEBOUNCE_TIME as v,ANALYTICS_LIST_SEARCH as x,ANALYTICS_INPUT_STR as C}from"../../../core/Analytics/constants.js";import{debounce as O}from"../../../utils/debounce.js";function S(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function F(e,t){if(null==e)return{};var s,r,o=function(e,t){if(null==e)return{};var s,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)s=i[r],t.indexOf(s)>=0||(o[s]=e[s]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)s=i[r],t.indexOf(s)>=0||Object.prototype.propertyIsEnumerable.call(e,s)&&(o[s]=e[s])}return o}const w=({issuer:e,items:t},s)=>{var r;const o=null===(r=t.find((t=>t.id===e)))||void 0===r?void 0:r.name;return e&&o?`${s.get("continueTo")} ${o}`:s.get("continue")},_=["issuer"],I={issuer:{validate:e=>!!e&&e.length>0,errorMessage:"issuerList.selectField.contextualText",modes:["blur"]}};function P(P){var{items:k,placeholder:E,issuer:M,highlightedIds:A=[],showContextualElement:T,contextualText:V}=P,B=F(P,["items","placeholder","issuer","highlightedIds","showContextualElement","contextualText"]);const{i18n:D}=c(),{handleChangeFor:N,triggerValidation:R,data:L,valid:G,errors:$,isValid:K}=n({schema:_,defaultData:{issuer:M},rules:I}),[q,z]=s("ready"),[H,J]=s(1),{setSRMessagesFromObjects:Q,shouldMoveFocusSR:U}=m(),W=null==Q?void 0:Q({});this.setStatus=e=>{z(e)};const X=r((e=>t=>{const s=1===e?f:y,r=k.find((e=>e.id===t.target.value));B.onSubmitAnalytics({type:b,target:s,issuer:r.name}),J(e),N("issuer")(t)}),[N]),Y=r((e=>{e&&B.onSubmitAnalytics({type:j,target:f})}),[]),Z=o(O(B.onSubmitAnalytics,v)),ee=r((()=>{Z.current({type:C,target:x})}),[]);i((()=>{B.onChange({data:L,valid:G,errors:$,isValid:K});const e=null==W?void 0:W({errors:$,isValidating:!0});(null==e?void 0:e.action)===d&&U&&g(".adyen-checkout__issuer-list","issuer-list")}),[L,G,$,K]),this.showValidation=()=>{R()};const{highlightedItems:te}=k.reduce(((e,t)=>(A.includes(t.id)&&e.highlightedItems.push(function(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},r=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(s).filter((function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable})))),r.forEach((function(t){S(e,t,s[t])}))}return e}({},t)),e)),{highlightedItems:[]});return e("div",{className:"adyen-checkout__issuer-list"},!!te.length&&e(t,null,e(l,{selectedIssuerId:0===H?L.issuer:null,items:te,onChange:X(0)}),e(u,null)),e(a,{label:D.get("issuerList.selectField.label"),errorMessage:(se=$.issuer,se&&se.errorMessage?D.get(se.errorMessage):!!se),classNameModifiers:["issuer-list"],name:"issuer",showContextualElement:T,contextualText:V},e(p,{items:k,selectedValue:1===H?L.issuer:null,placeholder:E,name:"issuer",className:"adyen-checkout__issuer-list__dropdown",onChange:X(1),onListToggle:Y,onInput:ee})),B.termsAndConditions&&e("div",{className:"adyen-checkout__issuer-list__termsAndConditions"},e(h,{message:D.get(B.termsAndConditions.translationKey),urls:B.termsAndConditions.urls})),B.showPayButton&&B.payButton({status:q,label:w({issuer:L.issuer,items:[...k,...te]},D)}));var se}P.defaultProps={onChange:()=>{}};export{P as default};
|
|
2
2
|
//# sourceMappingURL=IssuerList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IssuerList.js","sources":["../../../../../src/components/internal/IssuerList/IssuerList.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useState, useEffect, useCallback, useRef } from 'preact/hooks';\nimport useForm from '../../../utils/useForm';\nimport Field from '../FormFields/Field';\nimport IssuerButtonGroup from './IssuerButtonGroup';\nimport ContentSeparator from '../ContentSeparator';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ValidatorRules } from '../../../utils/Validator/types';\nimport { IssuerListProps } from './types';\nimport './IssuerList.scss';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport DisclaimerMessage from '../DisclaimerMessage';\nimport Select from '../FormFields/Select';\nimport { SelectTargetObject } from '../FormFields/Select/types';\nimport {\n ANALYTICS_DISPLAYED_STR,\n ANALYTICS_FEATURED_ISSUER,\n ANALYTICS_INPUT_STR,\n ANALYTICS_LIST,\n ANALYTICS_LIST_SEARCH,\n ANALYTICS_SEARCH_DEBOUNCE_TIME,\n ANALYTICS_SELECTED_STR\n} from '../../../core/Analytics/constants';\nimport { debounce } from '../../../utils/debounce';\n\nconst payButtonLabel = ({ issuer, items }, i18n): string => {\n const issuerName = items.find(i => i.id === issuer)?.name;\n if (!issuer || !issuerName) return i18n.get('continue');\n return `${i18n.get('continueTo')} ${issuerName}`;\n};\n\nconst schema = ['issuer'];\nconst validationRules: ValidatorRules = {\n issuer: {\n validate: issuer => !!issuer && issuer.length > 0,\n errorMessage: 'issuerList.selectField.contextualText',\n modes: ['blur']\n }\n};\n\nenum IssuerListInputTypes {\n ButtonGroup,\n Dropdown\n}\n\nfunction IssuerList({ items, placeholder, issuer, highlightedIds = [], showContextualElement, contextualText, ...props }: IssuerListProps) {\n const { i18n } = useCoreContext();\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm({\n schema,\n defaultData: { issuer },\n rules: validationRules\n });\n const [status, setStatus] = useState('ready');\n const [inputType, setInputType] = useState<IssuerListInputTypes>(IssuerListInputTypes.Dropdown);\n\n const { setSRMessagesFromObjects, shouldMoveFocusSR } = useSRPanelContext();\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({});\n\n const getErrorMessage = error => (error && error.errorMessage ? i18n.get(error.errorMessage) : !!error);\n\n this.setStatus = newStatus => {\n setStatus(newStatus);\n };\n\n const handleInputChange = useCallback(\n (type: IssuerListInputTypes) => (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n const target = type === IssuerListInputTypes.Dropdown ? ANALYTICS_LIST : ANALYTICS_FEATURED_ISSUER;\n const issuerObj = items.find(issuer => issuer.id === (event.target as SelectTargetObject).value);\n props.onSubmitAnalytics({ type: ANALYTICS_SELECTED_STR, target, issuer: issuerObj.name });\n\n setInputType(type);\n handleChangeFor('issuer')(event);\n },\n [handleChangeFor]\n );\n\n const handleListToggle = useCallback((isOpen: boolean) => {\n if (isOpen) {\n props.onSubmitAnalytics({ type: ANALYTICS_DISPLAYED_STR, target: ANALYTICS_LIST });\n }\n }, []);\n\n const debounceSearchAnalytics = useRef(debounce(props.onSubmitAnalytics, ANALYTICS_SEARCH_DEBOUNCE_TIME));\n\n const handleSearch = useCallback(() => {\n debounceSearchAnalytics.current({ type: ANALYTICS_INPUT_STR, target: ANALYTICS_LIST_SEARCH });\n }, []);\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({ errors, isValidating: true });\n if (srPanelResp?.action === ERROR_ACTION_FOCUS_FIELD) {\n // Focus field in error, if required\n if (shouldMoveFocusSR) setFocusOnField('.adyen-checkout__issuer-list', srPanelResp.fieldToFocus);\n }\n }, [data, valid, errors, isValid]);\n\n this.showValidation = () => {\n triggerValidation();\n };\n\n const { highlightedItems } = items.reduce(\n (memo, item) => {\n if (highlightedIds.includes(item.id)) memo.highlightedItems.push({ ...item });\n return memo;\n },\n { highlightedItems: [] }\n );\n\n return (\n <div className=\"adyen-checkout__issuer-list\">\n {!!highlightedItems.length && (\n <Fragment>\n <IssuerButtonGroup\n selectedIssuerId={inputType === IssuerListInputTypes.ButtonGroup ? data['issuer'] : null}\n items={highlightedItems}\n onChange={handleInputChange(IssuerListInputTypes.ButtonGroup)}\n />\n <ContentSeparator />\n </Fragment>\n )}\n\n <Field\n label={i18n.get('issuerList.selectField.label')}\n errorMessage={getErrorMessage(errors.issuer)}\n classNameModifiers={['issuer-list']}\n name={'issuer'}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <Select\n items={items}\n selectedValue={inputType === IssuerListInputTypes.Dropdown ? data['issuer'] : null}\n placeholder={placeholder}\n name={'issuer'}\n className={'adyen-checkout__issuer-list__dropdown'}\n onChange={handleInputChange(IssuerListInputTypes.Dropdown)}\n onListToggle={handleListToggle}\n onInput={handleSearch}\n />\n </Field>\n\n {props.termsAndConditions && (\n <div className=\"adyen-checkout__issuer-list__termsAndConditions\">\n <DisclaimerMessage message={i18n.get(props.termsAndConditions.translationKey)} urls={props.termsAndConditions.urls} />\n </div>\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n label: payButtonLabel({ issuer: data['issuer'], items: [...items, ...highlightedItems] }, i18n)\n })}\n </div>\n );\n}\n\nIssuerList.defaultProps = {\n onChange: () => {}\n};\n\nexport default IssuerList;\n"],"names":["payButtonLabel","issuer","items","i18n","issuerName","find","i","id","name","get","schema","validationRules","validate","length","errorMessage","modes","IssuerList","_param","placeholder","highlightedIds","showContextualElement","contextualText","props","_object_without_properties","useCoreContext","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","defaultData","rules","status","setStatus","useState","inputType","setInputType","setSRMessagesFromObjects","shouldMoveFocusSR","useSRPanelContext","setSRMessages","this","newStatus","handleInputChange","useCallback","type","event","target","ANALYTICS_LIST","ANALYTICS_FEATURED_ISSUER","issuerObj","value","onSubmitAnalytics","ANALYTICS_SELECTED_STR","handleListToggle","isOpen","ANALYTICS_DISPLAYED_STR","debounceSearchAnalytics","useRef","debounce","ANALYTICS_SEARCH_DEBOUNCE_TIME","handleSearch","current","ANALYTICS_INPUT_STR","ANALYTICS_LIST_SEARCH","useEffect","onChange","srPanelResp","isValidating","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnField","fieldToFocus","showValidation","highlightedItems","reduce","memo","item","includes","push","_object_spread","h","div","className","Fragment","IssuerButtonGroup","selectedIssuerId","ContentSeparator","Field","label","error","classNameModifiers","Select","selectedValue","onListToggle","onInput","termsAndConditions","DisclaimerMessage","message","translationKey","urls","showPayButton","payButton","defaultProps"],"mappings":"+hDA6BA,MAAMA,EAAiB,EAAGC,SAAQC,SAASC,KACpBD,IAAAA,EAAnB,MAAME,EAAaF,QAAAA,EAAAA,EAAMG,MAAKC,GAAKA,EAAEC,KAAON,WAAzBC,IAAAA,OAAAA,EAAAA,EAAkCM,KACrD,OAAKP,GAAWG,EACT,GAAGD,EAAKM,IAAI,iBAAiBL,IADDD,EAAKM,IAAI,WACI,EAG9CC,EAAS,CAAC,UACVC,EAAkC,CACpCV,OAAQ,CACJW,SAAUX,KAAYA,GAAUA,EAAOY,OAAS,EAChDC,aAAc,wCACdC,MAAO,CAAC,UAShB,SAASC,EAAWC,GAAA,IAAAf,MAAEA,EAAKgB,YAAEA,EAAWjB,OAAEA,EAAMkB,eAAEA,EAAiB,GAAEC,sBAAEA,EAAqBC,eAAEA,GAA1EJ,EAA6FK,EAA7FC,EAAAN,EAAA,CAAEf,QAAOgB,cAAajB,SAAQkB,iBAAqBC,wBAAuBC,mBAC1F,MAAMlB,KAAEA,GAASqB,KACXC,gBAAEA,EAAeC,kBAAEA,EA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KF,iBAAiBK,2UAAKC,CAAKH,CAAAA,EAAAA,IAC/DD,IAEX,CAAEF,iBAAkB,KAGxB,OACIO,EAACC,MAAAA,CAAIC,UAAU,iCACRT,GAAiB/D,QAChBsE,EAACG,OACGH,EAACI,EAAAA,CACGC,iBAAmE7D,IAAjDU,EAAiDV,EAAK,OAAY,KACpFzB,MAAO0E,GACPR,SAAUvB,EAAAA,KAEdsC,EAACM,SAITN,EAACO,EAAAA,CACGC,MAAOxF,EAAKM,IAAI,gCAChBK,cAnEY8E,GAmEkB/D,EAAO5B,OAnEf2F,IAASA,GAAM9E,aAAeX,EAAKM,IAAImF,GAAM9E,gBAAkB8E,IAoErFC,mBAAoB,CAAC,eACrBrF,KAAM,SACNY,sBAAuBA,EACvBC,eAAgBA,GAEhB8D,EAACW,EAAAA,CACG5F,MAAOA,EACP6F,cAA6DpE,IAA9CU,EAA8CV,EAAK,OAAY,KAC9ET,YAAaA,EACbV,KAAM,SACN6E,UAAW,wCACXjB,SAAUvB,EAAAA,GACVmD,aAAcxC,EACdyC,QAASlC,MAIhBzC,EAAM4E,oBACHf,EAACC,MAAAA,CAAIC,UAAU,mDACXF,EAACgB,EAAAA,CAAkBC,QAASjG,EAAKM,IAAIa,EAAM4E,mBAAmBG,gBAAiBC,KAAMhF,EAAM4E,mBAAmBI,QAIrHhF,EAAMiF,eACHjF,EAAMkF,UAAU,CACZtE,SACAyD,MAAO3F,EAAe,CAAEC,OAAQ0B,EAAc,OAAEzB,MAAO,IAAIA,KAAU0E,KAAqBzE,MA9FlFyF,IAAAA,EAkG5B,CAEA5E,EAAWyF,aAAe,CACtBrC,SAAU"}
|
|
1
|
+
{"version":3,"file":"IssuerList.js","sources":["../../../../../src/components/internal/IssuerList/IssuerList.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useState, useEffect, useCallback, useRef } from 'preact/hooks';\nimport useForm from '../../../utils/useForm';\nimport Field from '../FormFields/Field';\nimport IssuerButtonGroup from './IssuerButtonGroup';\nimport ContentSeparator from '../ContentSeparator';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ValidatorRules } from '../../../utils/Validator/types';\nimport { IssuerListProps } from './types';\nimport './IssuerList.scss';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport DisclaimerMessage from '../DisclaimerMessage';\nimport Select from '../FormFields/Select';\nimport { SelectTargetObject } from '../FormFields/Select/types';\nimport {\n ANALYTICS_DISPLAYED_STR,\n ANALYTICS_FEATURED_ISSUER,\n ANALYTICS_INPUT_STR,\n ANALYTICS_LIST,\n ANALYTICS_LIST_SEARCH,\n ANALYTICS_SEARCH_DEBOUNCE_TIME,\n ANALYTICS_SELECTED_STR\n} from '../../../core/Analytics/constants';\nimport { debounce } from '../../../utils/debounce';\n\nconst payButtonLabel = ({ issuer, items }, i18n): string => {\n const issuerName = items.find(i => i.id === issuer)?.name;\n if (!issuer || !issuerName) return i18n.get('continue');\n return `${i18n.get('continueTo')} ${issuerName}`;\n};\n\nconst schema = ['issuer'];\nconst validationRules: ValidatorRules = {\n issuer: {\n validate: issuer => !!issuer && issuer.length > 0,\n errorMessage: 'issuerList.selectField.contextualText',\n modes: ['blur']\n }\n};\n\nenum IssuerListInputTypes {\n ButtonGroup,\n Dropdown\n}\n\nfunction IssuerList({ items, placeholder, issuer, highlightedIds = [], showContextualElement, contextualText, ...props }: IssuerListProps) {\n const { i18n } = useCoreContext();\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm({\n schema,\n defaultData: { issuer },\n rules: validationRules\n });\n const [status, setStatus] = useState('ready');\n const [inputType, setInputType] = useState<IssuerListInputTypes>(IssuerListInputTypes.Dropdown);\n\n const { setSRMessagesFromObjects, shouldMoveFocusSR } = useSRPanelContext();\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({});\n\n const getErrorMessage = error => (error && error.errorMessage ? i18n.get(error.errorMessage) : !!error);\n\n this.setStatus = newStatus => {\n setStatus(newStatus);\n };\n\n const handleInputChange = useCallback(\n (type: IssuerListInputTypes) => (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n const target = type === IssuerListInputTypes.Dropdown ? ANALYTICS_LIST : ANALYTICS_FEATURED_ISSUER;\n const issuerObj = items.find(issuer => issuer.id === (event.target as SelectTargetObject).value);\n props.onSubmitAnalytics({ type: ANALYTICS_SELECTED_STR, target, issuer: issuerObj.name });\n\n setInputType(type);\n handleChangeFor('issuer')(event);\n },\n [handleChangeFor]\n );\n\n const handleListToggle = useCallback((isOpen: boolean) => {\n if (isOpen) {\n props.onSubmitAnalytics({ type: ANALYTICS_DISPLAYED_STR, target: ANALYTICS_LIST });\n }\n }, []);\n\n const debounceSearchAnalytics = useRef(debounce(props.onSubmitAnalytics, ANALYTICS_SEARCH_DEBOUNCE_TIME));\n\n const handleSearch = useCallback(() => {\n debounceSearchAnalytics.current({ type: ANALYTICS_INPUT_STR, target: ANALYTICS_LIST_SEARCH });\n }, []);\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({ errors, isValidating: true });\n if (srPanelResp?.action === ERROR_ACTION_FOCUS_FIELD) {\n // Focus field in error, if required\n if (shouldMoveFocusSR) setFocusOnField('.adyen-checkout__issuer-list', 'issuer-list');\n }\n }, [data, valid, errors, isValid]);\n\n this.showValidation = () => {\n triggerValidation();\n };\n\n const { highlightedItems } = items.reduce(\n (memo, item) => {\n if (highlightedIds.includes(item.id)) memo.highlightedItems.push({ ...item });\n return memo;\n },\n { highlightedItems: [] }\n );\n\n return (\n <div className=\"adyen-checkout__issuer-list\">\n {!!highlightedItems.length && (\n <Fragment>\n <IssuerButtonGroup\n selectedIssuerId={inputType === IssuerListInputTypes.ButtonGroup ? data['issuer'] : null}\n items={highlightedItems}\n onChange={handleInputChange(IssuerListInputTypes.ButtonGroup)}\n />\n <ContentSeparator />\n </Fragment>\n )}\n\n <Field\n label={i18n.get('issuerList.selectField.label')}\n errorMessage={getErrorMessage(errors.issuer)}\n classNameModifiers={['issuer-list']}\n name={'issuer'}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <Select\n items={items}\n selectedValue={inputType === IssuerListInputTypes.Dropdown ? data['issuer'] : null}\n placeholder={placeholder}\n name={'issuer'}\n className={'adyen-checkout__issuer-list__dropdown'}\n onChange={handleInputChange(IssuerListInputTypes.Dropdown)}\n onListToggle={handleListToggle}\n onInput={handleSearch}\n />\n </Field>\n\n {props.termsAndConditions && (\n <div className=\"adyen-checkout__issuer-list__termsAndConditions\">\n <DisclaimerMessage message={i18n.get(props.termsAndConditions.translationKey)} urls={props.termsAndConditions.urls} />\n </div>\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n label: payButtonLabel({ issuer: data['issuer'], items: [...items, ...highlightedItems] }, i18n)\n })}\n </div>\n );\n}\n\nIssuerList.defaultProps = {\n onChange: () => {}\n};\n\nexport default IssuerList;\n"],"names":["payButtonLabel","issuer","items","i18n","issuerName","find","i","id","name","get","schema","validationRules","validate","length","errorMessage","modes","IssuerList","_param","placeholder","highlightedIds","showContextualElement","contextualText","props","_object_without_properties","useCoreContext","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","defaultData","rules","status","setStatus","useState","inputType","setInputType","setSRMessagesFromObjects","shouldMoveFocusSR","useSRPanelContext","setSRMessages","this","newStatus","handleInputChange","useCallback","type","event","target","ANALYTICS_LIST","ANALYTICS_FEATURED_ISSUER","issuerObj","value","onSubmitAnalytics","ANALYTICS_SELECTED_STR","handleListToggle","isOpen","ANALYTICS_DISPLAYED_STR","debounceSearchAnalytics","useRef","debounce","ANALYTICS_SEARCH_DEBOUNCE_TIME","handleSearch","current","ANALYTICS_INPUT_STR","ANALYTICS_LIST_SEARCH","useEffect","onChange","srPanelResp","isValidating","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnField","showValidation","highlightedItems","reduce","memo","item","includes","push","_object_spread","h","div","className","Fragment","IssuerButtonGroup","selectedIssuerId","ContentSeparator","Field","label","error","classNameModifiers","Select","selectedValue","onListToggle","onInput","termsAndConditions","DisclaimerMessage","message","translationKey","urls","showPayButton","payButton","defaultProps"],"mappings":"+hDA6BA,MAAMA,EAAiB,EAAGC,SAAQC,SAASC,KACpBD,IAAAA,EAAnB,MAAME,EAAaF,QAAAA,EAAAA,EAAMG,MAAKC,GAAKA,EAAEC,KAAON,WAAzBC,IAAAA,OAAAA,EAAAA,EAAkCM,KACrD,OAAKP,GAAWG,EACT,GAAGD,EAAKM,IAAI,iBAAiBL,IADDD,EAAKM,IAAI,WACI,EAG9CC,EAAS,CAAC,UACVC,EAAkC,CACpCV,OAAQ,CACJW,SAAUX,KAAYA,GAAUA,EAAOY,OAAS,EAChDC,aAAc,wCACdC,MAAO,CAAC,UAShB,SAASC,EAAWC,GAAA,IAAAf,MAAEA,EAAKgB,YAAEA,EAAWjB,OAAEA,EAAMkB,eAAEA,EAAiB,GAAEC,sBAAEA,EAAqBC,eAAEA,GAA1EJ,EAA6FK,EAA7FC,EAAAN,EAAA,CAAEf,QAAOgB,cAAajB,SAAQkB,iBAAqBC,wBAAuBC,mBAC1F,MAAMlB,KAAEA,GAASqB,KACXC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAAQ,CACjFrB,SACAsB,YAAa,CAAE/B,UACfgC,MAAOtB,KAEJuB,EAAQC,GAAaC,EAAS,UAC9BC,EAAWC,GAAgBF,EAAAA,IAE5BG,yBAAEA,EAAwBC,kBAAEA,GAAsBC,IAClDC,EAAuCH,aAAAA,EAAAA,EAA2B,IAIxEI,KAAKR,UAAYS,IACbT,EAAUS,EAAAA,EAGd,MAAMC,EAAoBC,G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EkB9D,EAAO5B,OAnEf0F,IAASA,GAAM7E,aAAeX,EAAKM,IAAIkF,GAAM7E,gBAAkB6E,IAoErFC,mBAAoB,CAAC,eACrBpF,KAAM,SACNY,sBAAuBA,EACvBC,eAAgBA,GAEhB6D,EAACW,EAAAA,CACG3F,MAAOA,EACP4F,cAA6DnE,IAA9CU,EAA8CV,EAAK,OAAY,KAC9ET,YAAaA,EACbV,KAAM,SACN4E,UAAW,wCACXhB,SAAUvB,EAAAA,GACVkD,aAAcvC,EACdwC,QAASjC,MAIhBzC,EAAM2E,oBACHf,EAACC,MAAAA,CAAIC,UAAU,mDACXF,EAACgB,EAAAA,CAAkBC,QAAShG,EAAKM,IAAIa,EAAM2E,mBAAmBG,gBAAiBC,KAAM/E,EAAM2E,mBAAmBI,QAIrH/E,EAAMgF,eACHhF,EAAMiF,UAAU,CACZrE,SACAwD,MAAO1F,EAAe,CAAEC,OAAQ0B,EAAc,OAAEzB,MAAO,IAAIA,KAAUyE,KAAqBxE,MA9FlFwF,IAAAA,EAkG5B,CAEA3E,EAAWwF,aAAe,CACtBpC,SAAU"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useState as e,useMemo as r,useEffect as o}from"../../../external/preact/hooks/dist/hooks.js";import{enhanceErrorObjectKeys as t}from"../../../core/Errors/utils.js";import{COMPANY_DETAILS_SCHEMA as s}from"../CompanyDetails/CompanyDetails.js";import{PERSONAL_DETAILS_SCHEMA as
|
|
1
|
+
import{useState as e,useMemo as r,useEffect as o}from"../../../external/preact/hooks/dist/hooks.js";import{enhanceErrorObjectKeys as t}from"../../../core/Errors/utils.js";import{COMPANY_DETAILS_SCHEMA as s}from"../CompanyDetails/CompanyDetails.js";import{PERSONAL_DETAILS_SCHEMA as l}from"../PersonalDetails/PersonalDetails.js";import{ERROR_ACTION_BLUR_SCENARIO as i,ERROR_ACTION_FOCUS_FIELD as n}from"../../../core/Errors/constants.js";import c from"../../../core/Errors/useSRPanelContext.js";import a from"../Address/Specifications.js";import{setFocusOnField as d}from"../../../utils/setFocus.js";import{usePrevious as u}from"../../../utils/hookUtils.js";import{getArrayDifferences as f}from"../../../utils/arrayUtils.js";import{mapFieldKey as p}from"./utils.js";function y(e,r,o){return r in e?Object.defineProperty(e,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[r]=o,e}function m(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{},t=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(o).filter((function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable})))),t.forEach((function(r){y(e,r,o[r])}))}return e}function b(e,r){if(null==e)return{};var o,t,s=function(e,r){if(null==e)return{};var o,t,s={},l=Object.keys(e);for(t=0;t<l.length;t++)o=l[t],r.indexOf(o)>=0||(s[o]=e[o]);return s}(e,r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(t=0;t<l.length;t++)o=l[t],r.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(s[o]=e[o])}return s}const v=({errors:y,data:v,props:g,isValidating:j})=>{const[h,A]=e(null),F=u(h),{setSRMessagesFromObjects:O,setSRMessagesFromStrings:S,clearSRPanel:k,shouldMoveFocusSR:D}=c(),P=null==O?void 0:O({fieldTypeMappingFn:p}),w=r((()=>new a),[]),C=r((()=>new a(g.deliveryAddressSpecification)),[]);o((()=>{try{var e,r,o,c;const u="deliveryAddress:",p="billingAddress:",{companyDetails:h,personalDetails:O,bankAccount:E,billingAddress:T,deliveryAddress:x}=y,M=b(y,["companyDetails","personalDetails","bankAccount","billingAddress","deliveryAddress"]),R=t(T,p),$=t(x,u),L=m({},"object"==typeof h&&h,"object"==typeof O&&O,"object"==typeof E&&E,"object"==typeof R&&R,"object"==typeof $&&$,M),_=s;var a;const U=null!==(a=g.personalDetailsRequiredFields)&&void 0!==a?a:l,V=l.filter((e=>null==U?void 0:U.includes(e))),q=["holder","iban"],B=w.getAddressSchemaForCountryFlat(null===(e=v.billingAddress)||void 0===e?void 0:e.country).map((e=>`${p}${e}`)),I=C.getAddressSchemaForCountryFlat(null===(r=v.deliveryAddress)||void 0===r?void 0:r.country).map((e=>`${u}${e}`)),z=_.concat(V,q,B,I,["consentCheckbox"]),G=w.getAddressLabelsForCountry(null===(o=v.billingAddress)||void 0===o?void 0:o.country),H=C.getAddressLabelsForCountry(null===(c=v.deliveryAddress)||void 0===c?void 0:c.country),J=null==P?void 0:P({errors:L,isValidating:j.current,layout:z,countrySpecificLabels:m({},G,H)}),K=null==J?void 0:J.currentErrorsSortedByLayout;switch(A(K),null==J?void 0:J.action){case n:{const e=J.fieldToFocus.includes(":")?J.fieldToFocus.split(":")[1]:J.fieldToFocus;let r="";const o=J.fieldToFocus.includes(":")?J.fieldToFocus.split(":")[0]:"";o.length&&(r=`.adyen-checkout__fieldset--${o} `),D&&d(".adyen-checkout__open-invoice",e,r),setTimeout((()=>{j.current=!1}),300);break}case i:{const e=f(K,F,"field"),r=null==e?void 0:e[0];if(r){const e="shopperEmail"===r.field&&"field.error.invalid"===r.errorCode?r.errorMessage:null;S(e)}else k();break}}}catch(e){}}),[y,v])};export{v as default};
|
|
2
2
|
//# sourceMappingURL=useSRPanelForOpenInvoiceErrors.js.map
|
package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSRPanelForOpenInvoiceErrors.js","sources":["../../../../../src/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.ts"],"sourcesContent":["import { useEffect, useState, useMemo, MutableRef } from 'preact/hooks';\nimport { enhanceErrorObjectKeys } from '../../../core/Errors/utils';\nimport { COMPANY_DETAILS_SCHEMA } from '../CompanyDetails/CompanyDetails';\nimport { PERSONAL_DETAILS_SCHEMA } from '../PersonalDetails/PersonalDetails';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_BLUR_SCENARIO, ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport Specifications from '../Address/Specifications';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport { usePrevious } from '../../../utils/hookUtils';\nimport { getArrayDifferences } from '../../../utils/arrayUtils';\nimport { mapFieldKey } from './utils';\nimport { OpenInvoiceProps, OpenInvoiceStateData, OpenInvoiceStateError } from './types';\n\ninterface UseSRPanelForErrorsProps {\n errors: OpenInvoiceStateError;\n data: OpenInvoiceStateData;\n props: OpenInvoiceProps;\n isValidating: MutableRef<boolean>;\n}\n\nconst useSRPanelForOpenInvoiceErrors = ({ errors, data, props, isValidating }: UseSRPanelForErrorsProps) => {\n // Relates to onBlur errors\n const [sortedErrorList, setSortedErrorList] = useState(null);\n // Get the previous value (Relates to onBlur errors)\n const previousSortedErrors = usePrevious(sortedErrorList);\n const { setSRMessagesFromObjects, setSRMessagesFromStrings, clearSRPanel, shouldMoveFocusSR } = useSRPanelContext();\n // Generate a setSRMessages function - implemented as a partial, since the initial set of arguments don't change.\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({\n fieldTypeMappingFn: mapFieldKey\n });\n\n const billingAddressSpecifications = useMemo(() => new Specifications(), []);\n const deliveryAddressSpecifications = useMemo(() => new Specifications(props.deliveryAddressSpecification), []);\n\n useEffect(() => {\n try {\n const DELIVERY_ADDRESS_PREFIX = 'deliveryAddress:';\n const BILLING_ADDRESS_PREFIX = 'billingAddress:';\n\n /** Create messages for SRPanel */\n // Extract nested errors from the various child components...\n const {\n companyDetails: extractedCompanyDetailsErrors,\n personalDetails: extractedPersonalDetailsErrors,\n bankAccount: extractedBankAccountErrors,\n billingAddress: extractedBillingAddressErrors,\n deliveryAddress: extractedDeliveryAddressErrors,\n ...remainingErrors\n } = errors;\n\n // Differentiate between billingAddress and deliveryAddress errors by adding a prefix.\n // This also allows overlapping errors e.g. now that addresses can contain first & last name fields\n const enhancedBillingAddressErrors = enhanceErrorObjectKeys(extractedBillingAddressErrors, BILLING_ADDRESS_PREFIX);\n const enhancedDeliveryAddressErrors = enhanceErrorObjectKeys(extractedDeliveryAddressErrors, DELIVERY_ADDRESS_PREFIX);\n\n // ...and then collate the errors into a new object so that they all sit at top level\n const errorsForPanel = {\n ...(typeof extractedCompanyDetailsErrors === 'object' && extractedCompanyDetailsErrors),\n ...(typeof extractedPersonalDetailsErrors === 'object' && extractedPersonalDetailsErrors),\n ...(typeof extractedBankAccountErrors === 'object' && extractedBankAccountErrors),\n ...(typeof enhancedBillingAddressErrors === 'object' && enhancedBillingAddressErrors),\n ...(typeof enhancedDeliveryAddressErrors === 'object' && enhancedDeliveryAddressErrors),\n ...remainingErrors\n };\n\n // Create layout\n const companyDetailsLayout: string[] = COMPANY_DETAILS_SCHEMA;\n\n const personalDetailsReqFields: string[] = props.personalDetailsRequiredFields ?? PERSONAL_DETAILS_SCHEMA;\n const personalDetailLayout: string[] = PERSONAL_DETAILS_SCHEMA.filter(x => personalDetailsReqFields?.includes(x));\n\n const bankAccountLayout = ['holder', 'iban'];\n\n const billingAddressLayout = billingAddressSpecifications.getAddressSchemaForCountryFlat(data.billingAddress?.country);\n // In order to sort the address errors the layout entries need to have the same (prefixed) identifier as the errors themselves\n const billingAddressLayoutEnhanced = billingAddressLayout.map(item => `${BILLING_ADDRESS_PREFIX}${item}`);\n\n const deliveryAddressLayout = deliveryAddressSpecifications.getAddressSchemaForCountryFlat(data.deliveryAddress?.country);\n const deliveryAddressLayoutEnhanced = deliveryAddressLayout.map(item => `${DELIVERY_ADDRESS_PREFIX}${item}`);\n\n const fullLayout = companyDetailsLayout.concat(\n personalDetailLayout,\n bankAccountLayout,\n billingAddressLayoutEnhanced,\n deliveryAddressLayoutEnhanced,\n ['consentCheckbox']\n );\n\n // Country specific address labels\n const countrySpecificLabels_billing = billingAddressSpecifications.getAddressLabelsForCountry(data.billingAddress?.country);\n const countrySpecificLabels_delivery = deliveryAddressSpecifications.getAddressLabelsForCountry(data.deliveryAddress?.country);\n\n // Set messages: Pass dynamic props (errors, layout etc) to SRPanel via partial\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({\n errors: errorsForPanel,\n isValidating: isValidating.current,\n layout: fullLayout,\n countrySpecificLabels: { ...countrySpecificLabels_billing, ...countrySpecificLabels_delivery }\n });\n\n // Relates to onBlur errors\n const currentErrorsSortedByLayout = srPanelResp?.currentErrorsSortedByLayout;\n\n // Store the array of sorted error objects separately so that we can use it to make comparisons between the old and new arrays\n setSortedErrorList(currentErrorsSortedByLayout); // Relates to onBlur errors\n\n /**\n * Need extra actions after setting SRPanel messages in order to focus field (if required) and because we have some errors that are fired onBlur\n */\n switch (srPanelResp?.action) {\n // A call to focus the first field in error will always follow the call to validate the whole form\n case ERROR_ACTION_FOCUS_FIELD:\n // Focus first field in error, if required\n if (shouldMoveFocusSR) setFocusOnField('.adyen-checkout__open-invoice', srPanelResp.fieldToFocus);\n // Remove 'showValidation' mode - allowing time for collation of all the fields in error whilst it is 'showValidation' mode (some errors come in a second render pass)\n setTimeout(() => {\n isValidating.current = false;\n }, 300);\n break;\n\n /** On blur scenario: not validating, i.e. trying to submit form, but there might be an error, either to set or to clear */\n case ERROR_ACTION_BLUR_SCENARIO: {\n const difference = getArrayDifferences(currentErrorsSortedByLayout, previousSortedErrors, 'field');\n\n const latestErrorMsg = difference?.[0];\n\n if (latestErrorMsg) {\n // Is error actually a blur based one - depends on the specific fields in a component as to whether they validate on blur\n const isBlurBasedError = latestErrorMsg.errorCode === 'shopperEmail.invalid';\n\n // Only add blur based errors to the error panel - doing this step prevents the non-blur based errors from being read out twice\n const latestSRError = isBlurBasedError ? latestErrorMsg.errorMessage : null;\n setSRMessagesFromStrings(latestSRError);\n } else {\n // called when previousSortedErrors.length >= currentErrorsSortedByLayout.length\n clearSRPanel();\n }\n\n break;\n }\n default:\n break;\n }\n } catch (_) {\n // We don't handle the error related to the sr panel, let it fail silently.\n }\n }, [errors, data]);\n};\n\nexport default useSRPanelForOpenInvoiceErrors;\n"],"names":["useSRPanelForOpenInvoiceErrors","errors","data","props","isValidating","sortedErrorList","setSortedErrorList","useState","previousSortedErrors","usePrevious","setSRMessagesFromObjects","setSRMessagesFromStrings","clearSRPanel","shouldMoveFocusSR","useSRPanelContext","setSRMessages","fieldTypeMappingFn","mapFieldKey","billingAddressSpecifications","useMemo","Specifications","deliveryAddressSpecifications","deliveryAddressSpecification","useEffect","DELIVERY_ADDRESS_PREFIX","BILLING_ADDRESS_PREFIX","companyDetails","extractedCompanyDetailsErrors","personalDetails","extractedPersonalDetailsErrors","bankAccount","extractedBankAccountErrors","billingAddress","extractedBillingAddressErrors","deliveryAddress","extractedDeliveryAddressErrors","remainingErrors","enhancedBillingAddressErrors","enhanceErrorObjectKeys","enhancedDeliveryAddressErrors","errorsForPanel","_object_spread","companyDetailsLayout","COMPANY_DETAILS_SCHEMA","personalDetailsReqFields","personalDetailsRequiredFields","PERSONAL_DETAILS_SCHEMA","personalDetailLayout","filter","x","includes","bankAccountLayout","billingAddressLayoutEnhanced","getAddressSchemaForCountryFlat","country","map","item","deliveryAddressLayoutEnhanced","fullLayout","concat","countrySpecificLabels_billing","getAddressLabelsForCountry","countrySpecificLabels_delivery","srPanelResp","current","layout","countrySpecificLabels","currentErrorsSortedByLayout","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnField","fieldToFocus","setTimeout","ERROR_ACTION_BLUR_SCENARIO","difference","getArrayDifferences","latestErrorMsg","latestSRError","errorCode","errorMessage","_"],"mappings":"ijDAsBMA,MAAAA,EAAiC,EAAGC,SAAQC,OAAMC,QAAOC,mBAE3D,MAAOC,EAAiBC,GAAsBC,EAAS,MAEjDC,EAAuBC,EAAYJ,IACnCK,yBAAEA,EAAwBC,yBAAEA,EAAwBC,aAAEA,EAAYC,kBAAEA,GAAsBC,IAE1FC,EAAuCL,aAAAA,EAAAA,EAA2B,CACpEM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,EAAiCzC,EAA8BwC,2BAA+C,QAApB3D,EAAAA,EAAKgC,uBAALhC,IAAAA,OAAAA,EAAAA,EAAsBoD,SAGhHS,EAAyChD,aAAAA,EAAAA,EAAgB,CAC3Dd,OAAQuC,EACRpC,aAAcA,EAAa4D,QAC3BC,OAAQP,EACRQ,sBAAuBzB,KAAKmB,EAAkCE,KAI5DK,EAA8BJ,aAAAA,EAAAA,EAAaI,4BAQjD,OALA7D,EAAmB6D,GAKXJ,aAAAA,EAAAA,EAAaK,QAEjB,KAAKC,EAEGxD,GAAmByD,EAAgB,gCAAiCP,EAAYQ,cAEpFC,YAAW,KACPpE,EAAa4D,SAAU,CAAA,GACxB,KACH,MAGJ,KAAKS,EAA4B,CAC7B,MAAMC,EAAaC,EAAoBR,EAA6B3D,EAAsB,SAEpFoE,EAAiBF,aAAAA,EAAAA,EAAa,GAEpC,GAAIE,EAAgB,CAEhB,MAGMC,EAHgD,yBAA7BD,EAAeE,UAGCF,EAAeG,aAAe,KACvEpE,EAAyBkE,QAGzBjE,IAGJ,KACJ,EAIR,CAAE,MAAOoE,GAET,IACD,CAAC/E,EAAQC,GAAK"}
|
|
1
|
+
{"version":3,"file":"useSRPanelForOpenInvoiceErrors.js","sources":["../../../../../src/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.ts"],"sourcesContent":["import { useEffect, useState, useMemo, MutableRef } from 'preact/hooks';\nimport { enhanceErrorObjectKeys } from '../../../core/Errors/utils';\nimport { COMPANY_DETAILS_SCHEMA } from '../CompanyDetails/CompanyDetails';\nimport { PERSONAL_DETAILS_SCHEMA } from '../PersonalDetails/PersonalDetails';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_BLUR_SCENARIO, ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport Specifications from '../Address/Specifications';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport { usePrevious } from '../../../utils/hookUtils';\nimport { getArrayDifferences } from '../../../utils/arrayUtils';\nimport { mapFieldKey } from './utils';\nimport { OpenInvoiceProps, OpenInvoiceStateData, OpenInvoiceStateError } from './types';\n\ninterface UseSRPanelForErrorsProps {\n errors: OpenInvoiceStateError;\n data: OpenInvoiceStateData;\n props: OpenInvoiceProps;\n isValidating: MutableRef<boolean>;\n}\n\nconst useSRPanelForOpenInvoiceErrors = ({ errors, data, props, isValidating }: UseSRPanelForErrorsProps) => {\n // Relates to onBlur errors\n const [sortedErrorList, setSortedErrorList] = useState(null);\n // Get the previous value (Relates to onBlur errors)\n const previousSortedErrors = usePrevious(sortedErrorList);\n const { setSRMessagesFromObjects, setSRMessagesFromStrings, clearSRPanel, shouldMoveFocusSR } = useSRPanelContext();\n // Generate a setSRMessages function - implemented as a partial, since the initial set of arguments don't change.\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({\n fieldTypeMappingFn: mapFieldKey\n });\n\n const billingAddressSpecifications = useMemo(() => new Specifications(), []);\n const deliveryAddressSpecifications = useMemo(() => new Specifications(props.deliveryAddressSpecification), []);\n\n useEffect(() => {\n try {\n const DELIVERY_ADDRESS_PREFIX = 'deliveryAddress:';\n const BILLING_ADDRESS_PREFIX = 'billingAddress:';\n\n /** Create messages for SRPanel */\n // Extract nested errors from the various child components...\n const {\n companyDetails: extractedCompanyDetailsErrors,\n personalDetails: extractedPersonalDetailsErrors,\n bankAccount: extractedBankAccountErrors,\n billingAddress: extractedBillingAddressErrors,\n deliveryAddress: extractedDeliveryAddressErrors,\n ...remainingErrors\n } = errors;\n\n // Differentiate between billingAddress and deliveryAddress errors by adding a prefix.\n // This also allows overlapping errors e.g. now that addresses can contain first & last name fields\n const enhancedBillingAddressErrors = enhanceErrorObjectKeys(extractedBillingAddressErrors, BILLING_ADDRESS_PREFIX);\n const enhancedDeliveryAddressErrors = enhanceErrorObjectKeys(extractedDeliveryAddressErrors, DELIVERY_ADDRESS_PREFIX);\n\n // ...and then collate the errors into a new object so that they all sit at top level\n const errorsForPanel = {\n ...(typeof extractedCompanyDetailsErrors === 'object' && extractedCompanyDetailsErrors),\n ...(typeof extractedPersonalDetailsErrors === 'object' && extractedPersonalDetailsErrors),\n ...(typeof extractedBankAccountErrors === 'object' && extractedBankAccountErrors),\n ...(typeof enhancedBillingAddressErrors === 'object' && enhancedBillingAddressErrors),\n ...(typeof enhancedDeliveryAddressErrors === 'object' && enhancedDeliveryAddressErrors),\n ...remainingErrors\n };\n\n // Create layout\n const companyDetailsLayout: string[] = COMPANY_DETAILS_SCHEMA;\n\n const personalDetailsReqFields: string[] = props.personalDetailsRequiredFields ?? PERSONAL_DETAILS_SCHEMA;\n const personalDetailLayout: string[] = PERSONAL_DETAILS_SCHEMA.filter(x => personalDetailsReqFields?.includes(x));\n\n const bankAccountLayout = ['holder', 'iban'];\n\n const billingAddressLayout = billingAddressSpecifications.getAddressSchemaForCountryFlat(data.billingAddress?.country);\n // In order to sort the address errors the layout entries need to have the same (prefixed) identifier as the errors themselves\n const billingAddressLayoutEnhanced = billingAddressLayout.map(item => `${BILLING_ADDRESS_PREFIX}${item}`);\n\n const deliveryAddressLayout = deliveryAddressSpecifications.getAddressSchemaForCountryFlat(data.deliveryAddress?.country);\n const deliveryAddressLayoutEnhanced = deliveryAddressLayout.map(item => `${DELIVERY_ADDRESS_PREFIX}${item}`);\n\n const fullLayout = companyDetailsLayout.concat(\n personalDetailLayout,\n bankAccountLayout,\n billingAddressLayoutEnhanced,\n deliveryAddressLayoutEnhanced,\n ['consentCheckbox']\n );\n\n // Country specific address labels\n const countrySpecificLabels_billing = billingAddressSpecifications.getAddressLabelsForCountry(data.billingAddress?.country);\n const countrySpecificLabels_delivery = deliveryAddressSpecifications.getAddressLabelsForCountry(data.deliveryAddress?.country);\n\n // Set messages: Pass dynamic props (errors, layout etc) to SRPanel via partial\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({\n errors: errorsForPanel,\n isValidating: isValidating.current,\n layout: fullLayout,\n countrySpecificLabels: { ...countrySpecificLabels_billing, ...countrySpecificLabels_delivery }\n });\n\n // Relates to onBlur errors\n const currentErrorsSortedByLayout = srPanelResp?.currentErrorsSortedByLayout;\n\n // Store the array of sorted error objects separately so that we can use it to make comparisons between the old and new arrays\n setSortedErrorList(currentErrorsSortedByLayout); // Relates to onBlur errors\n\n /**\n * Need extra actions after setting SRPanel messages in order to focus field (if required) and because we have some errors that are fired onBlur\n */\n switch (srPanelResp?.action) {\n // A call to focus the first field in error will always follow the call to validate the whole form\n case ERROR_ACTION_FOCUS_FIELD: {\n /**\n * For prefixed fields (ones that can occur twice but in different contexts i.e. billingAddress & deliveryAddress) - consider the prefix...\n */\n // ...Firstly strip it to gain a \"clean\" reference to the field...\n const fieldToFocus = srPanelResp.fieldToFocus.includes(':') ? srPanelResp.fieldToFocus.split(':')[1] : srPanelResp.fieldToFocus; // country, street etc\n\n // ...Secondly use the prefix to add context for when we try to select it\n let focusContextSelector = '';\n const focusContext = srPanelResp.fieldToFocus.includes(':') ? srPanelResp.fieldToFocus.split(':')[0] : ''; // 'billingAddress' | 'deliveryAddress'\n if (focusContext.length) {\n focusContextSelector = `.adyen-checkout__fieldset--${focusContext} `;\n }\n\n // Focus first field in error, if required\n if (shouldMoveFocusSR) setFocusOnField('.adyen-checkout__open-invoice', fieldToFocus, focusContextSelector);\n // Remove 'showValidation' mode - allowing time for collation of all the fields in error whilst it is 'showValidation' mode (some errors come in a second render pass)\n setTimeout(() => {\n isValidating.current = false;\n }, 300);\n break;\n }\n\n /**\n * Relates to errors triggered by a field blurring (some pm forms have this, some don't) - check if there is an error to either set or to clear\n */\n case ERROR_ACTION_BLUR_SCENARIO: {\n const difference = getArrayDifferences(currentErrorsSortedByLayout, previousSortedErrors, 'field');\n\n const latestErrorMsg = difference?.[0];\n\n if (latestErrorMsg) {\n // Is error actually a blur based one - depends on the specific fields in a component as to whether they validate on blur\n const isBlurBasedError = latestErrorMsg.field === 'shopperEmail' && latestErrorMsg.errorCode === 'field.error.invalid';\n\n // Only add blur based errors to the error panel - doing this step prevents the non-blur based errors from being read out twice\n const latestSRError = isBlurBasedError ? latestErrorMsg.errorMessage : null;\n setSRMessagesFromStrings(latestSRError);\n } else {\n // called when previousSortedErrors.length >= currentErrorsSortedByLayout.length\n clearSRPanel();\n }\n\n break;\n }\n default:\n break;\n }\n } catch (_) {\n // We don't handle the error related to the sr panel, let it fail silently.\n }\n }, [errors, data]);\n};\n\nexport default useSRPanelForOpenInvoiceErrors;\n"],"names":["useSRPanelForOpenInvoiceErrors","errors","data","props","isValidating","sortedErrorList","setSortedErrorList","useState","previousSortedErrors","usePrevious","setSRMessagesFromObjects","setSRMessagesFromStrings","clearSRPanel","shouldMoveFocusSR","useSRPanelContext","setSRMessages","fieldTypeMappingFn","mapFieldKey","billingAddressSpecifications","useMemo","Specifications","deliveryAddressSpecifications","deliveryAddressSpecification","useEffect","DELIVERY_ADDRESS_PREFIX","BILLING_ADDRESS_PREFIX","companyDetails","extractedCompanyDetailsErrors","personalDetails","extractedPersonalDetailsErrors","bankAccount","extractedBankAccountErrors","billingAddress","extractedBillingAddressErrors","deliveryAddress","extractedDeliveryAddressErrors","remainingErrors","enhancedBillingAddressErrors","enhanceErrorObjectKeys","enhancedDeliveryAddressErrors","errorsForPanel","_object_spread","companyDetailsLayout","COMPANY_DETAILS_SCHEMA","personalDetailsReqFields","personalDetailsRequiredFields","PERSONAL_DETAILS_SCHEMA","personalDetailLayout","filter","x","includes","bankAccountLayout","billingAddressLayoutEnhanced","getAddressSchemaForCountryFlat","country","map","item","deliveryAddressLayoutEnhanced","fullLayout","concat","countrySpecificLabels_billing","getAddressLabelsForCountry","countrySpecificLabels_delivery","srPanelResp","current","layout","countrySpecificLabels","currentErrorsSortedByLayout","action","ERROR_ACTION_FOCUS_FIELD","fieldToFocus","split","focusContextSelector","focusContext","length","setFocusOnField","setTimeout","ERROR_ACTION_BLUR_SCEN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AAE,MAAOyE,GAET,IACD,CAACpF,EAAQC,GAAK"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../external/preact/dist/preact.js";import{useEffect as r,useRef as t,useCallback as o}from"../../../external/preact/hooks/dist/hooks.js";import n from"../../../utils/useForm/useForm.js";import{useCoreContext as i}from"../../../core/Context/CoreProvider.js";import{
|
|
1
|
+
import{createElement as e}from"../../../external/preact/dist/preact.js";import{useEffect as r,useRef as t,useCallback as o}from"../../../external/preact/hooks/dist/hooks.js";import n from"../../../utils/useForm/useForm.js";import{useCoreContext as i}from"../../../core/Context/CoreProvider.js";import{phoneFormatters as s,phoneValidationRules as l}from"./validate.js";import a from"../FormFields/Fieldset/Fieldset.js";import u from"./PhoneInputFields.js";function c(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function p(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),o.forEach((function(r){c(e,r,t[r])}))}return e}function f(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})),e}function m(c){var m,d;const{i18n:b}=i(),h=c.requiredFields||[...(null==c||null===(m=c.items)||void 0===m?void 0:m.length)?["phonePrefix"]:[],"phoneNumber"],O=h.includes("phonePrefix")&&!!(null==c||null===(d=c.items)||void 0===d?void 0:d.length),j=h.includes("phoneNumber"),y=n(f(p({i18n:b},c),{schema:h,defaultData:c.data,rules:l,formatters:s}));r((()=>{y.setSchema(h)}),[h.toString()]);const{data:g,valid:P,errors:v,isValid:w,triggerValidation:x}=y;r((()=>{c.onChange({data:g,valid:P,errors:v,isValid:w})}),[g,P,v,w]);const F=t({showValidation:x});r((()=>{c.setComponentRef(F.current)}),[c.setComponentRef]);const E=o((e=>{if(v[e]){const t="phoneNumber"===e?"phoneNumberErrorKey":"phonePrefixErrorKey",o=c[t]?c[t]:v[e].errorMessage;var r;return null!==(r=b.get(o))&&void 0!==r?r:null}return null}),[v]);return e(a,{classNameModifiers:["phone-input"]},e(u,p({getError:E,showNumber:j,showPrefix:O,form:y},c)))}m.defaultProps={phoneLabel:"telephoneNumber"};export{m as default};
|
|
2
2
|
//# sourceMappingURL=PhoneInputForm.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Component as t,createElement as e}from"../../../external/preact/dist/preact.js";import o from"../Countdown/index.js";import r from"../Button/Button.js";import s from"../Spinner/Spinner.js";import a from"../../../core/Services/payment-status.js";import{processResponse as i}from"../../../core/ProcessResponse/process-response.js";import{copyToClipboard as n}from"../../../utils/clipboard.js";import c from"../../../core/Errors/AdyenCheckoutError.js";import{useCoreContext as p}from"../../../core/Context/CoreProvider.js";import d from"../ContentSeparator/ContentSeparator.js";import l from"../../../core/Context/useImage.js";import{useA11yReporter as m}from"../../../core/Errors/useA11yReporter.js";import u from"../../../utils/useAutoFocus.js";import{
|
|
1
|
+
import{Component as t,createElement as e}from"../../../external/preact/dist/preact.js";import o from"../Countdown/index.js";import r from"../Button/Button.js";import s from"../Spinner/Spinner.js";import a from"../../../core/Services/payment-status.js";import{processResponse as i}from"../../../core/ProcessResponse/process-response.js";import{copyToClipboard as n}from"../../../utils/clipboard.js";import c from"../../../core/Errors/AdyenCheckoutError.js";import{useCoreContext as p}from"../../../core/Context/CoreProvider.js";import d from"../ContentSeparator/ContentSeparator.js";import l from"../../../core/Context/useImage.js";import{useA11yReporter as m}from"../../../core/Errors/useA11yReporter.js";import u from"../../../utils/useAutoFocus.js";import{ANALYTICS_QR_CODE_DOWNLOAD as h,ANALYTICS_DOWNLOAD_STR as _}from"../../../core/Analytics/constants.js";import{PREFIX as y}from"../Icon/constants.js";function g(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class f extends t{componentDidMount(){this.statusInterval()}componentWillUnmount(){clearTimeout(this.timeoutId)}pollStatus(t){clearTimeout(this.timeoutId),this.timeoutId=setTimeout((async()=>{const t=performance.now();await this.checkStatus();const e=performance.now();this.statusInterval(Math.round(e-t))}),t)}render({amount:t,url:a,brandLogo:i,brandName:c,countdownTime:g,type:f,onActionHandled:k},{expired:v,completed:q,loading:b}){var C,N,w,T;const{i18n:I,loadingContext:j}=p(),S=l(),x=this.props.qrCodeData?`${j}utility/v1/barcode.png?type=qrCode&data=${this.props.qrCodeData}&clientKey=${this.props.clientKey}`:this.props.qrCodeImage,E=(t,o)=>{const r=I.get(o);return m(r),e("div",{className:"adyen-checkout__qr-loader adyen-checkout__qr-loader--result"},e("img",{className:"adyen-checkout__qr-loader__icon adyen-checkout__qr-loader__icon--result",src:S({imageFolder:"components/"})(t),alt:r}),e("div",{className:"adyen-checkout__qr-loader__subtitle"},r))};if(v)return E("error","error.subtitle.payment");if(q)return E("success","creditCard.success");if(b)return e("div",{className:"adyen-checkout__qr-loader"},i&&e("div",{className:"adyen-checkout__qr-loader__brand-logo-wrapper"},e("img",{alt:c,src:i,className:"adyen-checkout__qr-loader__brand-logo"})),e(s,null));const P=I.get(this.props.timeToPay).split("%@"),D=u(),A=this.props.classNameModifiers.map((t=>`adyen-checkout__qr-loader--${t}`));return e("div",{className:`adyen-checkout__qr-loader adyen-checkout__qr-loader--${f} ${A.join(" ")}`},i&&e("div",{className:"adyen-checkout__qr-loader__brand-logo-wrapper"},e("img",{src:i,alt:c,className:"adyen-checkout__qr-loader__brand-logo"})),t&&t.value&&t.currency&&e("div",{className:"adyen-checkout__qr-loader__payment_amount"},I.amount(t.value,t.currency)),a&&e("div",{className:"adyen-checkout__qr-loader__app-link"},this.props.redirectIntroduction&&e("div",{className:"adyen-checkout__qr-loader__subtitle"},I.get(this.props.redirectIntroduction)),e(r,{classNameModifiers:["qr-loader"],onClick:()=>this.redirectToApp(a),label:I.get(this.props.buttonLabel)}),e(d,null)),e("div",{ref:D,tabIndex:0,className:"adyen-checkout__qr-loader__subtitle"},"string"==typeof this.props.introduction?I.get(this.props.introduction):null===(C=(N=this.props).introduction)||void 0===C?void 0:C.call(N)),e("img",{src:x,alt:I.get("wechatpay.scanqrcode"),onLoad:()=>{null==k||k({componentType:this.props.type,actionDescription:"qr-code-loaded"})}}),e("div",{className:"adyen-checkout__qr-loader__progress"},e("span",{className:"adyen-checkout__qr-loader__percentage",style:{width:`${this.state.percentage}%`}})),e("div",{className:"adyen-checkout__qr-loader__countdown"},P[0]," ",e(o,{minutesFromNow:g,onTick:this.onTick,onCompleted:this.onTimeUp})," ",P[1]),this.props.instructions&&e("div",{className:"adyen-checkout__qr-loader__instructions"},"string"==typeof this.props.instructions?I.get(this.props.instructions):null===(w=(T=this.props).instructions)||void 0===w?void 0:w.call(T)),this.props.copyBtn&&e("div",{className:"adyen-checkout__qr-loader__actions"},e(r,{inline:!0,variant:"action",onClick:(t,{complete:e})=>{n(this.props.qrCodeData),this.props.onSubmitAnalytics({type:_,target:h}),e()},icon:S({imageFolder:"components/"})(`${y}copy`),label:I.get("button.copy")})))}constructor(t){super(t),g(this,"timeoutId",void 0),g(this,"redirectToApp",(t=>{window.location.assign(t)})),g(this,"statusInterval",((t=0)=>{if(this.state.expired||this.state.completed)return;this.setState((e=>({timePassed:e.timePassed+this.props.delay+t})));const e=this.state.timePassed>=this.props.throttleTime?this.props.throttledInterval:this.state.delay;this.pollStatus(e)})),g(this,"onTick",(t=>{this.setState({percentage:t.percentage})})),g(this,"onTimeUp",(()=>{this.setState({expired:!0}),clearTimeout(this.timeoutId),this.props.onError(new c("ERROR","Payment Expired"))})),g(this,"onComplete",(t=>{clearTimeout(this.timeoutId),this.setState({completed:!0,loading:!1});const e={data:{details:{payload:t.props.payload},paymentData:this.props.paymentData}};this.props.onComplete(e,this)})),g(this,"onError",(t=>{if(clearTimeout(this.timeoutId),this.setState({expired:!0,loading:!1}),t.props.payload){const e={data:{details:{payload:t.props.payload},paymentData:this.props.paymentData}};this.props.onComplete(e,this)}const e=new c("ERROR","error result with no payload in response");return this.props.onError(e)})),g(this,"checkStatus",(()=>{const{paymentData:t,clientKey:e,loadingContext:o,throttledInterval:r}=this.props;return a(t,e,o,r).then(i).catch((t=>({type:"network-error",props:t}))).then((t=>{switch(t.type){case"success":this.onComplete(t);break;case"error":this.onError(t);break;default:this.setState({loading:!1})}return t}))})),this.state={buttonStatus:"default",completed:!1,delay:t.delay,expired:!1,loading:!0,percentage:100,timePassed:0}}}g(f,"defaultProps",{delay:2e3,countdownTime:15,onError:()=>{},onComplete:()=>{},throttleTime:6e4,classNameModifiers:[],throttledInterval:1e4,introduction:"wechatpay.scanqrcode",timeToPay:"wechatpay.timetopay",buttonLabel:"openApp"});export{f as default};
|
|
2
2
|
//# sourceMappingURL=QRLoader.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Component as t}from"../../../../external/preact/dist/preact.js";import{getFields as s,validFieldsReducer as e,getErrorReducer as i,getErrorObject as o}from"./SFPUtils.js";import r from"../lib/CSF/initCSF.js";import n from"./SecuredFieldsProviderHandlers.js";import d from"./defaultProps.js";import{ENCRYPTED_PWD_FIELD as a,ENCRYPTED_CARD_NUMBER as h,DEDICATED_CARD_COMPONENTS as l,
|
|
1
|
+
import{Component as t}from"../../../../external/preact/dist/preact.js";import{getFields as s,validFieldsReducer as e,getErrorReducer as i,getErrorObject as o}from"./SFPUtils.js";import r from"../lib/CSF/initCSF.js";import n from"./SecuredFieldsProviderHandlers.js";import d from"./defaultProps.js";import{ENCRYPTED_PWD_FIELD as a,ENCRYPTED_CARD_NUMBER as h,DEDICATED_CARD_COMPONENTS as l,DATE_POLICY_REQUIRED as p,CVC_POLICY_REQUIRED as c}from"../lib/constants.js";import u from"../../../../core/Errors/AdyenCheckoutError.js";import{getErrorMessageFromCode as f}from"../../../../core/Errors/utils.js";import{SF_ErrorCodes as m}from"../../../../core/Errors/constants.js";function O(t,s,e){return s in t?Object.defineProperty(t,s,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[s]=e,t}function y(t){for(var s=1;s<arguments.length;s++){var e=null!=arguments[s]?arguments[s]:{},i=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(e).filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})))),i.forEach((function(s){O(t,s,e[s])}))}return t}function F(t,s){return s=null!=s?s:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):function(t){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);s.push.apply(s,e)}return s}(Object(s)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))})),t}class C extends t{componentDidMount(){this.props.rootNode&&this.setRootNode(this.props.rootNode);const t=s(this.rootNode),i=t.reduce(e,{});this.setState({valid:i}),t.forEach((t=>{this.numCharsInField[t]=0})),this.numDateFields=t.filter((t=>t.match(/Expiry/))).length,t.length?(this.destroy(),this.initializeCSF(this.rootNode)):this.handleOnNoDataRequired()}componentDidUpdate(){this.checkForKCPFields()}componentWillUnmount(){this.csf=null,clearTimeout(this.csfLoadFailTimeout),clearTimeout(this.csfConfigFailTimeout)}initializeCSF(t){let s=this.props.loadingContext;var e;const i={rootNode:t,type:this.props.type,clientKey:this.props.clientKey,cardGroupTypes:this.props.brands,autoFocus:this.props.autoFocus,trimTrailingSeparator:this.props.trimTrailingSeparator,loadingContext:s,keypadFix:this.props.keypadFix,showWarnings:this.props.showWarnings,iframeUIConfig:{sfStyles:this.props.styles},i18n:this.props.i18n,callbacks:{onLoad:this.handleOnLoad,onConfigSuccess:this.handleOnConfigSuccess,onFieldValid:this.handleOnFieldValid,onAllValid:this.handleOnAllValid,onBrand:this.handleOnBrand,onError:this.handleOnError,onFocus:this.handleFocus,onBinValue:this.props.onBinValue,onAutoComplete:this.handleOnAutoComplete,onAdditionalSFConfig:this.props.onAdditionalSFConfig,onAdditionalSFRemoved:this.props.onAdditionalSFRemoved,onTouchstartIOS:this.handleOnTouchstartIOS,onKeyPressed:this.handleKeyPressed},isKCP:this.state.hasKoreanFields,legacyInputMode:this.props.legacyInputMode,minimumExpiryDate:this.props.minimumExpiryDate,implementationType:this.props.implementationType||"components",forceCompat:this.props.forceCompat,maskSecurityCode:this.props.maskSecurityCode,exposeExpiryDate:this.props.exposeExpiryDate,shouldDisableIOSArrowKeys:!!this.props.disableIOSArrowKeys,placeholders:null!==(e=this.props.placeholders)&&void 0!==e?e:{},showContextualElement:this.props.showContextualElement};this.csf=r(i),this.csfLoadFailTimeout=setTimeout((()=>{"ready"!==this.state.status&&(this.setState({status:"csfLoadFailure"}),this.props.onError(new u("ERROR","secured field iframes have failed to load")))}),this.csfLoadFailTimeoutMS)}checkForKCPFields(){let t=!1;if(this.props.koreanAuthenticationRequired&&(t=this.issuingCountryCode?"kr"===this.issuingCountryCode:"kr"===this.props.countryCode),this.state.hasKoreanFields&&!t){const t=t=>({data:F(y({},t.data),{[a]:void 0}),valid:F(y({},t.valid),{[a]:!1}),errors:F(y({},t.errors),{[a]:!1}),hasKoreanFields:!1});this.setState(t,(()=>{this.props.onChange(this.state)})),this.csf.removeSecuredField(a),this.csf.setKCPStatus(!1)}if(!this.state.hasKoreanFields&&t){const t=t=>({valid:F(y({},t.valid),{[a]:!1}),hasKoreanFields:!0,isSfpValid:!1});this.setState(t,(()=>{this.props.onChange(this.state)})),this.csf.addSecuredField(a),this.csf.setKCPStatus(!0)}}getChildContext(){return{i18n:this.props.i18n}}handleUnsupportedCard(t){const s=!!t.error;return s&&this.setState({detectedUnsupportedBrands:t.detectedBrands}),t.rootNode=this.rootNode,this.handleOnError(t,s),this.csf&&this.csf.hasUnsupportedCard(h,t.error),s}setFocusOn(t){this.csf&&this.csf.setFocusOnFrame(t)}updateStyles(t){this.csf&&this.csf.updateStyles(t)}sfIsOptionalOrHidden(t){return this.csf.sfIsOptionalOrHidden(t)}destroy(){this.csf&&this.csf.destroy()}showValidation(){const{numDateFields:t,state:s}=this;Object.keys(s.valid).reduce(i(t,s),[]).forEach((t=>{const e=o(t,this.rootNode,s);this.handleOnError(e,!!s.detectedUnsupportedBrands),this.csf&&this.csf.isValidated&&this.csf.isValidated(t,e.error)}))}mapErrorsToValidationRuleResult(){return Object.keys(this.state.errors).reduce(((t,s)=>{const e=this.state.errors[s];return t[s]=e?y({isValid:!1,errorMessage:f(e,m),errorI18n:this.props.i18n.get(e),error:e,rootNode:this.rootNode},this.state.detectedUnsupportedBrands&&{detectedBrands:this.state.detectedUnsupportedBrands}):null,t}),{})}processBinLookupResponse(t,s){var e;if(this.state.detectedUnsupportedBrands&&(this.setState((t=>({errors:F(y({},t.errors),{[h]:!1}),detectedUnsupportedBrands:null}))),this.csf&&t)){const t={type:"card",fieldType:"encryptedCardNumber",error:""};this.handleUnsupportedCard(t)}this.issuingCountryCode=null==t||null===(e=t.issuingCountryCode)||void 0===e?void 0:e.toLowerCase();const i=(null==s?void 0:s.brand)&&l.includes(s.brand);i&&this.setState(s,(()=>{this.props.onChange(this.state)})),this.csf&&this.csf.brandsFromBinLookup(t,i?s:null)}render(t,s){return t.render({setRootNode:this.setRootNode,setFocusOn:this.setFocusOn},s)}constructor(t){super(t),O(this,"csfLoadFailTimeout",void 0),O(this,"csfLoadFailTimeoutMS",void 0),O(this,"csfConfigFailTimeout",void 0),O(this,"csfConfigFailTimeoutMS",void 0),O(this,"numCharsInField",void 0),O(this,"rootNode",void 0),O(this,"numDateFields",void 0),O(this,"csf",void 0),O(this,"handleOnLoad",void 0),O(this,"handleOnConfigSuccess",void 0),O(this,"handleOnFieldValid",void 0),O(this,"handleOnAllValid",void 0),O(this,"handleOnBrand",void 0),O(this,"handleFocus",void 0),O(this,"handleOnError",void 0),O(this,"handleOnAutoComplete",void 0),O(this,"handleOnNoDataRequired",void 0),O(this,"handleOnTouchstartIOS",void 0),O(this,"handleKeyPressed",void 0),O(this,"state",void 0),O(this,"props",void 0),O(this,"issuingCountryCode",void 0),O(this,"setRootNode",(t=>{this.rootNode=t}));const s={status:"loading",brand:t.type,errors:{},valid:{},data:{},cvcPolicy:c,expiryDatePolicy:p,isSfpValid:!1,hasKoreanFields:t.hasKoreanFields};this.state=s,this.csfLoadFailTimeout=null,this.csfLoadFailTimeoutMS=3e4,this.csfConfigFailTimeout=null,this.csfConfigFailTimeoutMS=15e3,this.numCharsInField={},this.handleOnLoad=n.handleOnLoad.bind(this),this.handleOnConfigSuccess=n.handleOnConfigSuccess.bind(this),this.handleOnFieldValid=n.handleOnFieldValid.bind(this),this.handleOnAllValid=n.handleOnAllValid.bind(this),this.handleOnBrand=n.handleOnBrand.bind(this),this.handleFocus=n.handleFocus.bind(this),this.handleOnError=n.handleOnError.bind(this),this.handleOnNoDataRequired=n.handleOnNoDataRequired.bind(this),this.handleOnAutoComplete=n.handleOnAutoComplete.bind(this),this.handleOnTouchstartIOS=n.handleOnTouchstartIOS.bind(this),this.handleKeyPressed=n.handleKeyPressed.bind(this),this.processBinLookupResponse=this.processBinLookupResponse.bind(this),this.setFocusOn=this.setFocusOn.bind(this),this.updateStyles=this.updateStyles.bind(this),this.handleUnsupportedCard=this.handleUnsupportedCard.bind(this),this.showValidation=this.showValidation.bind(this),this.destroy=this.destroy.bind(this)}}O(C,"defaultProps",d);export{C as default};
|
|
2
2
|
//# sourceMappingURL=SecuredFieldsProvider.js.map
|
package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getCardImageUrl as e}from"../utils.js";import{ENCRYPTED_CARD_NUMBER as t,ENCRYPTED_SECURITY_CODE as r,ENCRYPTED_EXPIRY_DATE as n,ENCRYPTED_EXPIRY_MONTH as i,ENCRYPTED_EXPIRY_YEAR as s,
|
|
1
|
+
import{getCardImageUrl as e}from"../utils.js";import{ENCRYPTED_CARD_NUMBER as t,ENCRYPTED_SECURITY_CODE as r,ENCRYPTED_EXPIRY_DATE as n,ENCRYPTED_EXPIRY_MONTH as i,ENCRYPTED_EXPIRY_YEAR as s,DATE_POLICY_REQUIRED as o,CVC_POLICY_REQUIRED as a,OPTIONAL as l,HIDDEN as d}from"../lib/constants.js";import{existy as u}from"../../../../utils/commonUtils.js";import c from"../../../../core/Errors/AdyenCheckoutError.js";function p(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){p(e,t,r[t])}))}return e}function f(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 r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}function y(e,t,r,n){return(t!==l&&t!==d||0!==r[e])&&n[e]}var m={handleFocus:function(e){this.numCharsInField[e.fieldType]=e.numChars,this.props.onFocus(e)},handleOnAllValid:function(e){return!this.state.detectedUnsupportedBrands&&(this.setState({isSfpValid:e.allValid},(()=>{this.props.onChange(this.state,{event:"handleOnAllValid"}),this.props.onAllValid(e)})),!0)},handleOnAutoComplete:function(e){this.setState({autoCompleteName:e.value},(()=>{this.props.onChange(this.state,{event:"handleOnAutoComplete",fieldType:e.fieldType}),this.setState({autoCompleteName:null})})),this.props.onAutoComplete(e)},handleOnFieldValid:function(e){return(!this.state.detectedUnsupportedBrands||e.fieldType!==t)&&(this.setState((t=>{var r;return{data:f(h({},t.data),{[e.encryptedFieldName]:e.blob}),valid:f(h({},t.valid),{[e.encryptedFieldName]:e.valid}),errors:f(h({},t.errors),{[e.fieldType]:null!==(r=t.errors[e.fieldType])&&void 0!==r&&r})}}),(()=>{this.props.onChange(this.state,{event:"handleOnFieldValid",fieldType:e.fieldType}),this.props.onFieldValid(e)})),!0)},handleOnLoad:function(e){clearTimeout(this.csfLoadFailTimeout),this.csfLoadFailTimeout=null,this.props.onLoad(e),this.csfConfigFailTimeout=setTimeout((()=>{"ready"!==this.state.status&&(this.setState({status:"csfConfigFailure"}),this.props.onError(new c("ERROR","secured fields have failed to configure")))}),this.csfConfigFailTimeoutMS)},handleOnConfigSuccess:function(e){clearTimeout(this.csfConfigFailTimeout),this.csfConfigFailTimeout=null,this.setState({status:"ready"},(()=>{this.props.onConfigSuccess(e)}))},handleOnBrand:function(t){this.setState((e=>{const l=y(r,t.cvcPolicy,this.numCharsInField,e.errors),d=1===this.numDateFields?y(n,t.expiryDatePolicy,this.numCharsInField,e.errors):null,c=2===this.numDateFields?y(i,t.expiryDatePolicy,this.numCharsInField,e.errors):null,p=2===this.numDateFields?y(s,t.expiryDatePolicy,this.numCharsInField,e.errors):null;var f,m;return{brand:t.brand,cvcPolicy:null!==(f=t.cvcPolicy)&&void 0!==f?f:a,showSocialSecurityNumber:t.showSocialSecurityNumber,errors:h({},e.errors,u(l)&&{[r]:l},u(d)&&{[n]:d},u(c)&&{[i]:c},u(p)&&{[s]:p}),expiryDatePolicy:null!==(m=t.expiryDatePolicy)&&void 0!==m?m:o}}),(()=>{var r,n;this.props.onChange(this.state,{event:"handleOnBrand"});const i=null!==(n=null===(r=this.props.brandsConfiguration[t.brand])||void 0===r?void 0:r.icon)&&void 0!==n?n:e(t.brand,this.props.resources);this.props.onBrand(f(h({},t),{brandImageUrl:i}))}))},handleOnError:function(e,r=null){const n=e.error;return this.setState((i=>h({errors:f(h({},i.errors),{[e.fieldType]:n||!1})},r&&{data:f(h({},i.data),{[t]:void 0})},r&&{valid:f(h({},i.valid),{[t]:!1})},r&&{isSfpValid:!1})),(()=>{this.props.onChange(this.state,{event:"handleOnError",fieldType:e.fieldType})})),!0},handleOnNoDataRequired:function(){this.setState({status:"ready"},(()=>this.props.onChange({isSfpValid:!0})))},handleOnTouchstartIOS:function(e){var t,r;null===(t=(r=this.props).disableIOSArrowKeys)||void 0===t||t.call(r,e)},handleKeyPressed:function(e){if("enterKeyPressed"===e.action){var t,r;const e=new KeyboardEvent("keypress",{bubbles:!0,cancelable:!0,key:"Enter",code:"Enter"});null===(t=(r=this.props).handleKeyPress)||void 0===t||t.call(r,e)}}};export{m as default};
|
|
2
2
|
//# sourceMappingURL=SecuredFieldsProviderHandlers.js.map
|
package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{select as e,getAttribute as t}from"../../utilities/dom.js";import{DATA_ENCRYPTED_FIELD_ATTR as i,
|
|
1
|
+
import{select as e,getAttribute as t}from"../../utilities/dom.js";import{DATA_ENCRYPTED_FIELD_ATTR as i,ALL_SECURED_FIELDS as o,CVC_POLICY_REQUIRED as s,DATE_POLICY_REQUIRED as r,ENCRYPTED_EXPIRY_YEAR as n,SF_CONFIG_TIMEOUT as a,DATA_UID as d,DATA_INFO as l}from"../../constants.js";import{existy as c}from"../../../../../../utils/commonUtils.js";import h from"../utils/cardType.js";import u from"../../securedField/SecuredField.js";import p from"../../../../../../core/Errors/AdyenCheckoutError.js";function f(e,t){if(null==e)return{};var i,o,s=function(e,t){if(null==e)return{};var i,o,s={},r=Object.keys(e);for(o=0;o<r.length;o++)i=r[o],t.indexOf(i)>=0||(s[i]=e[i]);return s}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(o=0;o<r.length;o++)i=r[o],t.indexOf(i)>=0||Object.prototype.propertyIsEnumerable.call(e,i)&&(s[i]=e[i])}return s}function m(){this.encryptedAttrName=i;const n=e(this.props.rootNode,`[${this.encryptedAttrName}]`).filter((e=>{const i=t(e,this.encryptedAttrName),s=o.includes(i);return s||console.warn(`WARNING: '${i}' is not a valid type for the '${this.encryptedAttrName}' attribute. A SecuredField will not be created for this element.`),s})),a=s,d=r;return this.config.isCreditCardType?(this.isSingleBrandedCard=!1,this.securityCode="",this.createCardSecuredFields(n,a,d),n.length):(this.createNonCardSecuredFields(n),n.length)}async function y(e){for(let t=0;t<e.length;t++){const i=e[t];await this.setupSecuredField(i).catch((e=>{window._b$dl&&console.log("Secured fields setup failure. e=",e)}))}}async function g(e,t,i){let o=this.state.type;if("card"===o&&1===this.config.cardGroupTypes.length&&(o=this.config.cardGroupTypes[0],this.state.type=o),this.isSingleBrandedCard="card"!==o,this.isSingleBrandedCard){const e=h.getCardByBrand(o);c(e)?(t=e.cvcPolicy||s,i=e.expiryDatePolicy||r,this.securityCode=e.securityCode):this.state.type="unrecognised-single-brand"}for(let o=0;o<e.length;o++){const s=e[o];window._b$dl&&console.log("\nAbout to set up securedField:",s),await this.setupSecuredField(s,t,i).catch((e=>{window._b$dl&&console.log("Secured fields setup failure. e=",e)})),window._b$dl&&console.log("Finished setting up securedField:",s)}if(window._b$dl&&console.log("Finished setting up all securedFields"),this.isSingleBrandedCard){const e={type:this.state.type,rootNode:this.props.rootNode,brand:o,cvcPolicy:t,expiryDatePolicy:i,cvcText:this.securityCode};setTimeout((()=>{this.callbacks.onBrand(e)}),0)}}function C(e,i,o){return new Promise(((s,r)=>{const c=t(e,this.encryptedAttrName);c===n&&(this.state.hasSeparateDateFields=!0);const h={fieldType:c,extraFieldData:t(e,l),uid:t(e,d),cvcPolicy:i,holderEl:e,expiryDatePolicy:o,txVariant:this.state.type,cardGroupTypes:this.config.cardGroupTypes,iframeUIConfig:this.config.iframeUIConfig,sfLogAtStart:this.config.sfLogAtStart,trimTrailingSeparator:this.config.trimTrailingSeparator,isCreditCardType:this.config.isCreditCardType,iframeSrc:this.config.iframeSrc,loadingContext:this.config.loadingContext,showWarnings:this.config.showWarnings,legacyInputMode:this.config.legacyInputMode,minimumExpiryDate:this.config.minimumExpiryDate,maskSecurityCode:this.props.maskSecurityCode,exposeExpiryDate:this.props.exposeExpiryDate,disableIOSArrowKeys:this.props.shouldDisableIOSArrowKeys,implementationType:this.props.implementationType,showContextualElement:this.props.showContextualElement,placeholders:this.props.placeholders},m=new u(h,this.props.i18n).onIframeLoaded((()=>{if(this.state.iframeCount+=1,window._b$dl&&console.log("### createSecuredFields::onIframeLoaded:: this.state.iframeCount=",this.state.iframeCount),this.state.iframeCount>this.state.numIframes)throw this.destroySecuredFields(),new p("ERROR",`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}`);if(m.loadToConfigTimeout=setTimeout((()=>{r({type:h.fieldType,failReason:"sf took too long to config"})}),a),this.state.iframeCount===this.state.originalNumIframes){const e={iframesLoaded:!0};this.callbacks.onLoad(e)}})).onConfig((e=>{this.handleIframeConfigFeedback(e),clearTimeout(m.loadToConfigTimeout),m.loadToConfigTimeout=null,s(e)})).onFocus((e=>{this.handleFocus(e)})).onBinValue((e=>{this.handleBinValue(e)})).onTouchstart((e=>{this.props.shouldDisableIOSArrowKeys&&(this.hasGenuineTouchEvents||e.hasGenuineTouchEvents)&&this.callbacks.onTouchstartIOS({fieldType:e.fieldType}),(e.hasGenuineTouchEvents||this.hasGenuineTouchEvents)&&this.postMessageToAllIframes({fieldType:e.fieldType,fieldClick:!0})})).onShiftTab((e=>{this.handleSFShiftTab(e.fieldType)})).onEncryption((e=>{this.handleEncryption(e)})).onValidation((e=>{this.handleValidation(e)})).onAutoComplete((e=>{this.processAutoComplete(e)})).onKeyPressed((e=>{const{numKey:t}=e,i=f(e,["numKey"]);this.callbacks.onKeyPressed(i)}));this.state.securedFields[c]=m}))}export{g as createCardSecuredFields,y as createNonCardSecuredFields,m as createSecuredFields,C as setupSecuredField};
|
|
2
2
|
//# sourceMappingURL=createSecuredFields.js.map
|
|
@@ -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","rest","numKey"],"mappings":"w2BAwBO,SAASA,IACZC,KAAKC,kBAAoBC,EAGzB,MAAMC,EAA+BC,EAAOJ,KAAKK,MAAMC,SAAU,IAAIN,KAAKC,sBAAsBM,QAAOC,IACnG,MAAMC,EAAoBC,EAAaF,EAAOR,KAAKC,mBAM7CU,EAAcC,EAAmBC,SAASJ,GAMhD,OALKE,GACDG,QAAQC,KACJ,aAAaN,mCAA2CT,KAAKC,sFAG9DU,CAAAA,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,OAAMC,IACzCC,OAAOC,OAAOpB,QAAQqB,IAAI,mCAAoCH,EAAAA,GAE1E,CACJ,CAEOL,eAAeH,EAClBrB,EACAa,EACAE,GAGA,IAAIkB,EAAepC,KAAKqC,MAAMD,KAa9B,GATa,SAATA,GAAyD,IAAtCpC,KAAKoB,OAAOkB,eAAeb,SAC9CW,EAAOpC,KAAKoB,OA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EAAAA,IAEXG,SAASH,IACN5F,KAAKgG,YAAYJ,EAAAA,IAEpBK,YAAYL,IACT5F,KAAKkG,eAAeN,EAAAA,IAEvBO,cAAcP,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,GAClF,IAEHC,YAAYZ,IAET5F,KAAKyG,iBAAiBb,EAAanF,UAAS,IAE/CiG,cAAcd,IACX5F,KAAK2G,iBAAiBf,EAAAA,IAEzBgB,cAAchB,IACX5F,KAAK6G,iBAAiBjB,EAAAA,IAEzBkB,gBAAgBlB,IACb5F,KAAK+G,oBAAoBnB,EAAAA,IAE5BoB,cAAcpB,IACX,MAAmBqB,EAASrB,EAAAA,EAAAA,CAApBsB,WACRlH,KAAK+C,UAAUiE,aAAaC,EAAAA,IAIpCjH,KAAKqC,MAAMlC,cAAcM,GAAaoE,CAAAA,GAE9C"}
|
|
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":"w2BAwBO,SAASA,IACZC,KAAKC,kBAAoBC,EAGzB,MAAMC,EAA+BC,EAAOJ,KAAKK,MAAMC,SAAU,IAAIN,KAAKC,sBAAsBM,QAAOC,IACnG,MAAMC,EAAoBC,EAAaF,EAAOR,KAAKC,mBAM7CU,EAAcC,EAAmBC,SAASJ,GAMhD,OALKE,GACDG,QAAQC,KACJ,aAAaN,mCAA2CT,KAAKC,sFAG9DU,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B,EAAAA,EAAAA,CAApBqB,WACRjH,KAAK+C,UAAUiE,aAAaE,EAAAA,IAIpClH,KAAKqC,MAAMlC,cAAcM,GAAaoE,CAAAA,GAE9C"}
|
|
@@ -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 a
|
|
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}${!!e.forceCompat||!("function"==typeof window.TextEncoder)?"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
|
package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleConfig.js.map
CHANGED
|
@@ -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
|
|
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 * Unless we are forcing the use of the compat version via card config\n * - detect Edge vn \\<= 18 & IE11 - who don't support TextEncoder; and use this as an indicator to load a different, compatible, version of SF\n */\n const needsJWECompatVersion = props.forceCompat ? true : !(typeof window.TextEncoder === 'function');\n\n const bundleType = `${sfBundleType}${needsJWECompatVersion ? 'Compat' : ''}`; // 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","TextEncoder","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,CAAC,EAGtDC,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,QAQzBC,EAAa,GAAGL,MAFQxB,EAAM8B,eAAqD,mBAAvBR,OAAOS,aAEZ,SAAW,KAExE9B,KAAKC,OAAO8B,UAAY,GAAG/B,KAAKC,OAAOG,+BAA+BL,EAAMiC,aAAaC,6BAAsCL,OAAgBJ,GAOnJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"../utils/userAgent.js";import"../../utilities/logger.js";import{shiftTabCreditCard as i}from"../utils/tabbing/tabScenarioCreditCard.js";import{
|
|
1
|
+
import t from"../utils/userAgent.js";import"../../utilities/logger.js";import{shiftTabCreditCard as i}from"../utils/tabbing/tabScenarioCreditCard.js";import{shiftTabGiftCard as s}from"../utils/tabbing/tabScenarioGiftCard.js";import{shiftTabKCP as a}from"../utils/tabbing/tabScenarioKCP.js";import{focusExternalField as e}from"../utils/tabbing/utils.js";var o={handleShiftTab:function(t){let o;if("giftcard"===this.state.type)o=s(t,this.props.rootNode);else o=this.state.isKCP?a(t,this.props.rootNode,this.state.hasSeparateDateFields):i(t,this.props.rootNode,this.state.hasSeparateDateFields,this.state.numIframes);const r=o.fieldToFocus,l=o.additionalField;r?this.setFocusOnFrame(r,false):l&&e(l)},handleSFShiftTab:function(i){(t.__IS_FIREFOX||t.__IS_IE&&t.__IS_IE<=11)&&this.handleShiftTab(i)}};export{o as default};
|
|
2
2
|
//# sourceMappingURL=handleTab.js.map
|
package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleTab.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleTab.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/extensions/handleTab.ts"],"sourcesContent":["import ua from '../utils/userAgent';\nimport * as logger from '../../utilities/logger';\nimport { shiftTabCreditCard } from '../utils/tabbing/tabScenarioCreditCard';\nimport {
|
|
1
|
+
{"version":3,"file":"handleTab.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/extensions/handleTab.ts"],"sourcesContent":["import ua from '../utils/userAgent';\nimport * as logger from '../../utilities/logger';\nimport { shiftTabCreditCard } from '../utils/tabbing/tabScenarioCreditCard';\nimport { shiftTabGiftCard } from '../utils/tabbing/tabScenarioGiftCard';\nimport { shiftTabKCP } from '../utils/tabbing/tabScenarioKCP';\nimport { SFFieldType, ShiftTabObject } from '../../types';\nimport { focusExternalField } from '../utils/tabbing/utils';\n\nconst logTab = false;\n\nfunction handleShiftTab(fieldType: SFFieldType): void {\n if (logTab) logger.log('### handleTab::handleShiftTab:: fieldType', fieldType);\n\n let shiftTabObj: ShiftTabObject;\n\n switch (this.state.type) {\n // GIFT CARD scenario: SecurityCode preceded by CardNumber\n case 'giftcard':\n shiftTabObj = shiftTabGiftCard(fieldType, this.props.rootNode);\n break;\n\n // Credit Card scenarios\n default:\n // KCP scenario: Regular credit card but with additional fields\n // - an encrypted pin/password field preceded by a form field of a non-SF type (d.o.b/taxRefNum)\n if (this.state.isKCP) {\n shiftTabObj = shiftTabKCP(fieldType, this.props.rootNode, this.state.hasSeparateDateFields);\n } else {\n // Regular Credit Card\n shiftTabObj = shiftTabCreditCard(fieldType, this.props.rootNode, this.state.hasSeparateDateFields, this.state.numIframes);\n }\n break;\n }\n\n const fieldToFocus: string = shiftTabObj.fieldToFocus;\n const additionalField: HTMLElement = shiftTabObj.additionalField;\n\n if (fieldToFocus) {\n this.setFocusOnFrame(fieldToFocus, logTab);\n } else if (additionalField) {\n focusExternalField(additionalField);\n }\n}\n\nconst eligibleForTabFix = (): boolean => ua.__IS_FIREFOX || (ua.__IS_IE && ua.__IS_IE <= 11);\n\nfunction handleSFShiftTab(fieldType: SFFieldType): void {\n if (eligibleForTabFix()) {\n this.handleShiftTab(fieldType);\n }\n}\n\nexport default {\n handleShiftTab,\n handleSFShiftTab\n};\n"],"names":["handleTab","handleShiftTab","fieldType","shiftTabObj","this","state","type","shiftTabGiftCard","props","rootNode","isKCP","shiftTabKCP","hasSeparateDateFields","shiftTabCreditCard","numIframes","fieldToFocus","additionalField","setFocusOnFrame","focusExternalField","handleSFShiftTab","ua","__IS_FIREFOX","__IS_IE"],"mappings":"iWAoDA,IAAeA,EAAA,CACXC,eA3CJ,SAAwBC,GAGpB,IAAIC,EAEJ,GAES,aAFDC,KAAKC,MAAMC,KAGXH,EAAcI,EAAiBL,EAAWE,KAAKI,MAAMC,eAQjDN,EADAC,KAAKC,MAAMK,MACGC,EAAYT,EAAWE,KAAKI,MAAMC,SAAUL,KAAKC,MAAMO,uBAGvDC,EAAmBX,EAAWE,KAAKI,MAAMC,SAAUL,KAAKC,MAAMO,sBAAuBR,KAAKC,MAAMS,YAK1H,MAAMC,EAAuBZ,EAAYY,aACnCC,EAA+Bb,EAAYa,gBAE7CD,EACAX,KAAKa,gBAAgBF,EA9Bd,OA+BAC,GACPE,EAAmBF,EAE3B,EAYIG,iBARJ,SAA0BjB,IAFekB,EAAGC,cAAiBD,EAAGE,SAAWF,EAAGE,SAAW,KAIjFlB,KAAKH,eAAeC,EAE5B"}
|
package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/processAutoComplete.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processAutoComplete.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/partials/processAutoComplete.ts"],"sourcesContent":["import postMessageToIframe from '../utils/iframes/postMessageToIframe';\nimport { ENCRYPTED_EXPIRY_DATE, ENCRYPTED_EXPIRY_MONTH, ENCRYPTED_EXPIRY_YEAR } from '../../constants';\nimport { SFFeedbackObj, CardAutoCompleteData } from '../../types';\nimport { hasOwnProperty } from '../../../../../../utils/hasOwnProperty';\nimport getIframeContentWin from '../utils/iframes/getIframeContentWin';\nimport { CSFThisObject } from '../types';\n\n/**\n *\n * @param csfState - comes from initial, partial, implementation\n * @param csfConfig - comes from initial, partial, implementation\n * @param csfCallbacks - comes from initial, partial, implementation\n *\n * @param pFeedbackObj -\n */\nexport function processAutoComplete({ csfState, csfConfig, csfCallbacks }: CSFThisObject, pFeedbackObj: SFFeedbackObj): boolean {\n /**\n * NOTE: It seems Chrome has started autofilling across cross-origin iframes. Have tested as far back as v104 but have no resources to test further back\n * So, in theory for Chrome \\>= v104 we don't need to do any of this, including having special listeners in the securedFields\n */\n\n // Specifically for cc-name (but no reason not to propagate all AC objects to the merchant)\n if (pFeedbackObj.name === 'cc-name') {\n const feedbackObj: SFFeedbackObj = { ...pFeedbackObj };\n delete feedbackObj.numKey;\n const ACFeedbackObj: CardAutoCompleteData = feedbackObj as CardAutoCompleteData;\n csfCallbacks.onAutoComplete(ACFeedbackObj);\n return true;\n }\n\n // Send date info to relevant secured fields (needed for Safari whose Security model won't allow direct population of fields in 3rd party iframes)\n if (pFeedbackObj.name === 'cc-exp') {\n const splittableDateVal = pFeedbackObj.value.replace(/[^0-9]/gi, '/'); // Replace any non-digits with a fwd-slash so we can always split it\n\n const dateValArr: string[] = splittableDateVal.split('/');\n\n if (dateValArr.length !== 2) {\n // To avoid bug in some versions of Safari where date doesn't come through as expected\n return false;\n }\n\n if (dateValArr[0].length === 1) dateValArr[0] = `0${dateValArr[0]}`; // pad, if required\n\n const acMonthVal: string = dateValArr[0];\n\n // Extra checks that passed year is a valid value\n const year = dateValArr[1];\n const isValidYear = (year?.length === 4 || year?.length === 2) && !isNaN(parseInt(year));\n if (!isValidYear) {\n return false;\n }\n\n const acYearVal: string = year.slice(-2); // take last 2 digits of year\n const acDateVal = `${acMonthVal}/${acYearVal}`;\n\n if (hasOwnProperty(csfState.securedFields, ENCRYPTED_EXPIRY_DATE)) {\n const dataObj: object = {\n txVariant: csfState.type,\n fieldType: ENCRYPTED_EXPIRY_DATE,\n autoComplete: acDateVal,\n numKey: csfState.securedFields[ENCRYPTED_EXPIRY_DATE].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(csfState, ENCRYPTED_EXPIRY_DATE), csfConfig.loadingContext);\n return true;\n }\n\n if (hasOwnProperty(csfState.securedFields, ENCRYPTED_EXPIRY_MONTH)) {\n const dataObj: object = {\n txVariant: csfState.type,\n fieldType: ENCRYPTED_EXPIRY_MONTH,\n autoComplete: acMonthVal,\n numKey: csfState.securedFields[ENCRYPTED_EXPIRY_MONTH].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(csfState, ENCRYPTED_EXPIRY_MONTH), csfConfig.loadingContext);\n }\n\n if (hasOwnProperty(csfState.securedFields, ENCRYPTED_EXPIRY_YEAR)) {\n // Dirty! - Need to wait til next page draw if setting month and year at the same time, otherwise only year gets set\n setTimeout(() => {\n const dataObj: object = {\n txVariant: csfState.type,\n fieldType: ENCRYPTED_EXPIRY_YEAR,\n autoComplete: acYearVal,\n numKey: csfState.securedFields[ENCRYPTED_EXPIRY_YEAR].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(csfState, ENCRYPTED_EXPIRY_YEAR), csfConfig.loadingContext);\n }, 0);\n }\n return true;\n }\n\n return false;\n}\n"],"names":["processAutoComplete","csfState","csfConfig","csfCallbacks","pFeedbackObj","name","feedbackObj","_object_spread","numKey","ACFeedbackObj","onAutoComplete","dateValArr","value","replace","split","length","acMonthVal","year","isNaN","parseInt","acYearVal","slice","acDateVal","hasOwnProperty","securedFields","ENCRYPTED_EXPIRY_DATE","dataObj","txVariant","type","fieldType","autoComplete","postMessageToIframe","getIframeContentWin","loadingContext","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","setTimeout"],"mappings":"maAeO,SAASA,GAAoBC,SAAEA,EAAQC,UAAEA,EAASC,aAAEA,GAA+BC,GAOtF,GAA0B,YAAtBA,EAAaC,KAAoB,CACjC,MAAMC,wUAA6BC,CAAKH,CAAAA,EAAAA,UACjCE,EAAYE,OACnB,MAAMC,EAAsCH,EAE5C,OADAH,EAAaO,eAAeD,IACrB,CACX,CAGA,GAA0B,WAAtBL,EAAaC,KAAmB,CAChC,MAEMM,EAFoBP,EAAaQ,MAAMC,QAAQ,WAAY,KAElBC,MAAM,KAErD,GAA0B,IAAtBH,EAAWI,OAEX,OAAO,EAGkB,IAAzBJ,EAAW,GAAGI,SAAcJ,EAAW,GAAK,IAAIA,EAAW,MAE/D,MAAMK,EAAqBL,EAAW,GAGhCM,EAAON,EAAW,GAExB,MADsC,KAAjBM,aAAAA,EAAAA,EAAMF,SAAiC,KAAjBE,aAAAA,EAAAA,EAAMF,WAAkBG,MAAMC,SAASF,KAE9E,OAAO,EAGX,MAAMG,EAAoBH,EAAKI,
|
|
1
|
+
{"version":3,"file":"processAutoComplete.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/partials/processAutoComplete.ts"],"sourcesContent":["import postMessageToIframe from '../utils/iframes/postMessageToIframe';\nimport { ENCRYPTED_EXPIRY_DATE, ENCRYPTED_EXPIRY_MONTH, ENCRYPTED_EXPIRY_YEAR } from '../../constants';\nimport { SFFeedbackObj, CardAutoCompleteData } from '../../types';\nimport { hasOwnProperty } from '../../../../../../utils/hasOwnProperty';\nimport getIframeContentWin from '../utils/iframes/getIframeContentWin';\nimport { CSFThisObject } from '../types';\n\n/**\n *\n * @param csfState - comes from initial, partial, implementation\n * @param csfConfig - comes from initial, partial, implementation\n * @param csfCallbacks - comes from initial, partial, implementation\n *\n * @param pFeedbackObj -\n */\nexport function processAutoComplete({ csfState, csfConfig, csfCallbacks }: CSFThisObject, pFeedbackObj: SFFeedbackObj): boolean {\n /**\n * NOTE: It seems Chrome has started autofilling across cross-origin iframes. Have tested as far back as v104 but have no resources to test further back\n * So, in theory for Chrome \\>= v104 we don't need to do any of this, including having special listeners in the securedFields\n */\n\n // Specifically for cc-name (but no reason not to propagate all AC objects to the merchant)\n if (pFeedbackObj.name === 'cc-name') {\n const feedbackObj: SFFeedbackObj = { ...pFeedbackObj };\n delete feedbackObj.numKey;\n const ACFeedbackObj: CardAutoCompleteData = feedbackObj as CardAutoCompleteData;\n csfCallbacks.onAutoComplete(ACFeedbackObj);\n return true;\n }\n\n // Send date info to relevant secured fields (needed for Safari whose Security model won't allow direct population of fields in 3rd party iframes)\n if (pFeedbackObj.name === 'cc-exp') {\n const splittableDateVal = pFeedbackObj.value.replace(/[^0-9]/gi, '/'); // Replace any non-digits with a fwd-slash so we can always split it\n\n const dateValArr: string[] = splittableDateVal.split('/');\n\n if (dateValArr.length !== 2) {\n // To avoid bug in some versions of Safari where date doesn't come through as expected\n return false;\n }\n\n if (dateValArr[0].length === 1) dateValArr[0] = `0${dateValArr[0]}`; // pad, if required\n\n const acMonthVal: string = dateValArr[0];\n\n // Extra checks that passed year is a valid value\n const year = dateValArr[1];\n const isValidYear = (year?.length === 4 || year?.length === 2) && !isNaN(parseInt(year));\n if (!isValidYear) {\n return false;\n }\n\n const acYearVal: string = year.slice(-2); // take last 2 digits of year\n const acDateVal = `${acMonthVal}/${acYearVal}`;\n\n if (hasOwnProperty(csfState.securedFields, ENCRYPTED_EXPIRY_DATE)) {\n const dataObj: object = {\n txVariant: csfState.type,\n fieldType: ENCRYPTED_EXPIRY_DATE,\n autoComplete: acDateVal,\n numKey: csfState.securedFields[ENCRYPTED_EXPIRY_DATE].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(csfState, ENCRYPTED_EXPIRY_DATE), csfConfig.loadingContext);\n return true;\n }\n\n if (hasOwnProperty(csfState.securedFields, ENCRYPTED_EXPIRY_MONTH)) {\n const dataObj: object = {\n txVariant: csfState.type,\n fieldType: ENCRYPTED_EXPIRY_MONTH,\n autoComplete: acMonthVal,\n numKey: csfState.securedFields[ENCRYPTED_EXPIRY_MONTH].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(csfState, ENCRYPTED_EXPIRY_MONTH), csfConfig.loadingContext);\n }\n\n if (hasOwnProperty(csfState.securedFields, ENCRYPTED_EXPIRY_YEAR)) {\n // Dirty! - Need to wait til next page draw if setting month and year at the same time, otherwise only year gets set\n setTimeout(() => {\n const dataObj: object = {\n txVariant: csfState.type,\n fieldType: ENCRYPTED_EXPIRY_YEAR,\n autoComplete: acYearVal,\n numKey: csfState.securedFields[ENCRYPTED_EXPIRY_YEAR].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(csfState, ENCRYPTED_EXPIRY_YEAR), csfConfig.loadingContext);\n }, 0);\n }\n return true;\n }\n\n return false;\n}\n"],"names":["processAutoComplete","csfState","csfConfig","csfCallbacks","pFeedbackObj","name","feedbackObj","_object_spread","numKey","ACFeedbackObj","onAutoComplete","dateValArr","value","replace","split","length","acMonthVal","year","isNaN","parseInt","acYearVal","slice","acDateVal","hasOwnProperty","securedFields","ENCRYPTED_EXPIRY_DATE","dataObj","txVariant","type","fieldType","autoComplete","postMessageToIframe","getIframeContentWin","loadingContext","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","setTimeout"],"mappings":"maAeO,SAASA,GAAoBC,SAAEA,EAAQC,UAAEA,EAASC,aAAEA,GAA+BC,GAOtF,GAA0B,YAAtBA,EAAaC,KAAoB,CACjC,MAAMC,wUAA6BC,CAAKH,CAAAA,EAAAA,UACjCE,EAAYE,OACnB,MAAMC,EAAsCH,EAE5C,OADAH,EAAaO,eAAeD,IACrB,CACX,CAGA,GAA0B,WAAtBL,EAAaC,KAAmB,CAChC,MAEMM,EAFoBP,EAAaQ,MAAMC,QAAQ,WAAY,KAElBC,MAAM,KAErD,GAA0B,IAAtBH,EAAWI,OAEX,OAAO,EAGkB,IAAzBJ,EAAW,GAAGI,SAAcJ,EAAW,GAAK,IAAIA,EAAW,MAE/D,MAAMK,EAAqBL,EAAW,GAGhCM,EAAON,EAAW,GAExB,MADsC,KAAjBM,aAAAA,EAAAA,EAAMF,SAAiC,KAAjBE,aAAAA,EAAAA,EAAMF,WAAkBG,MAAMC,SAASF,KAE9E,OAAO,EAGX,MAAMG,EAAoBH,EAAKI,UACzBC,EAAY,GAAGN,KAAcI,IAEnC,GAAIG,EAAetB,EAASuB,cAAeC,GAAwB,CAC/D,MAAMC,EAAkB,CACpBC,UAAW1B,EAAS2B,KACpBC,UAAWJ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