@adyen/adyen-web 6.6.0 → 6.8.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 +45 -45
- 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 +224 -141
- package/dist/es/adyen.css +45 -45
- package/dist/es/adyen.css.map +1 -1
- package/dist/es/components/ANCV/ANCV.js +1 -1
- package/dist/es/components/ANCV/ANCV.js.map +1 -1
- package/dist/es/components/Ach/components/AchInput/AchInput.js.map +1 -1
- package/dist/es/components/Ach/components/AchInput/defaultProps.js.map +1 -1
- package/dist/es/components/Ach/components/AchInput/defaultStyles.js.map +1 -1
- package/dist/es/components/AfterPay/AfterPayB2B.js.map +1 -1
- package/dist/es/components/AmazonPay/AmazonPay.js.map +1 -1
- package/dist/es/components/AmazonPay/components/AmazonPayButton.js.map +1 -1
- package/dist/es/components/BacsDD/BacsDD.js.map +1 -1
- package/dist/es/components/BacsDD/components/BacsInput.js.map +1 -1
- package/dist/es/components/BankTransfer/BankTransfer.js.map +1 -1
- package/dist/es/components/Boleto/Boleto.js.map +1 -1
- package/dist/es/components/Boleto/components/BoletoInput/BoletoInput.js.map +1 -1
- package/dist/es/components/Card/Card.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/CardInput.js +1 -1
- package/dist/es/components/Card/components/CardInput/CardInput.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/defaultProps.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/handlers.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
- package/dist/es/components/CashAppPay/CashAppPay.js.map +1 -1
- package/dist/es/components/CustomCard/CustomCard.js +1 -1
- package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
- package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
- package/dist/es/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
- package/dist/es/components/Doku/components/DokuInput/DokuInput.js.map +1 -1
- package/dist/es/components/Dropin/Dropin.js.map +1 -1
- package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
- package/dist/es/components/Dropin/components/PaymentMethod/useBrandLogoConfiguration.js.map +1 -1
- package/dist/es/components/Dropin/elements/filters.js.map +1 -1
- package/dist/es/components/Dropin/elements/getComponentConfiguration.js.map +1 -1
- package/dist/es/components/Econtext/components/EcontextInput/EcontextInput.js.map +1 -1
- package/dist/es/components/Giftcard/Giftcard.js +1 -1
- package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
- package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
- package/dist/es/components/GooglePay/components/GooglePayButton.js +1 -1
- package/dist/es/components/GooglePay/components/GooglePayButton.js.map +1 -1
- package/dist/es/components/GooglePay/requests.js.map +1 -1
- package/dist/es/components/Klarna/KlarnaPayments.js +1 -1
- package/dist/es/components/Klarna/KlarnaPayments.js.map +1 -1
- package/dist/es/components/Klarna/components/KlarnaWidget/KlarnaWidget.js.map +1 -1
- package/dist/es/components/MBWay/MBWay.js.map +1 -1
- package/dist/es/components/Multibanco/Multibanco.js.map +1 -1
- package/dist/es/components/Oxxo/Oxxo.js.map +1 -1
- package/dist/es/components/PayByBankUS/PayByBankUS.js.map +1 -1
- package/dist/es/components/PayPal/utils/get-paypal-styles.js.map +1 -1
- package/dist/es/components/Pix/Pix.js.map +1 -1
- package/dist/es/components/Redirect/Redirect.js.map +1 -1
- package/dist/es/components/Redirect/components/RedirectShopper/RedirectShopper.js.map +1 -1
- package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
- package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
- package/dist/es/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
- package/dist/es/components/ThreeDS2/callSubmit3DS2Fingerprint.js.map +1 -1
- package/dist/es/components/ThreeDS2/components/Form/ThreeDS2Form.js.map +1 -1
- package/dist/es/components/Twint/Twint.js.map +1 -1
- package/dist/es/components/UPI/UPI.js.map +1 -1
- package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
- package/dist/es/components/helpers/OpenInvoiceContainer/OpenInvoiceContainer.js.map +1 -1
- package/dist/es/components/internal/Address/Address.js.map +1 -1
- package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
- package/dist/es/components/internal/Button/Button.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPSection/CtPLogoutLink.js +1 -1
- package/dist/es/components/internal/ClickToPay/components/CtPSection/CtPLogoutLink.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/context/ClickToPayProvider.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/services/ClickToPayService.js.map +1 -1
- package/dist/es/components/internal/CompanyDetails/CompanyDetails.js.map +1 -1
- package/dist/es/components/internal/FormFields/Select/Select.js.map +1 -1
- package/dist/es/components/internal/IFrame/Iframe.js.map +1 -1
- package/dist/es/components/internal/IbanInput/IbanInput.js.map +1 -1
- package/dist/es/components/internal/IssuerList/IssuerList.js.map +1 -1
- package/dist/es/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
- package/dist/es/components/internal/OpenInvoice/utils.js.map +1 -1
- package/dist/es/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/defaultProps.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/AbstractCSF.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/CSF.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +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/handleEncryption.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleValidation.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/partials/handleBinValue.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/partials/handleFocus.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/partials/handleIframeConfigFeedback.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/partials/isConfigured.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/partials/postMessageToAllIframes.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/partials/processBrand.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/partials/validateForm.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/utils/callbackUtils.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/utils/destroySecuredFields.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/utils/processErrors.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/AbstractSecuredField.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/utilities/addContextTranslations.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/components/internal/UIElement/utils.js.map +1 -1
- package/dist/es/components/internal/Voucher/utils.js.map +1 -1
- package/dist/es/core/Analytics/Analytics.js.map +1 -1
- package/dist/es/core/Analytics/constants.js.map +1 -1
- package/dist/es/core/Analytics/utils.js.map +1 -1
- package/dist/es/core/Errors/AdyenCheckoutError.js +1 -1
- package/dist/es/core/Errors/AdyenCheckoutError.js.map +1 -1
- package/dist/es/core/Errors/SRMessages.js.map +1 -1
- package/dist/es/core/Errors/constants.js.map +1 -1
- package/dist/es/core/Errors/utils.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/Services/http.js.map +1 -1
- package/dist/es/core/Services/sessions/constants.js +1 -1
- package/dist/es/core/Services/sessions/constants.js.map +1 -1
- package/dist/es/core/Services/sessions/create-order.js +1 -1
- package/dist/es/core/Services/sessions/create-order.js.map +1 -1
- package/dist/es/core/Services/sessions/make-payment.js +1 -1
- package/dist/es/core/Services/sessions/make-payment.js.map +1 -1
- package/dist/es/core/Services/sessions/setup-session.js.map +1 -1
- package/dist/es/core/Services/sessions/submit-details.js +1 -1
- package/dist/es/core/Services/sessions/submit-details.js.map +1 -1
- package/dist/es/core/core.js +1 -1
- package/dist/es/core/core.registry.js.map +1 -1
- package/dist/es/core/utils.js.map +1 -1
- package/dist/es/external/classnames/index.js.map +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/index.d.ts +224 -141
- package/dist/es/language/Language.js.map +1 -1
- package/dist/es/language/utils.js.map +1 -1
- package/dist/es/utils/Storage.js.map +1 -1
- package/dist/es/utils/commonUtils.js.map +1 -1
- package/dist/es/utils/get-process-message-handler.js.map +1 -1
- package/dist/es/utils/getOrigin.js.map +1 -1
- package/dist/es/utils/useForm/reducer.js.map +1 -1
- package/dist/es/utils/useForm/useForm.js.map +1 -1
- package/dist/es-legacy/adyen.css +45 -45
- package/dist/es-legacy/adyen.css.map +1 -1
- package/dist/es-legacy/components/ANCV/ANCV.js +1 -1
- package/dist/es-legacy/components/ANCV/ANCV.js.map +1 -1
- package/dist/es-legacy/components/Ach/components/AchInput/AchInput.js.map +1 -1
- package/dist/es-legacy/components/Ach/components/AchInput/defaultProps.js.map +1 -1
- package/dist/es-legacy/components/Ach/components/AchInput/defaultStyles.js.map +1 -1
- package/dist/es-legacy/components/AfterPay/AfterPayB2B.js.map +1 -1
- package/dist/es-legacy/components/AmazonPay/AmazonPay.js.map +1 -1
- package/dist/es-legacy/components/AmazonPay/components/AmazonPayButton.js.map +1 -1
- package/dist/es-legacy/components/BacsDD/BacsDD.js.map +1 -1
- package/dist/es-legacy/components/BacsDD/components/BacsInput.js.map +1 -1
- package/dist/es-legacy/components/BankTransfer/BankTransfer.js.map +1 -1
- package/dist/es-legacy/components/Boleto/Boleto.js.map +1 -1
- package/dist/es-legacy/components/Boleto/components/BoletoInput/BoletoInput.js.map +1 -1
- package/dist/es-legacy/components/Card/Card.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/CardInput.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/CardInput.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/defaultProps.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/handlers.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
- package/dist/es-legacy/components/CashAppPay/CashAppPay.js.map +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCard.js +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js +1 -1
- package/dist/es-legacy/components/CustomCard/CustomCardInput/CustomCardInput.js.map +1 -1
- package/dist/es-legacy/components/Doku/components/DokuInput/DokuInput.js.map +1 -1
- package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/PaymentMethod/useBrandLogoConfiguration.js.map +1 -1
- package/dist/es-legacy/components/Dropin/elements/filters.js.map +1 -1
- package/dist/es-legacy/components/Dropin/elements/getComponentConfiguration.js.map +1 -1
- package/dist/es-legacy/components/Econtext/components/EcontextInput/EcontextInput.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/Giftcard.js +1 -1
- package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
- package/dist/es-legacy/components/GooglePay/components/GooglePayButton.js +1 -1
- package/dist/es-legacy/components/GooglePay/components/GooglePayButton.js.map +1 -1
- package/dist/es-legacy/components/GooglePay/requests.js.map +1 -1
- package/dist/es-legacy/components/Klarna/KlarnaPayments.js +1 -1
- package/dist/es-legacy/components/Klarna/KlarnaPayments.js.map +1 -1
- package/dist/es-legacy/components/Klarna/components/KlarnaWidget/KlarnaWidget.js.map +1 -1
- package/dist/es-legacy/components/MBWay/MBWay.js.map +1 -1
- package/dist/es-legacy/components/Multibanco/Multibanco.js.map +1 -1
- package/dist/es-legacy/components/Oxxo/Oxxo.js.map +1 -1
- package/dist/es-legacy/components/PayByBankUS/PayByBankUS.js.map +1 -1
- package/dist/es-legacy/components/PayPal/utils/get-paypal-styles.js.map +1 -1
- package/dist/es-legacy/components/Pix/Pix.js.map +1 -1
- package/dist/es-legacy/components/Redirect/Redirect.js.map +1 -1
- package/dist/es-legacy/components/Redirect/components/RedirectShopper/RedirectShopper.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Form/ThreeDS2Form.js.map +1 -1
- package/dist/es-legacy/components/Twint/Twint.js.map +1 -1
- package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
- package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
- package/dist/es-legacy/components/helpers/OpenInvoiceContainer/OpenInvoiceContainer.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
- package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
- package/dist/es-legacy/components/internal/Button/Button.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPResendOtpLink.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPSection/CtPLogoutLink.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/components/CtPSection/CtPLogoutLink.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/context/ClickToPayProvider.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/services/ClickToPayService.js.map +1 -1
- package/dist/es-legacy/components/internal/CompanyDetails/CompanyDetails.js.map +1 -1
- package/dist/es-legacy/components/internal/FormFields/Select/Select.js.map +1 -1
- package/dist/es-legacy/components/internal/IFrame/Iframe.js.map +1 -1
- package/dist/es-legacy/components/internal/IbanInput/IbanInput.js.map +1 -1
- package/dist/es-legacy/components/internal/IssuerList/IssuerList.js.map +1 -1
- package/dist/es-legacy/components/internal/OpenInvoice/OpenInvoice.js.map +1 -1
- package/dist/es-legacy/components/internal/OpenInvoice/utils.js.map +1 -1
- package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/defaultProps.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/AbstractCSF.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/CSF.js.map +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.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleEncryption.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleValidation.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/handleBinValue.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/handleFocus.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/handleIframeConfigFeedback.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/isConfigured.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/postMessageToAllIframes.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/partials/processBrand.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/partials/validateForm.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/callbackUtils.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/destroySecuredFields.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/processErrors.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/AbstractSecuredField.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/utilities/addContextTranslations.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/components/internal/UIElement/utils.js.map +1 -1
- package/dist/es-legacy/components/internal/Voucher/utils.js.map +1 -1
- package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
- package/dist/es-legacy/core/Analytics/constants.js.map +1 -1
- package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
- package/dist/es-legacy/core/Errors/AdyenCheckoutError.js +1 -1
- package/dist/es-legacy/core/Errors/AdyenCheckoutError.js.map +1 -1
- package/dist/es-legacy/core/Errors/SRMessages.js.map +1 -1
- package/dist/es-legacy/core/Errors/constants.js.map +1 -1
- package/dist/es-legacy/core/Errors/utils.js.map +1 -1
- package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
- package/dist/es-legacy/core/Services/http.js +1 -1
- package/dist/es-legacy/core/Services/http.js.map +1 -1
- package/dist/es-legacy/core/Services/sessions/constants.js +1 -1
- package/dist/es-legacy/core/Services/sessions/constants.js.map +1 -1
- package/dist/es-legacy/core/Services/sessions/create-order.js +1 -1
- package/dist/es-legacy/core/Services/sessions/create-order.js.map +1 -1
- package/dist/es-legacy/core/Services/sessions/make-payment.js +1 -1
- package/dist/es-legacy/core/Services/sessions/make-payment.js.map +1 -1
- package/dist/es-legacy/core/Services/sessions/setup-session.js.map +1 -1
- package/dist/es-legacy/core/Services/sessions/submit-details.js +1 -1
- package/dist/es-legacy/core/Services/sessions/submit-details.js.map +1 -1
- package/dist/es-legacy/core/core.js +1 -1
- package/dist/es-legacy/core/core.registry.js.map +1 -1
- package/dist/es-legacy/core/utils.js.map +1 -1
- package/dist/es-legacy/external/classnames/index.js.map +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/language/Language.js.map +1 -1
- package/dist/es-legacy/language/utils.js.map +1 -1
- package/dist/es-legacy/utils/Storage.js.map +1 -1
- package/dist/es-legacy/utils/commonUtils.js.map +1 -1
- package/dist/es-legacy/utils/get-process-message-handler.js.map +1 -1
- package/dist/es-legacy/utils/getOrigin.js.map +1 -1
- package/dist/es-legacy/utils/useForm/reducer.js.map +1 -1
- package/dist/es-legacy/utils/useForm/useForm.js.map +1 -1
- package/package.json +22 -22
- package/styles/adyen.css +45 -45
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecuredFieldsProvider.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SecuredFieldsProvider.ts"],"sourcesContent":["import { Component } from 'preact';\nimport { getErrorObject, getFields, getErrorReducer, validFieldsReducer } from './SFPUtils';\nimport initCSF from '../lib/CSF';\nimport handlers from './SecuredFieldsProviderHandlers';\nimport defaultProps from './defaultProps';\nimport { SFPProps, SFPState, SingleBrandResetObject } from './types';\nimport {\n StylesObject,\n CbObjOnError,\n CbObjOnFocus,\n CbObjOnBrand,\n CbObjOnAllValid,\n CbObjOnFieldValid,\n CbObjOnAutoComplete,\n CbObjOnConfigSuccess,\n CbObjOnLoad,\n SFKeyPressObj\n} from '../lib/types';\nimport { CSFReturnObject, CSFSetupObject } from '../lib/CSF/types';\nimport { CVC_POLICY_REQUIRED, DATE_POLICY_REQUIRED, DEDICATED_CARD_COMPONENTS, ENCRYPTED_CARD_NUMBER, ENCRYPTED_PWD_FIELD } from '../lib/constants';\nimport { BinLookupResponse } from '../../../Card/types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { SFStateErrorObj } from '../../../Card/components/CardInput/types';\nimport { getErrorMessageFromCode } from '../../../../core/Errors/utils';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\n\n/**\n * SecuredFieldsProvider:\n * Initialises & handles the client-side part of SecuredFields\n */\nclass SecuredFieldsProvider extends Component<SFPProps, SFPState> {\n private csfLoadFailTimeout: number;\n private csfLoadFailTimeoutMS: number;\n private csfConfigFailTimeout: number;\n private csfConfigFailTimeoutMS: number;\n private numCharsInField: object;\n private rootNode;\n private numDateFields: number;\n private csf: CSFReturnObject;\n private handleOnLoad: (obj: CbObjOnLoad) => void;\n private handleOnConfigSuccess: (obj: CbObjOnConfigSuccess) => void;\n private handleOnFieldValid: (obj: CbObjOnFieldValid) => void;\n private handleOnAllValid: (obj: CbObjOnAllValid) => void;\n private handleOnBrand: (obj: CbObjOnBrand) => void;\n private handleFocus: (obj: CbObjOnFocus) => void;\n private handleOnError: (obj: CbObjOnError, hasUnsupportedCard?: boolean) => void;\n private handleOnAutoComplete: (obj: CbObjOnAutoComplete) => void;\n private handleOnNoDataRequired: () => void;\n private handleOnTouchstartIOS: (obj) => void;\n private handleKeyPressed: (obj: SFKeyPressObj) => void;\n public state: SFPState;\n public props;\n private issuingCountryCode;\n\n constructor(props: SFPProps) {\n super(props);\n\n const stateObj: SFPState = {\n status: 'loading',\n brand: props.type,\n errors: {},\n valid: {},\n data: {},\n cvcPolicy: CVC_POLICY_REQUIRED,\n expiryDatePolicy: DATE_POLICY_REQUIRED,\n isSfpValid: false,\n hasKoreanFields: props.hasKoreanFields\n };\n this.state = stateObj;\n\n this.csfLoadFailTimeout = null;\n this.csfLoadFailTimeoutMS = 30000;\n\n this.csfConfigFailTimeout = null;\n this.csfConfigFailTimeoutMS = 15000;\n\n this.numCharsInField = {};\n\n // Handlers\n this.handleOnLoad = handlers.handleOnLoad.bind(this);\n this.handleOnConfigSuccess = handlers.handleOnConfigSuccess.bind(this);\n this.handleOnFieldValid = handlers.handleOnFieldValid.bind(this);\n this.handleOnAllValid = handlers.handleOnAllValid.bind(this);\n this.handleOnBrand = handlers.handleOnBrand.bind(this);\n this.handleFocus = handlers.handleFocus.bind(this);\n this.handleOnError = handlers.handleOnError.bind(this);\n this.handleOnNoDataRequired = handlers.handleOnNoDataRequired.bind(this);\n this.handleOnAutoComplete = handlers.handleOnAutoComplete.bind(this);\n this.handleOnTouchstartIOS = handlers.handleOnTouchstartIOS.bind(this); // Only called when iOS detected\n this.handleKeyPressed = handlers.handleKeyPressed.bind(this);\n\n this.processBinLookupResponse = this.processBinLookupResponse.bind(this);\n\n // Bindings for functions exposed to users of this component: SecuredFields & CardInput\n this.setFocusOn = this.setFocusOn.bind(this);\n this.updateStyles = this.updateStyles.bind(this);\n this.handleUnsupportedCard = this.handleUnsupportedCard.bind(this);\n this.showValidation = this.showValidation.bind(this);\n this.destroy = this.destroy.bind(this);\n }\n\n public static defaultProps = defaultProps;\n\n public componentDidMount(): void {\n // When SFP instantiated through SecuredFieldsInput c.f. CardInput\n if (this.props.rootNode) {\n this.setRootNode(this.props.rootNode);\n }\n\n // Find encryptedFields and map them to the values we use to store valid states\n const fields = getFields(this.rootNode);\n const valid = fields.reduce(validFieldsReducer, {});\n\n this.setState({ valid });\n\n // Populate numCharsInField object\n fields.forEach(field => {\n this.numCharsInField[field] = 0;\n });\n\n // Store how many dateFields we are dealing with visually\n this.numDateFields = fields.filter(f => f.match(/Expiry/)).length;\n\n if (fields.length) {\n this.destroy(); // TODO test if this solves the React double render problem.\n this.initializeCSF(this.rootNode);\n } else {\n this.handleOnNoDataRequired();\n }\n }\n\n public componentDidUpdate() {\n this.checkForKCPFields();\n }\n\n public componentWillUnmount(): void {\n this.csf = null;\n clearTimeout(this.csfLoadFailTimeout);\n clearTimeout(this.csfConfigFailTimeout);\n }\n\n private initializeCSF(root: HTMLElement): void {\n let loadingContext = this.props.loadingContext;\n\n // For loading securedFields from local server during development\n if (process.env.NODE_ENV === 'development' && process.env.__SF_ENV__ !== 'build') {\n loadingContext = process.env.__SF_ENV__;\n }\n\n // TODO\n // if(!this.props.keypadFix){\n // send analytics action because to know if anyone *ever* sets this config prop\n // }\n\n const csfSetupObj: CSFSetupObject = {\n rootNode: root,\n type: this.props.type,\n clientKey: this.props.clientKey,\n cardGroupTypes: this.props.brands,\n autoFocus: this.props.autoFocus,\n trimTrailingSeparator: this.props.trimTrailingSeparator,\n loadingContext,\n keypadFix: this.props.keypadFix,\n showWarnings: this.props.showWarnings,\n iframeUIConfig: {\n sfStyles: this.props.styles\n },\n i18n: this.props.i18n,\n callbacks: {\n onLoad: this.handleOnLoad,\n onConfigSuccess: this.handleOnConfigSuccess,\n onFieldValid: this.handleOnFieldValid,\n onAllValid: this.handleOnAllValid,\n onBrand: this.handleOnBrand,\n onError: this.handleOnError,\n onFocus: this.handleFocus,\n onBinValue: this.props.onBinValue,\n onAutoComplete: this.handleOnAutoComplete,\n onAdditionalSFConfig: this.props.onAdditionalSFConfig,\n onAdditionalSFRemoved: this.props.onAdditionalSFRemoved,\n onTouchstartIOS: this.handleOnTouchstartIOS,\n onKeyPressed: this.handleKeyPressed\n },\n isKCP: this.state.hasKoreanFields,\n legacyInputMode: this.props.legacyInputMode,\n minimumExpiryDate: this.props.minimumExpiryDate,\n implementationType: this.props.implementationType || 'components', // to distinguish between 'regular' and 'custom' card component\n forceCompat: this.props.forceCompat,\n maskSecurityCode: this.props.maskSecurityCode,\n exposeExpiryDate: this.props.exposeExpiryDate,\n shouldDisableIOSArrowKeys: !!this.props.disableIOSArrowKeys, // convert whether function has been defined into a boolean\n placeholders: this.props.placeholders ?? {},\n showContextualElement: this.props.showContextualElement\n };\n\n this.csf = initCSF(csfSetupObj);\n\n /**\n * Expect to at least have had the handleOnLoad callback called within this time\n * - if this hasn't happened then something has happened to interrupt the loading of the securedFields\n * So we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n // @ts-ignore - timout 'type' is a number\n this.csfLoadFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfLoadFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured field iframes have failed to load'));\n }\n }, this.csfLoadFailTimeoutMS);\n }\n\n private checkForKCPFields() {\n let needsKoreanFields = false;\n if (this.props.koreanAuthenticationRequired) {\n needsKoreanFields = this.issuingCountryCode ? this.issuingCountryCode === 'kr' : this.props.countryCode === 'kr';\n }\n\n // Was korean, now isn't - hide password field\n if (this.state.hasKoreanFields && !needsKoreanFields) {\n // Clear any stored data\n const setRemovedFieldState = prevState => ({\n data: { ...prevState.data, [ENCRYPTED_PWD_FIELD]: undefined },\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n errors: { ...prevState.errors, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: false\n });\n\n this.setState(setRemovedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.removeSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(false);\n }\n\n // Wasn't korean, now is - show password field\n if (!this.state.hasKoreanFields && needsKoreanFields) {\n const setAddedFieldState = prevState => ({\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: true,\n isSfpValid: false\n });\n\n this.setState(setAddedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.addSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(true);\n }\n }\n\n public getChildContext(): object {\n return { i18n: this.props.i18n };\n }\n\n public handleUnsupportedCard(errObj: CbObjOnError): boolean {\n const hasUnsupportedCard = !!errObj.error;\n\n // Store the brand(s) we detected and which we don't support\n if (hasUnsupportedCard) {\n this.setState({ detectedUnsupportedBrands: errObj.detectedBrands });\n }\n\n errObj.rootNode = this.rootNode; // Needed for CustomCard\n this.handleOnError(errObj, hasUnsupportedCard);\n // Inform CSF that the number field has an unsupportedCard error (or that it has been cleared)\n if (this.csf) {\n this.csf.hasUnsupportedCard(ENCRYPTED_CARD_NUMBER, errObj.error);\n }\n return hasUnsupportedCard;\n }\n\n public setFocusOn(frame: string): void {\n if (this.csf) this.csf.setFocusOnFrame(frame);\n }\n\n public updateStyles(stylesObj: StylesObject): void {\n if (this.csf) this.csf.updateStyles(stylesObj);\n }\n\n public sfIsOptionalOrHidden(fieldType: string): boolean {\n return this.csf.sfIsOptionalOrHidden(fieldType);\n }\n\n public destroy(): void {\n if (this.csf) this.csf.destroy();\n }\n\n public showValidation(): void {\n const { numDateFields, state }: SecuredFieldsProvider = this;\n\n Object.keys(state.valid)\n .reduce(getErrorReducer(numDateFields, state), [])\n .forEach(field => {\n // For each detected error pass an error object to the handler (calls error callback & sets state)\n const errorObj: CbObjOnError = getErrorObject(field, this.rootNode, state);\n this.handleOnError(errorObj, !!state.detectedUnsupportedBrands);\n // Inform the secured-fields instance of which fields have been found to have errors\n if (this.csf && this.csf.isValidated) {\n this.csf.isValidated(field, errorObj.error);\n }\n });\n }\n\n /**\n * Map SF errors to ValidationRuleResult-like objects, for CardInput component\n */\n public mapErrorsToValidationRuleResult(): SFStateErrorObj {\n const fieldNames: string[] = Object.keys(this.state.errors);\n\n const sfStateErrorsObj = fieldNames.reduce((acc, fieldName) => {\n const errorCode = this.state.errors[fieldName];\n if (errorCode) {\n acc[fieldName] = {\n isValid: false,\n errorMessage: getErrorMessageFromCode(errorCode, SF_ErrorCodes), // this is the human-readable, untranslated, explanation of the error that will exist on the error object in card.state.errors\n // For v5 the object found in state.errors should also contain the additional properties that used to be sent to the onError callback\n // namely: translation, errorCode, a ref to rootNode &, in the case of failed binLookup, an array of the detectedBrands\n errorI18n: this.props.i18n.get(errorCode),\n error: errorCode,\n rootNode: this.rootNode,\n ...(this.state.detectedUnsupportedBrands && { detectedBrands: this.state.detectedUnsupportedBrands })\n };\n } else {\n acc[fieldName] = null;\n }\n return acc;\n }, {});\n return sfStateErrorsObj;\n }\n\n public processBinLookupResponse(binLookupResponse: BinLookupResponse, resetObject: SingleBrandResetObject): void {\n // If we were dealing with an unsupported card & now we have a valid /binLookup response (or a response triggering a reset of the UI),\n // - reset state to clear the error & the stored unsupportedBrands and, in the case of a valid /binLookup response, inform CSF (via handleUnsupportedCard)\n // (Scenario: from an unsupportedCard state the shopper has pasted another number long enough to trigger a /binLookup)\n if (this.state.detectedUnsupportedBrands) {\n this.setState(prevState => ({\n errors: { ...prevState.errors, [ENCRYPTED_CARD_NUMBER]: false },\n detectedUnsupportedBrands: null\n }));\n\n // If we have some sort of binLookupResponse object then this isn't the reset caused by digits dropping below a threshold\n // - so call handleUnsupportedCard to clear the error\n if (this.csf && binLookupResponse) {\n const errObj: CbObjOnError = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n this.handleUnsupportedCard(errObj);\n }\n }\n\n this.issuingCountryCode = binLookupResponse?.issuingCountryCode?.toLowerCase();\n\n const hasBrandedResetObj = resetObject?.brand;\n\n /**\n * Are we dealing with a \"dedicated\" card scenario i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands\n * - in which case we will need to reset brand and pass on the resetObj to CSF\n */\n const mustResetDedicatedBrand = hasBrandedResetObj && DEDICATED_CARD_COMPONENTS.includes(resetObject.brand);\n\n if (mustResetDedicatedBrand) {\n // resetObject.brand will be the value of the brand whose logo we want to reshow in the UI\n this.setState(resetObject, () => {\n this.props.onChange(this.state);\n });\n }\n\n /**\n * Scenarios:\n *\n * - RESET (binLookupResponse === null): The number of digits in number field has dropped below threshold for BIN lookup\n * - RESULT (binLookupResponse.supportedBrands.length === 1): binLookup has found a result so inform CSF\n *\n * In the RESET scenario, for \"dedicated\" card components we also need to pass on the resetObject since this contains information about\n * the brand that CSF needs to reset to, internally.\n */\n if (this.csf) this.csf.brandsFromBinLookup(binLookupResponse, mustResetDedicatedBrand ? resetObject : null);\n }\n\n private setRootNode = (input: HTMLElement): void => {\n this.rootNode = input;\n };\n\n public render(props, state) {\n return props.render({ setRootNode: this.setRootNode, setFocusOn: this.setFocusOn }, state);\n }\n}\n\nexport default SecuredFieldsProvider;\n"],"names":["SecuredFieldsProvider","Component","componentDidMount","this","props","rootNode","setRootNode","fields","getFields","valid","reduce","validFieldsReducer","setState","forEach","field","numCharsInField","numDateFields","filter","f","match","length","destroy","initializeCSF","handleOnNoDataRequired","componentDidUpdate","checkForKCPFields","componentWillUnmount","csf","clearTimeout","csfLoadFailTimeout","csfConfigFailTimeout","root","loadingContext","_this_props_placeholders","csfSetupObj","type","clientKey","cardGroupTypes","brands","autoFocus","trimTrailingSeparator","keypadFix","showWarnings","iframeUIConfig","sfStyles","styles","i18n","callbacks","onLoad","handleOnLoad","onConfigSuccess","handleOnConfigSuccess","onFieldValid","handleOnFieldValid","onAllValid","handleOnAllValid","onBrand","handleOnBrand","onError","handleOnError","onFocus","handleFocus","onBinValue","onAutoComplete","handleOnAutoComplete","onAdditionalSFConfig","onAdditionalSFRemoved","onTouchstartIOS","handleOnTouchstartIOS","onKeyPressed","handleKeyPressed","isKCP","state","hasKoreanFields","legacyInputMode","minimumExpiryDate","implementationType","forceCompat","maskSecurityCode","exposeExpiryDate","shouldDisableIOSArrowKeys","disableIOSArrowKeys","placeholders","showContextualElement","initCSF","setTimeout","status","AdyenCheckoutError","csfLoadFailTimeoutMS","needsKoreanFields","koreanAuthenticationRequired","issuingCountryCode","countryCode","setRemovedFieldState","prevState","data","_object_spread_props","_object_spread","ENCRYPTED_PWD_FIELD","undefined","errors","onChange","removeSecuredField","setKCPStatus","setAddedFieldState","isSfpValid","addSecuredField","getChildContext","handleUnsupportedCard","errObj","hasUnsupportedCard","error","detectedUnsupportedBrands","detectedBrands","ENCRYPTED_CARD_NUMBER","setFocusOn","frame","setFocusOnFrame","updateStyles","stylesObj","sfIsOptionalOrHidden","fieldType","showValidation","Object","keys","getErrorReducer","errorObj","getErrorObject","isValidated","mapErrorsToValidationRuleResult","acc","fieldName","errorCode","isValid","errorMessage","getErrorMessageFromCode","SF_ErrorCodes","errorI18n","get","processBinLookupResponse","binLookupResponse","resetObject","toLowerCase","mustResetDedicatedBrand","brand","DEDICATED_CARD_COMPONENTS","includes","brandsFromBinLookup","render","constructor","super","_define_property","csfConfigFailTimeoutMS","input","stateObj","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","handlers","bind","defaultProps"],"mappings":"68CA8BA,MAAMA,UAA8BC,EAyEzBC,iBAAAA,GAECC,KAAKC,MAAMC,UACXF,KAAKG,YAAYH,KAAKC,MAAMC,UAIhC,MAAME,EAASC,EAAUL,KAAKE,UACxBI,EAAQF,EAAOG,OAAOC,EAAoB,CAAC,GAEjDR,KAAKS,SAAS,CAAEH,UAGhBF,EAAOM,SAAQC,IACXX,KAAKY,gBAAgBD,GAAS,CAAA,IAIlCX,KAAKa,cAAgBT,EAAOU,QAAOC,GAAKA,EAAEC,MAAM,YAAWC,OAEvDb,EAAOa,QACPjB,KAAKkB,UACLlB,KAAKmB,cAAcnB,KAAKE,WAExBF,KAAKoB,wBAEb,CAEOC,kBAAAA,GACHrB,KAAKsB,mBACT,CAEOC,oBAAAA,GACHvB,KAAKwB,IAAM,KACXC,aAAazB,KAAK0B,oBAClBD,aAAazB,KAAK2B,qBACtB,CAEQR,aAAAA,CAAcS,GAClB,IAAIC,EAAiB7B,KAAKC,MAAM4B,eAiDd,IAAAC,EArClB,MAAMC,EAA8B,CAChC7B,SAAU0B,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GnEA,KAAKgH,WAAahH,KAAKgH,WAAW6C,KAAK7J,MACvCA,KAAKmH,aAAenH,KAAKmH,aAAa0C,KAAK7J,MAC3CA,KAAKyG,sBAAwBzG,KAAKyG,sBAAsBoD,KAAK7J,MAC7DA,KAAKuH,eAAiBvH,KAAKuH,eAAesC,KAAK7J,MAC/CA,KAAKkB,QAAUlB,KAAKkB,QAAQ2I,KAAK7J,KACrC,EAEAoJ,EAvEEvJ,EAuEYiK,eAAeA"}
|
|
1
|
+
{"version":3,"file":"SecuredFieldsProvider.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SecuredFieldsProvider.ts"],"sourcesContent":["import { Component } from 'preact';\nimport { getErrorObject, getFields, getErrorReducer, validFieldsReducer } from './SFPUtils';\nimport initCSF from '../lib/CSF';\nimport handlers from './SecuredFieldsProviderHandlers';\nimport defaultProps from './defaultProps';\nimport { SFPProps, SFPState, SingleBrandResetObject } from './types';\nimport {\n StylesObject,\n CardErrorData,\n CardFocusData,\n CardBrandData,\n CardAllValidData,\n CardFieldValidData,\n CardAutoCompleteData,\n CardConfigSuccessData,\n CardLoadData,\n SFKeyPressObj\n} from '../lib/types';\nimport { CSFReturnObject, CSFSetupObject } from '../lib/CSF/types';\nimport { CVC_POLICY_REQUIRED, DATE_POLICY_REQUIRED, DEDICATED_CARD_COMPONENTS, ENCRYPTED_CARD_NUMBER, ENCRYPTED_PWD_FIELD } from '../lib/constants';\nimport { BinLookupResponse } from '../../../Card/types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { SFStateErrorObj } from '../../../Card/components/CardInput/types';\nimport { getErrorMessageFromCode } from '../../../../core/Errors/utils';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\n\n/**\n * SecuredFieldsProvider:\n * Initialises & handles the client-side part of SecuredFields\n */\nclass SecuredFieldsProvider extends Component<SFPProps, SFPState> {\n private csfLoadFailTimeout: number;\n private csfLoadFailTimeoutMS: number;\n private csfConfigFailTimeout: number;\n private csfConfigFailTimeoutMS: number;\n private numCharsInField: object;\n private rootNode;\n private numDateFields: number;\n private csf: CSFReturnObject;\n private handleOnLoad: (obj: CardLoadData) => void;\n private handleOnConfigSuccess: (obj: CardConfigSuccessData) => void;\n private handleOnFieldValid: (obj: CardFieldValidData) => void;\n private handleOnAllValid: (obj: CardAllValidData) => void;\n private handleOnBrand: (obj: CardBrandData) => void;\n private handleFocus: (obj: CardFocusData) => void;\n private handleOnError: (obj: CardErrorData, hasUnsupportedCard?: boolean) => void;\n private handleOnAutoComplete: (obj: CardAutoCompleteData) => void;\n private handleOnNoDataRequired: () => void;\n private handleOnTouchstartIOS: (obj) => void;\n private handleKeyPressed: (obj: SFKeyPressObj) => void;\n public state: SFPState;\n public props;\n private issuingCountryCode;\n\n constructor(props: SFPProps) {\n super(props);\n\n const stateObj: SFPState = {\n status: 'loading',\n brand: props.type,\n errors: {},\n valid: {},\n data: {},\n cvcPolicy: CVC_POLICY_REQUIRED,\n expiryDatePolicy: DATE_POLICY_REQUIRED,\n isSfpValid: false,\n hasKoreanFields: props.hasKoreanFields\n };\n this.state = stateObj;\n\n this.csfLoadFailTimeout = null;\n this.csfLoadFailTimeoutMS = 30000;\n\n this.csfConfigFailTimeout = null;\n this.csfConfigFailTimeoutMS = 15000;\n\n this.numCharsInField = {};\n\n // Handlers\n this.handleOnLoad = handlers.handleOnLoad.bind(this);\n this.handleOnConfigSuccess = handlers.handleOnConfigSuccess.bind(this);\n this.handleOnFieldValid = handlers.handleOnFieldValid.bind(this);\n this.handleOnAllValid = handlers.handleOnAllValid.bind(this);\n this.handleOnBrand = handlers.handleOnBrand.bind(this);\n this.handleFocus = handlers.handleFocus.bind(this);\n this.handleOnError = handlers.handleOnError.bind(this);\n this.handleOnNoDataRequired = handlers.handleOnNoDataRequired.bind(this);\n this.handleOnAutoComplete = handlers.handleOnAutoComplete.bind(this);\n this.handleOnTouchstartIOS = handlers.handleOnTouchstartIOS.bind(this); // Only called when iOS detected\n this.handleKeyPressed = handlers.handleKeyPressed.bind(this);\n\n this.processBinLookupResponse = this.processBinLookupResponse.bind(this);\n\n // Bindings for functions exposed to users of this component: SecuredFields & CardInput\n this.setFocusOn = this.setFocusOn.bind(this);\n this.updateStyles = this.updateStyles.bind(this);\n this.handleUnsupportedCard = this.handleUnsupportedCard.bind(this);\n this.showValidation = this.showValidation.bind(this);\n this.destroy = this.destroy.bind(this);\n }\n\n public static defaultProps = defaultProps;\n\n public componentDidMount(): void {\n // When SFP instantiated through SecuredFieldsInput c.f. CardInput\n if (this.props.rootNode) {\n this.setRootNode(this.props.rootNode);\n }\n\n // Find encryptedFields and map them to the values we use to store valid states\n const fields = getFields(this.rootNode);\n const valid = fields.reduce(validFieldsReducer, {});\n\n this.setState({ valid });\n\n // Populate numCharsInField object\n fields.forEach(field => {\n this.numCharsInField[field] = 0;\n });\n\n // Store how many dateFields we are dealing with visually\n this.numDateFields = fields.filter(f => f.match(/Expiry/)).length;\n\n if (fields.length) {\n this.destroy(); // TODO test if this solves the React double render problem.\n this.initializeCSF(this.rootNode);\n } else {\n this.handleOnNoDataRequired();\n }\n }\n\n public componentDidUpdate() {\n this.checkForKCPFields();\n }\n\n public componentWillUnmount(): void {\n this.csf = null;\n clearTimeout(this.csfLoadFailTimeout);\n clearTimeout(this.csfConfigFailTimeout);\n }\n\n private initializeCSF(root: HTMLElement): void {\n let loadingContext = this.props.loadingContext;\n\n // For loading securedFields from local server during development\n if (process.env.NODE_ENV === 'development' && process.env.__SF_ENV__ !== 'build') {\n loadingContext = process.env.__SF_ENV__;\n }\n\n // TODO\n // if(!this.props.keypadFix){\n // send analytics action because to know if anyone *ever* sets this config prop\n // }\n\n const csfSetupObj: CSFSetupObject = {\n rootNode: root,\n type: this.props.type,\n clientKey: this.props.clientKey,\n cardGroupTypes: this.props.brands,\n autoFocus: this.props.autoFocus,\n trimTrailingSeparator: this.props.trimTrailingSeparator,\n loadingContext,\n keypadFix: this.props.keypadFix,\n showWarnings: this.props.showWarnings,\n iframeUIConfig: {\n sfStyles: this.props.styles\n },\n i18n: this.props.i18n,\n callbacks: {\n onLoad: this.handleOnLoad,\n onConfigSuccess: this.handleOnConfigSuccess,\n onFieldValid: this.handleOnFieldValid,\n onAllValid: this.handleOnAllValid,\n onBrand: this.handleOnBrand,\n onError: this.handleOnError,\n onFocus: this.handleFocus,\n onBinValue: this.props.onBinValue,\n onAutoComplete: this.handleOnAutoComplete,\n onAdditionalSFConfig: this.props.onAdditionalSFConfig,\n onAdditionalSFRemoved: this.props.onAdditionalSFRemoved,\n onTouchstartIOS: this.handleOnTouchstartIOS,\n onKeyPressed: this.handleKeyPressed\n },\n isKCP: this.state.hasKoreanFields,\n legacyInputMode: this.props.legacyInputMode,\n minimumExpiryDate: this.props.minimumExpiryDate,\n implementationType: this.props.implementationType || 'components', // to distinguish between 'regular' and 'custom' card component\n forceCompat: this.props.forceCompat,\n maskSecurityCode: this.props.maskSecurityCode,\n exposeExpiryDate: this.props.exposeExpiryDate,\n shouldDisableIOSArrowKeys: !!this.props.disableIOSArrowKeys, // convert whether function has been defined into a boolean\n placeholders: this.props.placeholders ?? {},\n showContextualElement: this.props.showContextualElement\n };\n\n this.csf = initCSF(csfSetupObj);\n\n /**\n * Expect to at least have had the handleOnLoad callback called within this time\n * - if this hasn't happened then something has happened to interrupt the loading of the securedFields\n * So we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n // @ts-ignore - timout 'type' is a number\n this.csfLoadFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfLoadFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured field iframes have failed to load'));\n }\n }, this.csfLoadFailTimeoutMS);\n }\n\n private checkForKCPFields() {\n let needsKoreanFields = false;\n if (this.props.koreanAuthenticationRequired) {\n needsKoreanFields = this.issuingCountryCode ? this.issuingCountryCode === 'kr' : this.props.countryCode === 'kr';\n }\n\n // Was korean, now isn't - hide password field\n if (this.state.hasKoreanFields && !needsKoreanFields) {\n // Clear any stored data\n const setRemovedFieldState = prevState => ({\n data: { ...prevState.data, [ENCRYPTED_PWD_FIELD]: undefined },\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n errors: { ...prevState.errors, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: false\n });\n\n this.setState(setRemovedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.removeSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(false);\n }\n\n // Wasn't korean, now is - show password field\n if (!this.state.hasKoreanFields && needsKoreanFields) {\n const setAddedFieldState = prevState => ({\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: true,\n isSfpValid: false\n });\n\n this.setState(setAddedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.addSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(true);\n }\n }\n\n public getChildContext(): object {\n return { i18n: this.props.i18n };\n }\n\n public handleUnsupportedCard(errObj: CardErrorData): boolean {\n const hasUnsupportedCard = !!errObj.error;\n\n // Store the brand(s) we detected and which we don't support\n if (hasUnsupportedCard) {\n this.setState({ detectedUnsupportedBrands: errObj.detectedBrands });\n }\n\n errObj.rootNode = this.rootNode; // Needed for CustomCard\n this.handleOnError(errObj, hasUnsupportedCard);\n // Inform CSF that the number field has an unsupportedCard error (or that it has been cleared)\n if (this.csf) {\n this.csf.hasUnsupportedCard(ENCRYPTED_CARD_NUMBER, errObj.error);\n }\n return hasUnsupportedCard;\n }\n\n public setFocusOn(frame: string): void {\n if (this.csf) this.csf.setFocusOnFrame(frame);\n }\n\n public updateStyles(stylesObj: StylesObject): void {\n if (this.csf) this.csf.updateStyles(stylesObj);\n }\n\n public sfIsOptionalOrHidden(fieldType: string): boolean {\n return this.csf.sfIsOptionalOrHidden(fieldType);\n }\n\n public destroy(): void {\n if (this.csf) this.csf.destroy();\n }\n\n public showValidation(): void {\n const { numDateFields, state }: SecuredFieldsProvider = this;\n\n Object.keys(state.valid)\n .reduce(getErrorReducer(numDateFields, state), [])\n .forEach(field => {\n // For each detected error pass an error object to the handler (calls error callback & sets state)\n const errorObj: CardErrorData = getErrorObject(field, this.rootNode, state);\n this.handleOnError(errorObj, !!state.detectedUnsupportedBrands);\n // Inform the secured-fields instance of which fields have been found to have errors\n if (this.csf && this.csf.isValidated) {\n this.csf.isValidated(field, errorObj.error);\n }\n });\n }\n\n /**\n * Map SF errors to ValidationRuleResult-like objects, for CardInput component\n */\n public mapErrorsToValidationRuleResult(): SFStateErrorObj {\n const fieldNames: string[] = Object.keys(this.state.errors);\n\n const sfStateErrorsObj = fieldNames.reduce((acc, fieldName) => {\n const errorCode = this.state.errors[fieldName];\n if (errorCode) {\n acc[fieldName] = {\n isValid: false,\n errorMessage: getErrorMessageFromCode(errorCode, SF_ErrorCodes), // this is the human-readable, untranslated, explanation of the error that will exist on the error object in card.state.errors\n // For v5 the object found in state.errors should also contain the additional properties that used to be sent to the onError callback\n // namely: translation, errorCode, a ref to rootNode &, in the case of failed binLookup, an array of the detectedBrands\n errorI18n: this.props.i18n.get(errorCode),\n error: errorCode,\n rootNode: this.rootNode,\n ...(this.state.detectedUnsupportedBrands && { detectedBrands: this.state.detectedUnsupportedBrands })\n };\n } else {\n acc[fieldName] = null;\n }\n return acc;\n }, {});\n return sfStateErrorsObj;\n }\n\n public processBinLookupResponse(binLookupResponse: BinLookupResponse, resetObject: SingleBrandResetObject): void {\n // If we were dealing with an unsupported card & now we have a valid /binLookup response (or a response triggering a reset of the UI),\n // - reset state to clear the error & the stored unsupportedBrands and, in the case of a valid /binLookup response, inform CSF (via handleUnsupportedCard)\n // (Scenario: from an unsupportedCard state the shopper has pasted another number long enough to trigger a /binLookup)\n if (this.state.detectedUnsupportedBrands) {\n this.setState(prevState => ({\n errors: { ...prevState.errors, [ENCRYPTED_CARD_NUMBER]: false },\n detectedUnsupportedBrands: null\n }));\n\n // If we have some sort of binLookupResponse object then this isn't the reset caused by digits dropping below a threshold\n // - so call handleUnsupportedCard to clear the error\n if (this.csf && binLookupResponse) {\n const errObj: CardErrorData = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n this.handleUnsupportedCard(errObj);\n }\n }\n\n this.issuingCountryCode = binLookupResponse?.issuingCountryCode?.toLowerCase();\n\n const hasBrandedResetObj = resetObject?.brand;\n\n /**\n * Are we dealing with a \"dedicated\" card scenario i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands\n * - in which case we will need to reset brand and pass on the resetObj to CSF\n */\n const mustResetDedicatedBrand = hasBrandedResetObj && DEDICATED_CARD_COMPONENTS.includes(resetObject.brand);\n\n if (mustResetDedicatedBrand) {\n // resetObject.brand will be the value of the brand whose logo we want to reshow in the UI\n this.setState(resetObject, () => {\n this.props.onChange(this.state);\n });\n }\n\n /**\n * Scenarios:\n *\n * - RESET (binLookupResponse === null): The number of digits in number field has dropped below threshold for BIN lookup\n * - RESULT (binLookupResponse.supportedBrands.length === 1): binLookup has found a result so inform CSF\n *\n * In the RESET scenario, for \"dedicated\" card components we also need to pass on the resetObject since this contains information about\n * the brand that CSF needs to reset to, internally.\n */\n if (this.csf) this.csf.brandsFromBinLookup(binLookupResponse, mustResetDedicatedBrand ? resetObject : null);\n }\n\n private setRootNode = (input: HTMLElement): void => {\n this.rootNode = input;\n };\n\n public render(props, state) {\n return props.render({ setRootNode: this.setRootNode, setFocusOn: this.setFocusOn }, state);\n }\n}\n\nexport default SecuredFieldsProvider;\n"],"names":["SecuredFieldsProvider","Component","componentDidMount","this","props","rootNode","setRootNode","fields","getFields","valid","reduce","validFieldsReducer","setState","forEach","field","numCharsInField","numDateFields","filter","f","match","length","destroy","initializeCSF","handleOnNoDataRequired","componentDidUpdate","checkForKCPFields","componentWillUnmount","csf","clearTimeout","csfLoadFailTimeout","csfConfigFailTimeout","root","loadingContext","_this_props_placeholders","csfSetupObj","type","clientKey","cardGroupTypes","brands","autoFocus","trimTrailingSeparator","keypadFix","showWarnings","iframeUIConfig","sfStyles","styles","i18n","callbacks","onLoad","handleOnLoad","onConfigSuccess","handleOnConfigSuccess","onFieldValid","handleOnFieldValid","onAllValid","handleOnAllValid","onBrand","handleOnBrand","onError","handleOnError","onFocus","handleFocus","onBinValue","onAutoComplete","handleOnAutoComplete","onAdditionalSFConfig","onAdditionalSFRemoved","onTouchstartIOS","handleOnTouchstartIOS","onKeyPressed","handleKeyPressed","isKCP","state","hasKoreanFields","legacyInputMode","minimumExpiryDate","implementationType","forceCompat","maskSecurityCode","exposeExpiryDate","shouldDisableIOSArrowKeys","disableIOSArrowKeys","placeholders","showContextualElement","initCSF","setTimeout","status","AdyenCheckoutError","csfLoadFailTimeoutMS","needsKoreanFields","koreanAuthenticationRequired","issuingCountryCode","countryCode","setRemovedFieldState","prevState","data","_object_spread_props","_object_spread","ENCRYPTED_PWD_FIELD","undefined","errors","onChange","removeSecuredField","setKCPStatus","setAddedFieldState","isSfpValid","addSecuredField","getChildContext","handleUnsupportedCard","errObj","hasUnsupportedCard","error","detectedUnsupportedBrands","detectedBrands","ENCRYPTED_CARD_NUMBER","setFocusOn","frame","setFocusOnFrame","updateStyles","stylesObj","sfIsOptionalOrHidden","fieldType","showValidation","Object","keys","getErrorReducer","errorObj","getErrorObject","isValidated","mapErrorsToValidationRuleResult","acc","fieldName","errorCode","isValid","errorMessage","getErrorMessageFromCode","SF_ErrorCodes","errorI18n","get","processBinLookupResponse","binLookupResponse","resetObject","toLowerCase","mustResetDedicatedBrand","brand","DEDICATED_CARD_COMPONENTS","includes","brandsFromBinLookup","render","constructor","super","_define_property","csfConfigFailTimeoutMS","input","stateObj","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","handlers","bind","defaultProps"],"mappings":"68CA8BA,MAAMA,UAA8BC,EAyEzBC,iBAAAA,GAECC,KAAKC,MAAMC,UACXF,KAAKG,YAAYH,KAAKC,MAAMC,UAIhC,MAAME,EAASC,EAAUL,KAAKE,UAC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A,KAAKkD,mBAAqB0G,EAAS1G,mBAAmB2G,KAAK7J,MAC3DA,KAAKoD,iBAAmBwG,EAASxG,iBAAiByG,KAAK7J,MACvDA,KAAKsD,cAAgBsG,EAAStG,cAAcuG,KAAK7J,MACjDA,KAAK0D,YAAckG,EAASlG,YAAYmG,KAAK7J,MAC7CA,KAAKwD,cAAgBoG,EAASpG,cAAcqG,KAAK7J,MACjDA,KAAKoB,uBAAyBwI,EAASxI,uBAAuByI,KAAK7J,MACnEA,KAAK6D,qBAAuB+F,EAAS/F,qBAAqBgG,KAAK7J,MAC/DA,KAAKiE,sBAAwB2F,EAAS3F,sBAAsB4F,KAAK7J,MACjEA,KAAKmE,iBAAmByF,EAASzF,iBAAiB0F,KAAK7J,MAEvDA,KAAKwI,yBAA2BxI,KAAKwI,yBAAyBqB,KAAK7J,MAGnEA,KAAKgH,WAAahH,KAAKgH,WAAW6C,KAAK7J,MACvCA,KAAKmH,aAAenH,KAAKmH,aAAa0C,KAAK7J,MAC3CA,KAAKyG,sBAAwBzG,KAAKyG,sBAAsBoD,KAAK7J,MAC7DA,KAAKuH,eAAiBvH,KAAKuH,eAAesC,KAAK7J,MAC/CA,KAAKkB,QAAUlB,KAAKkB,QAAQ2I,KAAK7J,KACrC,EAEAoJ,EAvEEvJ,EAuEYiK,eAAeA"}
|
package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecuredFieldsProviderHandlers.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.ts"],"sourcesContent":["import { getCardImageUrl } from '../utils';\nimport {\n ENCRYPTED_SECURITY_CODE,\n ENCRYPTED_CARD_NUMBER,\n CVC_POLICY_REQUIRED,\n DATE_POLICY_REQUIRED,\n ENCRYPTED_EXPIRY_DATE,\n OPTIONAL,\n HIDDEN,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR\n} from '../lib/constants';\nimport {\n CbObjOnError,\n CbObjOnFocus,\n CbObjOnBrand,\n CbObjOnAllValid,\n CbObjOnFieldValid,\n CbObjOnAutoComplete,\n CbObjOnConfigSuccess,\n CbObjOnLoad,\n SFKeyPressObj\n} from '../lib/types';\nimport { existy } from '../../../../utils/commonUtils';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\n\n/**\n * Emits the onLoad event\n * Here we can assume all securedFields iframes have fired their 'load' event\n */\nfunction handleOnLoad(cbObj: CbObjOnLoad): void {\n // Clear 'loading' timeout\n clearTimeout(this.csfLoadFailTimeout);\n this.csfLoadFailTimeout = null;\n\n // Propagate onLoad event\n this.props.onLoad(cbObj);\n\n /**\n * Having seen that the securedFields iframes have loaded some kind of content (we don't know what, yet)\n * - setTimeout since we expect to get a successful configuration message \"within a reasonable time\"\n *\n * Now we catch clientKey & environment mismatch in core.ts - this timeout being called indicates that the securedFields have not all configured\n * - so we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n this.csfConfigFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfConfigFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured fields have failed to configure'));\n }\n }, this.csfConfigFailTimeoutMS);\n}\n\n/**\n * Emits the onConfigSuccess (ready) event\n * Here we can assume CSF is loaded, configured and ready to be used\n */\nfunction handleOnConfigSuccess(cbObj: CbObjOnConfigSuccess): void {\n // Clear 'config' timeout\n clearTimeout(this.csfConfigFailTimeout);\n this.csfConfigFailTimeout = null;\n\n this.setState({ status: 'ready' }, () => {\n // Propagate onConfigSuccess event\n this.props.onConfigSuccess(cbObj);\n });\n}\n\n/**\n * Emits the onAllValid event\n */\nfunction handleOnAllValid(status: CbObjOnAllValid): boolean {\n // Form cannot be valid whilst there is an unsupported card\n if (this.state.detectedUnsupportedBrands) {\n return false;\n }\n\n this.setState({ isSfpValid: status.allValid }, () => {\n // New - fixes maestro-with-error-on-optional-cvc-field bug\n this.props.onChange(this.state, { event: 'handleOnAllValid' });\n // Propagate onAllValid event\n this.props.onAllValid(status);\n });\n\n return true;\n}\n\n/**\n * Saves a field value from CSF in the CardInput state\n * Emits the onFieldValid event\n */\nfunction handleOnFieldValid(fieldObj: CbObjOnFieldValid): boolean {\n // A card number field cannot be valid whilst there is an unsupported card\n if (this.state.detectedUnsupportedBrands && fieldObj.fieldType === ENCRYPTED_CARD_NUMBER) {\n return false;\n }\n\n const setValidFieldState = prevState => ({\n data: { ...prevState.data, [fieldObj.encryptedFieldName]: fieldObj.blob },\n valid: { ...prevState.valid, [fieldObj.encryptedFieldName]: fieldObj.valid },\n /**\n * For a field that has just received valid:true (field has just been completed & encrypted) - mark the error state for this field as false\n * For a field that has just received valid:false (field was encrypted, now is not)\n * - field is either in a state of being incomplete but without errors (digit deleted) - so mark the error state for this field as false\n * or has switched from valid/encrypted state to being in error (digit edited to one that puts the field in error) - so keep any error that\n * might just have been set\n */\n errors: { ...prevState.errors, [fieldObj.fieldType]: prevState.errors[fieldObj.fieldType] ?? false }\n });\n\n this.setState(setValidFieldState, () => {\n this.props.onChange(this.state, { event: 'handleOnFieldValid', fieldType: fieldObj.fieldType });\n\n // Propagate onFieldValid event\n this.props.onFieldValid(fieldObj);\n });\n\n return true;\n}\n\nfunction fieldIsInError(fieldType: string, policy: string, numCharsObj: object, errorsObj) {\n return (policy === OPTIONAL || policy === HIDDEN) && numCharsObj[fieldType] === 0 ? false : errorsObj[fieldType];\n}\n\n/**\n * Saves the card brand in state\n * Emits the onBrand event\n */\nfunction handleOnBrand(cardInfo: CbObjOnBrand): void {\n this.setState(\n prevState => {\n /**\n * If we change brand to one where the cvc or date field(s) are not required & are empty - then these fields cannot be in error\n * (scenario: have validated empty form, then choose brand w. optional/hidden cvc or date)...\n * ...else propagate the existing error.\n */\n const cvcFieldInError = fieldIsInError(ENCRYPTED_SECURITY_CODE, cardInfo.cvcPolicy, this.numCharsInField, prevState.errors);\n\n const dateFieldInError =\n this.numDateFields === 1\n ? fieldIsInError(ENCRYPTED_EXPIRY_DATE, cardInfo.expiryDatePolicy, this.numCharsInField, prevState.errors)\n : null;\n\n // For custom card comp\n const monthFieldInError =\n this.numDateFields === 2\n ? fieldIsInError(ENCRYPTED_EXPIRY_MONTH, cardInfo.expiryDatePolicy, this.numCharsInField, prevState.errors)\n : null;\n\n const yearFieldInError =\n this.numDateFields === 2\n ? fieldIsInError(ENCRYPTED_EXPIRY_YEAR, cardInfo.expiryDatePolicy, this.numCharsInField, prevState.errors)\n : null;\n // --\n /** end */\n\n return {\n brand: cardInfo.brand,\n cvcPolicy: cardInfo.cvcPolicy ?? CVC_POLICY_REQUIRED,\n showSocialSecurityNumber: cardInfo.showSocialSecurityNumber,\n errors: {\n ...prevState.errors,\n ...(existy(cvcFieldInError) && { [ENCRYPTED_SECURITY_CODE]: cvcFieldInError }),\n ...(existy(dateFieldInError) && { [ENCRYPTED_EXPIRY_DATE]: dateFieldInError }),\n ...(existy(monthFieldInError) && { [ENCRYPTED_EXPIRY_MONTH]: monthFieldInError }),\n ...(existy(yearFieldInError) && { [ENCRYPTED_EXPIRY_YEAR]: yearFieldInError })\n },\n expiryDatePolicy: cardInfo.expiryDatePolicy ?? DATE_POLICY_REQUIRED\n };\n },\n () => {\n this.props.onChange(this.state, { event: 'handleOnBrand' });\n\n // Enhance data object with the url for the brand image, first checking if the merchant has configured their own one for this brand\n const brandImageUrl = this.props.brandsConfiguration[cardInfo.brand]?.icon ?? getCardImageUrl(cardInfo.brand, this.props.resources);\n this.props.onBrand({ ...cardInfo, brandImageUrl });\n }\n );\n}\n\n/**\n * Handles validation errors\n */\nfunction handleOnError(cbObj: CbObjOnError, hasUnsupportedCard: boolean = null): boolean {\n const errorCode = cbObj.error;\n\n this.setState(\n prevState => ({\n errors: { ...prevState.errors, [cbObj.fieldType]: errorCode || false },\n // If dealing with an unsupported card ensure these card number related fields are reset re. pasting a full, unsupported card straight in\n ...(hasUnsupportedCard && { data: { ...prevState.data, [ENCRYPTED_CARD_NUMBER]: undefined } }),\n ...(hasUnsupportedCard && { valid: { ...prevState.valid, [ENCRYPTED_CARD_NUMBER]: false } }),\n ...(hasUnsupportedCard && { isSfpValid: false })\n }),\n () => {\n this.props.onChange(this.state, { event: 'handleOnError', fieldType: cbObj.fieldType });\n }\n );\n\n return true;\n}\n\nfunction handleFocus(cbObj: CbObjOnFocus): void {\n this.numCharsInField[cbObj.fieldType] = cbObj.numChars;\n\n this.props.onFocus(cbObj);\n}\n\nfunction handleOnTouchstartIOS(cbObj): void {\n // disableIOSArrowKeys is either null or a function (in which case we should call it)\n this.props.disableIOSArrowKeys?.(cbObj);\n}\n\n// Only called for holder name (from CSF>partials>processAutoComplete)\nfunction handleOnAutoComplete(cbObj: CbObjOnAutoComplete): void {\n this.setState({ autoCompleteName: cbObj.value }, () => {\n this.props.onChange(this.state, { event: 'handleOnAutoComplete', fieldType: cbObj.fieldType });\n this.setState({ autoCompleteName: null }); // Nullify ref after sending it (lets shopper edit holder name)\n });\n this.props.onAutoComplete(cbObj);\n}\n\nfunction handleKeyPressed(obj: SFKeyPressObj): void {\n if (obj.action === 'enterKeyPressed') {\n const kb = new KeyboardEvent('keypress', {\n bubbles: true,\n cancelable: true,\n key: 'Enter',\n code: 'Enter'\n });\n this.props.handleKeyPress?.(kb);\n }\n}\n\n/**\n * Handles cases where no secured fields are necessary (one click payments without CVC)\n * Automatically resolves with a valid state\n */\nfunction handleOnNoDataRequired(): void {\n this.setState({ status: 'ready' }, () => this.props.onChange({ isSfpValid: true }));\n}\n\nexport default {\n handleFocus,\n handleOnAllValid,\n handleOnAutoComplete,\n handleOnFieldValid,\n handleOnLoad,\n handleOnConfigSuccess,\n handleOnBrand,\n handleOnError,\n handleOnNoDataRequired,\n handleOnTouchstartIOS,\n handleKeyPressed\n};\n"],"names":["fieldIsInError","fieldType","policy","numCharsObj","errorsObj","OPTIONAL","HIDDEN","handlers","handleFocus","cbObj","this","numCharsInField","numChars","props","onFocus","handleOnAllValid","status","state","detectedUnsupportedBrands","setState","isSfpValid","allValid","onChange","event","onAllValid","handleOnAutoComplete","autoCompleteName","value","onAutoComplete","handleOnFieldValid","fieldObj","ENCRYPTED_CARD_NUMBER","prevState","data","_object_spread_props","_object_spread","encryptedFieldName","blob","valid","errors","onFieldValid","handleOnLoad","clearTimeout","csfLoadFailTimeout","onLoad","csfConfigFailTimeout","setTimeout","onError","AdyenCheckoutError","csfConfigFailTimeoutMS","handleOnConfigSuccess","onConfigSuccess","handleOnBrand","cardInfo","cvcFieldInError","ENCRYPTED_SECURITY_CODE","cvcPolicy","dateFieldInError","numDateFields","ENCRYPTED_EXPIRY_DATE","expiryDatePolicy","monthFieldInError","ENCRYPTED_EXPIRY_MONTH","yearFieldInError","ENCRYPTED_EXPIRY_YEAR","brand","CVC_POLICY_REQUIRED","showSocialSecurityNumber","existy","DATE_POLICY_REQUIRED","_this_props_brandsConfiguration_cardInfo_brand","_this_props_brandsConfiguration_cardInfo_brand_icon","brandImageUrl","brandsConfiguration","icon","getCardImageUrl","resources","onBrand","handleOnError","hasUnsupportedCard","errorCode","error","undefined","handleOnNoDataRequired","handleOnTouchstartIOS","_this_props_disableIOSArrowKeys","_this_props","disableIOSArrowKeys","call","handleKeyPressed","obj","action","_this_props_handleKeyPress","kb","KeyboardEvent","bubbles","cancelable","key","code","handleKeyPress"],"mappings":"4sCA0HA,SAASA,EAAeC,EAAmBC,EAAgBC,EAAqBC,GAC5E,OAAQF,IAAWG,GAAYH,IAAWI,GAAsC,IAA3BH,EAAYF,KAA2BG,EAAUH,EAC1G,CAwHA,IAAeM,EAAA,CACXC,YAzCJ,SAAqBC,GACjBC,KAAKC,gBAAgBF,EAAMR,WAAaQ,EAAMG,SAE9CF,KAAKG,MAAMC,QAAQL,EACvB,EAsCIM,iBA7KJ,SAA0BC,GAEtB,OAAIN,KAAKO,MAAMC,4BAIfR,KAAKS,SAAS,CAAEC,WAAYJ,EAAOK,WAAY,KAE3CX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version":3,"file":"SecuredFieldsProviderHandlers.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SecuredFieldsProviderHandlers.ts"],"sourcesContent":["import { getCardImageUrl } from '../utils';\nimport {\n ENCRYPTED_SECURITY_CODE,\n ENCRYPTED_CARD_NUMBER,\n CVC_POLICY_REQUIRED,\n DATE_POLICY_REQUIRED,\n ENCRYPTED_EXPIRY_DATE,\n OPTIONAL,\n HIDDEN,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR\n} from '../lib/constants';\nimport {\n CardErrorData,\n CardFocusData,\n CardBrandData,\n CardAllValidData,\n CardFieldValidData,\n CardAutoCompleteData,\n CardConfigSuccessData,\n CardLoadData,\n SFKeyPressObj\n} from '../lib/types';\nimport { existy } from '../../../../utils/commonUtils';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\n\n/**\n * Emits the onLoad event\n * Here we can assume all securedFields iframes have fired their 'load' event\n */\nfunction handleOnLoad(cbObj: CardLoadData): void {\n // Clear 'loading' timeout\n clearTimeout(this.csfLoadFailTimeout);\n this.csfLoadFailTimeout = null;\n\n // Propagate onLoad event\n this.props.onLoad(cbObj);\n\n /**\n * Having seen that the securedFields iframes have loaded some kind of content (we don't know what, yet)\n * - setTimeout since we expect to get a successful configuration message \"within a reasonable time\"\n *\n * Now we catch clientKey & environment mismatch in core.ts - this timeout being called indicates that the securedFields have not all configured\n * - so we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n this.csfConfigFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfConfigFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured fields have failed to configure'));\n }\n }, this.csfConfigFailTimeoutMS);\n}\n\n/**\n * Emits the onConfigSuccess (ready) event\n * Here we can assume CSF is loaded, configured and ready to be used\n */\nfunction handleOnConfigSuccess(cbObj: CardConfigSuccessData): void {\n // Clear 'config' timeout\n clearTimeout(this.csfConfigFailTimeout);\n this.csfConfigFailTimeout = null;\n\n this.setState({ status: 'ready' }, () => {\n // Propagate onConfigSuccess event\n this.props.onConfigSuccess(cbObj);\n });\n}\n\n/**\n * Emits the onAllValid event\n */\nfunction handleOnAllValid(status: CardAllValidData): boolean {\n // Form cannot be valid whilst there is an unsupported card\n if (this.state.detectedUnsupportedBrands) {\n return false;\n }\n\n this.setState({ isSfpValid: status.allValid }, () => {\n // New - fixes maestro-with-error-on-optional-cvc-field bug\n this.props.onChange(this.state, { event: 'handleOnAllValid' });\n // Propagate onAllValid event\n this.props.onAllValid(status);\n });\n\n return true;\n}\n\n/**\n * Saves a field value from CSF in the CardInput state\n * Emits the onFieldValid event\n */\nfunction handleOnFieldValid(fieldObj: CardFieldValidData): boolean {\n // A card number field cannot be valid whilst there is an unsupported card\n if (this.state.detectedUnsupportedBrands && fieldObj.fieldType === ENCRYPTED_CARD_NUMBER) {\n return false;\n }\n\n const setValidFieldState = prevState => ({\n data: { ...prevState.data, [fieldObj.encryptedFieldName]: fieldObj.blob },\n valid: { ...prevState.valid, [fieldObj.encryptedFieldName]: fieldObj.valid },\n /**\n * For a field that has just received valid:true (field has just been completed & encrypted) - mark the error state for this field as false\n * For a field that has just received valid:false (field was encrypted, now is not)\n * - field is either in a state of being incomplete but without errors (digit deleted) - so mark the error state for this field as false\n * or has switched from valid/encrypted state to being in error (digit edited to one that puts the field in error) - so keep any error that\n * might just have been set\n */\n errors: { ...prevState.errors, [fieldObj.fieldType]: prevState.errors[fieldObj.fieldType] ?? false }\n });\n\n this.setState(setValidFieldState, () => {\n this.props.onChange(this.state, { event: 'handleOnFieldValid', fieldType: fieldObj.fieldType });\n\n // Propagate onFieldValid event\n this.props.onFieldValid(fieldObj);\n });\n\n return true;\n}\n\nfunction fieldIsInError(fieldType: string, policy: string, numCharsObj: object, errorsObj) {\n return (policy === OPTIONAL || policy === HIDDEN) && numCharsObj[fieldType] === 0 ? false : errorsObj[fieldType];\n}\n\n/**\n * Saves the card brand in state\n * Emits the onBrand event\n */\nfunction handleOnBrand(cardInfo: CardBrandData): void {\n this.setState(\n prevState => {\n /**\n * If we change brand to one where the cvc or date field(s) are not required & are empty - then these fields cannot be in error\n * (scenario: have validated empty form, then choose brand w. optional/hidden cvc or date)...\n * ...else propagate the existing error.\n */\n const cvcFieldInError = fieldIsInError(ENCRYPTED_SECURITY_CODE, cardInfo.cvcPolicy, this.numCharsInField, prevState.errors);\n\n const dateFieldInError =\n this.numDateFields === 1\n ? fieldIsInError(ENCRYPTED_EXPIRY_DATE, cardInfo.expiryDatePolicy, this.numCharsInField, prevState.errors)\n : null;\n\n // For custom card comp\n const monthFieldInError =\n this.numDateFields === 2\n ? fieldIsInError(ENCRYPTED_EXPIRY_MONTH, cardInfo.expiryDatePolicy, this.numCharsInField, prevState.errors)\n : null;\n\n const yearFieldInError =\n this.numDateFields === 2\n ? fieldIsInError(ENCRYPTED_EXPIRY_YEAR, cardInfo.expiryDatePolicy, this.numCharsInField, prevState.errors)\n : null;\n // --\n /** end */\n\n return {\n brand: cardInfo.brand,\n cvcPolicy: cardInfo.cvcPolicy ?? CVC_POLICY_REQUIRED,\n showSocialSecurityNumber: cardInfo.showSocialSecurityNumber,\n errors: {\n ...prevState.errors,\n ...(existy(cvcFieldInError) && { [ENCRYPTED_SECURITY_CODE]: cvcFieldInError }),\n ...(existy(dateFieldInError) && { [ENCRYPTED_EXPIRY_DATE]: dateFieldInError }),\n ...(existy(monthFieldInError) && { [ENCRYPTED_EXPIRY_MONTH]: monthFieldInError }),\n ...(existy(yearFieldInError) && { [ENCRYPTED_EXPIRY_YEAR]: yearFieldInError })\n },\n expiryDatePolicy: cardInfo.expiryDatePolicy ?? DATE_POLICY_REQUIRED\n };\n },\n () => {\n this.props.onChange(this.state, { event: 'handleOnBrand' });\n\n // Enhance data object with the url for the brand image, first checking if the merchant has configured their own one for this brand\n const brandImageUrl = this.props.brandsConfiguration[cardInfo.brand]?.icon ?? getCardImageUrl(cardInfo.brand, this.props.resources);\n this.props.onBrand({ ...cardInfo, brandImageUrl });\n }\n );\n}\n\n/**\n * Handles validation errors\n */\nfunction handleOnError(cbObj: CardErrorData, hasUnsupportedCard: boolean = null): boolean {\n const errorCode = cbObj.error;\n\n this.setState(\n prevState => ({\n errors: { ...prevState.errors, [cbObj.fieldType]: errorCode || false },\n // If dealing with an unsupported card ensure these card number related fields are reset re. pasting a full, unsupported card straight in\n ...(hasUnsupportedCard && { data: { ...prevState.data, [ENCRYPTED_CARD_NUMBER]: undefined } }),\n ...(hasUnsupportedCard && { valid: { ...prevState.valid, [ENCRYPTED_CARD_NUMBER]: false } }),\n ...(hasUnsupportedCard && { isSfpValid: false })\n }),\n () => {\n this.props.onChange(this.state, { event: 'handleOnError', fieldType: cbObj.fieldType });\n }\n );\n\n return true;\n}\n\nfunction handleFocus(cbObj: CardFocusData): void {\n this.numCharsInField[cbObj.fieldType] = cbObj.numChars;\n\n this.props.onFocus(cbObj);\n}\n\nfunction handleOnTouchstartIOS(cbObj): void {\n // disableIOSArrowKeys is either null or a function (in which case we should call it)\n this.props.disableIOSArrowKeys?.(cbObj);\n}\n\n// Only called for holder name (from CSF>partials>processAutoComplete)\nfunction handleOnAutoComplete(cbObj: CardAutoCompleteData): void {\n this.setState({ autoCompleteName: cbObj.value }, () => {\n this.props.onChange(this.state, { event: 'handleOnAutoComplete', fieldType: cbObj.fieldType });\n this.setState({ autoCompleteName: null }); // Nullify ref after sending it (lets shopper edit holder name)\n });\n this.props.onAutoComplete(cbObj);\n}\n\nfunction handleKeyPressed(obj: SFKeyPressObj): void {\n if (obj.action === 'enterKeyPressed') {\n const kb = new KeyboardEvent('keypress', {\n bubbles: true,\n cancelable: true,\n key: 'Enter',\n code: 'Enter'\n });\n this.props.handleKeyPress?.(kb);\n }\n}\n\n/**\n * Handles cases where no secured fields are necessary (one click payments without CVC)\n * Automatically resolves with a valid state\n */\nfunction handleOnNoDataRequired(): void {\n this.setState({ status: 'ready' }, () => this.props.onChange({ isSfpValid: true }));\n}\n\nexport default {\n handleFocus,\n handleOnAllValid,\n handleOnAutoComplete,\n handleOnFieldValid,\n handleOnLoad,\n handleOnConfigSuccess,\n handleOnBrand,\n handleOnError,\n handleOnNoDataRequired,\n handleOnTouchstartIOS,\n handleKeyPressed\n};\n"],"names":["fieldIsInError","fieldType","policy","numCharsObj","errorsObj","OPTIONAL","HIDDEN","handlers","handleFocus","cbObj","this","numCharsInField","numChars","props","onFocus","handleOnAllValid","status","state","detectedUnsupportedBrands","setState","isSfpValid","allValid","onChange","event","onAllValid","handleOnAutoComplete","autoCompleteName","value","onAutoComplete","handleOnFieldValid","fieldObj","ENCRYPTED_CARD_NUMBER","prevState","data","_object_spread_props","_object_spread","encryptedFieldName","blob","valid","errors","onFieldValid","handleOnLoad","clearTimeout","csfLoadFailTimeout","onLoad","csfConfigFailTimeout","setTimeout","onError","AdyenCheckoutError","csfConfigFailTimeoutMS","handleOnConfigSuccess","onConfigSuccess","handleOnBrand","cardInfo","cvcFieldInError","ENCRYPTED_SECURITY_CODE","cvcPolicy","dateFieldInError","numDateFields","ENCRYPTED_EXPIRY_DATE","expiryDatePolicy","monthFieldInError","ENCRYPTED_EXPIRY_MONTH","yearFieldInError","ENCRYPTED_EXPIRY_YEAR","brand","CVC_POLICY_REQUIRED","showSocialSecurityNumber","existy","DATE_POLICY_REQUIRED","_this_props_brandsConfiguration_cardInfo_brand","_this_props_brandsConfiguration_cardInfo_brand_icon","brandImageUrl","brandsConfiguration","icon","getCardImageUrl","resources","onBrand","handleOnError","hasUnsupportedCard","errorCode","error","undefined","handleOnNoDataRequired","handleOnTouchstartIOS","_this_props_disableIOSArrowKeys","_this_props","disableIOSArrowKeys","call","handleKeyPressed","obj","action","_this_props_handleKeyPress","kb","KeyboardEvent","bubbles","cancelable","key","code","handleKeyPress"],"mappings":"4sCA0HA,SAASA,EAAeC,EAAmBC,EAAgBC,EAAqBC,GAC5E,OAAQF,IAAWG,GAAYH,IAAWI,GAAsC,IAA3BH,EAAYF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0BC,GACtB,GAAmB,oBAAfA,EAAIC,OAA8B,KAOlCC,EAAAN,EANA,MAAMO,EAAK,IAAIC,cAAc,WAAY,CACrCC,SAAS,EACTC,YAAY,EACZC,IAAK,QACLC,KAAM,UAEe,QAAzBN,GAAAN,EAAA5E,KAAKG,OAAMsF,sBAAX,IAAAP,GAAAA,EAAAJ,KAAAF,EAA4BO,EAChC,CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultProps.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/defaultProps.ts"],"sourcesContent":["export default {\n type: 'card',\n\n // Settings\n keypadFix: true,\n rootNode: null,\n loadingContext: null,\n brands: [],\n showWarnings: false,\n autoFocus: true,\n trimTrailingSeparator: true,\n\n // Events\n onChange: () => {},\n onLoad: () => {},\n onConfigSuccess: () => {},\n onAllValid: () => {},\n onFieldValid: () => {},\n onBrand: () => {},\n onError: () => {},\n onBinValue: () => {},\n onFocus: () => {},\n onAutoComplete: () => {},\n handleKeyPress: () => {},\n\n // Customization\n styles: {}\n};\n"],"names":["defaultProps","type","keypadFix","rootNode","loadingContext","brands","showWarnings","autoFocus","trimTrailingSeparator","onChange","onLoad","onConfigSuccess","onAllValid","onFieldValid","onBrand","onError","onBinValue","onFocus","onAutoComplete","handleKeyPress","styles"],"mappings":"AAAA,IAAeA,EAAA,CACXC,KAAM,OAGNC,WAAW,EACXC,SAAU,KACVC,eAAgB,KAChBC,OAAQ,GACRC,cAAc,EACdC,WAAW,EACXC,uBAAuB,EAGvBC,SAAU,OACVC,OAAQ,OACRC,gBAAiB,OACjBC,WAAY,OACZC,aAAc,OACdC,QAAS,OACTC,QAAS,OACTC,WAAY,OACZC,QAAS,OACTC,eAAgB,OAChBC,eAAgB,OAGhBC,OAAQ,
|
|
1
|
+
{"version":3,"file":"defaultProps.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/defaultProps.ts"],"sourcesContent":["export default {\n type: 'card',\n\n // Settings\n keypadFix: true,\n rootNode: null,\n loadingContext: null,\n brands: [],\n showWarnings: false,\n autoFocus: true,\n trimTrailingSeparator: true,\n\n // Events\n onChange: () => {},\n onLoad: () => {},\n onConfigSuccess: () => {},\n onAllValid: () => {},\n onFieldValid: () => {},\n onBrand: () => {},\n onError: () => {},\n onBinValue: () => {},\n onFocus: () => {},\n onAutoComplete: () => {},\n handleKeyPress: () => {},\n\n // Customization\n styles: {}\n};\n"],"names":["defaultProps","type","keypadFix","rootNode","loadingContext","brands","showWarnings","autoFocus","trimTrailingSeparator","onChange","onLoad","onConfigSuccess","onAllValid","onFieldValid","onBrand","onError","onBinValue","onFocus","onAutoComplete","handleKeyPress","styles"],"mappings":"AAAA,IAAeA,EAAA,CACXC,KAAM,OAGNC,WAAW,EACXC,SAAU,KACVC,eAAgB,KAChBC,OAAQ,GACRC,cAAc,EACdC,WAAW,EACXC,uBAAuB,EAGvBC,SAAU,OACVC,OAAQ,OACRC,gBAAiB,OACjBC,WAAY,OACZC,aAAc,OACdC,QAAS,OACTC,QAAS,OACTC,WAAY,OACZC,QAAS,OACTC,eAAgB,OAChBC,eAAgB,OAGhBC,OAAQ,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.js","sources":["../../../../../../src/components/internal/SecuredFields/binLookup/extensions.ts"],"sourcesContent":["import { SingleBrandResetObject } from '../SFP/types';\nimport { BrandObject } from '../../../Card/types';\nimport createCardVariantSwitcher from './createCardVariantSwitcher';\nimport { BRAND_ICON_UI_EXCLUSION_LIST } from '../lib/constants';\n\n// Externally testable utils\nexport const containsExcludedBrand = (brandsArr: BrandObject[], excludedBrands: string[]): boolean => {\n return brandsArr.reduce((acc, brandObj) => acc || excludedBrands.includes(brandObj.brand), false);\n};\n\nexport const cloneBrandsArr = (brandsArr: BrandObject[]): BrandObject[] => brandsArr.map(item => ({ ...item }));\n\nexport const removeExcludedBrand = (brandsArr: BrandObject[], mainBrand1 = 'mc', mainBrand2 = 'visa'): BrandObject[] => {\n const clonedBrands: BrandObject[] = cloneBrandsArr(brandsArr);\n\n if (clonedBrands[0].brand !== mainBrand1 && clonedBrands[0].brand !== mainBrand2) clonedBrands.reverse();\n clonedBrands.length = 1;\n return clonedBrands;\n};\n// --\n\nexport default function extensions(props, refs, states, hasPanLengthRef: Partial<{ current }> = {}) {\n // Destructure props, refs and state hooks\n const { type, cvcPolicy } = props;\n const { sfp } = refs;\n const { dualBrandSelectElements, setDualBrandSelectElements, setSelectedBrandValue, issuingCountryCode, setIssuingCountryCode } = states;\n\n return {\n /**\n * Handle the binLookup response object generated in triggerBinLookup and process it in relation to the CardInput and it's sub-components.\n * e.g. we might need to add/remove additional markup (a selector for brands), and inform SFP of the issuingCountryCode & detected brand(s).\n *\n * @param binLookupResponse -\n * @param isReset -\n */\n processBinLookup: (binLookupResponse, isReset) => {\n const issuingCode = binLookupResponse?.issuingCountryCode ? binLookupResponse.issuingCountryCode.toLowerCase() : null;\n setIssuingCountryCode(issuingCode);\n\n // Reset UI\n if (!binLookupResponse || !Object.keys(binLookupResponse).length) {\n setDualBrandSelectElements([]);\n setSelectedBrandValue('');\n\n // If /binLookup has 'reset' then for a generic card the internal regex will kick in to show the right brand icon - so set to null\n // However for a single-branded card we need to pass the \"base\" type so the brand logo is reset - so set to type\n const brandToReset = isReset && type !== 'card' ? type : null;\n\n sfp.current.processBinLookupResponse(binLookupResponse, {\n brand: brandToReset,\n cvcPolicy: cvcPolicy // undefined except for Bancontact\n } as SingleBrandResetObject);\n\n // Reset storage var\n hasPanLengthRef.current = 0;\n return;\n }\n\n // RESULT: binLookup has found a result so proceed accordingly\n if (binLookupResponse.supportedBrands?.length) {\n const hasExcludedBrand: boolean = containsExcludedBrand(binLookupResponse.supportedBrands, BRAND_ICON_UI_EXCLUSION_LIST);\n\n const supportedBrands: BrandObject[] = hasExcludedBrand\n ? removeExcludedBrand(binLookupResponse.supportedBrands)\n : cloneBrandsArr(binLookupResponse.supportedBrands);\n\n // 1) Multiple options found - add to the UI & inform SFP\n if (supportedBrands.length > 1) {\n // --\n const switcherObj = createCardVariantSwitcher(supportedBrands);\n\n // Set properties on state to trigger the dual branding icons in the UI\n setDualBrandSelectElements(switcherObj.dualBrandSelectElements);\n setSelectedBrandValue(switcherObj.selectedBrandValue); // initially this value from switcherObj will be ''\n\n // Pass an object through to SFP\n sfp.current.processBinLookupResponse({\n issuingCountryCode: binLookupResponse.issuingCountryCode,\n supportedBrands: [switcherObj.leadBrand]\n });\n\n // Store the fact the binLookup obj has a panLength prop\n if (switcherObj.leadBrand.panLength > 0) {\n hasPanLengthRef.current = switcherObj.leadBrand.panLength;\n }\n\n // 2) Single option found (binValueObject.supportedBrands.length === 1)\n } else {\n // Reset UI\n setDualBrandSelectElements([]);\n setSelectedBrandValue('');\n\n // Set (single) value from binLookup so it will be added to the 'brand' property in the paymentMethod object\n // EXCEPT - if we are dealing with a brand that we exclude from the UI\n if (!hasExcludedBrand) setSelectedBrandValue(supportedBrands[0].brand);\n\n // Pass object through to SFP\n sfp.current.processBinLookupResponse({\n issuingCountryCode: binLookupResponse.issuingCountryCode,\n supportedBrands\n });\n\n // Store the fact the binLookup obj has a panLength prop\n if (supportedBrands[0].panLength > 0) {\n hasPanLengthRef.current = supportedBrands[0].panLength;\n }\n }\n }\n },\n /**\n * Handler for clicks on the icons added in response to the /binLookup call\n * Inform SFP of the brand changes when these selections are made\n */\n handleDualBrandSelection: (e: Event | string): void => {\n let value: Event | string = e;\n\n if (e instanceof Event) {\n const target = e.target as HTMLLIElement;\n value = target.getAttribute('data-value') || target.getAttribute('alt');\n }\n\n // Check if we have a value and whether that value corresponds to a brandObject we can propagate\n // If either are false then abandon the process\n let brandObjArr: BrandObject[] = [];\n if (value) {\n // Find the brandObject with the matching brand value and place into an array\n brandObjArr = dualBrandSelectElements.reduce((acc, item) => {\n if (item.brandObject.brand === value) {\n acc.push(item.brandObject);\n }\n return acc;\n }, []);\n\n if (!brandObjArr.length) {\n return; // no brand object associated with value was found\n }\n } else {\n return; // no value passed\n }\n\n setSelectedBrandValue(value);\n\n // Pass brand object into SecuredFields\n sfp.current.processBinLookupResponse({\n issuingCountryCode,\n supportedBrands: brandObjArr\n });\n }\n };\n}\n"],"names":["containsExcludedBrand","brandsArr","excludedBrands","reduce","acc","brandObj","includes","brand","cloneBrandsArr","map","item","_object_spread","removeExcludedBrand","mainBrand1","mainBrand2","clonedBrands","reverse","length","extensions","props","refs","states","hasPanLengthRef","type","cvcPolicy","sfp","dualBrandSelectElements","setDualBrandSelectElements","setSelectedBrandValue","issuingCountryCode","setIssuingCountryCode","processBinLookup","binLookupResponse","isReset","issuingCode","toLowerCase","Object","keys","brandToReset","current","processBinLookupResponse","supportedBrands","hasExcludedBrand","BRAND_ICON_UI_EXCLUSION_LIST","switcherObj","createCardVariantSwitcher","selectedBrandValue","leadBrand","panLength","handleDualBrandSelection","e","value","Event","target","getAttribute","brandObjArr","brandObject","push"],"mappings":"yOAMO,MAAMA,EAAwB,CAACC,EAA0BC,IACrDD,EAAUE,QAAO,CAACC,EAAKC,IAAaD,GAAOF,EAAeI,SAASD,EAASE,SAAQ,GAGlFC,EAAkBP,GAA4CA,EAAUQ,KAAIC,yUAASC,CAAA,GAAKD,KAE1FE,EAAsB,CAACX,EAA0BY,EAAa,KAAMC,EAAa,UAC1F,MAAMC,EAA8BP,EAAeP,GAInD,OAFIc,EAAa,GAAGR,QAAUM,GAAcE,EAAa,GAAGR,QAAUO,GAAYC,EAAaC,UAC/FD,EAAaE,OAAS,EACfF,CAAAA,EAII,SAASG,EAAWC,EAAOC,EAAMC,EAAQC,EAAwC,CAAA,GAE5F,MAAMC,KAAEA,EAAIC,UAAEA,GAAcL,GACtBM,IAAEA,GAAQL,GACVM,wBAAEA,EAAuBC,2BAAEA,EAA0BC,sBAAEA,EAAqBC,mBAAEA,EAAkBC,sBAAEA,GAA0BT,EAElI,MAAO,CAQHU,iBAAkB,CAACC,EAAmBC,KAwB9BD,IAAAA,EAvBJ,MAAME,GAAcF,aAAAA,EAAAA,EA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YjD,QAAU4C,GAC3B/C,EAAIqD,KAAK/C,EAAK8C,aAEXpD,IACR,IAEEmD,EAAYtC,SAOrBW,EAAsBuB,GAGtB1B,EAAIc,QAAQC,yBAAyB,CACjCX,qBACAY,gBAAiBc,KACrB,EAGZ"}
|
|
1
|
+
{"version":3,"file":"extensions.js","sources":["../../../../../../src/components/internal/SecuredFields/binLookup/extensions.ts"],"sourcesContent":["import { SingleBrandResetObject } from '../SFP/types';\nimport { BrandObject } from '../../../Card/types';\nimport createCardVariantSwitcher from './createCardVariantSwitcher';\nimport { BRAND_ICON_UI_EXCLUSION_LIST } from '../lib/constants';\n\n// Externally testable utils\nexport const containsExcludedBrand = (brandsArr: BrandObject[], excludedBrands: string[]): boolean => {\n return brandsArr.reduce((acc, brandObj) => acc || excludedBrands.includes(brandObj.brand), false);\n};\n\nexport const cloneBrandsArr = (brandsArr: BrandObject[]): BrandObject[] => brandsArr.map(item => ({ ...item }));\n\nexport const removeExcludedBrand = (brandsArr: BrandObject[], mainBrand1 = 'mc', mainBrand2 = 'visa'): BrandObject[] => {\n const clonedBrands: BrandObject[] = cloneBrandsArr(brandsArr);\n\n if (clonedBrands[0].brand !== mainBrand1 && clonedBrands[0].brand !== mainBrand2) clonedBrands.reverse();\n clonedBrands.length = 1;\n return clonedBrands;\n};\n// --\n\nexport default function extensions(props, refs, states, hasPanLengthRef: Partial<{ current }> = {}) {\n // Destructure props, refs and state hooks\n const { type, cvcPolicy } = props;\n const { sfp } = refs;\n const { dualBrandSelectElements, setDualBrandSelectElements, setSelectedBrandValue, issuingCountryCode, setIssuingCountryCode } = states;\n\n return {\n /**\n * Handle the binLookup response object generated in triggerBinLookup and process it in relation to the CardInput and it's sub-components.\n * e.g. we might need to add/remove additional markup (a selector for brands), and inform SFP of the issuingCountryCode & detected brand(s).\n *\n * @param binLookupResponse -\n * @param isReset -\n */\n processBinLookup: (binLookupResponse, isReset) => {\n const issuingCode = binLookupResponse?.issuingCountryCode ? binLookupResponse.issuingCountryCode.toLowerCase() : null;\n setIssuingCountryCode(issuingCode);\n\n // Reset UI\n if (!binLookupResponse || !Object.keys(binLookupResponse).length) {\n setDualBrandSelectElements([]);\n setSelectedBrandValue('');\n\n // If /binLookup has 'reset' then for a generic card the internal regex will kick in to show the right brand icon - so set to null\n // However for a single-branded card we need to pass the \"base\" type so the brand logo is reset - so set to type\n const brandToReset = isReset && type !== 'card' ? type : null;\n\n sfp.current.processBinLookupResponse(binLookupResponse, {\n brand: brandToReset,\n cvcPolicy: cvcPolicy // undefined except for Bancontact\n } as SingleBrandResetObject);\n\n // Reset storage var\n hasPanLengthRef.current = 0;\n return;\n }\n\n // RESULT: binLookup has found a result so proceed accordingly\n if (binLookupResponse.supportedBrands?.length) {\n const hasExcludedBrand: boolean = containsExcludedBrand(binLookupResponse.supportedBrands, BRAND_ICON_UI_EXCLUSION_LIST);\n\n const supportedBrands: BrandObject[] = hasExcludedBrand\n ? removeExcludedBrand(binLookupResponse.supportedBrands)\n : cloneBrandsArr(binLookupResponse.supportedBrands);\n\n // 1) Multiple options found - add to the UI & inform SFP\n if (supportedBrands.length > 1) {\n // --\n const switcherObj = createCardVariantSwitcher(supportedBrands);\n\n // Set properties on state to trigger the dual branding icons in the UI\n setDualBrandSelectElements(switcherObj.dualBrandSelectElements);\n setSelectedBrandValue(switcherObj.selectedBrandValue); // initially this value from switcherObj will be ''\n\n // Pass an object through to SFP\n sfp.current.processBinLookupResponse({\n issuingCountryCode: binLookupResponse.issuingCountryCode,\n supportedBrands: [switcherObj.leadBrand]\n });\n\n // Store the fact the binLookup obj has a panLength prop\n if (switcherObj.leadBrand.panLength > 0) {\n hasPanLengthRef.current = switcherObj.leadBrand.panLength;\n }\n\n // 2) Single option found (binValueObject.supportedBrands.length === 1)\n } else {\n // Reset UI\n setDualBrandSelectElements([]);\n setSelectedBrandValue('');\n\n // Set (single) value from binLookup so it will be added to the 'brand' property in the paymentMethod object\n // EXCEPT - if we are dealing with a brand that we exclude from the UI\n if (!hasExcludedBrand) setSelectedBrandValue(supportedBrands[0].brand);\n\n // Pass object through to SFP\n sfp.current.processBinLookupResponse({\n issuingCountryCode: binLookupResponse.issuingCountryCode,\n supportedBrands\n });\n\n // Store the fact the binLookup obj has a panLength prop\n if (supportedBrands[0].panLength > 0) {\n hasPanLengthRef.current = supportedBrands[0].panLength;\n }\n }\n }\n },\n /**\n * Handler for clicks on the icons added in response to the /binLookup call\n * Inform SFP of the brand changes when these selections are made\n */\n handleDualBrandSelection: (e: Event | string): void => {\n let value: Event | string = e;\n\n if (e instanceof Event) {\n const target = e.target as HTMLLIElement;\n value = target.getAttribute('data-value') || target.getAttribute('alt');\n }\n\n // Check if we have a value and whether that value corresponds to a brandObject we can propagate\n // If either are false then abandon the process\n let brandObjArr: BrandObject[] = [];\n if (value) {\n // Find the brandObject with the matching brand value and place into an array\n brandObjArr = dualBrandSelectElements.reduce((acc, item) => {\n if (item.brandObject.brand === value) {\n acc.push(item.brandObject);\n }\n return acc;\n }, []);\n\n if (!brandObjArr.length) {\n return; // no brand object associated with value was found\n }\n } else {\n return; // no value passed\n }\n\n setSelectedBrandValue(value);\n\n // Pass brand object into SecuredFields\n sfp.current.processBinLookupResponse({\n issuingCountryCode,\n supportedBrands: brandObjArr\n });\n }\n };\n}\n"],"names":["containsExcludedBrand","brandsArr","excludedBrands","reduce","acc","brandObj","includes","brand","cloneBrandsArr","map","item","_object_spread","removeExcludedBrand","mainBrand1","mainBrand2","clonedBrands","reverse","length","extensions","props","refs","states","hasPanLengthRef","type","cvcPolicy","sfp","dualBrandSelectElements","setDualBrandSelectElements","setSelectedBrandValue","issuingCountryCode","setIssuingCountryCode","processBinLookup","binLookupResponse","isReset","issuingCode","toLowerCase","Object","keys","brandToReset","current","processBinLookupResponse","supportedBrands","hasExcludedBrand","BRAND_ICON_UI_EXCLUSION_LIST","switcherObj","createCardVariantSwitcher","selectedBrandValue","leadBrand","panLength","handleDualBrandSelection","e","value","Event","target","getAttribute","brandObjArr","brandObject","push"],"mappings":"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,GAG9Cd,EAA2BiB,EAAYlB,yBACvCE,EAAsBgB,EAAYE,oBAGlCrB,EAAIc,QAAQC,yBAAyB,CACjCX,mBAAoBG,EAAkBH,mBACtCY,gBAAiB,CAACG,EAAYG,aAI9BH,EAAYG,UAAUC,UAAY,IAClC1B,EAAgBiB,QAAUK,EAAYG,UAAUC,gBAMpDrB,EAA2B,IAC3BC,EAAsB,IAIjBc,GAAkBd,EAAsBa,EAAgB,GAAGlC,OAGhEkB,EAAIc,QAAQC,yBAAyB,CACjCX,mBAAoBG,EAAkBH,mBACtCY,oBAIAA,EAAgB,GAAGO,UAAY,IAC/B1B,EAAgBiB,QAAUE,EAAgB,GAAGO,UAGzD,GAMJC,yBAA2BC,IACvB,IAAIC,EAAwBD,EAE5B,GAAIA,aAAaE,MAAO,CACpB,MAAMC,EAASH,EAAEG,OACjBF,EAAQE,EAAOC,aAAa,eAAiBD,EAAOC,aAAa,MACrE,CAIA,IAAIC,EAA6B,GAC7BJ,IAEAI,EAAc7B,EAAwBvB,QAAO,CAACC,EAAKM,KAC3CA,EAAK8C,YAAYjD,QAAU4C,GAC3B/C,EAAIqD,KAAK/C,EAAK8C,aAEXpD,IACR,IAEEmD,EAAYtC,SAOrBW,EAAsBuB,GAGtB1B,EAAIc,QAAQC,yBAAyB,CACjCX,qBACAY,gBAAiBc,KACrB,EAGZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"triggerBinLookUp.js","sources":["../../../../../../src/components/internal/SecuredFields/binLookup/triggerBinLookUp.ts"],"sourcesContent":["import { httpPost } from '../../../../core/Services/http';\nimport { CbObjOnBinLookup, CbObjOnBinValue, CbObjOnError } from '../lib/types';\nimport { DEFAULT_CARD_GROUP_TYPES } from '../lib/constants';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\nimport { BinLookupResponse, BinLookupResponseRaw } from '../../../Card/types';\n\nif (process.env.NODE_ENV === 'development') {\n window.mockBinCount = 0; // Set to 0 to turn off mocking, 1 to turn it on\n}\n\nexport default parent => {\n let currentRequestId = null;\n\n return (callbackObj: CbObjOnBinValue) => {\n // Allow way for merchant to disallow binLookup by specifically setting the prop to false\n if (parent.props.doBinLookup === false) {\n if (parent.props.onBinValue) parent.props.onBinValue(callbackObj);\n return;\n }\n\n // Do binLookup when encryptedBin property is present (and only if the merchant is using a clientKey)\n if (callbackObj.encryptedBin && parent.props.clientKey) {\n // Store id of request we're about to make\n currentRequestId = callbackObj.uuid;\n\n void httpPost(\n {\n loadingContext: parent.props.loadingContext,\n path: `v3/bin/binLookup?token=${parent.props.clientKey}`\n },\n {\n type: parent.props.brand,\n supportedBrands: parent.props.brands || DEFAULT_CARD_GROUP_TYPES,\n encryptedBin: callbackObj.encryptedBin,\n requestId: callbackObj.uuid // Pass id of request\n }\n ).then((data: BinLookupResponseRaw) => {\n // If response is the one we were waiting for...\n if (data?.requestId === currentRequestId) {\n if (process.env.NODE_ENV === 'development') {\n // TODO mocking\n if (window.mockBinCount >= 1) {\n switch (window.mockBinCount) {\n case 1:\n console.log('\\n### triggerBinLookUp::mock first response:: ');\n data.brands = [\n {\n brand: 'mc',\n cvcPolicy: 'optional',\n enableLuhnCheck: true,\n // showExpiryDate: true, // deprecated in /binLookup v3\n expiryDatePolicy: 'optional',\n // panLength: 16,\n supported: true\n }\n ];\n // data.issuingCountryCode = 'KR'; // needed to mock korean_local_card\n // increment to alter second response\n window.mockBinCount++;\n\n break;\n case 2:\n console.log('\\n### triggerBinLookUp::mock second response:: ');\n // data.brands = null;\n data.brands = [\n {\n brand: 'maestro',\n cvcPolicy: 'required',\n enableLuhnCheck: true,\n showExpiryDate: true,\n supported: true,\n showSocialSecurityNumber: false\n // panLength: 16\n }\n ];\n break;\n default:\n }\n }\n // TODO end\n }\n\n if (data.brands?.length) {\n const mappedResponse = data.brands.reduce(\n (acc, item) => {\n // All brand strings end up in the detectedBrands array\n acc.detectedBrands.push(item.brand);\n // Also add the paymentMethodVariants (more granular description of the txvariant)\n acc.paymentMethodVariants.push(item.paymentMethodVariant);\n\n // Add supported brand objects to the supportedBrands array\n if (item.supported === true) {\n acc.supportedBrands.push(item);\n return acc;\n }\n\n return acc;\n },\n { supportedBrands: [], detectedBrands: [], paymentMethodVariants: [] }\n );\n\n /**\n * supportedBrands = merchant supports this brand(s); we have detected the card number to be of this brand(s); carry on!\n */\n if (mappedResponse.supportedBrands.length) {\n // ...call processBinLookupResponse with, a simplified, response object if it contains at least one supported brand\n parent.processBinLookupResponse({\n issuingCountryCode: data.issuingCountryCode,\n supportedBrands: mappedResponse.supportedBrands,\n ...(data.showSocialSecurityNumber ? { showSocialSecurityNumber: data.showSocialSecurityNumber } : {})\n } as BinLookupResponse);\n\n // Inform merchant of the result\n parent.onBinLookup({\n type: callbackObj.type,\n detectedBrands: mappedResponse.detectedBrands,\n // supportedBrands contains the subset of this.props.brands that matches the card number that the shopper has typed\n supportedBrands: mappedResponse.supportedBrands.map(item => item.brand),\n paymentMethodVariants: mappedResponse.paymentMethodVariants,\n supportedBrandsRaw: mappedResponse.supportedBrands, // full supportedBrands data (for customCard comp)\n brands: parent.props.brands || DEFAULT_CARD_GROUP_TYPES,\n issuingCountryCode: data.issuingCountryCode\n } as CbObjOnBinLookup);\n\n return;\n }\n\n /**\n * detectedBrands = no brands the merchant supports were found; what we did detect the shopper to be entering was this brand;\n * error!\n */\n if (mappedResponse.detectedBrands.length) {\n const errObj: CbObjOnError = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: SF_ErrorCodes.ERROR_MSG_UNSUPPORTED_CARD_ENTERED,\n detectedBrands: mappedResponse.detectedBrands\n };\n parent.handleUnsupportedCard(errObj);\n\n // Inform merchant of the result\n parent.onBinLookup({\n type: callbackObj.type,\n detectedBrands: mappedResponse.detectedBrands,\n supportedBrands: null,\n paymentMethodVariants: mappedResponse.paymentMethodVariants,\n brands: parent.props.brands || DEFAULT_CARD_GROUP_TYPES\n } as CbObjOnBinLookup);\n\n return;\n }\n } else {\n /**\n * BIN not in DB (a failed lookup will just contain a requestId)\n */\n parent.onBinLookup({\n type: callbackObj.type,\n detectedBrands: null,\n supportedBrands: null,\n paymentMethodVariants: null,\n brands: parent.props.brands || DEFAULT_CARD_GROUP_TYPES\n } as CbObjOnBinLookup);\n\n // Reset the UI and let the native, regex branding happen (for the generic card)\n // For a single-branded card we need to pass a boolean to prompt resetting the brand logo to the 'base' type\n parent.processBinLookupResponse({}, true);\n }\n } else {\n if (!data?.requestId) {\n // Some other kind of error on the backend\n parent.props.onError(data || { errorType: 'binLookup', message: 'unknownError' });\n }\n // Else - response with wrong requestId\n }\n });\n } else if (currentRequestId) {\n /**\n * If onBinValue callback is called AND we have been doing binLookup BUT passed object doesn't have an encryptedBin property\n * - then THE NUMBER OF DIGITS IN NUMBER FIELD HAS DROPPED BELOW THRESHOLD for BIN lookup - so reset the UI\n */\n parent.processBinLookupResponse(null, true);\n\n currentRequestId = null; // Ignore any pending responses\n\n // Reset any errors\n const errObj: CbObjOnError = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n parent.handleUnsupportedCard(errObj);\n\n // CustomCard needs this to reset the UI\n parent.onBinLookup({\n isReset: true\n } as CbObjOnBinLookup);\n }\n\n if (parent.props.onBinValue) parent.props.onBinValue(callbackObj);\n };\n};\n"],"names":["parent","currentRequestId","callbackObj","props","doBinLookup","encryptedBin","clientKey","uuid","httpPost","loadingContext","path","type","brand","supportedBrands","brands","DEFAULT_CARD_GROUP_TYPES","requestId","then","data","length","mappedResponse","reduce","acc","item","detectedBrands","push","paymentMethodVariants","paymentMethodVariant","supported","processBinLookupResponse","_object_spread","issuingCountryCode","showSocialSecurityNumber","onBinLookup","map","supportedBrandsRaw","errObj","fieldType","error","SF_ErrorCodes","ERROR_MSG_UNSUPPORTED_CARD_ENTERED","handleUnsupportedCard","onError","errorType","message","isReset","onBinValue"],"mappings":"yTAUA,IAAeA,EAAAA,IACX,IAAIC,EAAmB,KAEvB,OAAQC,IAEJ,IAAiC,IAA7BF,EAAOG,MA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,EAAeI,gBAanC,OAXAxB,EAAOyC,sBAAsBL,QAG7BpC,EAAOiC,YAAY,CACftB,KAAMT,EAAYS,KAClBa,eAAgBJ,EAAeI,eAC/BX,gBAAiB,KACjBa,sBAAuBN,EAAeM,sBACtCZ,OAAQd,EAAOG,MAAMW,QAAUC,GAIvC,OAKAf,EAAOiC,YAAY,CACftB,KAAMT,EAAYS,KAClBa,eAAgB,KAChBX,gBAAiB,KACjBa,sBAAuB,KACvBZ,OAAQd,EAAOG,MAAMW,QAAUC,IAKnCf,EAAO6B,yBAAyB,IAAI,QAGnCX,aAAAA,EAAAA,EAAMF,YAEPhB,EAAOG,MAAMuC,QAAQxB,GAAQ,CAAEyB,UAAW,YAAaC,QAAS,gBAGxE,SAED,GAAI3C,EAAkB,CAKzBD,EAAO6B,yBAAyB,MAAM,GAEtC5B,EAAmB,KAGnB,MAAMmC,EAAuB,CACzBzB,KAAM,OACN0B,UAAW,sBACXC,MAAO,IAEXtC,EAAOyC,sBAAsBL,GAG7BpC,EAAOiC,YAAY,CACfY,SAAS,GAEjB,CAEI7C,EAAOG,MAAM2C,YAAY9C,EAAOG,MAAM2C,WAAW5C,EApLrD,MAFQF,EAAOG,MAAM2C,YAAY9C,EAAOG,MAAM2C,WAAW5C,EAsLJA,CAE7D"}
|
|
1
|
+
{"version":3,"file":"triggerBinLookUp.js","sources":["../../../../../../src/components/internal/SecuredFields/binLookup/triggerBinLookUp.ts"],"sourcesContent":["import { httpPost } from '../../../../core/Services/http';\nimport { CardBinLookupData, CardBinValueData, CardErrorData } from '../lib/types';\nimport { DEFAULT_CARD_GROUP_TYPES } from '../lib/constants';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\nimport { BinLookupResponse, BinLookupResponseRaw } from '../../../Card/types';\n\nif (process.env.NODE_ENV === 'development') {\n window.mockBinCount = 0; // Set to 0 to turn off mocking, 1 to turn it on\n}\n\nexport default parent => {\n let currentRequestId = null;\n\n return (callbackObj: CardBinValueData) => {\n // Allow way for merchant to disallow binLookup by specifically setting the prop to false\n if (parent.props.doBinLookup === false) {\n if (parent.props.onBinValue) parent.props.onBinValue(callbackObj);\n return;\n }\n\n // Do binLookup when encryptedBin property is present (and only if the merchant is using a clientKey)\n if (callbackObj.encryptedBin && parent.props.clientKey) {\n // Store id of request we're about to make\n currentRequestId = callbackObj.uuid;\n\n void httpPost(\n {\n loadingContext: parent.props.loadingContext,\n path: `v3/bin/binLookup?token=${parent.props.clientKey}`\n },\n {\n type: parent.props.brand,\n supportedBrands: parent.props.brands || DEFAULT_CARD_GROUP_TYPES,\n encryptedBin: callbackObj.encryptedBin,\n requestId: callbackObj.uuid // Pass id of request\n }\n ).then((data: BinLookupResponseRaw) => {\n // If response is the one we were waiting for...\n if (data?.requestId === currentRequestId) {\n if (process.env.NODE_ENV === 'development') {\n // TODO mocking\n if (window.mockBinCount >= 1) {\n switch (window.mockBinCount) {\n case 1:\n console.log('\\n### triggerBinLookUp::mock first response:: ');\n data.brands = [\n {\n brand: 'mc',\n cvcPolicy: 'optional',\n enableLuhnCheck: true,\n // showExpiryDate: true, // deprecated in /binLookup v3\n expiryDatePolicy: 'optional',\n // panLength: 16,\n supported: true\n }\n ];\n // data.issuingCountryCode = 'KR'; // needed to mock korean_local_card\n // increment to alter second response\n window.mockBinCount++;\n\n break;\n case 2:\n console.log('\\n### triggerBinLookUp::mock second response:: ');\n // data.brands = null;\n data.brands = [\n {\n brand: 'maestro',\n cvcPolicy: 'required',\n enableLuhnCheck: true,\n showExpiryDate: true,\n supported: true,\n showSocialSecurityNumber: false\n // panLength: 16\n }\n ];\n break;\n default:\n }\n }\n // TODO end\n }\n\n if (data.brands?.length) {\n const mappedResponse = data.brands.reduce(\n (acc, item) => {\n // All brand strings end up in the detectedBrands array\n acc.detectedBrands.push(item.brand);\n // Also add the paymentMethodVariants (more granular description of the txvariant)\n acc.paymentMethodVariants.push(item.paymentMethodVariant);\n\n // Add supported brand objects to the supportedBrands array\n if (item.supported === true) {\n acc.supportedBrands.push(item);\n return acc;\n }\n\n return acc;\n },\n { supportedBrands: [], detectedBrands: [], paymentMethodVariants: [] }\n );\n\n /**\n * supportedBrands = merchant supports this brand(s); we have detected the card number to be of this brand(s); carry on!\n */\n if (mappedResponse.supportedBrands.length) {\n // ...call processBinLookupResponse with, a simplified, response object if it contains at least one supported brand\n parent.processBinLookupResponse({\n issuingCountryCode: data.issuingCountryCode,\n supportedBrands: mappedResponse.supportedBrands,\n ...(data.showSocialSecurityNumber ? { showSocialSecurityNumber: data.showSocialSecurityNumber } : {})\n } as BinLookupResponse);\n\n // Inform merchant of the result\n parent.onBinLookup({\n type: callbackObj.type,\n detectedBrands: mappedResponse.detectedBrands,\n // supportedBrands contains the subset of this.props.brands that matches the card number that the shopper has typed\n supportedBrands: mappedResponse.supportedBrands.map(item => item.brand),\n paymentMethodVariants: mappedResponse.paymentMethodVariants,\n supportedBrandsRaw: mappedResponse.supportedBrands, // full supportedBrands data (for customCard comp)\n brands: parent.props.brands || DEFAULT_CARD_GROUP_TYPES,\n issuingCountryCode: data.issuingCountryCode\n } as CardBinLookupData);\n\n return;\n }\n\n /**\n * detectedBrands = no brands the merchant supports were found; what we did detect the shopper to be entering was this brand;\n * error!\n */\n if (mappedResponse.detectedBrands.length) {\n const errObj: CardErrorData = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: SF_ErrorCodes.ERROR_MSG_UNSUPPORTED_CARD_ENTERED,\n detectedBrands: mappedResponse.detectedBrands\n };\n parent.handleUnsupportedCard(errObj);\n\n // Inform merchant of the result\n parent.onBinLookup({\n type: callbackObj.type,\n detectedBrands: mappedResponse.detectedBrands,\n supportedBrands: null,\n paymentMethodVariants: mappedResponse.paymentMethodVariants,\n brands: parent.props.brands || DEFAULT_CARD_GROUP_TYPES\n } as CardBinLookupData);\n\n return;\n }\n } else {\n /**\n * BIN not in DB (a failed lookup will just contain a requestId)\n */\n parent.onBinLookup({\n type: callbackObj.type,\n detectedBrands: null,\n supportedBrands: null,\n paymentMethodVariants: null,\n brands: parent.props.brands || DEFAULT_CARD_GROUP_TYPES\n } as CardBinLookupData);\n\n // Reset the UI and let the native, regex branding happen (for the generic card)\n // For a single-branded card we need to pass a boolean to prompt resetting the brand logo to the 'base' type\n parent.processBinLookupResponse({}, true);\n }\n } else {\n if (!data?.requestId) {\n // Some other kind of error on the backend\n parent.props.onError(data || { errorType: 'binLookup', message: 'unknownError' });\n }\n // Else - response with wrong requestId\n }\n });\n } else if (currentRequestId) {\n /**\n * If onBinValue callback is called AND we have been doing binLookup BUT passed object doesn't have an encryptedBin property\n * - then THE NUMBER OF DIGITS IN NUMBER FIELD HAS DROPPED BELOW THRESHOLD for BIN lookup - so reset the UI\n */\n parent.processBinLookupResponse(null, true);\n\n currentRequestId = null; // Ignore any pending responses\n\n // Reset any errors\n const errObj: CardErrorData = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n parent.handleUnsupportedCard(errObj);\n\n // CustomCard needs this to reset the UI\n parent.onBinLookup({\n isReset: true\n } as CardBinLookupData);\n }\n\n if (parent.props.onBinValue) parent.props.onBinValue(callbackObj);\n };\n};\n"],"names":["parent","currentRequestId","callbackObj","props","doBinLookup","encryptedBin","clientKey","uuid","httpPost","loadingContext","path","type","brand","supportedBrands","brands","DEFAULT_CARD_GROUP_TYPES","requestId","then","data","length","mappedResponse","reduce","acc","item","detectedBrands","push","paymentMethodVariants","paymentMethodVariant","supported","processBinLookupResponse","_object_spread","issuingCountryCode","showSocialSecurityNumber","onBinLookup","map","supportedBrandsRaw","errObj","fieldType","error","SF_ErrorCodes","ERROR_MSG_UNSUPPORTED_CARD_ENTERED","handleUnsupportedCard","onError","errorType","message","isReset","onBinValue"],"mappings":"yTAUA,IAAeA,EAAAA,IACX,IAAIC,EAAmB,KAEvB,OAAQC,IAEJ,IAAiC,IAA7BF,EAAOG,MAAMC,YAAjB,CAMA,GAAIF,EAAYG,cAAgBL,EAAOG,MAAMG,UAEzCL,EAAmBC,EAAYK,KAE1BC,EACD,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ClBa,eAAgBJ,EAAeI,eAC/BX,gBAAiB,KACjBa,sBAAuBN,EAAeM,sBACtCZ,OAAQd,EAAOG,MAAMW,QAAUC,GAIvC,OAKAf,EAAOiC,YAAY,CACftB,KAAMT,EAAYS,KAClBa,eAAgB,KAChBX,gBAAiB,KACjBa,sBAAuB,KACvBZ,OAAQd,EAAOG,MAAMW,QAAUC,IAKnCf,EAAO6B,yBAAyB,CAAI,GAAA,QAGnCX,aAAAA,EAAAA,EAAMF,YAEPhB,EAAOG,MAAMuC,QAAQxB,GAAQ,CAAEyB,UAAW,YAAaC,QAAS,gBAGxE,SAED,GAAI3C,EAAkB,CAKzBD,EAAO6B,yBAAyB,MAAM,GAEtC5B,EAAmB,KAGnB,MAAMmC,EAAwB,CAC1BzB,KAAM,OACN0B,UAAW,sBACXC,MAAO,IAEXtC,EAAOyC,sBAAsBL,GAG7BpC,EAAOiC,YAAY,CACfY,SAAS,GAEjB,CAEI7C,EAAOG,MAAM2C,YAAY9C,EAAOG,MAAM2C,WAAW5C,EApLrD,MAFQF,EAAOG,MAAM2C,YAAY9C,EAAOG,MAAM2C,WAAW5C,EAsLJA,CAE7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractCSF.js","sources":["../../../../../../../src/components/internal/SecuredFields/lib/CSF/AbstractCSF.ts"],"sourcesContent":["import { CSFSetupObject, CSFConfigObject, CSFCallbacksConfig, CSFStateObject } from './types';\nimport { SFFeedbackObj, SendBrandObject, SendExpiryDateObject, CVCPolicyType, DatePolicyType, SFFieldType } from '../types';\nimport { createSecuredFields } from './extensions/createSecuredFields';\nimport processBrand from './partials/processBrand';\nimport handleBrandFromBinLookup from './extensions/handleBrandFromBinLookup';\n\nabstract class AbstractCSF {\n // Set in CSF\n protected callbacks: CSFCallbacksConfig;\n protected config: CSFConfigObject;\n protected props: CSFSetupObject;\n protected state: CSFStateObject;\n protected validateForm: () => void;\n protected handleBrandFromBinLookup: typeof handleBrandFromBinLookup;\n protected callbacksHandler: (callbacksObj: object) => void;\n protected configHandler: (props: CSFSetupObject) => void;\n protected createCardSecuredFields: (securedFields: HTMLElement[], cvcPolicy: CVCPolicyType, expiryDatePolicy: DatePolicyType) => Promise<any>;\n protected createNonCardSecuredFields: (securedFields: HTMLElement[]) => Promise<any>;\n protected createSecuredFields: typeof createSecuredFields;\n protected destroySecuredFields: () => void;\n protected handleIOSTouchEvents: () => void;\n protected destroyTouchendListener: () => void;\n protected destroyTouchstartListener: () => void;\n protected handleBinValue: (pFeedbackObj: SFFeedbackObj) => void;\n protected handleEncryption: (pFeedbackObj: SFFeedbackObj) => void;\n protected handleFocus: (pFeedbackObj: SFFeedbackObj) => void;\n protected handleIframeConfigFeedback: (pFeedbackObj) => boolean;\n protected handleValidation: (pFeedbackObj: SFFeedbackObj) => void;\n protected handleSFShiftTab: (fieldType: string) => void;\n protected handleShiftTab: (fieldType: string) => void;\n protected isConfigured: () => void;\n protected postMessageToAllIframes: (pDataObj: object) => void;\n protected processAutoComplete: (pFeedbackObj: SFFeedbackObj) => void;\n protected processBrand: typeof processBrand;\n protected sendBrandToCardSF: (brandObj: SendBrandObject) => void;\n protected sendExpiryDatePolicyToSF: (dateObj: SendExpiryDateObject) => void;\n protected setFocusOnFrame: (pFieldType: SFFieldType, doLog?: boolean) => void;\n protected setupSecuredField: (pItem: HTMLElement) => void;\n protected touchendListener: (e: Event) => void;\n protected touchstartListener: () => void;\n protected hasGenuineTouchEvents: boolean;\n // Set in createSecuredFields\n protected encryptedAttrName: string;\n protected hasRedundantCVCField: boolean;\n protected isSingleBrandedCard: boolean;\n protected securityCode: string;\n // --\n protected constructor(setupObj: CSFSetupObject) {\n this.props = setupObj;\n this.state = {} as any as CSFStateObject;\n\n // Initialise storage objects\n this.config = {} as any as CSFConfigObject; // {} as ConfigObject fails in linting\n this.callbacks = {} as any as CSFCallbacksConfig;\n }\n}\nexport default AbstractCSF;\n"],"names":["AbstractCSF","constructor","setupObj","_define_property","this","callbacks","config","props","state","validateForm","handleBrandFromBinLookup","callbacksHandler","configHandler","createCardSecuredFields","createNonCardSecuredFields","createSecuredFields","destroySecuredFields","handleIOSTouchEvents","destroyTouchendListener","destroyTouchstartListener","handleBinValue","handleEncryption","handleFocus","handleIframeConfigFeedback","handleValidation","handleSFShiftTab","handleShiftTab","isConfigured","postMessageToAllIframes","processAutoComplete","processBrand","sendBrandToCardSF","sendExpiryDatePolicyToSF","setFocusOnFrame","setupSecuredField","touchendListener","touchstartListener","hasGenuineTouchEvents","encryptedAttrName","hasRedundantCVCField","isSingleBrandedCard","securityCode"],"mappings":"wHAMA,MAAeA,EAyCX,WAAAC,CAAsBC,GAvCtBC,EAAAC,KAAUC,iBAAV,GACAF,EAAAC,KAAUE,cAAV,GACAH,EAAAC,KAAUG,aAAV,GACAJ,EAAAC,KAAUI,aAAV,GACAL,EAAAC,KAAUK,oBAAV,GACAN,EAAAC,KAAUM,gCAAV,GACAP,EAAAC,KAAUO,wBAAV,GACAR,EAAAC,KAAUQ,qBAAV,GACAT,EAAAC,KAAUS,+BAAV,GACAV,EAAAC,KAAUU,kCAAV,GACAX,EAAAC,KAAUW,2BAAV,GACAZ,EAAAC,KAAUY,4BAAV,GACAb,EAAAC,KAAUa,4BAAV,GACAd,EAAAC,KAAUc,+BAAV,GACAf,EAAAC,KAAUe,iCAAV,GACAhB,EAAAC,KAAUgB,sBAAV,GACAjB,EAAAC,KAAUiB,wBAAV,GACAlB,EAAAC,KAAUkB,mBAAV,GACAnB,EAAAC,KAAUmB,kCAAV,GACApB,EAAAC,KAAUoB,wBAAV,GACArB,EAAAC,KAAUqB,wBAAV,GACAtB,EAAAC,KAAUsB,sBAAV,GACAvB,EAAAC,KAAUuB,oBAAV,GACAxB,EAAAC,KAAUwB,+BAAV,GACAzB,EAAAC,KAAUyB,2BAAV,GACA1B,EAAAC,KAAU0B,oBAAV,GACA3B,EAAAC,KAAU2B,yBAAV,GACA5B,EAAAC,KAAU4B,gCAAV,GACA7B,EAAAC,KAAU6B,uBAAV,GACA9B,EAAAC,KAAU8B,yBAAV,GACA/B,EAAAC,KAAU+B,wBAAV,GACAhC,EAAAC,KAAUgC,0BAAV,GACAjC,EAAAC,KAAUiC,6BAAV,GAEAlC,EAAAC,KAAUkC,yBAAV,GACAnC,EAAAC,KAAUmC,4BAAV,GACApC,EAAAC,KAAUoC,2BAAV,GACArC,EAAAC,KAAUqC,oBAAV,GAGIrC,KAAKG,MAAQL,EACbE,KAAKI,MAAQ,
|
|
1
|
+
{"version":3,"file":"AbstractCSF.js","sources":["../../../../../../../src/components/internal/SecuredFields/lib/CSF/AbstractCSF.ts"],"sourcesContent":["import { CSFSetupObject, CSFConfigObject, CSFCallbacksConfig, CSFStateObject } from './types';\nimport { SFFeedbackObj, SendBrandObject, SendExpiryDateObject, CVCPolicyType, DatePolicyType, SFFieldType } from '../types';\nimport { createSecuredFields } from './extensions/createSecuredFields';\nimport processBrand from './partials/processBrand';\nimport handleBrandFromBinLookup from './extensions/handleBrandFromBinLookup';\n\nabstract class AbstractCSF {\n // Set in CSF\n protected callbacks: CSFCallbacksConfig;\n protected config: CSFConfigObject;\n protected props: CSFSetupObject;\n protected state: CSFStateObject;\n protected validateForm: () => void;\n protected handleBrandFromBinLookup: typeof handleBrandFromBinLookup;\n protected callbacksHandler: (callbacksObj: object) => void;\n protected configHandler: (props: CSFSetupObject) => void;\n protected createCardSecuredFields: (securedFields: HTMLElement[], cvcPolicy: CVCPolicyType, expiryDatePolicy: DatePolicyType) => Promise<any>;\n protected createNonCardSecuredFields: (securedFields: HTMLElement[]) => Promise<any>;\n protected createSecuredFields: typeof createSecuredFields;\n protected destroySecuredFields: () => void;\n protected handleIOSTouchEvents: () => void;\n protected destroyTouchendListener: () => void;\n protected destroyTouchstartListener: () => void;\n protected handleBinValue: (pFeedbackObj: SFFeedbackObj) => void;\n protected handleEncryption: (pFeedbackObj: SFFeedbackObj) => void;\n protected handleFocus: (pFeedbackObj: SFFeedbackObj) => void;\n protected handleIframeConfigFeedback: (pFeedbackObj) => boolean;\n protected handleValidation: (pFeedbackObj: SFFeedbackObj) => void;\n protected handleSFShiftTab: (fieldType: string) => void;\n protected handleShiftTab: (fieldType: string) => void;\n protected isConfigured: () => void;\n protected postMessageToAllIframes: (pDataObj: object) => void;\n protected processAutoComplete: (pFeedbackObj: SFFeedbackObj) => void;\n protected processBrand: typeof processBrand;\n protected sendBrandToCardSF: (brandObj: SendBrandObject) => void;\n protected sendExpiryDatePolicyToSF: (dateObj: SendExpiryDateObject) => void;\n protected setFocusOnFrame: (pFieldType: SFFieldType, doLog?: boolean) => void;\n protected setupSecuredField: (pItem: HTMLElement) => void;\n protected touchendListener: (e: Event) => void;\n protected touchstartListener: () => void;\n protected hasGenuineTouchEvents: boolean;\n // Set in createSecuredFields\n protected encryptedAttrName: string;\n protected hasRedundantCVCField: boolean;\n protected isSingleBrandedCard: boolean;\n protected securityCode: string;\n // --\n protected constructor(setupObj: CSFSetupObject) {\n this.props = setupObj;\n this.state = {} as any as CSFStateObject;\n\n // Initialise storage objects\n this.config = {} as any as CSFConfigObject; // {} as ConfigObject fails in linting\n this.callbacks = {} as any as CSFCallbacksConfig;\n }\n}\nexport default AbstractCSF;\n"],"names":["AbstractCSF","constructor","setupObj","_define_property","this","callbacks","config","props","state","validateForm","handleBrandFromBinLookup","callbacksHandler","configHandler","createCardSecuredFields","createNonCardSecuredFields","createSecuredFields","destroySecuredFields","handleIOSTouchEvents","destroyTouchendListener","destroyTouchstartListener","handleBinValue","handleEncryption","handleFocus","handleIframeConfigFeedback","handleValidation","handleSFShiftTab","handleShiftTab","isConfigured","postMessageToAllIframes","processAutoComplete","processBrand","sendBrandToCardSF","sendExpiryDatePolicyToSF","setFocusOnFrame","setupSecuredField","touchendListener","touchstartListener","hasGenuineTouchEvents","encryptedAttrName","hasRedundantCVCField","isSingleBrandedCard","securityCode"],"mappings":"wHAMA,MAAeA,EAyCX,WAAAC,CAAsBC,GAvCtBC,EAAAC,KAAUC,iBAAV,GACAF,EAAAC,K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ts"],"sourcesContent":["import AbstractCSF from './AbstractCSF';\nimport { CSFReturnObject, CSFSetupObject, CSFStateObject, CSFThisObject } from './types';\nimport { StylesObject, CbObjOnAdditionalSF, SFFieldType } from '../types';\nimport { BinLookupResponse } from '../../../../Card/types';\nimport { handleConfig } from './extensions/handleConfig';\nimport { configureCallbacks } from './extensions/configureCallbacks';\nimport { handleValidation } from './extensions/handleValidation';\nimport { handleEncryption } from './extensions/handleEncryption';\nimport { createSecuredFields, createNonCardSecuredFields, createCardSecuredFields, setupSecuredField } from './extensions/createSecuredFields';\nimport handleIOSTouchEvents from './extensions/handleIOSTouchEvents';\nimport handleTab from './extensions/handleTab';\nimport handleBrandFromBinLookup, { sendBrandToCardSF, sendExpiryDatePolicyToSF } from './extensions/handleBrandFromBinLookup';\nimport { setFocusOnFrame } from './partials/setFocusOnFrame';\nimport { postMessageToAllIframes } from './partials/postMessageToAllIframes';\nimport processBrand from './partials/processBrand';\nimport { processAutoComplete } from './partials/processAutoComplete';\nimport { handleFocus } from './partials/handleFocus';\nimport { handleIframeConfigFeedback } from './partials/handleIframeConfigFeedback';\nimport { isConfigured } from './partials/isConfigured';\nimport validateForm from './partials/validateForm';\nimport { handleBinValue } from './partials/handleBinValue';\nimport { destroySecuredFields } from './utils/destroySecuredFields';\nimport postMessageToIframe from './utils/iframes/postMessageToIframe';\nimport getIframeContentWin from './utils/iframes/getIframeContentWin';\nimport * as logger from '../utilities/logger';\nimport { selectOne } from '../utilities/dom';\nimport { on } from '../../../../../utils/listenerUtils';\nimport { partial } from '../utilities/commonUtils';\nimport { hasOwnProperty } from '../../../../../utils/hasOwnProperty';\nimport ua from './utils/userAgent';\nimport { SingleBrandResetObject } from '../../SFP/types';\n\nconst notConfiguredWarning = (str = 'You cannot use secured fields') => {\n logger.warn(`${str} - they are not yet configured. Use the 'onConfigSuccess' callback to know when this has happened.`);\n};\n\nclass CSF extends AbstractCSF {\n // --\n constructor(setupObj: CSFSetupObject) {\n /**\n * Initialises:\n * - this.props = setupObj: CSFSetupObject\n *\n * and empty objects for:\n * - this.config: CSFConfigObject (populated in handleConfig.ts)\n * - this.callbacks: CSFCallbacksConfig (populated in configureCallbacks.ts\n * - this.state: CSFStateObject (populated below)\n */\n super(setupObj);\n\n this.state = {\n /**\n * For generic card will always be 'card'.\n * For non-generic card will be hardcoded to a particular txVariant e.g. 'mc' or 'visa'\n * For other types of SecuredField will be the passed type e.g. 'ach' or 'giftcard'\n */\n type: this.props.type,\n /**\n * For generic card will change as shopper types\n * For non-generic card will be fixed\n */\n brand: this.props.type !== 'card' ? { brand: this.props.type, cvcPolicy: 'required' } : { brand: null, cvcPolicy: 'required' },\n allValid: undefined,\n numIframes: 0,\n originalNumIframes: 0,\n iframeCount: 0,\n iframeConfigCount: 0,\n isConfigured: false,\n hasSeparateDateFields: false,\n currentFocusObject: null,\n registerFieldForIos: false,\n securedFields: {},\n isKCP: false\n } as CSFStateObject;\n\n // Create object of references to properties on 'this', that can be used to set up the partials\n const thisObj: CSFThisObject = { csfState: this.state, csfConfig: this.config, csfProps: this.props, csfCallbacks: this.callbacks };\n\n // Setup 'this' references\n this.configHandler = handleConfig;\n\n this.callbacksHandler = configureCallbacks;\n\n this.validateForm = partial(validateForm, thisObj);\n\n this.isConfigured = partial(isConfigured, thisObj, this.validateForm);\n this.handleIframeConfigFeedback = partial(handleIframeConfigFeedback, thisObj, this.isConfigured);\n\n this.processBrand = partial(processBrand, thisObj);\n\n this.handleValidation = handleValidation;\n this.handleEncryption = handleEncryption;\n\n this.createSecuredFields = createSecuredFields;\n this.createNonCardSecuredFields = createNonCardSecuredFields;\n this.createCardSecuredFields = createCardSecuredFields;\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.setupSecuredField = setupSecuredField;\n\n this.postMessageToAllIframes = partial(postMessageToAllIframes, thisObj);\n\n this.handleIOSTouchEvents = handleIOSTouchEvents.handleTouchend.bind(this);\n this.touchendListener = handleIOSTouchEvents.touchendListener.bind(this);\n this.destroyTouchendListener = handleIOSTouchEvents.destroyTouchendListener.bind(this);\n this.touchstartListener = handleIOSTouchEvents.touchstartListener.bind(this);\n this.destroyTouchstartListener = handleIOSTouchEvents.destroyTouchstartListener.bind(this);\n\n this.setFocusOnFrame = partial(setFocusOnFrame, thisObj);\n this.handleFocus = partial(handleFocus, thisObj, this.handleIOSTouchEvents);\n\n this.handleSFShiftTab = handleTab.handleSFShiftTab;\n this.handleShiftTab = handleTab.handleShiftTab;\n\n this.destroySecuredFields = destroySecuredFields;\n\n this.processAutoComplete = partial(processAutoComplete, thisObj);\n\n this.handleBinValue = partial(handleBinValue, thisObj);\n\n this.handleBrandFromBinLookup = handleBrandFromBinLookup;\n this.sendBrandToCardSF = sendBrandToCardSF;\n this.sendExpiryDatePolicyToSF = sendExpiryDatePolicyToSF;\n\n // Populate config & callbacks objects & create securedFields\n this.init();\n }\n\n private init(): void {\n this.configHandler(this.props);\n this.callbacksHandler(this.props.callbacks);\n\n /**\n * Create all the securedFields\n */\n const numIframes: number = this.createSecuredFields();\n\n this.state.numIframes = this.state.originalNumIframes = numIframes;\n\n this.state.isKCP = !!this.props.isKCP;\n\n /**\n * Add touchstart listener\n * re. Disabling arrow keys in iOS\n */\n if (ua.__IS_IOS && this.props.shouldDisableIOSArrowKeys) {\n this.hasGenuineTouchEvents = false;\n on(document, 'touchstart', this.touchstartListener);\n }\n }\n\n // Expose functions that can be called on the CSF instance\n public createReturnObject(): CSFReturnObject {\n // --\n const returnObj: CSFReturnObject = {\n // --\n updateStyles: (pStyleObject: StylesObject): void => {\n if (this.state.isConfigured) {\n this.postMessageToAllIframes({ styleObject: pStyleObject });\n } else {\n logger.warn(\n 'You cannot update the secured fields styling ' +\n \"- they are not yet configured. Use the 'onConfigSuccess' callback to know when this has happened.\"\n );\n }\n },\n setFocusOnFrame: (pFieldType: SFFieldType): void => {\n if (this.state.isConfigured) {\n this.setFocusOnFrame(pFieldType);\n // Comment in a quick way to test destroying secured fields (also see comment in destroySecuredFields)\n // this.destroySecuredFields();\n } else {\n notConfiguredWarning('You cannot set focus on any secured field');\n }\n },\n // For component based implementation - if showValidation function is called on the component use this\n // function as a way to notify the CSF that a field is in error\n isValidated: (pFieldType: SFFieldType, code: string): void => {\n if (this.state.isConfigured) {\n if (hasOwnProperty(this.state.securedFields, pFieldType)) {\n this.state.securedFields[pFieldType].hasError = true;\n\n // If there's not already an errorType, set one\n // NOTE: fixes issue in Components where you first validate and then start typing a maestro number\n // - w/o this and the corresponding fix in the SecuredField class the maestro PM will never register as valid\n if (this.state.securedFields[pFieldType].errorType === '') {\n this.state.securedFields[pFieldType].errorType = 'isValidated';\n }\n\n // Inform iframe\n const dataObj: object = {\n txVariant: this.state.type,\n fieldType: pFieldType,\n externalValidation: true,\n code,\n numKey: this.state.securedFields[pFieldType].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(this.state, pFieldType), this.config.loadingContext);\n }\n } else {\n notConfiguredWarning('You cannot set validated on any secured field');\n }\n },\n hasUnsupportedCard: (pFieldType: SFFieldType, code: string): void => {\n if (this.state.isConfigured) {\n if (hasOwnProperty(this.state.securedFields, pFieldType)) {\n //\n this.state.securedFields[pFieldType].hasError = !!code;\n this.state.securedFields[pFieldType].errorType = code;\n\n // Inform iframe\n const dataObj: object = {\n txVariant: this.state.type,\n fieldType: pFieldType,\n unsupportedCard: !!code,\n code,\n numKey: this.state.securedFields[pFieldType].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(this.state, pFieldType), this.config.loadingContext);\n }\n } else {\n notConfiguredWarning('You cannot set hasUnsupportedCard on any secured field');\n }\n },\n destroy: (): void => {\n if (this.state.isConfigured) {\n this.destroySecuredFields();\n } else {\n notConfiguredWarning('You cannot destroy secured fields');\n }\n },\n brandsFromBinLookup: (binLookupResponse: BinLookupResponse, resetObj: SingleBrandResetObject): void => {\n if (!this.config.isCreditCardType) return null;\n\n if (this.state.isConfigured) {\n this.handleBrandFromBinLookup(binLookupResponse, resetObj);\n } else {\n notConfiguredWarning('You cannot set pass brands to secured fields');\n }\n },\n addSecuredField: (pFieldType: SFFieldType): void => {\n const securedField: HTMLElement = selectOne(this.props.rootNode, `[data-cse=\"${pFieldType}\"]`);\n if (securedField) {\n this.state.numIframes += 1;\n this.setupSecuredField(securedField);\n }\n },\n removeSecuredField: (pFieldType: SFFieldType): void => {\n if (this.state.securedFields[pFieldType]) {\n this.state.securedFields[pFieldType].destroy();\n delete this.state.securedFields[pFieldType];\n this.state.numIframes -= 1;\n this.state.iframeCount -= 1;\n\n const callbackObj: CbObjOnAdditionalSF = { additionalIframeRemoved: true, fieldType: pFieldType, type: this.state.type };\n this.callbacks.onAdditionalSFRemoved(callbackObj);\n }\n },\n setKCPStatus: (isKCP: boolean): void => {\n this.state.isKCP = isKCP;\n },\n sfIsOptionalOrHidden: (fieldType: string): boolean => {\n return this.state.securedFields[fieldType].isOptionalOrHidden();\n }\n };\n\n return returnObj;\n }\n}\n\nexport default CSF;\n"],"names":["notConfiguredWarning","str","logger","CSF","AbstractCSF","init","this","configHandler","props","callbacksHandler","callbacks","numIframes","createSecuredFields","state","originalNumIframes","isKCP","ua","__IS_IOS","shouldDisableIOSArrowKeys","hasGenuineTouchEvents","on","document","touchstartListener","createReturnObject","updateStyles","pStyleObject","isConfigured","postMessageToAllIframes","styleObject","setFocusOnFrame","pFieldType","isValidated","code","hasOwnProperty","securedFields","hasError","errorType","dataObj","txVariant","type","fieldType","externalValidation","numKey","postMessageToIframe","getIframeContentWin","config","loadingContext","hasUnsupportedCard","unsupportedCard","destroy","destroySecuredFields","brandsFromBinLookup","binLookupResponse","resetObj","isCreditCardType","handleBrandFromBinLookup","addSecuredField","securedField","selectOne","rootNode","setupSecuredField","removeSecuredField","iframeCount","callbackObj","additionalIframeRemoved","onAdditionalSFRemoved","setKCPStatus","sfIsOptionalOrHidden","isOptionalOrHidden","constructor","setupObj","super","brand","cvcPolicy","allValid","undefined","iframeConfigCount","hasSeparateDateFields","currentFocusObject","registerFieldForIos","thisObj","csfState","csfConfig","csfProps","csfCallbacks","handleConfig","configureCallbacks","validateForm","partial","handleIframeConfigFeedback","processBrand","handleValidation","handleEncryption","createNonCardSecuredFields","createCardSecuredFields","handleIOSTouchEvents","handleTouchend","bind","touchendListener","destroyTouchendListener","destroyTouchstartListener","handleFocus","handleSFShiftTab","handleTab","handleShiftTab","processAutoComplete","handleBinValue","sendBrandToCardSF","sendExpiryDatePolicyToSF"],"mappings":"qrDAgCA,MAAMA,EAAuB,CAACC,EAAM,mCAChCC,EAAY,GAAGD,sGAAuG,EAG1H,MAAME,UAAYC,EA2FNC,IAAAA,GACJC,KAAKC,cAAcD,KAAKE,OACxBF,KAAKG,iBAAiBH,KAAKE,MAAME,WAKjC,MAAMC,EAAqBL,KAAKM,sBAEhCN,KAAKO,MAAMF,WAAaL,KAAKO,MAAMC,mBAAqBH,EAExDL,KAAKO,MAAME,QAAUT,KAAKE,MAAMO,MAM5BC,EAAGC,UAAYX,KAAKE,MAAMU,4BAC1BZ,KAAKa,uBAAwB,EAC7BC,EAAGC,SAAU,aAAcf,KAAKgB,oBAExC,CAGOC,kBAAAA,GAkHH,MAhHmC,CAE/BC,aAAeC,IACPnB,KAAKO,MAAMa,aACXpB,KAAKqB,wBAAwB,CAAEC,YAAaH,IAE5CvB,EACI,iJAGR,EAEJ2B,gBAAkBC,IACVxB,KAAKO,MAAMa,aACXpB,KAAKuB,gBAAgBC,GAIrB9B,EAAqB,4CACzB,EAIJ+B,YAAa,CAACD,EAAyBE,KACnC,GAAI1B,KAAKO,MAAMa,cACX,GAAIO,EAAe3B,KAAKO,MAAMqB,cAAeJ,GAAa,CACtDxB,KAAKO,MAAMqB,cAAcJ,GAAYK,UAAW,EAKO,KAAnD7B,KAAKO,MAAMqB,cAAcJ,GAAYM,YACrC9B,KAAKO,MAAMqB,cAAcJ,GAAYM,UAAY,eAIrD,MAAMC,EAAkB,CACpBC,UAAWhC,KAAKO,MAAM0B,KACtBC,UAAWV,EACXW,oBAAoB,EACpBT,OACAU,OAAQpC,KAAKO,M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AAK6F,wBAA0BJ,EAAqBI,wBAAwBF,KAAK3F,MACjFA,KAAKgB,mBAAqByE,EAAqBzE,mBAAmB2E,KAAK3F,MACvEA,KAAK8F,0BAA4BL,EAAqBK,0BAA0BH,KAAK3F,MAErFA,KAAKuB,gBAAkB2D,EAAQ3D,EAAiBmD,GAChD1E,KAAK+F,YAAcb,EAAQa,EAAarB,EAAS1E,KAAKyF,sBAEtDzF,KAAKgG,iBAAmBC,EAAUD,iBAClChG,KAAKkG,eAAiBD,EAAUC,eAEhClG,KAAK4C,qBAAuBA,EAE5B5C,KAAKmG,oBAAsBjB,EAAQiB,EAAqBzB,GAExD1E,KAAKoG,eAAiBlB,EAAQkB,EAAgB1B,GAE9C1E,KAAKiD,yBAA2BA,EAChCjD,KAAKqG,kBAAoBA,EACzBrG,KAAKsG,yBAA2BA,EAGhCtG,KAAKD,MACT"}
|
|
1
|
+
{"version":3,"file":"CSF.js","sources":["../../../../../../../src/components/internal/SecuredFields/lib/CSF/CSF.ts"],"sourcesContent":["import AbstractCSF from './AbstractCSF';\nimport { CSFReturnObject, CSFSetupObject, CSFStateObject, CSFThisObject } from './types';\nimport { StylesObject, CardAdditionalSFData, SFFieldType } from '../types';\nimport { BinLookupResponse } from '../../../../Card/types';\nimport { handleConfig } from './extensions/handleConfig';\nimport { configureCallbacks } from './extensions/configureCallbacks';\nimport { handleValidation } from './extensions/handleValidation';\nimport { handleEncryption } from './extensions/handleEncryption';\nimport { createSecuredFields, createNonCardSecuredFields, createCardSecuredFields, setupSecuredField } from './extensions/createSecuredFields';\nimport handleIOSTouchEvents from './extensions/handleIOSTouchEvents';\nimport handleTab from './extensions/handleTab';\nimport handleBrandFromBinLookup, { sendBrandToCardSF, sendExpiryDatePolicyToSF } from './extensions/handleBrandFromBinLookup';\nimport { setFocusOnFrame } from './partials/setFocusOnFrame';\nimport { postMessageToAllIframes } from './partials/postMessageToAllIframes';\nimport processBrand from './partials/processBrand';\nimport { processAutoComplete } from './partials/processAutoComplete';\nimport { handleFocus } from './partials/handleFocus';\nimport { handleIframeConfigFeedback } from './partials/handleIframeConfigFeedback';\nimport { isConfigured } from './partials/isConfigured';\nimport validateForm from './partials/validateForm';\nimport { handleBinValue } from './partials/handleBinValue';\nimport { destroySecuredFields } from './utils/destroySecuredFields';\nimport postMessageToIframe from './utils/iframes/postMessageToIframe';\nimport getIframeContentWin from './utils/iframes/getIframeContentWin';\nimport * as logger from '../utilities/logger';\nimport { selectOne } from '../utilities/dom';\nimport { on } from '../../../../../utils/listenerUtils';\nimport { partial } from '../utilities/commonUtils';\nimport { hasOwnProperty } from '../../../../../utils/hasOwnProperty';\nimport ua from './utils/userAgent';\nimport { SingleBrandResetObject } from '../../SFP/types';\n\nconst notConfiguredWarning = (str = 'You cannot use secured fields') => {\n logger.warn(`${str} - they are not yet configured. Use the 'onConfigSuccess' callback to know when this has happened.`);\n};\n\nclass CSF extends AbstractCSF {\n // --\n constructor(setupObj: CSFSetupObject) {\n /**\n * Initialises:\n * - this.props = setupObj: CSFSetupObject\n *\n * and empty objects for:\n * - this.config: CSFConfigObject (populated in handleConfig.ts)\n * - this.callbacks: CSFCallbacksConfig (populated in configureCallbacks.ts\n * - this.state: CSFStateObject (populated below)\n */\n super(setupObj);\n\n this.state = {\n /**\n * For generic card will always be 'card'.\n * For non-generic card will be hardcoded to a particular txVariant e.g. 'mc' or 'visa'\n * For other types of SecuredField will be the passed type e.g. 'ach' or 'giftcard'\n */\n type: this.props.type,\n /**\n * For generic card will change as shopper types\n * For non-generic card will be fixed\n */\n brand: this.props.type !== 'card' ? { brand: this.props.type, cvcPolicy: 'required' } : { brand: null, cvcPolicy: 'required' },\n allValid: undefined,\n numIframes: 0,\n originalNumIframes: 0,\n iframeCount: 0,\n iframeConfigCount: 0,\n isConfigured: false,\n hasSeparateDateFields: false,\n currentFocusObject: null,\n registerFieldForIos: false,\n securedFields: {},\n isKCP: false\n } as CSFStateObject;\n\n // Create object of references to properties on 'this', that can be used to set up the partials\n const thisObj: CSFThisObject = { csfState: this.state, csfConfig: this.config, csfProps: this.props, csfCallbacks: this.callbacks };\n\n // Setup 'this' references\n this.configHandler = handleConfig;\n\n this.callbacksHandler = configureCallbacks;\n\n this.validateForm = partial(validateForm, thisObj);\n\n this.isConfigured = partial(isConfigured, thisObj, this.validateForm);\n this.handleIframeConfigFeedback = partial(handleIframeConfigFeedback, thisObj, this.isConfigured);\n\n this.processBrand = partial(processBrand, thisObj);\n\n this.handleValidation = handleValidation;\n this.handleEncryption = handleEncryption;\n\n this.createSecuredFields = createSecuredFields;\n this.createNonCardSecuredFields = createNonCardSecuredFields;\n this.createCardSecuredFields = createCardSecuredFields;\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.setupSecuredField = setupSecuredField;\n\n this.postMessageToAllIframes = partial(postMessageToAllIframes, thisObj);\n\n this.handleIOSTouchEvents = handleIOSTouchEvents.handleTouchend.bind(this);\n this.touchendListener = handleIOSTouchEvents.touchendListener.bind(this);\n this.destroyTouchendListener = handleIOSTouchEvents.destroyTouchendListener.bind(this);\n this.touchstartListener = handleIOSTouchEvents.touchstartListener.bind(this);\n this.destroyTouchstartListener = handleIOSTouchEvents.destroyTouchstartListener.bind(this);\n\n this.setFocusOnFrame = partial(setFocusOnFrame, thisObj);\n this.handleFocus = partial(handleFocus, thisObj, this.handleIOSTouchEvents);\n\n this.handleSFShiftTab = handleTab.handleSFShiftTab;\n this.handleShiftTab = handleTab.handleShiftTab;\n\n this.destroySecuredFields = destroySecuredFields;\n\n this.processAutoComplete = partial(processAutoComplete, thisObj);\n\n this.handleBinValue = partial(handleBinValue, thisObj);\n\n this.handleBrandFromBinLookup = handleBrandFromBinLookup;\n this.sendBrandToCardSF = sendBrandToCardSF;\n this.sendExpiryDatePolicyToSF = sendExpiryDatePolicyToSF;\n\n // Populate config & callbacks objects & create securedFields\n this.init();\n }\n\n private init(): void {\n this.configHandler(this.props);\n this.callbacksHandler(this.props.callbacks);\n\n /**\n * Create all the securedFields\n */\n const numIframes: number = this.createSecuredFields();\n\n this.state.numIframes = this.state.originalNumIframes = numIframes;\n\n this.state.isKCP = !!this.props.isKCP;\n\n /**\n * Add touchstart listener\n * re. Disabling arrow keys in iOS\n */\n if (ua.__IS_IOS && this.props.shouldDisableIOSArrowKeys) {\n this.hasGenuineTouchEvents = false;\n on(document, 'touchstart', this.touchstartListener);\n }\n }\n\n // Expose functions that can be called on the CSF instance\n public createReturnObject(): CSFReturnObject {\n // --\n const returnObj: CSFReturnObject = {\n // --\n updateStyles: (pStyleObject: StylesObject): void => {\n if (this.state.isConfigured) {\n this.postMessageToAllIframes({ styleObject: pStyleObject });\n } else {\n logger.warn(\n 'You cannot update the secured fields styling ' +\n \"- they are not yet configured. Use the 'onConfigSuccess' callback to know when this has happened.\"\n );\n }\n },\n setFocusOnFrame: (pFieldType: SFFieldType): void => {\n if (this.state.isConfigured) {\n this.setFocusOnFrame(pFieldType);\n // Comment in a quick way to test destroying secured fields (also see comment in destroySecuredFields)\n // this.destroySecuredFields();\n } else {\n notConfiguredWarning('You cannot set focus on any secured field');\n }\n },\n // For component based implementation - if showValidation function is called on the component use this\n // function as a way to notify the CSF that a field is in error\n isValidated: (pFieldType: SFFieldType, code: string): void => {\n if (this.state.isConfigured) {\n if (hasOwnProperty(this.state.securedFields, pFieldType)) {\n this.state.securedFields[pFieldType].hasError = true;\n\n // If there's not already an errorType, set one\n // NOTE: fixes issue in Components where you first validate and then start typing a maestro number\n // - w/o this and the corresponding fix in the SecuredField class the maestro PM will never register as valid\n if (this.state.securedFields[pFieldType].errorType === '') {\n this.state.securedFields[pFieldType].errorType = 'isValidated';\n }\n\n // Inform iframe\n const dataObj: object = {\n txVariant: this.state.type,\n fieldType: pFieldType,\n externalValidation: true,\n code,\n numKey: this.state.securedFields[pFieldType].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(this.state, pFieldType), this.config.loadingContext);\n }\n } else {\n notConfiguredWarning('You cannot set validated on any secured field');\n }\n },\n hasUnsupportedCard: (pFieldType: SFFieldType, code: string): void => {\n if (this.state.isConfigured) {\n if (hasOwnProperty(this.state.securedFields, pFieldType)) {\n //\n this.state.securedFields[pFieldType].hasError = !!code;\n this.state.securedFields[pFieldType].errorType = code;\n\n // Inform iframe\n const dataObj: object = {\n txVariant: this.state.type,\n fieldType: pFieldType,\n unsupportedCard: !!code,\n code,\n numKey: this.state.securedFields[pFieldType].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(this.state, pFieldType), this.config.loadingContext);\n }\n } else {\n notConfiguredWarning('You cannot set hasUnsupportedCard on any secured field');\n }\n },\n destroy: (): void => {\n if (this.state.isConfigured) {\n this.destroySecuredFields();\n } else {\n notConfiguredWarning('You cannot destroy secured fields');\n }\n },\n brandsFromBinLookup: (binLookupResponse: BinLookupResponse, resetObj: SingleBrandResetObject): void => {\n if (!this.config.isCreditCardType) return null;\n\n if (this.state.isConfigured) {\n this.handleBrandFromBinLookup(binLookupResponse, resetObj);\n } else {\n notConfiguredWarning('You cannot set pass brands to secured fields');\n }\n },\n addSecuredField: (pFieldType: SFFieldType): void => {\n const securedField: HTMLElement = selectOne(this.props.rootNode, `[data-cse=\"${pFieldType}\"]`);\n if (securedField) {\n this.state.numIframes += 1;\n this.setupSecuredField(securedField);\n }\n },\n removeSecuredField: (pFieldType: SFFieldType): void => {\n if (this.state.securedFields[pFieldType]) {\n this.state.securedFields[pFieldType].destroy();\n delete this.state.securedFields[pFieldType];\n this.state.numIframes -= 1;\n this.state.iframeCount -= 1;\n\n const callbackObj: CardAdditionalSFData = { additionalIframeRemoved: true, fieldType: pFieldType, type: this.state.type };\n this.callbacks.onAdditionalSFRemoved(callbackObj);\n }\n },\n setKCPStatus: (isKCP: boolean): void => {\n this.state.isKCP = isKCP;\n },\n sfIsOptionalOrHidden: (fieldType: string): boolean => {\n return this.state.securedFields[fieldType].isOptionalOrHidden();\n }\n };\n\n return returnObj;\n }\n}\n\nexport default CSF;\n"],"names":["notConfiguredWarning","str","logger","CSF","AbstractCSF","init","this","configHandler","props","callbacksHandler","callbacks","numIframes","createSecuredFields","state","originalNumIframes","isKCP","ua","__IS_IOS","shouldDisableIOSArrowKeys","hasGenuineTouchEvents","on","document","touchstartListener","createReturnObject","updateStyles","pStyleObject","isConfigured","postMessageToAllIframes","styleObject","setFocusOnFrame","pFieldType","isValidated","code","hasOwnProperty","securedFields","hasError","errorType","dataObj","txVariant","type","fieldType","externalValidation","numKey","postMessageToIframe","getIframeContentWin","config","loadingContext","hasUnsupportedCard","unsupportedCard","destroy","destroySecuredFields","brandsFromBinLookup","binLookupResponse","resetObj","isCreditCardType","handleBrandFromBinLookup","addSecuredField","securedField","selectOne","rootNode","setupSecuredField","removeSecuredField","iframeCount","callbackObj","additionalIframeRemoved","onAdditionalSFRemoved","setKCPStatus","sfIsOptionalOrHidden","isOptionalOrHidden","constructor","setupObj","super","brand","cvcPolicy","allValid","undefined","iframeConfigCount","hasSeparateDateFields","currentFocusObject","registerFieldForIos","thisObj","csfState","csfConfig","csfProps","csfCallbacks","handleConfig","configureCallbacks","validateForm","partial","handleIframeConfigFeedback","processBrand","handleValidation","handleEncryption","createNonCardSecuredFields","createCardSecuredFields","handleIOSTouchEvents","handleTouchend","bind","touchendListener","destroyTouchendListener","destroyTouchstartListener","handleFocus","handleSFShiftTab","handleTab","handleShiftTab","processAutoComplete","handleBinValue","sendBrandToCardSF","sendExpiryDatePolicyToSF"],"mappings":"qrDAgCA,MAAMA,EAAuB,CAACC,EAAM,mCAChCC,EAAY,GAAGD,sGAAuG,EAG1H,MAAME,UAAYC,EA2FNC,IAAAA,GACJC,KAAKC,cAAcD,KAAKE,OACxBF,KAAKG,iBAAiBH,KAAKE,MAAME,WAKjC,MAAMC,EAAqBL,KAAKM,sBAEhCN,KAAKO,MAAMF,WAAaL,KAAKO,MAAMC,mBAAqBH,EAExDL,KAAKO,MAAME,QAAUT,KAAKE,MAAMO,MAM5BC,EAAGC,UAAYX,KAAKE,MAAMU,4BAC1BZ,KAAKa,uBAAwB,EAC7BC,EAAG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