@adyen/adyen-web 6.0.0-alpha.2 → 6.0.0-alpha.3
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/README.md +166 -0
- package/dist/cjs/adyen.css +2 -2
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1932 -1968
- package/dist/es/adyen.css +2 -2
- package/dist/es/components/AmazonPay/AmazonPay.js +1 -1
- package/dist/es/components/AmazonPay/AmazonPay.js.map +1 -1
- package/dist/es/components/AmazonPay/components/AmazonPayComponent.js +1 -1
- package/dist/es/components/AmazonPay/components/AmazonPayComponent.js.map +1 -1
- package/dist/es/components/ApplePay/ApplePay.js +1 -1
- package/dist/es/components/ApplePay/ApplePay.js.map +1 -1
- package/dist/es/components/ApplePay/defaultProps.js +1 -1
- package/dist/es/components/ApplePay/defaultProps.js.map +1 -1
- package/dist/es/components/ApplePay/payment-request.js.map +1 -1
- package/dist/es/components/Boleto/components/BoletoInput/validate.js +1 -1
- package/dist/es/components/Boleto/components/BoletoInput/validate.js.map +1 -1
- package/dist/es/components/Card/Card.js +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/components/CardFieldsWrapper.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/CardHolderName.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/CardHolderName.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/KCPAuthentication.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/KCPAuthentication.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/utils.js +1 -1
- package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/validate.js +1 -1
- package/dist/es/components/Card/components/CardInput/validate.js.map +1 -1
- package/dist/es/components/CashAppPay/defaultProps.js +1 -1
- package/dist/es/components/CashAppPay/defaultProps.js.map +1 -1
- package/dist/es/components/Donation/Donation.js.map +1 -1
- package/dist/es/components/Dragonpay/Dragonpay.js +1 -1
- package/dist/es/components/Dragonpay/Dragonpay.js.map +1 -1
- package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
- package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
- package/dist/es/components/Econtext/Econtext.js +1 -1
- package/dist/es/components/Econtext/Econtext.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/Giropay/Giropay.js +1 -1
- package/dist/es/components/Giropay/Giropay.js.map +1 -1
- package/dist/es/components/GooglePay/GooglePay.js +1 -1
- package/dist/es/components/GooglePay/GooglePay.js.map +1 -1
- package/dist/es/components/GooglePay/GooglePayService.js +1 -1
- package/dist/es/components/GooglePay/GooglePayService.js.map +1 -1
- package/dist/es/components/GooglePay/defaultProps.js +1 -1
- package/dist/es/components/GooglePay/defaultProps.js.map +1 -1
- package/dist/es/components/GooglePay/requests.js.map +1 -1
- package/dist/es/components/Multibanco/Multibanco.js +1 -1
- package/dist/es/components/Multibanco/Multibanco.js.map +1 -1
- package/dist/es/components/Pix/Pix.js +1 -1
- package/dist/es/components/Pix/Pix.js.map +1 -1
- package/dist/es/components/Pix/PixInput/PixInput.js +1 -1
- package/dist/es/components/Pix/PixInput/PixInput.js.map +1 -1
- package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
- package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
- package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js +1 -1
- package/dist/es/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
- package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
- package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
- package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
- package/dist/es/components/ThreeDS2/components/utils.js +1 -1
- package/dist/es/components/ThreeDS2/components/utils.js.map +1 -1
- package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
- package/dist/es/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
- package/dist/es/components/internal/Address/Address.js +1 -1
- package/dist/es/components/internal/Address/Address.js.map +1 -1
- package/dist/es/components/internal/Address/validate.js +1 -1
- package/dist/es/components/internal/Address/validate.js.map +1 -1
- package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
- package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
- package/dist/es/components/internal/CompanyDetails/validate.js +1 -1
- package/dist/es/components/internal/CompanyDetails/validate.js.map +1 -1
- package/dist/es/components/internal/IbanInput/IbanInput.js.map +1 -1
- package/dist/es/components/internal/Img/Img.js +1 -1
- package/dist/es/components/internal/Img/Img.js.map +1 -1
- package/dist/es/components/internal/PersonalDetails/PersonalDetails.js +1 -1
- package/dist/es/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
- package/dist/es/components/internal/PersonalDetails/validate.js +1 -1
- package/dist/es/components/internal/PersonalDetails/validate.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SFPUtils.js +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SFPUtils.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js +1 -1
- package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.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/utils/cardType.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/utils/cardType.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/utils/processErrors.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/utils/processErrors.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/configuration/constants.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/configuration/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/securedField/SecuredField.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/securedField/utils/processAriaConfig.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/securedField/utils/processPlaceholders.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/utilities/addContextTranslations.js.map +1 -1
- package/dist/es/components/internal/SegmentedControl/SegmentedControl.js +1 -1
- package/dist/es/components/internal/SegmentedControl/SegmentedControl.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 +1 -1
- package/dist/es/components/internal/UIElement/utils.js.map +1 -1
- package/dist/es/core/Analytics/Analytics.js +1 -1
- package/dist/es/core/Analytics/Analytics.js.map +1 -1
- package/dist/es/core/Analytics/constants.js +1 -1
- package/dist/es/core/Analytics/constants.js.map +1 -1
- package/dist/es/core/Analytics/utils.js +1 -1
- package/dist/es/core/Analytics/utils.js.map +1 -1
- package/dist/es/core/Errors/constants.js +1 -1
- package/dist/es/core/Errors/constants.js.map +1 -1
- package/dist/es/core/Errors/utils.js +1 -1
- package/dist/es/core/Errors/utils.js.map +1 -1
- package/dist/es/core/ProcessResponse/PaymentAction/actionTypes.js +1 -1
- package/dist/es/core/ProcessResponse/PaymentAction/actionTypes.js.map +1 -1
- package/dist/es/core/Services/analytics/collect-id.js +1 -1
- package/dist/es/core/Services/analytics/log-event.js +1 -1
- package/dist/es/core/core.js +1 -1
- package/dist/es/core/core.js.map +1 -1
- package/dist/es/core/utils.js +1 -1
- package/dist/es/core/utils.js.map +1 -1
- package/dist/es/index.d.ts +1932 -1968
- package/dist/es/language/locales/ar.json.js +1 -1
- package/dist/es/language/locales/cs-CZ.json.js +1 -1
- package/dist/es/language/locales/da-DK.json.js +1 -1
- package/dist/es/language/locales/de-DE.json.js +1 -1
- package/dist/es/language/locales/el-GR.json.js +1 -1
- package/dist/es/language/locales/en-US.json.js +1 -1
- package/dist/es/language/locales/es-ES.json.js +1 -1
- package/dist/es/language/locales/fi-FI.json.js +1 -1
- package/dist/es/language/locales/fr-FR.json.js +1 -1
- package/dist/es/language/locales/hr-HR.json.js +1 -1
- package/dist/es/language/locales/hu-HU.json.js +1 -1
- package/dist/es/language/locales/it-IT.json.js +1 -1
- package/dist/es/language/locales/ja-JP.json.js +1 -1
- package/dist/es/language/locales/ko-KR.json.js +1 -1
- package/dist/es/language/locales/nl-NL.json.js +1 -1
- package/dist/es/language/locales/no-NO.json.js +1 -1
- package/dist/es/language/locales/pl-PL.json.js +1 -1
- package/dist/es/language/locales/pt-BR.json.js +1 -1
- package/dist/es/language/locales/pt-PT.json.js +1 -1
- package/dist/es/language/locales/ro-RO.json.js +1 -1
- package/dist/es/language/locales/ru-RU.json.js +1 -1
- package/dist/es/language/locales/sk-SK.json.js +1 -1
- package/dist/es/language/locales/sl-SI.json.js +1 -1
- package/dist/es/language/locales/sv-SE.json.js +1 -1
- package/dist/es/language/locales/zh-CN.json.js +1 -1
- package/dist/es/language/locales/zh-TW.json.js +1 -1
- package/dist/es/utils/Formatters/formatters.js.map +1 -1
- package/dist/es/utils/Validator/defaultRules.js +1 -1
- package/dist/es/utils/Validator/defaultRules.js.map +1 -1
- package/dist/es/utils/base64.js +1 -1
- package/dist/es/utils/base64.js.map +1 -1
- package/dist/es/utils/getErrorMessage.js +1 -1
- package/dist/es/utils/getErrorMessage.js.map +1 -1
- package/dist/es-legacy/adyen.css +2 -2
- package/dist/es-legacy/components/AmazonPay/AmazonPay.js +1 -1
- package/dist/es-legacy/components/AmazonPay/AmazonPay.js.map +1 -1
- package/dist/es-legacy/components/AmazonPay/components/AmazonPayComponent.js +1 -1
- package/dist/es-legacy/components/AmazonPay/components/AmazonPayComponent.js.map +1 -1
- package/dist/es-legacy/components/ApplePay/ApplePay.js +1 -1
- package/dist/es-legacy/components/ApplePay/ApplePay.js.map +1 -1
- package/dist/es-legacy/components/ApplePay/defaultProps.js +1 -1
- package/dist/es-legacy/components/ApplePay/defaultProps.js.map +1 -1
- package/dist/es-legacy/components/ApplePay/payment-request.js.map +1 -1
- package/dist/es-legacy/components/Boleto/components/BoletoInput/validate.js +1 -1
- package/dist/es-legacy/components/Boleto/components/BoletoInput/validate.js.map +1 -1
- package/dist/es-legacy/components/Card/Card.js +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/components/CardFieldsWrapper.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CardFieldsWrapper.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CardHolderName.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/CardHolderName.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/KCPAuthentication.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/KCPAuthentication.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/utils.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/validate.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/validate.js.map +1 -1
- package/dist/es-legacy/components/CashAppPay/defaultProps.js +1 -1
- package/dist/es-legacy/components/CashAppPay/defaultProps.js.map +1 -1
- package/dist/es-legacy/components/Donation/Donation.js.map +1 -1
- package/dist/es-legacy/components/Dragonpay/Dragonpay.js +1 -1
- package/dist/es-legacy/components/Dragonpay/Dragonpay.js.map +1 -1
- package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
- package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
- package/dist/es-legacy/components/Econtext/Econtext.js +1 -1
- package/dist/es-legacy/components/Econtext/Econtext.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/Giropay/Giropay.js +1 -1
- package/dist/es-legacy/components/Giropay/Giropay.js.map +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePay.js +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePayService.js +1 -1
- package/dist/es-legacy/components/GooglePay/GooglePayService.js.map +1 -1
- package/dist/es-legacy/components/GooglePay/defaultProps.js +1 -1
- package/dist/es-legacy/components/GooglePay/defaultProps.js.map +1 -1
- package/dist/es-legacy/components/GooglePay/requests.js.map +1 -1
- package/dist/es-legacy/components/Multibanco/Multibanco.js +1 -1
- package/dist/es-legacy/components/Multibanco/Multibanco.js.map +1 -1
- package/dist/es-legacy/components/Pix/Pix.js +1 -1
- package/dist/es-legacy/components/Pix/Pix.js.map +1 -1
- package/dist/es-legacy/components/Pix/PixInput/PixInput.js +1 -1
- package/dist/es-legacy/components/Pix/PixInput/PixInput.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Challenge/DoChallenge3DS2.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/utils.js +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/utils.js.map +1 -1
- package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js +1 -1
- package/dist/es-legacy/components/helpers/IssuerListContainer/IssuerListContainer.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/Address.js +1 -1
- package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
- package/dist/es-legacy/components/internal/Address/validate.js +1 -1
- package/dist/es-legacy/components/internal/Address/validate.js.map +1 -1
- package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
- package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
- package/dist/es-legacy/components/internal/CompanyDetails/validate.js +1 -1
- package/dist/es-legacy/components/internal/CompanyDetails/validate.js.map +1 -1
- package/dist/es-legacy/components/internal/IbanInput/IbanInput.js.map +1 -1
- package/dist/es-legacy/components/internal/Img/Img.js +1 -1
- package/dist/es-legacy/components/internal/Img/Img.js.map +1 -1
- package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js +1 -1
- package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
- package/dist/es-legacy/components/internal/PersonalDetails/validate.js +1 -1
- package/dist/es-legacy/components/internal/PersonalDetails/validate.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SFPUtils.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SFPUtils.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.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/utils/cardType.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/cardType.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/processErrors.js +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/configuration/constants.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/configuration/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/securedField/SecuredField.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/utils/processAriaConfig.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/utils/processPlaceholders.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/utilities/addContextTranslations.js.map +1 -1
- package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js +1 -1
- package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.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 +1 -1
- package/dist/es-legacy/components/internal/UIElement/utils.js.map +1 -1
- package/dist/es-legacy/core/Analytics/Analytics.js +1 -1
- package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
- package/dist/es-legacy/core/Analytics/constants.js +1 -1
- package/dist/es-legacy/core/Analytics/constants.js.map +1 -1
- package/dist/es-legacy/core/Analytics/utils.js +1 -1
- package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
- package/dist/es-legacy/core/Errors/constants.js +1 -1
- package/dist/es-legacy/core/Errors/constants.js.map +1 -1
- package/dist/es-legacy/core/Errors/utils.js +1 -1
- package/dist/es-legacy/core/Errors/utils.js.map +1 -1
- package/dist/es-legacy/core/ProcessResponse/PaymentAction/actionTypes.js +1 -1
- package/dist/es-legacy/core/ProcessResponse/PaymentAction/actionTypes.js.map +1 -1
- package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
- package/dist/es-legacy/core/Services/analytics/log-event.js +1 -1
- package/dist/es-legacy/core/core.js +1 -1
- package/dist/es-legacy/core/core.js.map +1 -1
- package/dist/es-legacy/core/utils.js +1 -1
- package/dist/es-legacy/core/utils.js.map +1 -1
- package/dist/es-legacy/language/locales/ar.json.js +1 -1
- package/dist/es-legacy/language/locales/cs-CZ.json.js +1 -1
- package/dist/es-legacy/language/locales/da-DK.json.js +1 -1
- package/dist/es-legacy/language/locales/de-DE.json.js +1 -1
- package/dist/es-legacy/language/locales/el-GR.json.js +1 -1
- package/dist/es-legacy/language/locales/en-US.json.js +1 -1
- package/dist/es-legacy/language/locales/es-ES.json.js +1 -1
- package/dist/es-legacy/language/locales/fi-FI.json.js +1 -1
- package/dist/es-legacy/language/locales/fr-FR.json.js +1 -1
- package/dist/es-legacy/language/locales/hr-HR.json.js +1 -1
- package/dist/es-legacy/language/locales/hu-HU.json.js +1 -1
- package/dist/es-legacy/language/locales/it-IT.json.js +1 -1
- package/dist/es-legacy/language/locales/ja-JP.json.js +1 -1
- package/dist/es-legacy/language/locales/ko-KR.json.js +1 -1
- package/dist/es-legacy/language/locales/nl-NL.json.js +1 -1
- package/dist/es-legacy/language/locales/no-NO.json.js +1 -1
- package/dist/es-legacy/language/locales/pl-PL.json.js +1 -1
- package/dist/es-legacy/language/locales/pt-BR.json.js +1 -1
- package/dist/es-legacy/language/locales/pt-PT.json.js +1 -1
- package/dist/es-legacy/language/locales/ro-RO.json.js +1 -1
- package/dist/es-legacy/language/locales/ru-RU.json.js +1 -1
- package/dist/es-legacy/language/locales/sk-SK.json.js +1 -1
- package/dist/es-legacy/language/locales/sl-SI.json.js +1 -1
- package/dist/es-legacy/language/locales/sv-SE.json.js +1 -1
- package/dist/es-legacy/language/locales/zh-CN.json.js +1 -1
- package/dist/es-legacy/language/locales/zh-TW.json.js +1 -1
- package/dist/es-legacy/utils/Formatters/formatters.js.map +1 -1
- package/dist/es-legacy/utils/Validator/defaultRules.js +1 -1
- package/dist/es-legacy/utils/Validator/defaultRules.js.map +1 -1
- package/dist/es-legacy/utils/base64.js +1 -1
- package/dist/es-legacy/utils/base64.js.map +1 -1
- package/dist/es-legacy/utils/getErrorMessage.js +1 -1
- package/dist/es-legacy/utils/getErrorMessage.js.map +1 -1
- package/dist/umd/adyen.css +2 -2
- package/dist/umd/adyen.js +2 -2
- package/dist/umd/adyen.js.map +1 -1
- package/package.json +1 -1
|
@@ -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} from '../lib/types';\nimport { CSFReturnObject, CSFSetupObject } from '../lib/CSF/types';\nimport {\n CVC_POLICY_REQUIRED,\n DATE_POLICY_REQUIRED,\n DEDICATED_CARD_COMPONENTS,\n ENCRYPTED_CARD_NUMBER,\n ENCRYPTED_PWD_FIELD\n} from '../lib/configuration/constants';\nimport { BinLookupResponse } from '../../../Card/types';\nimport { getError } from '../../../../core/Errors/utils';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { SFStateErrorObj } from '../../../Card/components/CardInput/types';\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 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\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 },\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 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 errorKeys: string[] = Object.keys(this.state.errors);\n const sfStateErrorsObj = errorKeys.reduce((acc, key) => {\n if (this.state.errors[key]) {\n acc[key] = {\n isValid: false,\n errorMessage: getError(this.state.errors[key]),\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(this.state.errors[key]),\n error: this.state.errors[key],\n rootNode: this.rootNode,\n ...(this.state.detectedUnsupportedBrands && { detectedBrands: this.state.detectedUnsupportedBrands })\n };\n } else {\n acc[key] = null;\n }\n return acc;\n }, {});\n return sfStateErrorsObj;\n }\n\n public processBinLookupResponse(binLookupResponse: BinLookupResponse, resetObject: SingleBrandResetObject): void {\n // If we were dealing with an unsupported card & now we have a valid /binLookup response (or a response triggering a reset of the UI),\n // - reset state to clear the error & the stored unsupportedBrands and, in the case of a valid /binLookup response, inform CSF (via handleUnsupportedCard)\n // (Scenario: from an unsupportedCard state the shopper has pasted another number long enough to trigger a /binLookup)\n if (this.state.detectedUnsupportedBrands) {\n this.setState(prevState => ({\n errors: { ...prevState.errors, [ENCRYPTED_CARD_NUMBER]: false },\n detectedUnsupportedBrands: null\n }));\n\n // If we have some sort of binLookupResponse object then this isn't the reset caused by digits dropping below a threshold\n // - so call handleUnsupportedCard to clear the error\n if (this.csf && binLookupResponse) {\n const errObj: CbObjOnError = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n this.handleUnsupportedCard(errObj);\n }\n }\n\n this.issuingCountryCode = binLookupResponse?.issuingCountryCode?.toLowerCase();\n\n const hasBrandedResetObj = resetObject?.brand;\n\n /**\n * Are we dealing with a \"dedicated\" card scenario i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands\n * - in which case we will need to reset brand and pass on the resetObj to CSF\n */\n const mustResetDedicatedBrand = hasBrandedResetObj && DEDICATED_CARD_COMPONENTS.includes(resetObject.brand);\n\n if (mustResetDedicatedBrand) {\n // resetObject.brand will be the value of the brand whose logo we want to reshow in the UI\n this.setState(resetObject, () => {\n this.props.onChange(this.state);\n });\n }\n\n /**\n * Scenarios:\n *\n * - RESET (binLookupResponse === null): The number of digits in number field has dropped below threshold for BIN lookup\n * - RESULT (binLookupResponse.supportedBrands.length === 1): binLookup has found a result so inform CSF\n *\n * In the RESET scenario, for \"dedicated\" card components we also need to pass on the resetObject since this contains information about\n * the brand that CSF needs to reset to, internally.\n */\n if (this.csf) this.csf.brandsFromBinLookup(binLookupResponse, mustResetDedicatedBrand ? resetObject : null);\n }\n\n private setRootNode = (input: HTMLElement): void => {\n this.rootNode = input;\n };\n\n public render(props, state) {\n return props.render({ setRootNode: this.setRootNode, setFocusOn: this.setFocusOn }, state);\n }\n}\n\nexport default SecuredFieldsProvider;\n"],"names":["SecuredFieldsProvider","Component","csfLoadFailTimeout","csfLoadFailTimeoutMS","csfConfigFailTimeout","csfConfigFailTimeoutMS","numCharsInField","rootNode","numDateFields","csf","handleOnLoad","handleOnConfigSuccess","handleOnFieldValid","handleOnAllValid","handleOnBrand","handleFocus","handleOnError","handleOnAutoComplete","handleOnNoDataRequired","handleOnTouchstartIOS","state","props","issuingCountryCode","constructor","super","stateObj","status","brand","type","errors","valid","data","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","isSfpValid","hasKoreanFields","this","handlers","bind","processBinLookupResponse","setFocusOn","updateStyles","handleUnsupportedCard","showValidation","destroy","static","defaultProps","componentDidMount","setRootNode","fields","getFields","reduce","validFieldsReducer","setState","forEach","field","filter","f","match","length","initializeCSF","componentDidUpdate","checkForKCPFields","componentWillUnmount","clearTimeout","root","loadingContext","csfSetupObj","clientKey","cardGroupTypes","brands","autoFocus","trimTrailingSeparator","keypadFix","showWarnings","iframeUIConfig","sfStyles","styles","i18n","callbacks","onLoad","onConfigSuccess","onFieldValid","onAllValid","onBrand","onError","onFocus","onBinValue","onAutoComplete","onAdditionalSFConfig","onAdditionalSFRemoved","onTouchstartIOS","isKCP","legacyInputMode","minimumExpiryDate","implementationType","forceCompat","maskSecurityCode","shouldDisableIOSArrowKeys","disableIOSArrowKeys","placeholders","showContextualElement","initCSF","setTimeout","AdyenCheckoutError","needsKoreanFields","koreanAuthenticationRequired","countryCode","setRemovedFieldState","prevState","ENCRYPTED_PWD_FIELD","undefined","onChange","removeSecuredField","setKCPStatus","setAddedFieldState","addSecuredField","getChildContext","errObj","hasUnsupportedCard","error","detectedUnsupportedBrands","detectedBrands","ENCRYPTED_CARD_NUMBER","frame","setFocusOnFrame","stylesObj","sfIsOptionalOrHidden","fieldType","Object","keys","getErrorReducer","errorObj","getErrorObject","isValidated","mapErrorsToValidationRuleResult","acc","key","isValid","errorMessage","getError","errorI18n","get","binLookupResponse","resetObject","toLowerCase","hasBrandedResetObj","mustResetDedicatedBrand","DEDICATED_CARD_COMPONENTS","includes","brandsFromBinLookup","input","render"],"mappings":"wlBAkCA,MAAMA,UAA8BC,EACxBC,mBACAC,qBACAC,qBACAC,uBACAC,gBACAC,SACAC,cACAC,IACAC,aACAC,sBACAC,mBACAC,iBACAC,cACAC,YACAC,cACAC,qBACAC,uBACAC,sBACDC,MACAC,MACCC,mBAERC,WAAAA,CAAYF,GACRG,MAAMH,GAEN,MAAMI,EAAqB,CACvBC,OAAQ,UACRC,MAAON,EAAMO,KACbC,OAAQ,CAAC,EACTC,MAAO,CAAC,EACRC,KAAM,CAAC,EACPC,UAAWC,EACXC,iBAAkBC,EAClBC,YAAY,EACZC,gBAAiBhB,EAAMgB,iBAE3BC,KAAKlB,MAAQK,EAEba,KAAKpC,mBAAqB,KAC1BoC,KAAKnC,qBAAuB,IAE5BmC,KAAKlC,qBAAuB,KAC5BkC,KAAKjC,uBAAyB,KAE9BiC,KAAKhC,gBAAkB,GAGvBgC,KAAK5B,aAAe6B,EAAS7B,aAAa8B,KAAKF,MAC/CA,KAAK3B,sBAAwB4B,EAAS5B,sBAAsB6B,KAAKF,MACjEA,KAAK1B,mBAAqB2B,EAAS3B,mBAAmB4B,KAAKF,MAC3DA,KAAKzB,iBAAmB0B,EAAS1B,iBAAiB2B,KAAKF,MACvDA,KAAKxB,cAAgByB,EAASzB,cAAc0B,KAAKF,MACjDA,KAAKvB,YAAcwB,EAASxB,YAAYyB,KAAKF,MAC7CA,KAAKtB,cAAgBuB,EAASvB,cAAcwB,KAAKF,MACjDA,KAAKpB,uBAAyBqB,EAASrB,uBAAuBsB,KAAKF,MACnEA,KAAKrB,qBAAuBsB,EAAStB,qBAAqBuB,KAAKF,MAC/DA,KAAKnB,sBAAwBoB,EAASpB,sBAAsBqB,KAAKF,MAEjEA,KAAKG,yBAA2BH,KAAKG,yBAAyBD,KAAKF,MAGn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AAS5E,KAAKlB,MAAK,IAalCkB,KAAK7B,KAAK6B,KAAK7B,IAAI+I,oBAAoBP,EAAmBI,EAA0BH,EAAc,KAC1G,CAEQhG,YAAeuG,IACnBnH,KAAK/B,SAAWkJ,CAAAA,EAGbC,MAAAA,CAAOrI,EAAOD,GACjB,OAAOC,EAAMqI,OAAO,CAAExG,YAAaZ,KAAKY,YAAaR,WAAYJ,KAAKI,YAActB,EACxF"}
|
|
1
|
+
{"version":3,"file":"SecuredFieldsProvider.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SecuredFieldsProvider.ts"],"sourcesContent":["import { Component } from 'preact';\nimport { getErrorObject, getFields, getErrorReducer, validFieldsReducer } from './SFPUtils';\nimport initCSF from '../lib/CSF';\nimport handlers from './SecuredFieldsProviderHandlers';\nimport defaultProps from './defaultProps';\nimport { SFPProps, SFPState, SingleBrandResetObject } from './types';\nimport {\n StylesObject,\n CbObjOnError,\n CbObjOnFocus,\n CbObjOnBrand,\n CbObjOnAllValid,\n CbObjOnFieldValid,\n CbObjOnAutoComplete,\n CbObjOnConfigSuccess,\n CbObjOnLoad\n} from '../lib/types';\nimport { CSFReturnObject, CSFSetupObject } from '../lib/CSF/types';\nimport {\n CVC_POLICY_REQUIRED,\n DATE_POLICY_REQUIRED,\n DEDICATED_CARD_COMPONENTS,\n ENCRYPTED_CARD_NUMBER,\n ENCRYPTED_PWD_FIELD\n} from '../lib/configuration/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 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\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 },\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 shouldDisableIOSArrowKeys: !!this.props.disableIOSArrowKeys, // convert whether function has been defined into a boolean\n placeholders: this.props.placeholders ?? {},\n showContextualElement: this.props.showContextualElement\n };\n\n this.csf = initCSF(csfSetupObj);\n\n /**\n * Expect to at least have had the handleOnLoad callback called within this time\n * - if this hasn't happened then something has happened to interrupt the loading of the securedFields\n * So we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n // @ts-ignore - timout 'type' is a number\n this.csfLoadFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfLoadFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured field iframes have failed to load'));\n }\n }, this.csfLoadFailTimeoutMS);\n }\n\n private checkForKCPFields() {\n let needsKoreanFields = false;\n if (this.props.koreanAuthenticationRequired) {\n needsKoreanFields = this.issuingCountryCode ? this.issuingCountryCode === 'kr' : this.props.countryCode === 'kr';\n }\n\n // Was korean, now isn't - hide password field\n if (this.state.hasKoreanFields && !needsKoreanFields) {\n // Clear any stored data\n const setRemovedFieldState = prevState => ({\n data: { ...prevState.data, [ENCRYPTED_PWD_FIELD]: undefined },\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n errors: { ...prevState.errors, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: false\n });\n\n this.setState(setRemovedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.removeSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(false);\n }\n\n // Wasn't korean, now is - show password field\n if (!this.state.hasKoreanFields && needsKoreanFields) {\n const setAddedFieldState = prevState => ({\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: true,\n isSfpValid: false\n });\n\n this.setState(setAddedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.addSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(true);\n }\n }\n\n public getChildContext(): object {\n return { i18n: this.props.i18n };\n }\n\n public handleUnsupportedCard(errObj: CbObjOnError): boolean {\n const hasUnsupportedCard = !!errObj.error;\n\n // Store the brand(s) we detected and which we don't support\n if (hasUnsupportedCard) {\n this.setState({ detectedUnsupportedBrands: errObj.detectedBrands });\n }\n\n errObj.rootNode = this.rootNode; // Needed for CustomCard\n this.handleOnError(errObj, hasUnsupportedCard);\n // Inform CSF that the number field has an unsupportedCard error (or that it has been cleared)\n if (this.csf) {\n this.csf.hasUnsupportedCard(ENCRYPTED_CARD_NUMBER, errObj.error);\n }\n return hasUnsupportedCard;\n }\n\n public setFocusOn(frame: string): void {\n if (this.csf) this.csf.setFocusOnFrame(frame);\n }\n\n public updateStyles(stylesObj: StylesObject): void {\n if (this.csf) this.csf.updateStyles(stylesObj);\n }\n\n public sfIsOptionalOrHidden(fieldType: string): boolean {\n return this.csf.sfIsOptionalOrHidden(fieldType);\n }\n\n public destroy(): void {\n if (this.csf) this.csf.destroy();\n }\n\n public showValidation(): void {\n const { numDateFields, state }: SecuredFieldsProvider = this;\n\n Object.keys(state.valid)\n .reduce(getErrorReducer(numDateFields, state), [])\n .forEach(field => {\n // For each detected error pass an error object to the handler (calls error callback & sets state)\n const errorObj: CbObjOnError = getErrorObject(field, this.rootNode, state);\n this.handleOnError(errorObj, !!state.detectedUnsupportedBrands);\n // Inform the secured-fields instance of which fields have been found to have errors\n if (this.csf && this.csf.isValidated) {\n this.csf.isValidated(field, errorObj.error);\n }\n });\n }\n\n /**\n * Map SF errors to ValidationRuleResult-like objects, for CardInput component\n */\n public mapErrorsToValidationRuleResult(): SFStateErrorObj {\n const fieldNames: string[] = Object.keys(this.state.errors);\n\n const sfStateErrorsObj = fieldNames.reduce((acc, fieldName) => {\n const errorCode = this.state.errors[fieldName];\n if (errorCode) {\n acc[fieldName] = {\n isValid: false,\n errorMessage: getErrorMessageFromCode(errorCode, SF_ErrorCodes), // this is the human-readable, untranslated, explanation of the error that will exist on the error object in card.state.errors\n // For v5 the object found in state.errors should also contain the additional properties that used to be sent to the onError callback\n // namely: translation, errorCode, a ref to rootNode &, in the case of failed binLookup, an array of the detectedBrands\n errorI18n: this.props.i18n.get(errorCode),\n error: errorCode,\n rootNode: this.rootNode,\n ...(this.state.detectedUnsupportedBrands && { detectedBrands: this.state.detectedUnsupportedBrands })\n };\n } else {\n acc[fieldName] = null;\n }\n return acc;\n }, {});\n return sfStateErrorsObj;\n }\n\n public processBinLookupResponse(binLookupResponse: BinLookupResponse, resetObject: SingleBrandResetObject): void {\n // If we were dealing with an unsupported card & now we have a valid /binLookup response (or a response triggering a reset of the UI),\n // - reset state to clear the error & the stored unsupportedBrands and, in the case of a valid /binLookup response, inform CSF (via handleUnsupportedCard)\n // (Scenario: from an unsupportedCard state the shopper has pasted another number long enough to trigger a /binLookup)\n if (this.state.detectedUnsupportedBrands) {\n this.setState(prevState => ({\n errors: { ...prevState.errors, [ENCRYPTED_CARD_NUMBER]: false },\n detectedUnsupportedBrands: null\n }));\n\n // If we have some sort of binLookupResponse object then this isn't the reset caused by digits dropping below a threshold\n // - so call handleUnsupportedCard to clear the error\n if (this.csf && binLookupResponse) {\n const errObj: CbObjOnError = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n this.handleUnsupportedCard(errObj);\n }\n }\n\n this.issuingCountryCode = binLookupResponse?.issuingCountryCode?.toLowerCase();\n\n const hasBrandedResetObj = resetObject?.brand;\n\n /**\n * Are we dealing with a \"dedicated\" card scenario i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands\n * - in which case we will need to reset brand and pass on the resetObj to CSF\n */\n const mustResetDedicatedBrand = hasBrandedResetObj && DEDICATED_CARD_COMPONENTS.includes(resetObject.brand);\n\n if (mustResetDedicatedBrand) {\n // resetObject.brand will be the value of the brand whose logo we want to reshow in the UI\n this.setState(resetObject, () => {\n this.props.onChange(this.state);\n });\n }\n\n /**\n * Scenarios:\n *\n * - RESET (binLookupResponse === null): The number of digits in number field has dropped below threshold for BIN lookup\n * - RESULT (binLookupResponse.supportedBrands.length === 1): binLookup has found a result so inform CSF\n *\n * In the RESET scenario, for \"dedicated\" card components we also need to pass on the resetObject since this contains information about\n * the brand that CSF needs to reset to, internally.\n */\n if (this.csf) this.csf.brandsFromBinLookup(binLookupResponse, mustResetDedicatedBrand ? resetObject : null);\n }\n\n private setRootNode = (input: HTMLElement): void => {\n this.rootNode = input;\n };\n\n public render(props, state) {\n return props.render({ setRootNode: this.setRootNode, setFocusOn: this.setFocusOn }, state);\n }\n}\n\nexport default SecuredFieldsProvider;\n"],"names":["SecuredFieldsProvider","Component","csfLoadFailTimeout","csfLoadFailTimeoutMS","csfConfigFailTimeout","csfConfigFailTimeoutMS","numCharsInField","rootNode","numDateFields","csf","handleOnLoad","handleOnConfigSuccess","handleOnFieldValid","handleOnAllValid","handleOnBrand","handleFocus","handleOnError","handleOnAutoComplete","handleOnNoDataRequired","handleOnTouchstartIOS","state","props","issuingCountryCode","constructor","super","stateObj","status","brand","type","errors","valid","data","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","isSfpValid","hasKoreanFields","this","handlers","bind","processBinLookupResponse","setFocusOn","updateStyles","handleUnsupportedCard","showValidation","destroy","static","defaultProps","componentDidMount","setRootNode","fields","getFields","reduce","validFieldsReducer","setState","forEach","field","filter","f","match","length","initializeCSF","componentDidUpdate","checkForKCPFields","componentWillUnmount","clearTimeout","root","loadingContext","csfSetupObj","clientKey","cardGroupTypes","brands","autoFocus","trimTrailingSeparator","keypadFix","showWarnings","iframeUIConfig","sfStyles","styles","i18n","callbacks","onLoad","onConfigSuccess","onFieldValid","onAllValid","onBrand","onError","onFocus","onBinValue","onAutoComplete","onAdditionalSFConfig","onAdditionalSFRemoved","onTouchstartIOS","isKCP","legacyInputMode","minimumExpiryDate","implementationType","forceCompat","maskSecurityCode","shouldDisableIOSArrowKeys","disableIOSArrowKeys","placeholders","showContextualElement","initCSF","setTimeout","AdyenCheckoutError","needsKoreanFields","koreanAuthenticationRequired","countryCode","setRemovedFieldState","prevState","ENCRYPTED_PWD_FIELD","undefined","onChange","removeSecuredField","setKCPStatus","setAddedFieldState","addSecuredField","getChildContext","errObj","hasUnsupportedCard","error","detectedUnsupportedBrands","detectedBrands","ENCRYPTED_CARD_NUMBER","frame","setFocusOnFrame","stylesObj","sfIsOptionalOrHidden","fieldType","Object","keys","getErrorReducer","errorObj","getErrorObject","isValidated","mapErrorsToValidationRuleResult","acc","fieldName","errorCode","isValid","errorMessage","getErrorMessageFromCode","SF_ErrorCodes","errorI18n","get","binLookupResponse","resetObject","toLowerCase","hasBrandedResetObj","mustResetDedicatedBrand","DEDICATED_CARD_COMPONENTS","includes","brandsFromBinLookup","input","render"],"mappings":"4qBAmCA,MAAMA,UAA8BC,EACxBC,mBACAC,qBACAC,qBACAC,uBACAC,gBACAC,SACAC,cACAC,IACAC,aACAC,sBACAC,mBACAC,iBACAC,cACAC,YACAC,cACAC,qBACAC,uBACAC,sBACDC,MACAC,MACCC,mBAERC,WAAAA,CAAYF,GACRG,MAAMH,GAEN,MAAMI,EAAqB,CACvBC,OAAQ,UACRC,MAAON,EAAMO,KACbC,OAAQ,CAAC,EACTC,M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AAO8G,GAepC,OAbID,EAAIC,GADJC,EACiB,CACbC,SAAS,EACTC,aAAcC,EAAwBH,EAAWI,GAGjDC,UAAW3G,KAAKjB,MAAM2D,KAAKkE,IAAIN,GAC/BlB,MAAOkB,EACPrI,SAAU+B,KAAK/B,YACX+B,KAAKlB,MAAMuG,2BAA6B,CAAEC,eAAgBtF,KAAKlB,MAAMuG,4BAG5D,KAEde,CAAAA,GACR,CAAC,EAER,CAEOjG,wBAAAA,CAAyB0G,EAAsCC,GAIlE,GAAI9G,KAAKlB,MAAMuG,4BACXrF,KAAKiB,UAASwD,IAAc,CACxBlF,OAAQ,IAAKkF,EAAUlF,OAAQgG,CAACA,IAAwB,GACxDF,0BAA2B,SAK3BrF,KAAK7B,KAAO0I,GAAmB,CAC/B,MAAM3B,EAAuB,CACzB5F,KAAM,OACNsG,UAAW,sBACXR,MAAO,IAEXpF,KAAKM,sBAAsB4E,EAC/B,CAGJlF,KAAKhB,mBAAqB6H,GAAmB7H,oBAAoB+H,cAEjE,MAAMC,EAAqBF,GAAazH,MAMlC4H,EAA0BD,GAAsBE,EAA0BC,SAASL,EAAYzH,OAEjG4H,GAEAjH,KAAKiB,SAAS6F,GAAa,KACvB9G,KAAKjB,MAAM6F,SAAS5E,KAAKlB,MAAK,IAalCkB,KAAK7B,KAAK6B,KAAK7B,IAAIiJ,oBAAoBP,EAAmBI,EAA0BH,EAAc,KAC1G,CAEQlG,YAAeyG,IACnBrH,KAAK/B,SAAWoJ,CAAAA,EAGbC,MAAAA,CAAOvI,EAAOD,GACjB,OAAOC,EAAMuI,OAAO,CAAE1G,YAAaZ,KAAKY,YAAaR,WAAYJ,KAAKI,YAActB,EACxF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{httpPost as e}from"../../../../core/Services/http.js";import{DEFAULT_CARD_GROUP_TYPES as r}from"../lib/configuration/constants.js";import{
|
|
1
|
+
import{httpPost as e}from"../../../../core/Services/http.js";import{DEFAULT_CARD_GROUP_TYPES as r}from"../lib/configuration/constants.js";import{SF_ErrorCodes as n}from"../../../../core/Errors/constants.js";var o=o=>{let s=null;return t=>{if(!1!==o.props.doBinLookup){if(t.encryptedBin&&o.props.clientKey)s=t.uuid,e({loadingContext:o.props.loadingContext,path:`v3/bin/binLookup?token=${o.props.clientKey}`},{type:o.props.brand,supportedBrands:o.props.brands||r,encryptedBin:t.encryptedBin,requestId:t.uuid}).then((e=>{if(e?.requestId===s)if(e.brands?.length){const s=e.brands.reduce(((e,r)=>(e.detectedBrands.push(r.brand),e.paymentMethodVariants.push(r.paymentMethodVariant),!0===r.supported?(e.supportedBrands.push(r),e):e)),{supportedBrands:[],detectedBrands:[],paymentMethodVariants:[]});if(s.supportedBrands.length)return o.processBinLookupResponse({issuingCountryCode:e.issuingCountryCode,supportedBrands:s.supportedBrands,...e.showSocialSecurityNumber?{showSocialSecurityNumber:e.showSocialSecurityNumber}:{}}),void o.onBinLookup({type:t.type,detectedBrands:s.detectedBrands,supportedBrands:s.supportedBrands.map((e=>e.brand)),paymentMethodVariants:s.paymentMethodVariants,supportedBrandsRaw:s.supportedBrands,brands:o.props.brands||r,issuingCountryCode:e.issuingCountryCode});if(s.detectedBrands.length){const e={type:"card",fieldType:"encryptedCardNumber",error:n.ERROR_MSG_UNSUPPORTED_CARD_ENTERED,detectedBrands:s.detectedBrands};return o.handleUnsupportedCard(e),void o.onBinLookup({type:t.type,detectedBrands:s.detectedBrands,supportedBrands:null,paymentMethodVariants:s.paymentMethodVariants,brands:o.props.brands||r})}}else o.onBinLookup({type:t.type,detectedBrands:null,supportedBrands:null,paymentMethodVariants:null,brands:o.props.brands||r}),o.processBinLookupResponse({},!0);else e?.requestId||o.props.onError(e||{errorType:"binLookup",message:"unknownError"})}));else if(s){o.processBinLookupResponse(null,!0),s=null;const e={type:"card",fieldType:"encryptedCardNumber",error:""};o.handleUnsupportedCard(e),o.onBinLookup({isReset:!0})}o.props.onBinValue&&o.props.onBinValue(t)}else o.props.onBinValue&&o.props.onBinValue(t)}};export{o as default};
|
|
2
2
|
//# sourceMappingURL=triggerBinLookUp.js.map
|
|
@@ -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/configuration/constants';\nimport { getError } from '../../../../core/Errors/utils';\nimport { ERROR_MSG_UNSUPPORTED_CARD_ENTERED } 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 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: getError(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","issuingCountryCode","showSocialSecurityNumber","onBinLookup","map","supportedBrandsRaw","errObj","fieldType","error","getError","ERROR_MSG_UNSUPPORTED_CARD_ENTERED","handleUnsupportedCard","onError","errorType","message","isReset","onBinValue"],"mappings":"gSAWA,IAAeA,EAAAA,IACX,IAAIC,EAAmB,KAEvB,OAAQC,IAEJ,IAAiC,IAA7BF,EAAOG,MAAMC,YAAjB,CAMA,GAAIF,EAAYG,cAAgBL,EAAOG,MAAMG,UAEzCL,EAAmBC,EAAYK,KAE/BC,EACI,CACIC,eAAgBT,EAAOG,MAAMM,eAC7BC,KAAM,0BAA0BV,EAAOG,MAAMG,aAEjD,CACIK,KAAMX,EAAOG,MAAMS,MACnBC,gBAAiBb,EAAOG,MAAMW,QAAUC,EACxCV,aAAcH,EAAYG,aAC1BW,UAAWd,EAAYK,OAE7BU,MAAMC,IAEJ,GAAIA,GAAMF,YAAcf,EA4CpB,GAAIiB,EAAKJ,QAAQK,OAAQ,CACrB,MAAMC,EAAiBF,EAAKJ,OAAOO,QAC/B,CAACC,EAAKC,KAEFD,EAAIE,eAAeC,KAAKF,EAAKX,OAE7BU,EAAII,sBAAsBD,KAAKF,EAAKI,uBAGb,IAAnBJ,EAAKK,WACLN,EAAIT,gBAAgBY,KAAKF,GAClBD,GAGJA,IAEX,CAAET,gBAAiB,GAAIW,eAAgB,GAAIE,sBAAuB,KAMtE,GAAIN,EAAeP,gBAAgBM,OAoB/B,OAlBAnB,EAAO6B,yBAAyB,CAC5BC,mBAAoBZ,EAAKY,mBACzBjB,gBAAiBO,EAAeP,mBAC5BK,EAAKa,yBAA2B,CA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../../../../../../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/configuration/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 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","issuingCountryCode","showSocialSecurityNumber","onBinLookup","map","supportedBrandsRaw","errObj","fieldType","error","SF_ErrorCodes","ERROR_MSG_UNSUPPORTED_CARD_ENTERED","handleUnsupportedCard","onError","errorType","message","isReset","onBinValue"],"mappings":"+MAUA,IAAeA,EAAAA,IACX,IAAIC,EAAmB,KAEvB,OAAQC,IAEJ,IAAiC,IAA7BF,EAAOG,MAAMC,YAAjB,CAMA,GAAIF,EAAYG,cAAgBL,EAAOG,MAAMG,UAEzCL,EAAmBC,EAAYK,KAE/BC,EACI,CACIC,eAAgBT,EAAOG,MAAMM,eAC7BC,KAAM,0BAA0BV,EAAOG,MAAMG,aAEjD,CACIK,KAAMX,EAAOG,MAAMS,MACnBC,gBAAiBb,EAAOG,MAAMW,QAAUC,EACxCV,aAAcH,EAAYG,aAC1BW,UAAWd,EAAYK,OAE7BU,MAAMC,IAEJ,GAAIA,GAAMF,YAAcf,EA4CpB,GAAIiB,EAAKJ,QAAQK,OAAQ,CACrB,MAAMC,EAAiBF,EAAKJ,OAAOO,QAC/B,CAACC,EAAKC,KAEFD,EAAIE,eAAeC,KAAKF,EAAKX,OAE7BU,EAAII,sBAAsBD,KAAKF,EAAKI,uBAGb,IAAnBJ,EAAKK,WACLN,EAAIT,gBAAgBY,KAAKF,GAClBD,GAGJA,IAEX,CAAET,gBAAiB,GAAIW,eAAgB,GAAIE,sBAAuB,KAMtE,GAAIN,EAAeP,gBAAgBM,OAoB/B,OAlBAnB,EAAO6B,yBAAyB,CAC5BC,mBAAoBZ,EAAKY,mBACzBjB,gBAAiBO,EAAeP,mBAC5BK,EAAKa,yBAA2B,CAAEA,yBAA0Bb,EAAKa,0BAA6B,CAAE,SAIxG/B,EAAOgC,YAAY,CACfrB,KAAMT,EAAYS,KAClBa,eAAgBJ,EAAeI,eAE/BX,gBAAiBO,EAAeP,gBAAgBoB,KAAIV,GAAQA,EAAKX,QACjEc,sBAAuBN,EAAeM,sBACtCQ,mBAAoBd,EAAeP,gBACnCC,OAAQd,EAAOG,MAAMW,QAAUC,EAC/Be,mBAAoBZ,EAAKY,qBAUjC,GAAIV,EAAeI,eAAeL,OAAQ,CACtC,MAAMgB,EAAuB,CACzBxB,KAAM,OACNyB,UAAW,sBACXC,MAAOC,EAAcC,mCACrBf,eAAgBJ,EAAeI,gBAanC,OAXAxB,EAAOwC,sBAAsBL,QAG7BnC,EAAOgC,YAAY,CACfrB,KAAMT,EAAYS,KAClBa,eAAgBJ,EAAeI,eAC/BX,gBAAiB,KACjBa,sBAAuBN,EAAeM,sBACtCZ,OAAQd,EAAOG,MAAMW,QAAUC,GAIvC,OAKAf,EAAOgC,YAAY,CACfrB,KAAMT,EAAYS,KAClBa,eAAgB,KAChBX,gBAAiB,KACjBa,sBAAuB,KACvBZ,OAAQd,EAAOG,MAAMW,QAAUC,IAKnCf,EAAO6B,yBAAyB,IAAI,QAGnCX,GAAMF,WAEPhB,EAAOG,MAAMsC,QAAQvB,GAAQ,CAAEwB,UAAW,YAAaC,QAAS,gBAGxE,SAED,GAAI1C,EAAkB,CAKzBD,EAAO6B,yBAAyB,MAAM,GAEtC5B,EAAmB,KAGnB,MAAMkC,EAAuB,CACzBxB,KAAM,OACNyB,UAAW,sBACXC,MAAO,IAEXrC,EAAOwC,sBAAsBL,GAG7BnC,EAAOgC,YAAY,CACfY,SAAS,GAEjB,CAEI5C,EAAOG,MAAM0C,YAAY7C,EAAOG,MAAM0C,WAAW3C,EApLrD,MAFQF,EAAOG,MAAM0C,YAAY7C,EAAOG,MAAM0C,WAAW3C,EAsLJA,CAE7D"}
|
package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSecuredFields.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.ts"],"sourcesContent":["import { select, getAttribute } from '../../utilities/dom';\nimport {\n ENCRYPTED_EXPIRY_YEAR,\n DATE_POLICY_REQUIRED,\n CVC_POLICY_REQUIRED,\n DATA_ENCRYPTED_FIELD_ATTR,\n DATA_INFO,\n DATA_UID,\n SF_CONFIG_TIMEOUT,\n ALL_SECURED_FIELDS\n} from '../../configuration/constants';\nimport { existy } from '../../utilities/commonUtils';\nimport cardType from '../utils/cardType';\nimport { SecuredFieldSetupObject } from '../../securedField/AbstractSecuredField';\nimport SecuredField from '../../securedField/SecuredField';\nimport { CardObject, CbObjOnBrand, SFFeedbackObj, CbObjOnLoad, CVCPolicyType, DatePolicyType } from '../../types';\nimport AdyenCheckoutError from '../../../../../../core/Errors/AdyenCheckoutError';\n\n/**\n * Bound to the instance of CSF\n * Handles specific functionality related to configuring & creating SecuredFields\n */\nexport function createSecuredFields(): number {\n this.encryptedAttrName = DATA_ENCRYPTED_FIELD_ATTR;\n\n // Detect DOM elements that qualify as securedField holders & filter them for valid types\n const securedFields: HTMLElement[] = select(this.props.rootNode, `[${this.encryptedAttrName}]`).filter(field => {\n const fieldType: string = getAttribute(field, this.encryptedAttrName);\n const isValidType = ALL_SECURED_FIELDS.includes(fieldType);\n if (!isValidType) {\n console.warn(\n `WARNING: '${fieldType}' is not a valid type for the '${this.encryptedAttrName}' attribute. A SecuredField will not be created for this element.`\n );\n }\n return isValidType;\n });\n\n /**\n * cvcPolicy - 'required' | 'optional' | 'hidden'\n * - Always 'required' for GiftCards\n * - Usually 'required' for single branded Credit Cards but with exceptions e.g. maestro ('optional'), bcmc ('hidden').\n * - Always 'required' for generic Credit Cards at start up - in this case, subsequent, supporting information about whether cvc stops being required\n * comes from the SF in the brand information (as the shopper inputs the cc number)\n */\n const cvcPolicy: CVCPolicyType = CVC_POLICY_REQUIRED;\n\n /** Usually 'required' for single branded Credit Cards but with exceptions e.g. ticket ('hidden', *technically* a meal voucher) */\n const expiryDatePolicy: DatePolicyType = DATE_POLICY_REQUIRED;\n\n // CHECK IF THIS SECURED FIELD IS NOT OF A CREDIT CARD TYPE\n if (!this.config.isCreditCardType) {\n this.createNonCardSecuredFields(securedFields);\n return securedFields.length;\n }\n\n // CONTINUE AS CREDIT-CARD TYPE...\n this.isSingleBrandedCard = false;\n\n this.securityCode = '';\n\n this.createCardSecuredFields(securedFields, cvcPolicy, expiryDatePolicy);\n\n // Return the number of iframes we're going to create\n return securedFields.length;\n}\n\n/**\n * i.e. giftcard and ach fields\n *\n * Create a new SecuredField for each detected holding element\n */\nexport async function createNonCardSecuredFields(securedFields: HTMLElement[]): Promise<any> {\n for (let i = 0; i < securedFields.length; i++) {\n const securedField = securedFields[i];\n await this.setupSecuredField(securedField).catch(e => {\n if (window._b$dl) console.log('Secured fields setup failure. e=', e);\n });\n }\n}\n\nexport async function createCardSecuredFields(\n securedFields: HTMLElement[],\n cvcPolicy: CVCPolicyType,\n expiryDatePolicy: DatePolicyType\n): Promise<any> {\n // Declared card type from the initialisation of CSF\n let type: string = this.state.type;\n\n // Maybe it's a single branded card defined by setting type: 'card' & a single item in cardGroupTypes\n // In which case update the type var both locally AND in State\n if (type === 'card' && this.config.cardGroupTypes.length === 1) {\n type = this.config.cardGroupTypes[0];\n this.state.type = type;\n }\n\n // So, is it a single branded card?\n this.isSingleBrandedCard = type !== 'card';\n\n // If single branded card field...\n if (this.isSingleBrandedCard) {\n // Check that type exists\n const card: CardObject = cardType.getCardByBrand(type);\n\n // It's possible we don't recognise the card type -\n // scenario: frontend initially recognises card as e.g. Visa - but then backend tokenises it as a sub-brand which we currently don't recognise\n if (!existy(card)) {\n this.state.type = 'unrecognised-single-brand'; // Will let CVC field accept 4 digits in the input\n } else {\n // Assess whether cvc field is required based on the card type & whether the cvc field should even be visible\n cvcPolicy = (card.cvcPolicy as CVCPolicyType) || CVC_POLICY_REQUIRED;\n expiryDatePolicy = (card.expiryDatePolicy as DatePolicyType) || DATE_POLICY_REQUIRED;\n\n this.securityCode = card.securityCode;\n }\n }\n\n /**\n * Create a new SecuredField for each detected holding element\n *\n * - we do this in sequence, waiting until one has configured before creating the next.\n * We do it this way to avoid the 'bug' whereby if something interrupts the loading of an iframe the listener we have for its load event\n * never fires; which means the iframe never configures.\n * (NB - you can recreate this 'bug' by creating the securedFields in a synchronous loop:\n * securedFields.forEach(this.setupSecuredField.bind(this));\n * and putting a breakpoint on the line where we declare the setupSecuredField function)\n *\n * Also note we tried the Array.map/Promise.all way of asynchronously looping through an array - but it didn't fix the issue,\n * - so we fall back to a good old for-loop\n */\n for (let i = 0; i < securedFields.length; i++) {\n const securedField = securedFields[i];\n if (window._b$dl) console.log('\\nAbout to set up securedField:', securedField);\n await this.setupSecuredField(securedField, cvcPolicy, expiryDatePolicy).catch(e => {\n if (window._b$dl) console.log('Secured fields setup failure. e=', e);\n });\n if (window._b$dl) console.log('Finished setting up securedField:', securedField);\n }\n if (window._b$dl) console.log('Finished setting up all securedFields');\n\n /**\n * Now the securedFields have all been created and configured...\n *\n * For a single branded card we call to onBrand callback once.\n * This allows the UI to set the correct logo if they haven't already,\n * and we also pass the cvcPolicy & expiryDatePolicy so the UI can hide the iframe holders if necessary\n */\n if (this.isSingleBrandedCard) {\n const callbackObj: CbObjOnBrand = {\n type: this.state.type,\n rootNode: this.props.rootNode,\n brand: type,\n cvcPolicy,\n expiryDatePolicy,\n cvcText: this.securityCode\n };\n\n // Allow a tick for the securedField to finish rendering\n setTimeout(() => {\n this.callbacks.onBrand(callbackObj);\n }, 0);\n }\n}\n\n// Run for each detected holder of a securedField...\nexport function setupSecuredField(pItem: HTMLElement, cvcPolicy?: CVCPolicyType, expiryDatePolicy?: DatePolicyType): Promise<any> {\n return new Promise((resolve, reject) => {\n /**\n * possible values:\n * encryptedCardNumber\n * encryptedExpiryDate\n * encryptedExpiryMonth\n * encryptedExpiryYear\n * encryptedSecurityCode\n * encryptedPassword\n * encryptedPin???\n * encryptedBankAccountNumber\n * encryptedBankLocationId\n * encryptedIBAN\n */\n const fieldType: string = getAttribute(pItem, this.encryptedAttrName);\n\n if (fieldType === ENCRYPTED_EXPIRY_YEAR) {\n this.state.hasSeparateDateFields = true;\n }\n\n const extraFieldData: string = getAttribute(pItem, DATA_INFO);\n const uid = getAttribute(pItem, DATA_UID);\n\n // CREATE SecuredField passing config object\n const sfInitObj: SecuredFieldSetupObject = {\n fieldType,\n extraFieldData,\n uid,\n cvcPolicy,\n holderEl: pItem,\n expiryDatePolicy,\n txVariant: this.state.type,\n // from this.config (calculated)\n cardGroupTypes: this.config.cardGroupTypes,\n iframeUIConfig: this.config.iframeUIConfig,\n sfLogAtStart: this.config.sfLogAtStart,\n trimTrailingSeparator: this.config.trimTrailingSeparator,\n isCreditCardType: this.config.isCreditCardType,\n iframeSrc: this.config.iframeSrc,\n loadingContext: this.config.loadingContext,\n showWarnings: this.config.showWarnings,\n legacyInputMode: this.config.legacyInputMode,\n minimumExpiryDate: this.config.minimumExpiryDate,\n // from this.props (passed straight thru)\n maskSecurityCode: this.props.maskSecurityCode,\n disableIOSArrowKeys: this.props.shouldDisableIOSArrowKeys,\n implementationType: this.props.implementationType,\n showContextualElement: this.props.showContextualElement,\n placeholders: this.props.placeholders\n };\n\n const sf: SecuredField = new SecuredField(sfInitObj, this.props.i18n)\n .onIframeLoaded((): void => {\n // Count\n this.state.iframeCount += 1;\n\n if (window._b$dl) console.log('### createSecuredFields::onIframeLoaded:: this.state.iframeCount=', this.state.iframeCount);\n\n // One of our existing securedFields has just loaded new content!\n if (this.state.iframeCount > this.state.numIframes) {\n this.destroySecuredFields();\n throw new AdyenCheckoutError(\n 'ERROR',\n `One or more securedFields has just loaded new content. This should never happen. securedFields have been removed.\n iframe load count=${this.state.iframeCount}. Expected count:${this.state.numIframes}`\n );\n }\n\n /** Create timeout within which time we expect the securedField to configure */\n // @ts-ignore - timeout 'type' *is* a number\n sf.loadToConfigTimeout = setTimeout(() => {\n reject({ type: sfInitObj.fieldType, failReason: 'sf took too long to config' });\n }, SF_CONFIG_TIMEOUT);\n\n // If all iframes are loaded - call onLoad callback\n if (this.state.iframeCount === this.state.originalNumIframes) {\n const callbackObj: CbObjOnLoad = { iframesLoaded: true };\n this.callbacks.onLoad(callbackObj);\n }\n })\n .onConfig((pFeedbackObj: SFFeedbackObj): void => {\n this.handleIframeConfigFeedback(pFeedbackObj);\n\n // Clear timeout since the securedField has configured\n clearTimeout(sf.loadToConfigTimeout);\n sf.loadToConfigTimeout = null;\n\n resolve(pFeedbackObj);\n })\n .onFocus((pFeedbackObj: SFFeedbackObj): void => {\n this.handleFocus(pFeedbackObj);\n })\n .onBinValue((pFeedbackObj: SFFeedbackObj): void => {\n this.handleBinValue(pFeedbackObj);\n })\n .onTouchstart((pFeedbackObj: SFFeedbackObj): void => {\n // re. Disabling arrow keys in iOS - need to disable all other fields in the form\n if (this.props.shouldDisableIOSArrowKeys) {\n /**\n * re. this.hasGenuineTouchEvents...\n * There seems to be an issue with Responsive Design mode in Safari that means it allows setting focus on cross-origin iframes,\n * without enabling the touch events that allow the \"disableIOSArrowKeys\" workaround to fully function.\n * This results in a click on an securedFields *label* leading to, for example, the holderName field being disabled, but w/o access\n * to the touch events that would let it re-enable itself.\n *\n * So we prevent the \"disableIOSArrowKeys\" workaround unless we genuinely have touch events available.\n */\n if (this.hasGenuineTouchEvents || pFeedbackObj.hasGenuineTouchEvents) {\n this.callbacks.onTouchstartIOS({ fieldType: pFeedbackObj.fieldType });\n }\n }\n\n // Only perform this step if we genuinely have touch events available\n if (pFeedbackObj.hasGenuineTouchEvents || this.hasGenuineTouchEvents) {\n // iOS ONLY - RE. iOS BUGS AROUND BLUR AND FOCUS EVENTS\n // - pass information about which field has just been clicked (gained focus) to the other iframes\n this.postMessageToAllIframes({ fieldType: pFeedbackObj.fieldType, fieldClick: true });\n }\n })\n .onShiftTab((pFeedbackObj: SFFeedbackObj): void => {\n // Only happens for Firefox & IE <= 11\n this.handleSFShiftTab(pFeedbackObj.fieldType);\n })\n .onEncryption((pFeedbackObj: SFFeedbackObj): void => {\n this.handleEncryption(pFeedbackObj);\n })\n .onValidation((pFeedbackObj: SFFeedbackObj): void => {\n this.handleValidation(pFeedbackObj);\n })\n .onAutoComplete((pFeedbackObj: SFFeedbackObj): void => {\n this.processAutoComplete(pFeedbackObj);\n });\n\n // Store reference to securedField in this.state (under fieldType)\n this.state.securedFields[fieldType] = sf;\n });\n}\n"],"names":["createSecuredFields","this","encryptedAttrName","DATA_ENCRYPTED_FIELD_ATTR","securedFields","select","props","rootNode","filter","field","fieldType","getAttribute","isValidType","ALL_SECURED_FIELDS","includes","console","warn","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","config","isCreditCardType","isSingleBrandedCard","securityCode","createCardSecuredFields","length","createNonCardSecuredFields","async","i","securedField","setupSecuredField","catch","e","window","_b$dl","log","type","state","cardGroupTypes","card","cardType","getCardByBrand","existy","callbackObj","brand","cvcText","setTimeout","callbacks","onBrand","pItem","Promise","resolve","reject","ENCRYPTED_EXPIRY_YEAR","hasSeparateDateFields","sfInitObj","extraFieldData","DATA_INFO","uid","DATA_UID","holderEl","txVariant","iframeUIConfig","sfLogAtStart","trimTrailingSeparator","iframeSrc","loadingContext","showWarnings","legacyInputMode","minimumExpiryDate","maskSecurityCode","disableIOSArrowKeys","shouldDisableIOSArrowKeys","implementationType","showContextualElement","placeholders","sf","SecuredField","i18n","onIframeLoaded","iframeCount","numIframes","destroySecuredFields","AdyenCheckoutError","loadToConfigTimeout","failReason","SF_CONFIG_TIMEOUT","originalNumIframes","iframesLoaded","onLoad","onConfig","pFeedbackObj","handleIframeConfigFeedback","clearTimeout","onFocus","handleFocus","onBinValue","handleBinValue","onTouchstart","hasGenuineTouchEvents","onTouchstartIOS","postMessageToAllIframes","fieldClick","onShiftTab","handleSFShiftTab","onEncryption","handleEncryption","onValidation","handleValidation","onAutoComplete","processAutoComplete"],"mappings":"0fAsBO,SAASA,IACZC,KAAKC,kBAAoBC,EAGzB,MAAMC,EAA+BC,EAAOJ,KAAKK,MAAMC,SAAU,IAAIN,KAAKC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AAA,IAEzBkB,gBAAgBlB,IACb3F,KAAK8G,oBAAoBnB,EAAAA,IAIjC3F,KAAKqC,MAAMlC,cAAcM,GAAamE,CAAAA,GAE9C"}
|
|
1
|
+
{"version":3,"file":"createSecuredFields.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.ts"],"sourcesContent":["import { select, getAttribute } from '../../utilities/dom';\nimport {\n ENCRYPTED_EXPIRY_YEAR,\n DATE_POLICY_REQUIRED,\n CVC_POLICY_REQUIRED,\n DATA_ENCRYPTED_FIELD_ATTR,\n DATA_INFO,\n DATA_UID,\n SF_CONFIG_TIMEOUT,\n ALL_SECURED_FIELDS,\n ENCRYPTED_EXPIRY_MONTH\n} from '../../configuration/constants';\nimport { existy } from '../../utilities/commonUtils';\nimport cardType from '../utils/cardType';\nimport { SecuredFieldSetupObject } from '../../types';\nimport SecuredField from '../../securedField/SecuredField';\nimport { CardObject, CbObjOnBrand, SFFeedbackObj, CbObjOnLoad, CVCPolicyType, DatePolicyType } from '../../types';\nimport AdyenCheckoutError from '../../../../../../core/Errors/AdyenCheckoutError';\n\n/**\n * Bound to the instance of CSF\n * Handles specific functionality related to configuring & creating SecuredFields\n */\nexport function createSecuredFields(): number {\n this.encryptedAttrName = DATA_ENCRYPTED_FIELD_ATTR;\n\n // Detect DOM elements that qualify as securedField holders & filter them for valid types\n const securedFields: HTMLElement[] = select(this.props.rootNode, `[${this.encryptedAttrName}]`).filter(field => {\n const fieldType: string = getAttribute(field, this.encryptedAttrName);\n\n if (fieldType === ENCRYPTED_EXPIRY_MONTH) {\n // TODO send analytics about separate date fields\n }\n\n const isValidType = ALL_SECURED_FIELDS.includes(fieldType);\n if (!isValidType) {\n console.warn(\n `WARNING: '${fieldType}' is not a valid type for the '${this.encryptedAttrName}' attribute. A SecuredField will not be created for this element.`\n );\n }\n return isValidType;\n });\n\n /**\n * cvcPolicy - 'required' | 'optional' | 'hidden'\n * - Always 'required' for GiftCards\n * - Usually 'required' for single branded Credit Cards but with exceptions e.g. maestro ('optional'), bcmc ('hidden').\n * - Always 'required' for generic Credit Cards at start up - in this case, subsequent, supporting information about whether cvc stops being required\n * comes from the SF in the brand information (as the shopper inputs the cc number)\n */\n const cvcPolicy: CVCPolicyType = CVC_POLICY_REQUIRED;\n\n /** Usually 'required' for single branded Credit Cards but with exceptions e.g. ticket ('hidden', *technically* a meal voucher) */\n const expiryDatePolicy: DatePolicyType = DATE_POLICY_REQUIRED;\n\n // CHECK IF THIS SECURED FIELD IS NOT OF A CREDIT CARD TYPE\n if (!this.config.isCreditCardType) {\n this.createNonCardSecuredFields(securedFields);\n return securedFields.length;\n }\n\n // CONTINUE AS CREDIT-CARD TYPE...\n this.isSingleBrandedCard = false;\n\n this.securityCode = '';\n\n this.createCardSecuredFields(securedFields, cvcPolicy, expiryDatePolicy);\n\n // Return the number of iframes we're going to create\n return securedFields.length;\n}\n\n/**\n * i.e. giftcard and ach fields\n *\n * Create a new SecuredField for each detected holding element\n */\nexport async function createNonCardSecuredFields(securedFields: HTMLElement[]): Promise<any> {\n for (let i = 0; i < securedFields.length; i++) {\n const securedField = securedFields[i];\n await this.setupSecuredField(securedField).catch(e => {\n if (window._b$dl) console.log('Secured fields setup failure. e=', e);\n });\n }\n}\n\nexport async function createCardSecuredFields(\n securedFields: HTMLElement[],\n cvcPolicy: CVCPolicyType,\n expiryDatePolicy: DatePolicyType\n): Promise<any> {\n // Declared card type from the initialisation of CSF\n let type: string = this.state.type;\n\n // Maybe it's a single branded card defined by setting type: 'card' & a single item in cardGroupTypes\n // In which case update the type var both locally AND in State\n if (type === 'card' && this.config.cardGroupTypes.length === 1) {\n type = this.config.cardGroupTypes[0];\n this.state.type = type;\n }\n\n // So, is it a single branded card?\n this.isSingleBrandedCard = type !== 'card';\n\n // If single branded card field...\n if (this.isSingleBrandedCard) {\n // Check that type exists\n const card: CardObject = cardType.getCardByBrand(type);\n\n // It's possible we don't recognise the card type -\n // scenario: frontend initially recognises card as e.g. Visa - but then backend tokenises it as a sub-brand which we currently don't recognise\n if (!existy(card)) {\n this.state.type = 'unrecognised-single-brand'; // Will let CVC field accept 4 digits in the input\n } else {\n // Assess whether cvc field is required based on the card type & whether the cvc field should even be visible\n cvcPolicy = (card.cvcPolicy as CVCPolicyType) || CVC_POLICY_REQUIRED;\n expiryDatePolicy = (card.expiryDatePolicy as DatePolicyType) || DATE_POLICY_REQUIRED;\n\n this.securityCode = card.securityCode;\n }\n }\n\n /**\n * Create a new SecuredField for each detected holding element\n *\n * - we do this in sequence, waiting until one has configured before creating the next.\n * We do it this way to avoid the 'bug' whereby if something interrupts the loading of an iframe the listener we have for its load event\n * never fires; which means the iframe never configures.\n * (NB - you can recreate this 'bug' by creating the securedFields in a synchronous loop:\n * securedFields.forEach(this.setupSecuredField.bind(this));\n * and putting a breakpoint on the line where we declare the setupSecuredField function)\n *\n * Also note we tried the Array.map/Promise.all way of asynchronously looping through an array - but it didn't fix the issue,\n * - so we fall back to a good old for-loop\n */\n for (let i = 0; i < securedFields.length; i++) {\n const securedField = securedFields[i];\n if (window._b$dl) console.log('\\nAbout to set up securedField:', securedField);\n await this.setupSecuredField(securedField, cvcPolicy, expiryDatePolicy).catch(e => {\n if (window._b$dl) console.log('Secured fields setup failure. e=', e);\n });\n if (window._b$dl) console.log('Finished setting up securedField:', securedField);\n }\n if (window._b$dl) console.log('Finished setting up all securedFields');\n\n /**\n * Now the securedFields have all been created and configured...\n *\n * For a single branded card we call to onBrand callback once.\n * This allows the UI to set the correct logo if they haven't already,\n * and we also pass the cvcPolicy & expiryDatePolicy so the UI can hide the iframe holders if necessary\n */\n if (this.isSingleBrandedCard) {\n const callbackObj: CbObjOnBrand = {\n type: this.state.type,\n rootNode: this.props.rootNode,\n brand: type,\n cvcPolicy,\n expiryDatePolicy,\n cvcText: this.securityCode\n };\n\n // Allow a tick for the securedField to finish rendering\n setTimeout(() => {\n this.callbacks.onBrand(callbackObj);\n }, 0);\n }\n}\n\n// Run for each detected holder of a securedField...\nexport function setupSecuredField(pItem: HTMLElement, cvcPolicy?: CVCPolicyType, expiryDatePolicy?: DatePolicyType): Promise<any> {\n return new Promise((resolve, reject) => {\n /**\n * possible values:\n * encryptedCardNumber\n * encryptedExpiryDate\n * encryptedExpiryMonth\n * encryptedExpiryYear\n * encryptedSecurityCode\n * encryptedPassword\n * encryptedPin???\n * encryptedBankAccountNumber\n * encryptedBankLocationId\n * encryptedIBAN\n */\n const fieldType: string = getAttribute(pItem, this.encryptedAttrName);\n\n if (fieldType === ENCRYPTED_EXPIRY_YEAR) {\n this.state.hasSeparateDateFields = true;\n }\n\n const extraFieldData: string = getAttribute(pItem, DATA_INFO);\n const uid = getAttribute(pItem, DATA_UID);\n\n // CREATE SecuredField passing config object\n const sfInitObj: SecuredFieldSetupObject = {\n fieldType,\n extraFieldData,\n uid,\n cvcPolicy,\n holderEl: pItem,\n expiryDatePolicy,\n txVariant: this.state.type,\n // from this.config (calculated)\n cardGroupTypes: this.config.cardGroupTypes,\n iframeUIConfig: this.config.iframeUIConfig,\n sfLogAtStart: this.config.sfLogAtStart,\n trimTrailingSeparator: this.config.trimTrailingSeparator,\n isCreditCardType: this.config.isCreditCardType,\n iframeSrc: this.config.iframeSrc,\n loadingContext: this.config.loadingContext,\n showWarnings: this.config.showWarnings,\n legacyInputMode: this.config.legacyInputMode,\n minimumExpiryDate: this.config.minimumExpiryDate,\n // from this.props (passed straight thru)\n maskSecurityCode: this.props.maskSecurityCode,\n disableIOSArrowKeys: this.props.shouldDisableIOSArrowKeys,\n implementationType: this.props.implementationType,\n showContextualElement: this.props.showContextualElement,\n placeholders: this.props.placeholders\n };\n\n const sf: SecuredField = new SecuredField(sfInitObj, this.props.i18n)\n .onIframeLoaded((): void => {\n // Count\n this.state.iframeCount += 1;\n\n if (window._b$dl) console.log('### createSecuredFields::onIframeLoaded:: this.state.iframeCount=', this.state.iframeCount);\n\n // One of our existing securedFields has just loaded new content!\n if (this.state.iframeCount > this.state.numIframes) {\n this.destroySecuredFields();\n // TODO send analytics about this error\n throw new AdyenCheckoutError(\n 'ERROR',\n `One or more securedFields has just loaded new content. This should never happen. securedFields have been removed.\n iframe load count=${this.state.iframeCount}. Expected count:${this.state.numIframes}`\n );\n }\n\n /** Create timeout within which time we expect the securedField to configure */\n // @ts-ignore - timeout 'type' *is* a number\n sf.loadToConfigTimeout = setTimeout(() => {\n reject({ type: sfInitObj.fieldType, failReason: 'sf took too long to config' });\n }, SF_CONFIG_TIMEOUT);\n\n // If all iframes are loaded - call onLoad callback\n if (this.state.iframeCount === this.state.originalNumIframes) {\n const callbackObj: CbObjOnLoad = { iframesLoaded: true };\n this.callbacks.onLoad(callbackObj);\n }\n })\n .onConfig((pFeedbackObj: SFFeedbackObj): void => {\n this.handleIframeConfigFeedback(pFeedbackObj);\n\n // Clear timeout since the securedField has configured\n clearTimeout(sf.loadToConfigTimeout);\n sf.loadToConfigTimeout = null;\n\n resolve(pFeedbackObj);\n })\n .onFocus((pFeedbackObj: SFFeedbackObj): void => {\n this.handleFocus(pFeedbackObj);\n })\n .onBinValue((pFeedbackObj: SFFeedbackObj): void => {\n this.handleBinValue(pFeedbackObj);\n })\n .onTouchstart((pFeedbackObj: SFFeedbackObj): void => {\n // re. Disabling arrow keys in iOS - need to disable all other fields in the form\n if (this.props.shouldDisableIOSArrowKeys) {\n /**\n * re. this.hasGenuineTouchEvents...\n * There seems to be an issue with Responsive Design mode in Safari that means it allows setting focus on cross-origin iframes,\n * without enabling the touch events that allow the \"disableIOSArrowKeys\" workaround to fully function.\n * This results in a click on an securedFields *label* leading to, for example, the holderName field being disabled, but w/o access\n * to the touch events that would let it re-enable itself.\n *\n * So we prevent the \"disableIOSArrowKeys\" workaround unless we genuinely have touch events available.\n */\n if (this.hasGenuineTouchEvents || pFeedbackObj.hasGenuineTouchEvents) {\n this.callbacks.onTouchstartIOS({ fieldType: pFeedbackObj.fieldType });\n }\n }\n\n // Only perform this step if we genuinely have touch events available\n if (pFeedbackObj.hasGenuineTouchEvents || this.hasGenuineTouchEvents) {\n // iOS ONLY - RE. iOS BUGS AROUND BLUR AND FOCUS EVENTS\n // - pass information about which field has just been clicked (gained focus) to the other iframes\n this.postMessageToAllIframes({ fieldType: pFeedbackObj.fieldType, fieldClick: true });\n }\n })\n .onShiftTab((pFeedbackObj: SFFeedbackObj): void => {\n // Only happens for Firefox & IE <= 11\n this.handleSFShiftTab(pFeedbackObj.fieldType);\n })\n .onEncryption((pFeedbackObj: SFFeedbackObj): void => {\n this.handleEncryption(pFeedbackObj);\n })\n .onValidation((pFeedbackObj: SFFeedbackObj): void => {\n this.handleValidation(pFeedbackObj);\n })\n .onAutoComplete((pFeedbackObj: SFFeedbackObj): void => {\n this.processAutoComplete(pFeedbackObj);\n });\n\n // Store reference to securedField in this.state (under fieldType)\n this.state.securedFields[fieldType] = sf;\n });\n}\n"],"names":["createSecuredFields","this","encryptedAttrName","DATA_ENCRYPTED_FIELD_ATTR","securedFields","select","props","rootNode","filter","field","fieldType","getAttribute","isValidType","ALL_SECURED_FIELDS","includes","console","warn","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","config","isCreditCardType","isSingleBrandedCard","securityCode","createCardSecuredFields","length","createNonCardSecuredFields","async","i","securedField","setupSecuredField","catch","e","window","_b$dl","log","type","state","cardGroupTypes","card","cardType","getCardByBrand","existy","callbackObj","brand","cvcText","setTimeout","callbacks","onBrand","pItem","Promise","resolve","reject","ENCRYPTED_EXPIRY_YEAR","hasSeparateDateFields","sfInitObj","extraFieldData","DATA_INFO","uid","DATA_UID","holderEl","txVariant","iframeUIConfig","sfLogAtStart","trimTrailingSeparator","iframeSrc","loadingContext","showWarnings","legacyInputMode","minimumExpiryDate","maskSecurityCode","disableIOSArrowKeys","shouldDisableIOSArrowKeys","implementationType","showContextualElement","placeholders","sf","SecuredField","i18n","onIframeLoaded","iframeCount","numIframes","destroySecuredFields","AdyenCheckoutError","loadToConfigTimeout","failReason","SF_CONFIG_TIMEOUT","originalNumIframes","iframesLoaded","onLoad","onConfig","pFeedbackObj","handleIframeConfigFeedback","clearTimeout","onFocus","handleFocus","onBinValue","handleBinValue","onTouchstart","hasGenuineTouchEvents","onTouchstartIOS","postMessageToAllIframes","fieldClick","onShiftTab","handleSFShiftTab","onEncryption","handleEncryption","onValidation","handleValidation","onAutoComplete","processAutoComplete"],"mappings":"0fAuBO,SAASA,IACZC,KAAKC,kBAAoBC,EAGzB,MAAMC,EAA+BC,EAAOJ,KAAKK,MAAMC,SAAU,IAAIN,KAAKC,sBAAsBM,QAAOC,IACnG,MAAMC,EAAoBC,EAAaF,EAAOR,KAAKC,mBAM7CU,EAAcC,EAAmBC,SAASJ,GAMhD,OALKE,GACDG,QAAQC,KACJ,aAAaN,mCAA2CT,KAAKC,sFAG9DU,CAAAA,IAULK,EAA2BC,EAG3BC,EAAmCC,EAGzC,OAAKnB,KAAKoB,OAAOC,kBAMjBrB,KAAKsB,qBAAsB,EAE3BtB,KAAKuB,aAAe,GAEpBvB,KAAKwB,wBAAwBrB,EAAea,EAAWE,GAGhDf,EAAcsB,SAZjBzB,KAAK0B,2BAA2BvB,GACzBA,EAAcsB,OAY7B,CAOOE,eAAeD,EAA2BvB,GAC7C,IAAK,IAAIyB,EAAI,EAAGA,EAAIzB,EAAcsB,OAAQG,IAAK,CAC3C,MAAMC,EAAe1B,EAAcyB,SAC7B5B,KAAK8B,kBAAkBD,GAAcE,OAAMC,IACzCC,OAAOC,OAAOpB,QAAQqB,IAAI,mCAAoCH,EAAAA,GAE1E,CACJ,CAEOL,eAAeH,EAClBrB,EACAa,EACAE,GAGA,IAAIkB,EAAepC,KAAKqC,MAAMD,KAa9B,GATa,SAATA,GAAyD,IAAtCpC,KAAKoB,OAAOkB,eAAeb,SAC9CW,EAAOpC,KAAKoB,OAAOkB,eAAe,GAClCtC,KAAKqC,MAAMD,KAAOA,GAItBpC,KAAKsB,oBAA+B,SAATc,EAGvBpC,KAAKsB,oBAAqB,CAE1B,MAAMiB,EAAmBC,EAAS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AaQ,wBAC3CnG,KAAK+C,UAAUqD,gBAAgB,CAAE3F,UAAWkF,EAAalF,aAK7DkF,EAAaQ,uBAAyBnG,KAAKmG,wBAG3CnG,KAAKqG,wBAAwB,CAAE5F,UAAWkF,EAAalF,UAAW6F,YAAY,GAClF,IAEHC,YAAYZ,IAET3F,KAAKwG,iBAAiBb,EAAalF,UAAS,IAE/CgG,cAAcd,IACX3F,KAAK0G,iBAAiBf,EAAAA,IAEzBgB,cAAchB,IACX3F,KAAK4G,iBAAiBjB,EAAAA,IAEzBkB,gBAAgBlB,IACb3F,KAAK8G,oBAAoBnB,EAAAA,IAIjC3F,KAAKqC,MAAMlC,cAAcM,GAAamE,CAAAA,GAE9C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{hasOwnProperty as t}from"../../../../../../utils/hasOwnProperty.js";let e;const r={__NO_BRAND:"noBrand",cards:[]};r.cards.push({cardType:"mc",startingRules:[51,52,53,54,55,22,23,24,25,26,27],permittedLengths:[16],pattern:/^(5[1-5][0-9]{0,14}|2[2-7][0-9]{0,14})$/,securityCode:"CVC"}),r.cards.push({cardType:"visadankort",startingRules:[4571],permittedLengths:[16],pattern:/^(4571)[0-9]{0,12}$/}),r.cards.push({cardType:"visa",startingRules:[4],permittedLengths:[13,16,19],pattern:/^4[0-9]{0,18}$/,securityCode:"CVV"}),r.cards.push({cardType:"amex",startingRules:[34,37],permittedLengths:[15],pattern:/^3[47][0-9]{0,13}$/,securityCode:"CID"}),r.cards.push({cardType:"diners",startingRules:[36],permittedLengths:[14],pattern:/^(36)[0-9]{0,12}$/}),r.cards.push({cardType:"maestrouk",startingRules:[6759],permittedLengths:[16,18,19],pattern:/^(6759)[0-9]{0,15}$/}),r.cards.push({cardType:"solo",startingRules:[6767],permittedLengths:[16,18,19],pattern:/^(6767)[0-9]{0,15}$/}),r.cards.push({cardType:"laser",startingRules:[6304,6706,677117,677120],permittedLengths:[16,17,18,19],pattern:/^(6304|6706|6709|6771)[0-9]{0,15}$/,cvcPolicy:"optional"}),r.cards.push({cardType:"discover",startingRules:[6011,644,645,646,647,648,649,65],permittedLengths:[16],pattern:/^(6011[0-9]{0,12}|(644|645|646|647|648|649)[0-9]{0,13}|65[0-9]{0,14})$/}),r.cards.push({cardType:"jcb",startingRules:[3528,3529,353,354,355,356,357,358],permittedLengths:[16,19],pattern:/^(352[8,9]{1}[0-9]{0,15}|35[4-8]{1}[0-9]{0,16})$/,securityCode:"CAV"}),r.cards.push({cardType:"bcmc",startingRules:[6703,479658,606005],permittedLengths:[16,17,18,19],pattern:/^((6703)[0-9]{0,15}|(479658|606005)[0-9]{0,13})$/,cvcPolicy:"hidden"}),r.cards.push({cardType:"bijcard",startingRules:[5100081],permittedLengths:[16],pattern:/^(5100081)[0-9]{0,9}$/}),r.cards.push({cardType:"dankort",startingRules:[5019],permittedLengths:[16],pattern:/^(5019)[0-9]{0,12}$/}),r.cards.push({cardType:"hipercard",startingRules:[606282],permittedLengths:[16],pattern:/^(606282)[0-9]{0,10}$/}),r.cards.push({cardType:"cup",startingRules:[62,81],permittedLengths:[14,15,16,17,18,19],pattern:/^(62|81)[0-9]{0,17}$/}),r.cards.push({cardType:"maestro",startingRules:[50,56,57,58,6],permittedLengths:[16,17,18,19],pattern:/^(5[0|6-8][0-9]{0,17}|6[0-9]{0,18})$/,cvcPolicy:"optional"}),r.cards.push({cardType:"elo",startingRules:[506699,50670,50671,50672,50673,50674,50675,50676,506770,506771,506772,506773,506774,506775,506776,506777,506778,401178,438935,451416,457631,457632,504175,627780,636297,636368],permittedLengths:[16],pattern:/^((((506699)|(506770)|(506771)|(506772)|(506773)|(506774)|(506775)|(506776)|(506777)|(506778)|(401178)|(438935)|(451416)|(457631)|(457632)|(504175)|(627780)|(636368)|(636297))[0-9]{0,10})|((50676)|(50675)|(50674)|(50673)|(50672)|(50671)|(50670))[0-9]{0,11})$/}),r.cards.push({cardType:"uatp",startingRules:[1],permittedLengths:[15],pattern:/^1[0-9]{0,14}$/,cvcPolicy:"optional"}),r.cards.push({cardType:"cartebancaire",startingRules:[4,5,6],permittedLengths:[16],pattern:/^[4-6][0-9]{0,15}$/}),r.cards.push({cardType:"visaalphabankbonus",startingRules:[450903],permittedLengths:[16],pattern:/^(450903)[0-9]{0,10}$/}),r.cards.push({cardType:"mcalphabankbonus",startingRules:[510099],permittedLengths:[16],pattern:/^(510099)[0-9]{0,10}$/}),r.cards.push({cardType:"hiper",startingRules:[637095,637568,637599,637609,637612],permittedLengths:[16],pattern:/^(637095|637568|637599|637609|637612)[0-9]{0,10}$/}),r.cards.push({cardType:"oasis",startingRules:[982616],permittedLengths:[16],pattern:/^(982616)[0-9]{0,10}$/,cvcPolicy:"optional"}),r.cards.push({cardType:"karenmillen",startingRules:[98261465],permittedLengths:[16],pattern:/^(98261465)[0-9]{0,8}$/,cvcPolicy:"optional"}),r.cards.push({cardType:"warehouse",startingRules:[982633],permittedLengths:[16],pattern:/^(982633)[0-9]{0,10}$/,cvcPolicy:"optional"}),r.cards.push({cardType:"mir",startingRules:[220],permittedLengths:[16,17,18,19],pattern:/^(220)[0-9]{0,16}$/}),r.cards.push({cardType:"codensa",startingRules:[590712],permittedLengths:[16],pattern:/^(590712)[0-9]{0,10}$/}),r.cards.push({cardType:"naranja",startingRules:[377798,377799,402917,402918,527571,527572,589562],permittedLengths:[16,17,18,19],pattern:/^(37|40|5[28])([279])\d*$/}),r.cards.push({cardType:"cabal",startingRules:[589657,600691,603522,6042,6043,636908],permittedLengths:[16,17,18,19],pattern:/^(58|6[03])([03469])\d*$/}),r.cards.push({cardType:"shopping",startingRules:[2799,589407,603488],permittedLengths:[16,17,18,19],pattern:/^(27|58|60)([39])\d*$/}),r.cards.push({cardType:"argencard",startingRules:[501],permittedLengths:[16,17,18,19],pattern:/^(50)(1)\d*$/}),r.cards.push({cardType:"troy",startingRules:[9792],permittedLengths:[16],pattern:/^(97)(9)\d*$/}),r.cards.push({cardType:"forbrugsforeningen",startingRules:[600722],permittedLengths:[16],pattern:/^(60)(0)\d*$/}),r.cards.push({cardType:"vpay",startingRules:[401,408,413,434,435,437,439,441,442,443,444,446,447,455,458,460,461,463,466,471,479,482,483,487],permittedLengths:[13,14,15,16,17,18,19],pattern:/^(40[1,8]|413|43[4,5]|44[1,2,3,4,6,7]|45[5,8]|46[0,1,3,6]|47[1,9]|48[2,3,7])[0-9]{0,16}$/}),r.cards.push({cardType:"rupay",startingRules:[508528],permittedLengths:[16],pattern:/^(100003|508(2|[5-9])|60(69|[7-8])|652(1[5-9]|[2-5][0-9]|8[5-9])|65300[3-4]|8172([0-1]|[3-5]|7|9)|817(3[3-8]|40[6-9]|410)|35380([0-2]|[5-6]|9))[0-9]{0,12}$/}),r.cards.push({cardType:"ticket",expiryDatePolicy:"hidden"});var s={detectCard:(e,s)=>{let a,n,p;if(s){if(a=r.cards.filter((t=>s.includes(t.cardType))).filter((r=>t(r,"pattern")&&e.match(r.pattern))),a.length){if(1===a.length)return a[0];for(n=0,p=a.length;n<p;n+=1)if(!a[n].longestRule){const t=a[n].startingRules.reduce(((t,e)=>t>e?t:e));a[n].longestRule=String(t).length}return a.reduce(((t,e)=>t.longestRule>=e.longestRule?t:e))}return{cardType:r.__NO_BRAND}}return{cardType:r.__NO_BRAND}},detectCardLength:(t,e)=>{let s,a,n=0,p=!1,d=e;const c=t.cardType!==r.__NO_BRAND?t.permittedLengths[t.permittedLengths.length-1]:0;if(c&&d>c&&(n=d.length-c,n>0&&(d=d.substring(0,d.length-n),a=d)),t.permittedLengths.forEach((t=>{d.length===t&&(p=!0)})),d.length===c){const e=Math.floor(d.length/4);s=c+(d.length%4>0?e:e-1),"amex"===t.cardType.toLowerCase()&&(s=c+2)}return{shortenedNewValue:a,maxLength:s,reachedValidLength:p}},getShortestPermittedCardLength:()=>{if(!e){let t=[];r.cards.forEach((e=>{t=t.concat(e.permittedLengths??[])})),e=Math.min.apply(null,t)}return e},getCardByBrand:t=>r.cards.filter((e=>e.cardType===t))[0],isGenericCardType:t=>{if(!t)throw new Error("Error: isGenericCardType: type param has not been specified");return"card"===t||"scheme"===t},__NO_BRAND:r.__NO_BRAND,allCards:r.cards};export{s as default};
|
|
1
|
+
import{hasOwnProperty as t}from"../../../../../../utils/hasOwnProperty.js";let e;const r={__NO_BRAND:"noBrand",cards:[]};r.cards.push({cardType:"mc",startingRules:[51,52,53,54,55,22,23,24,25,26,27],permittedLengths:[16],pattern:/^(5[1-5][0-9]{0,14}|2[2-7][0-9]{0,14})$/,securityCode:"CVC"}),r.cards.push({cardType:"visadankort",startingRules:[4571],permittedLengths:[16],pattern:/^(4571)[0-9]{0,12}$/}),r.cards.push({cardType:"visa",startingRules:[4],permittedLengths:[13,16,19],pattern:/^4[0-9]{0,18}$/,securityCode:"CVV"}),r.cards.push({cardType:"amex",startingRules:[34,37],permittedLengths:[15],pattern:/^3[47][0-9]{0,13}$/,securityCode:"CID"}),r.cards.push({cardType:"diners",startingRules:[36],permittedLengths:[14,16],pattern:/^(36)[0-9]{0,12}$/}),r.cards.push({cardType:"maestrouk",startingRules:[6759],permittedLengths:[16,18,19],pattern:/^(6759)[0-9]{0,15}$/}),r.cards.push({cardType:"solo",startingRules:[6767],permittedLengths:[16,18,19],pattern:/^(6767)[0-9]{0,15}$/}),r.cards.push({cardType:"laser",startingRules:[6304,6706,677117,677120],permittedLengths:[16,17,18,19],pattern:/^(6304|6706|6709|6771)[0-9]{0,15}$/,cvcPolicy:"optional"}),r.cards.push({cardType:"discover",startingRules:[6011,644,645,646,647,648,649,65],permittedLengths:[16,17,18,19],pattern:/^(6011[0-9]{0,12}|(644|645|646|647|648|649)[0-9]{0,13}|65[0-9]{0,14})$/}),r.cards.push({cardType:"jcb",startingRules:[3528,3529,353,354,355,356,357,358],permittedLengths:[16,19],pattern:/^(352[8,9]{1}[0-9]{0,15}|35[4-8]{1}[0-9]{0,16})$/,securityCode:"CAV"}),r.cards.push({cardType:"bcmc",startingRules:[6703,479658,606005],permittedLengths:[16,17,18,19],pattern:/^((6703)[0-9]{0,15}|(479658|606005)[0-9]{0,13})$/,cvcPolicy:"hidden"}),r.cards.push({cardType:"bijcard",startingRules:[5100081],permittedLengths:[16],pattern:/^(5100081)[0-9]{0,9}$/}),r.cards.push({cardType:"dankort",startingRules:[5019],permittedLengths:[16],pattern:/^(5019)[0-9]{0,12}$/}),r.cards.push({cardType:"hipercard",startingRules:[606282],permittedLengths:[16],pattern:/^(606282)[0-9]{0,10}$/}),r.cards.push({cardType:"cup",startingRules:[62,81],permittedLengths:[14,15,16,17,18,19],pattern:/^(62|81)[0-9]{0,17}$/}),r.cards.push({cardType:"maestro",startingRules:[50,56,57,58,6],permittedLengths:[16,17,18,19],pattern:/^(5[0|6-8][0-9]{0,17}|6[0-9]{0,18})$/,cvcPolicy:"optional"}),r.cards.push({cardType:"elo",startingRules:[506699,50670,50671,50672,50673,50674,50675,50676,506770,506771,506772,506773,506774,506775,506776,506777,506778,401178,438935,451416,457631,457632,504175,627780,636297,636368],permittedLengths:[16],pattern:/^((((506699)|(506770)|(506771)|(506772)|(506773)|(506774)|(506775)|(506776)|(506777)|(506778)|(401178)|(438935)|(451416)|(457631)|(457632)|(504175)|(627780)|(636368)|(636297))[0-9]{0,10})|((50676)|(50675)|(50674)|(50673)|(50672)|(50671)|(50670))[0-9]{0,11})$/}),r.cards.push({cardType:"uatp",startingRules:[1],permittedLengths:[15],pattern:/^1[0-9]{0,14}$/,cvcPolicy:"optional"}),r.cards.push({cardType:"cartebancaire",startingRules:[4,5,6],permittedLengths:[16],pattern:/^[4-6][0-9]{0,15}$/}),r.cards.push({cardType:"visaalphabankbonus",startingRules:[450903],permittedLengths:[16],pattern:/^(450903)[0-9]{0,10}$/}),r.cards.push({cardType:"mcalphabankbonus",startingRules:[510099],permittedLengths:[16],pattern:/^(510099)[0-9]{0,10}$/}),r.cards.push({cardType:"hiper",startingRules:[637095,637568,637599,637609,637612],permittedLengths:[16],pattern:/^(637095|637568|637599|637609|637612)[0-9]{0,10}$/}),r.cards.push({cardType:"oasis",startingRules:[982616],permittedLengths:[16],pattern:/^(982616)[0-9]{0,10}$/,cvcPolicy:"optional"}),r.cards.push({cardType:"karenmillen",startingRules:[98261465],permittedLengths:[16],pattern:/^(98261465)[0-9]{0,8}$/,cvcPolicy:"optional"}),r.cards.push({cardType:"warehouse",startingRules:[982633],permittedLengths:[16],pattern:/^(982633)[0-9]{0,10}$/,cvcPolicy:"optional"}),r.cards.push({cardType:"mir",startingRules:[220],permittedLengths:[16,17,18,19],pattern:/^(220)[0-9]{0,16}$/}),r.cards.push({cardType:"codensa",startingRules:[590712],permittedLengths:[16],pattern:/^(590712)[0-9]{0,10}$/}),r.cards.push({cardType:"naranja",startingRules:[377798,377799,402917,402918,527571,527572,589562],permittedLengths:[16,17,18,19],pattern:/^(37|40|5[28])([279])\d*$/}),r.cards.push({cardType:"cabal",startingRules:[589657,600691,603522,6042,6043,636908],permittedLengths:[16,17,18,19],pattern:/^(58|6[03])([03469])\d*$/}),r.cards.push({cardType:"shopping",startingRules:[2799,589407,603488],permittedLengths:[16,17,18,19],pattern:/^(27|58|60)([39])\d*$/}),r.cards.push({cardType:"argencard",startingRules:[501],permittedLengths:[16,17,18,19],pattern:/^(50)(1)\d*$/}),r.cards.push({cardType:"troy",startingRules:[9792],permittedLengths:[16],pattern:/^(97)(9)\d*$/}),r.cards.push({cardType:"forbrugsforeningen",startingRules:[600722],permittedLengths:[16],pattern:/^(60)(0)\d*$/}),r.cards.push({cardType:"vpay",startingRules:[401,408,413,434,435,437,439,441,442,443,444,446,447,455,458,460,461,463,466,471,479,482,483,487],permittedLengths:[13,14,15,16,17,18,19],pattern:/^(40[1,8]|413|43[4,5]|44[1,2,3,4,6,7]|45[5,8]|46[0,1,3,6]|47[1,9]|48[2,3,7])[0-9]{0,16}$/}),r.cards.push({cardType:"rupay",startingRules:[508528],permittedLengths:[16],pattern:/^(100003|508(2|[5-9])|60(69|[7-8])|652(1[5-9]|[2-5][0-9]|8[5-9])|65300[3-4]|8172([0-1]|[3-5]|7|9)|817(3[3-8]|40[6-9]|410)|35380([0-2]|[5-6]|9))[0-9]{0,12}$/}),r.cards.push({cardType:"ticket",expiryDatePolicy:"hidden"});var s={detectCard:(e,s)=>{let a,n,p;if(s){if(a=r.cards.filter((t=>s.includes(t.cardType))).filter((r=>t(r,"pattern")&&e.match(r.pattern))),a.length){if(1===a.length)return a[0];for(n=0,p=a.length;n<p;n+=1)if(!a[n].longestRule){const t=a[n].startingRules.reduce(((t,e)=>t>e?t:e));a[n].longestRule=String(t).length}return a.reduce(((t,e)=>t.longestRule>=e.longestRule?t:e))}return{cardType:r.__NO_BRAND}}return{cardType:r.__NO_BRAND}},detectCardLength:(t,e)=>{let s,a,n=0,p=!1,d=e;const c=t.cardType!==r.__NO_BRAND?t.permittedLengths[t.permittedLengths.length-1]:0;if(c&&d>c&&(n=d.length-c,n>0&&(d=d.substring(0,d.length-n),a=d)),t.permittedLengths.forEach((t=>{d.length===t&&(p=!0)})),d.length===c){const e=Math.floor(d.length/4);s=c+(d.length%4>0?e:e-1),"amex"===t.cardType.toLowerCase()&&(s=c+2)}return{shortenedNewValue:a,maxLength:s,reachedValidLength:p}},getShortestPermittedCardLength:()=>{if(!e){let t=[];r.cards.forEach((e=>{t=t.concat(e.permittedLengths??[])})),e=Math.min.apply(null,t)}return e},getCardByBrand:t=>r.cards.filter((e=>e.cardType===t))[0],isGenericCardType:t=>{if(!t)throw new Error("Error: isGenericCardType: type param has not been specified");return"card"===t||"scheme"===t},__NO_BRAND:r.__NO_BRAND,allCards:r.cards};export{s as default};
|
|
2
2
|
//# sourceMappingURL=cardType.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cardType.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/utils/cardType.ts"],"sourcesContent":["import { CardObject } from '../../types';\nimport { hasOwnProperty } from '../../../../../../utils/hasOwnProperty';\n\nlet shortestPermittedCardLength;\n\ninterface CardType {\n __NO_BRAND?: string;\n cards?: CardObject[];\n}\n\nconst CardType: CardType = {};\nCardType.__NO_BRAND = 'noBrand';\n\nCardType.cards = [];\n\nCardType.cards.push({\n cardType: 'mc',\n startingRules: [51, 52, 53, 54, 55, 22, 23, 24, 25, 26, 27],\n permittedLengths: [16],\n pattern: /^(5[1-5][0-9]{0,14}|2[2-7][0-9]{0,14})$/,\n securityCode: 'CVC'\n});\n\nCardType.cards.push({ cardType: 'visadankort', startingRules: [4571], permittedLengths: [16], pattern: /^(4571)[0-9]{0,12}$/ });\n\nCardType.cards.push({\n cardType: 'visa',\n startingRules: [4],\n permittedLengths: [13, 16, 19],\n pattern: /^4[0-9]{0,18}$/,\n securityCode: 'CVV'\n});\n\nCardType.cards.push({ cardType: 'amex', startingRules: [34, 37], permittedLengths: [15], pattern: /^3[47][0-9]{0,13}$/, securityCode: 'CID' });\n\nCardType.cards.push({ cardType: 'diners', startingRules: [36], permittedLengths: [14], pattern: /^(36)[0-9]{0,12}$/ });\n\nCardType.cards.push({ cardType: 'maestrouk', startingRules: [6759], permittedLengths: [16, 18, 19], pattern: /^(6759)[0-9]{0,15}$/ });\n\nCardType.cards.push({ cardType: 'solo', startingRules: [6767], permittedLengths: [16, 18, 19], pattern: /^(6767)[0-9]{0,15}$/ });\n\nCardType.cards.push({\n cardType: 'laser',\n startingRules: [6304, 6706, 677117, 677120],\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(6304|6706|6709|6771)[0-9]{0,15}$/,\n cvcPolicy: 'optional'\n});\n\nCardType.cards.push({\n cardType: 'discover',\n startingRules: [6011, 644, 645, 646, 647, 648, 649, 65],\n permittedLengths: [16],\n pattern: /^(6011[0-9]{0,12}|(644|645|646|647|648|649)[0-9]{0,13}|65[0-9]{0,14})$/\n});\n\nCardType.cards.push({\n cardType: 'jcb',\n startingRules: [3528, 3529, 353, 354, 355, 356, 357, 358],\n permittedLengths: [16, 19],\n pattern: /^(352[8,9]{1}[0-9]{0,15}|35[4-8]{1}[0-9]{0,16})$/,\n securityCode: 'CAV'\n});\n\nCardType.cards.push({\n cardType: 'bcmc',\n startingRules: [6703, 479658, 606005],\n permittedLengths: [16, 17, 18, 19],\n pattern: /^((6703)[0-9]{0,15}|(479658|606005)[0-9]{0,13})$/,\n cvcPolicy: 'hidden'\n});\n\nCardType.cards.push({ cardType: 'bijcard', startingRules: [5100081], permittedLengths: [16], pattern: /^(5100081)[0-9]{0,9}$/ });\n\nCardType.cards.push({ cardType: 'dankort', startingRules: [5019], permittedLengths: [16], pattern: /^(5019)[0-9]{0,12}$/ });\n\nCardType.cards.push({ cardType: 'hipercard', startingRules: [606282], permittedLengths: [16], pattern: /^(606282)[0-9]{0,10}$/ });\n\n// Moved above maestro (from position below uatp) to stop maestro being recognised over cup\nCardType.cards.push({ cardType: 'cup', startingRules: [62, 81], permittedLengths: [14, 15, 16, 17, 18, 19], pattern: /^(62|81)[0-9]{0,17}$/ }); // orig & android v1 + modified to include our test cards (81...)\n\nCardType.cards.push({\n cardType: 'maestro',\n startingRules: [50, 56, 57, 58, 6],\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(5[0|6-8][0-9]{0,17}|6[0-9]{0,18})$/,\n cvcPolicy: 'optional'\n});\n\nCardType.cards.push({\n cardType: 'elo',\n // prettier-ignore\n startingRules: [506699, 50670, 50671, 50672, 50673, 50674, 50675, 50676, 506770, 506771, 506772, 506773, 506774, 506775, 506776, 506777, 506778, 401178, 438935, 451416, 457631, 457632, 504175, 627780, 636297, 636368], // eslint-disable-line max-len\n permittedLengths: [16],\n // prettier-ignore\n pattern:\n /^((((506699)|(506770)|(506771)|(506772)|(506773)|(506774)|(506775)|(506776)|(506777)|(506778)|(401178)|(438935)|(451416)|(457631)|(457632)|(504175)|(627780)|(636368)|(636297))[0-9]{0,10})|((50676)|(50675)|(50674)|(50673)|(50672)|(50671)|(50670))[0-9]{0,11})$/ // eslint-disable-line max-len\n});\n\nCardType.cards.push({ cardType: 'uatp', startingRules: [1], permittedLengths: [15], pattern: /^1[0-9]{0,14}$/, cvcPolicy: 'optional' });\n\nCardType.cards.push({\n cardType: 'cartebancaire',\n startingRules: [4, 5, 6],\n permittedLengths: [16],\n pattern: /^[4-6][0-9]{0,15}$/\n});\n\nCardType.cards.push({ cardType: 'visaalphabankbonus', startingRules: [450903], permittedLengths: [16], pattern: /^(450903)[0-9]{0,10}$/ });\n\nCardType.cards.push({ cardType: 'mcalphabankbonus', startingRules: [510099], permittedLengths: [16], pattern: /^(510099)[0-9]{0,10}$/ });\n\nCardType.cards.push({\n cardType: 'hiper',\n startingRules: [637095, 637568, 637599, 637609, 637612],\n permittedLengths: [16],\n pattern: /^(637095|637568|637599|637609|637612)[0-9]{0,10}$/\n});\n\nCardType.cards.push({ cardType: 'oasis', startingRules: [982616], permittedLengths: [16], pattern: /^(982616)[0-9]{0,10}$/, cvcPolicy: 'optional' });\n\nCardType.cards.push({\n cardType: 'karenmillen',\n startingRules: [98261465],\n permittedLengths: [16],\n pattern: /^(98261465)[0-9]{0,8}$/,\n cvcPolicy: 'optional'\n});\n\nCardType.cards.push({\n cardType: 'warehouse',\n startingRules: [982633],\n permittedLengths: [16],\n pattern: /^(982633)[0-9]{0,10}$/,\n cvcPolicy: 'optional'\n});\n\nCardType.cards.push({ cardType: 'mir', startingRules: [220], permittedLengths: [16, 17, 18, 19], pattern: /^(220)[0-9]{0,16}$/ });\n\nCardType.cards.push({ cardType: 'codensa', startingRules: [590712], permittedLengths: [16], pattern: /^(590712)[0-9]{0,10}$/ });\n\nCardType.cards.push({\n cardType: 'naranja',\n startingRules: [377798, 377799, 402917, 402918, 527571, 527572, 589562],\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(37|40|5[28])([279])\\d*$/\n});\n\n// TODO: 589657 clashes with naranja, rest ok\nCardType.cards.push({\n cardType: 'cabal',\n startingRules: [589657, 600691, 603522, 6042, 6043, 636908],\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(58|6[03])([03469])\\d*$/\n});\n\nCardType.cards.push({\n cardType: 'shopping',\n startingRules: [2799, 589407, 603488],\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(27|58|60)([39])\\d*$/\n});\n\nCardType.cards.push({ cardType: 'argencard', startingRules: [501], permittedLengths: [16, 17, 18, 19], pattern: /^(50)(1)\\d*$/ }); // NOTE: starting rule changed, from 501105, to not clash with dankort. Plus it now matches its regEx!\n\nCardType.cards.push({ cardType: 'troy', startingRules: [9792], permittedLengths: [16], pattern: /^(97)(9)\\d*$/ });\n\n// TODO: clashes with cabal\nCardType.cards.push({ cardType: 'forbrugsforeningen', startingRules: [600722], permittedLengths: [16], pattern: /^(60)(0)\\d*$/ });\n\nCardType.cards.push({\n cardType: 'vpay',\n startingRules: [401, 408, 413, 434, 435, 437, 439, 441, 442, 443, 444, 446, 447, 455, 458, 460, 461, 463, 466, 471, 479, 482, 483, 487],\n permittedLengths: [13, 14, 15, 16, 17, 18, 19],\n pattern: /^(40[1,8]|413|43[4,5]|44[1,2,3,4,6,7]|45[5,8]|46[0,1,3,6]|47[1,9]|48[2,3,7])[0-9]{0,16}$/ // ^(4[0-1|3-8][0-9]{1,17})$\n});\n\nCardType.cards.push({\n cardType: 'rupay',\n startingRules: [508528],\n permittedLengths: [16],\n // prettier-ignore\n pattern:\n /^(100003|508(2|[5-9])|60(69|[7-8])|652(1[5-9]|[2-5][0-9]|8[5-9])|65300[3-4]|8172([0-1]|[3-5]|7|9)|817(3[3-8]|40[6-9]|410)|35380([0-2]|[5-6]|9))[0-9]{0,12}$/ // eslint-disable-line max-len\n});\n\nCardType.cards.push({\n cardType: 'ticket',\n expiryDatePolicy: 'hidden'\n});\n\nconst detectCard = (pCardNumber, pAvailableCards?) => {\n let matchedCards;\n let i;\n let len;\n\n if (pAvailableCards) {\n // Filter CardType.cards down to those that are found in pAvailableCards\n matchedCards = CardType.cards\n .filter(card => pAvailableCards.includes(card.cardType))\n // Further filter them to those with a regEx pattern that matches pCardNumber\n .filter(card => hasOwnProperty(card, 'pattern') && pCardNumber.match(card.pattern));\n\n // If we have matched cards: if there's only one - return it; else return the one with the longest startingRule\n if (matchedCards.length) {\n if (matchedCards.length === 1) {\n return matchedCards[0];\n }\n\n // Find longest rule for each matched card & store it as a property on the card\n for (i = 0, len = matchedCards.length; i < len; i += 1) {\n if (!matchedCards[i].longestRule) {\n const longestRule = matchedCards[i].startingRules.reduce((a, b) => (a > b ? a : b));\n // What we actually store is how many chars are in the rule\n matchedCards[i].longestRule = String(longestRule).length;\n }\n }\n\n // Based on each matched cards longest rule - find the card with the longest one!\n return matchedCards.reduce((a, b) => (a.longestRule >= b.longestRule ? a : b));\n }\n\n return { cardType: CardType.__NO_BRAND };\n }\n\n return { cardType: CardType.__NO_BRAND };\n};\n\nconst detectCardLength = (pCard, pUnformattedVal) => {\n let maxLength;\n let shortenedNewValue;\n let lengthDiff = 0;\n let reachedValidLength = false;\n let unformattedVal = pUnformattedVal;\n\n // Find the longest of the permitted card number lengths for this card brand\n const maxPermittedLength = pCard.cardType !== CardType.__NO_BRAND ? pCard.permittedLengths[pCard.permittedLengths.length - 1] : 0;\n\n // If the input value is longer than it's max permitted length then shorten it to that length\n if (maxPermittedLength && unformattedVal > maxPermittedLength) {\n lengthDiff = unformattedVal.length - maxPermittedLength;\n\n if (lengthDiff > 0) {\n unformattedVal = unformattedVal.substring(0, unformattedVal.length - lengthDiff);\n shortenedNewValue = unformattedVal;\n }\n }\n\n // If cardNumber has reached one of the cardBrand's 'permitted lengths' - mark it as 'valid'\n pCard.permittedLengths.forEach(pItem => {\n if (unformattedVal.length === pItem) {\n reachedValidLength = true;\n }\n });\n\n // If cardNumber is as long as the cardBrand's maximum permitted length then set the maxLength var\n if (unformattedVal.length === maxPermittedLength) {\n // Set maxlength to max + the right amount of spaces (one for every 4 digits, but not on the last block)\n const div = Math.floor(unformattedVal.length / 4);\n const mod = unformattedVal.length % 4;\n const numSpaces = mod > 0 ? div : div - 1;\n\n maxLength = maxPermittedLength + numSpaces;\n\n if (pCard.cardType.toLowerCase() === 'amex') {\n maxLength = maxPermittedLength + 2; // = 17 = 15 digits with space after 4th & 10th\n }\n }\n\n return {\n shortenedNewValue,\n maxLength,\n reachedValidLength\n };\n};\n\nconst getShortestPermittedCardLength = () => {\n if (!shortestPermittedCardLength) {\n let permittedLengthsArray = [];\n\n CardType.cards.forEach(pItem => {\n permittedLengthsArray = permittedLengthsArray.concat(pItem.permittedLengths ?? []);\n });\n\n shortestPermittedCardLength = Math.min.apply(null, permittedLengthsArray);\n }\n\n return shortestPermittedCardLength;\n};\n\nconst getCardByBrand = pBrand => {\n const cardType = CardType.cards.filter(card => card.cardType === pBrand);\n\n return cardType[0];\n};\n\nconst isGenericCardType = type => {\n if (!type) throw new Error('Error: isGenericCardType: type param has not been specified');\n return type === 'card' || type === 'scheme';\n};\n\nexport default {\n detectCard,\n detectCardLength,\n getShortestPermittedCardLength,\n getCardByBrand,\n isGenericCardType,\n __NO_BRAND: CardType.__NO_BRAND,\n allCards: CardType.cards\n};\n"],"names":["shortestPermittedCardLength","CardType","cards","push","cardType","startingRules","permittedLengths","pattern","securityCode","cvcPolicy","expiryDatePolicy","detectCard","pCardNumber","pAvailableCards","matchedCards","i","len","filter","card","includes","hasOwnProperty","match","length","longestRule","reduce","a","b","String","__NO_BRAND","detectCardLength","pCard","pUnformattedVal","maxLength","shortenedNewValue","lengthDiff","reachedValidLength","unformattedVal","maxPermittedLength","substring","forEach","pItem","div","Math","floor","toLowerCase","getShortestPermittedCardLength","permittedLengthsArray","concat","min","apply","getCardByBrand","pBrand","isGenericCardType","type","Error","allCards"],"mappings":"2EAGA,IAAIA,EAOJ,MAAMC,EAAqB,CAC3BA,WAAsB,UAEtBA,MAAiB,IAEjBA,EAASC,MAAMC,KAAK,CAChBC,SAAU,KACVC,cAAe,CAAC,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,IACxDC,iBAAkB,CAAC,IACnBC,QAAS,0CACTC,aAAc,QAGlBP,EAASC,MAAMC,KAAK,CAAEC,SAAU,cAAeC,cAAe,CAAC,MAAOC,iBAAkB,CAAC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A8EvCC,iBA3EqB,CAACC,EAAOC,KAC7B,IAAIC,EACAC,EACAC,EAAa,EACbC,GAAqB,EACrBC,EAAiBL,EAGrB,MAAMM,EAAqBP,EAAM1B,WAAaH,EAAS2B,WAAaE,EAAMxB,iBAAiBwB,EAAMxB,iBAAiBgB,OAAS,GAAK,EAoBhI,GAjBIe,GAAsBD,EAAiBC,IACvCH,EAAaE,EAAed,OAASe,EAEjCH,EAAa,IACbE,EAAiBA,EAAeE,UAAU,EAAGF,EAAed,OAASY,GACrED,EAAoBG,IAK5BN,EAAMxB,iBAAiBiC,SAAQC,IACvBJ,EAAed,SAAWkB,IAC1BL,GAAqB,EACzB,IAIAC,EAAed,SAAWe,EAAoB,CAE9C,MAAMI,EAAMC,KAAKC,MAAMP,EAAed,OAAS,GAI/CU,EAAYK,GAHAD,EAAed,OAAS,EACZ,EAAImB,EAAMA,EAAM,GAIH,SAAjCX,EAAM1B,SAASwC,gBACfZ,EAAYK,EAAqB,EAEzC,CAEA,MAAO,CACHJ,oBACAD,YACAG,qBACJ,EA+BAU,+BA5BmC,KACnC,IAAK7C,EAA6B,CAC9B,IAAI8C,EAAwB,GAE5B7C,EAASC,MAAMqC,SAAQC,IACnBM,EAAwBA,EAAsBC,OAAOP,EAAMlC,kBAAoB,GAAE,IAGrFN,EAA8B0C,KAAKM,IAAIC,MAAM,KAAMH,EACvD,CAEA,OAAO9C,CAAAA,EAkBPkD,eAfmBC,GACFlD,EAASC,MAAMe,QAAOC,GAAQA,EAAKd,WAAa+C,IAEjD,GAahBC,kBAVsBC,IACtB,IAAKA,EAAM,MAAM,IAAIC,MAAM,+DAC3B,MAAgB,SAATD,GAA4B,WAATA,CAAS,EASnCzB,WAAY3B,EAAS2B,WACrB2B,SAAUtD,EAASC"}
|
|
1
|
+
{"version":3,"file":"cardType.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/utils/cardType.ts"],"sourcesContent":["import { CardObject } from '../../types';\nimport { hasOwnProperty } from '../../../../../../utils/hasOwnProperty';\n\nlet shortestPermittedCardLength;\n\ninterface CardType {\n __NO_BRAND?: string;\n cards?: CardObject[];\n}\n\nconst CardType: CardType = {};\nCardType.__NO_BRAND = 'noBrand';\n\nCardType.cards = [];\n\nCardType.cards.push({\n cardType: 'mc',\n startingRules: [51, 52, 53, 54, 55, 22, 23, 24, 25, 26, 27],\n permittedLengths: [16],\n pattern: /^(5[1-5][0-9]{0,14}|2[2-7][0-9]{0,14})$/,\n securityCode: 'CVC'\n});\n\nCardType.cards.push({ cardType: 'visadankort', startingRules: [4571], permittedLengths: [16], pattern: /^(4571)[0-9]{0,12}$/ });\n\nCardType.cards.push({\n cardType: 'visa',\n startingRules: [4],\n permittedLengths: [13, 16, 19],\n pattern: /^4[0-9]{0,18}$/,\n securityCode: 'CVV'\n});\n\nCardType.cards.push({ cardType: 'amex', startingRules: [34, 37], permittedLengths: [15], pattern: /^3[47][0-9]{0,13}$/, securityCode: 'CID' });\n\nCardType.cards.push({ cardType: 'diners', startingRules: [36], permittedLengths: [14, 16], pattern: /^(36)[0-9]{0,12}$/ });\n\nCardType.cards.push({ cardType: 'maestrouk', startingRules: [6759], permittedLengths: [16, 18, 19], pattern: /^(6759)[0-9]{0,15}$/ });\n\nCardType.cards.push({ cardType: 'solo', startingRules: [6767], permittedLengths: [16, 18, 19], pattern: /^(6767)[0-9]{0,15}$/ });\n\nCardType.cards.push({\n cardType: 'laser',\n startingRules: [6304, 6706, 677117, 677120],\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(6304|6706|6709|6771)[0-9]{0,15}$/,\n cvcPolicy: 'optional'\n});\n\nCardType.cards.push({\n cardType: 'discover',\n startingRules: [6011, 644, 645, 646, 647, 648, 649, 65],\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(6011[0-9]{0,12}|(644|645|646|647|648|649)[0-9]{0,13}|65[0-9]{0,14})$/\n});\n\nCardType.cards.push({\n cardType: 'jcb',\n startingRules: [3528, 3529, 353, 354, 355, 356, 357, 358],\n permittedLengths: [16, 19],\n pattern: /^(352[8,9]{1}[0-9]{0,15}|35[4-8]{1}[0-9]{0,16})$/,\n securityCode: 'CAV'\n});\n\nCardType.cards.push({\n cardType: 'bcmc',\n startingRules: [6703, 479658, 606005],\n permittedLengths: [16, 17, 18, 19],\n pattern: /^((6703)[0-9]{0,15}|(479658|606005)[0-9]{0,13})$/,\n cvcPolicy: 'hidden'\n});\n\nCardType.cards.push({ cardType: 'bijcard', startingRules: [5100081], permittedLengths: [16], pattern: /^(5100081)[0-9]{0,9}$/ });\n\nCardType.cards.push({ cardType: 'dankort', startingRules: [5019], permittedLengths: [16], pattern: /^(5019)[0-9]{0,12}$/ });\n\nCardType.cards.push({ cardType: 'hipercard', startingRules: [606282], permittedLengths: [16], pattern: /^(606282)[0-9]{0,10}$/ });\n\n// Moved above maestro (from position below uatp) to stop maestro being recognised over cup\nCardType.cards.push({ cardType: 'cup', startingRules: [62, 81], permittedLengths: [14, 15, 16, 17, 18, 19], pattern: /^(62|81)[0-9]{0,17}$/ }); // orig & android v1 + modified to include our test cards (81...)\n\nCardType.cards.push({\n cardType: 'maestro',\n startingRules: [50, 56, 57, 58, 6],\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(5[0|6-8][0-9]{0,17}|6[0-9]{0,18})$/,\n cvcPolicy: 'optional'\n});\n\nCardType.cards.push({\n cardType: 'elo',\n // prettier-ignore\n startingRules: [506699, 50670, 50671, 50672, 50673, 50674, 50675, 50676, 506770, 506771, 506772, 506773, 506774, 506775, 506776, 506777, 506778, 401178, 438935, 451416, 457631, 457632, 504175, 627780, 636297, 636368], // eslint-disable-line max-len\n permittedLengths: [16],\n // prettier-ignore\n pattern:\n /^((((506699)|(506770)|(506771)|(506772)|(506773)|(506774)|(506775)|(506776)|(506777)|(506778)|(401178)|(438935)|(451416)|(457631)|(457632)|(504175)|(627780)|(636368)|(636297))[0-9]{0,10})|((50676)|(50675)|(50674)|(50673)|(50672)|(50671)|(50670))[0-9]{0,11})$/ // eslint-disable-line max-len\n});\n\nCardType.cards.push({ cardType: 'uatp', startingRules: [1], permittedLengths: [15], pattern: /^1[0-9]{0,14}$/, cvcPolicy: 'optional' });\n\nCardType.cards.push({\n cardType: 'cartebancaire',\n startingRules: [4, 5, 6],\n permittedLengths: [16],\n pattern: /^[4-6][0-9]{0,15}$/\n});\n\nCardType.cards.push({ cardType: 'visaalphabankbonus', startingRules: [450903], permittedLengths: [16], pattern: /^(450903)[0-9]{0,10}$/ });\n\nCardType.cards.push({ cardType: 'mcalphabankbonus', startingRules: [510099], permittedLengths: [16], pattern: /^(510099)[0-9]{0,10}$/ });\n\nCardType.cards.push({\n cardType: 'hiper',\n startingRules: [637095, 637568, 637599, 637609, 637612],\n permittedLengths: [16],\n pattern: /^(637095|637568|637599|637609|637612)[0-9]{0,10}$/\n});\n\nCardType.cards.push({ cardType: 'oasis', startingRules: [982616], permittedLengths: [16], pattern: /^(982616)[0-9]{0,10}$/, cvcPolicy: 'optional' });\n\nCardType.cards.push({\n cardType: 'karenmillen',\n startingRules: [98261465],\n permittedLengths: [16],\n pattern: /^(98261465)[0-9]{0,8}$/,\n cvcPolicy: 'optional'\n});\n\nCardType.cards.push({\n cardType: 'warehouse',\n startingRules: [982633],\n permittedLengths: [16],\n pattern: /^(982633)[0-9]{0,10}$/,\n cvcPolicy: 'optional'\n});\n\nCardType.cards.push({ cardType: 'mir', startingRules: [220], permittedLengths: [16, 17, 18, 19], pattern: /^(220)[0-9]{0,16}$/ });\n\nCardType.cards.push({ cardType: 'codensa', startingRules: [590712], permittedLengths: [16], pattern: /^(590712)[0-9]{0,10}$/ });\n\nCardType.cards.push({\n cardType: 'naranja',\n startingRules: [377798, 377799, 402917, 402918, 527571, 527572, 589562],\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(37|40|5[28])([279])\\d*$/\n});\n\n// TODO: 589657 clashes with naranja, rest ok\nCardType.cards.push({\n cardType: 'cabal',\n startingRules: [589657, 600691, 603522, 6042, 6043, 636908],\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(58|6[03])([03469])\\d*$/\n});\n\nCardType.cards.push({\n cardType: 'shopping',\n startingRules: [2799, 589407, 603488],\n permittedLengths: [16, 17, 18, 19],\n pattern: /^(27|58|60)([39])\\d*$/\n});\n\nCardType.cards.push({ cardType: 'argencard', startingRules: [501], permittedLengths: [16, 17, 18, 19], pattern: /^(50)(1)\\d*$/ }); // NOTE: starting rule changed, from 501105, to not clash with dankort. Plus it now matches its regEx!\n\nCardType.cards.push({ cardType: 'troy', startingRules: [9792], permittedLengths: [16], pattern: /^(97)(9)\\d*$/ });\n\n// TODO: clashes with cabal\nCardType.cards.push({ cardType: 'forbrugsforeningen', startingRules: [600722], permittedLengths: [16], pattern: /^(60)(0)\\d*$/ });\n\nCardType.cards.push({\n cardType: 'vpay',\n startingRules: [401, 408, 413, 434, 435, 437, 439, 441, 442, 443, 444, 446, 447, 455, 458, 460, 461, 463, 466, 471, 479, 482, 483, 487],\n permittedLengths: [13, 14, 15, 16, 17, 18, 19],\n pattern: /^(40[1,8]|413|43[4,5]|44[1,2,3,4,6,7]|45[5,8]|46[0,1,3,6]|47[1,9]|48[2,3,7])[0-9]{0,16}$/ // ^(4[0-1|3-8][0-9]{1,17})$\n});\n\nCardType.cards.push({\n cardType: 'rupay',\n startingRules: [508528],\n permittedLengths: [16],\n // prettier-ignore\n pattern:\n /^(100003|508(2|[5-9])|60(69|[7-8])|652(1[5-9]|[2-5][0-9]|8[5-9])|65300[3-4]|8172([0-1]|[3-5]|7|9)|817(3[3-8]|40[6-9]|410)|35380([0-2]|[5-6]|9))[0-9]{0,12}$/ // eslint-disable-line max-len\n});\n\nCardType.cards.push({\n cardType: 'ticket',\n expiryDatePolicy: 'hidden'\n});\n\nconst detectCard = (pCardNumber, pAvailableCards?) => {\n let matchedCards;\n let i;\n let len;\n\n if (pAvailableCards) {\n // Filter CardType.cards down to those that are found in pAvailableCards\n matchedCards = CardType.cards\n .filter(card => pAvailableCards.includes(card.cardType))\n // Further filter them to those with a regEx pattern that matches pCardNumber\n .filter(card => hasOwnProperty(card, 'pattern') && pCardNumber.match(card.pattern));\n\n // If we have matched cards: if there's only one - return it; else return the one with the longest startingRule\n if (matchedCards.length) {\n if (matchedCards.length === 1) {\n return matchedCards[0];\n }\n\n // Find longest rule for each matched card & store it as a property on the card\n for (i = 0, len = matchedCards.length; i < len; i += 1) {\n if (!matchedCards[i].longestRule) {\n const longestRule = matchedCards[i].startingRules.reduce((a, b) => (a > b ? a : b));\n // What we actually store is how many chars are in the rule\n matchedCards[i].longestRule = String(longestRule).length;\n }\n }\n\n // Based on each matched cards longest rule - find the card with the longest one!\n return matchedCards.reduce((a, b) => (a.longestRule >= b.longestRule ? a : b));\n }\n\n return { cardType: CardType.__NO_BRAND };\n }\n\n return { cardType: CardType.__NO_BRAND };\n};\n\nconst detectCardLength = (pCard, pUnformattedVal) => {\n let maxLength;\n let shortenedNewValue;\n let lengthDiff = 0;\n let reachedValidLength = false;\n let unformattedVal = pUnformattedVal;\n\n // Find the longest of the permitted card number lengths for this card brand\n const maxPermittedLength = pCard.cardType !== CardType.__NO_BRAND ? pCard.permittedLengths[pCard.permittedLengths.length - 1] : 0;\n\n // If the input value is longer than it's max permitted length then shorten it to that length\n if (maxPermittedLength && unformattedVal > maxPermittedLength) {\n lengthDiff = unformattedVal.length - maxPermittedLength;\n\n if (lengthDiff > 0) {\n unformattedVal = unformattedVal.substring(0, unformattedVal.length - lengthDiff);\n shortenedNewValue = unformattedVal;\n }\n }\n\n // If cardNumber has reached one of the cardBrand's 'permitted lengths' - mark it as 'valid'\n pCard.permittedLengths.forEach(pItem => {\n if (unformattedVal.length === pItem) {\n reachedValidLength = true;\n }\n });\n\n // If cardNumber is as long as the cardBrand's maximum permitted length then set the maxLength var\n if (unformattedVal.length === maxPermittedLength) {\n // Set maxlength to max + the right amount of spaces (one for every 4 digits, but not on the last block)\n const div = Math.floor(unformattedVal.length / 4);\n const mod = unformattedVal.length % 4;\n const numSpaces = mod > 0 ? div : div - 1;\n\n maxLength = maxPermittedLength + numSpaces;\n\n if (pCard.cardType.toLowerCase() === 'amex') {\n maxLength = maxPermittedLength + 2; // = 17 = 15 digits with space after 4th & 10th\n }\n }\n\n return {\n shortenedNewValue,\n maxLength,\n reachedValidLength\n };\n};\n\nconst getShortestPermittedCardLength = () => {\n if (!shortestPermittedCardLength) {\n let permittedLengthsArray = [];\n\n CardType.cards.forEach(pItem => {\n permittedLengthsArray = permittedLengthsArray.concat(pItem.permittedLengths ?? []);\n });\n\n shortestPermittedCardLength = Math.min.apply(null, permittedLengthsArray);\n }\n\n return shortestPermittedCardLength;\n};\n\nconst getCardByBrand = pBrand => {\n const cardType = CardType.cards.filter(card => card.cardType === pBrand);\n\n return cardType[0];\n};\n\nconst isGenericCardType = type => {\n if (!type) throw new Error('Error: isGenericCardType: type param has not been specified');\n return type === 'card' || type === 'scheme';\n};\n\nexport default {\n detectCard,\n detectCardLength,\n getShortestPermittedCardLength,\n getCardByBrand,\n isGenericCardType,\n __NO_BRAND: CardType.__NO_BRAND,\n allCards: CardType.cards\n};\n"],"names":["shortestPermittedCardLength","CardType","cards","push","cardType","startingRules","permittedLengths","pattern","securityCode","cvcPolicy","expiryDatePolicy","detectCard","pCardNumber","pAvailableCards","matchedCards","i","len","filter","card","includes","hasOwnProperty","match","length","longestRule","reduce","a","b","String","__NO_BRAND","detectCardLength","pCard","pUnformattedVal","maxLength","shortenedNewValue","lengthDiff","reachedValidLength","unformattedVal","maxPermittedLength","substring","forEach","pItem","div","Math","floor","toLowerCase","getShortestPermittedCardLength","permittedLengthsArray","concat","min","apply","getCardByBrand","pBrand","isGenericCardType","type","Error","allCards"],"mappings":"2EAGA,IAAIA,EAOJ,MAAMC,EAAqB,CAC3BA,WAAsB,UAEtBA,MAAiB,IAEjBA,EAASC,MAAMC,KAAK,CAChBC,SAAU,KACVC,cAAe,CAAC,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,GAAI,IACxDC,iBAAkB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
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{hasOwnProperty as r}from"../../../../../../utils/hasOwnProperty.js";const e=(e,o,l,t,n)=>{if(!r(e,"error"))return null;const p=o,s={rootNode:t,fieldType:e.fieldType,error:null,type:null},u=""!==e.error;return u||p.hasError?(s.error=u?e.error:"",s.type=l,p.hasError=u,p.errorType=s.error,n(s),s):null};export{e as processErrors};
|
|
2
2
|
//# sourceMappingURL=processErrors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processErrors.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/utils/processErrors.ts"],"sourcesContent":["import { CbObjOnError, SFFeedbackObj } from '../../types';\nimport SecuredField from '../../securedField/SecuredField';\nimport {
|
|
1
|
+
{"version":3,"file":"processErrors.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/utils/processErrors.ts"],"sourcesContent":["import { CbObjOnError, SFFeedbackObj } from '../../types';\nimport SecuredField from '../../securedField/SecuredField';\nimport { hasOwnProperty } from '../../../../../../utils/hasOwnProperty';\n\ntype RtnType_callbackFn = (obj: CbObjOnError) => void;\n\nexport const processErrors = (\n pFeedbackObj: SFFeedbackObj,\n securedField: SecuredField,\n type: string,\n rootNode: HTMLElement,\n callbackFn: RtnType_callbackFn\n): CbObjOnError => {\n if (!hasOwnProperty(pFeedbackObj, 'error')) return null;\n\n const fieldType: string = pFeedbackObj.fieldType;\n\n const field: SecuredField = securedField;\n\n // Initialise error callback object\n const dataObj: CbObjOnError = { rootNode, fieldType, error: null, type: null };\n\n const isError: boolean = pFeedbackObj.error !== '';\n\n // Error is empty string && field is not already in error: do nothing - don't need to propagate this non-error if the field wasn't already in error\n // This situation arises when we encrypt a field and trigger an \"error clearing\" event i.e. deleting a character\n // It also arises when an unsupportedCard (re. binLookup) is entered and the shopper continues to interact with the field (adding or deleting digits)\n if (!isError && !field.hasError) {\n return null;\n }\n\n // Add props to error callback object\n dataObj.error = isError ? pFeedbackObj.error : '';\n dataObj.type = type;\n\n // Set error state & type on securedField instance\n field.hasError = isError;\n field.errorType = dataObj.error;\n\n callbackFn(dataObj);\n\n return dataObj;\n};\n"],"names":["processErrors","pFeedbackObj","securedField","type","rootNode","callbackFn","hasOwnProperty","field","dataObj","fieldType","error","isError","hasError","errorType"],"mappings":"iFAMaA,EAAgB,CACzBC,EACAC,EACAC,EACAC,EACAC,KAEA,IAAKC,EAAeL,EAAc,SAAU,OAAO,KAEnD,MAEMM,EAAsBL,EAGtBM,EAAwB,CAAEJ,WAAUK,UALhBR,EAAaQ,UAKcC,MAAO,KAAMP,KAAM,MAElEQ,EAA0C,KAAvBV,EAAaS,MAKtC,OAAKC,GAAYJ,EAAMK,UAKvBJ,EAAQE,MAAQC,EAAUV,EAAaS,MAAQ,GAC/CF,EAAQL,KAAOA,EAGfI,EAAMK,SAAWD,EACjBJ,EAAMM,UAAYL,EAAQE,MAE1BL,EAAWG,GAEJA,GAbI,IAaJA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e="encrypted",r="encryptedCardNumber",c="encryptedExpiryDate",t="encryptedExpiryMonth",a="encryptedExpiryYear",d="encryptedSecurityCode",i="encryptedPassword",n="encryptedBankAccountNumber",o="encryptedBankLocationId",s="encryptedSecurityCode3digits",y="encryptedSecurityCode4digits",p="giftcard",u="
|
|
1
|
+
const e="encrypted",r="encryptedCardNumber",c="encryptedExpiryDate",t="encryptedExpiryMonth",a="encryptedExpiryYear",d="encryptedSecurityCode",i="encryptedPassword",n="encryptedBankAccountNumber",o="encryptedBankLocationId",s="encryptedSecurityCode3digits",y="encryptedSecurityCode4digits",p="giftcard",u="5.0.1",m=["amex","mc","visa"],C=["ach",p],b=[r,c,t,a,d,i],x=[n,o],h=b.concat(x),D=["bcmc"],g="required",k="optional",B="hidden",l=g,v=k,A=B,E=g,M=k,N=B,S="data-cse",f="data-info",j="data-uid",I=["accel","pulse","star","nyce"],w={visa:"VISA",mc:"MasterCard",amex:"American Express",discover:"Discover",cup:"China Union Pay",jcb:"JCB",diners:"Diners Club",maestro:"Maestro",bcmc:"Bancontact card",bijcard:"de Bijenkorf Card"},L={[r]:"cardNumber",[c]:"expiryDate",[d]:"securityCode",[t]:"expiryMonth",[a]:"expiryYear",[i]:"password",[n]:"bankAccountNumber",[o]:"bankLocationId",[s]:"securityCodeThreeDigits",[y]:"securityCodeFourDigits"},P=6e3;export{h as ALL_SECURED_FIELDS,I as BRAND_ICON_UI_EXCLUSION_LIST,w as BRAND_READABLE_NAME_MAP,b as CREDIT_CARD_SF_FIELDS,A as CVC_POLICY_HIDDEN,v as CVC_POLICY_OPTIONAL,l as CVC_POLICY_REQUIRED,S as DATA_ENCRYPTED_FIELD_ATTR,f as DATA_INFO,j as DATA_UID,N as DATE_POLICY_HIDDEN,M as DATE_POLICY_OPTIONAL,E as DATE_POLICY_REQUIRED,D as DEDICATED_CARD_COMPONENTS,m as DEFAULT_CARD_GROUP_TYPES,e as ENCRYPTED,n as ENCRYPTED_BANK_ACCNT_NUMBER_FIELD,o as ENCRYPTED_BANK_LOCATION_FIELD,r as ENCRYPTED_CARD_NUMBER,c as ENCRYPTED_EXPIRY_DATE,t as ENCRYPTED_EXPIRY_MONTH,a as ENCRYPTED_EXPIRY_YEAR,i as ENCRYPTED_PWD_FIELD,d as ENCRYPTED_SECURITY_CODE,s as ENCRYPTED_SECURITY_CODE_3_DIGITS,y as ENCRYPTED_SECURITY_CODE_4_DIGITS,p as GIFT_CARD,B as HIDDEN,C as NON_CREDIT_CARD_TYPE_SECURED_FIELDS,k as OPTIONAL,x as OTHER_SF_FIELDS,g as REQUIRED,P as SF_CONFIG_TIMEOUT,L as SF_FIELDS_MAP,u as SF_VERSION};
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../../../../../src/components/internal/SecuredFields/lib/configuration/constants.ts"],"sourcesContent":["import { CVCPolicyType, DatePolicyType } from '../types';\n\nexport const ENCRYPTED = 'encrypted';\n\nexport const ENCRYPTED_CARD_NUMBER = 'encryptedCardNumber';\nexport const ENCRYPTED_EXPIRY_DATE = 'encryptedExpiryDate';\nexport const ENCRYPTED_EXPIRY_MONTH = 'encryptedExpiryMonth';\nexport const ENCRYPTED_EXPIRY_YEAR = 'encryptedExpiryYear';\nexport const ENCRYPTED_SECURITY_CODE = 'encryptedSecurityCode';\nexport const ENCRYPTED_PWD_FIELD = 'encryptedPassword';\nexport const ENCRYPTED_PIN_FIELD = 'encryptedPin';\nexport const ENCRYPTED_BANK_ACCNT_NUMBER_FIELD = 'encryptedBankAccountNumber';\nexport const ENCRYPTED_BANK_LOCATION_FIELD = 'encryptedBankLocationId';\n\nexport const ENCRYPTED_SECURITY_CODE_3_DIGITS = 'encryptedSecurityCode3digits';\nexport const ENCRYPTED_SECURITY_CODE_4_DIGITS = 'encryptedSecurityCode4digits';\n\nexport const GIFT_CARD = 'giftcard';\n\nexport const SF_VERSION = '
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../../../../src/components/internal/SecuredFields/lib/configuration/constants.ts"],"sourcesContent":["import { CVCPolicyType, DatePolicyType } from '../types';\n\nexport const ENCRYPTED = 'encrypted';\n\nexport const ENCRYPTED_CARD_NUMBER = 'encryptedCardNumber';\nexport const ENCRYPTED_EXPIRY_DATE = 'encryptedExpiryDate';\nexport const ENCRYPTED_EXPIRY_MONTH = 'encryptedExpiryMonth';\nexport const ENCRYPTED_EXPIRY_YEAR = 'encryptedExpiryYear';\nexport const ENCRYPTED_SECURITY_CODE = 'encryptedSecurityCode';\nexport const ENCRYPTED_PWD_FIELD = 'encryptedPassword';\nexport const ENCRYPTED_PIN_FIELD = 'encryptedPin';\nexport const ENCRYPTED_BANK_ACCNT_NUMBER_FIELD = 'encryptedBankAccountNumber';\nexport const ENCRYPTED_BANK_LOCATION_FIELD = 'encryptedBankLocationId';\n\nexport const ENCRYPTED_SECURITY_CODE_3_DIGITS = 'encryptedSecurityCode3digits';\nexport const ENCRYPTED_SECURITY_CODE_4_DIGITS = 'encryptedSecurityCode4digits';\n\nexport const GIFT_CARD = 'giftcard';\n\nexport const SF_VERSION = '5.0.1';\n\nexport const DEFAULT_CARD_GROUP_TYPES = ['amex', 'mc', 'visa'];\n\nexport const NON_CREDIT_CARD_TYPE_SECURED_FIELDS = ['ach', GIFT_CARD]; // Maybe, sometime in the future will include 'sepa' & 'sepadirectdebit'\n\n// Credit card (CardInput) related securedFields (based on the data-cse attribute)\nexport const CREDIT_CARD_SF_FIELDS = [\n ENCRYPTED_CARD_NUMBER,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR,\n ENCRYPTED_SECURITY_CODE,\n ENCRYPTED_PWD_FIELD\n // ENCRYPTED_PIN_FIELD,// probably redundant - it was an alt. name for KCP's encryptedPassword. But maybe has a role to play if we ever encrypt ibans.\n];\n\nexport const OTHER_SF_FIELDS = [ENCRYPTED_BANK_ACCNT_NUMBER_FIELD, ENCRYPTED_BANK_LOCATION_FIELD]; // ACH fields\n\n/** A list of all the data-cse attributes that relate to securedFields (as found in card, giftcard or ach) */\nexport const ALL_SECURED_FIELDS = CREDIT_CARD_SF_FIELDS.concat(OTHER_SF_FIELDS);\n\n// Card components created as: checkout.create({BRAND}) e.g. checkout.create('bcmc')\n// - which are dedicated to a single, core, brand e.g. 'bcmc' BUT which can in effect handle multiple brands e.g. \"bcmc\", \"maestro\", \"visa\"\nexport const DEDICATED_CARD_COMPONENTS = ['bcmc'];\n\nexport const REQUIRED = 'required';\nexport const OPTIONAL = 'optional';\nexport const HIDDEN = 'hidden';\n\nexport const CVC_POLICY_REQUIRED: CVCPolicyType = REQUIRED;\nexport const CVC_POLICY_OPTIONAL: CVCPolicyType = OPTIONAL;\nexport const CVC_POLICY_HIDDEN: CVCPolicyType = HIDDEN;\n\nexport const DATE_POLICY_REQUIRED: DatePolicyType = REQUIRED;\nexport const DATE_POLICY_OPTIONAL: DatePolicyType = OPTIONAL;\nexport const DATE_POLICY_HIDDEN: DatePolicyType = HIDDEN;\n\nexport const DATA_ENCRYPTED_FIELD_ATTR = 'data-cse';\nexport const DATA_INFO = 'data-info';\nexport const DATA_UID = 'data-uid';\n\nexport const BRAND_ICON_UI_EXCLUSION_LIST = ['accel', 'pulse', 'star', 'nyce'];\n\nexport const BRAND_READABLE_NAME_MAP = {\n visa: 'VISA',\n mc: 'MasterCard',\n amex: 'American Express',\n discover: 'Discover',\n cup: 'China Union Pay',\n jcb: 'JCB',\n diners: 'Diners Club',\n maestro: 'Maestro',\n bcmc: 'Bancontact card',\n bijcard: 'de Bijenkorf Card'\n};\n\nexport const SF_FIELDS_MAP = {\n [ENCRYPTED_CARD_NUMBER]: 'cardNumber', // ph\n [ENCRYPTED_EXPIRY_DATE]: 'expiryDate', // ph\n [ENCRYPTED_SECURITY_CODE]: 'securityCode',\n [ENCRYPTED_EXPIRY_MONTH]: 'expiryMonth', // ph\n [ENCRYPTED_EXPIRY_YEAR]: 'expiryYear', // ph\n //\n [ENCRYPTED_PWD_FIELD]: 'password',\n [ENCRYPTED_BANK_ACCNT_NUMBER_FIELD]: 'bankAccountNumber',\n [ENCRYPTED_BANK_LOCATION_FIELD]: 'bankLocationId',\n //\n [ENCRYPTED_SECURITY_CODE_3_DIGITS]: 'securityCodeThreeDigits', // ph\n [ENCRYPTED_SECURITY_CODE_4_DIGITS]: 'securityCodeFourDigits' // ph\n};\n\n/** time within which we expect to receive a \"configured\" message from a securedField iframe, once it has registered as having loaded */\nexport const SF_CONFIG_TIMEOUT = 6000;\n"],"names":["ENCRYPTED","ENCRYPTED_CARD_NUMBER","ENCRYPTED_EXPIRY_DATE","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","ENCRYPTED_SECURITY_CODE","ENCRYPTED_PWD_FIELD","ENCRYPTED_BANK_ACCNT_NUMBER_FIELD","ENCRYPTED_BANK_LOCATION_FIELD","ENCRYPTED_SECURITY_CODE_3_DIGITS","ENCRYPTED_SECURITY_CODE_4_DIGITS","GIFT_CARD","SF_VERSION","DEFAULT_CARD_GROUP_TYPES","NON_CREDIT_CARD_TYPE_SECURED_FIELDS","CREDIT_CARD_SF_FIELDS","OTHER_SF_FIELDS","ALL_SECURED_FIELDS","concat","DEDICATED_CARD_COMPONENTS","REQUIRED","OPTIONAL","HIDDEN","CVC_POLICY_REQUIRED","CVC_POLICY_OPTIONAL","CVC_POLICY_HIDDEN","DATE_POLICY_REQUIRED","DATE_POLICY_OPTIONAL","DATE_POLICY_HIDDEN","DATA_ENCRYPTED_FIELD_ATTR","DATA_INFO","DATA_UID","BRAND_ICON_UI_EXCLUSION_LIST","BRAND_READABLE_NAME_MAP","visa","mc","amex","discover","cup","jcb","diners","maestro","bcmc","bijcard","SF_FIELDS_MAP","SF_CONFIG_TIMEOUT"],"mappings":"AAEO,MAAMA,EAAY,YAEZC,EAAwB,sBACxBC,EAAwB,sBACxBC,EAAyB,uBACzBC,EAAwB,sBACxBC,EAA0B,wBAC1BC,EAAsB,oBAEtBC,EAAoC,6BACpCC,EAAgC,0BAEhCC,EAAmC,+BACnCC,EAAmC,+BAEnCC,EAAY,WAEZC,EAAa,QAEbC,EAA2B,CAAC,OAAQ,KAAM,QAE1CC,EAAsC,CAAC,MAAOH,GAG9CI,EAAwB,CACjCd,EACAC,EACAC,EACAC,EACAC,EACAC,GAISU,EAAkB,CAACT,EAAmCC,GAGtDS,EAAqBF,EAAsBG,OAAOF,GAIlDG,EAA4B,CAAC,QAE7BC,EAAW,WACXC,EAAW,WACXC,EAAS,SAETC,EAAqCH,EACrCI,EAAqCH,EACrCI,EAAmCH,EAEnCI,EAAuCN,EACvCO,EAAuCN,EACvCO,EAAqCN,EAErCO,EAA4B,WAC5BC,EAAY,YACZC,EAAW,WAEXC,EAA+B,CAAC,QAAS,QAAS,OAAQ,QAE1DC,EAA0B,CACnCC,KAAM,OACNC,GAAI,aACJC,KAAM,mBACNC,SAAU,WACVC,IAAK,kBACLC,IAAK,MACLC,OAAQ,cACRC,QAAS,UACTC,KAAM,kBACNC,QAAS,qBAGAC,EAAgB,CACzB3C,CAACA,GAAwB,aACzBC,CAACA,GAAwB,aACzBG,CAACA,GAA0B,eAC3BF,CAACA,GAAyB,cAC1BC,CAACA,GAAwB,aAEzBE,CAACA,GAAsB,WACvBC,CAACA,GAAoC,oBACrCC,CAACA,GAAgC,iBAEjCC,CAACA,GAAmC,0BACpCC,CAACA,GAAmC,0BAI3BmC,EAAoB"}
|
package/dist/es/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractSecuredField.js","sources":["../../../../../../../src/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"AbstractSecuredField.js","sources":["../../../../../../../src/components/internal/SecuredFields/lib/securedField/AbstractSecuredField.ts"],"sourcesContent":["import {\n CVCPolicyType,\n DatePolicyType,\n RtnType_callbackFn,\n RtnType_noParamVoidFn,\n RtnType_postMessageListener,\n SecuredFieldCommonProps\n} from '../types';\n\nabstract class AbstractSecuredField {\n public sfConfig: SecuredFieldCommonProps; // could be protected but needs to be public for tests to run\n protected loadingContext: string;\n protected holderEl: HTMLElement;\n protected iframeRef: HTMLElement;\n public loadToConfigTimeout: number;\n // From getters/setters with the same name\n protected _isValid: boolean;\n protected _iframeContentWindow: Window;\n protected _numKey: number;\n protected _isEncrypted: boolean;\n protected _hasError: boolean;\n protected _errorType: string;\n protected _cvcPolicy: CVCPolicyType;\n protected _expiryDatePolicy: DatePolicyType;\n protected _iframeOnLoadListener: RtnType_noParamVoidFn;\n protected _postMessageListener: RtnType_postMessageListener;\n // Callback fns assigned via public functions\n protected onIframeLoadedCallback: RtnType_noParamVoidFn;\n protected onConfigCallback: RtnType_callbackFn;\n protected onEncryptionCallback: RtnType_callbackFn;\n protected onValidationCallback: RtnType_callbackFn;\n protected onFocusCallback: RtnType_callbackFn;\n protected onBinValueCallback: RtnType_callbackFn;\n protected onTouchstartCallback: RtnType_callbackFn;\n protected onShiftTabCallback: RtnType_callbackFn;\n protected onAutoCompleteCallback: RtnType_callbackFn;\n\n protected constructor() {\n this.sfConfig = {} as any as SecuredFieldCommonProps;\n }\n}\n\nexport default AbstractSecuredField;\n"],"names":["AbstractSecuredField","sfConfig","loadingContext","holderEl","iframeRef","loadToConfigTimeout","_isValid","_iframeContentWindow","_numKey","_isEncrypted","_hasError","_errorType","_cvcPolicy","_expiryDatePolicy","_iframeOnLoadListener","_postMessageListener","onIframeLoadedCallback","onConfigCallback","onEncryptionCallback","onValidationCallback","onFocusCallback","onBinValueCallback","onTouchstartCallback","onShiftTabCallback","onAutoCompleteCallback","constructor","this"],"mappings":"AASA,MAAeA,EACJC,SACGC,eACAC,SACAC,UACHC,oBAEGC,SACAC,qBACAC,QACAC,aACAC,UACAC,WACAC,WACAC,kBACAC,sBACAC,qBAEAC,uBACAC,iBACAC,qBACAC,qBACAC,gBACAC,mBACAC,qBACAC,mBACAC,uBAEV,WAAAC,GACIC,KAAKzB,SAAW,EACpB"}
|